@arcblock/jwt 1.29.18 → 1.29.20

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/esm/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { isFromPublicKey, isValid, toDid, toStrictHex, toTypeInfo } from "@arcblock/did";
1
+ import { extractMethod, isFromPublicKey, isValid, toDid, toStrictHex, toTypeInfo } from "@arcblock/did";
2
2
  import { Hasher, getSigner, types } from "@ocap/mcrypto";
3
3
  import { fromBase64, scopeMatchAny, toBase64, toHex } from "@ocap/util";
4
4
  import Debug from "debug";
@@ -43,9 +43,10 @@ async function sign(signer, sk, payload = {}, doSign = true, version = "1.0.0")
43
43
  if (type.pk === void 0) throw new Error("Cannot determine key type from signer");
44
44
  const header = headers[type.pk];
45
45
  const headerB64 = toBase64(stringify(header));
46
+ const signerMethod = extractMethod(signer) || "abt";
46
47
  const now = Math.floor(Date.now() / 1e3);
47
48
  const body = {
48
- iss: toDid(signer),
49
+ iss: toDid(signer, signerMethod),
49
50
  iat: String(now),
50
51
  nbf: String(now),
51
52
  exp: String(now + 300),
@@ -197,9 +198,10 @@ async function signDelegationToken(signer, sk, payload) {
197
198
  if (type.pk === void 0) throw new Error("Cannot determine key type from signer");
198
199
  const header = delegationTokenHeaders[type.pk];
199
200
  const headerB64 = toBase64(stringify(header));
201
+ const delegationSignerMethod = extractMethod(signer) || "abt";
200
202
  const now = Math.floor(Date.now() / 1e3);
201
203
  const body = {
202
- iss: toDid(signer),
204
+ iss: toDid(signer, delegationSignerMethod),
203
205
  sub: payload.sub,
204
206
  iat: payload.iat || String(now),
205
207
  nbf: payload.nbf || String(now),
package/lib/index.cjs CHANGED
@@ -47,9 +47,10 @@ async function sign(signer, sk, payload = {}, doSign = true, version = "1.0.0")
47
47
  if (type.pk === void 0) throw new Error("Cannot determine key type from signer");
48
48
  const header = headers[type.pk];
49
49
  const headerB64 = (0, _ocap_util.toBase64)((0, json_stable_stringify.default)(header));
50
+ const signerMethod = (0, _arcblock_did.extractMethod)(signer) || "abt";
50
51
  const now = Math.floor(Date.now() / 1e3);
51
52
  const body = {
52
- iss: (0, _arcblock_did.toDid)(signer),
53
+ iss: (0, _arcblock_did.toDid)(signer, signerMethod),
53
54
  iat: String(now),
54
55
  nbf: String(now),
55
56
  exp: String(now + 300),
@@ -201,9 +202,10 @@ async function signDelegationToken(signer, sk, payload) {
201
202
  if (type.pk === void 0) throw new Error("Cannot determine key type from signer");
202
203
  const header = delegationTokenHeaders[type.pk];
203
204
  const headerB64 = (0, _ocap_util.toBase64)((0, json_stable_stringify.default)(header));
205
+ const delegationSignerMethod = (0, _arcblock_did.extractMethod)(signer) || "abt";
204
206
  const now = Math.floor(Date.now() / 1e3);
205
207
  const body = {
206
- iss: (0, _arcblock_did.toDid)(signer),
208
+ iss: (0, _arcblock_did.toDid)(signer, delegationSignerMethod),
207
209
  sub: payload.sub,
208
210
  iat: payload.iat || String(now),
209
211
  nbf: payload.nbf || String(now),
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@arcblock/jwt",
3
3
  "description": "JSON Web Token variant for arcblock DID solutions",
4
4
  "type": "module",
5
- "version": "1.29.18",
5
+ "version": "1.29.20",
6
6
  "author": {
7
7
  "name": "wangshijun",
8
8
  "email": "shijun@arcblock.io",
@@ -19,15 +19,15 @@
19
19
  "access": "public"
20
20
  },
21
21
  "dependencies": {
22
- "@arcblock/did": "1.29.18",
23
- "@ocap/mcrypto": "1.29.18",
24
- "@ocap/util": "1.29.18",
22
+ "@arcblock/did": "1.29.20",
23
+ "@ocap/mcrypto": "1.29.20",
24
+ "@ocap/util": "1.29.20",
25
25
  "debug": "^4.4.3",
26
26
  "json-stable-stringify": "^1.0.1",
27
27
  "semver": "^7.6.3"
28
28
  },
29
29
  "devDependencies": {
30
- "@ocap/wallet": "1.29.18",
30
+ "@ocap/wallet": "1.29.20",
31
31
  "@types/json-stable-stringify": "^1.0.36",
32
32
  "@types/node": "^22.7.5",
33
33
  "@types/semver": "^7.5.8",