@abtnode/auth 1.8.69-beta-650a290b → 1.16.0-beta-b16cb035

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 CHANGED
@@ -308,10 +308,11 @@ const getRandomMessage = (len = 16) => {
308
308
  return hex.replace(/^0x/, '').toUpperCase();
309
309
  };
310
310
 
311
- const getTeamInfo = async ({ node, nodeInfo, teamDid }) => {
311
+ const getApplicationInfo = async ({ node, nodeInfo, teamDid }) => {
312
312
  let type;
313
313
  let name;
314
314
  let wallet;
315
+ let permanentWallet;
315
316
  let description;
316
317
  let passportColor;
317
318
  let owner;
@@ -320,7 +321,9 @@ const getTeamInfo = async ({ node, nodeInfo, teamDid }) => {
320
321
  if (teamDid === nodeInfo.did) {
321
322
  name = nodeInfo.name;
322
323
  description = nodeInfo.description;
323
- wallet = getNodeWallet(nodeInfo.sk);
324
+ const _wallet = getNodeWallet(nodeInfo.sk);
325
+ wallet = _wallet;
326
+ permanentWallet = _wallet;
324
327
  type = TEAM_TYPE.NODE;
325
328
  passportColor = 'default';
326
329
  owner = nodeInfo.nodeOwner;
@@ -331,6 +334,7 @@ const getTeamInfo = async ({ node, nodeInfo, teamDid }) => {
331
334
  name = blockletInfo.name;
332
335
  description = blockletInfo.description;
333
336
  wallet = blockletInfo.wallet;
337
+ permanentWallet = blockletInfo.permanentWallet;
334
338
  passportColor = blockletInfo.passportColor;
335
339
  type = TEAM_TYPE.BLOCKLET;
336
340
  owner = get(blocklet, 'settings.owner');
@@ -342,8 +346,8 @@ const getTeamInfo = async ({ node, nodeInfo, teamDid }) => {
342
346
  name,
343
347
  description,
344
348
  wallet,
349
+ permanentWallet,
345
350
  passportColor,
346
- did: teamDid,
347
351
  owner,
348
352
  dataDir,
349
353
  };
@@ -423,7 +427,11 @@ const createInvitationRequest = async ({ node, nodeInfo, teamDid, inviteId, loca
423
427
  throw new Error('The invitation does not exist or has been used');
424
428
  }
425
429
 
426
- const { name: issuerName, wallet: issuerWallet, passportColor } = await getTeamInfo({ node, nodeInfo, teamDid });
430
+ const {
431
+ name: issuerName,
432
+ wallet: issuerWallet,
433
+ passportColor,
434
+ } = await getApplicationInfo({ node, nodeInfo, teamDid });
427
435
 
428
436
  const passport = await createPassport({
429
437
  name: inviteInfo.role,
@@ -507,7 +515,7 @@ const handleInvitationResponse = async ({
507
515
  type: issuerType,
508
516
  passportColor,
509
517
  dataDir,
510
- } = await getTeamInfo({ node, nodeInfo, teamDid });
518
+ } = await getApplicationInfo({ node, nodeInfo, teamDid });
511
519
 
512
520
  const { remark } = inviteInfo;
513
521
 
@@ -670,7 +678,7 @@ const createIssuePassportRequest = async ({ node, nodeInfo, teamDid, id, locale
670
678
  passportColor,
671
679
  owner: teamOwner,
672
680
  dataDir,
673
- } = await getTeamInfo({ node, nodeInfo, teamDid });
681
+ } = await getApplicationInfo({ node, nodeInfo, teamDid });
674
682
 
675
683
  if (issuanceInfo.name === ROLES.OWNER && !!teamOwner) {
676
684
  throw new Error('Cannot receive owner passport because the owner already exists');
@@ -742,7 +750,7 @@ const handleIssuePassportResponse = async ({
742
750
  passportColor,
743
751
  owner: teamOwner,
744
752
  dataDir,
745
- } = await getTeamInfo({ node, nodeInfo, teamDid });
753
+ } = await getApplicationInfo({ node, nodeInfo, teamDid });
746
754
 
747
755
  // get issuanceInfo from session
748
756
  const list = await node.getPassportIssuances({ teamDid });
@@ -894,7 +902,11 @@ const checkWalletVersion = ({ didwallet, locale = 'en' }) => {
894
902
 
895
903
  const getPassportStatus = async ({ node, teamDid, userDid, vcId, locale = 'en' }) => {
896
904
  const nodeInfo = await node.getNodeInfo();
897
- const { wallet: issuerWallet, name: issuerName, type: issuerType } = await getTeamInfo({ node, nodeInfo, teamDid });
905
+ const {
906
+ wallet: issuerWallet,
907
+ name: issuerName,
908
+ type: issuerType,
909
+ } = await getApplicationInfo({ node, nodeInfo, teamDid });
898
910
 
899
911
  const actionLabel = {
900
912
  open: {
@@ -1031,7 +1043,7 @@ const setUserInfoHeaders = (req) => {
1031
1043
 
1032
1044
  module.exports = {
1033
1045
  getUser,
1034
- getTeamInfo,
1046
+ getApplicationInfo,
1035
1047
  createAuthToken,
1036
1048
  createAuthTokenByOwnershipNFT,
1037
1049
  beforeInvitationRequest,
@@ -29,7 +29,7 @@ const TEAM_TYPES = {
29
29
  NODE: 'node',
30
30
  };
31
31
 
32
- const getTeamInfo = async ({ type, node, req }) => {
32
+ const getApplicationInfo = async ({ type, node, req }) => {
33
33
  let teamDid;
34
34
  let issuerDid;
35
35
  let issuerDidList;
@@ -100,7 +100,7 @@ const createLostPassportListRoute = ({ node, type }) => ({
100
100
  onAuth: async ({ userDid, extraParams, updateSession, req }) => {
101
101
  const { locale } = extraParams;
102
102
 
103
- const { teamDid, issuerDidList, dataDir } = await getTeamInfo({ node, req, type });
103
+ const { teamDid, issuerDidList, dataDir } = await getApplicationInfo({ node, req, type });
104
104
 
105
105
  // check user approved
106
106
  const user = await getUser(node, teamDid, userDid);
@@ -161,7 +161,7 @@ const createLostPassportIssueRoute = ({ node, type, authServicePrefix }) => ({
161
161
  const { locale, passportName, receiverDid } = extraParams;
162
162
  checkWalletVersion({ didwallet, locale });
163
163
 
164
- const { teamDid, issuerDid, issuerName, passportColor, dataDir } = await getTeamInfo({
164
+ const { teamDid, issuerDid, issuerName, passportColor, dataDir } = await getApplicationInfo({
165
165
  node,
166
166
  req: request,
167
167
  type,
@@ -198,7 +198,7 @@ const createLostPassportIssueRoute = ({ node, type, authServicePrefix }) => ({
198
198
  onAuth: async ({ claims, userDid, userPk, extraParams, updateSession, baseUrl, req }) => {
199
199
  const { locale = 'en', receiverDid, passportName } = extraParams;
200
200
 
201
- const { teamDid, issuerDidList, issuerName, issuerWallet, passportColor, dataDir } = await getTeamInfo({
201
+ const { teamDid, issuerDidList, issuerName, issuerWallet, passportColor, dataDir } = await getApplicationInfo({
202
202
  node,
203
203
  req,
204
204
  type,
package/lib/server.js CHANGED
@@ -367,7 +367,7 @@ const getRotateKeyPairClaims = (node) => {
367
367
  return {
368
368
  chainInfo,
369
369
  description: description[locale] || description.en,
370
- target: blocklet.appPid,
370
+ target: blocklet.appDid,
371
371
  };
372
372
  },
373
373
  },
@@ -684,9 +684,14 @@ const createRotateKeyPairHandler =
684
684
  throw new Error(messages.invalidBlocklet[locale]);
685
685
  }
686
686
 
687
- // Only the blocklet owner(identified by appPid) can rotate key pair
688
- if (blocklet.appPid !== userDid) {
689
- throw new Error(messages.notAllowed[locale]);
687
+ // Only the blocklet owner(identified by appDid) can rotate key pair
688
+ if (blocklet.appDid !== userDid) {
689
+ throw new Error(
690
+ {
691
+ zh: `只有 应用DID 所有者(${blocklet.appDid})可以修改钥匙对. 当前用户:${userDid}`,
692
+ en: `Only the owner of AppDID (${blocklet.appDid}) can rotate key pair. Current User: ${userDid}`,
693
+ }[locale]
694
+ );
690
695
  }
691
696
 
692
697
  await node.configBlocklet(
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.69-beta-650a290b",
6
+ "version": "1.16.0-beta-b16cb035",
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.69-beta-650a290b",
24
- "@abtnode/logger": "1.8.69-beta-650a290b",
25
- "@abtnode/util": "1.8.69-beta-650a290b",
23
+ "@abtnode/constant": "1.16.0-beta-b16cb035",
24
+ "@abtnode/logger": "1.16.0-beta-b16cb035",
25
+ "@abtnode/util": "1.16.0-beta-b16cb035",
26
26
  "@arcblock/did": "1.18.59",
27
27
  "@arcblock/jwt": "^1.18.59",
28
28
  "@arcblock/vc": "1.18.59",
29
- "@blocklet/constant": "1.8.69-beta-650a290b",
30
- "@blocklet/meta": "1.8.69-beta-650a290b",
29
+ "@blocklet/constant": "1.16.0-beta-b16cb035",
30
+ "@blocklet/meta": "1.16.0-beta-b16cb035",
31
31
  "@ocap/client": "1.18.59",
32
32
  "@ocap/mcrypto": "1.18.59",
33
33
  "@ocap/util": "1.18.59",
@@ -43,5 +43,5 @@
43
43
  "devDependencies": {
44
44
  "jest": "^27.5.1"
45
45
  },
46
- "gitHead": "a33c9ce6a52b8d522d13860e85809dcbba236712"
46
+ "gitHead": "138bd91aee5a35b28c2de4e1e924c44932efaf3a"
47
47
  }