coyotte508 HF staff commited on
Commit
497f0f2
1 Parent(s): b198b14

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +13 -0
index.js CHANGED
@@ -16,6 +16,19 @@ function hexFromBytes(arr) {
16
  }
17
  }
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  /**
21
  * Use "Sign in with Hub" to authenticate a user, and get oauth user info / access token.
 
16
  }
17
  }
18
 
19
+ function base64FromBytes(arr) {
20
+ if (globalThis.Buffer) {
21
+ return globalThis.Buffer.from(arr).toString("base64");
22
+ } else {
23
+ const bin = [];
24
+ arr.forEach((byte) => {
25
+ bin.push(String.fromCharCode(byte));
26
+ });
27
+ return globalThis.btoa(bin.join(""));
28
+ }
29
+ }
30
+
31
+
32
 
33
  /**
34
  * Use "Sign in with Hub" to authenticate a user, and get oauth user info / access token.