@abtnode/auth 1.7.14 → 1.7.17

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/lib/auth.js CHANGED
@@ -561,6 +561,7 @@ const handleIssuePassportResponse = async ({
561
561
  locale = 'en',
562
562
  claims,
563
563
  statusEndpointBaseUrl,
564
+ updateSession,
564
565
  endpoint,
565
566
  }) => {
566
567
  // verify signature
@@ -656,6 +657,8 @@ const handleIssuePassportResponse = async ({
656
657
  await node.setBlockletInitialized({ did: teamDid, owner: { did: userDid, pk: userPk } });
657
658
  }
658
659
 
660
+ await updateSession({ passportId: vc.id });
661
+
659
662
  return {
660
663
  disposition: 'attachment',
661
664
  type: 'VerifiableCredential',
@@ -182,7 +182,7 @@ const createLostPassportIssueRoute = ({ node, type, authServicePrefix }) => ({
182
182
  },
183
183
  ],
184
184
 
185
- onAuth: async ({ claims, userDid, userPk, extraParams, baseUrl, req }) => {
185
+ onAuth: async ({ claims, userDid, userPk, extraParams, updateSession, baseUrl, req }) => {
186
186
  const { locale = 'en', receiverDid, passportName } = extraParams;
187
187
 
188
188
  const { teamDid, issuerDid, issuerName, issuerWallet, passportColor } = await getTeamInfo({ node, req, type });
@@ -276,6 +276,8 @@ const createLostPassportIssueRoute = ({ node, type, authServicePrefix }) => ({
276
276
  node
277
277
  );
278
278
 
279
+ await updateSession({ passportId: vc.id });
280
+
279
281
  return {
280
282
  disposition: 'attachment',
281
283
  type: 'VerifiableCredential',
package/lib/server.js CHANGED
@@ -147,7 +147,7 @@ const authenticateByNFT = async ({ node, claims, userDid, challenge, locale }) =
147
147
  if (!state) {
148
148
  throw new Error(messages.invalidNft[locale]);
149
149
  }
150
- if (state.owner !== ownerDid || state.owner !== info.ownerNft.holder) {
150
+ if (state.owner !== ownerDid) {
151
151
  throw new Error(messages.invalidNftHolder[locale]);
152
152
  }
153
153
  if (state.issuer !== info.launcher.did) {
@@ -165,17 +165,23 @@ const authenticateByNFT = async ({ node, claims, userDid, challenge, locale }) =
165
165
 
166
166
  const getAuthVcClaim =
167
167
  (node) =>
168
- async ({ extraParams: { locale }, context: { didwallet } }) => {
168
+ async ({ extraParams: { locale, passportId = '' }, context: { didwallet } }) => {
169
169
  checkWalletVersion({ didwallet, locale });
170
170
  const info = await node.getNodeInfo();
171
171
  const trustedPassports = (info.trustedPassports || []).map((x) => x.issuerDid);
172
172
  const trustedIssuers = [info.did, ...trustedPassports].filter(Boolean);
173
- return {
173
+ const claim = {
174
174
  description: messages.requestPassport[locale],
175
175
  optional: false,
176
176
  item: abtnodeVcTypes,
177
177
  trustedIssuers,
178
178
  };
179
+
180
+ if (passportId) {
181
+ claim.target = passportId;
182
+ }
183
+
184
+ return claim;
179
185
  };
180
186
 
181
187
  const getLaunchFreeBlockletClaims = (node, authMethod) => {
@@ -223,7 +229,7 @@ const getLaunchPaidBlockletClaims = (node, authMethod) => {
223
229
 
224
230
  const getOwnershipNFTClaim = async (node, locale) => {
225
231
  const info = await node.getNodeInfo();
226
- if (!info.ownerNft && !info.ownerNft.holder && !info.ownerNft.issuer) {
232
+ if (!info.ownerNft && !info.ownerNft.issuer) {
227
233
  throw new Error(messages.noNft[locale]);
228
234
  }
229
235
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.7.14",
6
+ "version": "1.7.17",
7
7
  "description": "Simple lib to manage auth in ABT Node",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -20,16 +20,16 @@
20
20
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@abtnode/constant": "1.7.14",
24
- "@abtnode/logger": "1.7.14",
25
- "@abtnode/util": "1.7.14",
26
- "@arcblock/did": "^1.16.6",
27
- "@arcblock/vc": "^1.16.6",
28
- "@blocklet/meta": "1.7.14",
29
- "@ocap/client": "1.16.6",
30
- "@ocap/mcrypto": "^1.16.6",
31
- "@ocap/util": "^1.16.6",
32
- "@ocap/wallet": "^1.16.6",
23
+ "@abtnode/constant": "1.7.17",
24
+ "@abtnode/logger": "1.7.17",
25
+ "@abtnode/util": "1.7.17",
26
+ "@arcblock/did": "^1.16.9",
27
+ "@arcblock/vc": "^1.16.9",
28
+ "@blocklet/meta": "1.7.17",
29
+ "@ocap/client": "1.16.9",
30
+ "@ocap/mcrypto": "^1.16.9",
31
+ "@ocap/util": "^1.16.9",
32
+ "@ocap/wallet": "^1.16.9",
33
33
  "axios": "^0.26.1",
34
34
  "joi": "^17.6.0",
35
35
  "jsonwebtoken": "^8.5.1",
@@ -40,5 +40,5 @@
40
40
  "devDependencies": {
41
41
  "jest": "^27.4.5"
42
42
  },
43
- "gitHead": "1f3855e6dc8b6d6c91526264e2f63215df6b962c"
43
+ "gitHead": "142a5b1e83ea03647ef9bea8de9bb269c9c82928"
44
44
  }