@cef-ai/vault-sdk 4.3.0 → 5.1.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 +35 -19
- package/dist/agreements/payload.d.ts +15 -1
- package/dist/agreements/payload.d.ts.map +1 -1
- package/dist/agreements/payload.js +13 -1
- package/dist/agreements/payload.js.map +1 -1
- package/dist/agreements/sign.d.ts +16 -3
- package/dist/agreements/sign.d.ts.map +1 -1
- package/dist/agreements/sign.js +16 -1
- package/dist/agreements/sign.js.map +1 -1
- package/dist/client.d.ts +54 -52
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +95 -98
- package/dist/client.js.map +1 -1
- package/dist/core/connect-scopes.d.ts +18 -0
- package/dist/core/connect-scopes.d.ts.map +1 -0
- package/dist/core/connect-scopes.js +72 -0
- package/dist/core/connect-scopes.js.map +1 -0
- package/dist/core/endpoints.d.ts +22 -1
- package/dist/core/endpoints.d.ts.map +1 -1
- package/dist/core/endpoints.js +24 -3
- package/dist/core/endpoints.js.map +1 -1
- package/dist/core/errors.d.ts +13 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +14 -2
- package/dist/core/errors.js.map +1 -1
- package/dist/core/types.d.ts +70 -3
- package/dist/core/types.d.ts.map +1 -1
- package/dist/fluent/agent-connection.d.ts +16 -1
- package/dist/fluent/agent-connection.d.ts.map +1 -1
- package/dist/fluent/agent-connection.js +20 -0
- package/dist/fluent/agent-connection.js.map +1 -1
- package/dist/fluent/service.d.ts +34 -0
- package/dist/fluent/service.d.ts.map +1 -0
- package/dist/fluent/service.js +41 -0
- package/dist/fluent/service.js.map +1 -0
- package/dist/fluent/vault.d.ts +59 -10
- package/dist/fluent/vault.d.ts.map +1 -1
- package/dist/fluent/vault.js +62 -8
- package/dist/fluent/vault.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/agents.d.ts +54 -7
- package/dist/internal/agents.d.ts.map +1 -1
- package/dist/internal/agents.js +110 -8
- package/dist/internal/agents.js.map +1 -1
- package/dist/internal/cubbies.d.ts +33 -0
- package/dist/internal/cubbies.d.ts.map +1 -1
- package/dist/internal/cubbies.js +39 -0
- package/dist/internal/cubbies.js.map +1 -1
- package/dist/internal/memory.d.ts +85 -5
- package/dist/internal/memory.d.ts.map +1 -1
- package/dist/internal/memory.js +58 -8
- package/dist/internal/memory.js.map +1 -1
- package/dist/internal/vaults.d.ts +8 -5
- package/dist/internal/vaults.d.ts.map +1 -1
- package/dist/internal/vaults.js +0 -10
- package/dist/internal/vaults.js.map +1 -1
- package/package.json +2 -2
- package/dist/internal/gateway-info.d.ts +0 -16
- package/dist/internal/gateway-info.d.ts.map +0 -1
- package/dist/internal/gateway-info.js +0 -34
- package/dist/internal/gateway-info.js.map +0 -1
package/dist/client.js
CHANGED
|
@@ -7,29 +7,35 @@ import { Health } from "./internal/health.js";
|
|
|
7
7
|
import { Vault } from "./fluent/vault.js";
|
|
8
8
|
import { WalletAuthProvider } from "./auth/wallet.js";
|
|
9
9
|
import { GarClient } from "./agreements/gar-client.js";
|
|
10
|
-
// Import the two chain-free helpers via account's `./delegation-token` subpath
|
|
11
|
-
// (not the root barrel) so vault-sdk never pulls `@cef-ai/account`'s
|
|
12
|
-
// `provisioning` → `@cef-ai/chain` → polkadot stack. Keeps vault-sdk web3-free.
|
|
13
|
-
import { buildDelegationToken, buildDelegateGrantToken, fetchGatewayPubkey, } from "@cef-ai/account/delegation-token";
|
|
14
|
-
// Same chain-free-seam rule applies to the delegate-grants subpath: it pulls
|
|
15
|
-
// only `gateway-signing.ts` (wallet-signature headers) — never the account
|
|
16
|
-
// root barrel, never `@cef-ai/chain`.
|
|
17
|
-
import { registerDelegate, revokeDelegate } from "@cef-ai/account/delegate-grants";
|
|
18
|
-
import { VaultInfo } from "./internal/vault-info.js";
|
|
19
10
|
import { OnboardingRequiredError, runOnboarding, signerToOnboardingSigner, } from "./internal/onboarding.js";
|
|
11
|
+
import { VaultRequestError } from "./core/errors.js";
|
|
20
12
|
const DEFAULT_S3_GATEWAY_AUTH_INFO_URL = "https://ddc-s3-gateway.compute.dev.ddcdragon.com/auth/info";
|
|
21
13
|
const DEFAULT_MARKETPLACE_ENDPOINT = "https://agent-marketplace.compute.dev.ddcdragon.com";
|
|
14
|
+
/** Claim attempts per `vault.ensure()`: the initial POST plus 2 retries. */
|
|
15
|
+
const CLAIM_MAX_ATTEMPTS = 3;
|
|
16
|
+
/** Backoff between claim attempts: 2s after the first, 5s after the second. */
|
|
17
|
+
const CLAIM_BACKOFF_MS = [2_000, 5_000];
|
|
18
|
+
/**
|
|
19
|
+
* Whether a failed claim POST had no effect and may simply be re-sent.
|
|
20
|
+
* `425 Too Early` always qualifies — vault-api answers it while the
|
|
21
|
+
* NonTransfer grant from the step above is still propagating, so the claim
|
|
22
|
+
* was merely early. `503` qualifies ONLY when the server's error envelope
|
|
23
|
+
* marked the outage `retryable: true`; an unmarked 503 might be down for a
|
|
24
|
+
* reason a blind re-POST would worsen, so it surfaces immediately.
|
|
25
|
+
*/
|
|
26
|
+
function isRetryableClaimError(err) {
|
|
27
|
+
return err.status === 425 || (err.status === 503 && err.retryable === true);
|
|
28
|
+
}
|
|
22
29
|
export class VaultSDK {
|
|
23
30
|
http;
|
|
24
31
|
marketplaceHttp;
|
|
32
|
+
endpoint;
|
|
33
|
+
chainUrl;
|
|
25
34
|
vaults;
|
|
26
|
-
vaultInfo;
|
|
27
35
|
gar;
|
|
28
36
|
signer;
|
|
29
|
-
s3GatewayPubkey;
|
|
30
37
|
s3GatewayAuthInfoUrl;
|
|
31
38
|
fetchFn;
|
|
32
|
-
cachedGatewayPubkey;
|
|
33
39
|
marketplace;
|
|
34
40
|
health;
|
|
35
41
|
/**
|
|
@@ -41,6 +47,8 @@ export class VaultSDK {
|
|
|
41
47
|
constructor(config) {
|
|
42
48
|
const auth = config.auth ??
|
|
43
49
|
(config.signer ? new WalletAuthProvider(config.signer) : undefined);
|
|
50
|
+
this.endpoint = config.endpoint;
|
|
51
|
+
this.chainUrl = config.chainUrl;
|
|
44
52
|
this.http = new VaultHttpClient({
|
|
45
53
|
url: config.endpoint,
|
|
46
54
|
auth,
|
|
@@ -66,12 +74,10 @@ export class VaultSDK {
|
|
|
66
74
|
}));
|
|
67
75
|
}
|
|
68
76
|
this.signer = config.signer;
|
|
69
|
-
this.s3GatewayPubkey = config.s3GatewayPubkey;
|
|
70
77
|
this.s3GatewayAuthInfoUrl =
|
|
71
78
|
config.s3GatewayAuthInfoUrl ?? DEFAULT_S3_GATEWAY_AUTH_INFO_URL;
|
|
72
79
|
this.fetchFn = config.fetch ?? fetch.bind(globalThis);
|
|
73
80
|
this.vaults = new Vaults(this.http);
|
|
74
|
-
this.vaultInfo = new VaultInfo(this.http);
|
|
75
81
|
this.marketplace = new Marketplace(this.marketplaceHttp);
|
|
76
82
|
this.health = new Health(this.http);
|
|
77
83
|
// The signer is the GRANT signer, not just the request signer: `put` and
|
|
@@ -83,19 +89,6 @@ export class VaultSDK {
|
|
|
83
89
|
// `VaultSignerRequiredError`.
|
|
84
90
|
this.memberships = new Memberships(this.http, config.signer);
|
|
85
91
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Resolves the gateway pubkey: prefers the static config, falls back to
|
|
88
|
-
* `/auth/info` (cached for the SDK's lifetime).
|
|
89
|
-
*/
|
|
90
|
-
async resolveGatewayPubkey() {
|
|
91
|
-
if (this.s3GatewayPubkey)
|
|
92
|
-
return this.s3GatewayPubkey;
|
|
93
|
-
if (this.cachedGatewayPubkey)
|
|
94
|
-
return this.cachedGatewayPubkey;
|
|
95
|
-
const pk = await fetchGatewayPubkey(this.s3GatewayAuthInfoUrl, this.fetchFn);
|
|
96
|
-
this.cachedGatewayPubkey = pk;
|
|
97
|
-
return pk;
|
|
98
|
-
}
|
|
99
92
|
/**
|
|
100
93
|
* Strip `/auth/info` (and any trailing slash) off the configured auth-info
|
|
101
94
|
* URL to reach the gateway base — the prefix the onboarding endpoints sit
|
|
@@ -107,6 +100,36 @@ export class VaultSDK {
|
|
|
107
100
|
.replace(/\/+$/, "")
|
|
108
101
|
.replace(/\/auth\/info$/, "");
|
|
109
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* The claim POST of `vault.ensure()`, with the bounded retry the 425
|
|
105
|
+
* contract implies. The SAME `ClaimVaultRequest` is re-sent on every
|
|
106
|
+
* attempt (the auth layer re-signs it each time, so with the default
|
|
107
|
+
* clock each retry carries a fresh timestamp; the claim itself stays
|
|
108
|
+
* idempotent server-side — a claim for a wallet that already owns a
|
|
109
|
+
* vault resolves to that vault). Bounded: `CLAIM_MAX_ATTEMPTS` POSTs
|
|
110
|
+
* total, backoff per `CLAIM_BACKOFF_MS` via the injectable `sleep`.
|
|
111
|
+
*
|
|
112
|
+
* Non-retryable failures — and exhaustion — re-throw the LAST error
|
|
113
|
+
* unchanged: the server's own `VaultRequestError`, never a retry wrapper.
|
|
114
|
+
* No progress events fire between attempts; the caller already saw
|
|
115
|
+
* `provisioning-vault` once and a stepper must not replay it.
|
|
116
|
+
*/
|
|
117
|
+
async claimVaultWithRetry(req, sleep) {
|
|
118
|
+
const doSleep = sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
119
|
+
for (let attempt = 1;; attempt++) {
|
|
120
|
+
try {
|
|
121
|
+
return await this.vaults.claim(req);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
if (attempt >= CLAIM_MAX_ATTEMPTS ||
|
|
125
|
+
!(err instanceof VaultRequestError) ||
|
|
126
|
+
!isRetryableClaimError(err)) {
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
await doSleep(CLAIM_BACKOFF_MS[attempt - 1]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
110
133
|
vault = {
|
|
111
134
|
ensure: async (opts = {}) => {
|
|
112
135
|
const onProgress = opts.onProgress ?? (() => { });
|
|
@@ -133,19 +156,40 @@ export class VaultSDK {
|
|
|
133
156
|
"resolve, then retry `vault.ensure()`.");
|
|
134
157
|
}
|
|
135
158
|
// 'skipped' (production gateway 404'd) and 'ready' both fall
|
|
136
|
-
// through silently to the
|
|
159
|
+
// through silently to the claim path.
|
|
137
160
|
}
|
|
138
|
-
|
|
161
|
+
// Grant step. The default (tokenless) path authorizes vault-api's
|
|
162
|
+
// delegate key as an on-chain NonTransfer proxy FIRST — the claim that
|
|
163
|
+
// follows is only useful if the delegate can actually write. Passing a
|
|
164
|
+
// pre-built `delegationToken` skips this entirely (legacy escape
|
|
165
|
+
// hatch): the token IS the authorization, no chain round-trip.
|
|
166
|
+
const delegationToken = opts.delegationToken;
|
|
139
167
|
if (!delegationToken) {
|
|
140
168
|
if (!this.signer) {
|
|
141
169
|
throw new Error("vault.ensure() needs either a `delegationToken` or a `signer` " +
|
|
142
|
-
"configured on VaultSDKConfig
|
|
170
|
+
"configured on VaultSDKConfig (the signer drives the on-chain " +
|
|
171
|
+
"vault-delegate grant).");
|
|
143
172
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
173
|
+
const chainUrl = opts.chainUrl ?? this.chainUrl;
|
|
174
|
+
if (!chainUrl) {
|
|
175
|
+
throw new Error("vault.ensure(): `chainUrl` is required on the wallet path — the SDK " +
|
|
176
|
+
"grants vault-api write delegation by submitting an on-chain NonTransfer " +
|
|
177
|
+
"proxy (`@cef-ai/account`'s `ensureVaultDelegate`) before claiming the " +
|
|
178
|
+
"vault. Set `chainUrl` on VaultSDKConfig (or pass it per call) with a " +
|
|
179
|
+
"Cere node WS URL, or pass `delegationToken` to use the legacy " +
|
|
180
|
+
"token-bearing claim instead.");
|
|
181
|
+
}
|
|
182
|
+
onProgress({ kind: "authorizing-vault" });
|
|
183
|
+
// Lazy import, via the `./vault-delegate` subpath (not the root
|
|
184
|
+
// barrel): consumers that never hit the wallet path — reads, the
|
|
185
|
+
// `delegationToken` escape hatch, `onboard:false` + token flows —
|
|
186
|
+
// never load the `@cef-ai/chain` → papi stack at module-init time.
|
|
187
|
+
const { ensureVaultDelegate } = await import("@cef-ai/account/vault-delegate");
|
|
188
|
+
await ensureVaultDelegate({
|
|
147
189
|
signer: this.signer,
|
|
148
|
-
|
|
190
|
+
chainUrl,
|
|
191
|
+
vaultApiUrl: this.endpoint,
|
|
192
|
+
fetchFn: this.fetchFn,
|
|
149
193
|
});
|
|
150
194
|
}
|
|
151
195
|
onProgress({ kind: "provisioning-vault" });
|
|
@@ -156,11 +200,15 @@ export class VaultSDK {
|
|
|
156
200
|
// register for the same wallet under the gateway's multi-credential
|
|
157
201
|
// model. It must be set HERE, before signing; vault-api cannot inject
|
|
158
202
|
// it later without invalidating the wallet signature.
|
|
159
|
-
|
|
203
|
+
//
|
|
204
|
+
// TOKENLESS by default: with no `delegationToken` the body is
|
|
205
|
+
// `{name, label}` and vault-api routes the claim through the proxy
|
|
206
|
+
// saga (the on-chain grant above is what authorizes it).
|
|
207
|
+
const rec = await this.claimVaultWithRetry({
|
|
160
208
|
name: opts.name,
|
|
161
|
-
delegation_token: delegationToken,
|
|
162
209
|
label: "vault",
|
|
163
|
-
|
|
210
|
+
...(delegationToken ? { delegation_token: delegationToken } : {}),
|
|
211
|
+
}, opts.sleep);
|
|
164
212
|
return new Vault(this.http, rec, { gar: this.gar, signer: this.signer });
|
|
165
213
|
},
|
|
166
214
|
current: async () => {
|
|
@@ -202,67 +250,16 @@ export class VaultSDK {
|
|
|
202
250
|
});
|
|
203
251
|
return new Vault(this.http, rec, { gar: this.gar, signer: this.signer });
|
|
204
252
|
},
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
rotateCredentials: async (vaultId, delegationToken) => {
|
|
216
|
-
const rec = await this.vaults.rotateCredentials(vaultId, {
|
|
217
|
-
delegation_token: delegationToken,
|
|
218
|
-
});
|
|
219
|
-
return new Vault(this.http, rec, { gar: this.gar, signer: this.signer });
|
|
220
|
-
},
|
|
221
|
-
delegate: {
|
|
222
|
-
/** vault-api's delegate signing pubkey (T_v subject). */
|
|
223
|
-
pubkey: async () => {
|
|
224
|
-
const { delegatePubkey } = await this.vaultInfo.delegate();
|
|
225
|
-
return delegatePubkey;
|
|
226
|
-
},
|
|
227
|
-
/**
|
|
228
|
-
* Grant vault-api autonomous S3-credential refresh for `bucketId`:
|
|
229
|
-
* owner signs T_v (subject = delegate pubkey) and registers it with the
|
|
230
|
-
* gateway. The SDK resolves vault-api's delegate pubkey itself (via
|
|
231
|
-
* `VaultInfo.delegate()`) unless the caller already knows it and passes
|
|
232
|
-
* `delegatePubkey` to skip the round-trip.
|
|
233
|
-
*/
|
|
234
|
-
grant: async (opts) => {
|
|
235
|
-
if (!this.signer) {
|
|
236
|
-
throw new Error("vault.delegate.grant() requires a `signer` on VaultSDKConfig to sign the grant token.");
|
|
237
|
-
}
|
|
238
|
-
const delegatePubkey = opts.delegatePubkey ?? (await this.vaultInfo.delegate()).delegatePubkey;
|
|
239
|
-
const delegationToken = await buildDelegateGrantToken({
|
|
240
|
-
signer: this.signer,
|
|
241
|
-
delegatePubkey,
|
|
242
|
-
bucketId: opts.bucketId,
|
|
243
|
-
});
|
|
244
|
-
await registerDelegate({
|
|
245
|
-
gatewayUrl: this.gatewayBaseUrl(),
|
|
246
|
-
signer: this.signer,
|
|
247
|
-
delegationToken,
|
|
248
|
-
fetchFn: this.fetchFn,
|
|
249
|
-
});
|
|
250
|
-
},
|
|
251
|
-
/** Revoke that grant. */
|
|
252
|
-
revoke: async (opts) => {
|
|
253
|
-
if (!this.signer) {
|
|
254
|
-
throw new Error("vault.delegate.revoke() requires a `signer` on VaultSDKConfig to sign the request.");
|
|
255
|
-
}
|
|
256
|
-
const delegatePubkey = opts.delegatePubkey ?? (await this.vaultInfo.delegate()).delegatePubkey;
|
|
257
|
-
await revokeDelegate({
|
|
258
|
-
gatewayUrl: this.gatewayBaseUrl(),
|
|
259
|
-
signer: this.signer,
|
|
260
|
-
delegatePubkey,
|
|
261
|
-
bucketId: opts.bucketId,
|
|
262
|
-
fetchFn: this.fetchFn,
|
|
263
|
-
});
|
|
264
|
-
},
|
|
265
|
-
},
|
|
253
|
+
// The `delegate` namespace (`delegate.pubkey` / `delegate.grant` /
|
|
254
|
+
// `delegate.revoke`, backed by the gateway's removed `/auth/delegates`
|
|
255
|
+
// API) was deleted: vault write delegation moved to on-chain NonTransfer
|
|
256
|
+
// proxy grants via `@cef-ai/account`'s `ensureVaultDelegate`.
|
|
257
|
+
//
|
|
258
|
+
// `rotateCredentials` (PUT /api/v1/vaults/:id/credentials) was deleted
|
|
259
|
+
// with the write-delegation migration: credentials now ride the proxy
|
|
260
|
+
// saga / the gateway's multi-credential `POST /auth/credentials` API
|
|
261
|
+
// (`@cef-ai/account`'s `registerCredential`), not a token-bearing
|
|
262
|
+
// rotation endpoint that could never return a secret.
|
|
266
263
|
};
|
|
267
264
|
}
|
|
268
265
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD
|
|
1
|
+
{"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I,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,mEAAmE;QACnE,uEAAuE;QACvE,yEAAyE;QACzE,8DAA8D;QAC9D,EAAE;QACF,uEAAuE;QACvE,sEAAsE;QACtE,qEAAqE;QACrE,kEAAkE;QAClE,sDAAsD;KACvD,CAAC;CACH"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the effective scope set from a `ScopeSelector`-shaped value
|
|
3
|
+
* (`./types.js`) and enforces, at runtime, the same "exactly one of
|
|
4
|
+
* `scope`/`scopes`" rule that type enforces at compile time for an object
|
|
5
|
+
* literal. The runtime check is still needed: `ScopeSelector`'s guarantee
|
|
6
|
+
* only holds for a literal passed directly at the call site — a value built
|
|
7
|
+
* dynamically (spread, JSON, `any`) can still carry both fields, or neither,
|
|
8
|
+
* and type-check anyway.
|
|
9
|
+
*
|
|
10
|
+
* `context` is prefixed onto the thrown message (e.g. `"Agents.connect"`,
|
|
11
|
+
* `"vault.agents.connect"`, `"signAndSubmitAgreement"`) so the error names
|
|
12
|
+
* which surface rejected the call.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveConnectScopes(input: {
|
|
15
|
+
scope?: string;
|
|
16
|
+
scopes?: string[];
|
|
17
|
+
}, context: string): string[];
|
|
18
|
+
//# sourceMappingURL=connect-scopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-scopes.d.ts","sourceRoot":"","sources":["../../src/core/connect-scopes.ts"],"names":[],"mappings":"AA4CA;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAC5C,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAyBV"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// src/core/connect-scopes.ts
|
|
2
|
+
/**
|
|
3
|
+
* The server (ddc-node's `normalizeConnectScopes`) refuses more than 16
|
|
4
|
+
* scopes on a single connection. Mirrored here only as a cheap pre-flight
|
|
5
|
+
* bound — the server remains the authority on this number.
|
|
6
|
+
*/
|
|
7
|
+
const MAX_SCOPES = 16;
|
|
8
|
+
/**
|
|
9
|
+
* Cheap, server-mirroring content bounds on a resolved scope set: no
|
|
10
|
+
* empty/blank member, no more than `MAX_SCOPES` entries. These exist only to
|
|
11
|
+
* fail BEFORE the wallet ceremony and GAR POST that the fluent connect flow
|
|
12
|
+
* runs ahead of the vault-api call — the server's own `normalizeConnectScopes`
|
|
13
|
+
* is still the authority and is free to be stricter than this. Never make
|
|
14
|
+
* this check narrower than the server's (that would reject requests the
|
|
15
|
+
* server would accept).
|
|
16
|
+
*
|
|
17
|
+
* ONE DELIBERATE DIVERGENCE: the blank check is `trim()`-based, while the
|
|
18
|
+
* server refuses only the exactly-empty string. A whitespace-only scope is
|
|
19
|
+
* therefore rejected here and would be accepted there. That is intentional —
|
|
20
|
+
* such a scope matches no catalogue entry and no routing predicate, so the
|
|
21
|
+
* connection it produces is dead on arrival, and failing before the wallet
|
|
22
|
+
* ceremony is strictly kinder than succeeding into a connection that can
|
|
23
|
+
* never receive an event. It is the only place this check is stricter than
|
|
24
|
+
* the server; keep it that way.
|
|
25
|
+
*/
|
|
26
|
+
function assertScopeContentInBounds(scopes, context) {
|
|
27
|
+
if (scopes.length > MAX_SCOPES) {
|
|
28
|
+
throw new Error(`[${context}] \`scopes\` has ${scopes.length} entries; the server ` +
|
|
29
|
+
`refuses more than ${MAX_SCOPES} — trim the set before calling`);
|
|
30
|
+
}
|
|
31
|
+
for (const s of scopes) {
|
|
32
|
+
if (typeof s !== "string" || s.trim().length === 0) {
|
|
33
|
+
throw new Error(`[${context}] \`scopes\` contains an empty/blank entry ` +
|
|
34
|
+
`(${JSON.stringify(s)}) — the server refuses an empty scope member`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolves the effective scope set from a `ScopeSelector`-shaped value
|
|
40
|
+
* (`./types.js`) and enforces, at runtime, the same "exactly one of
|
|
41
|
+
* `scope`/`scopes`" rule that type enforces at compile time for an object
|
|
42
|
+
* literal. The runtime check is still needed: `ScopeSelector`'s guarantee
|
|
43
|
+
* only holds for a literal passed directly at the call site — a value built
|
|
44
|
+
* dynamically (spread, JSON, `any`) can still carry both fields, or neither,
|
|
45
|
+
* and type-check anyway.
|
|
46
|
+
*
|
|
47
|
+
* `context` is prefixed onto the thrown message (e.g. `"Agents.connect"`,
|
|
48
|
+
* `"vault.agents.connect"`, `"signAndSubmitAgreement"`) so the error names
|
|
49
|
+
* which surface rejected the call.
|
|
50
|
+
*/
|
|
51
|
+
export function resolveConnectScopes(input, context) {
|
|
52
|
+
const hasScope = input.scope !== undefined;
|
|
53
|
+
const hasScopes = input.scopes !== undefined;
|
|
54
|
+
if (hasScope && hasScopes) {
|
|
55
|
+
throw new Error(`[${context}] both \`scope\` (${JSON.stringify(input.scope)}) and ` +
|
|
56
|
+
`\`scopes\` (${JSON.stringify(input.scopes)}) were supplied — these ` +
|
|
57
|
+
`conflict and which one would apply is undefined; pass exactly one.`);
|
|
58
|
+
}
|
|
59
|
+
if (hasScopes) {
|
|
60
|
+
if (!input.scopes || input.scopes.length === 0) {
|
|
61
|
+
throw new Error(`[${context}] \`scopes\` must be a non-empty array`);
|
|
62
|
+
}
|
|
63
|
+
assertScopeContentInBounds(input.scopes, context);
|
|
64
|
+
return input.scopes;
|
|
65
|
+
}
|
|
66
|
+
if (hasScope) {
|
|
67
|
+
assertScopeContentInBounds([input.scope], context);
|
|
68
|
+
return [input.scope];
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`[${context}] requires \`scope\` or a non-empty \`scopes\` array`);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=connect-scopes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-scopes.js","sourceRoot":"","sources":["../../src/core/connect-scopes.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAE7B;;;;GAIG;AACH,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,0BAA0B,CAAC,MAAgB,EAAE,OAAe;IACnE,IAAI,MAAM,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,IAAI,OAAO,oBAAoB,MAAM,CAAC,MAAM,uBAAuB;YACjE,qBAAqB,UAAU,gCAAgC,CAClE,CAAC;IACJ,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CACb,IAAI,OAAO,6CAA6C;gBACtD,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,8CAA8C,CACtE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAA4C,EAC5C,OAAe;IAEf,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC;IAC3C,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC;IAE7C,IAAI,QAAQ,IAAI,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,IAAI,OAAO,qBAAqB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ;YACjE,eAAe,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,0BAA0B;YACrE,oEAAoE,CACvE,CAAC;IACJ,CAAC;IACD,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,IAAI,OAAO,wCAAwC,CAAC,CAAC;QACvE,CAAC;QACD,0BAA0B,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,0BAA0B,CAAC,CAAC,KAAK,CAAC,KAAM,CAAC,EAAE,OAAO,CAAC,CAAC;QACpD,OAAO,CAAC,KAAK,CAAC,KAAM,CAAC,CAAC;IACxB,CAAC;IACD,MAAM,IAAI,KAAK,CACb,IAAI,OAAO,sDAAsD,CAClE,CAAC;AACJ,CAAC"}
|
package/dist/core/endpoints.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export declare const endpoints: {
|
|
2
2
|
readonly vaults: () => string;
|
|
3
3
|
readonly vault: (v: string) => string;
|
|
4
|
-
readonly vaultCredentials: (v: string) => string;
|
|
5
4
|
readonly scopes: (v: string) => string;
|
|
6
5
|
readonly scope: (v: string, s: string) => string;
|
|
7
6
|
readonly agents: (v: string) => string;
|
|
8
7
|
readonly agent: (v: string, a: string) => string;
|
|
8
|
+
readonly agentCeiling: (v: string, a: string) => string;
|
|
9
9
|
readonly scopeEvents: (v: string, s: string) => string;
|
|
10
10
|
readonly scopeObjects: (v: string, s: string) => string;
|
|
11
11
|
readonly scopeObject: (v: string, s: string, path: string) => string;
|
|
@@ -21,6 +21,27 @@ export declare const endpoints: {
|
|
|
21
21
|
readonly jobTaskLogs: (v: string, j: string, t: string) => string;
|
|
22
22
|
readonly cubbyQuery: (v: string, s: string, a: string, alias: string) => string;
|
|
23
23
|
readonly cubbyExec: (v: string, s: string, a: string, alias: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* The AGENT-SERVICE tier: one cubby per service, readable and writable by
|
|
26
|
+
* every agent that service published — and by a person whose grant on this
|
|
27
|
+
* vault already lets them read or write a cubby in it.
|
|
28
|
+
*
|
|
29
|
+
* NO SCOPE. A scope is a compartment of a vault, and a cubby addressed inside
|
|
30
|
+
* one forks the state of whatever owns it — a service connected to two of
|
|
31
|
+
* them would remember different things depending on which one triggered it.
|
|
32
|
+
* This is global within the vault.
|
|
33
|
+
*
|
|
34
|
+
* A sibling of the two above rather than a replacement. `agents/:agentId`
|
|
35
|
+
* stays exactly what it was, scope and all, because those files exist.
|
|
36
|
+
*
|
|
37
|
+
* The service key is NOT `seg()`-escaped for the same reason `a` is not: it
|
|
38
|
+
* is a bare hex key, and percent-encoding it would not match the route.
|
|
39
|
+
*/
|
|
40
|
+
readonly serviceCubbies: (v: string, as: string) => string;
|
|
41
|
+
readonly serviceCubby: (v: string, as: string, alias: string) => string;
|
|
42
|
+
readonly serviceCubbyQuery: (v: string, as: string, alias: string) => string;
|
|
43
|
+
readonly serviceCubbyExec: (v: string, as: string, alias: string) => string;
|
|
44
|
+
readonly serviceCubbyProvision: (v: string, as: string, alias: string) => string;
|
|
24
45
|
readonly memoryTool: (v: string, tool: string) => string;
|
|
25
46
|
readonly marketplaceAgents: () => string;
|
|
26
47
|
readonly marketplaceAgent: (a: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/core/endpoints.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,SAAS;;wBAET,MAAM;
|
|
1
|
+
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/core/endpoints.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,SAAS;;wBAET,MAAM;yBACL,MAAM;wBACP,MAAM,KAAK,MAAM;yBAChB,MAAM;wBACP,MAAM,KAAK,MAAM;+BACV,MAAM,KAAK,MAAM;8BAClB,MAAM,KAAK,MAAM;+BAChB,MAAM,KAAK,MAAM;8BAClB,MAAM,KAAK,MAAM,QAAQ,MAAM;2CAQlB,MAAM,KAAK,MAAM;+BAE7B,MAAM,KAAK,MAAM;yBACvB,MAAM,KAAK,MAAM,OAAO,MAAM;+BAExB,MAAM,KAAK,MAAM,OAAO,MAAM;uBAEtC,MAAM;sBACP,MAAM,KAAK,MAAM;4BACX,MAAM,KAAK,MAAM;2BAClB,MAAM,KAAK,MAAM;0BAClB,MAAM,KAAK,MAAM,KAAK,MAAM;8BAExB,MAAM,KAAK,MAAM,KAAK,MAAM;6BAE7B,MAAM,KAAK,MAAM,KAAK,MAAM,SAAS,MAAM;4BAE5C,MAAM,KAAK,MAAM,KAAK,MAAM,SAAS,MAAM;IAE1D;;;;;;;;;;;;;;;OAeG;iCACiB,MAAM,MAAM,MAAM;+BAEpB,MAAM,MAAM,MAAM,SAAS,MAAM;oCAE5B,MAAM,MAAM,MAAM,SAAS,MAAM;mCAElC,MAAM,MAAM,MAAM,SAAS,MAAM;wCAE5B,MAAM,MAAM,MAAM,SAAS,MAAM;6BAM5C,MAAM,QAAQ,MAAM;;mCAGd,MAAM;0CACC,MAAM,KAAK,MAAM;;+BAM5B,MAAM;8BACP,MAAM,gBAAgB,MAAM;oCAEtB,MAAM,gBAAgB,MAAM;oCAK5B,MAAM;;;;;CAOrB,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC"}
|
package/dist/core/endpoints.js
CHANGED
|
@@ -10,11 +10,11 @@ const segPath = (p) => p.split("/").map(seg).join("/");
|
|
|
10
10
|
export const endpoints = {
|
|
11
11
|
vaults: () => `${API_BASE}/vaults`,
|
|
12
12
|
vault: (v) => `${API_BASE}/vaults/${seg(v)}`,
|
|
13
|
-
vaultCredentials: (v) => `${API_BASE}/vaults/${seg(v)}/credentials`,
|
|
14
13
|
scopes: (v) => `${API_BASE}/vaults/${seg(v)}/scopes`,
|
|
15
14
|
scope: (v, s) => `${API_BASE}/vaults/${seg(v)}/scopes/${seg(s)}`,
|
|
16
15
|
agents: (v) => `${API_BASE}/vaults/${seg(v)}/agents`,
|
|
17
16
|
agent: (v, a) => `${API_BASE}/vaults/${seg(v)}/agents/${seg(a)}`,
|
|
17
|
+
agentCeiling: (v, a) => `${API_BASE}/vaults/${seg(v)}/agents/${seg(a)}/ceiling`,
|
|
18
18
|
scopeEvents: (v, s) => `${API_BASE}/vaults/${seg(v)}/scopes/${seg(s)}/events`,
|
|
19
19
|
scopeObjects: (v, s) => `${API_BASE}/vaults/${seg(v)}/scopes/${seg(s)}/objects`,
|
|
20
20
|
scopeObject: (v, s, path) => `${API_BASE}/vaults/${seg(v)}/scopes/${seg(s)}/objects/${segPath(path)}`,
|
|
@@ -36,10 +36,31 @@ export const endpoints = {
|
|
|
36
36
|
jobTaskLogs: (v, j, t) => `${API_BASE}/vaults/${seg(v)}/jobs/${seg(j)}/tasks/${seg(t)}/logs`,
|
|
37
37
|
cubbyQuery: (v, s, a, alias) => `${API_BASE}/vaults/${seg(v)}/scopes/${seg(s)}/agents/${a}/cubbies/${seg(alias)}/query`,
|
|
38
38
|
cubbyExec: (v, s, a, alias) => `${API_BASE}/vaults/${seg(v)}/scopes/${seg(s)}/agents/${a}/cubbies/${seg(alias)}/exec`,
|
|
39
|
+
/**
|
|
40
|
+
* The AGENT-SERVICE tier: one cubby per service, readable and writable by
|
|
41
|
+
* every agent that service published — and by a person whose grant on this
|
|
42
|
+
* vault already lets them read or write a cubby in it.
|
|
43
|
+
*
|
|
44
|
+
* NO SCOPE. A scope is a compartment of a vault, and a cubby addressed inside
|
|
45
|
+
* one forks the state of whatever owns it — a service connected to two of
|
|
46
|
+
* them would remember different things depending on which one triggered it.
|
|
47
|
+
* This is global within the vault.
|
|
48
|
+
*
|
|
49
|
+
* A sibling of the two above rather than a replacement. `agents/:agentId`
|
|
50
|
+
* stays exactly what it was, scope and all, because those files exist.
|
|
51
|
+
*
|
|
52
|
+
* The service key is NOT `seg()`-escaped for the same reason `a` is not: it
|
|
53
|
+
* is a bare hex key, and percent-encoding it would not match the route.
|
|
54
|
+
*/
|
|
55
|
+
serviceCubbies: (v, as) => `${API_BASE}/vaults/${seg(v)}/services/${as}/cubbies`,
|
|
56
|
+
serviceCubby: (v, as, alias) => `${API_BASE}/vaults/${seg(v)}/services/${as}/cubbies/${seg(alias)}`,
|
|
57
|
+
serviceCubbyQuery: (v, as, alias) => `${API_BASE}/vaults/${seg(v)}/services/${as}/cubbies/${seg(alias)}/query`,
|
|
58
|
+
serviceCubbyExec: (v, as, alias) => `${API_BASE}/vaults/${seg(v)}/services/${as}/cubbies/${seg(alias)}/exec`,
|
|
59
|
+
serviceCubbyProvision: (v, as, alias) => `${API_BASE}/vaults/${seg(v)}/services/${as}/cubbies/${seg(alias)}/provision`,
|
|
39
60
|
// The memory bank's per-tool route: one wildcard `:tool` segment, so every
|
|
40
61
|
// read (record_search / record_get / record_neighbours /
|
|
41
|
-
// record_count_by_type) shares this builder — the READ half
|
|
42
|
-
// vault-sdk (`vault.memory`), writes stay agent-side (ctx.memory).
|
|
62
|
+
// record_count_by_type / record_list) shares this builder — the READ half
|
|
63
|
+
// lives in vault-sdk (`vault.memory`), writes stay agent-side (ctx.memory).
|
|
43
64
|
memoryTool: (v, tool) => `${API_BASE}/vaults/${seg(v)}/memory/${seg(tool)}`,
|
|
44
65
|
marketplaceAgents: () => `${API_BASE}/marketplace/agents`,
|
|
45
66
|
marketplaceAgent: (a) => `${API_BASE}/marketplace/agents/${seg(a)}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../../src/core/endpoints.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,SAAS,CAAC;AAC3B,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAEjD,2EAA2E;AAC3E,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,4EAA4E;AAC5E,g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G,QAAQ,cAAc;IAC5C,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS;IACvB,KAAK,EAAE,GAAG,EAAE,CAAC,QAAQ;IACrB,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU;CACjB,CAAC"}
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
export declare class VaultRequestError extends Error {
|
|
2
2
|
readonly status?: number | undefined;
|
|
3
3
|
readonly code?: string | number | undefined;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The server's own "safe to re-issue" verdict from the error envelope
|
|
6
|
+
* (`error.retryable`). Defaults to false when the envelope omits it —
|
|
7
|
+
* only errors the server explicitly marks retryable may be re-sent.
|
|
8
|
+
*/
|
|
9
|
+
readonly retryable?: boolean | undefined;
|
|
10
|
+
constructor(message: string, status?: number | undefined, code?: string | number | undefined,
|
|
11
|
+
/**
|
|
12
|
+
* The server's own "safe to re-issue" verdict from the error envelope
|
|
13
|
+
* (`error.retryable`). Defaults to false when the envelope omits it —
|
|
14
|
+
* only errors the server explicitly marks retryable may be re-sent.
|
|
15
|
+
*/
|
|
16
|
+
retryable?: boolean | undefined);
|
|
5
17
|
}
|
|
6
18
|
export declare class VaultNotImplementedError extends VaultRequestError {
|
|
7
19
|
constructor(message?: string);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AACA,qBAAa,iBAAkB,SAAQ,KAAK;aAGxB,MAAM,CAAC,EAAE,MAAM;aACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AACA,qBAAa,iBAAkB,SAAQ,KAAK;aAGxB,MAAM,CAAC,EAAE,MAAM;aACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;IACtC;;;;OAIG;aACa,SAAS,CAAC,EAAE,OAAO;gBARnC,OAAO,EAAE,MAAM,EACC,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,YAAA;IACtC;;;;OAIG;IACa,SAAS,CAAC,EAAE,OAAO,YAAA;CAKtC;AAED,qBAAa,wBAAyB,SAAQ,iBAAiB;gBACjD,OAAO,SAAmC;CAIvD;AAED,qBAAa,wBAAyB,SAAQ,KAAK;gBAE/C,OAAO,SAAiE;CAK3E;AAUD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,GACZ,iBAAiB,CAYnB"}
|
package/dist/core/errors.js
CHANGED
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
export class VaultRequestError extends Error {
|
|
3
3
|
status;
|
|
4
4
|
code;
|
|
5
|
-
|
|
5
|
+
retryable;
|
|
6
|
+
constructor(message, status, code,
|
|
7
|
+
/**
|
|
8
|
+
* The server's own "safe to re-issue" verdict from the error envelope
|
|
9
|
+
* (`error.retryable`). Defaults to false when the envelope omits it —
|
|
10
|
+
* only errors the server explicitly marks retryable may be re-sent.
|
|
11
|
+
*/
|
|
12
|
+
retryable) {
|
|
6
13
|
super(message);
|
|
7
14
|
this.status = status;
|
|
8
15
|
this.code = code;
|
|
16
|
+
this.retryable = retryable;
|
|
9
17
|
this.name = "VaultRequestError";
|
|
10
18
|
}
|
|
11
19
|
}
|
|
@@ -25,8 +33,12 @@ export function mapResponseError(status, body) {
|
|
|
25
33
|
const parsed = body && typeof body === "object" ? body : undefined;
|
|
26
34
|
const message = parsed?.error?.message ?? `Request failed with status ${status}`;
|
|
27
35
|
const code = parsed?.error?.code;
|
|
36
|
+
// Strictly `=== true`: anything else the envelope might smuggle into the
|
|
37
|
+
// flag (strings, truthy garbage) must not license a re-POST. Absent means
|
|
38
|
+
// false — only the server's explicit verdict retries.
|
|
39
|
+
const retryable = parsed?.error?.retryable === true;
|
|
28
40
|
if (status === 501)
|
|
29
41
|
return new VaultNotImplementedError(message);
|
|
30
|
-
return new VaultRequestError(message, status, code);
|
|
42
|
+
return new VaultRequestError(message, status, code, retryable);
|
|
31
43
|
}
|
|
32
44
|
//# sourceMappingURL=errors.js.map
|
package/dist/core/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAGxB;IACA;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAGxB;IACA;IAMA;IATlB,YACE,OAAe,EACC,MAAe,EACf,IAAsB;IACtC;;;;OAIG;IACa,SAAmB;QAEnC,KAAK,CAAC,OAAO,CAAC,CAAC;QATC,WAAM,GAAN,MAAM,CAAS;QACf,SAAI,GAAJ,IAAI,CAAkB;QAMtB,cAAS,GAAT,SAAS,CAAU;QAGnC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAC7D,YAAY,OAAO,GAAG,gCAAgC;QACpD,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YACE,OAAO,GAAG,8DAA8D;QAExE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAUD,MAAM,UAAU,gBAAgB,CAC9B,MAAc,EACd,IAAa;IAEb,MAAM,MAAM,GACV,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAE,IAAo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