@abtnode/auth 1.6.18 → 1.6.22
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 +53 -3
- package/lib/lost-passport.js +2 -2
- package/lib/passport.js +2 -2
- package/lib/util/create-passport-svg.js +4 -4
- package/package.json +13 -13
package/lib/auth.js
CHANGED
|
@@ -6,7 +6,7 @@ const { verifyPresentation, createCredentialList } = require('@arcblock/vc');
|
|
|
6
6
|
const Mcrypto = require('@ocap/mcrypto');
|
|
7
7
|
const { fromSecretKey, WalletType } = require('@ocap/wallet');
|
|
8
8
|
const getBlockletInfo = require('@blocklet/meta/lib/info');
|
|
9
|
-
const { PASSPORT_STATUS,
|
|
9
|
+
const { PASSPORT_STATUS, VC_TYPE_NODE_PASSPORT } = require('@abtnode/constant');
|
|
10
10
|
const axios = require('@abtnode/util/lib/axios');
|
|
11
11
|
const logger = require('./logger');
|
|
12
12
|
const verifySignature = require('./util/verify-signature');
|
|
@@ -140,6 +140,56 @@ const messages = {
|
|
|
140
140
|
en: 'Invalid Blocklet VC',
|
|
141
141
|
zh: '无效的 Blocklet VC',
|
|
142
142
|
},
|
|
143
|
+
|
|
144
|
+
// NFT related
|
|
145
|
+
missingProfileClaim: {
|
|
146
|
+
en: 'Owner profile not provided',
|
|
147
|
+
zh: '节点所有者信息必须提供',
|
|
148
|
+
},
|
|
149
|
+
invalidNftClaim: {
|
|
150
|
+
en: 'Invalid Asset Claim: ownerPk, ownerDid and ownerProof are required',
|
|
151
|
+
zh: '无效的 NFT Claim:ownerPk、ownerDid、ownerProof 是必填的',
|
|
152
|
+
},
|
|
153
|
+
invalidNft: {
|
|
154
|
+
en: 'Invalid server ownership NFT state',
|
|
155
|
+
zh: '无效的节点所有权 NFT',
|
|
156
|
+
},
|
|
157
|
+
invalidNftHolder: {
|
|
158
|
+
en: 'Invalid server ownership NFT holder',
|
|
159
|
+
zh: '无效的节点所有权 NFT 持有者',
|
|
160
|
+
},
|
|
161
|
+
invalidNftProof: {
|
|
162
|
+
en: 'Invalid server ownership NFT signature proof',
|
|
163
|
+
zh: '无效的节点所有权 NFT 签名',
|
|
164
|
+
},
|
|
165
|
+
invalidNftIssuer: {
|
|
166
|
+
en: 'Invalid server ownership NFT issuer',
|
|
167
|
+
zh: '无效的节点所有权 NFT 颁发者',
|
|
168
|
+
},
|
|
169
|
+
tagNotMatch: {
|
|
170
|
+
en: 'This NFT is for another blocklet server',
|
|
171
|
+
zh: '您所提供的所有权 NFT 不属于当前节点',
|
|
172
|
+
},
|
|
173
|
+
requestNft: {
|
|
174
|
+
en: 'Please provide server ownership NFT',
|
|
175
|
+
zh: '请提供节点所有权 NFT',
|
|
176
|
+
},
|
|
177
|
+
missingNftClaim: {
|
|
178
|
+
en: 'Ownership NFT not provided',
|
|
179
|
+
zh: '节点所有权 NFT 必须提供',
|
|
180
|
+
},
|
|
181
|
+
noNft: {
|
|
182
|
+
en: 'This server is not initialized to accept ownership NFT',
|
|
183
|
+
zh: '该节点不能用这种方式成为管理员',
|
|
184
|
+
},
|
|
185
|
+
noTag: {
|
|
186
|
+
en: 'Tag not found from server launcher info',
|
|
187
|
+
zh: '节点初始化信息异常:缺少标签',
|
|
188
|
+
},
|
|
189
|
+
noChainHost: {
|
|
190
|
+
en: 'chainHost not found from server launcher info',
|
|
191
|
+
zh: '节点初始化信息异常:缺少链地址',
|
|
192
|
+
},
|
|
143
193
|
};
|
|
144
194
|
|
|
145
195
|
const PASSPORT_STATUS_KEY = 'passport-status';
|
|
@@ -333,7 +383,7 @@ const handleInvitationResponse = async ({
|
|
|
333
383
|
userDid,
|
|
334
384
|
teamDid,
|
|
335
385
|
}),
|
|
336
|
-
types: teamDid === nodeInfo.did ? [
|
|
386
|
+
types: teamDid === nodeInfo.did ? [VC_TYPE_NODE_PASSPORT] : [],
|
|
337
387
|
ownerProfile: profile,
|
|
338
388
|
preferredColor: passportColor,
|
|
339
389
|
};
|
|
@@ -505,7 +555,7 @@ const handleIssuePassportResponse = async ({
|
|
|
505
555
|
userDid,
|
|
506
556
|
teamDid,
|
|
507
557
|
}),
|
|
508
|
-
types: teamDid === nodeInfo.did ? [
|
|
558
|
+
types: teamDid === nodeInfo.did ? [VC_TYPE_NODE_PASSPORT] : [],
|
|
509
559
|
ownerProfile: user,
|
|
510
560
|
preferredColor: passportColor,
|
|
511
561
|
};
|
package/lib/lost-passport.js
CHANGED
|
@@ -3,7 +3,7 @@ const uniqBy = require('lodash/uniqBy');
|
|
|
3
3
|
const getBlockletInfo = require('@blocklet/meta/lib/info');
|
|
4
4
|
const getRandomMessage = require('@abtnode/util/lib/get-random-message');
|
|
5
5
|
const getNodeWallet = require('@abtnode/util/lib/get-app-wallet');
|
|
6
|
-
const {
|
|
6
|
+
const { VC_TYPE_NODE_PASSPORT, PASSPORT_STATUS } = require('@abtnode/constant');
|
|
7
7
|
const get = require('lodash/get');
|
|
8
8
|
|
|
9
9
|
const logger = require('./logger');
|
|
@@ -249,7 +249,7 @@ const createLostPassportIssueRoute = ({ node, type, authServicePrefix }) => ({
|
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
if (type === TEAM_TYPES.NODE) {
|
|
252
|
-
vcParams.types = [
|
|
252
|
+
vcParams.types = [VC_TYPE_NODE_PASSPORT];
|
|
253
253
|
vcParams.tag = teamDid;
|
|
254
254
|
}
|
|
255
255
|
|
package/lib/passport.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const Joi = require('joi');
|
|
4
4
|
const pick = require('lodash/pick');
|
|
5
5
|
const { create: createVC } = require('@arcblock/vc');
|
|
6
|
-
const { ROLES,
|
|
6
|
+
const { ROLES, VC_TYPE_GENERAL_PASSPORT, PASSPORT_STATUS } = require('@abtnode/constant');
|
|
7
7
|
const createPassportSvg = require('./util/create-passport-svg');
|
|
8
8
|
|
|
9
9
|
const SPEC_VERSION = '1.0.0';
|
|
@@ -63,7 +63,7 @@ const createPassportVC = ({
|
|
|
63
63
|
validatePassport(passport);
|
|
64
64
|
|
|
65
65
|
return createVC({
|
|
66
|
-
type: [
|
|
66
|
+
type: [VC_TYPE_GENERAL_PASSPORT, 'VerifiableCredential', ...types].filter(Boolean),
|
|
67
67
|
issuer: {
|
|
68
68
|
wallet: issuerWallet,
|
|
69
69
|
name: issuerName,
|
|
@@ -16,15 +16,15 @@ const { getNftBGColor, DEFAULT_COLOR } = require('./passport-color');
|
|
|
16
16
|
* @returns {string} svg xml or image data url
|
|
17
17
|
*/
|
|
18
18
|
const createPassportSvg = ({
|
|
19
|
-
issuer,
|
|
20
|
-
title,
|
|
21
|
-
issuerDid,
|
|
19
|
+
issuer = '',
|
|
20
|
+
title = '',
|
|
21
|
+
issuerDid = '',
|
|
22
22
|
ownerName = '',
|
|
23
23
|
preferredColor = 'default',
|
|
24
24
|
ownerAvatarUrl = '',
|
|
25
25
|
revoked,
|
|
26
26
|
isDataUrl,
|
|
27
|
-
}) => {
|
|
27
|
+
} = {}) => {
|
|
28
28
|
let colors;
|
|
29
29
|
if (preferredColor === 'default') {
|
|
30
30
|
colors = DEFAULT_COLOR;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.6.
|
|
6
|
+
"version": "1.6.22",
|
|
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.6.
|
|
24
|
-
"@abtnode/logger": "1.6.
|
|
25
|
-
"@abtnode/util": "1.6.
|
|
26
|
-
"@arcblock/did": "^1.14.
|
|
27
|
-
"@arcblock/vc": "^1.14.
|
|
28
|
-
"@blocklet/meta": "1.6.
|
|
29
|
-
"@ocap/mcrypto": "^1.14.
|
|
30
|
-
"@ocap/util": "^1.14.
|
|
31
|
-
"@ocap/wallet": "^1.14.
|
|
32
|
-
"axios": "^0.
|
|
33
|
-
"joi": "^17.
|
|
23
|
+
"@abtnode/constant": "1.6.22",
|
|
24
|
+
"@abtnode/logger": "1.6.22",
|
|
25
|
+
"@abtnode/util": "1.6.22",
|
|
26
|
+
"@arcblock/did": "^1.14.16",
|
|
27
|
+
"@arcblock/vc": "^1.14.16",
|
|
28
|
+
"@blocklet/meta": "1.6.22",
|
|
29
|
+
"@ocap/mcrypto": "^1.14.16",
|
|
30
|
+
"@ocap/util": "^1.14.16",
|
|
31
|
+
"@ocap/wallet": "^1.14.16",
|
|
32
|
+
"axios": "^0.25.0",
|
|
33
|
+
"joi": "^17.6.0",
|
|
34
34
|
"jsonwebtoken": "^8.5.1",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
36
|
"semver": "^7.3.2",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"jest": "^27.4.5"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "18ac52a439dbd04e4ace98d796b6de517503fb14"
|
|
43
43
|
}
|