@adcp/sdk 7.6.0 → 7.8.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.
- package/bin/adcp.js +3 -1
- package/dist/lib/errors/index.d.ts +54 -0
- package/dist/lib/errors/index.d.ts.map +1 -1
- package/dist/lib/errors/index.js +132 -1
- package/dist/lib/errors/index.js.map +1 -1
- package/dist/lib/index.d.ts +4 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +38 -9
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/media-buy/available-actions.d.ts +60 -0
- package/dist/lib/media-buy/available-actions.d.ts.map +1 -0
- package/dist/lib/media-buy/available-actions.js +112 -0
- package/dist/lib/media-buy/available-actions.js.map +1 -0
- package/dist/lib/media-buy/index.d.ts +9 -0
- package/dist/lib/media-buy/index.d.ts.map +1 -0
- package/dist/lib/media-buy/index.js +36 -0
- package/dist/lib/media-buy/index.js.map +1 -0
- package/dist/lib/media-buy/preflight.d.ts +118 -0
- package/dist/lib/media-buy/preflight.d.ts.map +1 -0
- package/dist/lib/media-buy/preflight.js +376 -0
- package/dist/lib/media-buy/preflight.js.map +1 -0
- package/dist/lib/media-buy/types.d.ts +113 -0
- package/dist/lib/media-buy/types.d.ts.map +1 -0
- package/dist/lib/media-buy/types.js +25 -0
- package/dist/lib/media-buy/types.js.map +1 -0
- package/dist/lib/media-buy/update-fields.generated.d.ts +14 -0
- package/dist/lib/media-buy/update-fields.generated.d.ts.map +1 -0
- package/dist/lib/media-buy/update-fields.generated.js +137 -0
- package/dist/lib/media-buy/update-fields.generated.js.map +1 -0
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/decisioning/account.d.ts +27 -0
- package/dist/lib/server/decisioning/account.d.ts.map +1 -1
- package/dist/lib/server/decisioning/account.js.map +1 -1
- package/dist/lib/server/decisioning/context.d.ts +65 -0
- package/dist/lib/server/decisioning/context.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.js +59 -58
- package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.d.ts +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.d.ts.map +1 -1
- package/dist/lib/server/decisioning/runtime/to-context.js +2 -1
- package/dist/lib/server/decisioning/runtime/to-context.js.map +1 -1
- package/dist/lib/server/test-controller.d.ts +46 -1
- package/dist/lib/server/test-controller.d.ts.map +1 -1
- package/dist/lib/server/test-controller.js +49 -2
- package/dist/lib/server/test-controller.js.map +1 -1
- package/dist/lib/signing/canonicalize.d.ts +53 -0
- package/dist/lib/signing/canonicalize.d.ts.map +1 -1
- package/dist/lib/signing/canonicalize.js +33 -1
- package/dist/lib/signing/canonicalize.js.map +1 -1
- package/dist/lib/signing/client.d.ts +6 -5
- package/dist/lib/signing/client.d.ts.map +1 -1
- package/dist/lib/signing/client.js +16 -1
- package/dist/lib/signing/client.js.map +1 -1
- package/dist/lib/signing/errors.d.ts +11 -0
- package/dist/lib/signing/errors.d.ts.map +1 -1
- package/dist/lib/signing/errors.js +11 -1
- package/dist/lib/signing/errors.js.map +1 -1
- package/dist/lib/signing/jwks-helpers.d.ts +11 -1
- package/dist/lib/signing/jwks-helpers.d.ts.map +1 -1
- package/dist/lib/signing/jwks-helpers.js.map +1 -1
- package/dist/lib/signing/provider.d.ts +17 -0
- package/dist/lib/signing/provider.d.ts.map +1 -1
- package/dist/lib/signing/replay.d.ts +16 -0
- package/dist/lib/signing/replay.d.ts.map +1 -1
- package/dist/lib/signing/replay.js.map +1 -1
- package/dist/lib/signing/request-context.d.ts +140 -0
- package/dist/lib/signing/request-context.d.ts.map +1 -0
- package/dist/lib/signing/request-context.js +160 -0
- package/dist/lib/signing/request-context.js.map +1 -0
- package/dist/lib/signing/response-verifier.d.ts +105 -0
- package/dist/lib/signing/response-verifier.d.ts.map +1 -0
- package/dist/lib/signing/response-verifier.js +271 -0
- package/dist/lib/signing/response-verifier.js.map +1 -0
- package/dist/lib/signing/server.d.ts +5 -3
- package/dist/lib/signing/server.d.ts.map +1 -1
- package/dist/lib/signing/server.js +13 -1
- package/dist/lib/signing/server.js.map +1 -1
- package/dist/lib/signing/signer-async.d.ts +8 -2
- package/dist/lib/signing/signer-async.d.ts.map +1 -1
- package/dist/lib/signing/signer-async.js +14 -0
- package/dist/lib/signing/signer-async.js.map +1 -1
- package/dist/lib/signing/signer.d.ts +170 -1
- package/dist/lib/signing/signer.d.ts.map +1 -1
- package/dist/lib/signing/signer.js +153 -0
- package/dist/lib/signing/signer.js.map +1 -1
- package/dist/lib/signing/testing.d.ts +14 -3
- package/dist/lib/signing/testing.d.ts.map +1 -1
- package/dist/lib/signing/testing.js +14 -0
- package/dist/lib/signing/testing.js.map +1 -1
- package/dist/lib/signing/types.d.ts +36 -0
- package/dist/lib/signing/types.d.ts.map +1 -1
- package/dist/lib/signing/types.js +37 -1
- package/dist/lib/signing/types.js.map +1 -1
- package/dist/lib/testing/comply-controller.d.ts +26 -1
- package/dist/lib/testing/comply-controller.d.ts.map +1 -1
- package/dist/lib/testing/comply-controller.js +17 -7
- package/dist/lib/testing/comply-controller.js.map +1 -1
- package/dist/lib/testing/index.d.ts +1 -1
- package/dist/lib/testing/index.d.ts.map +1 -1
- package/dist/lib/testing/index.js.map +1 -1
- package/dist/lib/testing/storyboard/agent-routing.d.ts +20 -3
- package/dist/lib/testing/storyboard/agent-routing.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/agent-routing.js +60 -10
- package/dist/lib/testing/storyboard/agent-routing.js.map +1 -1
- package/dist/lib/testing/storyboard/default-invariants.js +111 -59
- package/dist/lib/testing/storyboard/default-invariants.js.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/builder.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/builder.js +10 -1
- package/dist/lib/testing/storyboard/request-signing/builder.js.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/grader.d.ts +24 -10
- package/dist/lib/testing/storyboard/request-signing/grader.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/request-signing/grader.js +123 -29
- package/dist/lib/testing/storyboard/request-signing/grader.js.map +1 -1
- package/dist/lib/testing/storyboard/runner.d.ts +9 -1
- package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/runner.js +30 -1
- package/dist/lib/testing/storyboard/runner.js.map +1 -1
- package/dist/lib/testing/storyboard/types.d.ts +128 -3
- package/dist/lib/testing/storyboard/types.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/types.js.map +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/validations.js +223 -22
- package/dist/lib/testing/storyboard/validations.js.map +1 -1
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* RFC 9421 response-signing verifier (§2.2.9).
|
|
4
|
+
*
|
|
5
|
+
* Companion to `verifier.ts` (request signatures) and `webhook-verifier.ts`
|
|
6
|
+
* (webhook callbacks). This verifier runs on the buyer / receiver side of
|
|
7
|
+
* a signed response: a client receives a response from a seller agent and
|
|
8
|
+
* hands it here, with the originating request URL the client sent, for
|
|
9
|
+
* signature validation before parsing the body.
|
|
10
|
+
*
|
|
11
|
+
* Distinct from request / webhook signing:
|
|
12
|
+
* - Tag: `adcp/response-signing/v1`.
|
|
13
|
+
* - Key purpose: `adcp_use: "response-signing"`.
|
|
14
|
+
* - Default covered components: `@status`, `@authority`, `@target-uri`,
|
|
15
|
+
* plus `content-type` + `content-digest` when the body is non-empty.
|
|
16
|
+
* - The originating request URL is carried explicitly on `ResponseLike.request`
|
|
17
|
+
* because RFC 9421 §2.2 binds response signatures to their request
|
|
18
|
+
* context via `@authority` and `@target-uri`. The client supplies the URL
|
|
19
|
+
* it actually sent — a malformed reconstruction (e.g. `req.protocol`
|
|
20
|
+
* lying behind a proxy) will trip step 6a or fail the crypto check.
|
|
21
|
+
*
|
|
22
|
+
* Checklist steps below mirror the 13-step shape in `webhook-verifier.ts`
|
|
23
|
+
* so failures point at the same step numbers the request and webhook
|
|
24
|
+
* verifiers use. Numbers are 1-based.
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.verifyResponseSignature = verifyResponseSignature;
|
|
28
|
+
exports.createResponseVerifier = createResponseVerifier;
|
|
29
|
+
const canonicalize_1 = require("./canonicalize");
|
|
30
|
+
const content_digest_1 = require("./content-digest");
|
|
31
|
+
const errors_1 = require("./errors");
|
|
32
|
+
const parser_1 = require("./parser");
|
|
33
|
+
const crypto_1 = require("./crypto");
|
|
34
|
+
const replay_1 = require("./replay");
|
|
35
|
+
const revocation_1 = require("./revocation");
|
|
36
|
+
const types_1 = require("./types");
|
|
37
|
+
/**
|
|
38
|
+
* Verify an inbound response's RFC 9421 signature.
|
|
39
|
+
*
|
|
40
|
+
* Ordering invariant matches the webhook verifier: cheap invariant checks
|
|
41
|
+
* (tag, alg, window, components) run before JWKS resolution; revocation and
|
|
42
|
+
* rate-abuse run before cryptographic verify so an attacker can't amplify
|
|
43
|
+
* Ed25519/ECDSA work. Replay insert commits only after every earlier check
|
|
44
|
+
* passes — any signature failing crypto verify never consumes a cap entry.
|
|
45
|
+
*
|
|
46
|
+
* The replay scope is `(keyid, @target-uri-of-originating-request)`. Two
|
|
47
|
+
* responses to two different request URLs under the same keyid use
|
|
48
|
+
* independent replay budgets — same shape as webhook verification.
|
|
49
|
+
*
|
|
50
|
+
* Throws {@link ResponseSignatureError} on the first failed step.
|
|
51
|
+
*/
|
|
52
|
+
async function verifyResponseSignature(response, options) {
|
|
53
|
+
const now = options.now ? options.now() : Math.floor(Date.now() / 1000);
|
|
54
|
+
const requiredTag = options.requiredTag ?? types_1.RESPONSE_SIGNING_TAG;
|
|
55
|
+
// Step 1: both signature headers present AND parseable. Bound-pair rule.
|
|
56
|
+
const sigInputHeader = (0, canonicalize_1.getHeaderValue)(response.headers, 'Signature-Input');
|
|
57
|
+
const sigHeader = (0, canonicalize_1.getHeaderValue)(response.headers, 'Signature');
|
|
58
|
+
if (!sigInputHeader || !sigHeader) {
|
|
59
|
+
throw new errors_1.ResponseSignatureError('response_signature_header_malformed', 1, 'Response is missing Signature or Signature-Input headers.');
|
|
60
|
+
}
|
|
61
|
+
let parsedInput;
|
|
62
|
+
let parsedSig;
|
|
63
|
+
try {
|
|
64
|
+
parsedInput = (0, parser_1.parseSignatureInput)(sigInputHeader);
|
|
65
|
+
parsedSig = (0, parser_1.parseSignature)(sigHeader, parsedInput.label);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
throw new errors_1.ResponseSignatureError('response_signature_header_malformed', 1, err instanceof Error ? err.message : String(err));
|
|
69
|
+
}
|
|
70
|
+
// Step 2: required params present.
|
|
71
|
+
requireParams(parsedInput);
|
|
72
|
+
// Step 3: tag match.
|
|
73
|
+
if (parsedInput.params.tag !== requiredTag) {
|
|
74
|
+
throw new errors_1.ResponseSignatureError('response_signature_tag_invalid', 3, `Signature tag must be "${requiredTag}"; got "${parsedInput.params.tag}".`);
|
|
75
|
+
}
|
|
76
|
+
// Step 4: alg allowlist.
|
|
77
|
+
if (!types_1.ALLOWED_ALGS.has(parsedInput.params.alg)) {
|
|
78
|
+
throw new errors_1.ResponseSignatureError('response_signature_alg_not_allowed', 4, `Signature alg "${parsedInput.params.alg}" is not in the AdCP allowlist.`);
|
|
79
|
+
}
|
|
80
|
+
// Step 5: window valid.
|
|
81
|
+
validateWindow(parsedInput.params.created, parsedInput.params.expires, now);
|
|
82
|
+
// Step 6: covered components must include the response-signing mandatory set.
|
|
83
|
+
validateCoveredComponents(parsedInput.components, response.body);
|
|
84
|
+
// Step 6a: `@target-uri` syntactic validation against the originating-
|
|
85
|
+
// request URL the caller passed in. Same rationale as the webhook
|
|
86
|
+
// verifier — flag dangerous URI shapes (non-https, userinfo, fragment)
|
|
87
|
+
// before cryptographic work. Distinct from `header_malformed`, which
|
|
88
|
+
// flags the Signature / Signature-Input headers.
|
|
89
|
+
//
|
|
90
|
+
// Note: response-side `@target-uri` comes from `response.request.url`,
|
|
91
|
+
// which is the *client's* reconstruction of what they sent. This check
|
|
92
|
+
// most often fires on caller-side bugs (Express `req.protocol` lying
|
|
93
|
+
// behind a non-trust-proxy reverse proxy → http://...) rather than on
|
|
94
|
+
// wire-level attacker payloads. See ResponseLike.request JSDoc.
|
|
95
|
+
validateTargetUri(response.request.url);
|
|
96
|
+
// Step 7: resolve keyid.
|
|
97
|
+
const jwk = await options.jwks.resolve(parsedInput.params.keyid);
|
|
98
|
+
if (!jwk) {
|
|
99
|
+
throw new errors_1.ResponseSignatureError('response_signature_key_unknown', 7, `No JWK found for keyid "${parsedInput.params.keyid}".`);
|
|
100
|
+
}
|
|
101
|
+
if (jwk.kid !== parsedInput.params.keyid) {
|
|
102
|
+
throw new errors_1.ResponseSignatureError('response_signature_key_unknown', 7, `JWKS resolver returned a JWK whose kid "${jwk.kid}" does not match requested keyid "${parsedInput.params.keyid}".`);
|
|
103
|
+
}
|
|
104
|
+
// Step 8: key purpose — MUST be scoped for response signing.
|
|
105
|
+
//
|
|
106
|
+
// Same split as webhook: "no purpose declared" vs "declared but wrong".
|
|
107
|
+
// The former needs the publisher to add a purpose; the latter needs a
|
|
108
|
+
// new keypair (purpose binding is the whole point of `adcp_use`).
|
|
109
|
+
if (jwk.adcp_use === undefined || !jwk.key_ops?.includes('verify')) {
|
|
110
|
+
throw new errors_1.ResponseSignatureError('response_signature_key_purpose_invalid', 8, `JWK "${jwk.kid}" is not scoped for response-signing verification.`);
|
|
111
|
+
}
|
|
112
|
+
if (jwk.adcp_use !== 'response-signing') {
|
|
113
|
+
throw new errors_1.ResponseSignatureError('response_mode_mismatch', 8, `JWK "${jwk.kid}" declares adcp_use="${jwk.adcp_use}" but this endpoint requires "response-signing".`);
|
|
114
|
+
}
|
|
115
|
+
// Step 9: revocation. The shared revocation store throws
|
|
116
|
+
// `request_signature_revocation_stale` when its cached snapshot is past
|
|
117
|
+
// grace — re-map to the response taxonomy so callers see consistent codes.
|
|
118
|
+
try {
|
|
119
|
+
if (await options.revocationStore.isRevoked(jwk.kid)) {
|
|
120
|
+
throw new errors_1.ResponseSignatureError('response_signature_key_revoked', 9, `JWK "${jwk.kid}" is revoked.`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
if (err instanceof errors_1.RequestSignatureError && err.code === 'request_signature_revocation_stale') {
|
|
125
|
+
throw new errors_1.ResponseSignatureError('response_signature_revocation_stale', 9, err.message);
|
|
126
|
+
}
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
// Replay scope is `(keyid, @target-uri-of-originating-request)` — same
|
|
130
|
+
// rationale as webhook signing. A response to /adcp/get_products MUST NOT
|
|
131
|
+
// count against the replay budget for a response to /adcp/create_media_buy
|
|
132
|
+
// under the same keyid.
|
|
133
|
+
const replayScope = (0, canonicalize_1.canonicalTargetUri)(response.request.url);
|
|
134
|
+
// Step 9a: per-keyid rate abuse. Distinct code from step 12 replay — cap
|
|
135
|
+
// exhaustion is a compromised-key / misconfig signal, not "same nonce
|
|
136
|
+
// twice."
|
|
137
|
+
if (await options.replayStore.isCapHit(jwk.kid, replayScope, now)) {
|
|
138
|
+
throw new errors_1.ResponseSignatureError('response_signature_rate_abuse', 9, `Per-keyid replay cache cap exceeded for keyid=${jwk.kid}.`);
|
|
139
|
+
}
|
|
140
|
+
// Pre-check replay before crypto so a replayed nonce short-circuits an
|
|
141
|
+
// expensive Ed25519 / ECDSA verify.
|
|
142
|
+
if (await options.replayStore.has(jwk.kid, replayScope, parsedInput.params.nonce, now)) {
|
|
143
|
+
throw new errors_1.ResponseSignatureError('response_signature_replayed', 12, `Replay of (keyid=${jwk.kid}, nonce=${parsedInput.params.nonce}) within signature window.`);
|
|
144
|
+
}
|
|
145
|
+
// Step 10: cryptographic verify. Use the verbatim signatureParamsValue
|
|
146
|
+
// from the parsed input so byte-identity with what the signer sent is
|
|
147
|
+
// preserved regardless of param-order differences across SDKs.
|
|
148
|
+
const base = (0, canonicalize_1.buildResponseSignatureBase)(parsedInput.components, response, parsedInput.params, parsedInput.signatureParamsValue);
|
|
149
|
+
const publicKey = (0, crypto_1.jwkToPublicKey)(jwk);
|
|
150
|
+
const valid = (0, crypto_1.verifySignature)(parsedInput.params.alg, publicKey, Buffer.from(base, 'utf8'), parsedSig.bytes);
|
|
151
|
+
if (!valid) {
|
|
152
|
+
throw new errors_1.ResponseSignatureError('response_signature_invalid', 10, 'Cryptographic verification of response signature base failed.');
|
|
153
|
+
}
|
|
154
|
+
// Step 11: content-digest match (only when the signature covered it).
|
|
155
|
+
if (parsedInput.components.includes('content-digest')) {
|
|
156
|
+
const digestHeader = (0, canonicalize_1.getHeaderValue)(response.headers, 'Content-Digest');
|
|
157
|
+
if (!digestHeader || !(0, content_digest_1.contentDigestMatches)(digestHeader, response.body ?? '')) {
|
|
158
|
+
throw new errors_1.ResponseSignatureError('response_signature_digest_mismatch', 11, 'Content-Digest header does not match recomputed body hash.');
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Step 13: commit nonce. Insert AFTER every prior check passes — external
|
|
162
|
+
// traffic can't grow the cap because any signature failing at step 10
|
|
163
|
+
// never reaches this point.
|
|
164
|
+
const remaining = parsedInput.params.expires - now + types_1.CLOCK_SKEW_TOLERANCE_SECONDS;
|
|
165
|
+
const ttl = Math.max(remaining, types_1.MAX_SIGNATURE_WINDOW_SECONDS + types_1.CLOCK_SKEW_TOLERANCE_SECONDS);
|
|
166
|
+
const insertResult = await options.replayStore.insert(jwk.kid, replayScope, parsedInput.params.nonce, ttl, now);
|
|
167
|
+
if (insertResult === 'replayed') {
|
|
168
|
+
throw new errors_1.ResponseSignatureError('response_signature_replayed', 13, `Replay of (keyid=${jwk.kid}, nonce=${parsedInput.params.nonce}) within signature window.`);
|
|
169
|
+
}
|
|
170
|
+
if (insertResult === 'rate_abuse') {
|
|
171
|
+
throw new errors_1.ResponseSignatureError('response_signature_rate_abuse', 13, `Per-keyid replay cache cap exceeded on commit for keyid=${jwk.kid}.`);
|
|
172
|
+
}
|
|
173
|
+
const agent_url = options.agentUrlForKeyid?.(jwk.kid);
|
|
174
|
+
return { status: 'verified', keyid: jwk.kid, ...(agent_url !== undefined && { agent_url }), verified_at: now };
|
|
175
|
+
}
|
|
176
|
+
function requireParams(parsed) {
|
|
177
|
+
const required = ['created', 'expires', 'nonce', 'keyid', 'alg', 'tag'];
|
|
178
|
+
const missing = required.filter(k => parsed.params[k] === undefined);
|
|
179
|
+
if (missing.length) {
|
|
180
|
+
throw new errors_1.ResponseSignatureError('response_signature_params_incomplete', 2, `Signature-Input missing required parameter(s): ${missing.join(', ')}.`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function validateWindow(created, expires, now) {
|
|
184
|
+
// Same shape as webhook: every window failure (expired, negative window,
|
|
185
|
+
// over-long window, created-in-future) folds to a single code. Specific
|
|
186
|
+
// subtype lives in the error message for diagnostics.
|
|
187
|
+
if (expires <= created) {
|
|
188
|
+
throw new errors_1.ResponseSignatureError('response_signature_window_invalid', 5, 'Signature expires must be strictly greater than created.');
|
|
189
|
+
}
|
|
190
|
+
if (expires - created > types_1.MAX_SIGNATURE_WINDOW_SECONDS) {
|
|
191
|
+
throw new errors_1.ResponseSignatureError('response_signature_window_invalid', 5, `Signature window exceeds ${types_1.MAX_SIGNATURE_WINDOW_SECONDS}s maximum.`);
|
|
192
|
+
}
|
|
193
|
+
if (now < created - types_1.CLOCK_SKEW_TOLERANCE_SECONDS) {
|
|
194
|
+
throw new errors_1.ResponseSignatureError('response_signature_window_invalid', 5, 'Signature created is in the future beyond skew tolerance.');
|
|
195
|
+
}
|
|
196
|
+
if (now > expires + types_1.CLOCK_SKEW_TOLERANCE_SECONDS) {
|
|
197
|
+
throw new errors_1.ResponseSignatureError('response_signature_window_invalid', 5, 'Signature is expired.');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function validateCoveredComponents(components, body) {
|
|
201
|
+
for (const mandatory of types_1.RESPONSE_MANDATORY_COMPONENTS) {
|
|
202
|
+
if (!components.includes(mandatory)) {
|
|
203
|
+
throw new errors_1.ResponseSignatureError('response_signature_components_incomplete', 6, `Covered components must include "${mandatory}".`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// When the response carries a body, `content-digest` coverage is required
|
|
207
|
+
// — an unbound body is the cross-purpose footgun the signer's default
|
|
208
|
+
// opt-out behavior is designed to prevent. The signer omits
|
|
209
|
+
// content-digest only when the body is empty (e.g. 204 No Content); the
|
|
210
|
+
// verifier mirrors that envelope.
|
|
211
|
+
const hasBody = (body ?? '').length > 0;
|
|
212
|
+
if (hasBody && !components.includes('content-digest')) {
|
|
213
|
+
throw new errors_1.ResponseSignatureError('response_signature_components_incomplete', 6, 'Response carries a body but "content-digest" is not in covered components.');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Syntactic validation of the originating-request `@target-uri` value. Four
|
|
218
|
+
* failure modes mirror the webhook verifier:
|
|
219
|
+
* - URL doesn't parse at all.
|
|
220
|
+
* - Scheme is not https (response signatures bound to http will fail
|
|
221
|
+
* strict-HTTPS verifier profiles; loopback hosts are exempt for local
|
|
222
|
+
* test mock servers).
|
|
223
|
+
* - Authority contains userinfo — credentials don't belong in a signed URI.
|
|
224
|
+
* - URL carries a fragment — fragments are client-side and never transmitted.
|
|
225
|
+
*
|
|
226
|
+
* Each throws `response_target_uri_malformed`. The error message names the
|
|
227
|
+
* failure reason.
|
|
228
|
+
*/
|
|
229
|
+
function validateTargetUri(rawUrl) {
|
|
230
|
+
let url;
|
|
231
|
+
try {
|
|
232
|
+
url = new URL(rawUrl);
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
throw new errors_1.ResponseSignatureError('response_target_uri_malformed', 6, `@target-uri "${rawUrl}" is not a parseable URL.`);
|
|
236
|
+
}
|
|
237
|
+
if (url.protocol !== 'https:' && !isLoopbackHost(url.hostname)) {
|
|
238
|
+
throw new errors_1.ResponseSignatureError('response_target_uri_malformed', 6, `@target-uri must use https; got "${url.protocol}" in "${rawUrl}".`);
|
|
239
|
+
}
|
|
240
|
+
if (url.username || url.password) {
|
|
241
|
+
throw new errors_1.ResponseSignatureError('response_target_uri_malformed', 6, '@target-uri must not embed userinfo.');
|
|
242
|
+
}
|
|
243
|
+
if (url.hash) {
|
|
244
|
+
throw new errors_1.ResponseSignatureError('response_target_uri_malformed', 6, '@target-uri must not carry a fragment.');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function isLoopbackHost(hostname) {
|
|
248
|
+
if (!hostname)
|
|
249
|
+
return false;
|
|
250
|
+
const normalized = hostname.toLowerCase();
|
|
251
|
+
return normalized === 'localhost' || normalized === '::1' || normalized.startsWith('127.');
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Create a bound response-signature verifier with shared replay and
|
|
255
|
+
* revocation stores. Mirrors {@link createWebhookVerifier} for the response
|
|
256
|
+
* profile.
|
|
257
|
+
*
|
|
258
|
+
* **Why a factory?** Replay detection requires the same store instance to
|
|
259
|
+
* be consulted across every response. Constructing stores inside a
|
|
260
|
+
* per-response call would silently defeat replay dedup. The factory pattern
|
|
261
|
+
* captures stores in closure scope at wire-up time.
|
|
262
|
+
*
|
|
263
|
+
* **Multi-replica deployments MUST pass an explicit `replayStore`** backed
|
|
264
|
+
* by a shared persistence layer.
|
|
265
|
+
*/
|
|
266
|
+
function createResponseVerifier(options) {
|
|
267
|
+
const replayStore = options.replayStore ?? new replay_1.InMemoryReplayStore();
|
|
268
|
+
const revocationStore = options.revocationStore ?? new revocation_1.InMemoryRevocationStore();
|
|
269
|
+
return (response) => verifyResponseSignature(response, { ...options, replayStore, revocationStore });
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=response-verifier.js.map
|
|
@@ -0,0 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ate `@adcp/sdk/signing` barrel re-exports
|
|
9
9
|
* both for back-compat.
|
|
10
10
|
*/
|
|
11
|
-
export { buildSignatureBase, canonicalAuthority, canonicalMethod, canonicalTargetUri, formatSignatureParams, getHeaderValue, type RequestLike, type SignatureParams, } from './canonicalize';
|
|
11
|
+
export { buildResponseSignatureBase, buildSignatureBase, canonicalAuthority, canonicalMethod, canonicalTargetUri, formatSignatureParams, getHeaderValue, type RequestLike, type ResponseLike, type SignatureParams, } from './canonicalize';
|
|
12
12
|
export { computeContentDigest, contentDigestMatches, parseContentDigest } from './content-digest';
|
|
13
|
+
export { requestContextFromExpress, requestContextFromFetch, requestContextFromLambda, type ExpressRequestLike, type FetchRequestLike, type LambdaRequestEvent, type RequestContextFromExpressOptions, type RequestContextFromLambdaOptions, } from './request-context';
|
|
13
14
|
export { jwkToPublicKey, verifySignature } from './crypto';
|
|
14
|
-
export { RequestSignatureError, type RequestSignatureErrorCode, WebhookSignatureError, type WebhookSignatureErrorCode, } from './errors';
|
|
15
|
+
export { RequestSignatureError, type RequestSignatureErrorCode, ResponseSignatureError, type ResponseSignatureErrorCode, WebhookSignatureError, type WebhookSignatureErrorCode, } from './errors';
|
|
15
16
|
export { StaticJwksResolver, type JwksResolver } from './jwks';
|
|
16
17
|
export { HttpsJwksResolver, type HttpsJwksResolverOptions } from './jwks-https';
|
|
17
18
|
export { BrandJsonJwksResolver, BrandJsonResolverError, type BrandAgentType, type BrandJsonJwksResolverOptions, type BrandJsonResolverErrorCode, } from './brand-jwks';
|
|
@@ -20,8 +21,9 @@ export { InMemoryReplayStore, type InMemoryReplayStoreOptions, type ReplayInsert
|
|
|
20
21
|
export { PostgresReplayStore, REPLAY_CACHE_MIGRATION, getReplayStoreMigration, sweepExpiredReplays, type PostgresReplayStoreOptions, type SweepExpiredReplaysOptions, } from './postgres-replay-store';
|
|
21
22
|
export { InMemoryRevocationStore, type RevocationStore } from './revocation';
|
|
22
23
|
export { HttpsRevocationStore, type HttpsRevocationStoreOptions } from './revocation-https';
|
|
23
|
-
export { ALLOWED_ALGS, CLOCK_SKEW_TOLERANCE_SECONDS, MANDATORY_COMPONENTS, MAX_SIGNATURE_WINDOW_SECONDS, REQUEST_SIGNING_TAG, type AdcpJsonWebKey, type ContentDigestPolicy, type RevocationSnapshot, type VerifiedSigner, type VerifierCapability, type VerifyResult, } from './types';
|
|
24
|
+
export { ALLOWED_ALGS, CLOCK_SKEW_TOLERANCE_SECONDS, MANDATORY_COMPONENTS, MAX_SIGNATURE_WINDOW_SECONDS, REQUEST_SIGNING_TAG, RESPONSE_MANDATORY_COMPONENTS, RESPONSE_SIGNING_TAG, type AdcpJsonWebKey, type ContentDigestPolicy, type RevocationSnapshot, type VerifiedSigner, type VerifierCapability, type VerifyResult, } from './types';
|
|
24
25
|
export { verifyRequestSignature, type VerifyRequestOptions } from './verifier';
|
|
26
|
+
export { createResponseVerifier, verifyResponseSignature, type CreateResponseVerifierOptions, type VerifyResponseOptions, type VerifyResponseResult, } from './response-verifier';
|
|
25
27
|
export { createWebhookVerifier, verifyWebhookSignature, WEBHOOK_MANDATORY_COMPONENTS, WEBHOOK_SIGNING_TAG, type CreateWebhookVerifierOptions, type VerifyWebhookOptions, type VerifyWebhookResult, } from './webhook-verifier';
|
|
26
28
|
export { createExpressVerifier, type ExpressLike, type ExpressMiddlewareOptions } from './middleware';
|
|
27
29
|
export { resolveAgent, getAgentJwks, createAgentJwksSet, AgentResolverError, attackerInfluencedFields, ATTACKER_INFLUENCED, readBrandJsonUrl, readIdentityPosture, type AgentResolution, type AgentProtocol, type AgentResolverErrorCode, type AgentResolverErrorDetail, type AgentEntry, type AgentJwksResult, type CapabilitiesWithBrandJsonUrl, type CreateAgentJwksSetOptions, type FetchCapabilitiesFn, type GetAgentJwksOptions, type IdentityKeyOriginPurpose, type IdentityKeyOrigins, type IdentityPosture, type ResolveAgentOptions, type TraceStep, } from './agent-resolver';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","source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AAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,oBAAoB,EACpB,4BAA4B,EAC5B,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,4BAA4B,EAC5B,mBAAmB,EACnB,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,KAAK,WAAW,EAAE,KAAK,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACtG,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,SAAS,GACf,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/lib/signing/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KA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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AgentResolverError = exports.createAgentJwksSet = exports.getAgentJwks = exports.resolveAgent = exports.createExpressVerifier = exports.WEBHOOK_SIGNING_TAG = exports.WEBHOOK_MANDATORY_COMPONENTS = exports.verifyWebhookSignature = exports.createWebhookVerifier = exports.verifyResponseSignature = exports.createResponseVerifier = exports.verifyRequestSignature = exports.RESPONSE_SIGNING_TAG = exports.RESPONSE_MANDATORY_COMPONENTS = exports.REQUEST_SIGNING_TAG = exports.MAX_SIGNATURE_WINDOW_SECONDS = exports.MANDATORY_COMPONENTS = exports.CLOCK_SKEW_TOLERANCE_SECONDS = exports.ALLOWED_ALGS = exports.HttpsRevocationStore = exports.InMemoryRevocationStore = exports.sweepExpiredReplays = exports.getReplayStoreMigration = exports.REPLAY_CACHE_MIGRATION = exports.PostgresReplayStore = exports.InMemoryReplayStore = exports.parseSignatureInput = exports.parseSignature = exports.BrandJsonResolverError = exports.BrandJsonJwksResolver = exports.HttpsJwksResolver = exports.StaticJwksResolver = exports.WebhookSignatureError = exports.ResponseSignatureError = exports.RequestSignatureError = exports.verifySignature = exports.jwkToPublicKey = exports.requestContextFromLambda = exports.requestContextFromFetch = exports.requestContextFromExpress = exports.parseContentDigest = exports.contentDigestMatches = exports.computeContentDigest = exports.getHeaderValue = exports.formatSignatureParams = exports.canonicalTargetUri = exports.canonicalMethod = exports.canonicalAuthority = exports.buildSignatureBase = exports.buildResponseSignatureBase = void 0;
|
|
4
|
+
exports.readIdentityPosture = exports.readBrandJsonUrl = exports.ATTACKER_INFLUENCED = exports.attackerInfluencedFields = void 0;
|
|
4
5
|
/**
|
|
5
6
|
* Server-side signing surface: what a seller running an AdCP agent needs to
|
|
6
7
|
* verify inbound RFC 9421 signatures — verifier pipeline, Express-shaped
|
|
@@ -12,6 +13,7 @@ exports.readIdentityPosture = exports.readBrandJsonUrl = exports.ATTACKER_INFLUE
|
|
|
12
13
|
* both for back-compat.
|
|
13
14
|
*/
|
|
14
15
|
var canonicalize_1 = require("./canonicalize");
|
|
16
|
+
Object.defineProperty(exports, "buildResponseSignatureBase", { enumerable: true, get: function () { return canonicalize_1.buildResponseSignatureBase; } });
|
|
15
17
|
Object.defineProperty(exports, "buildSignatureBase", { enumerable: true, get: function () { return canonicalize_1.buildSignatureBase; } });
|
|
16
18
|
Object.defineProperty(exports, "canonicalAuthority", { enumerable: true, get: function () { return canonicalize_1.canonicalAuthority; } });
|
|
17
19
|
Object.defineProperty(exports, "canonicalMethod", { enumerable: true, get: function () { return canonicalize_1.canonicalMethod; } });
|
|
@@ -22,11 +24,16 @@ var content_digest_1 = require("./content-digest");
|
|
|
22
24
|
Object.defineProperty(exports, "computeContentDigest", { enumerable: true, get: function () { return content_digest_1.computeContentDigest; } });
|
|
23
25
|
Object.defineProperty(exports, "contentDigestMatches", { enumerable: true, get: function () { return content_digest_1.contentDigestMatches; } });
|
|
24
26
|
Object.defineProperty(exports, "parseContentDigest", { enumerable: true, get: function () { return content_digest_1.parseContentDigest; } });
|
|
27
|
+
var request_context_1 = require("./request-context");
|
|
28
|
+
Object.defineProperty(exports, "requestContextFromExpress", { enumerable: true, get: function () { return request_context_1.requestContextFromExpress; } });
|
|
29
|
+
Object.defineProperty(exports, "requestContextFromFetch", { enumerable: true, get: function () { return request_context_1.requestContextFromFetch; } });
|
|
30
|
+
Object.defineProperty(exports, "requestContextFromLambda", { enumerable: true, get: function () { return request_context_1.requestContextFromLambda; } });
|
|
25
31
|
var crypto_1 = require("./crypto");
|
|
26
32
|
Object.defineProperty(exports, "jwkToPublicKey", { enumerable: true, get: function () { return crypto_1.jwkToPublicKey; } });
|
|
27
33
|
Object.defineProperty(exports, "verifySignature", { enumerable: true, get: function () { return crypto_1.verifySignature; } });
|
|
28
34
|
var errors_1 = require("./errors");
|
|
29
35
|
Object.defineProperty(exports, "RequestSignatureError", { enumerable: true, get: function () { return errors_1.RequestSignatureError; } });
|
|
36
|
+
Object.defineProperty(exports, "ResponseSignatureError", { enumerable: true, get: function () { return errors_1.ResponseSignatureError; } });
|
|
30
37
|
Object.defineProperty(exports, "WebhookSignatureError", { enumerable: true, get: function () { return errors_1.WebhookSignatureError; } });
|
|
31
38
|
var jwks_1 = require("./jwks");
|
|
32
39
|
Object.defineProperty(exports, "StaticJwksResolver", { enumerable: true, get: function () { return jwks_1.StaticJwksResolver; } });
|
|
@@ -55,8 +62,13 @@ Object.defineProperty(exports, "CLOCK_SKEW_TOLERANCE_SECONDS", { enumerable: tru
|
|
|
55
62
|
Object.defineProperty(exports, "MANDATORY_COMPONENTS", { enumerable: true, get: function () { return types_1.MANDATORY_COMPONENTS; } });
|
|
56
63
|
Object.defineProperty(exports, "MAX_SIGNATURE_WINDOW_SECONDS", { enumerable: true, get: function () { return types_1.MAX_SIGNATURE_WINDOW_SECONDS; } });
|
|
57
64
|
Object.defineProperty(exports, "REQUEST_SIGNING_TAG", { enumerable: true, get: function () { return types_1.REQUEST_SIGNING_TAG; } });
|
|
65
|
+
Object.defineProperty(exports, "RESPONSE_MANDATORY_COMPONENTS", { enumerable: true, get: function () { return types_1.RESPONSE_MANDATORY_COMPONENTS; } });
|
|
66
|
+
Object.defineProperty(exports, "RESPONSE_SIGNING_TAG", { enumerable: true, get: function () { return types_1.RESPONSE_SIGNING_TAG; } });
|
|
58
67
|
var verifier_1 = require("./verifier");
|
|
59
68
|
Object.defineProperty(exports, "verifyRequestSignature", { enumerable: true, get: function () { return verifier_1.verifyRequestSignature; } });
|
|
69
|
+
var response_verifier_1 = require("./response-verifier");
|
|
70
|
+
Object.defineProperty(exports, "createResponseVerifier", { enumerable: true, get: function () { return response_verifier_1.createResponseVerifier; } });
|
|
71
|
+
Object.defineProperty(exports, "verifyResponseSignature", { enumerable: true, get: function () { return response_verifier_1.verifyResponseSignature; } });
|
|
60
72
|
var webhook_verifier_1 = require("./webhook-verifier");
|
|
61
73
|
Object.defineProperty(exports, "createWebhookVerifier", { enumerable: true, get: function () { return webhook_verifier_1.createWebhookVerifier; } });
|
|
62
74
|
Object.defineProperty(exports, "verifyWebhookSignature", { enumerable: true, get: function () { return webhook_verifier_1.verifyWebhookSignature; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/lib/signing/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/lib/signing/server.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;GASG;AACH,+CAWwB;AAVtB,0HAAA,0BAA0B,OAAA;AAC1B,kHAAA,kBAAkB,OAAA;AAClB,kHAAA,kBAAkB,OAAA;AAClB,+GAAA,eAAe,OAAA;AACf,kHAAA,kBAAkB,OAAA;AAClB,qHAAA,qBAAqB,OAAA;AACrB,8GAAA,cAAc,OAAA;AAKhB,mDAAkG;AAAzF,sHAAA,oBAAoB,OAAA;AAAE,sHAAA,oBAAoB,OAAA;AAAE,oHAAA,kBAAkB,OAAA;AACvE,qDAS2B;AARzB,4HAAA,yBAAyB,OAAA;AACzB,0HAAA,uBAAuB,OAAA;AACvB,2HAAA,wBAAwB,OAAA;AAO1B,mCAA2D;AAAlD,wGAAA,cAAc,OAAA;AAAE,yGAAA,eAAe,OAAA;AACxC,mCAOkB;AANhB,+GAAA,qBAAqB,OAAA;AAErB,gHAAA,sBAAsB,OAAA;AAEtB,+GAAA,qBAAqB,OAAA;AAGvB,+BAA+D;AAAtD,0GAAA,kBAAkB,OAAA;AAC3B,2CAAgF;AAAvE,+GAAA,iBAAiB,OAAA;AAC1B,2CAMsB;AALpB,mHAAA,qBAAqB,OAAA;AACrB,oHAAA,sBAAsB,OAAA;AAKxB,mCAAgH;AAAvG,wGAAA,cAAc,OAAA;AAAE,6GAAA,mBAAmB,OAAA;AAC5C,mCAKkB;AAJhB,6GAAA,mBAAmB,OAAA;AAKrB,iEAOiC;AAN/B,4HAAA,mBAAmB,OAAA;AACnB,+HAAA,sBAAsB,OAAA;AACtB,gIAAA,uBAAuB,OAAA;AACvB,4HAAA,mBAAmB,OAAA;AAIrB,2CAA6E;AAApE,qHAAA,uBAAuB,OAAA;AAChC,uDAA4F;AAAnF,wHAAA,oBAAoB,OAAA;AAC7B,iCAciB;AAbf,qGAAA,YAAY,OAAA;AACZ,qHAAA,4BAA4B,OAAA;AAC5B,6GAAA,oBAAoB,OAAA;AACpB,qHAAA,4BAA4B,OAAA;AAC5B,4GAAA,mBAAmB,OAAA;AACnB,sHAAA,6BAA6B,OAAA;AAC7B,6GAAA,oBAAoB,OAAA;AAQtB,uCAA+E;AAAtE,kHAAA,sBAAsB,OAAA;AAC/B,yDAM6B;AAL3B,2HAAA,sBAAsB,OAAA;AACtB,4HAAA,uBAAuB,OAAA;AAKzB,uDAQ4B;AAP1B,yHAAA,qBAAqB,OAAA;AACrB,0HAAA,sBAAsB,OAAA;AACtB,gIAAA,4BAA4B,OAAA;AAC5B,uHAAA,mBAAmB,OAAA;AAKrB,2CAAsG;AAA7F,mHAAA,qBAAqB,OAAA;AAC9B,mDAwB0B;AAvBxB,8GAAA,YAAY,OAAA;AACZ,8GAAA,YAAY,OAAA;AACZ,oHAAA,kBAAkB,OAAA;AAClB,oHAAA,kBAAkB,OAAA;AAClB,0HAAA,wBAAwB,OAAA;AACxB,qHAAA,mBAAmB,OAAA;AACnB,kHAAA,gBAAgB,OAAA;AAChB,qHAAA,mBAAmB,OAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { RequestLike } from './canonicalize';
|
|
1
|
+
import type { RequestLike, ResponseLike } from './canonicalize';
|
|
2
2
|
import type { SigningProvider } from './provider';
|
|
3
|
-
import type { SignedRequest, SignRequestOptions, SignWebhookOptions } from './signer';
|
|
3
|
+
import type { SignedRequest, SignedResponse, SignRequestOptions, SignResponseOptions, SignWebhookOptions } from './signer';
|
|
4
4
|
/**
|
|
5
5
|
* Async variant of `signRequest` that delegates the actual signature
|
|
6
6
|
* production to a {@link SigningProvider}. Reuses
|
|
@@ -21,4 +21,10 @@ export declare function signRequestAsync(request: RequestLike, provider: Signing
|
|
|
21
21
|
* `Content-Digest` header stay in lockstep.
|
|
22
22
|
*/
|
|
23
23
|
export declare function signWebhookAsync(request: RequestLike, provider: SigningProvider, options?: SignWebhookOptions): Promise<SignedRequest>;
|
|
24
|
+
/**
|
|
25
|
+
* Async variant of `signResponse`. Reuses {@link prepareResponseSignature}
|
|
26
|
+
* and {@link finalizeResponseSignature} from the sync path so canonicalization
|
|
27
|
+
* stays identical — `provider.sign(payload)` is the only difference.
|
|
28
|
+
*/
|
|
29
|
+
export declare function signResponseAsync(response: ResponseLike, provider: SigningProvider, options?: SignResponseOptions): Promise<SignedResponse>;
|
|
24
30
|
//# sourceMappingURL=signer-async.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer-async.d.ts","sourceRoot":"","sources":["../../../src/lib/signing/signer-async.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"signer-async.d.ts","sourceRoot":"","sources":["../../../src/lib/signing/signer-async.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAUlB;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,eAAe,EACzB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,aAAa,CAAC,CAKxB;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,eAAe,EACzB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,aAAa,CAAC,CAKxB;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,eAAe,EACzB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,cAAc,CAAC,CAKzB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.signRequestAsync = signRequestAsync;
|
|
4
4
|
exports.signWebhookAsync = signWebhookAsync;
|
|
5
|
+
exports.signResponseAsync = signResponseAsync;
|
|
5
6
|
const signer_1 = require("./signer");
|
|
6
7
|
/**
|
|
7
8
|
* Async variant of `signRequest` that delegates the actual signature
|
|
@@ -16,6 +17,7 @@ const signer_1 = require("./signer");
|
|
|
16
17
|
* deployments that store private keys in a managed key store.
|
|
17
18
|
*/
|
|
18
19
|
async function signRequestAsync(request, provider, options = {}) {
|
|
20
|
+
(0, signer_1.assertProviderPurpose)(provider, 'request-signing');
|
|
19
21
|
const prepared = (0, signer_1.prepareRequestSignature)(request, { keyid: provider.keyid, alg: provider.algorithm }, options);
|
|
20
22
|
const signature = await provider.sign(Buffer.from(prepared.base, 'utf8'));
|
|
21
23
|
return (0, signer_1.finalizeRequestSignature)(prepared, signature);
|
|
@@ -27,8 +29,20 @@ async function signRequestAsync(request, provider, options = {}) {
|
|
|
27
29
|
* `Content-Digest` header stay in lockstep.
|
|
28
30
|
*/
|
|
29
31
|
async function signWebhookAsync(request, provider, options = {}) {
|
|
32
|
+
(0, signer_1.assertProviderPurpose)(provider, 'webhook-signing');
|
|
30
33
|
const prepared = (0, signer_1.prepareWebhookSignature)(request, { keyid: provider.keyid, alg: provider.algorithm }, options);
|
|
31
34
|
const signature = await provider.sign(Buffer.from(prepared.base, 'utf8'));
|
|
32
35
|
return (0, signer_1.finalizeRequestSignature)(prepared, signature);
|
|
33
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Async variant of `signResponse`. Reuses {@link prepareResponseSignature}
|
|
39
|
+
* and {@link finalizeResponseSignature} from the sync path so canonicalization
|
|
40
|
+
* stays identical — `provider.sign(payload)` is the only difference.
|
|
41
|
+
*/
|
|
42
|
+
async function signResponseAsync(response, provider, options = {}) {
|
|
43
|
+
(0, signer_1.assertProviderPurpose)(provider, 'response-signing');
|
|
44
|
+
const prepared = (0, signer_1.prepareResponseSignature)(response, { keyid: provider.keyid, alg: provider.algorithm }, options);
|
|
45
|
+
const signature = await provider.sign(Buffer.from(prepared.base, 'utf8'));
|
|
46
|
+
return (0, signer_1.finalizeResponseSignature)(prepared, signature);
|
|
47
|
+
}
|
|
34
48
|
//# sourceMappingURL=signer-async.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer-async.js","sourceRoot":"","sources":["../../../src/lib/signing/signer-async.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"signer-async.js","sourceRoot":"","sources":["../../../src/lib/signing/signer-async.ts"],"names":[],"mappings":";;AA8BA,4CASC;AAQD,4CASC;AAOD,8CASC;AA/DD,qCAOkB;AAElB;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,gBAAgB,CACpC,OAAoB,EACpB,QAAyB,EACzB,UAA8B,EAAE;IAEhC,IAAA,8BAAqB,EAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAG,IAAA,gCAAuB,EAAC,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/G,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1E,OAAO,IAAA,iCAAwB,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACI,KAAK,U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