@astrasyncai/verification-gateway 3.11.1 → 4.0.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/dist/adapter-interface/interface.d.mts +2 -2
- package/dist/adapter-interface/interface.d.ts +2 -2
- package/dist/adapters/express.d.mts +2 -2
- package/dist/adapters/express.d.ts +2 -2
- package/dist/adapters/express.js +106 -10
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +106 -10
- 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 +111 -10
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +111 -10
- package/dist/adapters/mcp.mjs.map +1 -1
- package/dist/adapters/nextjs.d.mts +2 -2
- package/dist/adapters/nextjs.d.ts +2 -2
- package/dist/adapters/nextjs.js +107 -10
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +107 -10
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +2 -2
- package/dist/adapters/sdk.d.ts +2 -2
- package/dist/adapters/sdk.js +92 -10
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +92 -10
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.d.mts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/bin/astrasync-claude-hook.js +92 -10
- package/dist/bin/astrasync-codex-hook.js +92 -10
- package/dist/bin/astrasync-guard.js +92 -10
- package/dist/bin/astrasync.js +93 -10
- package/dist/browser/background.js +92 -10
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +92 -10
- package/dist/browser/background.mjs.map +1 -1
- package/dist/browser/browser-adapter.d.mts +2 -2
- package/dist/browser/browser-adapter.d.ts +2 -2
- package/dist/claude-code/claude-code-adapter.d.mts +2 -2
- package/dist/claude-code/claude-code-adapter.d.ts +2 -2
- package/dist/cli/index.d.mts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/codex/index.d.mts +2 -2
- package/dist/codex/index.d.ts +2 -2
- package/dist/codex/index.js +92 -10
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +92 -10
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/cursor-adapter.d.mts +2 -2
- package/dist/cursor/cursor-adapter.d.ts +2 -2
- package/dist/cursor/extension.d.mts +2 -2
- package/dist/cursor/extension.d.ts +2 -2
- package/dist/cursor/extension.js +92 -10
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +92 -10
- 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/{express-DCXa1oqj.d.mts → express-BZajRs4i.d.mts} +1 -1
- package/dist/{express-ClNtDhhc.d.ts → express-CjCUB1k7.d.ts} +1 -1
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +92 -10
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +92 -10
- package/dist/gateway/gateway.mjs.map +1 -1
- package/dist/git-trigger/git-hooks.d.mts +2 -2
- package/dist/git-trigger/git-hooks.d.ts +2 -2
- package/dist/{index-BrNKDmiR.d.mts → index-B0cyMZDL.d.mts} +1 -1
- package/dist/{index-Dr_XiN65.d.mts → index-BRYteOqO.d.mts} +1 -1
- package/dist/{index-CfHurO1P.d.ts → index-BZQdVqNw.d.ts} +1 -1
- package/dist/{index-D2ztkumS.d.ts → index-adgKhujR.d.ts} +1 -1
- package/dist/index.d.mts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +160 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -10
- 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/{nextjs-CEBVBsdi.d.ts → nextjs-D_iFf5k-.d.ts} +1 -1
- package/dist/{nextjs-DcQIk6Zj.d.mts → nextjs-DeUTnOBd.d.mts} +1 -1
- package/dist/{sdk-H0JCLW2y.d.ts → sdk-BM3mwEAq.d.ts} +1 -1
- package/dist/{sdk-CZkbSOeO.d.mts → sdk-_il1Q41f.d.mts} +1 -1
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-sy3tq8lp.d.mts → types-BcDf9Kk0.d.mts} +118 -1
- package/dist/{types-DhFPiZ3t.d.ts → types-CHKCgDFC.d.ts} +1 -1
- package/dist/{types-cQVCMeNV.d.mts → types-DfnP7JiM.d.mts} +1 -1
- package/dist/{types-9tns4wyl.d.ts → types-fTQD448H.d.ts} +118 -1
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +15 -2
- package/dist/verify.d.ts +15 -2
- package/dist/verify.js +117 -10
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +115 -10
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
package/dist/codex/index.mjs
CHANGED
|
@@ -3955,7 +3955,7 @@ function getTrustLevel(score) {
|
|
|
3955
3955
|
}
|
|
3956
3956
|
|
|
3957
3957
|
// src/version.ts
|
|
3958
|
-
var SDK_VERSION = "
|
|
3958
|
+
var SDK_VERSION = "4.0.0";
|
|
3959
3959
|
|
|
3960
3960
|
// src/well-known.ts
|
|
3961
3961
|
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
@@ -3981,7 +3981,7 @@ var DEFAULT_CONFIG = {
|
|
|
3981
3981
|
};
|
|
3982
3982
|
var initCheckPerformed = false;
|
|
3983
3983
|
var deprecationWarningShown = false;
|
|
3984
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
3984
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
3985
3985
|
initCheckPerformed = true;
|
|
3986
3986
|
try {
|
|
3987
3987
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -3998,6 +3998,28 @@ async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
|
3998
3998
|
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
3999
3999
|
);
|
|
4000
4000
|
}
|
|
4001
|
+
if (apiKey) {
|
|
4002
|
+
const selfCheck = await fetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
|
|
4003
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
4004
|
+
});
|
|
4005
|
+
if (selfCheck.status === 401) {
|
|
4006
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
4007
|
+
const message = `[VerificationGateway] the configured AstraSync API key was REJECTED at startup (${body.code ?? "api_key_invalid"}: ${body.message ?? "invalid key"}). Every inbound agent will be turned away until the key is rotated` + (body.remediation?.manageUrl ? ` at ${body.remediation.manageUrl}` : "") + `.`;
|
|
4008
|
+
if (strictInit) {
|
|
4009
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
4010
|
+
}
|
|
4011
|
+
console.error(message);
|
|
4012
|
+
} else if (selfCheck.ok) {
|
|
4013
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
4014
|
+
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
4015
|
+
console.warn(
|
|
4016
|
+
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
4017
|
+
);
|
|
4018
|
+
} else if (debug) {
|
|
4019
|
+
console.log("[VerificationGateway] API key self-check passed");
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4001
4023
|
} catch (err) {
|
|
4002
4024
|
if (strictInit) {
|
|
4003
4025
|
throw err;
|
|
@@ -4075,8 +4097,17 @@ function cacheResult(request, result, configuredTtl, counterpartyId) {
|
|
|
4075
4097
|
function createGuidanceResponse(_config, reason, options = {}) {
|
|
4076
4098
|
const source = options.source ?? "no_credentials";
|
|
4077
4099
|
const isApiError = source === "api_error";
|
|
4100
|
+
const isMisconfig = source === "merchant_misconfig";
|
|
4078
4101
|
const urls = options.urls;
|
|
4079
|
-
const guidance =
|
|
4102
|
+
const guidance = isMisconfig ? {
|
|
4103
|
+
message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or rotated). Your identity and the AstraSync platform are fine \u2014 contact the site operator. Retrying will not help.",
|
|
4104
|
+
registrationUrl: urls?.registrationUrl ?? "",
|
|
4105
|
+
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
4106
|
+
steps: [
|
|
4107
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
|
|
4108
|
+
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
4109
|
+
]
|
|
4110
|
+
} : isApiError ? {
|
|
4080
4111
|
message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
|
|
4081
4112
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
4082
4113
|
documentationUrl: urls?.documentationUrl ?? "",
|
|
@@ -4114,14 +4145,24 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
4114
4145
|
// partners (and their custom onDenied handlers) can branch on
|
|
4115
4146
|
// dimension. Without this, the synthesised stub was indistinguishable
|
|
4116
4147
|
// from a real policy deny.
|
|
4117
|
-
failures:
|
|
4148
|
+
failures: isMisconfig ? [
|
|
4149
|
+
{
|
|
4150
|
+
dimension: "verify_access.merchant_misconfigured",
|
|
4151
|
+
message: reason ?? "The integration API key was rejected by AstraSync",
|
|
4152
|
+
guidance: guidance.message
|
|
4153
|
+
}
|
|
4154
|
+
] : isApiError ? [
|
|
4118
4155
|
{
|
|
4119
4156
|
dimension: "verify_access.api_error",
|
|
4120
4157
|
message: reason ?? "Verification temporarily unavailable",
|
|
4121
4158
|
guidance: guidance.message
|
|
4122
4159
|
}
|
|
4123
4160
|
] : void 0,
|
|
4161
|
+
// 4.0.0: typed marker so adapters render the misconfig envelope (503 +
|
|
4162
|
+
// MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
|
|
4163
|
+
...isMisconfig && { misconfigured: true },
|
|
4124
4164
|
correlationId: options.correlationId,
|
|
4165
|
+
attemptId: options.attemptId,
|
|
4125
4166
|
verifiedAt: /* @__PURE__ */ new Date()
|
|
4126
4167
|
};
|
|
4127
4168
|
}
|
|
@@ -4151,6 +4192,8 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4151
4192
|
body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
|
|
4152
4193
|
if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
|
|
4153
4194
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
4195
|
+
if (requestData.attemptId) body.attemptId = requestData.attemptId;
|
|
4196
|
+
if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
|
|
4154
4197
|
body.sdkVersion = SDK_VERSION;
|
|
4155
4198
|
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
4156
4199
|
const meta = {
|
|
@@ -4172,12 +4215,16 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4172
4215
|
const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
|
|
4173
4216
|
method: "POST",
|
|
4174
4217
|
headers,
|
|
4175
|
-
body: JSON.stringify(body)
|
|
4218
|
+
body: JSON.stringify(body),
|
|
4219
|
+
signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
|
|
4176
4220
|
});
|
|
4177
4221
|
const data = await response.json();
|
|
4178
4222
|
if (response.status === 410) {
|
|
4179
4223
|
return {
|
|
4180
4224
|
success: true,
|
|
4225
|
+
// 3.12.0 (Trust Record): keep the server-echoed attempt handle even on
|
|
4226
|
+
// the synthesised 410 deny shape (echoed on every branch).
|
|
4227
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
|
|
4181
4228
|
access: {
|
|
4182
4229
|
allowed: false,
|
|
4183
4230
|
accessLevel: "none",
|
|
@@ -4193,10 +4240,22 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4193
4240
|
};
|
|
4194
4241
|
}
|
|
4195
4242
|
if (!response.ok) {
|
|
4243
|
+
if (response.status === 401) {
|
|
4244
|
+
return {
|
|
4245
|
+
success: false,
|
|
4246
|
+
error: data.message || data.error || "Integration API key rejected",
|
|
4247
|
+
misconfig: true,
|
|
4248
|
+
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
4249
|
+
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
4250
|
+
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
4251
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
4252
|
+
};
|
|
4253
|
+
}
|
|
4196
4254
|
return {
|
|
4197
4255
|
success: false,
|
|
4198
4256
|
error: data.message || data.error || `API returned ${response.status}`,
|
|
4199
|
-
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0
|
|
4257
|
+
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
4258
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
4200
4259
|
};
|
|
4201
4260
|
}
|
|
4202
4261
|
return data;
|
|
@@ -4213,9 +4272,19 @@ async function verify(config, request, options) {
|
|
|
4213
4272
|
const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
|
|
4214
4273
|
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
4215
4274
|
if (mergedConfig.strictInit) {
|
|
4216
|
-
await performInitCheck(
|
|
4275
|
+
await performInitCheck(
|
|
4276
|
+
mergedConfig.apiBaseUrl,
|
|
4277
|
+
mergedConfig.debug,
|
|
4278
|
+
true,
|
|
4279
|
+
mergedConfig.apiKey
|
|
4280
|
+
);
|
|
4217
4281
|
} else {
|
|
4218
|
-
void performInitCheck(
|
|
4282
|
+
void performInitCheck(
|
|
4283
|
+
mergedConfig.apiBaseUrl,
|
|
4284
|
+
mergedConfig.debug,
|
|
4285
|
+
false,
|
|
4286
|
+
mergedConfig.apiKey
|
|
4287
|
+
);
|
|
4219
4288
|
}
|
|
4220
4289
|
}
|
|
4221
4290
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
@@ -4230,7 +4299,13 @@ async function verify(config, request, options) {
|
|
|
4230
4299
|
if (mergedConfig.debug) {
|
|
4231
4300
|
console.log("[VerificationGateway] Returning cached result");
|
|
4232
4301
|
}
|
|
4233
|
-
|
|
4302
|
+
const hit = { ...cached };
|
|
4303
|
+
if (request.attemptId) {
|
|
4304
|
+
hit.attemptId = request.attemptId;
|
|
4305
|
+
} else {
|
|
4306
|
+
delete hit.attemptId;
|
|
4307
|
+
}
|
|
4308
|
+
return hit;
|
|
4234
4309
|
}
|
|
4235
4310
|
}
|
|
4236
4311
|
const enrichedRequest = { ...request };
|
|
@@ -4248,8 +4323,10 @@ async function verify(config, request, options) {
|
|
|
4248
4323
|
const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
|
|
4249
4324
|
if (!apiResponse.success) {
|
|
4250
4325
|
return createGuidanceResponse(mergedConfig, apiResponse.error, {
|
|
4251
|
-
source: "api_error",
|
|
4326
|
+
source: apiResponse.misconfig ? "merchant_misconfig" : "api_error",
|
|
4252
4327
|
correlationId: apiResponse.correlationId,
|
|
4328
|
+
attemptId: apiResponse.attemptId,
|
|
4329
|
+
remediation: apiResponse.remediation,
|
|
4253
4330
|
urls
|
|
4254
4331
|
});
|
|
4255
4332
|
}
|
|
@@ -4285,6 +4362,9 @@ async function verify(config, request, options) {
|
|
|
4285
4362
|
// Anonymous traffic has no session → correlationId is the per-attempt
|
|
4286
4363
|
// linking key (the sessionId-equivalent for anonymous callers).
|
|
4287
4364
|
correlationId: apiResponse.correlationId,
|
|
4365
|
+
// 3.12.0 (Trust Record): server echoes the attempt-chain handle on
|
|
4366
|
+
// every branch — denials included (the funnel outlives one deny).
|
|
4367
|
+
attemptId: apiResponse.attemptId,
|
|
4288
4368
|
recommendation: apiResponse.recommendation,
|
|
4289
4369
|
recommendationReasons: apiResponse.recommendationReasons,
|
|
4290
4370
|
stepUpApproval: apiResponse.stepUpApproval,
|
|
@@ -4336,6 +4416,8 @@ async function verify(config, request, options) {
|
|
|
4336
4416
|
// v2.3.10 (defect #34, round-4): anonymous responses surface correlationId
|
|
4337
4417
|
// (no session row exists for unverified callers).
|
|
4338
4418
|
correlationId: apiResponse.correlationId,
|
|
4419
|
+
// 3.12.0 (Trust Record): server-echoed attempt-chain handle.
|
|
4420
|
+
attemptId: apiResponse.attemptId,
|
|
4339
4421
|
runtimeChallenge: apiResponse.runtimeChallenge,
|
|
4340
4422
|
tokenGuidance: apiResponse.tokenGuidance,
|
|
4341
4423
|
recommendation: apiResponse.recommendation,
|