@jbrowse/plugin-authentication 4.0.4 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,15 +2,8 @@ import { ConfigurationReference, getConf } from '@jbrowse/core/configuration';
2
2
  import { InternetAccount } from '@jbrowse/core/pluggableElementTypes/models';
3
3
  import { isElectron } from '@jbrowse/core/util';
4
4
  import { types } from '@jbrowse/mobx-state-tree';
5
- import { fixup, generateChallenge, processError, processTokenResponse, } from "./util.js";
5
+ import { generateChallenge, processError, processTokenResponse, toBase64Url, } from "./util.js";
6
6
  import { getResponseError } from "../util.js";
7
- function encode(uint8array) {
8
- const output = [];
9
- for (let i = 0, length = uint8array.length; i < length; i++) {
10
- output.push(String.fromCharCode(uint8array[i]));
11
- }
12
- return btoa(output.join(''));
13
- }
14
7
  const stateModelFactory = (configSchema) => {
15
8
  return InternetAccount.named('OAuthInternetAccount')
16
9
  .props({
@@ -24,7 +17,7 @@ const stateModelFactory = (configSchema) => {
24
17
  if (!codeVerifier) {
25
18
  const array = new Uint8Array(32);
26
19
  globalThis.crypto.getRandomValues(array);
27
- codeVerifier = fixup(encode(array));
20
+ codeVerifier = toBase64Url(array);
28
21
  }
29
22
  return codeVerifier;
30
23
  },
@@ -1,7 +1,7 @@
1
- export declare function fixup(buf: string): string;
2
1
  export declare function generateChallenge(val: string): Promise<string>;
3
2
  export declare function processError(text: string, invalidErrorCb: () => void): any;
4
3
  export declare function processTokenResponse(data: {
5
4
  refresh_token?: string;
6
5
  access_token: string;
7
6
  }, storeRefreshTokenCb: (str: string) => void): string;
7
+ export { toBase64Url } from '@jbrowse/core/util';
@@ -1,10 +1,6 @@
1
- export function fixup(buf) {
2
- return buf.replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '');
3
- }
1
+ import { sha256Base64Url } from '@jbrowse/core/util';
4
2
  export async function generateChallenge(val) {
5
- const sha256 = await import('crypto-js/sha256').then(f => f.default);
6
- const Base64 = await import('crypto-js/enc-base64');
7
- return fixup(Base64.stringify(sha256(val)));
3
+ return sha256Base64Url(val);
8
4
  }
9
5
  export function processError(text, invalidErrorCb) {
10
6
  try {
@@ -24,3 +20,4 @@ export function processTokenResponse(data, storeRefreshTokenCb) {
24
20
  }
25
21
  return data.access_token;
26
22
  }
23
+ export { toBase64Url } from '@jbrowse/core/util';
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-authentication",
3
- "version": "4.0.4",
3
+ "version": "4.1.0",
4
+ "type": "module",
4
5
  "description": "JBrowse 2 Authentication",
5
6
  "keywords": [
6
7
  "jbrowse",
@@ -21,11 +22,11 @@
21
22
  ],
22
23
  "dependencies": {
23
24
  "@jbrowse/mobx-state-tree": "^5.5.0",
24
- "@mui/material": "^7.3.6",
25
+ "@mui/material": "^7.3.7",
25
26
  "crypto-js": "^4.2.0",
26
27
  "generic-filehandle2": "^2.0.18",
27
28
  "mobx": "^6.15.0",
28
- "@jbrowse/core": "^4.0.4"
29
+ "@jbrowse/core": "^4.1.0"
29
30
  },
30
31
  "peerDependencies": {
31
32
  "react": ">=18.0.0",