@astrasyncai/verification-gateway 5.18.1 → 5.20.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/CHANGELOG.md +232 -0
- package/README.md +217 -4
- package/dist/adapter-interface/interface.d.mts +2 -2
- package/dist/adapter-interface/interface.d.ts +2 -2
- package/dist/adapters/express.d.mts +9 -1
- package/dist/adapters/express.d.ts +9 -1
- package/dist/adapters/express.js +160 -52
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +160 -52
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/http-pdlss.d.mts +7 -1
- package/dist/adapters/http-pdlss.d.ts +7 -1
- package/dist/adapters/http-pdlss.js +18 -2
- package/dist/adapters/http-pdlss.js.map +1 -1
- package/dist/adapters/http-pdlss.mjs +16 -1
- package/dist/adapters/http-pdlss.mjs.map +1 -1
- package/dist/adapters/kit-express.d.mts +93 -1
- package/dist/adapters/kit-express.d.ts +93 -1
- package/dist/adapters/kit-express.js +181 -2
- package/dist/adapters/kit-express.js.map +1 -1
- package/dist/adapters/kit-express.mjs +180 -2
- package/dist/adapters/kit-express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +102 -9
- package/dist/adapters/mcp.d.ts +102 -9
- package/dist/adapters/mcp.js +242 -19
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +240 -19
- 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 +97 -14
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +97 -14
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +101 -2
- package/dist/adapters/sdk.d.ts +101 -2
- package/dist/adapters/sdk.js +199 -12
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +199 -12
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.d.mts +1 -1
- package/dist/agent/index.d.ts +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 +94 -16
- package/dist/bin/astrasync-codex-hook.js +94 -16
- package/dist/bin/astrasync-guard.js +94 -16
- package/dist/bin/astrasync.js +127 -16
- package/dist/browser/background.js +94 -16
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +94 -16
- 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 +94 -16
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +94 -16
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +94 -16
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +94 -16
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/edge-config.d.mts +1 -1
- package/dist/edge-config.d.ts +1 -1
- package/dist/edge-config.js +1 -1
- package/dist/edge-config.js.map +1 -1
- package/dist/edge-config.mjs +1 -1
- package/dist/edge-config.mjs.map +1 -1
- package/dist/edge-core/index.d.mts +1 -1
- package/dist/edge-core/index.d.ts +1 -1
- package/dist/edge-core/index.js +69 -12
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +69 -12
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +94 -16
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +94 -16
- 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 +706 -34
- package/dist/index.d.ts +706 -34
- package/dist/index.js +1391 -205
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1374 -195
- package/dist/index.mjs.map +1 -1
- package/dist/local-evaluator/evaluator.d.mts +2 -2
- package/dist/local-evaluator/evaluator.d.ts +2 -2
- package/dist/registration/index.d.mts +11 -2
- package/dist/registration/index.d.ts +11 -2
- package/dist/registration/index.js +1 -1
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +1 -1
- package/dist/registration/index.mjs.map +1 -1
- package/dist/transport/index.d.mts +1 -1
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +3 -2
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +3 -2
- package/dist/transport/index.mjs.map +1 -1
- package/dist/{types-BRz2U0Pn.d.ts → types-B_HLhZ9n.d.ts} +1 -1
- package/dist/{types-BfILnheI.d.mts → types-CU17R4Nr.d.mts} +11 -0
- package/dist/{types-BfILnheI.d.ts → types-CU17R4Nr.d.ts} +11 -0
- package/dist/{types-Cns4l8gX.d.mts → types-CxjqmPl-.d.mts} +115 -13
- package/dist/{types-Cns4l8gX.d.ts → types-CxjqmPl-.d.ts} +115 -13
- package/dist/{types-3ObBpsnf.d.mts → types-D37aSQ9c.d.mts} +106 -3
- package/dist/{types-CfBpm3w5.d.mts → types-Djpz-L0w.d.mts} +1 -1
- package/dist/{types-BoxZEYPS.d.ts → types-Dn8tXnei.d.ts} +106 -3
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +50 -4
- package/dist/verify.d.ts +50 -4
- package/dist/verify.js +93 -14
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +91 -14
- package/dist/verify.mjs.map +1 -1
- package/dist/webhooks.d.mts +16 -3
- package/dist/webhooks.d.ts +16 -3
- package/dist/webhooks.js +24 -13
- package/dist/webhooks.js.map +1 -1
- package/dist/webhooks.mjs +24 -13
- package/dist/webhooks.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-Djpz-L0w.mjs';
|
|
2
|
+
import '../types-CU17R4Nr.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Hybrid Mode — Local evaluation for speed, async API sync for trust scoring.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-B_HLhZ9n.js';
|
|
2
|
+
import '../types-CU17R4Nr.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Hybrid Mode — Local evaluation for speed, async API sync for trust scoring.
|
package/dist/gateway/gateway.js
CHANGED
|
@@ -3748,7 +3748,7 @@ function getTrustLevel(score) {
|
|
|
3748
3748
|
}
|
|
3749
3749
|
|
|
3750
3750
|
// src/version.ts
|
|
3751
|
-
var SDK_VERSION = "5.
|
|
3751
|
+
var SDK_VERSION = "5.20.0";
|
|
3752
3752
|
|
|
3753
3753
|
// src/http.ts
|
|
3754
3754
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -3903,7 +3903,12 @@ function getCacheKey(request, counterpartyId) {
|
|
|
3903
3903
|
// its start_checkout quote was served the cached quote-leg grant (no
|
|
3904
3904
|
// settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
|
|
3905
3905
|
request.commercePhase || "",
|
|
3906
|
-
request.checkoutSessionId || ""
|
|
3906
|
+
request.checkoutSessionId || "",
|
|
3907
|
+
// 5.19.0: a route_config purpose claim is checked server-side against
|
|
3908
|
+
// the stored rule for this method + path, so it changes the verdict.
|
|
3909
|
+
request.purposeSource || "",
|
|
3910
|
+
request.requestMethod || "",
|
|
3911
|
+
request.requestPath || ""
|
|
3907
3912
|
].join("|");
|
|
3908
3913
|
}
|
|
3909
3914
|
function getCachedResult(request, counterpartyId) {
|
|
@@ -4061,6 +4066,9 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4061
4066
|
if (requestData.enableRuntimeChallenge)
|
|
4062
4067
|
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
4063
4068
|
if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
|
|
4069
|
+
if (config.actingProof?.connectorToken) {
|
|
4070
|
+
body.actingProof = { connectorToken: config.actingProof.connectorToken };
|
|
4071
|
+
}
|
|
4064
4072
|
if (requestData.approvalHeldByRoute) body.approvalHeldByRoute = true;
|
|
4065
4073
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
4066
4074
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
@@ -4077,6 +4085,11 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4077
4085
|
if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
|
|
4078
4086
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
4079
4087
|
if (requestData.attemptId) body.attemptId = requestData.attemptId;
|
|
4088
|
+
if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
|
|
4089
|
+
if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
|
|
4090
|
+
if (requestData.metadata) body.metadata = requestData.metadata;
|
|
4091
|
+
if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
|
|
4092
|
+
if (requestData.requestPath) body.requestPath = requestData.requestPath;
|
|
4080
4093
|
if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
|
|
4081
4094
|
body.sdkVersion = SDK_VERSION;
|
|
4082
4095
|
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
@@ -4223,22 +4236,43 @@ async function verify(config, request, options) {
|
|
|
4223
4236
|
"[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access decisions (verified ID + runtime challenge + PDLSS + trust score). To gate access to an endpoint, configure the endpoint's trust_score_requirement server-side."
|
|
4224
4237
|
);
|
|
4225
4238
|
}
|
|
4226
|
-
const uncacheable = Boolean(request.commerceArtifacts);
|
|
4239
|
+
const uncacheable = Boolean(request.commerceArtifacts) || Boolean(mergedConfig.actingProof);
|
|
4227
4240
|
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
4228
4241
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
4229
4242
|
if (cached) {
|
|
4230
4243
|
if (mergedConfig.debug) {
|
|
4231
4244
|
console.log("[VerificationGateway] Returning cached result");
|
|
4232
4245
|
}
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4246
|
+
return sharedVerdict(cached, request);
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
4250
|
+
const key = getCacheKey(request, mergedConfig.counterpartyId);
|
|
4251
|
+
const pending = inflightVerifies.get(key);
|
|
4252
|
+
if (pending) return sharedVerdict(await pending, request);
|
|
4253
|
+
const flight = verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
4254
|
+
inflightVerifies.set(key, flight);
|
|
4255
|
+
try {
|
|
4256
|
+
return await flight;
|
|
4257
|
+
} finally {
|
|
4258
|
+
inflightVerifies.delete(key);
|
|
4240
4259
|
}
|
|
4241
4260
|
}
|
|
4261
|
+
return verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
4262
|
+
}
|
|
4263
|
+
var inflightVerifies = /* @__PURE__ */ new Map();
|
|
4264
|
+
var sharedVerdicts = /* @__PURE__ */ new WeakSet();
|
|
4265
|
+
function sharedVerdict(source, request) {
|
|
4266
|
+
const hit = { ...source };
|
|
4267
|
+
if (request.attemptId) {
|
|
4268
|
+
hit.attemptId = request.attemptId;
|
|
4269
|
+
} else {
|
|
4270
|
+
delete hit.attemptId;
|
|
4271
|
+
}
|
|
4272
|
+
sharedVerdicts.add(hit);
|
|
4273
|
+
return hit;
|
|
4274
|
+
}
|
|
4275
|
+
async function verifyViaApi(mergedConfig, request, urls, uncacheable) {
|
|
4242
4276
|
const enrichedRequest = { ...request };
|
|
4243
4277
|
if (!enrichedRequest.counterpartyUrl && mergedConfig.counterpartyUrl) {
|
|
4244
4278
|
enrichedRequest.counterpartyUrl = mergedConfig.counterpartyUrl;
|
|
@@ -4266,9 +4300,18 @@ async function verify(config, request, options) {
|
|
|
4266
4300
|
if (!apiResponse.access?.allowed) {
|
|
4267
4301
|
const aggregatedFailures = apiResponse.access?.failures;
|
|
4268
4302
|
const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
|
|
4303
|
+
const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
|
|
4304
|
+
astraId: apiResponse.agent.astraId,
|
|
4305
|
+
name: apiResponse.agent.name,
|
|
4306
|
+
trustScore: apiResponse.agent.trustScore,
|
|
4307
|
+
trustLevel: getTrustLevel(apiResponse.agent.trustScore),
|
|
4308
|
+
blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
|
|
4309
|
+
status: apiResponse.agent.agentStatus
|
|
4310
|
+
} : void 0;
|
|
4269
4311
|
const result2 = {
|
|
4270
4312
|
identityVerified: idVerifiedFromBackend,
|
|
4271
4313
|
policyAllowed: false,
|
|
4314
|
+
...denyAgent && { agent: denyAgent },
|
|
4272
4315
|
// 3.6.0: the server now emits top-level denialReasons on every deny
|
|
4273
4316
|
// path — prefer it verbatim; the failure-message reconstruction remains
|
|
4274
4317
|
// as the fallback for older backends.
|
|
@@ -4308,7 +4351,9 @@ async function verify(config, request, options) {
|
|
|
4308
4351
|
fulfilment: apiResponse.fulfilment,
|
|
4309
4352
|
mandates: apiResponse.mandates,
|
|
4310
4353
|
kyaToken: apiResponse.kyaToken,
|
|
4311
|
-
aep: apiResponse.aep
|
|
4354
|
+
aep: apiResponse.aep,
|
|
4355
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
4356
|
+
warnings: apiResponse.warnings
|
|
4312
4357
|
};
|
|
4313
4358
|
return result2;
|
|
4314
4359
|
}
|
|
@@ -4376,7 +4421,9 @@ async function verify(config, request, options) {
|
|
|
4376
4421
|
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
4377
4422
|
mandates: apiResponse.mandates,
|
|
4378
4423
|
kyaToken: apiResponse.kyaToken,
|
|
4379
|
-
aep: apiResponse.aep
|
|
4424
|
+
aep: apiResponse.aep,
|
|
4425
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
4426
|
+
warnings: apiResponse.warnings
|
|
4380
4427
|
};
|
|
4381
4428
|
if (result.recommendation === "deny") {
|
|
4382
4429
|
result.policyAllowed = false;
|
|
@@ -4402,8 +4449,18 @@ async function verify(config, request, options) {
|
|
|
4402
4449
|
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
4403
4450
|
}
|
|
4404
4451
|
}
|
|
4452
|
+
notifyVerificationListeners(request, result);
|
|
4405
4453
|
return result;
|
|
4406
4454
|
}
|
|
4455
|
+
var verificationListeners = /* @__PURE__ */ new Set();
|
|
4456
|
+
function notifyVerificationListeners(request, result) {
|
|
4457
|
+
for (const listener of verificationListeners) {
|
|
4458
|
+
try {
|
|
4459
|
+
listener(result, request);
|
|
4460
|
+
} catch {
|
|
4461
|
+
}
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4407
4464
|
|
|
4408
4465
|
// src/adapters/stepup-poll.ts
|
|
4409
4466
|
var FALLBACK_MAX_WAIT_MS = 5 * 60 * 1e3;
|
|
@@ -4414,6 +4471,9 @@ var MAX_TOTAL_BYTES = 16 * 1024;
|
|
|
4414
4471
|
// src/adapters/commerce-detect.ts
|
|
4415
4472
|
var MAX_BODY_BYTES = 64 * 1024;
|
|
4416
4473
|
|
|
4474
|
+
// src/adapters/routes-cache.ts
|
|
4475
|
+
var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
|
|
4476
|
+
|
|
4417
4477
|
// src/edge-config.ts
|
|
4418
4478
|
var DEFAULT_EDGE_CONFIG = Object.freeze({
|
|
4419
4479
|
version: 1,
|
|
@@ -4655,9 +4715,6 @@ var BeaconBuffer = class {
|
|
|
4655
4715
|
};
|
|
4656
4716
|
var beaconBuffer = new BeaconBuffer();
|
|
4657
4717
|
|
|
4658
|
-
// src/adapters/express.ts
|
|
4659
|
-
var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
|
|
4660
|
-
|
|
4661
4718
|
// src/adapters/nextjs.ts
|
|
4662
4719
|
var DEFAULT_ROUTES_REFRESH_MS2 = 5 * 60 * 1e3;
|
|
4663
4720
|
|
|
@@ -4743,6 +4800,25 @@ var import_jose2 = require("jose");
|
|
|
4743
4800
|
// src/idempotency/index.ts
|
|
4744
4801
|
var DEFAULT_IDEMPOTENCY_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
4745
4802
|
|
|
4803
|
+
// src/ucp/approval-events.ts
|
|
4804
|
+
var MemorySeenEvents = class {
|
|
4805
|
+
constructor(max = 1e4) {
|
|
4806
|
+
this.max = max;
|
|
4807
|
+
this.ids = /* @__PURE__ */ new Set();
|
|
4808
|
+
}
|
|
4809
|
+
async has(eventId) {
|
|
4810
|
+
return this.ids.has(eventId);
|
|
4811
|
+
}
|
|
4812
|
+
async add(eventId) {
|
|
4813
|
+
if (this.ids.size >= this.max) {
|
|
4814
|
+
const first = this.ids.values().next().value;
|
|
4815
|
+
if (first !== void 0) this.ids.delete(first);
|
|
4816
|
+
}
|
|
4817
|
+
this.ids.add(eventId);
|
|
4818
|
+
}
|
|
4819
|
+
};
|
|
4820
|
+
var defaultSeen = new MemorySeenEvents();
|
|
4821
|
+
|
|
4746
4822
|
// src/payments/kyapay.ts
|
|
4747
4823
|
var import_jose4 = require("jose");
|
|
4748
4824
|
|
|
@@ -4782,7 +4858,9 @@ function toDecision(result) {
|
|
|
4782
4858
|
if (result.identityVerified && result.policyAllowed) {
|
|
4783
4859
|
return {
|
|
4784
4860
|
recommendation: "ALLOW",
|
|
4785
|
-
|
|
4861
|
+
// 5.19.0: the score is on `trustScore` for the merchant; `reason` is
|
|
4862
|
+
// text a merchant may relay to the agent, so it never embeds the number.
|
|
4863
|
+
reason: "Verified",
|
|
4786
4864
|
trustScore: result.agent?.trustScore,
|
|
4787
4865
|
sessionId: "sessionId" in result ? result.sessionId : void 0
|
|
4788
4866
|
};
|