@astrasyncai/verification-gateway 5.19.0 → 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 +83 -0
- package/README.md +51 -2
- package/dist/adapter-interface/interface.d.mts +2 -2
- package/dist/adapter-interface/interface.d.ts +2 -2
- package/dist/adapters/express.d.mts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.js +65 -16
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +65 -16
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +23 -1
- package/dist/adapters/mcp.d.ts +23 -1
- package/dist/adapters/mcp.js +91 -16
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +91 -16
- 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 +57 -11
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +57 -11
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +58 -2
- package/dist/adapters/sdk.d.ts +58 -2
- package/dist/adapters/sdk.js +124 -11
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +124 -11
- 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 +49 -11
- package/dist/bin/astrasync-codex-hook.js +49 -11
- package/dist/bin/astrasync-guard.js +49 -11
- package/dist/bin/astrasync.js +51 -12
- package/dist/browser/background.js +49 -11
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +49 -11
- 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 +49 -11
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +49 -11
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +49 -11
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +49 -11
- 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 +49 -11
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +49 -11
- 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 +49 -11
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +49 -11
- 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 +168 -8
- package/dist/index.d.ts +168 -8
- package/dist/index.js +229 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +226 -31
- 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 +1 -1
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +1 -1
- 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-DqWPkiYl.d.mts → types-CxjqmPl-.d.mts} +25 -1
- package/dist/{types-DqWPkiYl.d.ts → types-CxjqmPl-.d.ts} +25 -1
- package/dist/{types-BoGjyon0.d.mts → types-D37aSQ9c.d.mts} +25 -1
- package/dist/{types-CfBpm3w5.d.mts → types-Djpz-L0w.d.mts} +1 -1
- package/dist/{types-eWyZuz-3.d.ts → types-Dn8tXnei.d.ts} +25 -1
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +28 -3
- package/dist/verify.d.ts +28 -3
- package/dist/verify.js +71 -11
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +69 -11
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
package/dist/adapters/sdk.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TrustLevel, S as SDKOptions, e as VerificationResult, d as VerificationRequest, A as AgentArtifacts, C as CheckoutMetadata } from '../types-
|
|
1
|
+
import { T as TrustLevel, S as SDKOptions, e as VerificationResult, d as VerificationRequest, A as AgentArtifacts, C as CheckoutMetadata } from '../types-CxjqmPl-.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* AstraSync Universal Verification Gateway — Trust Level helpers.
|
|
@@ -199,6 +199,40 @@ declare class VerificationGatewayClient {
|
|
|
199
199
|
status: string;
|
|
200
200
|
alreadySettled?: boolean;
|
|
201
201
|
}>;
|
|
202
|
+
/**
|
|
203
|
+
* 5.20.0 (round 29.1): change an endpoint's OPERATIONAL URLs with this
|
|
204
|
+
* client's API key — `PATCH /api/endpoints/:id`. Accepts the key of the
|
|
205
|
+
* endpoint's owner, or a personal key of an individual with an active seat
|
|
206
|
+
* in the owning organisation. Policy (rules, trust floor, challenge, edge
|
|
207
|
+
* config) stays dashboard-only. `null` clears a field. The owner is alerted
|
|
208
|
+
* when `eventsUrl` changes.
|
|
209
|
+
*
|
|
210
|
+
* @param endpointId the ASTRAE id (defaults to the client's `counterpartyId`)
|
|
211
|
+
* @returns the endpoint as stored, plus `changed` (the fields that changed)
|
|
212
|
+
* @throws AstraSyncError — 400 `UNKNOWN_FIELDS` / validation, 401/403, 404
|
|
213
|
+
*/
|
|
214
|
+
updateEndpoint(endpointId: string | undefined, patch: EndpointOperationalPatch): Promise<Record<string, unknown> & {
|
|
215
|
+
changed: Array<keyof EndpointOperationalPatch>;
|
|
216
|
+
}>;
|
|
217
|
+
/**
|
|
218
|
+
* 5.20.0 (round 29.1): ask AstraSync to send ONE signed step-up event to the
|
|
219
|
+
* endpoint's Events URL now — `POST /api/endpoints/:id/events/test`.
|
|
220
|
+
* Delivered synchronously, outside the event outbox (random `eventId`, no
|
|
221
|
+
* retries), signed with the endpoint's webhook secret like a real event.
|
|
222
|
+
* Without `approvalId` the payload is synthetic (a kit acknowledges and
|
|
223
|
+
* ignores it). With the id of a held kit approval at this endpoint the
|
|
224
|
+
* payload is the real one, so your resume path runs: `approved` makes the
|
|
225
|
+
* kit re-confirm (held again — nothing is charged); `denied` / `expired` /
|
|
226
|
+
* `lapsed` release the session.
|
|
227
|
+
*
|
|
228
|
+
* Resolves even when your endpoint refused the event (`delivered: false`,
|
|
229
|
+
* with `responseCode` / `error`).
|
|
230
|
+
*/
|
|
231
|
+
sendTestEvent(endpointId: string | undefined, options: {
|
|
232
|
+
type: TestEventType;
|
|
233
|
+
approvalId?: string;
|
|
234
|
+
}): Promise<TestEventResult>;
|
|
235
|
+
private endpointCall;
|
|
202
236
|
/**
|
|
203
237
|
* Quick verification — checks credentials and policy in one call.
|
|
204
238
|
*
|
|
@@ -238,6 +272,28 @@ declare class VerificationGatewayClient {
|
|
|
238
272
|
*/
|
|
239
273
|
private executeWithRetry;
|
|
240
274
|
}
|
|
275
|
+
/** 5.20.0: the operational fields `updateEndpoint` may change (`null` clears). */
|
|
276
|
+
interface EndpointOperationalPatch {
|
|
277
|
+
eventsUrl?: string | null;
|
|
278
|
+
healthCheckUrl?: string | null;
|
|
279
|
+
skillUrl?: string | null;
|
|
280
|
+
catalogUrl?: string | null;
|
|
281
|
+
checkoutUrl?: string | null;
|
|
282
|
+
}
|
|
283
|
+
/** 5.20.0: the step-up event types `sendTestEvent` can send. */
|
|
284
|
+
type TestEventType = 'step_up.approved' | 'step_up.denied' | 'step_up.expired' | 'step_up.lapsed';
|
|
285
|
+
/** 5.20.0: what `sendTestEvent` reports. */
|
|
286
|
+
interface TestEventResult {
|
|
287
|
+
delivered: boolean;
|
|
288
|
+
/** delivered | failed (bad answer / unreachable) | not_configured (no Events URL or secret). */
|
|
289
|
+
status: 'delivered' | 'failed' | 'not_configured';
|
|
290
|
+
/** Your endpoint's HTTP status, or null when nothing answered. */
|
|
291
|
+
responseCode: number | null;
|
|
292
|
+
error: string | null;
|
|
293
|
+
eventId: string;
|
|
294
|
+
type: TestEventType;
|
|
295
|
+
approvalId: string | null;
|
|
296
|
+
}
|
|
241
297
|
/**
|
|
242
298
|
* Create a new SDK client
|
|
243
299
|
*/
|
|
@@ -253,4 +309,4 @@ declare function verifyOnce(options: SDKOptions & {
|
|
|
253
309
|
action?: string;
|
|
254
310
|
}): Promise<VerificationResult>;
|
|
255
311
|
|
|
256
|
-
export { VerificationGatewayClient, createClient, getTrustLevel, verifyOnce };
|
|
312
|
+
export { type EndpointOperationalPatch, type TestEventResult, type TestEventType, VerificationGatewayClient, createClient, getTrustLevel, verifyOnce };
|
package/dist/adapters/sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TrustLevel, S as SDKOptions, e as VerificationResult, d as VerificationRequest, A as AgentArtifacts, C as CheckoutMetadata } from '../types-
|
|
1
|
+
import { T as TrustLevel, S as SDKOptions, e as VerificationResult, d as VerificationRequest, A as AgentArtifacts, C as CheckoutMetadata } from '../types-CxjqmPl-.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* AstraSync Universal Verification Gateway — Trust Level helpers.
|
|
@@ -199,6 +199,40 @@ declare class VerificationGatewayClient {
|
|
|
199
199
|
status: string;
|
|
200
200
|
alreadySettled?: boolean;
|
|
201
201
|
}>;
|
|
202
|
+
/**
|
|
203
|
+
* 5.20.0 (round 29.1): change an endpoint's OPERATIONAL URLs with this
|
|
204
|
+
* client's API key — `PATCH /api/endpoints/:id`. Accepts the key of the
|
|
205
|
+
* endpoint's owner, or a personal key of an individual with an active seat
|
|
206
|
+
* in the owning organisation. Policy (rules, trust floor, challenge, edge
|
|
207
|
+
* config) stays dashboard-only. `null` clears a field. The owner is alerted
|
|
208
|
+
* when `eventsUrl` changes.
|
|
209
|
+
*
|
|
210
|
+
* @param endpointId the ASTRAE id (defaults to the client's `counterpartyId`)
|
|
211
|
+
* @returns the endpoint as stored, plus `changed` (the fields that changed)
|
|
212
|
+
* @throws AstraSyncError — 400 `UNKNOWN_FIELDS` / validation, 401/403, 404
|
|
213
|
+
*/
|
|
214
|
+
updateEndpoint(endpointId: string | undefined, patch: EndpointOperationalPatch): Promise<Record<string, unknown> & {
|
|
215
|
+
changed: Array<keyof EndpointOperationalPatch>;
|
|
216
|
+
}>;
|
|
217
|
+
/**
|
|
218
|
+
* 5.20.0 (round 29.1): ask AstraSync to send ONE signed step-up event to the
|
|
219
|
+
* endpoint's Events URL now — `POST /api/endpoints/:id/events/test`.
|
|
220
|
+
* Delivered synchronously, outside the event outbox (random `eventId`, no
|
|
221
|
+
* retries), signed with the endpoint's webhook secret like a real event.
|
|
222
|
+
* Without `approvalId` the payload is synthetic (a kit acknowledges and
|
|
223
|
+
* ignores it). With the id of a held kit approval at this endpoint the
|
|
224
|
+
* payload is the real one, so your resume path runs: `approved` makes the
|
|
225
|
+
* kit re-confirm (held again — nothing is charged); `denied` / `expired` /
|
|
226
|
+
* `lapsed` release the session.
|
|
227
|
+
*
|
|
228
|
+
* Resolves even when your endpoint refused the event (`delivered: false`,
|
|
229
|
+
* with `responseCode` / `error`).
|
|
230
|
+
*/
|
|
231
|
+
sendTestEvent(endpointId: string | undefined, options: {
|
|
232
|
+
type: TestEventType;
|
|
233
|
+
approvalId?: string;
|
|
234
|
+
}): Promise<TestEventResult>;
|
|
235
|
+
private endpointCall;
|
|
202
236
|
/**
|
|
203
237
|
* Quick verification — checks credentials and policy in one call.
|
|
204
238
|
*
|
|
@@ -238,6 +272,28 @@ declare class VerificationGatewayClient {
|
|
|
238
272
|
*/
|
|
239
273
|
private executeWithRetry;
|
|
240
274
|
}
|
|
275
|
+
/** 5.20.0: the operational fields `updateEndpoint` may change (`null` clears). */
|
|
276
|
+
interface EndpointOperationalPatch {
|
|
277
|
+
eventsUrl?: string | null;
|
|
278
|
+
healthCheckUrl?: string | null;
|
|
279
|
+
skillUrl?: string | null;
|
|
280
|
+
catalogUrl?: string | null;
|
|
281
|
+
checkoutUrl?: string | null;
|
|
282
|
+
}
|
|
283
|
+
/** 5.20.0: the step-up event types `sendTestEvent` can send. */
|
|
284
|
+
type TestEventType = 'step_up.approved' | 'step_up.denied' | 'step_up.expired' | 'step_up.lapsed';
|
|
285
|
+
/** 5.20.0: what `sendTestEvent` reports. */
|
|
286
|
+
interface TestEventResult {
|
|
287
|
+
delivered: boolean;
|
|
288
|
+
/** delivered | failed (bad answer / unreachable) | not_configured (no Events URL or secret). */
|
|
289
|
+
status: 'delivered' | 'failed' | 'not_configured';
|
|
290
|
+
/** Your endpoint's HTTP status, or null when nothing answered. */
|
|
291
|
+
responseCode: number | null;
|
|
292
|
+
error: string | null;
|
|
293
|
+
eventId: string;
|
|
294
|
+
type: TestEventType;
|
|
295
|
+
approvalId: string | null;
|
|
296
|
+
}
|
|
241
297
|
/**
|
|
242
298
|
* Create a new SDK client
|
|
243
299
|
*/
|
|
@@ -253,4 +309,4 @@ declare function verifyOnce(options: SDKOptions & {
|
|
|
253
309
|
action?: string;
|
|
254
310
|
}): Promise<VerificationResult>;
|
|
255
311
|
|
|
256
|
-
export { VerificationGatewayClient, createClient, getTrustLevel, verifyOnce };
|
|
312
|
+
export { type EndpointOperationalPatch, type TestEventResult, type TestEventType, VerificationGatewayClient, createClient, getTrustLevel, verifyOnce };
|
package/dist/adapters/sdk.js
CHANGED
|
@@ -28,7 +28,7 @@ __export(sdk_exports, {
|
|
|
28
28
|
module.exports = __toCommonJS(sdk_exports);
|
|
29
29
|
|
|
30
30
|
// src/version.ts
|
|
31
|
-
var SDK_VERSION = "5.
|
|
31
|
+
var SDK_VERSION = "5.20.0";
|
|
32
32
|
|
|
33
33
|
// src/http.ts
|
|
34
34
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -236,6 +236,7 @@ function cacheResult(request, result, configuredTtl, counterpartyId) {
|
|
|
236
236
|
}
|
|
237
237
|
function clearCache() {
|
|
238
238
|
verificationCache.clear();
|
|
239
|
+
inflightVerifies.clear();
|
|
239
240
|
}
|
|
240
241
|
function mcpGuidance(urls) {
|
|
241
242
|
if (!urls?.mcpEndpoint) return void 0;
|
|
@@ -372,6 +373,9 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
372
373
|
if (requestData.enableRuntimeChallenge)
|
|
373
374
|
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
374
375
|
if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
|
|
376
|
+
if (config.actingProof?.connectorToken) {
|
|
377
|
+
body.actingProof = { connectorToken: config.actingProof.connectorToken };
|
|
378
|
+
}
|
|
375
379
|
if (requestData.approvalHeldByRoute) body.approvalHeldByRoute = true;
|
|
376
380
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
377
381
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
@@ -539,22 +543,43 @@ async function verify(config, request, options) {
|
|
|
539
543
|
"[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."
|
|
540
544
|
);
|
|
541
545
|
}
|
|
542
|
-
const uncacheable = Boolean(request.commerceArtifacts);
|
|
546
|
+
const uncacheable = Boolean(request.commerceArtifacts) || Boolean(mergedConfig.actingProof);
|
|
543
547
|
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
544
548
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
545
549
|
if (cached) {
|
|
546
550
|
if (mergedConfig.debug) {
|
|
547
551
|
console.log("[VerificationGateway] Returning cached result");
|
|
548
552
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
553
|
+
return sharedVerdict(cached, request);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
557
|
+
const key = getCacheKey(request, mergedConfig.counterpartyId);
|
|
558
|
+
const pending = inflightVerifies.get(key);
|
|
559
|
+
if (pending) return sharedVerdict(await pending, request);
|
|
560
|
+
const flight = verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
561
|
+
inflightVerifies.set(key, flight);
|
|
562
|
+
try {
|
|
563
|
+
return await flight;
|
|
564
|
+
} finally {
|
|
565
|
+
inflightVerifies.delete(key);
|
|
556
566
|
}
|
|
557
567
|
}
|
|
568
|
+
return verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
569
|
+
}
|
|
570
|
+
var inflightVerifies = /* @__PURE__ */ new Map();
|
|
571
|
+
var sharedVerdicts = /* @__PURE__ */ new WeakSet();
|
|
572
|
+
function sharedVerdict(source, request) {
|
|
573
|
+
const hit = { ...source };
|
|
574
|
+
if (request.attemptId) {
|
|
575
|
+
hit.attemptId = request.attemptId;
|
|
576
|
+
} else {
|
|
577
|
+
delete hit.attemptId;
|
|
578
|
+
}
|
|
579
|
+
sharedVerdicts.add(hit);
|
|
580
|
+
return hit;
|
|
581
|
+
}
|
|
582
|
+
async function verifyViaApi(mergedConfig, request, urls, uncacheable) {
|
|
558
583
|
const enrichedRequest = { ...request };
|
|
559
584
|
if (!enrichedRequest.counterpartyUrl && mergedConfig.counterpartyUrl) {
|
|
560
585
|
enrichedRequest.counterpartyUrl = mergedConfig.counterpartyUrl;
|
|
@@ -633,7 +658,9 @@ async function verify(config, request, options) {
|
|
|
633
658
|
fulfilment: apiResponse.fulfilment,
|
|
634
659
|
mandates: apiResponse.mandates,
|
|
635
660
|
kyaToken: apiResponse.kyaToken,
|
|
636
|
-
aep: apiResponse.aep
|
|
661
|
+
aep: apiResponse.aep,
|
|
662
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
663
|
+
warnings: apiResponse.warnings
|
|
637
664
|
};
|
|
638
665
|
return result2;
|
|
639
666
|
}
|
|
@@ -701,7 +728,9 @@ async function verify(config, request, options) {
|
|
|
701
728
|
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
702
729
|
mandates: apiResponse.mandates,
|
|
703
730
|
kyaToken: apiResponse.kyaToken,
|
|
704
|
-
aep: apiResponse.aep
|
|
731
|
+
aep: apiResponse.aep,
|
|
732
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
733
|
+
warnings: apiResponse.warnings
|
|
705
734
|
};
|
|
706
735
|
if (result.recommendation === "deny") {
|
|
707
736
|
result.policyAllowed = false;
|
|
@@ -727,8 +756,18 @@ async function verify(config, request, options) {
|
|
|
727
756
|
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
728
757
|
}
|
|
729
758
|
}
|
|
759
|
+
notifyVerificationListeners(request, result);
|
|
730
760
|
return result;
|
|
731
761
|
}
|
|
762
|
+
var verificationListeners = /* @__PURE__ */ new Set();
|
|
763
|
+
function notifyVerificationListeners(request, result) {
|
|
764
|
+
for (const listener of verificationListeners) {
|
|
765
|
+
try {
|
|
766
|
+
listener(result, request);
|
|
767
|
+
} catch {
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
732
771
|
async function quickVerify(config, credentials) {
|
|
733
772
|
const result = await verify(config, {
|
|
734
773
|
credentials,
|
|
@@ -988,6 +1027,80 @@ var VerificationGatewayClient = class {
|
|
|
988
1027
|
}
|
|
989
1028
|
return json.data;
|
|
990
1029
|
}
|
|
1030
|
+
/**
|
|
1031
|
+
* 5.20.0 (round 29.1): change an endpoint's OPERATIONAL URLs with this
|
|
1032
|
+
* client's API key — `PATCH /api/endpoints/:id`. Accepts the key of the
|
|
1033
|
+
* endpoint's owner, or a personal key of an individual with an active seat
|
|
1034
|
+
* in the owning organisation. Policy (rules, trust floor, challenge, edge
|
|
1035
|
+
* config) stays dashboard-only. `null` clears a field. The owner is alerted
|
|
1036
|
+
* when `eventsUrl` changes.
|
|
1037
|
+
*
|
|
1038
|
+
* @param endpointId the ASTRAE id (defaults to the client's `counterpartyId`)
|
|
1039
|
+
* @returns the endpoint as stored, plus `changed` (the fields that changed)
|
|
1040
|
+
* @throws AstraSyncError — 400 `UNKNOWN_FIELDS` / validation, 401/403, 404
|
|
1041
|
+
*/
|
|
1042
|
+
async updateEndpoint(endpointId, patch) {
|
|
1043
|
+
return this.endpointCall("PATCH", endpointId, "", patch);
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* 5.20.0 (round 29.1): ask AstraSync to send ONE signed step-up event to the
|
|
1047
|
+
* endpoint's Events URL now — `POST /api/endpoints/:id/events/test`.
|
|
1048
|
+
* Delivered synchronously, outside the event outbox (random `eventId`, no
|
|
1049
|
+
* retries), signed with the endpoint's webhook secret like a real event.
|
|
1050
|
+
* Without `approvalId` the payload is synthetic (a kit acknowledges and
|
|
1051
|
+
* ignores it). With the id of a held kit approval at this endpoint the
|
|
1052
|
+
* payload is the real one, so your resume path runs: `approved` makes the
|
|
1053
|
+
* kit re-confirm (held again — nothing is charged); `denied` / `expired` /
|
|
1054
|
+
* `lapsed` release the session.
|
|
1055
|
+
*
|
|
1056
|
+
* Resolves even when your endpoint refused the event (`delivered: false`,
|
|
1057
|
+
* with `responseCode` / `error`).
|
|
1058
|
+
*/
|
|
1059
|
+
async sendTestEvent(endpointId, options) {
|
|
1060
|
+
return this.endpointCall("POST", endpointId, "/events/test", options);
|
|
1061
|
+
}
|
|
1062
|
+
async endpointCall(method, endpointId, suffix, body) {
|
|
1063
|
+
const id = endpointId ?? this.config.counterpartyId;
|
|
1064
|
+
if (!id) {
|
|
1065
|
+
throw new AstraSyncError(
|
|
1066
|
+
"An endpoint id (ASTRAE-\u2026) is required: pass it, or set counterpartyId on the client",
|
|
1067
|
+
400,
|
|
1068
|
+
"VALIDATION"
|
|
1069
|
+
);
|
|
1070
|
+
}
|
|
1071
|
+
if (!this.config.apiKey) {
|
|
1072
|
+
throw new AstraSyncError("This call needs the client apiKey", 401, "AUTH_REQUIRED");
|
|
1073
|
+
}
|
|
1074
|
+
const base = this.config.apiBaseUrl.replace(/\/+$/, "");
|
|
1075
|
+
const url = `${base}/endpoints/${encodeURIComponent(id)}${suffix}`;
|
|
1076
|
+
let res;
|
|
1077
|
+
try {
|
|
1078
|
+
res = await sdkFetch(url, {
|
|
1079
|
+
method,
|
|
1080
|
+
headers: {
|
|
1081
|
+
"Content-Type": "application/json",
|
|
1082
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
1083
|
+
"X-API-Key": this.config.apiKey
|
|
1084
|
+
},
|
|
1085
|
+
body: JSON.stringify(body),
|
|
1086
|
+
signal: AbortSignal.timeout(Math.max(this.timeout, 15e3))
|
|
1087
|
+
});
|
|
1088
|
+
} catch (err) {
|
|
1089
|
+
throw new AstraSyncError(
|
|
1090
|
+
`${method} ${suffix || "/endpoints/:id"} failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
1091
|
+
0,
|
|
1092
|
+
"network_error"
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
const json = await res.json().catch(() => ({}));
|
|
1096
|
+
if (!res.ok || json.success === false || json.data === void 0) {
|
|
1097
|
+
const errObj = typeof json.error === "object" ? json.error : void 0;
|
|
1098
|
+
const code = json.code ?? errObj?.code ?? (typeof json.error === "string" ? json.error : "unknown_error");
|
|
1099
|
+
const message = json.message ?? errObj?.message ?? `HTTP ${res.status}`;
|
|
1100
|
+
throw new AstraSyncError(`${message} (${code})`, res.status, code);
|
|
1101
|
+
}
|
|
1102
|
+
return json.data;
|
|
1103
|
+
}
|
|
991
1104
|
/**
|
|
992
1105
|
* Quick verification — checks credentials and policy in one call.
|
|
993
1106
|
*
|