@metalabel/dfos-protocol 0.52.0 → 0.52.1

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.
@@ -52,9 +52,9 @@ import {
52
52
  verifyIdentityExtensionFromTrustedState,
53
53
  verifyRevocation,
54
54
  verifySignRequest
55
- } from "../chunk-OU2DPHCN.js";
56
- import "../chunk-IV3TIYKP.js";
57
- import "../chunk-QRCOMLAP.js";
55
+ } from "../chunk-Q7FREWMY.js";
56
+ import "../chunk-FZHHSC5N.js";
57
+ import "../chunk-BMIOY5W5.js";
58
58
  import {
59
59
  ED25519_PRIV_MULTICODEC,
60
60
  ED25519_PUB_MULTICODEC,
@@ -62,7 +62,7 @@ import {
62
62
  decodeMultikey,
63
63
  encodeEd25519Multikey
64
64
  } from "../chunk-F7RHI2CK.js";
65
- import "../chunk-QTJZGXMH.js";
65
+ import "../chunk-KAW4MT4P.js";
66
66
  export {
67
67
  ARTIFACT_CID_ANCHOR_RE,
68
68
  ArtifactPayload,
@@ -9,7 +9,7 @@ import {
9
9
  isValidEd25519Signature,
10
10
  sha256,
11
11
  signPayloadEd25519
12
- } from "./chunk-QTJZGXMH.js";
12
+ } from "./chunk-KAW4MT4P.js";
13
13
 
14
14
  // src/key-proof/role-set.ts
15
15
  var KEY_ROLES = ["auth", "assert", "controller"];
@@ -10,7 +10,7 @@ import {
10
10
  decodeJwsUnsafe,
11
11
  sha256,
12
12
  verifyJws
13
- } from "./chunk-QTJZGXMH.js";
13
+ } from "./chunk-KAW4MT4P.js";
14
14
 
15
15
  // src/credentials/schemas.ts
16
16
  import { z } from "zod";
@@ -438,6 +438,7 @@ var verifyDFOSCredential = async (jwsToken, options) => {
438
438
  }
439
439
  const payload = result.data;
440
440
  const kid = decoded.header.kid;
441
+ if (kid === void 0) throw new CredentialVerificationError("credential kid must be present");
441
442
  const hashIdx = kid.indexOf("#");
442
443
  if (hashIdx < 0) throw new CredentialVerificationError("credential kid must be a DID URL");
443
444
  const kidDid = kid.substring(0, hashIdx);
@@ -596,7 +597,7 @@ var matchesResource = async (att, resource, action) => {
596
597
  };
597
598
  var decodeDFOSCredentialUnsafe = (jwsToken) => {
598
599
  const decoded = decodeJwsUnsafe(jwsToken);
599
- if (!decoded) return null;
600
+ if (!decoded || decoded.header.kid === void 0) return null;
600
601
  const result = DFOSCredentialPayload.safeParse(decoded.payload);
601
602
  if (!result.success) return null;
602
603
  return {
@@ -178,7 +178,7 @@ var decodeJwsSegment = (segmentB64) => {
178
178
  var asJwsHeader = (raw) => {
179
179
  if (typeof raw["alg"] !== "string") return null;
180
180
  if (typeof raw["typ"] !== "string") return null;
181
- if (typeof raw["kid"] !== "string") return null;
181
+ if ("kid" in raw && typeof raw["kid"] !== "string") return null;
182
182
  if ("cid" in raw && typeof raw["cid"] !== "string") return null;
183
183
  return raw;
184
184
  };
@@ -6,13 +6,13 @@ import {
6
6
  matchesResource,
7
7
  verifyDFOSCredential,
8
8
  verifyDelegationChain
9
- } from "./chunk-IV3TIYKP.js";
9
+ } from "./chunk-FZHHSC5N.js";
10
10
  import {
11
11
  KEY_ADD_JWS_TYP,
12
12
  KEY_ROLES,
13
13
  unsafeKeyProofSubject,
14
14
  verifyChainKeyProof
15
- } from "./chunk-QRCOMLAP.js";
15
+ } from "./chunk-BMIOY5W5.js";
16
16
  import {
17
17
  decodeEd25519PublicMultikey
18
18
  } from "./chunk-F7RHI2CK.js";
@@ -25,7 +25,7 @@ import {
25
25
  decodeJwsUnsafe,
26
26
  generateIdNoPrefix,
27
27
  verifyJws
28
- } from "./chunk-QTJZGXMH.js";
28
+ } from "./chunk-KAW4MT4P.js";
29
29
 
30
30
  // src/chain/schemas.ts
31
31
  import { z } from "zod";
@@ -560,6 +560,7 @@ var verifyIdentityChain = async (input) => {
560
560
  throw new Error(`log[${idx}]: cid mismatch in protected header`);
561
561
  }
562
562
  const kid = decoded.header.kid;
