@abtnode/auth 1.8.69-beta-b0bb2d67 → 1.8.69-beta-76f8a46f
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 +9 -15
- package/package.json +14 -14
package/lib/server.js
CHANGED
|
@@ -8,6 +8,7 @@ const { fromPublicKey } = require('@ocap/wallet');
|
|
|
8
8
|
const { fromBase58, toAddress, toHex } = require('@ocap/util');
|
|
9
9
|
const { toTypeInfo, isFromPublicKey } = require('@arcblock/did');
|
|
10
10
|
const urlFriendly = require('@blocklet/meta/lib/url-friendly').default;
|
|
11
|
+
const getApplicationWallet = require('@blocklet/meta/lib/wallet');
|
|
11
12
|
const { slugify } = require('transliteration');
|
|
12
13
|
const { getChainInfo } = require('@blocklet/meta/lib/util');
|
|
13
14
|
const getBlockletInfo = require('@blocklet/meta/lib/info');
|
|
@@ -21,7 +22,6 @@ const {
|
|
|
21
22
|
NFT_TYPE_SERVERLESS,
|
|
22
23
|
MAIN_CHAIN_ENDPOINT,
|
|
23
24
|
} = require('@abtnode/constant');
|
|
24
|
-
const { toExternalBlocklet } = require('@blocklet/meta/lib/did');
|
|
25
25
|
const {
|
|
26
26
|
messages,
|
|
27
27
|
getVCFromClaims,
|
|
@@ -580,16 +580,13 @@ const createLaunchBlockletHandler =
|
|
|
580
580
|
await updateSession({ sessionToken }, true);
|
|
581
581
|
}
|
|
582
582
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
? toExternalBlocklet(blocklet.meta.name, controller.nftId, { didOnly: true })
|
|
587
|
-
: blocklet.meta.did;
|
|
588
|
-
|
|
589
|
-
await updateSession({ blockletDid });
|
|
583
|
+
const appSk = toHex(keyPair.secret);
|
|
584
|
+
const appDid = getApplicationWallet(appSk).address;
|
|
585
|
+
await updateSession({ appDid });
|
|
590
586
|
|
|
587
|
+
if (blocklet) {
|
|
591
588
|
// 检查是否已安装,这里不做升级的处理
|
|
592
|
-
const existedBlocklet = await node.getBlocklet({ did:
|
|
589
|
+
const existedBlocklet = await node.getBlocklet({ did: appDid, attachRuntimeInfo: false });
|
|
593
590
|
|
|
594
591
|
// 如果是 serverless, 并且已经消费过了,但是没有安装,则抛出异常
|
|
595
592
|
if (!existedBlocklet && role === SERVER_ROLES.EXTERNAL_BLOCKLET_CONTROLLER && isNFTConsumed(nft)) {
|
|
@@ -598,26 +595,24 @@ const createLaunchBlockletHandler =
|
|
|
598
595
|
|
|
599
596
|
if (existedBlocklet) {
|
|
600
597
|
await updateSession({ isInstalled: true });
|
|
601
|
-
logger.info('blocklet already exists', {
|
|
598
|
+
logger.info('blocklet already exists', { appDid });
|
|
602
599
|
return;
|
|
603
600
|
}
|
|
604
601
|
}
|
|
605
602
|
|
|
606
603
|
logger.info('start install blocklet', { blockletMetaUrl, title, description });
|
|
607
|
-
|
|
604
|
+
await node.installBlocklet(
|
|
608
605
|
{
|
|
609
606
|
url: blockletMetaUrl,
|
|
610
607
|
title,
|
|
611
608
|
description,
|
|
612
|
-
appSk
|
|
609
|
+
appSk,
|
|
613
610
|
delay: 1000 * 4, // delay 4 seconds to download, wait for ws connection from frontend
|
|
614
611
|
downloadTokenList: extraParams?.previousWorkflowData?.downloadTokenList,
|
|
615
612
|
controller: role === SERVER_ROLES.EXTERNAL_BLOCKLET_CONTROLLER ? controller : null,
|
|
616
613
|
},
|
|
617
614
|
formatContext(Object.assign(req, { user: { ...pick(user, ['did', 'fullName']), role } }))
|
|
618
615
|
);
|
|
619
|
-
|
|
620
|
-
await updateSession({ blockletDid: tmp.meta.did });
|
|
621
616
|
};
|
|
622
617
|
|
|
623
618
|
const getBlockletPermissionChecker =
|
|
@@ -679,7 +674,6 @@ const createRotateKeyPairHandler =
|
|
|
679
674
|
did: blocklet.meta.did,
|
|
680
675
|
configs: [{ key: 'BLOCKLET_APP_SK', value: toHex(keyPair.secret), secure: true }],
|
|
681
676
|
skipHook: true,
|
|
682
|
-
skipDidDocument: true,
|
|
683
677
|
},
|
|
684
678
|
formatContext(Object.assign(req, { user: { did: userDid, fullName: 'Owner', role: 'owner' } }))
|
|
685
679
|
);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.69-beta-
|
|
6
|
+
"version": "1.8.69-beta-76f8a46f",
|
|
7
7
|
"description": "Simple lib to manage auth in ABT Node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@abtnode/constant": "1.8.69-beta-
|
|
24
|
-
"@abtnode/logger": "1.8.69-beta-
|
|
25
|
-
"@abtnode/util": "1.8.69-beta-
|
|
26
|
-
"@arcblock/did": "1.18.
|
|
27
|
-
"@arcblock/jwt": "^1.18.
|
|
28
|
-
"@arcblock/vc": "1.18.
|
|
29
|
-
"@blocklet/constant": "1.8.69-beta-
|
|
30
|
-
"@blocklet/meta": "1.8.69-beta-
|
|
31
|
-
"@ocap/client": "1.18.
|
|
32
|
-
"@ocap/mcrypto": "1.18.
|
|
33
|
-
"@ocap/util": "1.18.
|
|
34
|
-
"@ocap/wallet": "1.18.
|
|
23
|
+
"@abtnode/constant": "1.8.69-beta-76f8a46f",
|
|
24
|
+
"@abtnode/logger": "1.8.69-beta-76f8a46f",
|
|
25
|
+
"@abtnode/util": "1.8.69-beta-76f8a46f",
|
|
26
|
+
"@arcblock/did": "1.18.58",
|
|
27
|
+
"@arcblock/jwt": "^1.18.58",
|
|
28
|
+
"@arcblock/vc": "1.18.58",
|
|
29
|
+
"@blocklet/constant": "1.8.69-beta-76f8a46f",
|
|
30
|
+
"@blocklet/meta": "1.8.69-beta-76f8a46f",
|
|
31
|
+
"@ocap/client": "1.18.58",
|
|
32
|
+
"@ocap/mcrypto": "1.18.58",
|
|
33
|
+
"@ocap/util": "1.18.58",
|
|
34
|
+
"@ocap/wallet": "1.18.58",
|
|
35
35
|
"axios": "^0.27.2",
|
|
36
36
|
"joi": "17.7.0",
|
|
37
37
|
"jsonwebtoken": "^9.0.0",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"jest": "^27.5.1"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "07415e674443b85648ea80b734f7a3690abfc15e"
|
|
47
47
|
}
|