@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
|
@@ -3915,7 +3915,7 @@ function getTrustLevel(score) {
|
|
|
3915
3915
|
}
|
|
3916
3916
|
|
|
3917
3917
|
// src/version.ts
|
|
3918
|
-
var SDK_VERSION = "
|
|
3918
|
+
var SDK_VERSION = "4.0.0";
|
|
3919
3919
|
|
|
3920
3920
|
// src/well-known.ts
|
|
3921
3921
|
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
@@ -3941,7 +3941,7 @@ var DEFAULT_CONFIG = {
|
|
|
3941
3941
|
};
|
|
3942
3942
|
var initCheckPerformed = false;
|
|
3943
3943
|
var deprecationWarningShown = false;
|
|
3944
|
-
async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
3944
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
|
|
3945
3945
|
initCheckPerformed = true;
|
|
3946
3946
|
try {
|
|
3947
3947
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
@@ -3958,6 +3958,28 @@ async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
|
3958
3958
|
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
3959
3959
|
);
|
|
3960
3960
|
}
|
|
3961
|
+
if (apiKey) {
|
|
3962
|
+
const selfCheck = await fetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
|
|
3963
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
3964
|
+
});
|
|
3965
|
+
if (selfCheck.status === 401) {
|
|
3966
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
3967
|
+
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}` : "") + `.`;
|
|
3968
|
+
if (strictInit) {
|
|
3969
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
3970
|
+
}
|
|
3971
|
+
console.error(message);
|
|
3972
|
+
} else if (selfCheck.ok) {
|
|
3973
|
+
const body = await selfCheck.json().catch(() => ({}));
|
|
3974
|
+
if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
|
|
3975
|
+
console.warn(
|
|
3976
|
+
`[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
|
|
3977
|
+
);
|
|
3978
|
+
} else if (debug) {
|
|
3979
|
+
console.log("[VerificationGateway] API key self-check passed");
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
}
|
|
3961
3983
|
} catch (err) {
|
|
3962
3984
|
if (strictInit) {
|
|
3963
3985
|
throw err;
|
|
@@ -4035,8 +4057,17 @@ function cacheResult(request, result, configuredTtl, counterpartyId) {
|
|
|
4035
4057
|
function createGuidanceResponse(_config, reason, options = {}) {
|
|
4036
4058
|
const source = options.source ?? "no_credentials";
|
|
4037
4059
|
const isApiError = source === "api_error";
|
|
4060
|
+
const isMisconfig = source === "merchant_misconfig";
|
|
4038
4061
|
const urls = options.urls;
|
|
4039
|
-
const guidance =
|
|
4062
|
+
const guidance = isMisconfig ? {
|
|
4063
|
+
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.",
|
|
4064
|
+
registrationUrl: urls?.registrationUrl ?? "",
|
|
4065
|
+
documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
|
|
4066
|
+
steps: [
|
|
4067
|
+
"Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
|
|
4068
|
+
"Do not retry: the failure is deterministic until the operator updates their key"
|
|
4069
|
+
]
|
|
4070
|
+
} : isApiError ? {
|
|
4040
4071
|
message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
|
|
4041
4072
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
4042
4073
|
documentationUrl: urls?.documentationUrl ?? "",
|
|
@@ -4074,14 +4105,24 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
4074
4105
|
// partners (and their custom onDenied handlers) can branch on
|
|
4075
4106
|
// dimension. Without this, the synthesised stub was indistinguishable
|
|
4076
4107
|
// from a real policy deny.
|
|
4077
|
-
failures:
|
|
4108
|
+
failures: isMisconfig ? [
|
|
4109
|
+
{
|
|
4110
|
+
dimension: "verify_access.merchant_misconfigured",
|
|
4111
|
+
message: reason ?? "The integration API key was rejected by AstraSync",
|
|
4112
|
+
guidance: guidance.message
|
|
4113
|
+
}
|
|
4114
|
+
] : isApiError ? [
|
|
4078
4115
|
{
|
|
4079
4116
|
dimension: "verify_access.api_error",
|
|
4080
4117
|
message: reason ?? "Verification temporarily unavailable",
|
|
4081
4118
|
guidance: guidance.message
|
|
4082
4119
|
}
|
|
4083
4120
|
] : void 0,
|
|
4121
|
+
// 4.0.0: typed marker so adapters render the misconfig envelope (503 +
|
|
4122
|
+
// MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
|
|
4123
|
+
...isMisconfig && { misconfigured: true },
|
|
4084
4124
|
correlationId: options.correlationId,
|
|
4125
|
+
attemptId: options.attemptId,
|
|
4085
4126
|
verifiedAt: /* @__PURE__ */ new Date()
|
|
4086
4127
|
};
|
|
4087
4128
|
}
|
|
@@ -4111,6 +4152,8 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4111
4152
|
body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
|
|
4112
4153
|
if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
|
|
4113
4154
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
4155
|
+
if (requestData.attemptId) body.attemptId = requestData.attemptId;
|
|
4156
|
+
if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
|
|
4114
4157
|
body.sdkVersion = SDK_VERSION;
|
|
4115
4158
|
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
4116
4159
|
const meta = {
|
|
@@ -4132,12 +4175,16 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4132
4175
|
const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
|
|
4133
4176
|
method: "POST",
|
|
4134
4177
|
headers,
|
|
4135
|
-
body: JSON.stringify(body)
|
|
4178
|
+
body: JSON.stringify(body),
|
|
4179
|
+
signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
|
|
4136
4180
|
});
|
|
4137
4181
|
const data = await response.json();
|
|
4138
4182
|
if (response.status === 410) {
|
|
4139
4183
|
return {
|
|
4140
4184
|
success: true,
|
|
4185
|
+
// 3.12.0 (Trust Record): keep the server-echoed attempt handle even on
|
|
4186
|
+
// the synthesised 410 deny shape (echoed on every branch).
|
|
4187
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
|
|
4141
4188
|
access: {
|
|
4142
4189
|
allowed: false,
|
|
4143
4190
|
accessLevel: "none",
|
|
@@ -4153,10 +4200,22 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
4153
4200
|
};
|
|
4154
4201
|
}
|
|
4155
4202
|
if (!response.ok) {
|
|
4203
|
+
if (response.status === 401) {
|
|
4204
|
+
return {
|
|
4205
|
+
success: false,
|
|
4206
|
+
error: data.message || data.error || "Integration API key rejected",
|
|
4207
|
+
misconfig: true,
|
|
4208
|
+
misconfigCode: typeof data?.code === "string" ? data.code : void 0,
|
|
4209
|
+
remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
|
|
4210
|
+
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
4211
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
4212
|
+
};
|
|
4213
|
+
}
|
|
4156
4214
|
return {
|
|
4157
4215
|
success: false,
|
|
4158
4216
|
error: data.message || data.error || `API returned ${response.status}`,
|
|
4159
|
-
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0
|
|
4217
|
+
correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
|
|
4218
|
+
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
|
|
4160
4219
|
};
|
|
4161
4220
|
}
|
|
4162
4221
|
return data;
|
|
@@ -4173,9 +4232,19 @@ async function verify(config, request, options) {
|
|
|
4173
4232
|
const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
|
|
4174
4233
|
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
4175
4234
|
if (mergedConfig.strictInit) {
|
|
4176
|
-
await performInitCheck(
|
|
4235
|
+
await performInitCheck(
|
|
4236
|
+
mergedConfig.apiBaseUrl,
|
|
4237
|
+
mergedConfig.debug,
|
|
4238
|
+
true,
|
|
4239
|
+
mergedConfig.apiKey
|
|
4240
|
+
);
|
|
4177
4241
|
} else {
|
|
4178
|
-
void performInitCheck(
|
|
4242
|
+
void performInitCheck(
|
|
4243
|
+
mergedConfig.apiBaseUrl,
|
|
4244
|
+
mergedConfig.debug,
|
|
4245
|
+
false,
|
|
4246
|
+
mergedConfig.apiKey
|
|
4247
|
+
);
|
|
4179
4248
|
}
|
|
4180
4249
|
}
|
|
4181
4250
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
@@ -4190,7 +4259,13 @@ async function verify(config, request, options) {
|
|
|
4190
4259
|
if (mergedConfig.debug) {
|
|
4191
4260
|
console.log("[VerificationGateway] Returning cached result");
|
|
4192
4261
|
}
|
|
4193
|
-
|
|
4262
|
+
const hit = { ...cached };
|
|
4263
|
+
if (request.attemptId) {
|
|
4264
|
+
hit.attemptId = request.attemptId;
|
|
4265
|
+
} else {
|
|
4266
|
+
delete hit.attemptId;
|
|
4267
|
+
}
|
|
4268
|
+
return hit;
|
|
4194
4269
|
}
|
|
4195
4270
|
}
|
|
4196
4271
|
const enrichedRequest = { ...request };
|
|
@@ -4208,8 +4283,10 @@ async function verify(config, request, options) {
|
|
|
4208
4283
|
const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
|
|
4209
4284
|
if (!apiResponse.success) {
|
|
4210
4285
|
return createGuidanceResponse(mergedConfig, apiResponse.error, {
|
|
4211
|
-
source: "api_error",
|
|
4286
|
+
source: apiResponse.misconfig ? "merchant_misconfig" : "api_error",
|
|
4212
4287
|
correlationId: apiResponse.correlationId,
|
|
4288
|
+
attemptId: apiResponse.attemptId,
|
|
4289
|
+
remediation: apiResponse.remediation,
|
|
4213
4290
|
urls
|
|
4214
4291
|
});
|
|
4215
4292
|
}
|
|
@@ -4245,6 +4322,9 @@ async function verify(config, request, options) {
|
|
|
4245
4322
|
// Anonymous traffic has no session → correlationId is the per-attempt
|
|
4246
4323
|
// linking key (the sessionId-equivalent for anonymous callers).
|
|
4247
4324
|
correlationId: apiResponse.correlationId,
|
|
4325
|
+
// 3.12.0 (Trust Record): server echoes the attempt-chain handle on
|
|
4326
|
+
// every branch — denials included (the funnel outlives one deny).
|
|
4327
|
+
attemptId: apiResponse.attemptId,
|
|
4248
4328
|
recommendation: apiResponse.recommendation,
|
|
4249
4329
|
recommendationReasons: apiResponse.recommendationReasons,
|
|
4250
4330
|
stepUpApproval: apiResponse.stepUpApproval,
|
|
@@ -4296,6 +4376,8 @@ async function verify(config, request, options) {
|
|
|
4296
4376
|
// v2.3.10 (defect #34, round-4): anonymous responses surface correlationId
|
|
4297
4377
|
// (no session row exists for unverified callers).
|
|
4298
4378
|
correlationId: apiResponse.correlationId,
|
|
4379
|
+
// 3.12.0 (Trust Record): server-echoed attempt-chain handle.
|
|
4380
|
+
attemptId: apiResponse.attemptId,
|
|
4299
4381
|
runtimeChallenge: apiResponse.runtimeChallenge,
|
|
4300
4382
|
tokenGuidance: apiResponse.tokenGuidance,
|
|
4301
4383
|
recommendation: apiResponse.recommendation,
|