@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
|
|
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
|
@@ -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
|
|
127
|
-
* freshness, and the signature against the payload's OWN
|
|
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,
|
package/dist/key-proof/index.js
CHANGED