@abtnode/auth 1.16.0-beta-b16cb035 → 1.16.0-beta-8ee536d7
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 +26 -7
- package/package.json +14 -14
package/lib/server.js
CHANGED
|
@@ -5,8 +5,9 @@ const last = require('lodash/last');
|
|
|
5
5
|
const { isNFTExpired, isNFTConsumed } = require('@abtnode/util/lib/nft');
|
|
6
6
|
const Client = require('@ocap/client');
|
|
7
7
|
const { fromPublicKey } = require('@ocap/wallet');
|
|
8
|
+
const { types } = require('@ocap/mcrypto');
|
|
8
9
|
const { fromBase58, toAddress, toHex } = require('@ocap/util');
|
|
9
|
-
const { toTypeInfo, isFromPublicKey } = require('@arcblock/did');
|
|
10
|
+
const { toTypeInfo, isFromPublicKey, DidType, isEthereumType } = require('@arcblock/did');
|
|
10
11
|
const urlFriendly = require('@blocklet/meta/lib/url-friendly').default;
|
|
11
12
|
const getApplicationWallet = require('@blocklet/meta/lib/wallet');
|
|
12
13
|
const { slugify } = require('transliteration');
|
|
@@ -292,7 +293,7 @@ const getAuthNFTClaim =
|
|
|
292
293
|
|
|
293
294
|
const getKeyPairClaim =
|
|
294
295
|
(node, declare = true) =>
|
|
295
|
-
async ({ extraParams: { locale, appDid, title }, context: { didwallet } }) => {
|
|
296
|
+
async ({ extraParams: { locale, appDid, wt = 'default', title }, context: { didwallet } }) => {
|
|
296
297
|
checkWalletVersion({ didwallet, locale });
|
|
297
298
|
|
|
298
299
|
const description = {
|
|
@@ -303,6 +304,9 @@ const getKeyPairClaim =
|
|
|
303
304
|
let appName = title;
|
|
304
305
|
let migrateFrom = '';
|
|
305
306
|
|
|
307
|
+
let type;
|
|
308
|
+
let chainInfo;
|
|
309
|
+
|
|
306
310
|
// We are rotating a key-pair for existing application
|
|
307
311
|
if (appDid) {
|
|
308
312
|
const blocklet = await node.getBlocklet({ did: appDid, attachRuntimeInfo: false });
|
|
@@ -314,21 +318,36 @@ const getKeyPairClaim =
|
|
|
314
318
|
const { name, wallet } = getBlockletInfo(blocklet, info.sk);
|
|
315
319
|
appName = name;
|
|
316
320
|
migrateFrom = wallet.address;
|
|
321
|
+
type = DidType(wallet.type);
|
|
322
|
+
chainInfo = getChainInfo(blocklet.configObj);
|
|
323
|
+
} else {
|
|
324
|
+
type = DidType(wt);
|
|
325
|
+
type.role = types.RoleType.ROLE_APPLICATION;
|
|
326
|
+
chainInfo = getChainInfo({});
|
|
317
327
|
}
|
|
318
328
|
|
|
319
|
-
|
|
329
|
+
const typeStr = DidType.toJSON(type);
|
|
330
|
+
if (isEthereumType(type)) {
|
|
331
|
+
chainInfo.type = 'ethereum';
|
|
332
|
+
chainInfo.id = '1';
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const result = {
|
|
320
336
|
mfa: !process.env.DID_CONNECT_MFA_DISABLED,
|
|
321
337
|
description: description[locale] || description.en,
|
|
322
338
|
moniker: (urlFriendly(slugify(appName)) || 'application').toLowerCase(),
|
|
323
339
|
declare: !!declare,
|
|
340
|
+
chainInfo,
|
|
324
341
|
migrateFrom,
|
|
325
342
|
targetType: {
|
|
326
|
-
role: '
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
encoding:
|
|
343
|
+
role: typeStr.role?.split('_').pop()?.toLowerCase(),
|
|
344
|
+
key: typeStr.pk?.toLowerCase(),
|
|
345
|
+
hash: typeStr.hash?.toLowerCase(),
|
|
346
|
+
encoding: typeStr.address?.toLowerCase(),
|
|
330
347
|
},
|
|
331
348
|
};
|
|
349
|
+
|
|
350
|
+
return result;
|
|
332
351
|
};
|
|
333
352
|
|
|
334
353
|
const getRotateKeyPairClaims = (node) => {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.0-beta-
|
|
6
|
+
"version": "1.16.0-beta-8ee536d7",
|
|
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.16.0-beta-
|
|
24
|
-
"@abtnode/logger": "1.16.0-beta-
|
|
25
|
-
"@abtnode/util": "1.16.0-beta-
|
|
26
|
-
"@arcblock/did": "1.18.
|
|
27
|
-
"@arcblock/jwt": "^1.18.
|
|
28
|
-
"@arcblock/vc": "1.18.
|
|
29
|
-
"@blocklet/constant": "1.16.0-beta-
|
|
30
|
-
"@blocklet/meta": "1.16.0-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.16.0-beta-8ee536d7",
|
|
24
|
+
"@abtnode/logger": "1.16.0-beta-8ee536d7",
|
|
25
|
+
"@abtnode/util": "1.16.0-beta-8ee536d7",
|
|
26
|
+
"@arcblock/did": "1.18.62",
|
|
27
|
+
"@arcblock/jwt": "^1.18.62",
|
|
28
|
+
"@arcblock/vc": "1.18.62",
|
|
29
|
+
"@blocklet/constant": "1.16.0-beta-8ee536d7",
|
|
30
|
+
"@blocklet/meta": "1.16.0-beta-8ee536d7",
|
|
31
|
+
"@ocap/client": "1.18.62",
|
|
32
|
+
"@ocap/mcrypto": "1.18.62",
|
|
33
|
+
"@ocap/util": "1.18.62",
|
|
34
|
+
"@ocap/wallet": "1.18.62",
|
|
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": "57d0c45be311a5fbc1c0fffa2814b62c1a3ee34c"
|
|
47
47
|
}
|