563
+ if (kid === void 0) throw new Error(`log[${idx}]: kid must be present`);
563
564
  let signingKeyId;
564
565
  if (kid.includes("#")) {
565
566
  const hashIdx = kid.indexOf("#");
@@ -704,6 +705,7 @@ var verifyIdentityExtensionFromTrustedState = async (input) => {
704
705
  if (!decoded.header.cid) throw new Error("missing cid in protected header");
705
706
  if (decoded.header.cid !== operationCID) throw new Error("cid mismatch in protected header");
706
707
  const kid = decoded.header.kid;
708
+ if (kid === void 0) throw new Error("kid must be present");
707
709
  if (!kid.includes("#")) {
708
710
  throw new Error("non-genesis op kid must be DID URL, got bare key ID");
709
711
  }
@@ -892,6 +894,7 @@ var verifyContentChain = async (input) => {
892
894
  }
893
895
  }
894
896
  const kid = decoded.header.kid;
897
+ if (kid === void 0) throw new Error(`log[${idx}]: kid must be present`);
895
898
  const hashIdx = kid.indexOf("#");
896
899
  if (hashIdx < 0) throw new Error(`log[${idx}]: kid must be a DID URL`);
897
900
  const kidDid = kid.substring(0, hashIdx);
@@ -1002,6 +1005,7 @@ var verifyContentExtensionFromTrustedState = async (input) => {
1002
1005
  throw new Error("createdAt must be after last op");
1003
1006
  }
1004
1007
  const kid = decoded.header.kid;
1008
+ if (kid === void 0) throw new Error("kid must be present");
1005
1009
  const hashIdx = kid.indexOf("#");
1006
1010
  if (hashIdx < 0) throw new Error("kid must be a DID URL");
1007
1011
  const kidDid = kid.substring(0, hashIdx);
@@ -1080,6 +1084,7 @@ var verifyCountersignature = async (input) => {
1080
1084
  }
1081
1085
  const payload = result.data;
1082
1086
  const kid = decoded.header.kid;
1087
+ if (kid === void 0) throw new Error("kid must be present");
1083
1088
  const hashIdx = kid.indexOf("#");
1084
1089
  if (hashIdx < 0) throw new Error("countersignature kid must be a DID URL");
1085
1090
  const kidDid = kid.substring(0, hashIdx);
@@ -1133,6 +1138,7 @@ var verifyArtifact = async (input) => {
1133
1138
  throw new Error(`invalid artifact typ: ${decoded.header.typ}`);
1134
1139
  }
1135
1140
  const kid = decoded.header.kid;
1141
+ if (kid === void 0) throw new Error("kid must be present");
1136
1142
  const hashIdx = kid.indexOf("#");
1137
1143
  if (hashIdx < 0) throw new Error("artifact kid must be a DID URL");
1138
1144
  const kidDid = kid.substring(0, hashIdx);
@@ -1190,6 +1196,7 @@ var verifyRevocation = async (input) => {
1190
1196
  throw new Error(`invalid revocation typ: ${decoded.header.typ}`);
1191
1197
  }
1192
1198
  const kid = decoded.header.kid;
1199
+ if (kid === void 0) throw new Error("kid must be present");
1193
1200
  const hashIdx = kid.indexOf("#");
1194
1201
  if (hashIdx < 0) throw new Error("revocation kid must be a DID URL");
1195
1202
  const kidDid = kid.substring(0, hashIdx);
@@ -1295,8 +1302,7 @@ var verifyCreditClaim = async (jwsToken, options) => {
1295
1302
  }
1296
1303
  const decoded = decodeJwsUnsafe(jwsToken);
1297
1304
  if (!decoded) throw invalid("failed to decode credit claim JWS");
1298
- const rawHeader = decoded.header;
1299
- if (typeof rawHeader["typ"] !== "string" || typeof rawHeader["kid"] !== "string") {
1305
+ if (typeof decoded.header.kid !== "string") {
1300
1306
  throw invalid("credit claim header must carry a string typ and kid");
1301
1307
  }
1302
1308
  if (decoded.header.typ !== "did:dfos:credit-claim") {
@@ -1522,7 +1528,7 @@ var verifySignRequest = async (jwsToken, options) => {
1522
1528
  throw invalid2("sign request protected header must be an object");
1523
1529
  }
1524
1530
  assertJwsProfile(rawHeader, invalid2);
1525
- if (typeof rawHeader["typ"] !== "string" || typeof rawHeader["kid"] !== "string") {
1531
+ if (typeof rawHeader["typ"] !== "string" || typeof decoded.header.kid !== "string") {
1526
1532
  throw invalid2("sign request header must carry a string typ and kid");
1527
1533
  }
1528
1534
  if (decoded.header.typ !== "did:dfos:sign-request") {
@@ -34,9 +34,9 @@ import {
34
34
  verifyDelegationChain,
35
35
  verifyIdentityProofEnvelope,
36
36
  verifyRequestProofEnvelope
37
- } from "../chunk-IV3TIYKP.js";
37
+ } from "../chunk-FZHHSC5N.js";
38
38
  import "../chunk-F7RHI2CK.js";
39
- import "../chunk-QTJZGXMH.js";
39
+ import "../chunk-KAW4MT4P.js";
40
40
  export {
41
41
  ApiRequestVerifyError,
42
42
  Attenuation,
@@ -85,7 +85,7 @@ declare const normalizedId: <T extends string>(prefix: T, id: string) => `${T}_$
85
85
  interface JwsHeader {
86
86
  alg: 'EdDSA';
87
87
  typ: string;
88
- kid: string;
88
+ kid?: string;
89
89
  /** CIDv1 of the operation payload (dag-cbor + SHA-256), signed in the protected header */
90
90
  cid?: string;
91
91
  }
@@ -96,7 +96,9 @@ interface JwsHeader {
96
96
  * signature (64 bytes)
97
97
  */
98
98
  declare const createJws: (options: {
99
- header: JwsHeader;
99
+ header: JwsHeader & {
100
+ kid: string;
101
+ };
100
102
  payload: Record<string, unknown>;
101
103
  sign: (message: Uint8Array) => Promise<Uint8Array>;
102
104
  }) => Promise<string>;
@@ -23,7 +23,7 @@ import {
23
23
  signPayloadEd25519,
24
24
  verifyJws,
25
25
  verifyJwt
26
- } from "../chunk-QTJZGXMH.js";
26
+ } from "../chunk-KAW4MT4P.js";
27
27
  export {
28
28
  JwsVerificationError,
29
29
  JwtVerificationError,
package/dist/index.js CHANGED
@@ -52,7 +52,7 @@ import {
52
52
  verifyIdentityExtensionFromTrustedState,
53
53
  verifyRevocation,
54
54
  verifySignRequest
55
- } from "./chunk-OU2DPHCN.js";
55
+ } from "./chunk-Q7FREWMY.js";
56
56
  import {
57
57
  ApiRequestVerifyError,
58
58
  Attenuation,
@@ -92,7 +92,7 @@ import {
92
92
  verifyDelegationChain,
93
93
  verifyIdentityProofEnvelope,
94
94
  verifyRequestProofEnvelope
95
- } from "./chunk-IV3TIYKP.js";
95
+ } from "./chunk-FZHHSC5N.js";
96
96
  import {
97
97
  DEFAULT_KEY_PROOF_SKEW_SECONDS,
98
98
  KEY_ADD_JWS_TYP,
@@ -109,7 +109,7 @@ import {
109
109
  unsafeKeyProofSubject,
110
110
  verifyChainKeyProof,
111
111
  verifyKeyProof
112
- } from "./chunk-QRCOMLAP.js";
112
+ } from "./chunk-BMIOY5W5.js";
113
113
  import {
114
114
  ED25519_PRIV_MULTICODEC,
115
115
  ED25519_PUB_MULTICODEC,
@@ -142,7 +142,7 @@ import {
142
142
  signPayloadEd25519,
143
143
  verifyJws,
144
144
  verifyJwt
145
- } from "./chunk-QTJZGXMH.js";
145
+ } from "./chunk-KAW4MT4P.js";
146
146
  import {
147
147
  INDEX_V1_SCHEMA,
148
148
  byteCompare,
@@ -143,7 +143,7 @@ interface SignKeyProofInput {
143
143
  * The protected header is EXACTLY `{"alg":"EdDSA","typ":"<purpose>"}` — two
144
144
  * members, no `kid` (the key is in no chain and rides in the payload) and no
145
145
  * `cid` (there is no operation to bind). It is assembled by hand rather than
146
- * through `createJws`, whose `JwsHeader` requires a `kid` this envelope must not
146
+ * through `createJws`, whose header input requires a `kid` this envelope must not
147
147
  * carry.
148
148
  *
149
149
  * HOLDER OBLIGATIONS THIS FUNCTION CANNOT DISCHARGE (INTEGRATIONS.md, Holder
@@ -14,9 +14,9 @@ import {
14
14
  unsafeKeyProofSubject,
15
15
  verifyChainKeyProof,
16
16
  verifyKeyProof
17
- } from "../chunk-QRCOMLAP.js";
17
+ } from "../chunk-BMIOY5W5.js";
18
18
  import "../chunk-F7RHI2CK.js";
19
- import "../chunk-QTJZGXMH.js";
19
+ import "../chunk-KAW4MT4P.js";
20
20
  export {
21
21
  DEFAULT_KEY_PROOF_SKEW_SECONDS,
22
22
  KEY_ADD_JWS_TYP,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metalabel/dfos-protocol",
3
- "version": "0.52.0",
3
+ "version": "0.52.1",
4
4
  "type": "module",
5
5
  "description": "DFOS Protocol — Ed25519 signed chain primitives, services, credentials, and verification",
6
6
  "license": "MIT",