@abtnode/auth 1.7.5 → 1.7.8
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 +2 -2
- package/lib/lost-passport.js +4 -6
- package/lib/server.js +11 -15
- package/package.json +13 -13
package/lib/auth.js
CHANGED
|
@@ -642,8 +642,8 @@ const getVCFromClaims = async ({ claims, challenge, trustedIssuers, vcTypes, loc
|
|
|
642
642
|
};
|
|
643
643
|
};
|
|
644
644
|
|
|
645
|
-
const checkWalletVersion = ({
|
|
646
|
-
const { os, version } =
|
|
645
|
+
const checkWalletVersion = ({ didwallet, locale = 'en' }) => {
|
|
646
|
+
const { os, version } = didwallet;
|
|
647
647
|
|
|
648
648
|
const defaultExpected = '3.0.0';
|
|
649
649
|
|
package/lib/lost-passport.js
CHANGED
|
@@ -85,7 +85,7 @@ const createLostPassportListRoute = ({ node, type }) => ({
|
|
|
85
85
|
},
|
|
86
86
|
},
|
|
87
87
|
|
|
88
|
-
onAuth: async ({ userDid, extraParams,
|
|
88
|
+
onAuth: async ({ userDid, extraParams, updateSession, req }) => {
|
|
89
89
|
const { locale } = extraParams;
|
|
90
90
|
|
|
91
91
|
const { teamDid, issuerDid } = await getTeamInfo({ node, req, type });
|
|
@@ -125,9 +125,7 @@ const createLostPassportListRoute = ({ node, type }) => ({
|
|
|
125
125
|
|
|
126
126
|
logger.info('get passport type list', { userDid });
|
|
127
127
|
|
|
128
|
-
await
|
|
129
|
-
user,
|
|
130
|
-
});
|
|
128
|
+
await updateSession({ user });
|
|
131
129
|
},
|
|
132
130
|
});
|
|
133
131
|
|
|
@@ -149,9 +147,9 @@ const createLostPassportIssueRoute = ({ node, type, authServicePrefix }) => ({
|
|
|
149
147
|
},
|
|
150
148
|
},
|
|
151
149
|
{
|
|
152
|
-
signature: async ({ extraParams, context: { request,
|
|
150
|
+
signature: async ({ extraParams, context: { request, didwallet } }) => {
|
|
153
151
|
const { locale, passportName, receiverDid } = extraParams;
|
|
154
|
-
checkWalletVersion({
|
|
152
|
+
checkWalletVersion({ didwallet, locale });
|
|
155
153
|
|
|
156
154
|
const { teamDid, issuerDid, issuerName, passportColor } = await getTeamInfo({ node, req: request, type });
|
|
157
155
|
const user = await getUser(node, teamDid, receiverDid);
|
package/lib/server.js
CHANGED
|
@@ -164,8 +164,8 @@ const authenticateByNFT = async ({ node, claims, userDid, challenge, locale }) =
|
|
|
164
164
|
|
|
165
165
|
const getAuthVcClaim =
|
|
166
166
|
(node) =>
|
|
167
|
-
async ({ extraParams: { locale }, context: {
|
|
168
|
-
checkWalletVersion({
|
|
167
|
+
async ({ extraParams: { locale }, context: { didwallet } }) => {
|
|
168
|
+
checkWalletVersion({ didwallet, locale });
|
|
169
169
|
const info = await node.getNodeInfo();
|
|
170
170
|
const trustedPassports = (info.trustedPassports || []).map((x) => x.issuerDid);
|
|
171
171
|
const trustedIssuers = [info.did, ...trustedPassports].filter(Boolean);
|
|
@@ -187,8 +187,8 @@ const getLaunchFreeBlockletClaims = (node, authMethod) => {
|
|
|
187
187
|
return {
|
|
188
188
|
serverNFT: [
|
|
189
189
|
'asset',
|
|
190
|
-
async ({ extraParams: { locale }, context: {
|
|
191
|
-
checkWalletVersion({
|
|
190
|
+
async ({ extraParams: { locale }, context: { didwallet } }) => {
|
|
191
|
+
checkWalletVersion({ didwallet, locale });
|
|
192
192
|
return getOwnershipNFTClaim(node, locale);
|
|
193
193
|
},
|
|
194
194
|
],
|
|
@@ -200,8 +200,8 @@ const getLaunchPaidBlockletClaims = (node, authMethod) => {
|
|
|
200
200
|
|
|
201
201
|
claims.blockletPurchaseNft = [
|
|
202
202
|
'verifiableCredential',
|
|
203
|
-
async ({ extraParams: { locale, blockletMetaUrl }, context: {
|
|
204
|
-
checkWalletVersion({
|
|
203
|
+
async ({ extraParams: { locale, blockletMetaUrl }, context: { didwallet } }) => {
|
|
204
|
+
checkWalletVersion({ didwallet, locale });
|
|
205
205
|
const registryUrl = new URL(blockletMetaUrl).origin;
|
|
206
206
|
const [registry, { meta }] = await Promise.all([
|
|
207
207
|
node.getRegistryMeta(registryUrl),
|
|
@@ -274,7 +274,7 @@ const ensureBlockletPermission = async ({ authMethod, node, userDid, claims, cha
|
|
|
274
274
|
|
|
275
275
|
const createLaunchBlockletHandler =
|
|
276
276
|
(node, authMethod) =>
|
|
277
|
-
async ({ claims, challenge, userDid,
|
|
277
|
+
async ({ claims, challenge, userDid, updateSession, extraParams: { locale, blockletMetaUrl } }) => {
|
|
278
278
|
if (!blockletMetaUrl) {
|
|
279
279
|
throw new Error(messages.invalidParams[locale]);
|
|
280
280
|
}
|
|
@@ -332,11 +332,10 @@ const createLaunchBlockletHandler =
|
|
|
332
332
|
|
|
333
333
|
// 检查是否已安装,这里不做升级的处理
|
|
334
334
|
const existedBlocklet = await node.getBlocklet({ did });
|
|
335
|
+
await updateSession({ sessionToken }, true);
|
|
336
|
+
|
|
335
337
|
if (existedBlocklet) {
|
|
336
|
-
const storageData = {
|
|
337
|
-
did: userDid,
|
|
338
|
-
sessionToken,
|
|
339
|
-
};
|
|
338
|
+
const storageData = { did: userDid };
|
|
340
339
|
|
|
341
340
|
if (semver.gt(result.meta.version, existedBlocklet.meta.version)) {
|
|
342
341
|
const appDidEnv = existedBlocklet.environments.find((e) => e.key === 'BLOCKLET_APP_ID');
|
|
@@ -348,14 +347,11 @@ const createLaunchBlockletHandler =
|
|
|
348
347
|
};
|
|
349
348
|
}
|
|
350
349
|
|
|
351
|
-
await
|
|
352
|
-
|
|
350
|
+
await updateSession(storageData);
|
|
353
351
|
logger.info('blocklet already exists', { did });
|
|
354
352
|
return;
|
|
355
353
|
}
|
|
356
354
|
|
|
357
|
-
await storage.update(token, { did: userDid, sessionToken });
|
|
358
|
-
|
|
359
355
|
const context = {};
|
|
360
356
|
if (typeof blockletPurchaseVerified !== 'undefined') {
|
|
361
357
|
context.blockletPurchaseVerified = blockletPurchaseVerified;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.7.
|
|
6
|
+
"version": "1.7.8",
|
|
7
7
|
"description": "Simple lib to manage auth in ABT Node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@abtnode/constant": "1.7.
|
|
24
|
-
"@abtnode/logger": "1.7.
|
|
25
|
-
"@abtnode/util": "1.7.
|
|
26
|
-
"@arcblock/did": "^1.
|
|
27
|
-
"@arcblock/vc": "^1.
|
|
28
|
-
"@blocklet/meta": "1.7.
|
|
29
|
-
"@ocap/client": "1.
|
|
30
|
-
"@ocap/mcrypto": "^1.
|
|
31
|
-
"@ocap/util": "^1.
|
|
32
|
-
"@ocap/wallet": "^1.
|
|
33
|
-
"axios": "^0.
|
|
23
|
+
"@abtnode/constant": "1.7.8",
|
|
24
|
+
"@abtnode/logger": "1.7.8",
|
|
25
|
+
"@abtnode/util": "1.7.8",
|
|
26
|
+
"@arcblock/did": "^1.16.3",
|
|
27
|
+
"@arcblock/vc": "^1.16.3",
|
|
28
|
+
"@blocklet/meta": "1.7.8",
|
|
29
|
+
"@ocap/client": "1.16.3",
|
|
30
|
+
"@ocap/mcrypto": "^1.16.3",
|
|
31
|
+
"@ocap/util": "^1.16.3",
|
|
32
|
+
"@ocap/wallet": "^1.16.3",
|
|
33
|
+
"axios": "^0.26.1",
|
|
34
34
|
"joi": "^17.6.0",
|
|
35
35
|
"jsonwebtoken": "^8.5.1",
|
|
36
36
|
"lodash": "^4.17.21",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"jest": "^27.4.5"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "ae75dd20b4750a31dc53c88b75ed1d95c8f15397"
|
|
44
44
|
}
|