@astrasyncai/verification-gateway 5.14.0 → 5.15.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/README.md +27 -17
- package/dist/adapters/express.d.mts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.js +477 -240
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +477 -240
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.d.ts +1 -1
- package/dist/adapters/mcp.js +20 -6
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +20 -6
- package/dist/adapters/mcp.mjs.map +1 -1
- package/dist/adapters/nextjs.d.mts +1 -1
- package/dist/adapters/nextjs.d.ts +1 -1
- package/dist/adapters/nextjs.js +460 -239
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +460 -239
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +18 -10
- package/dist/adapters/sdk.d.ts +18 -10
- package/dist/adapters/sdk.js +80 -23
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +80 -23
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +1 -1
- package/dist/agent/index.mjs.map +1 -1
- package/dist/bin/astrasync-claude-hook.js +55 -11
- package/dist/bin/astrasync-codex-hook.js +55 -11
- package/dist/bin/astrasync-guard.js +55 -11
- package/dist/bin/astrasync.js +288 -33
- package/dist/browser/background.js +50 -6
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +60 -6
- package/dist/browser/background.mjs.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/codex/index.js +55 -11
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +65 -11
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +55 -11
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +65 -11
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/edge-config.d.mts +31 -2
- package/dist/edge-config.d.ts +31 -2
- package/dist/edge-config.js +35 -5
- package/dist/edge-config.js.map +1 -1
- package/dist/edge-config.mjs +32 -4
- package/dist/edge-config.mjs.map +1 -1
- package/dist/edge-core/index.d.mts +11 -2
- package/dist/edge-core/index.d.ts +11 -2
- package/dist/edge-core/index.js +93 -10
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +91 -10
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.js +50 -6
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +60 -6
- package/dist/gateway/gateway.mjs.map +1 -1
- package/dist/git-trigger/git-hooks.d.mts +1 -1
- package/dist/git-trigger/git-hooks.d.ts +1 -1
- package/dist/index.d.mts +1314 -34
- package/dist/index.d.ts +1314 -34
- package/dist/index.js +5116 -2612
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5063 -2614
- package/dist/index.mjs.map +1 -1
- package/dist/registration/index.d.mts +28 -2
- package/dist/registration/index.d.ts +28 -2
- package/dist/registration/index.js +18 -3
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +15 -2
- package/dist/registration/index.mjs.map +1 -1
- package/dist/transport/index.d.mts +7 -5
- package/dist/transport/index.d.ts +7 -5
- package/dist/transport/index.js +61 -5
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +67 -11
- package/dist/transport/index.mjs.map +1 -1
- package/dist/{types-C_b4QTyO.d.ts → types-DtJjlW4O.d.ts} +104 -10
- package/dist/{types-BCkwBA84.d.mts → types-Dxf9DBpr.d.mts} +106 -12
- package/dist/{types-BCkwBA84.d.ts → types-Dxf9DBpr.d.ts} +106 -12
- package/dist/{types-DlshIIR-.d.mts → types-Eg6VoBNH.d.mts} +104 -10
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +1 -1
- package/dist/verify.d.ts +1 -1
- package/dist/verify.js +20 -6
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +20 -6
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
package/dist/transport/index.mjs
CHANGED
|
@@ -437,6 +437,7 @@ function bufferToBase64(bytes) {
|
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
// src/transport/rfc9421-verify.ts
|
|
440
|
+
import { createHash } from "crypto";
|
|
440
441
|
import { httpbis } from "http-message-signatures";
|
|
441
442
|
|
|
442
443
|
// src/transport/nonce-store.ts
|
|
@@ -508,6 +509,16 @@ async function verifyRFC9421(request, options) {
|
|
|
508
509
|
normalizeRequest(request)
|
|
509
510
|
);
|
|
510
511
|
if (result === true) {
|
|
512
|
+
const digestError = checkContentDigest(request);
|
|
513
|
+
if (digestError) {
|
|
514
|
+
return {
|
|
515
|
+
ok: false,
|
|
516
|
+
kid: resolvedKid,
|
|
517
|
+
registry: resolver.name,
|
|
518
|
+
algorithm: resolvedAlg,
|
|
519
|
+
error: digestError
|
|
520
|
+
};
|
|
521
|
+
}
|
|
511
522
|
return {
|
|
512
523
|
ok: true,
|
|
513
524
|
kid: resolvedKid,
|
|
@@ -532,6 +543,21 @@ async function verifyRFC9421(request, options) {
|
|
|
532
543
|
};
|
|
533
544
|
}
|
|
534
545
|
}
|
|
546
|
+
function checkContentDigest(request) {
|
|
547
|
+
if (request.body === void 0) return null;
|
|
548
|
+
const raw = Object.entries(request.headers).find(
|
|
549
|
+
([k]) => k.toLowerCase() === "content-digest"
|
|
550
|
+
)?.[1];
|
|
551
|
+
if (!raw) return null;
|
|
552
|
+
const header = Array.isArray(raw) ? raw.join(", ") : raw;
|
|
553
|
+
const entries = [...header.matchAll(/(sha-256|sha-512)=:([A-Za-z0-9+/=]+):/g)];
|
|
554
|
+
if (entries.length === 0) return null;
|
|
555
|
+
for (const [, alg, value] of entries) {
|
|
556
|
+
const expected = createHash(alg === "sha-256" ? "sha256" : "sha512").update(request.body, "utf8").digest("base64");
|
|
557
|
+
if (expected !== value) return "content-digest does not match the body";
|
|
558
|
+
}
|
|
559
|
+
return null;
|
|
560
|
+
}
|
|
535
561
|
function normalizeRequest(request) {
|
|
536
562
|
return {
|
|
537
563
|
method: request.method.toUpperCase(),
|
|
@@ -633,7 +659,7 @@ async function getCrypto() {
|
|
|
633
659
|
}
|
|
634
660
|
|
|
635
661
|
// src/version.ts
|
|
636
|
-
var SDK_VERSION = "5.
|
|
662
|
+
var SDK_VERSION = "5.15.0";
|
|
637
663
|
|
|
638
664
|
// src/http.ts
|
|
639
665
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -781,8 +807,9 @@ function extractBearer(authHeader) {
|
|
|
781
807
|
function extractPaymentToken(body) {
|
|
782
808
|
const paymentData = body.payment_data;
|
|
783
809
|
if (!paymentData) return void 0;
|
|
784
|
-
const
|
|
785
|
-
const
|
|
810
|
+
const instrument = paymentData.instrument;
|
|
811
|
+
const raw = coerceString3(instrument?.credential?.token) ?? coerceString3(paymentData.token);
|
|
812
|
+
const provider = coerceString3(paymentData.provider) ?? coerceString3(paymentData.handler_id);
|
|
786
813
|
if (!raw) return { raw: void 0, type: null, provider };
|
|
787
814
|
const type = classifyPaymentToken(raw);
|
|
788
815
|
return { raw, type, provider };
|
|
@@ -825,7 +852,7 @@ function coerceString3(v) {
|
|
|
825
852
|
|
|
826
853
|
// src/transport/vi.ts
|
|
827
854
|
import { splitSdJwt, decodeSdJwtSync } from "@sd-jwt/core";
|
|
828
|
-
import { createHash } from "crypto";
|
|
855
|
+
import { createHash as createHash2 } from "crypto";
|
|
829
856
|
function extractVIClaims(sdJwtCompact) {
|
|
830
857
|
if (!sdJwtCompact || typeof sdJwtCompact !== "string") return null;
|
|
831
858
|
let decoded;
|
|
@@ -976,7 +1003,7 @@ function coerceNumber2(v) {
|
|
|
976
1003
|
}
|
|
977
1004
|
function sha256Sync(data) {
|
|
978
1005
|
const buf = typeof data === "string" ? Buffer.from(data, "utf-8") : Buffer.from(new Uint8Array(data));
|
|
979
|
-
const hash =
|
|
1006
|
+
const hash = createHash2("sha256").update(buf).digest();
|
|
980
1007
|
return new Uint8Array(hash.buffer, hash.byteOffset, hash.byteLength);
|
|
981
1008
|
}
|
|
982
1009
|
|
|
@@ -1218,7 +1245,7 @@ var claim = {
|
|
|
1218
1245
|
|
|
1219
1246
|
// src/transport/ap2.ts
|
|
1220
1247
|
import { decodeSdJwtSync as decodeSdJwtSync2 } from "@sd-jwt/core";
|
|
1221
|
-
import { createHash as
|
|
1248
|
+
import { createHash as createHash3 } from "crypto";
|
|
1222
1249
|
function extractAP2Mandate(sdJwtCompact) {
|
|
1223
1250
|
if (!sdJwtCompact || typeof sdJwtCompact !== "string") return null;
|
|
1224
1251
|
let decoded;
|
|
@@ -1358,7 +1385,7 @@ function coerceStringOrNumber(v) {
|
|
|
1358
1385
|
}
|
|
1359
1386
|
function sha256Sync2(data) {
|
|
1360
1387
|
const buf = typeof data === "string" ? Buffer.from(data, "utf-8") : Buffer.from(new Uint8Array(data));
|
|
1361
|
-
const hash =
|
|
1388
|
+
const hash = createHash3("sha256").update(buf).digest();
|
|
1362
1389
|
return new Uint8Array(hash.buffer, hash.byteOffset, hash.byteLength);
|
|
1363
1390
|
}
|
|
1364
1391
|
|
|
@@ -1645,8 +1672,10 @@ async function getSubtle() {
|
|
|
1645
1672
|
// src/transport/mpp.ts
|
|
1646
1673
|
import { Challenge, Credential, Receipt } from "mppx";
|
|
1647
1674
|
function extractMPPFromRequest(request) {
|
|
1648
|
-
const
|
|
1649
|
-
|
|
1675
|
+
const alt = readHeader3(request.headers, "payment-authorization");
|
|
1676
|
+
const authHeader = readHeader3(request.headers, "authorization");
|
|
1677
|
+
const auth = authHeader && /^\s*Payment\s+/i.test(authHeader) ? authHeader : alt ? /^\s*Payment\s+/i.test(alt) ? alt : `Payment ${alt.trim()}` : void 0;
|
|
1678
|
+
if (!auth) return null;
|
|
1650
1679
|
try {
|
|
1651
1680
|
const credential = Credential.deserialize(auth);
|
|
1652
1681
|
return {
|
|
@@ -1836,6 +1865,16 @@ import {
|
|
|
1836
1865
|
} from "@x402/core/schemas";
|
|
1837
1866
|
import { safeBase64Decode } from "@x402/core/utils";
|
|
1838
1867
|
function extractX402FromRequest(request) {
|
|
1868
|
+
const v2Header = readHeader4(request.headers, "payment-signature");
|
|
1869
|
+
if (v2Header) {
|
|
1870
|
+
try {
|
|
1871
|
+
const decoded = safeBase64Decode(v2Header);
|
|
1872
|
+
const parsed = decoded ? tryParsePayload(JSON.parse(decoded)) : null;
|
|
1873
|
+
if (parsed) return buildPayloadContext(parsed, "header");
|
|
1874
|
+
} catch {
|
|
1875
|
+
}
|
|
1876
|
+
return { kind: "error", version: 2, source: "header", error: { type: "invalid-x402-payload" } };
|
|
1877
|
+
}
|
|
1839
1878
|
const headerValue = readHeader4(request.headers, "x-payment");
|
|
1840
1879
|
if (request.body && typeof request.body === "object") {
|
|
1841
1880
|
const parsed = tryParsePayload(request.body);
|
|
@@ -1862,6 +1901,21 @@ function extractX402FromRequest(request) {
|
|
|
1862
1901
|
}
|
|
1863
1902
|
function extractX402FromResponse(response) {
|
|
1864
1903
|
if (response.status !== 402) return null;
|
|
1904
|
+
const v2Header = readHeader4(response.headers, "payment-required");
|
|
1905
|
+
if (v2Header) {
|
|
1906
|
+
try {
|
|
1907
|
+
const decoded = safeBase64Decode(v2Header);
|
|
1908
|
+
const parsed = decoded ? tryParseRequired(JSON.parse(decoded)) : null;
|
|
1909
|
+
if (parsed) return buildRequiredContext(parsed, "header");
|
|
1910
|
+
} catch {
|
|
1911
|
+
}
|
|
1912
|
+
return {
|
|
1913
|
+
kind: "error",
|
|
1914
|
+
version: 2,
|
|
1915
|
+
source: "header",
|
|
1916
|
+
error: { type: "invalid-x402-required" }
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1865
1919
|
if (response.body && typeof response.body === "object") {
|
|
1866
1920
|
const parsed = tryParseRequired(response.body);
|
|
1867
1921
|
if (parsed) return buildRequiredContext(parsed, "body");
|
|
@@ -1979,7 +2033,7 @@ function readHeader4(headers, name) {
|
|
|
1979
2033
|
}
|
|
1980
2034
|
|
|
1981
2035
|
// src/transport/vi-verify.ts
|
|
1982
|
-
import { createHash as
|
|
2036
|
+
import { createHash as createHash4, webcrypto } from "crypto";
|
|
1983
2037
|
async function verifyVIChain(input) {
|
|
1984
2038
|
const errors = [];
|
|
1985
2039
|
const tolerance = input.clockSkewSec ?? 60;
|
|
@@ -2120,7 +2174,7 @@ function computeCheckoutHashFromL2(l2) {
|
|
|
2120
2174
|
const checkoutDisclosure = l2.payload.checkout ?? l2.payload.checkout_mandate;
|
|
2121
2175
|
if (!checkoutDisclosure) return null;
|
|
2122
2176
|
const canonical = canonicalStringify(checkoutDisclosure);
|
|
2123
|
-
const hash =
|
|
2177
|
+
const hash = createHash4("sha256").update(canonical).digest("base64url").replace(/=+$/, "");
|
|
2124
2178
|
return hash;
|
|
2125
2179
|
}
|
|
2126
2180
|
function canonicalStringify(value) {
|
|
@@ -2375,6 +2429,8 @@ function resolvePaymentToken(input) {
|
|
|
2375
2429
|
const mppMethod = input.mpp?.context.credential?.challenge?.method;
|
|
2376
2430
|
if (mppMethod === "tempo") return { present: true, type: "tempo-tx" };
|
|
2377
2431
|
if (mppMethod === "stripe") return { present: true, type: "stripe-spt" };
|
|
2432
|
+
if (input.x402?.paymentPayload) return { present: true, type: "x402-payload" };
|
|
2433
|
+
if (input.ap2?.triple.payment) return { present: true, type: "ap2-payment-mandate" };
|
|
2378
2434
|
return void 0;
|
|
2379
2435
|
}
|
|
2380
2436
|
function runConstraintEval(input) {
|