@arcblock/did-connect-js 1.28.5 → 1.28.7

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.
package/README.md CHANGED
@@ -25,7 +25,7 @@ The following diagram demonstrates how a typical DID Connect Session works:
25
25
  ```sh
26
26
  npm install @arcblock/did-connect-js
27
27
  // or
28
- pnpm install @arcblock/did-connect-js
28
+ bun install @arcblock/did-connect-js
29
29
  ```
30
30
 
31
31
  ## Usage
@@ -1,8 +1,6 @@
1
- /* eslint-disable no-promise-executor-return */
2
1
  const Jwt = require('@arcblock/jwt');
3
2
  const { isValid, fromJSON } = require('@ocap/wallet');
4
3
 
5
- // eslint-disable-next-line
6
4
  const debug = require('debug')(`${require('../../package.json').name}:authenticator:base`);
7
5
 
8
6
  class BaseAuthenticator {
@@ -49,7 +47,7 @@ class BaseAuthenticator {
49
47
  fullWallet.sk = fullWallet.secretKey;
50
48
  }
51
49
  return fullWallet;
52
- } catch (err) {
50
+ } catch (_err) {
53
51
  // If fromJSON fails, return the original object for backward compatibility
54
52
  return wallet;
55
53
  }
@@ -1,7 +1,4 @@
1
- /* eslint-disable no-underscore-dangle */
2
- /* eslint-disable indent */
3
- /* eslint-disable object-curly-newline */
4
- const qs = require('querystring');
1
+ const qs = require('node:querystring');
5
2
  const pick = require('lodash/pick');
6
3
  const random = require('lodash/random');
7
4
  const shuffle = require('lodash/shuffle');
@@ -14,7 +11,6 @@ const { toAddress } = require('@arcblock/did');
14
11
 
15
12
  const BaseAuthenticator = require('./base');
16
13
 
17
- // eslint-disable-next-line
18
14
  const debug = require('debug')(`${require('../../package.json').name}:authenticator:wallet`);
19
15
 
20
16
  const { DEFAULT_CHAIN_INFO } = BaseAuthenticator;
@@ -30,18 +26,18 @@ const formatDisplay = (display) => {
30
26
  }
31
27
 
32
28
  // object like
