@abtnode/auth 1.8.64 → 1.8.65-beta-5405baf2
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/server.js +7 -5
- package/package.json +7 -7
package/lib/server.js
CHANGED
|
@@ -188,16 +188,13 @@ const authenticateByNFT = async ({ node, claims, userDid, challenge, locale, isA
|
|
|
188
188
|
if (state.tags.includes(NFT_TYPE_SERVERLESS)) {
|
|
189
189
|
state.data.value = JSON.parse(state.data.value);
|
|
190
190
|
|
|
191
|
-
if (!isAuth && isNFTConsumed(state)) {
|
|
192
|
-
throw new Error(messages.nftAlreadyConsume[locale]);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
191
|
if (!isAuth && isNFTExpired(state)) {
|
|
196
192
|
throw new Error(messages.nftAlreadyExpired[locale]);
|
|
197
193
|
}
|
|
198
194
|
|
|
199
195
|
return {
|
|
200
196
|
role: SERVER_ROLES.EXTERNAL_BLOCKLET_CONTROLLER,
|
|
197
|
+
nft: state,
|
|
201
198
|
extra: {
|
|
202
199
|
controller: {
|
|
203
200
|
nftId: address,
|
|
@@ -401,7 +398,7 @@ const createLaunchBlockletHandler =
|
|
|
401
398
|
throw new Error(messages.invalidParams[locale]);
|
|
402
399
|
}
|
|
403
400
|
|
|
404
|
-
const { role, passport, user, extra } = await ensureBlockletPermission({
|
|
401
|
+
const { role, passport, user, extra, nft } = await ensureBlockletPermission({
|
|
405
402
|
authMethod,
|
|
406
403
|
node,
|
|
407
404
|
userDid,
|
|
@@ -469,6 +466,11 @@ const createLaunchBlockletHandler =
|
|
|
469
466
|
// 检查是否已安装,这里不做升级的处理
|
|
470
467
|
const existedBlocklet = await node.getBlocklet({ did: blockletDid, attachRuntimeInfo: false });
|
|
471
468
|
|
|
469
|
+
// 如果是 serverless, 并且已经消费过了,但是没有安装,则抛出异常
|
|
470
|
+
if (!existedBlocklet && role === SERVER_ROLES.EXTERNAL_BLOCKLET_CONTROLLER && isNFTConsumed(nft)) {
|
|
471
|
+
throw new Error(messages.nftAlreadyConsume[locale]);
|
|
472
|
+
}
|
|
473
|
+
|
|
472
474
|
if (existedBlocklet) {
|
|
473
475
|
await updateSession({ isInstalled: true });
|
|
474
476
|
logger.info('blocklet already exists', { blockletDid });
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.65-beta-5405baf2",
|
|
7
7
|
"description": "Simple lib to manage auth in ABT Node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@abtnode/constant": "1.8.
|
|
24
|
-
"@abtnode/logger": "1.8.
|
|
25
|
-
"@abtnode/util": "1.8.
|
|
23
|
+
"@abtnode/constant": "1.8.65-beta-5405baf2",
|
|
24
|
+
"@abtnode/logger": "1.8.65-beta-5405baf2",
|
|
25
|
+
"@abtnode/util": "1.8.65-beta-5405baf2",
|
|
26
26
|
"@arcblock/did": "1.18.37",
|
|
27
27
|
"@arcblock/jwt": "^1.18.37",
|
|
28
28
|
"@arcblock/vc": "1.18.37",
|
|
29
|
-
"@blocklet/constant": "1.8.
|
|
30
|
-
"@blocklet/meta": "1.8.
|
|
29
|
+
"@blocklet/constant": "1.8.65-beta-5405baf2",
|
|
30
|
+
"@blocklet/meta": "1.8.65-beta-5405baf2",
|
|
31
31
|
"@ocap/client": "1.18.37",
|
|
32
32
|
"@ocap/mcrypto": "1.18.37",
|
|
33
33
|
"@ocap/util": "1.18.37",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"jest": "^27.5.1"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "e5dc838baded7031096118462a604fd70d78ff1c"
|
|
46
46
|
}
|