@layervai/qurl 0.7.0 → 3.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/README.md +242 -2
- package/dist/cjs/client.d.ts +41 -9
- package/dist/cjs/client.js +734 -41
- package/dist/cjs/crid.d.ts +2 -1
- package/dist/cjs/crid.js +11 -2
- package/dist/cjs/errors.d.ts +20 -3
- package/dist/cjs/errors.js +31 -4
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/node/agent-runtime.d.ts +108 -0
- package/dist/cjs/node/agent-runtime.js +952 -0
- package/dist/cjs/node/agent-state.d.ts +100 -0
- package/dist/cjs/node/agent-state.js +311 -0
- package/dist/cjs/node/agent-transport.d.ts +17 -0
- package/dist/cjs/node/agent-transport.js +118 -0
- package/dist/cjs/node/deployment.d.ts +6 -0
- package/dist/cjs/node/deployment.js +24 -3
- package/dist/cjs/node/file-agent-state.d.ts +15 -0
- package/dist/cjs/node/file-agent-state.js +137 -0
- package/dist/cjs/node/native-loader.cjs +7 -0
- package/dist/cjs/node/native-loader.d.cts +11 -0
- package/dist/cjs/node/native-udp.d.ts +8 -3
- package/dist/cjs/node/native-udp.js +8 -3
- package/dist/cjs/node/nhp-wire.d.ts +9 -0
- package/dist/cjs/node/nhp-wire.js +24 -7
- package/dist/cjs/node/portal-opener.d.ts +7 -0
- package/dist/cjs/node/portal-opener.js +28 -6
- package/dist/cjs/node/provider.d.ts +19 -0
- package/dist/cjs/node/provider.js +153 -0
- package/dist/cjs/node/qv2.d.ts +3 -1
- package/dist/cjs/node/qv2.js +16 -2
- package/dist/cjs/node/relay.d.ts +12 -0
- package/dist/cjs/node/relay.js +111 -0
- package/dist/cjs/node/sealed-agent-state.d.ts +19 -0
- package/dist/cjs/node/sealed-agent-state.js +193 -0
- package/dist/cjs/node/strict-json.d.ts +1 -1
- package/dist/cjs/node/strict-json.js +8 -3
- package/dist/cjs/node.d.ts +14 -0
- package/dist/cjs/node.js +24 -1
- package/dist/cjs/types.d.ts +161 -8
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client.d.ts +41 -9
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +735 -42
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/crid.d.ts +2 -1
- package/dist/esm/crid.d.ts.map +1 -1
- package/dist/esm/crid.js +10 -2
- package/dist/esm/crid.js.map +1 -1
- package/dist/esm/errors.d.ts +20 -3
- package/dist/esm/errors.d.ts.map +1 -1
- package/dist/esm/errors.js +29 -3
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/agent-runtime.d.ts +109 -0
- package/dist/esm/node/agent-runtime.d.ts.map +1 -0
- package/dist/esm/node/agent-runtime.js +946 -0
- package/dist/esm/node/agent-runtime.js.map +1 -0
- package/dist/esm/node/agent-state.d.ts +101 -0
- package/dist/esm/node/agent-state.d.ts.map +1 -0
- package/dist/esm/node/agent-state.js +298 -0
- package/dist/esm/node/agent-state.js.map +1 -0
- package/dist/esm/node/agent-transport.d.ts +18 -0
- package/dist/esm/node/agent-transport.d.ts.map +1 -0
- package/dist/esm/node/agent-transport.js +114 -0
- package/dist/esm/node/agent-transport.js.map +1 -0
- package/dist/esm/node/deployment.d.ts +6 -0
- package/dist/esm/node/deployment.d.ts.map +1 -1
- package/dist/esm/node/deployment.js +23 -3
- package/dist/esm/node/deployment.js.map +1 -1
- package/dist/esm/node/file-agent-state.d.ts +16 -0
- package/dist/esm/node/file-agent-state.d.ts.map +1 -0
- package/dist/esm/node/file-agent-state.js +134 -0
- package/dist/esm/node/file-agent-state.js.map +1 -0
- package/dist/esm/node/native-loader.cjs +7 -0
- package/dist/esm/node/native-loader.d.cts +11 -0
- package/dist/esm/node/native-udp.d.ts +8 -3
- package/dist/esm/node/native-udp.d.ts.map +1 -1
- package/dist/esm/node/native-udp.js +7 -5
- package/dist/esm/node/native-udp.js.map +1 -1
- package/dist/esm/node/nhp-wire.d.ts +9 -0
- package/dist/esm/node/nhp-wire.d.ts.map +1 -1
- package/dist/esm/node/nhp-wire.js +23 -6
- package/dist/esm/node/nhp-wire.js.map +1 -1
- package/dist/esm/node/portal-opener.d.ts +7 -0
- package/dist/esm/node/portal-opener.d.ts.map +1 -1
- package/dist/esm/node/portal-opener.js +28 -6
- package/dist/esm/node/portal-opener.js.map +1 -1
- package/dist/esm/node/provider.d.ts +20 -0
- package/dist/esm/node/provider.d.ts.map +1 -0
- package/dist/esm/node/provider.js +149 -0
- package/dist/esm/node/provider.js.map +1 -0
- package/dist/esm/node/qv2.d.ts +3 -1
- package/dist/esm/node/qv2.d.ts.map +1 -1
- package/dist/esm/node/qv2.js +17 -3
- package/dist/esm/node/qv2.js.map +1 -1
- package/dist/esm/node/relay.d.ts +13 -0
- package/dist/esm/node/relay.d.ts.map +1 -0
- package/dist/esm/node/relay.js +105 -0
- package/dist/esm/node/relay.js.map +1 -0
- package/dist/esm/node/sealed-agent-state.d.ts +20 -0
- package/dist/esm/node/sealed-agent-state.d.ts.map +1 -0
- package/dist/esm/node/sealed-agent-state.js +190 -0
- package/dist/esm/node/sealed-agent-state.js.map +1 -0
- package/dist/esm/node/strict-json.d.ts +1 -1
- package/dist/esm/node/strict-json.d.ts.map +1 -1
- package/dist/esm/node/strict-json.js +8 -3
- package/dist/esm/node/strict-json.js.map +1 -1
- package/dist/esm/node.d.ts +14 -0
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +7 -0
- package/dist/esm/node.js.map +1 -1
- package/dist/esm/types.d.ts +161 -8
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +16 -6
package/dist/cjs/crid.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const CRID_DOMAIN = "NHP-QURL-CRID-V1\0";
|
|
2
|
+
export declare function parseCrid(value: unknown, knownVersionOnly?: boolean): Uint8Array | undefined;
|
|
2
3
|
export declare function cridKeyMatches(value: unknown, der: Uint8Array): Promise<boolean>;
|
package/dist/cjs/crid.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CRID_DOMAIN = void 0;
|
|
3
4
|
exports.parseCrid = parseCrid;
|
|
4
5
|
exports.cridKeyMatches = cridKeyMatches;
|
|
5
6
|
// CRID v1 local gate and delivered-key binding, matching qurl-go/crid.
|
|
6
7
|
// The byte selects a version/environment/digest width, not a new hash scheme.
|
|
7
8
|
// All key matches use the v1 domain separator, as in qurl-go/crid.KeyMatches.
|
|
8
9
|
// Unknown nonzero versions remain forwardable; the service owns activation.
|
|
10
|
+
// Access binding requires a locally known version and its registered width.
|
|
9
11
|
const ALPHABET = "abcdefghijklmnopqrstuvwxyz234567";
|
|
10
|
-
|
|
12
|
+
exports.CRID_DOMAIN = "NHP-QURL-CRID-V1\0";
|
|
13
|
+
function parseCrid(value, knownVersionOnly = false) {
|
|
11
14
|
if (typeof value !== "string" || ![47, 60].includes(value.length))
|
|
12
15
|
return undefined;
|
|
13
16
|
const bytes = new Uint8Array(Math.floor((value.length * 5) / 8));
|
|
@@ -27,6 +30,12 @@ function parseCrid(value) {
|
|
|
27
30
|
if (buffer !== 0 || bytes[0] === 0)
|
|
28
31
|
return undefined;
|
|
29
32
|
const payload = bytes.subarray(0, -4);
|
|
33
|
+
if (knownVersionOnly) {
|
|
34
|
+
const version = bytes[0];
|
|
35
|
+
const width = version === 1 || version === 0x81 ? 32 : version === 2 || version === 0x82 ? 24 : 0;
|
|
36
|
+
if (payload.length !== width + 1 || width === 0)
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
30
39
|
let crc = 0xffffffff;
|
|
31
40
|
for (const byte of payload) {
|
|
32
41
|
crc ^= byte;
|
|
@@ -41,7 +50,7 @@ async function cridKeyMatches(value, der) {
|
|
|
41
50
|
const expected = parseCrid(value);
|
|
42
51
|
if (!expected)
|
|
43
52
|
return false;
|
|
44
|
-
const prefix = new TextEncoder().encode(
|
|
53
|
+
const prefix = new TextEncoder().encode(exports.CRID_DOMAIN);
|
|
45
54
|
const message = new Uint8Array(prefix.length + der.length);
|
|
46
55
|
message.set(prefix);
|
|
47
56
|
message.set(der, prefix.length);
|
package/dist/cjs/errors.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export declare const ERROR_CODE_INVALID_CRID_KEY = "invalid_crid_key";
|
|
|
24
24
|
export declare const ERROR_CODE_CRID_MISMATCH = "crid_mismatch";
|
|
25
25
|
/** A dispatched Connector resource mutation could have committed and must be reconciled. */
|
|
26
26
|
export declare const ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN = "connector_resource_outcome_unknown";
|
|
27
|
+
/** A delegated batch create was dispatched but no valid acceptance was received. */
|
|
28
|
+
export declare const ERROR_CODE_DELEGATED_BATCH_OUTCOME_UNKNOWN = "delegated_batch_outcome_unknown";
|
|
27
29
|
/** A by-ID Connector resource lookup found a revoked lifecycle row. */
|
|
28
30
|
export declare const ERROR_CODE_CONNECTOR_RESOURCE_REVOKED = "connector_resource_revoked";
|
|
29
31
|
/** A Connector slug lookup found no active resource (client-detected, `status: 0`). */
|
|
@@ -65,6 +67,8 @@ export declare class QURLError extends Error {
|
|
|
65
67
|
readonly invalidFields?: Record<string, string>;
|
|
66
68
|
readonly requestId?: string;
|
|
67
69
|
readonly retryAfter?: number;
|
|
70
|
+
/** Known minted IDs from a rejected terminal batch, for bounded cleanup. No bearer links. */
|
|
71
|
+
readonly partialQurlIds?: readonly string[];
|
|
68
72
|
constructor(data: QURLErrorData);
|
|
69
73
|
}
|
|
70
74
|
/** 401 Unauthorized — invalid or missing API key. */
|
|
@@ -92,9 +96,10 @@ export declare class NotFoundError extends QURLError {
|
|
|
92
96
|
*
|
|
93
97
|
* `instanceof ValidationError` catches both on ordinary client/response
|
|
94
98
|
* paths. A Connector mutation wraps a post-dispatch `unexpected_response`
|
|
95
|
-
* in {@link ConnectorResourceOutcomeUnknownError}
|
|
96
|
-
*
|
|
97
|
-
*
|
|
99
|
+
* in {@link ConnectorResourceOutcomeUnknownError} or
|
|
100
|
+
* {@link DelegatedBatchOutcomeUnknownError}; inspect the wrapper's typed
|
|
101
|
+
* `cause` before deciding whether to retry. To distinguish them, check `.code`
|
|
102
|
+
* rather than using `instanceof` alone.
|
|
98
103
|
*
|
|
99
104
|
* **`.status` asymmetry within `code: "unexpected_response"`:**
|
|
100
105
|
* - Shape-guard failure on a parsed JSON body (wrong field types,
|
|
@@ -136,6 +141,18 @@ export declare class ConnectorResourceOutcomeUnknownError extends QURLError {
|
|
|
136
141
|
readonly cause: QURLError;
|
|
137
142
|
constructor(cause: QURLError);
|
|
138
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* A delegated batch create may have committed. Retry only with the same
|
|
146
|
+
* idempotency key and semantic body. The original typed failure is in `cause`.
|
|
147
|
+
* The wrapper uses `status: 0` so generic HTTP retry code cannot replay it.
|
|
148
|
+
*/
|
|
149
|
+
export declare class DelegatedBatchOutcomeUnknownError extends QURLError {
|
|
150
|
+
readonly code: typeof ERROR_CODE_DELEGATED_BATCH_OUTCOME_UNKNOWN;
|
|
151
|
+
readonly cause: QURLError;
|
|
152
|
+
/** Valid accepted batch identity, when the response body provided one. */
|
|
153
|
+
readonly batchId?: string;
|
|
154
|
+
constructor(cause: QURLError, batchId?: string);
|
|
155
|
+
}
|
|
139
156
|
/** Transport-level error — DNS failure, connection refused, etc. */
|
|
140
157
|
export declare class NetworkError extends QURLError {
|
|
141
158
|
constructor(message: string, options?: {
|
package/dist/cjs/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RuntimeError = exports.TimeoutError = exports.NetworkError = exports.ConnectorResourceOutcomeUnknownError = exports.ServerError = exports.RateLimitError = exports.ValidationError = exports.NotFoundError = exports.AuthorizationError = exports.AuthenticationError = exports.QURLError = exports.ERROR_CODE_UNKNOWN = exports.ERROR_CODE_AMBIGUOUS_RESOURCE = exports.ERROR_CODE_RESOURCE_NOT_FOUND = exports.ERROR_CODE_CONNECTOR_RESOURCE_REVOKED = exports.ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN = exports.ERROR_CODE_CRID_MISMATCH = exports.ERROR_CODE_INVALID_CRID_KEY = exports.ERROR_CODE_INVALID_CRID = exports.ERROR_CODE_MISSING_CRID = exports.ERROR_CODE_RUNTIME = exports.ERROR_CODE_TIMEOUT = exports.ERROR_CODE_NETWORK = exports.ERROR_CODE_UNEXPECTED_RESPONSE = exports.ERROR_CODE_CLIENT_VALIDATION = void 0;
|
|
3
|
+
exports.RuntimeError = exports.TimeoutError = exports.NetworkError = exports.DelegatedBatchOutcomeUnknownError = exports.ConnectorResourceOutcomeUnknownError = exports.ServerError = exports.RateLimitError = exports.ValidationError = exports.NotFoundError = exports.AuthorizationError = exports.AuthenticationError = exports.QURLError = exports.ERROR_CODE_UNKNOWN = exports.ERROR_CODE_AMBIGUOUS_RESOURCE = exports.ERROR_CODE_RESOURCE_NOT_FOUND = exports.ERROR_CODE_CONNECTOR_RESOURCE_REVOKED = exports.ERROR_CODE_DELEGATED_BATCH_OUTCOME_UNKNOWN = exports.ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN = exports.ERROR_CODE_CRID_MISMATCH = exports.ERROR_CODE_INVALID_CRID_KEY = exports.ERROR_CODE_INVALID_CRID = exports.ERROR_CODE_MISSING_CRID = exports.ERROR_CODE_RUNTIME = exports.ERROR_CODE_TIMEOUT = exports.ERROR_CODE_NETWORK = exports.ERROR_CODE_UNEXPECTED_RESPONSE = exports.ERROR_CODE_CLIENT_VALIDATION = void 0;
|
|
4
4
|
exports.createError = createError;
|
|
5
5
|
/**
|
|
6
6
|
* Sentinel `.code` values for SDK-internal failure modes (no real HTTP
|
|
@@ -27,6 +27,8 @@ exports.ERROR_CODE_INVALID_CRID_KEY = "invalid_crid_key";
|
|
|
27
27
|
exports.ERROR_CODE_CRID_MISMATCH = "crid_mismatch";
|
|
28
28
|
/** A dispatched Connector resource mutation could have committed and must be reconciled. */
|
|
29
29
|
exports.ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN = "connector_resource_outcome_unknown";
|
|
30
|
+
/** A delegated batch create was dispatched but no valid acceptance was received. */
|
|
31
|
+
exports.ERROR_CODE_DELEGATED_BATCH_OUTCOME_UNKNOWN = "delegated_batch_outcome_unknown";
|
|
30
32
|
/** A by-ID Connector resource lookup found a revoked lifecycle row. */
|
|
31
33
|
exports.ERROR_CODE_CONNECTOR_RESOURCE_REVOKED = "connector_resource_revoked";
|
|
32
34
|
/** A Connector slug lookup found no active resource (client-detected, `status: 0`). */
|
|
@@ -68,6 +70,8 @@ class QURLError extends Error {
|
|
|
68
70
|
invalidFields;
|
|
69
71
|
requestId;
|
|
70
72
|
retryAfter;
|
|
73
|
+
/** Known minted IDs from a rejected terminal batch, for bounded cleanup. No bearer links. */
|
|
74
|
+
partialQurlIds;
|
|
71
75
|
constructor(data) {
|
|
72
76
|
// RFC 7807 leaves `detail` optional; the API can legitimately omit it and
|
|
73
77
|
// `title` is required, so falling back to title keeps the Error.message
|
|
@@ -123,9 +127,10 @@ exports.NotFoundError = NotFoundError;
|
|
|
123
127
|
*
|
|
124
128
|
* `instanceof ValidationError` catches both on ordinary client/response
|
|
125
129
|
* paths. A Connector mutation wraps a post-dispatch `unexpected_response`
|
|
126
|
-
* in {@link ConnectorResourceOutcomeUnknownError}
|
|
127
|
-
*
|
|
128
|
-
*
|
|
130
|
+
* in {@link ConnectorResourceOutcomeUnknownError} or
|
|
131
|
+
* {@link DelegatedBatchOutcomeUnknownError}; inspect the wrapper's typed
|
|
132
|
+
* `cause` before deciding whether to retry. To distinguish them, check `.code`
|
|
133
|
+
* rather than using `instanceof` alone.
|
|
129
134
|
*
|
|
130
135
|
* **`.status` asymmetry within `code: "unexpected_response"`:**
|
|
131
136
|
* - Shape-guard failure on a parsed JSON body (wrong field types,
|
|
@@ -199,6 +204,28 @@ class ConnectorResourceOutcomeUnknownError extends QURLError {
|
|
|
199
204
|
}
|
|
200
205
|
}
|
|
201
206
|
exports.ConnectorResourceOutcomeUnknownError = ConnectorResourceOutcomeUnknownError;
|
|
207
|
+
/**
|
|
208
|
+
* A delegated batch create may have committed. Retry only with the same
|
|
209
|
+
* idempotency key and semantic body. The original typed failure is in `cause`.
|
|
210
|
+
* The wrapper uses `status: 0` so generic HTTP retry code cannot replay it.
|
|
211
|
+
*/
|
|
212
|
+
class DelegatedBatchOutcomeUnknownError extends QURLError {
|
|
213
|
+
/** Valid accepted batch identity, when the response body provided one. */
|
|
214
|
+
batchId;
|
|
215
|
+
constructor(cause, batchId) {
|
|
216
|
+
super({
|
|
217
|
+
status: 0,
|
|
218
|
+
code: exports.ERROR_CODE_DELEGATED_BATCH_OUTCOME_UNKNOWN,
|
|
219
|
+
title: "Delegated Batch Outcome Unknown",
|
|
220
|
+
detail: `Mutation outcome is unknown; retry only with the same idempotency key and body. ${cause.detail}`,
|
|
221
|
+
request_id: cause.requestId,
|
|
222
|
+
});
|
|
223
|
+
this.name = "DelegatedBatchOutcomeUnknownError";
|
|
224
|
+
this.batchId = batchId;
|
|
225
|
+
attachErrorCause(this, { cause });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
exports.DelegatedBatchOutcomeUnknownError = DelegatedBatchOutcomeUnknownError;
|
|
202
229
|
/** Transport-level error — DNS failure, connection refused, etc. */
|
|
203
230
|
class NetworkError extends QURLError {
|
|
204
231
|
constructor(message, options) {
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { ConnectorResource, isApiKeyRequestScope, ProtectedResource, QURLClient,
|
|
|
2
2
|
export type { EnsureConnectorResourceResult } from "./client.js";
|
|
3
3
|
export { CRIDVerificationError, ShareLink } from "./share.js";
|
|
4
4
|
export type { CRIDVerificationErrorCode, ShareLinkInit, ShareLinkJSON } from "./share.js";
|
|
5
|
-
export { AuthenticationError, AuthorizationError, ConnectorResourceOutcomeUnknownError, createError, ERROR_CODE_AMBIGUOUS_RESOURCE, ERROR_CODE_CLIENT_VALIDATION, ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN, ERROR_CODE_CONNECTOR_RESOURCE_REVOKED, ERROR_CODE_CRID_MISMATCH, ERROR_CODE_INVALID_CRID, ERROR_CODE_INVALID_CRID_KEY, ERROR_CODE_MISSING_CRID, ERROR_CODE_NETWORK, ERROR_CODE_RESOURCE_NOT_FOUND, ERROR_CODE_RUNTIME, ERROR_CODE_TIMEOUT, ERROR_CODE_UNEXPECTED_RESPONSE, ERROR_CODE_UNKNOWN, NetworkError, NotFoundError, QURLError, RateLimitError, RuntimeError, ServerError, TimeoutError, ValidationError, } from "./errors.js";
|
|
5
|
+
export { AuthenticationError, AuthorizationError, ConnectorResourceOutcomeUnknownError, createError, DelegatedBatchOutcomeUnknownError, ERROR_CODE_AMBIGUOUS_RESOURCE, ERROR_CODE_CLIENT_VALIDATION, ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN, ERROR_CODE_CONNECTOR_RESOURCE_REVOKED, ERROR_CODE_CRID_MISMATCH, ERROR_CODE_DELEGATED_BATCH_OUTCOME_UNKNOWN, ERROR_CODE_INVALID_CRID, ERROR_CODE_INVALID_CRID_KEY, ERROR_CODE_MISSING_CRID, ERROR_CODE_NETWORK, ERROR_CODE_RESOURCE_NOT_FOUND, ERROR_CODE_RUNTIME, ERROR_CODE_TIMEOUT, ERROR_CODE_UNEXPECTED_RESPONSE, ERROR_CODE_UNKNOWN, NetworkError, NotFoundError, QURLError, RateLimitError, RuntimeError, ServerError, TimeoutError, ValidationError, } from "./errors.js";
|
|
6
6
|
export { VERSION } from "./version.js";
|
|
7
|
-
export type { AccessCode, AccessCodeListOutput, AccessGrant, AccessPolicy, AccessToken, AIAgentCategory, AIAgentPolicy, ApiKey, ApiKeyListOutput, ApiKeyRequestScope, ApiKeyScope, BatchCreateInput, BatchCreateOutput, BatchItemFailure, BatchItemResult, BatchItemSuccess, BillingInvoiceListOutput, ClientOptions, ConnectorInstallation, ConnectorInstallationCapabilities, ConnectorInstallationListOutput, ConnectorInstallationStats, CreateAccessCodeInput, CreateAccessCodeOutput, CreateApiKeyInput, CreateApiKeyOutput, CreateDurableApiKeyInput, CreateEnrollmentTokenInput, CreateBillingCheckoutInput, CreateInput, CreateOutput, CreatePortalOptions, CreateQurlForResourceInput, CreateResourceInput, CreateWebhookInput, CredentialClaim, CredentialClaimInput, CredentialKind, CredentialTarget, CredentialTargetInput, Customer, CheckoutSession, DnsRecord, Domain, DomainCheckDetail, DomainListOutput, DomainVerifyResult, ExtendInput, Invoice, ListApiKeysInput, ListBillingInvoicesInput, ListConnectorInstallationsInput, ListDomainsInput, ListInput, ListOutput, ListWebhooksInput, ListWebhookDeliveriesInput, Meta, MintInput, MintOutput, PaginatedOutput, Portal, PortalSession, ProtectUrlOptions, QURL, QURLErrorData, QurlSummary, Quota, RedeemAccessCodeInput, RedeemAccessCodeOutput, RegisterDomainInput, Resource, ResourceDetail, ResourceHandle, ResourceListInput, ResourceListOutput, ResourceType, RequestOptions, ResolveInput, ResolveOutput, Session, SessionListOutput, SessionTerminateOutput, ShareResourceOptions, TombstoneInfo, UnpaginatedOutput, UpdateApiKeyInput, UpdateCustomerInput, UpdateInput, UpdateResourceInput, UpdateResourceQurlInput, UpdateWebhookInput, UsageCostEstimate, UsageCurrentPeriod, UsageDaily, UsageDailyEntry, Webhook, WebhookDelivery, WebhookDeliveryListOutput, WebhookEventType, WebhookEventTypeInfo, WebhookListOutput, WebhookPayload, WebhookWithSecret, } from "./types.js";
|
|
7
|
+
export type { ConsumerAccessPolicy, AccessCode, AccessCodeListOutput, AccessGrant, ConsumerInvitation, ConsumerGrant, ConsumerGrantApprovalInput, ConsumerListInput, ConsumerInvitationListOutput, ConsumerGrantListOutput, AccessPolicy, AccessToken, AIAgentCategory, AIAgentPolicy, ApiKey, ApiKeyListOutput, ApiKeyRequestScope, ApiKeyScope, BatchCreateInput, BatchCreateOutput, BatchItemFailure, BatchItemResult, BatchItemSuccess, BillingInvoiceListOutput, ClientOptions, ConnectorInstallation, ConnectorInstallationCapabilities, ConnectorInstallationListOutput, ConnectorInstallationStats, CreateAccessCodeInput, CreateAccessCodeOutput, CreateApiKeyInput, CreateApiKeyOutput, CreateDurableApiKeyInput, CreateEnrollmentTokenInput, CreateBillingCheckoutInput, CreateDelegatedQurlBatchInput, CreateDelegatedQurlBatchOptions, CreateInput, CreateOutput, CreatePortalOptions, CreateQurlForResourceInput, CreateResourceInput, CreateWebhookInput, CredentialClaim, CredentialClaimInput, CredentialKind, CredentialTarget, CredentialTargetInput, Customer, CheckoutSession, DnsRecord, Domain, DomainCheckDetail, DomainListOutput, DomainVerifyResult, DelegatedQurl, DelegatedQurlBatchAccepted, DelegatedQurlBatchItemFailure, DelegatedQurlBatchItemResult, DelegatedQurlBatchItemSuccess, DelegatedQurlBatchNotModified, DelegatedQurlBatchPending, DelegatedQurlBatchStatus, DelegatedQurlBatchTerminal, DelegatedQurlCreatedData, DelegatedQurlGrant, ExtendInput, Invoice, GetDelegatedQurlBatchOptions, GetDelegatedQurlBatchOutput, ListApiKeysInput, ListBillingInvoicesInput, ListConnectorInstallationsInput, ListDomainsInput, ListInput, ListOutput, ListWebhooksInput, ListWebhookDeliveriesInput, Meta, MintInput, MintOutput, PaginatedOutput, Portal, PortalSession, ProtectUrlOptions, QURL, QURLErrorData, QurlSummary, Quota, RedeemAccessCodeInput, RedeemAccessCodeOutput, RegisterDomainInput, Resource, ResourceDetail, ResourceHandle, ResourceListInput, ResourceListOutput, ResourceType, RequestOptions, ResolveInput, ResolveOutput, Session, SessionListOutput, SessionTerminateOutput, ShareResourceOptions, TombstoneInfo, UnpaginatedOutput, UpdateApiKeyInput, UpdateCustomerInput, UpdateInput, UpdateResourceInput, UpdateResourceQurlInput, UpdateWebhookInput, UsageCostEstimate, UsageCurrentPeriod, UsageDaily, UsageDailyEntry, Webhook, WebhookDelivery, WebhookDeliveryListOutput, WebhookEventType, WebhookEventTypeInfo, WebhookListOutput, WebhookPayload, WebhookWithSecret, } from "./types.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VERSION = exports.ValidationError = exports.TimeoutError = exports.ServerError = exports.RuntimeError = exports.RateLimitError = exports.QURLError = exports.NotFoundError = exports.NetworkError = exports.ERROR_CODE_UNKNOWN = exports.ERROR_CODE_UNEXPECTED_RESPONSE = exports.ERROR_CODE_TIMEOUT = exports.ERROR_CODE_RUNTIME = exports.ERROR_CODE_RESOURCE_NOT_FOUND = exports.ERROR_CODE_NETWORK = exports.ERROR_CODE_MISSING_CRID = exports.ERROR_CODE_INVALID_CRID_KEY = exports.ERROR_CODE_INVALID_CRID = exports.ERROR_CODE_CRID_MISMATCH = exports.ERROR_CODE_CONNECTOR_RESOURCE_REVOKED = exports.ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN = exports.ERROR_CODE_CLIENT_VALIDATION = exports.ERROR_CODE_AMBIGUOUS_RESOURCE = exports.createError = exports.ConnectorResourceOutcomeUnknownError = exports.AuthorizationError = exports.AuthenticationError = exports.ShareLink = exports.CRIDVerificationError = exports.QURLClient = exports.ProtectedResource = exports.isApiKeyRequestScope = exports.ConnectorResource = void 0;
|
|
3
|
+
exports.VERSION = exports.ValidationError = exports.TimeoutError = exports.ServerError = exports.RuntimeError = exports.RateLimitError = exports.QURLError = exports.NotFoundError = exports.NetworkError = exports.ERROR_CODE_UNKNOWN = exports.ERROR_CODE_UNEXPECTED_RESPONSE = exports.ERROR_CODE_TIMEOUT = exports.ERROR_CODE_RUNTIME = exports.ERROR_CODE_RESOURCE_NOT_FOUND = exports.ERROR_CODE_NETWORK = exports.ERROR_CODE_MISSING_CRID = exports.ERROR_CODE_INVALID_CRID_KEY = exports.ERROR_CODE_INVALID_CRID = exports.ERROR_CODE_DELEGATED_BATCH_OUTCOME_UNKNOWN = exports.ERROR_CODE_CRID_MISMATCH = exports.ERROR_CODE_CONNECTOR_RESOURCE_REVOKED = exports.ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN = exports.ERROR_CODE_CLIENT_VALIDATION = exports.ERROR_CODE_AMBIGUOUS_RESOURCE = exports.DelegatedBatchOutcomeUnknownError = exports.createError = exports.ConnectorResourceOutcomeUnknownError = exports.AuthorizationError = exports.AuthenticationError = exports.ShareLink = exports.CRIDVerificationError = exports.QURLClient = exports.ProtectedResource = exports.isApiKeyRequestScope = exports.ConnectorResource = void 0;
|
|
4
4
|
var client_js_1 = require("./client.js");
|
|
5
5
|
Object.defineProperty(exports, "ConnectorResource", { enumerable: true, get: function () { return client_js_1.ConnectorResource; } });
|
|
6
6
|
Object.defineProperty(exports, "isApiKeyRequestScope", { enumerable: true, get: function () { return client_js_1.isApiKeyRequestScope; } });
|
|
@@ -14,11 +14,13 @@ Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: f
|
|
|
14
14
|
Object.defineProperty(exports, "AuthorizationError", { enumerable: true, get: function () { return errors_js_1.AuthorizationError; } });
|
|
15
15
|
Object.defineProperty(exports, "ConnectorResourceOutcomeUnknownError", { enumerable: true, get: function () { return errors_js_1.ConnectorResourceOutcomeUnknownError; } });
|
|
16
16
|
Object.defineProperty(exports, "createError", { enumerable: true, get: function () { return errors_js_1.createError; } });
|
|
17
|
+
Object.defineProperty(exports, "DelegatedBatchOutcomeUnknownError", { enumerable: true, get: function () { return errors_js_1.DelegatedBatchOutcomeUnknownError; } });
|
|
17
18
|
Object.defineProperty(exports, "ERROR_CODE_AMBIGUOUS_RESOURCE", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_AMBIGUOUS_RESOURCE; } });
|
|
18
19
|
Object.defineProperty(exports, "ERROR_CODE_CLIENT_VALIDATION", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_CLIENT_VALIDATION; } });
|
|
19
20
|
Object.defineProperty(exports, "ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN; } });
|
|
20
21
|
Object.defineProperty(exports, "ERROR_CODE_CONNECTOR_RESOURCE_REVOKED", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_CONNECTOR_RESOURCE_REVOKED; } });
|
|
21
22
|
Object.defineProperty(exports, "ERROR_CODE_CRID_MISMATCH", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_CRID_MISMATCH; } });
|
|
23
|
+
Object.defineProperty(exports, "ERROR_CODE_DELEGATED_BATCH_OUTCOME_UNKNOWN", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_DELEGATED_BATCH_OUTCOME_UNKNOWN; } });
|
|
22
24
|
Object.defineProperty(exports, "ERROR_CODE_INVALID_CRID", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_INVALID_CRID; } });
|
|
23
25
|
Object.defineProperty(exports, "ERROR_CODE_INVALID_CRID_KEY", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_INVALID_CRID_KEY; } });
|
|
24
26
|
Object.defineProperty(exports, "ERROR_CODE_MISSING_CRID", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_MISSING_CRID; } });
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { QURLClient } from "../client.js";
|
|
2
|
+
import { type StrictJsonValue } from "./strict-json.js";
|
|
3
|
+
import { type AgentAssignment, type AgentState, type AgentStateStore, type NHPUDPEndpoint } from "./agent-state.js";
|
|
4
|
+
import { type AgentTransport } from "./agent-transport.js";
|
|
5
|
+
export interface AgentOTPChallenge {
|
|
6
|
+
agentID: string;
|
|
7
|
+
cellID: string;
|
|
8
|
+
assignmentTicketExpiresAt: string;
|
|
9
|
+
pendingActivationRecovery: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface AgentRuntimeOptions {
|
|
12
|
+
hub?: NHPUDPEndpoint;
|
|
13
|
+
agentID?: string;
|
|
14
|
+
enrollmentCredential?: string;
|
|
15
|
+
enrollmentCredentialProvider?: (request: {
|
|
16
|
+
agentID: string;
|
|
17
|
+
pendingActivationRecovery: boolean;
|
|
18
|
+
}, signal: AbortSignal) => Promise<string>;
|
|
19
|
+
otpProvider?: (challenge: AgentOTPChallenge, signal: AbortSignal) => Promise<string>;
|
|
20
|
+
headless?: boolean;
|
|
21
|
+
offline?: boolean;
|
|
22
|
+
hostname?: string;
|
|
23
|
+
version?: string;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
fetch?: typeof globalThis.fetch;
|
|
27
|
+
}
|
|
28
|
+
export declare class AgentLifecycleError extends Error {
|
|
29
|
+
readonly code: string;
|
|
30
|
+
readonly retryAfterMs?: number | undefined;
|
|
31
|
+
constructor(code: string, retryAfterMs?: number | undefined, options?: ErrorOptions);
|
|
32
|
+
}
|
|
33
|
+
declare function fingerprint(kind: "activation-enrollment" | "credential-recovery", credential: string): string;
|
|
34
|
+
/** One driver per producer operation. Persistence failures never enter the network retry loop. */
|
|
35
|
+
declare class Lifecycle {
|
|
36
|
+
readonly store: AgentStateStore;
|
|
37
|
+
readonly options: AgentRuntimeOptions;
|
|
38
|
+
readonly transport: AgentTransport;
|
|
39
|
+
readonly replacement?: {
|
|
40
|
+
anchor: string;
|
|
41
|
+
deadline: string;
|
|
42
|
+
} | undefined;
|
|
43
|
+
constructor(store: AgentStateStore, options: AgentRuntimeOptions, transport: AgentTransport, replacement?: {
|
|
44
|
+
anchor: string;
|
|
45
|
+
deadline: string;
|
|
46
|
+
} | undefined);
|
|
47
|
+
hub(): NHPUDPEndpoint;
|
|
48
|
+
exchange(state: AgentState, endpoint: NHPUDPEndpoint, type: 1 | 5 | 12 | 13 | 16, value: unknown, phase: "assignment" | "assignment-refresh" | "registration" | "completion" | "recovery-issue" | "recovery-completion" | "session", expires?: string, reknock?: unknown, detachedSignal?: AbortSignal): Promise<Record<string, StrictJsonValue>>;
|
|
49
|
+
assignment(state: AgentState, mode: "enroll" | "refresh", enrollment?: string): Promise<{
|
|
50
|
+
list: Record<string, StrictJsonValue>;
|
|
51
|
+
assignment: AgentAssignment;
|
|
52
|
+
}>;
|
|
53
|
+
refresh(state: AgentState, allowRecovered?: boolean): Promise<AgentState>;
|
|
54
|
+
complete(state: AgentState): Promise<AgentState>;
|
|
55
|
+
enroll(state: AgentState): Promise<AgentState>;
|
|
56
|
+
}
|
|
57
|
+
export interface NativeAgentKnockOptions {
|
|
58
|
+
runID: string;
|
|
59
|
+
runAttempt: bigint;
|
|
60
|
+
protectedResourceID: string;
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
}
|
|
63
|
+
export interface NativeSessionReceipt {
|
|
64
|
+
readonly cellID: string;
|
|
65
|
+
readonly sessionID: bigint;
|
|
66
|
+
readonly sessionIssuedAtMillis: bigint;
|
|
67
|
+
readonly runID: string;
|
|
68
|
+
readonly runAttempt: bigint;
|
|
69
|
+
}
|
|
70
|
+
export interface NativeAgentGrant {
|
|
71
|
+
token: string;
|
|
72
|
+
resourceHost: string;
|
|
73
|
+
openTime: number;
|
|
74
|
+
agentAddress: string;
|
|
75
|
+
receipt: NativeSessionReceipt;
|
|
76
|
+
}
|
|
77
|
+
export declare class AgentRuntime {
|
|
78
|
+
#private;
|
|
79
|
+
readonly store: AgentStateStore;
|
|
80
|
+
readonly transport: AgentTransport;
|
|
81
|
+
readonly client: QURLClient;
|
|
82
|
+
constructor(state: AgentState, store: AgentStateStore, options: AgentRuntimeOptions, transport: AgentTransport);
|
|
83
|
+
get agentID(): string;
|
|
84
|
+
assignment(): AgentAssignment;
|
|
85
|
+
refresh(signal?: AbortSignal): Promise<void>;
|
|
86
|
+
knock(knockResourceID: string, options: NativeAgentKnockOptions): Promise<NativeAgentGrant>;
|
|
87
|
+
retire(receipt: NativeSessionReceipt, signal?: AbortSignal): Promise<{
|
|
88
|
+
closeEventID: string;
|
|
89
|
+
state: "closing" | "closed";
|
|
90
|
+
}>;
|
|
91
|
+
close(): Promise<void>;
|
|
92
|
+
toJSON(): {
|
|
93
|
+
agentID: string | undefined;
|
|
94
|
+
closed: boolean;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export declare function connectAgentRuntime(store: AgentStateStore, options?: AgentRuntimeOptions): Promise<AgentRuntime>;
|
|
98
|
+
export type AgentRecoveryOptions = Pick<AgentRuntimeOptions, "hub" | "agentID" | "signal" | "baseUrl" | "fetch">;
|
|
99
|
+
export declare function recoverAgentRuntime(store: AgentStateStore, recoveryCredential: string | ((signal: AbortSignal) => Promise<string>), options?: AgentRecoveryOptions): Promise<AgentRuntime>;
|
|
100
|
+
declare function recoverWithTransport(store: AgentStateStore, provider: string | ((signal: AbortSignal) => Promise<string>), options: AgentRecoveryOptions, transport: AgentTransport): Promise<AgentRuntime>;
|
|
101
|
+
declare function connectWithTransport(store: AgentStateStore, options: AgentRuntimeOptions, transport: AgentTransport): Promise<AgentRuntime>;
|
|
102
|
+
export declare const agentRuntimeTesting: {
|
|
103
|
+
connectWithTransport: typeof connectWithTransport;
|
|
104
|
+
recoverWithTransport: typeof recoverWithTransport;
|
|
105
|
+
Lifecycle: typeof Lifecycle;
|
|
106
|
+
fingerprint: typeof fingerprint;
|
|
107
|
+
};
|
|
108
|
+
export {};
|