@cef-ai/vault-sdk 5.2.0 → 5.4.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 +2 -0
- package/dist/client.d.ts +45 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +57 -1
- package/dist/client.js.map +1 -1
- package/dist/core/auth-token.d.ts +27 -0
- package/dist/core/auth-token.d.ts.map +1 -0
- package/dist/core/auth-token.js +101 -0
- package/dist/core/auth-token.js.map +1 -0
- package/dist/core/delegation-tokens.d.ts +47 -0
- package/dist/core/delegation-tokens.d.ts.map +1 -0
- package/dist/core/delegation-tokens.js +113 -0
- package/dist/core/delegation-tokens.js.map +1 -0
- package/dist/core/endpoints.d.ts +1 -0
- package/dist/core/endpoints.d.ts.map +1 -1
- package/dist/core/endpoints.js +1 -0
- package/dist/core/endpoints.js.map +1 -1
- package/dist/core/errors.d.ts +55 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +92 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/types.d.ts +57 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/fluent/agent-connection.d.ts +3 -1
- package/dist/fluent/agent-connection.d.ts.map +1 -1
- package/dist/fluent/agent-connection.js +3 -0
- package/dist/fluent/agent-connection.js.map +1 -1
- package/dist/fluent/vault.d.ts +14 -0
- package/dist/fluent/vault.d.ts.map +1 -1
- package/dist/fluent/vault.js +7 -0
- package/dist/fluent/vault.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/agents.d.ts +6 -0
- package/dist/internal/agents.d.ts.map +1 -1
- package/dist/internal/agents.js +6 -0
- package/dist/internal/agents.js.map +1 -1
- package/dist/internal/browse.d.ts +2 -0
- package/dist/internal/browse.d.ts.map +1 -1
- package/dist/internal/browse.js +1 -1
- package/dist/internal/browse.js.map +1 -1
- package/dist/internal/memberships.d.ts +90 -17
- package/dist/internal/memberships.d.ts.map +1 -1
- package/dist/internal/memberships.js +133 -29
- package/dist/internal/memberships.js.map +1 -1
- package/dist/internal/vaults.d.ts +8 -1
- package/dist/internal/vaults.d.ts.map +1 -1
- package/dist/internal/vaults.js +9 -0
- package/dist/internal/vaults.js.map +1 -1
- package/dist/internal-exports.d.ts +1 -1
- package/dist/internal-exports.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Signer } from "@cef-ai/signer";
|
|
2
2
|
import type { VaultHttpClient } from "../core/http.js";
|
|
3
|
-
import type { PrivacyCeilingName } from "../core/grant-doc.js";
|
|
3
|
+
import type { PrivacyCeiling, PrivacyCeilingName } from "../core/grant-doc.js";
|
|
4
4
|
import type { Member, MemberRole, MembershipSummary, ScopeGrants, SignedRoster } from "../core/types.js";
|
|
5
5
|
/**
|
|
6
6
|
* What the caller already knows about the membership's OTHER half, so the
|
|
@@ -28,11 +28,37 @@ export interface PutMemberOptions {
|
|
|
28
28
|
*/
|
|
29
29
|
privacyCeiling?: PrivacyCeilingName;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* What `putScopes` signs besides the new scopes: the standing this member
|
|
33
|
+
* ALREADY has, which that route does not change.
|
|
34
|
+
*/
|
|
35
|
+
export interface HeldStanding {
|
|
36
|
+
role: MemberRole;
|
|
37
|
+
/** Absent: the membership has no expiry. */
|
|
38
|
+
expiresAt?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The privacy ceiling the member holds, or `NO_PRIVACY_CEILING` when they
|
|
41
|
+
* hold none. Absent: read it off the verified signed roster — absence here
|
|
42
|
+
* means "not known", never "none".
|
|
43
|
+
*
|
|
44
|
+
* vault-api rebuilds the document from the STORED ceiling, so a member who
|
|
45
|
+
* holds one is signed a `cere.vault.grant.v2` document and a member who
|
|
46
|
+
* holds none a v1 one. Passing the wrong value is refused with a 400; it
|
|
47
|
+
* cannot change the stored ceiling, which this route never writes.
|
|
48
|
+
*/
|
|
49
|
+
privacyCeiling?: PrivacyCeiling;
|
|
50
|
+
}
|
|
31
51
|
/** @see PutMemberOptions */
|
|
32
52
|
export interface PutScopesOptions {
|
|
33
53
|
/**
|
|
34
|
-
* The standing this member ALREADY has —
|
|
35
|
-
*
|
|
54
|
+
* The standing this member ALREADY has — the role, the expiry and the
|
|
55
|
+
* privacy ceiling, none of which this route sets. Default: the role and
|
|
56
|
+
* expiry are read off the roster (`list()`) in one GET, and the ceiling off
|
|
57
|
+
* the verified signed roster (`signedRoster()`) in another.
|
|
58
|
+
*
|
|
59
|
+
* Given without `privacyCeiling`, the role and expiry are signed as given
|
|
60
|
+
* and the ceiling is still read from the signed roster. Given with it, no
|
|
61
|
+
* read is made at all.
|
|
36
62
|
*
|
|
37
63
|
* ONE OPTION CARRYING TWO FIELDS, replacing the former `role?`. The grant
|
|
38
64
|
* document covers the role AND the expiry, and this route changes neither,
|
|
@@ -46,10 +72,7 @@ export interface PutScopesOptions {
|
|
|
46
72
|
* instant is accepted, because the server compares instants (it cannot
|
|
47
73
|
* render the signer's original string back out of a timestamp column).
|
|
48
74
|
*/
|
|
49
|
-
standing?:
|
|
50
|
-
role: MemberRole;
|
|
51
|
-
expiresAt?: string;
|
|
52
|
-
};
|
|
75
|
+
standing?: HeldStanding;
|
|
53
76
|
}
|
|
54
77
|
/**
|
|
55
78
|
* Who belongs to a vault, in what role, holding which scope grants — and,
|
|
@@ -106,9 +129,11 @@ export interface PutScopesOptions {
|
|
|
106
129
|
*
|
|
107
130
|
* `PutMember` builds its document from the role in the body and the scopes
|
|
108
131
|
* ALREADY IN THE STORE; `PutScopes` builds its own from the scopes in the
|
|
109
|
-
* body and the role already in the store. So each
|
|
110
|
-
* back before signing — one extra GET
|
|
111
|
-
*
|
|
132
|
+
* body and the role, expiry and privacy ceiling already in the store. So each
|
|
133
|
+
* method reads the other half back before signing — one extra GET for `put`,
|
|
134
|
+
* two for `putScopes` (the ceiling comes from the signed roster) — unless the
|
|
135
|
+
* caller supplies it
|
|
136
|
+
* (`PutMemberOptions.scopes` / `PutScopesOptions.standing`). Signing the same
|
|
112
137
|
* bytes for both calls is refused by the second.
|
|
113
138
|
*
|
|
114
139
|
* ### AN ADMIN WHO IS NOT THE OWNER CANNOT SIGN
|
|
@@ -308,12 +333,35 @@ export declare class Memberships {
|
|
|
308
333
|
* a currently-suspended membership.
|
|
309
334
|
*
|
|
310
335
|
* CARRIES THE OWNER'S `X-Grant-Signature` over
|
|
311
|
-
* `{vaultId, memberPubkey, role, scopes, issuedAt, expiresAt}
|
|
312
|
-
*
|
|
313
|
-
* the
|
|
314
|
-
*
|
|
336
|
+
* `{vaultId, memberPubkey, role, scopes, issuedAt, expiresAt}`, plus
|
|
337
|
+
* `privacyCeiling` when the member holds one — see the class doc comment.
|
|
338
|
+
* The role, the expiry and the ceiling in that document are the ones the
|
|
339
|
+
* member ALREADY HOLDS, because this route sets the scopes only. The role
|
|
340
|
+
* and expiry are read off the roster (`list()`) in one GET, which is why a
|
|
315
341
|
* `memberPubkey` with no row fails here rather than as the server's 404.
|
|
316
|
-
*
|
|
342
|
+
*
|
|
343
|
+
* THE CEILING DECIDES THE DOCUMENT'S VERSION. vault-api rebuilds this
|
|
344
|
+
* route's document from the stored ceiling, so a member who holds one needs
|
|
345
|
+
* the `cere.vault.grant.v2` document and a member who holds none the v1
|
|
346
|
+
* one, byte for byte as before. The ceiling is read from the SIGNED roster
|
|
347
|
+
* (`signedRoster()`, checked with `verifySignedRoster` against this vault
|
|
348
|
+
* id), because that is a document the vault owner signed and the plain
|
|
349
|
+
* roster does not carry it. A member whose grant there fails verification
|
|
350
|
+
* is refused with `GrantVerificationError`.
|
|
351
|
+
*
|
|
352
|
+
* A MEMBER THE SIGNED ROSTER DOES NOT SERVE IS SIGNED V1. It serves live
|
|
353
|
+
* memberships with a stored grant document only, so a suspended member or
|
|
354
|
+
* a legacy row is absent from it, and vault-api still lets an admin edit
|
|
355
|
+
* such a membership's scopes (its check is that the row exists, not that
|
|
356
|
+
* it is live). Most such members hold no ceiling and the v1 write succeeds
|
|
357
|
+
* as it always did. One who does hold a ceiling makes vault-api rebuild a
|
|
358
|
+
* v2 document, which the v1 signature does not cover: the server answers
|
|
359
|
+
* 400 naming the v2 document, writes nothing, and this method throws
|
|
360
|
+
* `CeilingUnknownError`. Retry with the ceiling passed in `standing`.
|
|
361
|
+
*
|
|
362
|
+
* Pass `{ standing: { role, expiresAt, privacyCeiling } }` to skip both
|
|
363
|
+
* reads — `NO_PRIVACY_CEILING` for a member who holds none. A `standing`
|
|
364
|
+
* without `privacyCeiling` skips the role read only.
|
|
317
365
|
*
|
|
318
366
|
* THE EXPIRY IS ALSO SENT IN THE BODY, and that is the one place this route
|
|
319
367
|
* differs from `put`. vault-api holds the expiry as a timestamp and the
|
|
@@ -345,10 +393,35 @@ export declare class Memberships {
|
|
|
345
393
|
* the one field whose absence is a document VERSION: unset builds the v1
|
|
346
394
|
* bytes exactly as before this option existed, set appends the ceiling and
|
|
347
395
|
* flips the schema string. An invalid value never gets this far — `put()`
|
|
348
|
-
*
|
|
349
|
-
* a typo cannot become a stored grant on any
|
|
396
|
+
* and `putScopes()` vet it before their read-backs — and the encoder
|
|
397
|
+
* re-checks regardless, so a typo cannot become a stored grant on any
|
|
398
|
+
* path in.
|
|
350
399
|
*/
|
|
351
400
|
private grantHeader;
|
|
401
|
+
/**
|
|
402
|
+
* The configured grant signer, or the reason there is none that vault-api
|
|
403
|
+
* would accept. `grantHeader` needs it to sign; `putScopes` also checks it
|
|
404
|
+
* up front, so a missing signer costs none of its read-backs.
|
|
405
|
+
*/
|
|
406
|
+
private grantSigner;
|
|
407
|
+
/**
|
|
408
|
+
* The privacy ceiling this member holds RIGHT NOW — `NO_PRIVACY_CEILING`
|
|
409
|
+
* when their grant is v1 — read out of the signed roster after verifying
|
|
410
|
+
* it against `vaultId`. `undefined` when the signed roster does not serve
|
|
411
|
+
* this member at all.
|
|
412
|
+
*
|
|
413
|
+
* The plain roster (`list()`) does not carry the ceiling, and the signed
|
|
414
|
+
* roster's is a value the vault owner signed rather than one vault-api
|
|
415
|
+
* rendered, so a verified document is the only source this trusts.
|
|
416
|
+
*
|
|
417
|
+
* An entry that fails verification is refused: the member is there and
|
|
418
|
+
* the value cannot be trusted. An ABSENT member is not refused, because
|
|
419
|
+
* the signed roster leaves out suspended members and rows with no stored
|
|
420
|
+
* grant document, both of which vault-api still lets an admin re-scope;
|
|
421
|
+
* `putScopes` signs v1 for them and turns the server's refusal, if the
|
|
422
|
+
* member does hold a ceiling, into `CeilingUnknownError`.
|
|
423
|
+
*/
|
|
424
|
+
private heldCeiling;
|
|
352
425
|
/**
|
|
353
426
|
* The scope grants this member holds RIGHT NOW — the half of `put`'s
|
|
354
427
|
* document that route reads from the store rather than from its body.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memberships.d.ts","sourceRoot":"","sources":["../../src/internal/memberships.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"memberships.d.ts","sourceRoot":"","sources":["../../src/internal/memberships.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAmBvD,OAAO,KAAK,EAAe,cAAc,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAM5F,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,YAAY,EACb,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,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EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5D;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,WAAW,CAAA;KAAE,CAAC;IAI/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;IACG,SAAS,CACb,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,WAAW,EACnB,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,IAAI,CAAC;IA4DhB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;YACW,WAAW;IAgDzB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAqBnB;;;;;;;;;;;;;;;;OAgBG;YACW,WAAW;IAyBzB;;;;;;;;;;;OAWG;YACW,UAAU;IASxB;;;;;;;;;;;;;;;;;;;OAmBG;YACW,YAAY;CAkB3B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { endpoints } from "../core/endpoints.js";
|
|
2
2
|
import { bytesToHex } from "../core/canonical.js";
|
|
3
|
-
import { GRANT_SIGNATURE_HEADER, GRANT_ISSUED_AT_HEADER, NO_GRANT_EXPIRY, PRIVACY_CEILINGS, canonicalGrantBytes, canonicalGrantBytesWithCeiling, canonicalPubkeyHex, grantExpiry, isValidPrivacyCeiling, privacyCeiling, } from "../core/grant-doc.js";
|
|
4
|
-
import { VaultRequestError, VaultSignerRequiredError } from "../core/errors.js";
|
|
3
|
+
import { GRANT_SIGNATURE_HEADER, GRANT_ISSUED_AT_HEADER, GRANT_SCHEMA_V2, GrantVerificationError, NO_GRANT_EXPIRY, NO_PRIVACY_CEILING, PRIVACY_CEILINGS, canonicalGrantBytes, canonicalGrantBytesWithCeiling, canonicalPubkeyHex, grantExpiry, isValidPrivacyCeiling, privacyCeiling, verifySignedRoster, } from "../core/grant-doc.js";
|
|
4
|
+
import { CeilingUnknownError, VaultRequestError, VaultSignerRequiredError, } from "../core/errors.js";
|
|
5
5
|
/**
|
|
6
6
|
* Who belongs to a vault, in what role, holding which scope grants — and,
|
|
7
7
|
* from the other direction, which vaults the caller belongs to.
|
|
@@ -57,9 +57,11 @@ import { VaultRequestError, VaultSignerRequiredError } from "../core/errors.js";
|
|
|
57
57
|
*
|
|
58
58
|
* `PutMember` builds its document from the role in the body and the scopes
|
|
59
59
|
* ALREADY IN THE STORE; `PutScopes` builds its own from the scopes in the
|
|
60
|
-
* body and the role already in the store. So each
|
|
61
|
-
* back before signing — one extra GET
|
|
62
|
-
*
|
|
60
|
+
* body and the role, expiry and privacy ceiling already in the store. So each
|
|
61
|
+
* method reads the other half back before signing — one extra GET for `put`,
|
|
62
|
+
* two for `putScopes` (the ceiling comes from the signed roster) — unless the
|
|
63
|
+
* caller supplies it
|
|
64
|
+
* (`PutMemberOptions.scopes` / `PutScopesOptions.standing`). Signing the same
|
|
63
65
|
* bytes for both calls is refused by the second.
|
|
64
66
|
*
|
|
65
67
|
* ### AN ADMIN WHO IS NOT THE OWNER CANNOT SIGN
|
|
@@ -306,12 +308,35 @@ export class Memberships {
|
|
|
306
308
|
* a currently-suspended membership.
|
|
307
309
|
*
|
|
308
310
|
* CARRIES THE OWNER'S `X-Grant-Signature` over
|
|
309
|
-
* `{vaultId, memberPubkey, role, scopes, issuedAt, expiresAt}
|
|
310
|
-
*
|
|
311
|
-
* the
|
|
312
|
-
*
|
|
311
|
+
* `{vaultId, memberPubkey, role, scopes, issuedAt, expiresAt}`, plus
|
|
312
|
+
* `privacyCeiling` when the member holds one — see the class doc comment.
|
|
313
|
+
* The role, the expiry and the ceiling in that document are the ones the
|
|
314
|
+
* member ALREADY HOLDS, because this route sets the scopes only. The role
|
|
315
|
+
* and expiry are read off the roster (`list()`) in one GET, which is why a
|
|
313
316
|
* `memberPubkey` with no row fails here rather than as the server's 404.
|
|
314
|
-
*
|
|
317
|
+
*
|
|
318
|
+
* THE CEILING DECIDES THE DOCUMENT'S VERSION. vault-api rebuilds this
|
|
319
|
+
* route's document from the stored ceiling, so a member who holds one needs
|
|
320
|
+
* the `cere.vault.grant.v2` document and a member who holds none the v1
|
|
321
|
+
* one, byte for byte as before. The ceiling is read from the SIGNED roster
|
|
322
|
+
* (`signedRoster()`, checked with `verifySignedRoster` against this vault
|
|
323
|
+
* id), because that is a document the vault owner signed and the plain
|
|
324
|
+
* roster does not carry it. A member whose grant there fails verification
|
|
325
|
+
* is refused with `GrantVerificationError`.
|
|
326
|
+
*
|
|
327
|
+
* A MEMBER THE SIGNED ROSTER DOES NOT SERVE IS SIGNED V1. It serves live
|
|
328
|
+
* memberships with a stored grant document only, so a suspended member or
|
|
329
|
+
* a legacy row is absent from it, and vault-api still lets an admin edit
|
|
330
|
+
* such a membership's scopes (its check is that the row exists, not that
|
|
331
|
+
* it is live). Most such members hold no ceiling and the v1 write succeeds
|
|
332
|
+
* as it always did. One who does hold a ceiling makes vault-api rebuild a
|
|
333
|
+
* v2 document, which the v1 signature does not cover: the server answers
|
|
334
|
+
* 400 naming the v2 document, writes nothing, and this method throws
|
|
335
|
+
* `CeilingUnknownError`. Retry with the ceiling passed in `standing`.
|
|
336
|
+
*
|
|
337
|
+
* Pass `{ standing: { role, expiresAt, privacyCeiling } }` to skip both
|
|
338
|
+
* reads — `NO_PRIVACY_CEILING` for a member who holds none. A `standing`
|
|
339
|
+
* without `privacyCeiling` skips the role read only.
|
|
315
340
|
*
|
|
316
341
|
* THE EXPIRY IS ALSO SENT IN THE BODY, and that is the one place this route
|
|
317
342
|
* differs from `put`. vault-api holds the expiry as a timestamp and the
|
|
@@ -321,12 +346,47 @@ export class Memberships {
|
|
|
321
346
|
* stating it cannot widen the membership: a different moment is a 400.
|
|
322
347
|
*/
|
|
323
348
|
async putScopes(vaultId, memberPubkey, scopes, opts = {}) {
|
|
349
|
+
// A caller error costs no round trip: the signer and a given ceiling are
|
|
350
|
+
// both checked before either read-back.
|
|
351
|
+
this.grantSigner();
|
|
352
|
+
const given = opts.standing?.privacyCeiling;
|
|
353
|
+
if (given !== undefined && given !== NO_PRIVACY_CEILING && !isValidPrivacyCeiling(given)) {
|
|
354
|
+
throw new Error(`putScopes: standing.privacyCeiling ${JSON.stringify(given)} must be one of ` +
|
|
355
|
+
PRIVACY_CEILINGS.map((c) => `"${c}"`).join(", ") +
|
|
356
|
+
`, or NO_PRIVACY_CEILING for a member who holds none`);
|
|
357
|
+
}
|
|
324
358
|
const standing = opts.standing ?? (await this.heldStanding(vaultId, memberPubkey));
|
|
359
|
+
// `undefined` when the signed roster does not serve this member: the
|
|
360
|
+
// ceiling is not known, and the v1 document is sent as it was before the
|
|
361
|
+
// ceiling existed.
|
|
362
|
+
const ceiling = given ?? (await this.heldCeiling(vaultId, memberPubkey));
|
|
325
363
|
const expiry = standing.expiresAt === undefined ? NO_GRANT_EXPIRY : grantExpiry(standing.expiresAt);
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
364
|
+
// The ceiling is signed and never sent: this route does not set it, and
|
|
365
|
+
// the server rebuilds the document from the one it stores.
|
|
366
|
+
try {
|
|
367
|
+
return await this.http.send("PUT", endpoints.vaultMemberScopes(vaultId, memberPubkey), {
|
|
368
|
+
body: { scopes, expiresAt: standing.expiresAt, timestamp: new Date().toISOString() },
|
|
369
|
+
headers: await this.grantHeader(vaultId, memberPubkey, standing.role, scopes, expiry, ceiling === undefined || ceiling === NO_PRIVACY_CEILING ? undefined : ceiling),
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
catch (err) {
|
|
373
|
+
// Only the unknown-ceiling case is reinterpreted. vault-api answers a
|
|
374
|
+
// signature over the wrong bytes with a 400 that quotes the document it
|
|
375
|
+
// rebuilt; a v2 schema there, after this client signed v1, means the
|
|
376
|
+
// member holds a ceiling this client could not see.
|
|
377
|
+
if (ceiling === undefined &&
|
|
378
|
+
err instanceof VaultRequestError &&
|
|
379
|
+
err.status === 400 &&
|
|
380
|
+
err.message.includes(GRANT_SCHEMA_V2)) {
|
|
381
|
+
const canonical = canonicalPubkeyHex(memberPubkey);
|
|
382
|
+
throw new CeilingUnknownError(`putScopes: ${canonical} is not in ${vaultId}'s signed roster (it serves live ` +
|
|
383
|
+
`memberships only), so the grant was signed with no privacy ceiling, and ` +
|
|
384
|
+
`vault-api refused it because this member holds one. Nothing was written. ` +
|
|
385
|
+
`Pass \`{ standing: { role, expiresAt, privacyCeiling } }\` with the ceiling ` +
|
|
386
|
+
`the member holds. Server said: ${err.message}`, canonical, err.status, err.code);
|
|
387
|
+
}
|
|
388
|
+
throw err;
|
|
389
|
+
}
|
|
330
390
|
}
|
|
331
391
|
/**
|
|
332
392
|
* The vault owner's signature over this grant's canonical document, as the
|
|
@@ -350,23 +410,12 @@ export class Memberships {
|
|
|
350
410
|
* the one field whose absence is a document VERSION: unset builds the v1
|
|
351
411
|
* bytes exactly as before this option existed, set appends the ceiling and
|
|
352
412
|
* flips the schema string. An invalid value never gets this far — `put()`
|
|
353
|
-
*
|
|
354
|
-
* a typo cannot become a stored grant on any
|
|
413
|
+
* and `putScopes()` vet it before their read-backs — and the encoder
|
|
414
|
+
* re-checks regardless, so a typo cannot become a stored grant on any
|
|
415
|
+
* path in.
|
|
355
416
|
*/
|
|
356
417
|
async grantHeader(vaultId, memberPubkey, role, scopes, expiresAt, ceiling) {
|
|
357
|
-
const signer = this.
|
|
358
|
-
if (signer === undefined || typeof signer.sign !== "function") {
|
|
359
|
-
throw new VaultSignerRequiredError(`A membership write must carry the VAULT OWNER's signature over the grant's ` +
|
|
360
|
-
`canonical document, in the ${GRANT_SIGNATURE_HEADER} header. Construct the ` +
|
|
361
|
-
`SDK with \`signer\` set to the vault owner's key (\`new VaultSDK({ endpoint, ` +
|
|
362
|
-
`signer })\`); a custom \`auth\` provider authenticates the request but cannot ` +
|
|
363
|
-
`sign the grant, because the two cover different bytes.`);
|
|
364
|
-
}
|
|
365
|
-
if (signer.type !== "ed25519") {
|
|
366
|
-
throw new VaultSignerRequiredError(`A grant signature must be ed25519 — vault-api verifies it with SchemeEd25519 ` +
|
|
367
|
-
`and nothing else — but this signer is "${signer.type}". An sr25519 key can ` +
|
|
368
|
-
`authenticate the request and still never authorise the grant.`);
|
|
369
|
-
}
|
|
418
|
+
const signer = this.grantSigner();
|
|
370
419
|
// The mint time is chosen HERE, by the signer, and sent beside the
|
|
371
420
|
// signature — vault-api rebuilds the document rather than receiving it,
|
|
372
421
|
// so it cannot supply a mint time of its own without guaranteeing the
|
|
@@ -389,6 +438,61 @@ export class Memberships {
|
|
|
389
438
|
[GRANT_ISSUED_AT_HEADER]: issuedAt,
|
|
390
439
|
};
|
|
391
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* The configured grant signer, or the reason there is none that vault-api
|
|
443
|
+
* would accept. `grantHeader` needs it to sign; `putScopes` also checks it
|
|
444
|
+
* up front, so a missing signer costs none of its read-backs.
|
|
445
|
+
*/
|
|
446
|
+
grantSigner() {
|
|
447
|
+
const signer = this.signer;
|
|
448
|
+
if (signer === undefined || typeof signer.sign !== "function") {
|
|
449
|
+
throw new VaultSignerRequiredError(`A membership write must carry the VAULT OWNER's signature over the grant's ` +
|
|
450
|
+
`canonical document, in the ${GRANT_SIGNATURE_HEADER} header. Construct the ` +
|
|
451
|
+
`SDK with \`signer\` set to the vault owner's key (\`new VaultSDK({ endpoint, ` +
|
|
452
|
+
`signer })\`); a custom \`auth\` provider authenticates the request but cannot ` +
|
|
453
|
+
`sign the grant, because the two cover different bytes.`);
|
|
454
|
+
}
|
|
455
|
+
if (signer.type !== "ed25519") {
|
|
456
|
+
throw new VaultSignerRequiredError(`A grant signature must be ed25519 — vault-api verifies it with SchemeEd25519 ` +
|
|
457
|
+
`and nothing else — but this signer is "${signer.type}". An sr25519 key can ` +
|
|
458
|
+
`authenticate the request and still never authorise the grant.`);
|
|
459
|
+
}
|
|
460
|
+
return signer;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* The privacy ceiling this member holds RIGHT NOW — `NO_PRIVACY_CEILING`
|
|
464
|
+
* when their grant is v1 — read out of the signed roster after verifying
|
|
465
|
+
* it against `vaultId`. `undefined` when the signed roster does not serve
|
|
466
|
+
* this member at all.
|
|
467
|
+
*
|
|
468
|
+
* The plain roster (`list()`) does not carry the ceiling, and the signed
|
|
469
|
+
* roster's is a value the vault owner signed rather than one vault-api
|
|
470
|
+
* rendered, so a verified document is the only source this trusts.
|
|
471
|
+
*
|
|
472
|
+
* An entry that fails verification is refused: the member is there and
|
|
473
|
+
* the value cannot be trusted. An ABSENT member is not refused, because
|
|
474
|
+
* the signed roster leaves out suspended members and rows with no stored
|
|
475
|
+
* grant document, both of which vault-api still lets an admin re-scope;
|
|
476
|
+
* `putScopes` signs v1 for them and turns the server's refusal, if the
|
|
477
|
+
* member does hold a ceiling, into `CeilingUnknownError`.
|
|
478
|
+
*/
|
|
479
|
+
async heldCeiling(vaultId, memberPubkey) {
|
|
480
|
+
const canonical = canonicalPubkeyHex(memberPubkey);
|
|
481
|
+
const unverifiable = [];
|
|
482
|
+
const grants = await verifySignedRoster(await this.signedRoster(vaultId), vaultId, {
|
|
483
|
+
onUnverifiableGrant: (err) => unverifiable.push(err),
|
|
484
|
+
});
|
|
485
|
+
const held = grants.find((g) => canonicalPubkeyHex(g.memberPubkey) === canonical);
|
|
486
|
+
if (held !== undefined)
|
|
487
|
+
return held.privacyCeiling;
|
|
488
|
+
const failed = unverifiable.find((err) => err.memberPubkey !== "" && canonicalPubkeyHex(err.memberPubkey) === canonical);
|
|
489
|
+
if (failed !== undefined) {
|
|
490
|
+
throw new GrantVerificationError(`putScopes: ${canonical}'s grant in the signed roster of ${vaultId} failed ` +
|
|
491
|
+
`verification (${failed.message}), so the privacy ceiling it holds is unknown ` +
|
|
492
|
+
`and no grant document can be signed for it.`, failed.memberPubkey);
|
|
493
|
+
}
|
|
494
|
+
return undefined;
|
|
495
|
+
}
|
|
392
496
|
/**
|
|
393
497
|
* The scope grants this member holds RIGHT NOW — the half of `put`'s
|
|
394
498
|
* document that route reads from the store rather than from its body.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memberships.js","sourceRoot":"","sources":["../../src/internal/memberships.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,8BAA8B,EAC9B,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,cAAc,
|
|
1
|
+
{"version":3,"file":"memberships.js","sourceRoot":"","sources":["../../src/internal/memberships.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,8BAA8B,EAC9B,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAoF3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AACH,MAAM,OAAO,WAAW;IAUH;IACA;IAVnB;;;;;;;OAOG;IACH,YACmB,IAAqB,EACrB,MAAe;QADf,SAAI,GAAJ,IAAI,CAAiB;QACrB,WAAM,GAAN,MAAM,CAAS;IAC/B,CAAC;IAEJ;;;;;;;;;;;;;OAaG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,C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YAAY,iBAAiB,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;gBAAE,OAAO,EAAE,CAAC;YACtE,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACK,KAAK,CAAC,YAAY,CACxB,OAAe,EACf,YAAoB;QAEpB,MAAM,SAAS,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;QACnD,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CACzC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,IAAI,kBAAkB,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,SAAS,CAC9E,CAAC;QACF,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,cAAc,SAAS,6BAA6B,OAAO,wBAAwB;gBACjF,+DAA+D;gBAC/D,8EAA8E;gBAC9E,oBAAoB,CACvB,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VaultHttpClient } from "../core/http.js";
|
|
2
|
-
import type { VaultRecord } from "../core/types.js";
|
|
2
|
+
import type { PutDelegationsRequest, PutDelegationsResponse, VaultRecord } from "../core/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Claim body. vault-api forwards the wallet-signed claim bytes BYTE-FOR-BYTE
|
|
5
5
|
* to the S3 gateway's `POST /auth/credentials` (ddc-node
|
|
@@ -48,5 +48,12 @@ export declare class Vaults {
|
|
|
48
48
|
* patch would skip.
|
|
49
49
|
*/
|
|
50
50
|
patch(vaultId: string, req: PatchVaultRequest): Promise<VaultRecord>;
|
|
51
|
+
/**
|
|
52
|
+
* The owner's delegation ceremony — `PUT /api/v1/vaults/:vaultId/delegations`.
|
|
53
|
+
* PUT because re-running it REPLACES both tokens (renewal). Owner-only.
|
|
54
|
+
*/
|
|
55
|
+
putDelegations(vaultId: string, req: PutDelegationsRequest & {
|
|
56
|
+
timestamp: string;
|
|
57
|
+
}): Promise<PutDelegationsResponse>;
|
|
51
58
|
}
|
|
52
59
|
//# sourceMappingURL=vaults.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vaults.d.ts","sourceRoot":"","sources":["../../src/internal/vaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"vaults.d.ts","sourceRoot":"","sources":["../../src/internal/vaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEnG;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,iBAAiB;IAAG,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;AAE/F;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAAG,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAE9E,qBAAa,MAAM;IACL,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,eAAe;IAElD,KAAK,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAGnD,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC;IAG/B,wEAAwE;IACxE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAG3C;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAKpE;;;OAGG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,qBAAqB,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAOrH"}
|
package/dist/internal/vaults.js
CHANGED
|
@@ -25,5 +25,14 @@ export class Vaults {
|
|
|
25
25
|
body: req,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* The owner's delegation ceremony — `PUT /api/v1/vaults/:vaultId/delegations`.
|
|
30
|
+
* PUT because re-running it REPLACES both tokens (renewal). Owner-only.
|
|
31
|
+
*/
|
|
32
|
+
putDelegations(vaultId, req) {
|
|
33
|
+
return this.http.send("PUT", endpoints.vaultDelegations(vaultId), {
|
|
34
|
+
body: req,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
28
37
|
}
|
|
29
38
|
//# sourceMappingURL=vaults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vaults.js","sourceRoot":"","sources":["../../src/internal/vaults.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAgCjD,MAAM,OAAO,MAAM;IACY;IAA7B,YAA6B,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;IAAG,CAAC;IAEtD,KAAK,CAAC,GAAsB;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAyC,EAAE,CAAC,CAAC;IACzG,CAAC;IACD,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM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AAE;YACvD,IAAI,EAAE,GAAyC;SAChD,CAAC,CAAC;IACL,CAAC;IACD;;;OAGG;IACH,cAAc,CAAC,OAAe,EAAE,GAAkD;QAChF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE;YAChE,IAAI,EAAE,GAAyC;SAChD,CAAC,CAAC;IACL,CAAC;CAGF"}
|
|
@@ -8,7 +8,7 @@ export { Health } from "./internal/health.js";
|
|
|
8
8
|
export { Marketplace } from "./internal/marketplace.js";
|
|
9
9
|
export { Memberships } from "./internal/memberships.js";
|
|
10
10
|
export { AgentConnectionAccess, Connections, listConnectors } from "./internal/connectors.js";
|
|
11
|
-
export type { PutMemberOptions, PutScopesOptions } from "./internal/memberships.js";
|
|
11
|
+
export type { HeldStanding, PutMemberOptions, PutScopesOptions } from "./internal/memberships.js";
|
|
12
12
|
export { VaultHttpClient } from "./core/http.js";
|
|
13
13
|
export { endpoints } from "./core/endpoints.js";
|
|
14
14
|
//# sourceMappingURL=internal-exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-exports.d.ts","sourceRoot":"","sources":["../src/internal-exports.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,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,qBAAqB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9F,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"internal-exports.d.ts","sourceRoot":"","sources":["../src/internal-exports.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,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,qBAAqB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9F,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElG,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cef-ai/vault-sdk",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@polkadot/keyring": "^14.0.3",
|
|
26
26
|
"@polkadot/util": "^14.0.3",
|
|
27
27
|
"@polkadot/util-crypto": "^14.0.3",
|
|
28
|
+
"@cef-ai/account": "2.0.0",
|
|
28
29
|
"@cef-ai/signer": "1.0.0",
|
|
29
|
-
"@cef-ai/transport": "1.1.0"
|
|
30
|
-
"@cef-ai/account": "2.0.0"
|
|
30
|
+
"@cef-ai/transport": "1.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^20.11.0",
|