@cortexkit/claustrum-client 0.16.0 → 0.18.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 +7 -0
- package/dist/wire.d.ts +25 -1
- package/dist/wire.js +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -168,6 +168,13 @@ for (;;) {
|
|
|
168
168
|
|
|
169
169
|
## Enrollment
|
|
170
170
|
|
|
171
|
+
`enrollPropose` accepts an optional `displayName`, for example
|
|
172
|
+
`{ name: 'consumer', requestSecretHash, displayName: 'Claude sign-in for Pi' }`.
|
|
173
|
+
The person sees and approves the proposed label, or replaces it during approval.
|
|
174
|
+
This option needs a vault build with enrollment display-name support; an older
|
|
175
|
+
vault refuses the `display_name` field as `invalid_params`. Omit `displayName`
|
|
176
|
+
for compatibility with older vaults.
|
|
177
|
+
|
|
171
178
|
Use `newEnrollmentSecret()` to prepare an enrollment proposal. It generates 32
|
|
172
179
|
random bytes as exactly 64 lowercase hex characters, plus `requestSecretHash`:
|
|
173
180
|
the lowercase hex SHA-256 of the **32 decoded bytes**, not of the UTF-8 hex text.
|
package/dist/wire.d.ts
CHANGED
|
@@ -179,10 +179,28 @@ export declare class ClaustrumClient {
|
|
|
179
179
|
* BEFORE calling this, and a crash costs nothing.
|
|
180
180
|
*
|
|
181
181
|
* A different secret on the same name is a different caller and is refused.
|
|
182
|
+
* Optional `displayName` proposes a person-facing label for operator approval. It
|
|
183
|
+
* needs a vault build with enrollment display-name support; an older vault refuses
|
|
184
|
+
* the `display_name` field as `invalid_params`. Omit it for older vaults.
|
|
185
|
+
* Optional `requestedGrants` proposes read/list permissions for operator review.
|
|
186
|
+
* Older vaults refuse `requested_grants` as `invalid_params`. Callers that want to
|
|
187
|
+
* support them must choose to retry without the field themselves; the client never
|
|
188
|
+
* silently drops permissions, since malformed grants have the same refusal code.
|
|
182
189
|
*/
|
|
183
190
|
enrollPropose(input: {
|
|
184
191
|
name: string;
|
|
185
192
|
requestSecretHash: string;
|
|
193
|
+
displayName?: string;
|
|
194
|
+
requestedGrants?: ReadonlyArray<{
|
|
195
|
+
selector: {
|
|
196
|
+
category: string;
|
|
197
|
+
exact?: never;
|
|
198
|
+
} | {
|
|
199
|
+
exact: string;
|
|
200
|
+
category?: never;
|
|
201
|
+
};
|
|
202
|
+
operation: 'read' | 'list';
|
|
203
|
+
}>;
|
|
186
204
|
}): Promise<{
|
|
187
205
|
requestId: string;
|
|
188
206
|
}>;
|
|
@@ -236,11 +254,17 @@ export declare class ClaustrumClient {
|
|
|
236
254
|
*/
|
|
237
255
|
export interface ScopedInventoryRow {
|
|
238
256
|
readonly id: string;
|
|
257
|
+
/** Vault catalog service key, not a routing provider id. */
|
|
258
|
+
readonly provider?: string;
|
|
259
|
+
readonly incarnation?: string;
|
|
260
|
+
/** First observation of the effective tier; absent when unknown. */
|
|
261
|
+
readonly planTierObservedAtMs?: number;
|
|
239
262
|
readonly categories: readonly string[];
|
|
240
263
|
readonly credentialType: string;
|
|
241
264
|
readonly serves: readonly string[];
|
|
242
265
|
/**
|
|
243
|
-
*
|
|
266
|
+
* Stored routing ids, defaulted at creation or operator-assigned; empty when unset.
|
|
267
|
+
* Always present on this type.
|
|
244
268
|
* A daemon older than the field omits it from the wire, and that decodes as empty,
|
|
245
269
|
* which is also what an unmapped credential reports.
|
|
246
270
|
*/
|
package/dist/wire.js
CHANGED
|
@@ -296,11 +296,20 @@ export class ClaustrumClient {
|
|
|
296
296
|
* BEFORE calling this, and a crash costs nothing.
|
|
297
297
|
*
|
|
298
298
|
* A different secret on the same name is a different caller and is refused.
|
|
299
|
+
* Optional `displayName` proposes a person-facing label for operator approval. It
|
|
300
|
+
* needs a vault build with enrollment display-name support; an older vault refuses
|
|
301
|
+
* the `display_name` field as `invalid_params`. Omit it for older vaults.
|
|
302
|
+
* Optional `requestedGrants` proposes read/list permissions for operator review.
|
|
303
|
+
* Older vaults refuse `requested_grants` as `invalid_params`. Callers that want to
|
|
304
|
+
* support them must choose to retry without the field themselves; the client never
|
|
305
|
+
* silently drops permissions, since malformed grants have the same refusal code.
|
|
299
306
|
*/
|
|
300
307
|
async enrollPropose(input) {
|
|
301
308
|
const response = await this.#call('auth.enroll_propose', {
|
|
302
309
|
proposed_name: input.name,
|
|
303
310
|
request_secret_hash: input.requestSecretHash,
|
|
311
|
+
...(input.displayName !== undefined ? { display_name: input.displayName } : {}),
|
|
312
|
+
...(input.requestedGrants !== undefined ? { requested_grants: input.requestedGrants } : {}),
|
|
304
313
|
});
|
|
305
314
|
const result = decodeEnrollmentResult(response, this.#logger);
|
|
306
315
|
const requestId = result.request_id;
|
|
@@ -491,6 +500,14 @@ export function decodeScopedInventory(response, logUnknownClass) {
|
|
|
491
500
|
throw asCredentialError(response, 'invalid_response', logUnknownClass);
|
|
492
501
|
}
|
|
493
502
|
const authMethod = row.auth_method;
|
|
503
|
+
const provider = row.provider ?? undefined;
|
|
504
|
+
const incarnation = row.incarnation ?? undefined;
|
|
505
|
+
const planTierObservedAtMs = row.plan_tier_observed_at_ms ?? undefined;
|
|
506
|
+
if (!isOptionalString(provider) || !isOptionalString(incarnation) ||
|
|
507
|
+
(planTierObservedAtMs !== undefined &&
|
|
508
|
+
(typeof planTierObservedAtMs !== 'number' || !Number.isSafeInteger(planTierObservedAtMs)))) {
|
|
509
|
+
throw asCredentialError(response, 'invalid_response', logUnknownClass);
|
|
510
|
+
}
|
|
494
511
|
const planTierSource = row.plan_tier_source;
|
|
495
512
|
if (planTierSource !== undefined && planTierSource !== 'operator' && planTierSource !== 'detected') {
|
|
496
513
|
throw asCredentialError(response, 'invalid_response', logUnknownClass);
|
|
@@ -508,6 +525,9 @@ export function decodeScopedInventory(response, logUnknownClass) {
|
|
|
508
525
|
}
|
|
509
526
|
return {
|
|
510
527
|
id: row.id,
|
|
528
|
+
provider,
|
|
529
|
+
incarnation,
|
|
530
|
+
planTierObservedAtMs,
|
|
511
531
|
categories: strings(row.categories),
|
|
512
532
|
credentialType: row.type,
|
|
513
533
|
serves: strings(row.serves),
|