@abtnode/auth 1.8.68-beta-500af7e5 → 1.8.69-beta-e0666d0d

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.
Files changed (2) hide show
  1. package/lib/server.js +7 -10
  2. package/package.json +7 -7
package/lib/server.js CHANGED
@@ -362,7 +362,7 @@ const getRotateKeyPairClaims = (node) => {
362
362
  return {
363
363
  chainInfo,
364
364
  description: description[locale] || description.en,
365
- target: '',
365
+ target: blocklet.appPid,
366
366
  };
367
367
  },
368
368
  },
@@ -648,7 +648,7 @@ const getBlockletPermissionChecker =
648
648
  };
649
649
 
650
650
  const createRotateKeyPairHandler =
651
- (node, authMethod) =>
651
+ (node) =>
652
652
  async ({ claims, userDid, req, extraParams }) => {
653
653
  const { locale, appDid } = extraParams;
654
654
  logger.info('createRotateKeyPairHandler', extraParams);
@@ -669,13 +669,10 @@ const createRotateKeyPairHandler =
669
669
  throw new Error(messages.invalidBlocklet[locale]);
670
670
  }
671
671
 
672
- const { role, user } = await ensureBlockletPermission({
673
- authMethod,
674
- node,
675
- userDid,
676
- locale,
677
- allowedRoles: ['owner'],
678
- });
672
+ // Only the blocklet owner(identified by appPid) can rotate key pair
673
+ if (blocklet.appPid !== userDid) {
674
+ throw new Error(messages.notAllowed[locale]);
675
+ }
679
676
 
680
677
  await node.configBlocklet(
681
678
  {
@@ -684,7 +681,7 @@ const createRotateKeyPairHandler =
684
681
  skipHook: true,
685
682
  skipDidDocument: true,
686
683
  },
687
- formatContext(Object.assign(req, { user: { ...pick(user, ['did', 'fullName']), role } }))
684
+ formatContext(Object.assign(req, { user: { did: userDid, fullName: 'Owner', role: 'owner' } }))
688
685
  );
689
686
  };
690
687
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.68-beta-500af7e5",
6
+ "version": "1.8.69-beta-e0666d0d",
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.68-beta-500af7e5",
24
- "@abtnode/logger": "1.8.68-beta-500af7e5",
25
- "@abtnode/util": "1.8.68-beta-500af7e5",
23
+ "@abtnode/constant": "1.8.69-beta-e0666d0d",
24
+ "@abtnode/logger": "1.8.69-beta-e0666d0d",
25
+ "@abtnode/util": "1.8.69-beta-e0666d0d",
26
26
  "@arcblock/did": "1.18.57",
27
27
  "@arcblock/jwt": "^1.18.57",
28
28
  "@arcblock/vc": "1.18.57",
29
- "@blocklet/constant": "1.8.68-beta-500af7e5",
30
- "@blocklet/meta": "1.8.68-beta-500af7e5",
29
+ "@blocklet/constant": "1.8.69-beta-e0666d0d",
30
+ "@blocklet/meta": "1.8.69-beta-e0666d0d",
31
31
  "@ocap/client": "1.18.57",
32
32
  "@ocap/mcrypto": "1.18.57",
33
33
  "@ocap/util": "1.18.57",
@@ -43,5 +43,5 @@
43
43
  "devDependencies": {
44
44
  "jest": "^27.5.1"
45
45
  },
46
- "gitHead": "9070621373f317a10ff0d289323bf725e30d3521"
46
+ "gitHead": "acf0373591eaa3aff76483edc4e648afc543f1f7"
47
47
  }