@layervai/qurl 0.6.0 → 2.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 +332 -15
- package/dist/cjs/client.d.ts +62 -31
- package/dist/cjs/client.js +932 -163
- package/dist/cjs/crid.d.ts +3 -0
- package/dist/cjs/crid.js +62 -0
- package/dist/cjs/errors.d.ts +30 -5
- package/dist/cjs/errors.js +41 -6
- package/dist/cjs/index.d.ts +5 -3
- package/dist/cjs/index.js +11 -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/share.d.ts +56 -0
- package/dist/cjs/share.js +113 -0
- package/dist/cjs/types.d.ts +173 -13
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client.d.ts +62 -31
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +932 -164
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/crid.d.ts +4 -0
- package/dist/esm/crid.d.ts.map +1 -0
- package/dist/esm/crid.js +58 -0
- package/dist/esm/crid.js.map +1 -0
- package/dist/esm/errors.d.ts +30 -5
- package/dist/esm/errors.d.ts.map +1 -1
- package/dist/esm/errors.js +39 -5
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.d.ts +5 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -2
- 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/share.d.ts +57 -0
- package/dist/esm/share.d.ts.map +1 -0
- package/dist/esm/share.js +109 -0
- package/dist/esm/share.js.map +1 -0
- package/dist/esm/types.d.ts +173 -13
- 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 +17 -8
package/dist/cjs/crid.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CRID_DOMAIN = void 0;
|
|
4
|
+
exports.parseCrid = parseCrid;
|
|
5
|
+
exports.cridKeyMatches = cridKeyMatches;
|
|
6
|
+
// CRID v1 local gate and delivered-key binding, matching qurl-go/crid.
|
|
7
|
+
// The byte selects a version/environment/digest width, not a new hash scheme.
|
|
8
|
+
// All key matches use the v1 domain separator, as in qurl-go/crid.KeyMatches.
|
|
9
|
+
// Unknown nonzero versions remain forwardable; the service owns activation.
|
|
10
|
+
// Access binding requires a locally known version and its registered width.
|
|
11
|
+
const ALPHABET = "abcdefghijklmnopqrstuvwxyz234567";
|
|
12
|
+
exports.CRID_DOMAIN = "NHP-QURL-CRID-V1\0";
|
|
13
|
+
function parseCrid(value, knownVersionOnly = false) {
|
|
14
|
+
if (typeof value !== "string" || ![47, 60].includes(value.length))
|
|
15
|
+
return undefined;
|
|
16
|
+
const bytes = new Uint8Array(Math.floor((value.length * 5) / 8));
|
|
17
|
+
let buffer = 0, bits = 0, offset = 0;
|
|
18
|
+
for (const character of value) {
|
|
19
|
+
const digit = ALPHABET.indexOf(character);
|
|
20
|
+
if (digit < 0)
|
|
21
|
+
return undefined;
|
|
22
|
+
buffer = (buffer << 5) | digit;
|
|
23
|
+
bits += 5;
|
|
24
|
+
if (bits >= 8) {
|
|
25
|
+
bits -= 8;
|
|
26
|
+
bytes[offset++] = buffer >>> bits;
|
|
27
|
+
buffer &= (1 << bits) - 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (buffer !== 0 || bytes[0] === 0)
|
|
31
|
+
return undefined;
|
|
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
|
+
}
|
|
39
|
+
let crc = 0xffffffff;
|
|
40
|
+
for (const byte of payload) {
|
|
41
|
+
crc ^= byte;
|
|
42
|
+
for (let bit = 0; bit < 8; bit++)
|
|
43
|
+
crc = (crc >>> 1) ^ (crc & 1 ? 0x82f63b78 : 0);
|
|
44
|
+
}
|
|
45
|
+
if (~crc >>> 0 !== new DataView(bytes.buffer).getUint32(bytes.length - 4))
|
|
46
|
+
return undefined;
|
|
47
|
+
return payload.subarray(1);
|
|
48
|
+
}
|
|
49
|
+
async function cridKeyMatches(value, der) {
|
|
50
|
+
const expected = parseCrid(value);
|
|
51
|
+
if (!expected)
|
|
52
|
+
return false;
|
|
53
|
+
const prefix = new TextEncoder().encode(exports.CRID_DOMAIN);
|
|
54
|
+
const message = new Uint8Array(prefix.length + der.length);
|
|
55
|
+
message.set(prefix);
|
|
56
|
+
message.set(der, prefix.length);
|
|
57
|
+
const digest = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", message));
|
|
58
|
+
let difference = 0;
|
|
59
|
+
for (let i = 0; i < expected.length; i++)
|
|
60
|
+
difference |= expected[i] ^ digest[i];
|
|
61
|
+
return difference === 0;
|
|
62
|
+
}
|
package/dist/cjs/errors.d.ts
CHANGED
|
@@ -14,8 +14,18 @@ export declare const ERROR_CODE_UNEXPECTED_RESPONSE = "unexpected_response";
|
|
|
14
14
|
export declare const ERROR_CODE_NETWORK = "network_error";
|
|
15
15
|
export declare const ERROR_CODE_TIMEOUT = "timeout";
|
|
16
16
|
export declare const ERROR_CODE_RUNTIME = "runtime_error";
|
|
17
|
+
/** A share response omitted the CRID required for delivered-key verification. */
|
|
18
|
+
export declare const ERROR_CODE_MISSING_CRID = "missing_crid";
|
|
19
|
+
/** A held CRID failed the local CRID v1 validation gate. */
|
|
20
|
+
export declare const ERROR_CODE_INVALID_CRID = "invalid_crid";
|
|
21
|
+
/** A caller supplied a non-binary runtime value where DER SPKI bytes are required. */
|
|
22
|
+
export declare const ERROR_CODE_INVALID_CRID_KEY = "invalid_crid_key";
|
|
23
|
+
/** A delivered key does not derive the held CRID. */
|
|
24
|
+
export declare const ERROR_CODE_CRID_MISMATCH = "crid_mismatch";
|
|
17
25
|
/** A dispatched Connector resource mutation could have committed and must be reconciled. */
|
|
18
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";
|
|
19
29
|
/** A by-ID Connector resource lookup found a revoked lifecycle row. */
|
|
20
30
|
export declare const ERROR_CODE_CONNECTOR_RESOURCE_REVOKED = "connector_resource_revoked";
|
|
21
31
|
/** A Connector slug lookup found no active resource (client-detected, `status: 0`). */
|
|
@@ -28,8 +38,8 @@ export declare const ERROR_CODE_UNKNOWN = "unknown";
|
|
|
28
38
|
* Base error thrown by the qURL API client. Catch this to handle all SDK errors.
|
|
29
39
|
*
|
|
30
40
|
* **`status: 0` convention:** Client-only validation, runtime, network, and
|
|
31
|
-
* timeout failures use `status: 0`
|
|
32
|
-
* response-shape guards can also use zero. An `unexpected_response` tied to a
|
|
41
|
+
* timeout failures and local CRID verification failures use `status: 0`
|
|
42
|
+
* because no HTTP status applies. Logical response-shape guards can also use zero. An `unexpected_response` tied to a
|
|
33
43
|
* concrete HTTP contract violation (redirect, oversized body, wrong
|
|
34
44
|
* no-content status/body) instead preserves the observed status. Branch on
|
|
35
45
|
* `.code` first and then `.status`; see {@link ValidationError}.
|
|
@@ -57,6 +67,8 @@ export declare class QURLError extends Error {
|
|
|
57
67
|
readonly invalidFields?: Record<string, string>;
|
|
58
68
|
readonly requestId?: string;
|
|
59
69
|
readonly retryAfter?: number;
|
|
70
|
+
/** Known minted IDs from a rejected terminal batch, for bounded cleanup. No bearer links. */
|
|
71
|
+
readonly partialQurlIds?: readonly string[];
|
|
60
72
|
constructor(data: QURLErrorData);
|
|
61
73
|
}
|
|
62
74
|
/** 401 Unauthorized — invalid or missing API key. */
|
|
@@ -84,9 +96,10 @@ export declare class NotFoundError extends QURLError {
|
|
|
84
96
|
*
|
|
85
97
|
* `instanceof ValidationError` catches both on ordinary client/response
|
|
86
98
|
* paths. A Connector mutation wraps a post-dispatch `unexpected_response`
|
|
87
|
-
* in {@link ConnectorResourceOutcomeUnknownError}
|
|
88
|
-
*
|
|
89
|
-
*
|
|
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.
|
|
90
103
|
*
|
|
91
104
|
* **`.status` asymmetry within `code: "unexpected_response"`:**
|
|
92
105
|
* - Shape-guard failure on a parsed JSON body (wrong field types,
|
|
@@ -128,6 +141,18 @@ export declare class ConnectorResourceOutcomeUnknownError extends QURLError {
|
|
|
128
141
|
readonly cause: QURLError;
|
|
129
142
|
constructor(cause: QURLError);
|
|
130
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
|
+
}
|
|
131
156
|
/** Transport-level error — DNS failure, connection refused, etc. */
|
|
132
157
|
export declare class NetworkError extends QURLError {
|
|
133
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_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
|
|
@@ -17,8 +17,18 @@ exports.ERROR_CODE_UNEXPECTED_RESPONSE = "unexpected_response";
|
|
|
17
17
|
exports.ERROR_CODE_NETWORK = "network_error";
|
|
18
18
|
exports.ERROR_CODE_TIMEOUT = "timeout";
|
|
19
19
|
exports.ERROR_CODE_RUNTIME = "runtime_error";
|
|
20
|
+
/** A share response omitted the CRID required for delivered-key verification. */
|
|
21
|
+
exports.ERROR_CODE_MISSING_CRID = "missing_crid";
|
|
22
|
+
/** A held CRID failed the local CRID v1 validation gate. */
|
|
23
|
+
exports.ERROR_CODE_INVALID_CRID = "invalid_crid";
|
|
24
|
+
/** A caller supplied a non-binary runtime value where DER SPKI bytes are required. */
|
|
25
|
+
exports.ERROR_CODE_INVALID_CRID_KEY = "invalid_crid_key";
|
|
26
|
+
/** A delivered key does not derive the held CRID. */
|
|
27
|
+
exports.ERROR_CODE_CRID_MISMATCH = "crid_mismatch";
|
|
20
28
|
/** A dispatched Connector resource mutation could have committed and must be reconciled. */
|
|
21
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";
|
|
22
32
|
/** A by-ID Connector resource lookup found a revoked lifecycle row. */
|
|
23
33
|
exports.ERROR_CODE_CONNECTOR_RESOURCE_REVOKED = "connector_resource_revoked";
|
|
24
34
|
/** A Connector slug lookup found no active resource (client-detected, `status: 0`). */
|
|
@@ -31,8 +41,8 @@ exports.ERROR_CODE_UNKNOWN = "unknown";
|
|
|
31
41
|
* Base error thrown by the qURL API client. Catch this to handle all SDK errors.
|
|
32
42
|
*
|
|
33
43
|
* **`status: 0` convention:** Client-only validation, runtime, network, and
|
|
34
|
-
* timeout failures use `status: 0`
|
|
35
|
-
* response-shape guards can also use zero. An `unexpected_response` tied to a
|
|
44
|
+
* timeout failures and local CRID verification failures use `status: 0`
|
|
45
|
+
* because no HTTP status applies. Logical response-shape guards can also use zero. An `unexpected_response` tied to a
|
|
36
46
|
* concrete HTTP contract violation (redirect, oversized body, wrong
|
|
37
47
|
* no-content status/body) instead preserves the observed status. Branch on
|
|
38
48
|
* `.code` first and then `.status`; see {@link ValidationError}.
|
|
@@ -60,6 +70,8 @@ class QURLError extends Error {
|
|
|
60
70
|
invalidFields;
|
|
61
71
|
requestId;
|
|
62
72
|
retryAfter;
|
|
73
|
+
/** Known minted IDs from a rejected terminal batch, for bounded cleanup. No bearer links. */
|
|
74
|
+
partialQurlIds;
|
|
63
75
|
constructor(data) {
|
|
64
76
|
// RFC 7807 leaves `detail` optional; the API can legitimately omit it and
|
|
65
77
|
// `title` is required, so falling back to title keeps the Error.message
|
|
@@ -115,9 +127,10 @@ exports.NotFoundError = NotFoundError;
|
|
|
115
127
|
*
|
|
116
128
|
* `instanceof ValidationError` catches both on ordinary client/response
|
|
117
129
|
* paths. A Connector mutation wraps a post-dispatch `unexpected_response`
|
|
118
|
-
* in {@link ConnectorResourceOutcomeUnknownError}
|
|
119
|
-
*
|
|
120
|
-
*
|
|
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.
|
|
121
134
|
*
|
|
122
135
|
* **`.status` asymmetry within `code: "unexpected_response"`:**
|
|
123
136
|
* - Shape-guard failure on a parsed JSON body (wrong field types,
|
|
@@ -191,6 +204,28 @@ class ConnectorResourceOutcomeUnknownError extends QURLError {
|
|
|
191
204
|
}
|
|
192
205
|
}
|
|
193
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;
|
|
194
229
|
/** Transport-level error — DNS failure, connection refused, etc. */
|
|
195
230
|
class NetworkError extends QURLError {
|
|
196
231
|
constructor(message, options) {
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { ConnectorResource, ProtectedResource, QURLClient } from "./client.js";
|
|
1
|
+
export { ConnectorResource, isApiKeyRequestScope, ProtectedResource, QURLClient, } from "./client.js";
|
|
2
2
|
export type { EnsureConnectorResourceResult } from "./client.js";
|
|
3
|
-
export {
|
|
3
|
+
export { CRIDVerificationError, ShareLink } from "./share.js";
|
|
4
|
+
export type { CRIDVerificationErrorCode, ShareLinkInit, ShareLinkJSON } from "./share.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";
|
|
4
6
|
export { VERSION } from "./version.js";
|
|
5
|
-
export type { AccessCode, AccessCodeListOutput, AccessGrant, AccessPolicy, AccessToken, AIAgentCategory, AIAgentPolicy, ApiKey, ApiKeyListOutput, ApiKeyScope, BatchCreateInput, BatchCreateOutput, BatchItemFailure, BatchItemResult, BatchItemSuccess, BillingInvoiceListOutput, ClientOptions, ConnectorInstallation, ConnectorInstallationCapabilities, ConnectorInstallationListOutput, ConnectorInstallationStats, CreateAccessCodeInput, CreateAccessCodeOutput, CreateApiKeyInput, CreateApiKeyOutput, CreateBillingCheckoutInput, CreateInput, CreateOutput, CreatePortalOptions, CreateQurlForResourceInput, CreateResourceInput, CreateWebhookInput, 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, 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 { 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, 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,19 +1,29 @@
|
|
|
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_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.QURLClient = exports.ProtectedResource = 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
|
+
Object.defineProperty(exports, "isApiKeyRequestScope", { enumerable: true, get: function () { return client_js_1.isApiKeyRequestScope; } });
|
|
6
7
|
Object.defineProperty(exports, "ProtectedResource", { enumerable: true, get: function () { return client_js_1.ProtectedResource; } });
|
|
7
8
|
Object.defineProperty(exports, "QURLClient", { enumerable: true, get: function () { return client_js_1.QURLClient; } });
|
|
9
|
+
var share_js_1 = require("./share.js");
|
|
10
|
+
Object.defineProperty(exports, "CRIDVerificationError", { enumerable: true, get: function () { return share_js_1.CRIDVerificationError; } });
|
|
11
|
+
Object.defineProperty(exports, "ShareLink", { enumerable: true, get: function () { return share_js_1.ShareLink; } });
|
|
8
12
|
var errors_js_1 = require("./errors.js");
|
|
9
13
|
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_js_1.AuthenticationError; } });
|
|
10
14
|
Object.defineProperty(exports, "AuthorizationError", { enumerable: true, get: function () { return errors_js_1.AuthorizationError; } });
|
|
11
15
|
Object.defineProperty(exports, "ConnectorResourceOutcomeUnknownError", { enumerable: true, get: function () { return errors_js_1.ConnectorResourceOutcomeUnknownError; } });
|
|
12
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; } });
|
|
13
18
|
Object.defineProperty(exports, "ERROR_CODE_AMBIGUOUS_RESOURCE", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_AMBIGUOUS_RESOURCE; } });
|
|
14
19
|
Object.defineProperty(exports, "ERROR_CODE_CLIENT_VALIDATION", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_CLIENT_VALIDATION; } });
|
|
15
20
|
Object.defineProperty(exports, "ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_CONNECTOR_RESOURCE_OUTCOME_UNKNOWN; } });
|
|
16
21
|
Object.defineProperty(exports, "ERROR_CODE_CONNECTOR_RESOURCE_REVOKED", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_CONNECTOR_RESOURCE_REVOKED; } });
|
|
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; } });
|
|
24
|
+
Object.defineProperty(exports, "ERROR_CODE_INVALID_CRID", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_INVALID_CRID; } });
|
|
25
|
+
Object.defineProperty(exports, "ERROR_CODE_INVALID_CRID_KEY", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_INVALID_CRID_KEY; } });
|
|
26
|
+
Object.defineProperty(exports, "ERROR_CODE_MISSING_CRID", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_MISSING_CRID; } });
|
|
17
27
|
Object.defineProperty(exports, "ERROR_CODE_NETWORK", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_NETWORK; } });
|
|
18
28
|
Object.defineProperty(exports, "ERROR_CODE_RESOURCE_NOT_FOUND", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_RESOURCE_NOT_FOUND; } });
|
|
19
29
|
Object.defineProperty(exports, "ERROR_CODE_RUNTIME", { enumerable: true, get: function () { return errors_js_1.ERROR_CODE_RUNTIME; } });
|
|
@@ -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 {};
|