@abtnode/auth 1.17.5-beta-20251208-123021-e8c53f96 → 1.17.5-beta-20251211-104355-426d7eb6

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.
Files changed (2) hide show
  1. package/lib/server.js +15 -9
  2. package/package.json +8 -8
package/lib/server.js CHANGED
@@ -8,7 +8,7 @@ const pRetry = require('p-retry');
8
8
  const { isNFTExpired, isNFTConsumed } = require('@abtnode/util/lib/nft');
9
9
  const axios = require('@abtnode/util/lib/axios');
10
10
  const { CustomError } = require('@blocklet/error');
11
- const { joinURL } = require('ufo');
11
+ const { joinURL, withHttps } = require('ufo');
12
12
  const { types } = require('@ocap/mcrypto');
13
13
  const { toHex, fromBase64 } = require('@ocap/util');
14
14
  const { DidType, isEthereumType } = require('@arcblock/did');
@@ -138,16 +138,16 @@ const getBlockletKnownDids = async ({ teamDid, blocklet, node }) => {
138
138
  }
139
139
  };
140
140
 
141
- const getKnownIssuerDids = async ({ issuerDid, node }) => {
141
+ const getKnownIssuerDids = async ({ issuerDid }) => {
142
142
  try {
143
143
  // FIXME: @liushuang 多次迁移后,did 可能是第一次的 did,存在查询不到 blocklet 信息的情况,通过 domain 间接查询
144
144
  const domain = getDidDomainForBlocklet({ did: issuerDid });
145
- const blockletInfo = await node.getBlocklet({
146
- did: issuerDid,
147
- domain,
148
- useCache: true,
145
+ const { data } = await axios.get(joinURL(withHttps(domain), '__blocklet__.js?type=json'), {
146
+ timeout: 10 * 1000,
149
147
  });
150
- return getBlockletAppIdList(blockletInfo);
148
+ const { appId, appPid, alsoKnownAs = [] } = data;
149
+ const alsoKnownAsDids = [appId, appPid, ...alsoKnownAs];
150
+ return [...new Set(alsoKnownAsDids.filter(Boolean))];
151
151
  } catch (error) {
152
152
  return [issuerDid];
153
153
  }
@@ -225,7 +225,8 @@ const authenticateByVc = async ({
225
225
 
226
226
  // 需要考虑到 Blocklet 迁移的情况
227
227
  const knownTeamDids = await getBlockletKnownDids({ teamDid, blocklet, node });
228
- const knownIssuerDids = await getKnownIssuerDids({ issuerDid: issuerId, node });
228
+ const knownIssuerDids =
229
+ trustedIssuers.length > 0 ? trustedIssuers : await getKnownIssuerDids({ issuerDid: issuerId });
229
230
 
230
231
  // 如果 issuerId 存在于 blocklet 的 alsoKnownAs 中认为是相同的 blocklet
231
232
  if (knownTeamDids.includes(issuerId)) {
@@ -486,10 +487,15 @@ const getKeyPairClaim =
486
487
  chainInfo.id = '1';
487
488
  }
488
489
 
490
+ let moniker = convertToMoniker(appName);
491
+ if (!/^[a-zA-Z0-9][-a-zA-Z0-9_]{2,128}$/.test(moniker)) {
492
+ moniker = appDid ? [appDid.slice(0, 6), appDid.slice(-5)].join('-') : `app-${Date.now().toString(36)}`;
493
+ }
494
+
489
495
  const result = {
490
496
  mfa: !process.env.DID_CONNECT_MFA_DISABLED,
491
497
  description: description[locale] || description.en,
492
- moniker: convertToMoniker(appName),
498
+ moniker,
493
499
  declare: !!declare,
494
500
  migrateFrom: declare ? migrateFrom : '',
495
501
  chainInfo,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.17.5-beta-20251208-123021-e8c53f96",
6
+ "version": "1.17.5-beta-20251211-104355-426d7eb6",
7
7
  "description": "Simple lib to manage auth in ABT Node",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -18,9 +18,9 @@
18
18
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
19
19
  "license": "Apache-2.0",
20
20
  "dependencies": {
21
- "@abtnode/constant": "1.17.5-beta-20251208-123021-e8c53f96",
22
- "@abtnode/logger": "1.17.5-beta-20251208-123021-e8c53f96",
23
- "@abtnode/util": "1.17.5-beta-20251208-123021-e8c53f96",
21
+ "@abtnode/constant": "1.17.5-beta-20251211-104355-426d7eb6",
22
+ "@abtnode/logger": "1.17.5-beta-20251211-104355-426d7eb6",
23
+ "@abtnode/util": "1.17.5-beta-20251211-104355-426d7eb6",
24
24
  "@arcblock/did": "^1.27.12",
25
25
  "@arcblock/did-connect-js": "^1.27.12",
26
26
  "@arcblock/did-ext": "^1.27.12",
@@ -29,10 +29,10 @@
29
29
  "@arcblock/nft-display": "^3.2.11",
30
30
  "@arcblock/validator": "^1.27.12",
31
31
  "@arcblock/vc": "^1.27.12",
32
- "@blocklet/constant": "1.17.5-beta-20251208-123021-e8c53f96",
32
+ "@blocklet/constant": "1.17.5-beta-20251211-104355-426d7eb6",
33
33
  "@blocklet/error": "^0.3.3",
34
- "@blocklet/meta": "1.17.5-beta-20251208-123021-e8c53f96",
35
- "@blocklet/sdk": "1.17.5-beta-20251208-123021-e8c53f96",
34
+ "@blocklet/meta": "1.17.5-beta-20251211-104355-426d7eb6",
35
+ "@blocklet/sdk": "1.17.5-beta-20251211-104355-426d7eb6",
36
36
  "@ocap/client": "^1.27.12",
37
37
  "@ocap/mcrypto": "^1.27.12",
38
38
  "@ocap/util": "^1.27.12",
@@ -55,5 +55,5 @@
55
55
  "devDependencies": {
56
56
  "axios-mock-adapter": "^2.1.0"
57
57
  },
58
- "gitHead": "ed63bdced5fa8df09ba7fd282b38751007df2216"
58
+ "gitHead": "9ea2a8077a8edbf5021281e823719758eb9fe02c"
59
59
  }