33
- if (display && display.type && display.content) {
29
+ if (display?.type && display.content) {
34
30
  return JSON.stringify(pick(display, ['type', 'content']));
35
31
  }
36
32
 
37
33
  // string like
38
34
  try {
39
35
  const parsed = JSON.parse(display);
40
- if (parsed && parsed.type && parsed.content) {
36
+ if (parsed?.type && parsed.content) {
41
37
  return display;
42
38
  }
43
39
  return '';
44
- } catch (err) {
40
+ } catch (_err) {
45
41
  return '';
46
42
  }
47
43
  };
@@ -659,7 +655,7 @@ class WalletAuthenticator extends BaseAuthenticator {
659
655
  const description = desc || 'Prepare and sign this transaction to continue.';
660
656
 
661
657
  // We have to encode the transaction
662
- if (type && type.endsWith('Tx')) {
658
+ if (type?.endsWith('Tx')) {
663
659
  if (!chainInfo.host) {
664
660
  throw new Error('Invalid chainInfo when trying to encoding partial transaction');
665
661
  }
@@ -744,7 +740,6 @@ class WalletAuthenticator extends BaseAuthenticator {
744
740
  const inferredLabel = label || asyncFn.name || asyncFn.toString();
745
741
  const invocationStack = new Error(`Timeout at: ${inferredLabel}`).stack;
746
742
 
747
- // eslint-disable-next-line no-async-promise-executor
748
743
  return new Promise(async (resolve, reject) => {
749
744
  const timer = setTimeout(() => {
750
745
  const error = new Error(`Async operation (${inferredLabel}) did not complete within ${timeout} ms`);
@@ -1,4 +1,4 @@
1
- const { EventEmitter } = require('events');
1
+ const { EventEmitter } = require('node:events');
2
2
  const omit = require('lodash/omit');
3
3
 
4
4
  const { PROTECTED_KEYS } = require('../protocol');
@@ -1,7 +1,3 @@
1
- /* eslint-disable no-underscore-dangle */
2
- /* eslint-disable prefer-destructuring */
3
- /* eslint-disable object-curly-newline */
4
- /* eslint-disable consistent-return */
5
1
  const url = require('url');
6
2
  const get = require('lodash/get');
7
3
  const set = require('lodash/set');
@@ -35,8 +31,7 @@ const isUrl = (input) => {
35
31
  return ABSOLUTE_URL_REGEX.test(input);
36
32
  };
37
33
 
38
- // eslint-disable-next-line
39
- const debug = require('debug')(`${require('../../package.json').name}:handlers:util`);
34
+ const _debug = require('debug')(`${require('../../package.json').name}:handlers:util`);
40
35
 
41
36
  const sha3 = Mcrypto.Hasher.SHA3.hash256;
42
37
  const getLocale = (req) => (req.acceptsLanguages('en-US', 'zh-CN') || 'en-US').split('-').shift();
@@ -232,11 +227,9 @@ module.exports = function createHandlers({
232
227
  const firstClaim = defaultSteps[0][keys[0]];
233
228
  if (Array.isArray(firstClaim)) {
234
229
  if (firstClaim[0] === 'authPrincipal') {
235
- // eslint-disable-next-line no-param-reassign
236
230
  authPrincipal = false;
237
231
  }
238
232
  } else if (keys[0] === 'authPrincipal') {
239
- // eslint-disable-next-line no-param-reassign
240
233
  authPrincipal = false;
241
234
  }
242
235
  }
@@ -282,7 +275,7 @@ module.exports = function createHandlers({
282
275
  }
283
276
 
284
277
  // Whether we can skip the authPrincipal step safely
285
- const canSkipConnect = defaultSteps[0] && defaultSteps[0].authPrincipal && defaultSteps[0].authPrincipal.skippable;
278
+ const canSkipConnect = defaultSteps[0]?.authPrincipal?.skippable;
286
279
 
287
280
  const createExtraParams = (locale, params, extra = {}) => {
288
281
  const finalParams = { ...params, ...(extra || {}) };
@@ -300,7 +293,6 @@ module.exports = function createHandlers({
300
293
 
301
294
  const createSessionUpdater =
302
295
  (token, params) =>
303
- // eslint-disable-next-line require-await
304
296
  async (key, value, secure = false) => {
305
297
  const getUpdate = (k, v) => {
306
298
  if (secure && params[encKey]) {
@@ -313,7 +305,7 @@ module.exports = function createHandlers({
313
305
 
314
306
  // If key is an object, update multiple keys
315
307
  if (typeof key === 'object') {
316
- secure = value; // eslint-disable-line no-param-reassign
308
+ secure = value;
317
309
  const keys = Object.keys(key);
318
310
  const updates = Object.assign(...keys.map((k) => getUpdate(k, key[k])));
319
311
  return tokenStorage.update(token, updates);
@@ -525,7 +517,6 @@ module.exports = function createHandlers({
525
517
  return false;
526
518
  };
527
519
 
528
- // eslint-disable-next-line consistent-return
529
520
  const onAuthRequest = async (req, res) => {
530
521
  const { locale, token, store, params, didwallet } = req.context;
531
522
  const extraParams = createExtraParams(locale, params, get(store, 'extraParams', {}));
@@ -614,7 +605,6 @@ module.exports = function createHandlers({
614
605
  }
615
606
  };
616
607
 
617
- // eslint-disable-next-line consistent-return
618
608
  const onAuthResponse = async (req, res) => {
619
609
  const { locale, token, store, params, didwallet } = req.context;
620
610
 
@@ -773,7 +763,7 @@ module.exports = function createHandlers({
773
763
  // Instead, save the relationship between the two
774
764
  // Then, mark both session as complete on nextWorkflow complete
775
765
  // In theory, we can use this mechanism to concat infinite sessions
776
- if (result && result.nextToken && result.nextWorkflow) {
766
+ if (result?.nextToken && result.nextWorkflow) {
777
767
  try {
778
768
  await tokenStorage.update(result.nextToken, { prevToken: token });
779
769
  } catch (err) {
@@ -850,7 +840,7 @@ module.exports = function createHandlers({
850
840
  }
851
841
  };
852
842
 
853
- const ensureContext = async (req, res, next) => {
843
+ const ensureContext = async (req, _res, next) => {
854
844
  const didwallet = parseWalletUA(req.query['user-agent'] || req.headers['user-agent']);
855
845
  const params = { ...req.body, ...req.query, ...req.params };
856
846
  const token = params[tokenKey];
@@ -1,5 +1,3 @@
1
- /* eslint-disable object-curly-newline */
2
- // eslint-disable-next-line
3
1
  const debug = require('debug')(`${require('../../package.json').name}:handlers:wallet`);
4
2
 
5
3
  const cors = require('cors');
@@ -84,7 +82,6 @@ class WalletHandlers extends BaseHandler {
84
82
  onDecline = noop,
85
83
  onComplete = noop,
86
84
  onExpire = noop,
87
- // eslint-disable-next-line no-console
88
85
  onError = console.error,
89
86
  authPrincipal = true,
90
87
  persistentDynamicClaims = false,
@@ -105,7 +102,6 @@ class WalletHandlers extends BaseHandler {
105
102
  const pathname = `${prefix}/${action}/auth`;
106
103
  debug('attach routes', { action, prefix, pathname });
107
104
 
108
- // eslint-disable-next-line consistent-return
109
105
  const onConnectWrapped = async (...args) => {
110
106
  if (typeof this.onConnect === 'function') {
111
107
  await this.onConnect(...args);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arcblock/did-connect-js",
3
3
  "description": "Helper function to setup DID Connect support on a node.js web server",
4
- "version": "1.28.5",
4
+ "version": "1.28.7",
5
5
  "author": {
6
6
  "name": "wangshijun",
7
7
  "email": "shijun@arcblock.io",
@@ -18,29 +18,28 @@
18
18
  "access": "public"
19
19
  },
20
20
  "dependencies": {
21
+ "@arcblock/did": "1.28.7",
22
+ "@arcblock/jwt": "1.28.7",
23
+ "@arcblock/validator": "1.28.7",
24
+ "@ocap/client": "1.28.7",
25
+ "@ocap/mcrypto": "1.28.7",
26
+ "@ocap/util": "1.28.7",
27
+ "@ocap/wallet": "1.28.7",
21
28
  "cors": "^2.8.5",
22
29
  "debug": "^4.3.6",
23
30
  "json-stable-stringify": "^1.0.1",
24
31
  "lodash": "^4.17.21",
25
32
  "semver": "^7.6.3",
26
- "tweetnacl-sealedbox-js": "^1.2.0",
27
- "@arcblock/did": "1.28.5",
28
- "@arcblock/jwt": "1.28.5",
29
- "@arcblock/validator": "1.28.5",
30
- "@ocap/client": "1.28.5",
31
- "@ocap/mcrypto": "1.28.5",
32
- "@ocap/util": "1.28.5",
33
- "@ocap/wallet": "1.28.5"
33
+ "tweetnacl-sealedbox-js": "^1.2.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@arcblock/did-agent-storage-memory": "^1.8.0",
37
37
  "@arcblock/did-connect-storage-memory": "^1.8.0",
38
+ "@ocap/e2e-test": "1.28.7",
38
39
  "axios": "^1.7.5",
39
- "jest": "^29.7.0",
40
40
  "remark-cli": "^10.0.1",
41
41
  "remark-preset-github": "^4.0.4",
42
- "tweetnacl": "^1.0.3",
43
- "@ocap/e2e-test": "1.28.5"
42
+ "tweetnacl": "^1.0.3"
44
43
  },
45
44
  "remarkConfig": {
46
45
  "plugins": [
@@ -68,19 +67,19 @@
68
67
  "type": "git",
69
68
  "url": "https://github.com/ArcBlock/blockchain/tree/master/did/did-connect"
70
69
  },
71
- "resolutions": {
72
- "tweetnacl": "1.0.3"
73
- },
74
- "gitHead": "87990c8b5e215107fc587c1ced0d6b3e2cd2483e",
75
70
  "scripts": {
76
- "lint": "eslint lib tests",
77
- "lint:fix": "eslint --fix lib tests",
78
- "docs": "pnpm run gen-dts && pnpm run gen-docs && pnpm run cleanup-docs && pnpm run format-docs",
71
+ "lint": "biome check",
72
+ "lint:fix": "biome check --write",
73
+ "docs": "bun run gen-dts && bun run gen-docs && bun run cleanup-docs && bun run format-docs",
79
74
  "cleanup-docs": "node ../../scripts/cleanup-docs.js docs/README.md $npm_package_name",
80
75
  "gen-docs": "jsdoc2md lib/**/*.js lib/**/**/*.js > docs/README.md",
81
76
  "gen-dts": "j2d lib/index.js",
82
77
  "format-docs": "remark . -o",
83
- "test": "jest --forceExit --detectOpenHandles",
78
+ "test": "bun test",
84
79
  "coverage": "npm run test -- --coverage"
85
- }
86
- }
80
+ },
81
+ "resolutions": {
82
+ "tweetnacl": "1.0.3"
83
+ },
84
+ "gitHead": "87990c8b5e215107fc587c1ced0d6b3e2cd2483e"
85
+ }