@metalabel/dfos-protocol 0.43.0 → 0.44.0

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.
@@ -67,6 +67,7 @@ var keyProofPayloadObject = (payload) => ({
67
67
  publicKeyMultibase: payload.publicKeyMultibase,
68
68
  timestamp: payload.timestamp
69
69
  });
70
+ var bytesEqual = (a, b) => a.length === b.length && a.every((byte, index) => byte === b[index]);
70
71
  var normalizeTimestamp = (ms) => new Date(Math.floor(ms / 1e3) * 1e3).toISOString();
71
72
  var signKeyProof = async (input) => {
72
73
  if (input.typ === "") {
@@ -143,8 +144,12 @@ var verifyKeyProof = (jws, options) => {
143
144
  }
144
145
  let payload;
145
146
  try {
146
- const source = new TextDecoder("utf-8", { fatal: true }).decode(base64urlDecode(payloadB64));
147
+ const payloadBytes = base64urlDecode(payloadB64);
148
+ const source = new TextDecoder("utf-8", { fatal: true }).decode(payloadBytes);
147
149
  payload = validateKeyProofPayload(JSON.parse(source));
150
+ if (!bytesEqual(keyProofSigningInput(payload), payloadBytes)) {
151
+ throw invalid("schema", "payload is not the canonical signing input for its members");
152
+ }
148
153
  } catch (err) {
149
154
  if (err instanceof KeyProofVerifyError) throw err;
150
155
  throw invalid("schema", err instanceof Error ? err.message : "payload is not valid UTF-8 JSON");
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ import {
95
95
  keyProofSigningInput,
96
96
  signKeyProof,
97
97
  verifyKeyProof
98
- } from "./chunk-WCYN7BV7.js";
98
+ } from "./chunk-VEJBAY3T.js";
99
99
  import {
100
100
  ED25519_PRIV_MULTICODEC,
101
101
  ED25519_PUB_MULTICODEC,
@@ -123,8 +123,9 @@ interface VerifiedKeyProof {
123
123
  }
124
124
  /**
125
125
  * Verify a key proof — KEY-PROOF.md's verification algorithm steps 1–5 and 7:
126
- * size cap, header gates, closed payload schema, audience byte-equality,
127
- * freshness, and the signature against the payload's OWN `publicKeyMultibase`.
126
+ * size cap, header gates, the closed payload schema over CANONICAL bytes,
127
+ * audience byte-equality, freshness, and the signature against the payload's OWN
128
+ * `publicKeyMultibase`.
128
129
  *
129
130
  * STEP 6 (NONCE) IS THE CALLER'S, and this function cannot stand in for it. The
130
131
  * nonce MUST be one this verifier minted, for this ceremony, not yet consumed,
@@ -6,7 +6,7 @@ import {
6
6
  keyProofSigningInput,
7
7
  signKeyProof,
8
8
  verifyKeyProof
9
- } from "../chunk-WCYN7BV7.js";
9
+ } from "../chunk-VEJBAY3T.js";
10
10
  import "../chunk-IDVYITX7.js";
11
11
  import "../chunk-4LG2GEB2.js";
12
12
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metalabel/dfos-protocol",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "type": "module",
5
5
  "description": "DFOS Protocol — Ed25519 signed chain primitives, services, credentials, and verification",
6
6
  "license": "MIT",