@wtfalch/keys 0.8.0 → 0.12.1

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.
Files changed (59) hide show
  1. package/README.md +248 -8
  2. package/dist/held/index.d.ts +116 -6
  3. package/dist/held/index.js +247 -25
  4. package/dist/held/schema.d.ts +17 -0
  5. package/dist/held/schema.js +12 -0
  6. package/dist/held/shred.d.ts +6 -0
  7. package/dist/held/shred.js +6 -0
  8. package/dist/held-edge/index.d.ts +17 -2
  9. package/dist/held-edge/index.js +51 -9
  10. package/dist/host/audit-endpoint.js +2 -8
  11. package/dist/host/company-registrar-keys.d.ts +13 -0
  12. package/dist/host/company-registrar-keys.js +6 -8
  13. package/dist/host/events.d.ts +19 -3
  14. package/dist/host/events.js +55 -20
  15. package/dist/host/index.d.ts +9 -2
  16. package/dist/host/index.js +9 -2
  17. package/dist/host/native-build.d.ts +126 -0
  18. package/dist/host/native-build.js +322 -0
  19. package/dist/host/registrar.d.ts +10 -4
  20. package/dist/host/registrar.js +64 -42
  21. package/dist/host/rotation-sweep.d.ts +56 -0
  22. package/dist/host/rotation-sweep.js +89 -0
  23. package/dist/issued/encoding.d.ts +4 -0
  24. package/dist/issued/encoding.js +22 -0
  25. package/dist/issued/index.d.ts +148 -7
  26. package/dist/issued/index.js +320 -34
  27. package/dist/issued/resign.d.ts +16 -0
  28. package/dist/issued/resign.js +55 -2
  29. package/dist/issued/tables.d.ts +38 -0
  30. package/dist/issued/tables.js +6 -0
  31. package/dist/issued/verify.d.ts +14 -3
  32. package/dist/issued/verify.js +10 -3
  33. package/dist/migrations/held/0004_keys_archived_publish_guard.sql +46 -0
  34. package/dist/migrations/held/0005_keys_held_migration_credential.sql +216 -0
  35. package/dist/migrations/held/0006_keys_held_entries_guard.sql +54 -0
  36. package/dist/migrations/host/0002_keys_host_held_events.sql +29 -0
  37. package/dist/migrations/issued/0007_keys_purpose.sql +68 -0
  38. package/dist/migrations/issued/0008_keys_idempotency_scope.sql +23 -0
  39. package/dist/service/body.d.ts +21 -0
  40. package/dist/service/body.js +128 -0
  41. package/dist/service/errors.d.ts +24 -0
  42. package/dist/service/errors.js +89 -0
  43. package/dist/service/handler.d.ts +35 -0
  44. package/dist/service/handler.js +328 -0
  45. package/dist/service/index.d.ts +7 -0
  46. package/dist/service/index.js +7 -0
  47. package/dist/service/policy.d.ts +130 -0
  48. package/dist/service/policy.js +123 -0
  49. package/dist/service/timeout.d.ts +6 -0
  50. package/dist/service/timeout.js +34 -0
  51. package/dist/testing/index.d.ts +3 -0
  52. package/dist/testing/index.js +3 -0
  53. package/dist/webhooks.d.ts +40 -17
  54. package/dist/webhooks.js +70 -26
  55. package/dist/worker-contract.d.ts +43 -6
  56. package/dist/worker-contract.js +37 -0
  57. package/dist/worker.d.ts +1 -1
  58. package/dist/worker.js +7 -28
  59. package/package.json +21 -3
@@ -0,0 +1,89 @@
1
+ /**
2
+ * `runRotationSweep` (docs/contracts.md C3): the sweep a host runs from its
3
+ * migrate container after `rotate-host.mjs start`. It moves every wrapped key
4
+ * onto the new wrap key id and every signed row onto the new signing
5
+ * generation, then counts what is left and reports it. `promote` reads that
6
+ * report.
7
+ *
8
+ * The counts come from the stored labels, not from the ids the sweep was told
9
+ * about, so a version left under an id nobody named still shows up.
10
+ */
11
+ import { HeldKeysError } from '../held/index.js';
12
+ import { ID_PATTERN } from '../worker-contract.js';
13
+ const RESIGN_BATCH_SIZE = 100;
14
+ export async function runRotationSweep(options) {
15
+ const { hostId, kekIdNew, sigIdNew, held, migrator, targetPublicKey } = options;
16
+ const now = options.now ?? Date.now;
17
+ let rewrapped = 0;
18
+ let resigned = 0;
19
+ const stop = (step, reason, from) => ({
20
+ ok: false,
21
+ step,
22
+ reason,
23
+ ...(from === undefined ? {} : { from }),
24
+ rewrapped,
25
+ resigned,
26
+ });
27
+ for (const id of [hostId, kekIdNew, sigIdNew]) {
28
+ if (!ID_PATTERN.test(id))
29
+ return stop('input', 'bad_request');
30
+ }
31
+ if (migrator && !(targetPublicKey instanceof Uint8Array && targetPublicKey.byteLength === 32)) {
32
+ return stop('input', 'bad_request');
33
+ }
34
+ if (held) {
35
+ for (const kekIdOld of await held.kekIdsInUse()) {
36
+ if (kekIdOld === kekIdNew)
37
+ continue;
38
+ try {
39
+ rewrapped += (await held.rewrap({ kekIdOld, kekIdNew })).rewrapped;
40
+ }
41
+ catch (error) {
42
+ if (error instanceof HeldKeysError)
43
+ return stop('rewrap', error.code, kekIdOld);
44
+ throw error;
45
+ }
46
+ }
47
+ }
48
+ if (migrator && targetPublicKey) {
49
+ for (const fromGenerationId of await migrator.generationsInUse()) {
50
+ if (fromGenerationId === sigIdNew)
51
+ continue;
52
+ let cursor = null;
53
+ for (;;) {
54
+ const batch = await migrator.resignBatch({
55
+ fromGenerationId,
56
+ toGenerationId: sigIdNew,
57
+ targetPublicKey,
58
+ cursor,
59
+ limit: RESIGN_BATCH_SIZE,
60
+ });
61
+ resigned += batch.migratedIds.length;
62
+ if (!batch.ok) {
63
+ return stop('resign', batch.reason, fromGenerationId);
64
+ }
65
+ if (batch.complete)
66
+ break;
67
+ cursor = batch.resumeCursor;
68
+ }
69
+ }
70
+ }
71
+ const remainingWrapped = held ? await held.countNotUnder(kekIdNew) : 0;
72
+ const remainingSigned = migrator ? await migrator.countNotGeneration(sigIdNew) : 0;
73
+ return {
74
+ ok: true,
75
+ report: {
76
+ version: 1,
77
+ hostId,
78
+ kekIdNew,
79
+ sigIdNew,
80
+ rewrapped,
81
+ resigned,
82
+ remainingWrapped,
83
+ remainingSigned,
84
+ heldSwept: held !== undefined,
85
+ signedSwept: migrator !== undefined,
86
+ finishedAt: now(),
87
+ },
88
+ };
89
+ }
@@ -28,6 +28,10 @@ import { type SignableRow, type SignedKind } from '../worker-contract.js';
28
28
  * `Object.keys(obj).sort()` alone gives JCS's key order.
29
29
  */
30
30
  export declare function canonicalJson(value: unknown): string;
31
+ /** True when the string holds a UTF-16 surrogate that is not half of a valid pair. */
32
+ export declare function hasLoneSurrogate(value: string): boolean;
33
+ /** True when a string, or an object key, anywhere in the JSON-like value holds a lone surrogate. */
34
+ export declare function containsLoneSurrogate(value: unknown): boolean;
31
35
  /**
32
36
  * `wtfalch-keys:${kind}:v1\n` + `canonicalJson(value)`, as UTF-8 bytes.
33
37
  *
@@ -33,6 +33,22 @@ import { ID_PATTERN, SIGNED_PREFIX, } from '../worker-contract.js';
33
33
  export function canonicalJson(value) {
34
34
  return encodeValue(value);
35
35
  }
36
+ const LONE_SURROGATE = /[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/;
37
+ /** True when the string holds a UTF-16 surrogate that is not half of a valid pair. */
38
+ export function hasLoneSurrogate(value) {
39
+ return LONE_SURROGATE.test(value);
40
+ }
41
+ /** True when a string, or an object key, anywhere in the JSON-like value holds a lone surrogate. */
42
+ export function containsLoneSurrogate(value) {
43
+ if (typeof value === 'string')
44
+ return hasLoneSurrogate(value);
45
+ if (Array.isArray(value))
46
+ return value.some(containsLoneSurrogate);
47
+ if (value !== null && typeof value === 'object') {
48
+ return Object.entries(value).some(([k, v]) => hasLoneSurrogate(k) || containsLoneSurrogate(v));
49
+ }
50
+ return false;
51
+ }
36
52
  function encodeValue(value) {
37
53
  if (value === null)
38
54
  return 'null';
@@ -95,6 +111,12 @@ function encodeString(value) {
95
111
  * other's.
96
112
  */
97
113
  export function encodeSigned(kind, value) {
114
+ // A lone surrogate has no UTF-8 form, and RFC 8785 forbids it. Without this,
115
+ // JSON.stringify would sign its \udXXX escape, a second spelling of a row
116
+ // that a strict encoder would refuse or write as U+FFFD.
117
+ if (containsLoneSurrogate(value)) {
118
+ throw new TypeError('encodeSigned: a string holding a lone surrogate is refused');
119
+ }
98
120
  const header = `${SIGNED_PREFIX}${kind}:v1\n`;
99
121
  return new TextEncoder().encode(header + canonicalJson(value));
100
122
  }
@@ -1,9 +1,10 @@
1
1
  import type { PgDatabase, PgQueryResultHKT } from 'drizzle-orm/pg-core';
2
2
  import type { SerializedCredential, VerifyKeys, WorkerClient, WorkerErrorCode } from '../worker-contract.js';
3
3
  import type { RateLimiter } from './ratelimit.js';
4
+ export type { KeysIssuedCredentialRow } from './tables.js';
4
5
  export { ID_PATTERN, SIGNED_PREFIX, type RequestMeta, type SerializedCredential, type SignableRow, type SignedKind, type SignedRow, type SignRowRequest, type SignRowResult, type SignRowSuccess, type VerifyKeys, type WorkerClient, type WorkerError, type WorkerErrorCode, type WorkerFailure, } from '../worker-contract.js';
5
6
  export { createPostgresRateLimiter, type CreatePostgresRateLimiterOptions, type RateLimiter, type RateLimitResult, } from './ratelimit.js';
6
- export { createSigningGenerationMigrator, MAX_RESIGN_BATCH_SIZE, type CreateSigningGenerationMigratorOptions, type ResignGenerationBatchRequest, type ResignGenerationBatchResult, type ResignGenerationRefusalReason, type SigningGenerationCursor, type SigningGenerationMigrator, } from './resign.js';
7
+ export { createSigningGenerationMigrator, MAX_RESIGN_BATCH_SIZE, RESIGN_GENERATION_REFUSAL_REASONS, type CreateSigningGenerationMigratorOptions, type ResignGenerationBatchRequest, type ResignGenerationBatchResult, type ResignGenerationRefusalReason, type SigningGenerationCursor, type SigningGenerationMigrator, } from './resign.js';
7
8
  export type Db = PgDatabase<PgQueryResultHKT, any, any>;
8
9
  /**
9
10
  * #47: a built-in sandbox/live split, so a stamped host does not invent its
@@ -12,6 +13,15 @@ export type Db = PgDatabase<PgQueryResultHKT, any, any>;
12
13
  * a presented secret is, same as before this existed.
13
14
  */
14
15
  export type KeyEnvironment = 'live' | 'test';
16
+ /**
17
+ * What a credential is for. `ordinary` is an app or user key a company may
18
+ * revoke. `company_root` is a company's service root: it can be rolled with
19
+ * `rotate()` but not removed through company key management. `platform_master`
20
+ * stays under the operator. A row of unknown purpose (older than this field)
21
+ * reads as `null`; nothing guesses it.
22
+ */
23
+ export type CredentialPurpose = 'ordinary' | 'company_root' | 'platform_master';
24
+ export declare const CREDENTIAL_PURPOSES: readonly CredentialPurpose[];
15
25
  export interface AuditEvent {
16
26
  readonly name: 'credential.minted' | 'credential.rotated' | 'credential.revoked';
17
27
  readonly credentialId: string;
@@ -28,8 +38,38 @@ export interface CreateCredentialIssuerOptions<TGrant> {
28
38
  readonly credential: SerializedCredential;
29
39
  /** The Worker's current Ed25519 public key, and its previous one during a Worker key-rotation window. */
30
40
  readonly verifyKeys: VerifyKeys;
31
- /** `credential.minted` / `credential.rotated` / `credential.revoked`, for the host's own audit chain. */
41
+ /**
42
+ * The signing generation `verifyKeys[1]` (`previous`) belongs to. When set,
43
+ * `check()` accepts the `previous` key only for a row labelled with this
44
+ * generation; any other row that verifies only under `previous` is
45
+ * `signature_invalid`. Unset, both keys are tried for every row. That is
46
+ * deprecated: 1.0.0 requires this whenever `previous` is passed.
47
+ *
48
+ * The label is not signed. Rollback is not prevented: someone who can write
49
+ * the database can restore an older row with its older signature.
50
+ */
51
+ readonly previousGenerationId?: string;
52
+ /**
53
+ * `credential.minted` / `credential.rotated` / `credential.revoked`, for the
54
+ * host's own audit chain. Called after the write has committed. A throw does
55
+ * not reach the caller: it goes to `onAuditError`, and the one-time secret is
56
+ * still returned and every remaining revoke event is still emitted.
57
+ */
32
58
  readonly audit?: AuditCallback;
59
+ /**
60
+ * Called with the event and the error when `audit` throws. Unset, one fixed
61
+ * line naming the event and the error's name is logged. Never receives a
62
+ * secret: events carry ids only.
63
+ */
64
+ readonly onAuditError?: (event: AuditEvent, error: unknown) => void;
65
+ /**
66
+ * Runs inside the transaction that makes the change, for hosts that keep
67
+ * events in the same database as `db`. The event and the change land
68
+ * together. A throw aborts the write: nothing is stored, and `issue()`,
69
+ * `rotate()` or `revoke()` throws. Pass `tx` to the same writer the host
70
+ * uses elsewhere, e.g. `recordEventInTransaction` from `./host`.
71
+ */
72
+ readonly auditInTransaction?: (tx: Db, event: AuditEvent) => Promise<void> | void;
33
73
  /** This host's split-secret prefix, e.g. `ai_live_`. Fixed per issuer; never inferred from a row. */
34
74
  readonly prefix: string;
35
75
  /**
@@ -46,15 +86,54 @@ export interface IssueRequest<TGrant> {
46
86
  readonly grants: readonly TGrant[];
47
87
  /** The id of the credential minting this one, or `null` for a root mint. */
48
88
  readonly minter: string | null;
49
- /** Unix milliseconds. Required: refused when missing or already past, never clamped to the minter's own. */
89
+ /** Unix milliseconds. Required: refused when missing, already past, or later than the minter's own -- never clamped. */
50
90
  readonly expiresAt: number;
51
91
  readonly idempotencyKey?: string;
52
92
  /** Default `'live'`. A child must match its minter's environment -- see `IssueRefusalReason`. */
53
93
  readonly environment?: KeyEnvironment;
94
+ /**
95
+ * Default `'ordinary'`. For trusted server code only: a host never fills it
96
+ * from a customer's request. A child (`minter` set) can only be `'ordinary'`.
97
+ */
98
+ readonly purpose?: CredentialPurpose;
99
+ /**
100
+ * The organisation a root belongs to. For trusted server code only. A child
101
+ * takes its minter's organisation and may not name a different one.
102
+ */
103
+ readonly organisationId?: string;
104
+ /**
105
+ * For trusted server code only. When the key is held by a stale row of this
106
+ * same minter (revoked or expired), `issue()` frees the key inside its own
107
+ * transaction, keeping the old row, and mints a new credential under it.
108
+ * A live row still answers as a replay.
109
+ */
110
+ readonly replaceStale?: boolean;
54
111
  }
112
+ /**
113
+ * Closed unions: each has a constant listing its members, pinned by `src/exports.test.ts`.
114
+ * Adding a member is a major change after 1.0.0. A union that embeds `WorkerErrorCode`
115
+ * spreads `WORKER_ERROR_CODES` into its list.
116
+ */
117
+ export { WORKER_ERROR_CODES } from '../worker-contract.js';
55
118
  export type IssueRefusalReason = 'expires_at_required' | 'expires_at_past' | 'minter_not_found' | 'minter_revoked' | 'minter_expired'
119
+ /** A child cannot outlive its minter: `request.expiresAt` is later than the minter row's own. Equal is allowed. */
120
+ | 'expires_after_minter'
121
+ /** A child asked for a purpose other than `'ordinary'`; nothing was signed. */
122
+ | 'purpose_not_allowed'
123
+ /** A child named an organisation that is not its minter's; nothing was signed. */
124
+ | 'organisation_mismatch'
125
+ /** The `idempotencyKey` is held by a row of this minter with other grants, environment or purpose. */
126
+ | 'idempotency_conflict'
127
+ /** The `idempotencyKey` is held by a row that has been revoked. Nothing was minted. */
128
+ | 'idempotent_row_revoked'
129
+ /** The `idempotencyKey` is held by a row that has expired. Nothing was minted. */
130
+ | 'idempotent_row_expired'
56
131
  /** #47: `request.environment` (or its `'live'` default) does not match the minter row's own. */
57
- | 'environment_mismatch' | WorkerErrorCode;
132
+ | 'environment_mismatch'
133
+ /** The Worker's signature does not verify against `verifyKeys`; nothing was stored. */
134
+ | 'bad_worker_signature' | WorkerErrorCode;
135
+ /** Every member of `IssueRefusalReason`. */
136
+ export declare const ISSUE_REFUSAL_REASONS: readonly ["expires_at_required", "expires_at_past", "minter_not_found", "minter_revoked", "minter_expired", "expires_after_minter", "purpose_not_allowed", "organisation_mismatch", "idempotency_conflict", "idempotent_row_revoked", "idempotent_row_expired", "environment_mismatch", "bad_worker_signature", "credential_invalid", "credential_expired", "credential_revoked", "grant_missing", "rate_limited", "bad_request", "aad_mismatch", "unknown_generation", "bad_minter_signature", "minter_expired", "minter_revoked", "minter_exceeded", "lineage_mismatch", "bad_old_signature", "unlogged_row", "not_in_lineage", "unreachable"];
58
137
  export type IssueResult = {
59
138
  readonly ok: true;
60
139
  readonly id: string;
@@ -64,29 +143,42 @@ export type IssueResult = {
64
143
  } | {
65
144
  readonly ok: false;
66
145
  readonly reason: IssueRefusalReason;
146
+ /** Only with `reason: 'rate_limited'`, when the Worker said how long to wait. */
147
+ readonly retryAfterMs?: number;
67
148
  };
68
149
  export type CheckRefusalReason = 'not_found' | 'signature_invalid' | 'revoked' | 'expired' | 'secret_mismatch'
69
150
  /** #45: `rateLimiter` refused this credential id for the current window. */
70
151
  | 'rate_limited';
152
+ /** Every member of `CheckRefusalReason`. */
153
+ export declare const CHECK_REFUSAL_REASONS: readonly ["not_found", "signature_invalid", "revoked", "expired", "secret_mismatch", "rate_limited"];
71
154
  export type CheckResult<TGrant> = {
72
155
  readonly ok: true;
73
156
  readonly id: string;
74
157
  readonly issuedById: string | null;
75
158
  readonly grants: readonly TGrant[];
76
159
  readonly environment: KeyEnvironment;
160
+ /** `null` on a row older than the purpose field. */
161
+ readonly purpose: CredentialPurpose | null;
162
+ readonly organisationId: string | null;
77
163
  } | {
78
164
  readonly ok: false;
79
165
  readonly reason: CheckRefusalReason;
80
166
  /** Only meaningful with `reason: 'rate_limited'`. */
81
167
  readonly retryAfterMs?: number;
82
168
  };
83
- export type RotateRefusalReason = 'signature_invalid' | 'conflict' | 'not_found' | 'revoked' | 'minter_not_found' | 'minter_revoked' | 'minter_expired' | WorkerErrorCode;
169
+ export type RotateRefusalReason = 'signature_invalid' | 'conflict' | 'not_found' | 'revoked' | 'minter_not_found' | 'minter_revoked' | 'minter_expired'
170
+ /** The Worker's signature does not verify against `verifyKeys`; the old secret still works. */
171
+ | 'bad_worker_signature' | WorkerErrorCode;
172
+ /** Every member of `RotateRefusalReason`. */
173
+ export declare const ROTATE_REFUSAL_REASONS: readonly ["signature_invalid", "conflict", "not_found", "revoked", "minter_not_found", "minter_revoked", "minter_expired", "bad_worker_signature", "credential_invalid", "credential_expired", "credential_revoked", "grant_missing", "rate_limited", "bad_request", "aad_mismatch", "unknown_generation", "bad_minter_signature", "minter_expired", "minter_revoked", "minter_exceeded", "lineage_mismatch", "bad_old_signature", "unlogged_row", "not_in_lineage", "unreachable"];
84
174
  export type RotateResult = {
85
175
  readonly ok: true;
86
176
  readonly secret: string;
87
177
  } | {
88
178
  readonly ok: false;
89
179
  readonly reason: RotateRefusalReason;
180
+ /** Only with `reason: 'rate_limited'`, when the Worker said how long to wait. */
181
+ readonly retryAfterMs?: number;
90
182
  };
91
183
  export interface CredentialLink<TGrant> {
92
184
  readonly id: string;
@@ -95,12 +187,38 @@ export interface CredentialLink<TGrant> {
95
187
  readonly expiresAt: number;
96
188
  readonly revokedAt: number | null;
97
189
  readonly environment: KeyEnvironment;
190
+ readonly purpose: CredentialPurpose | null;
191
+ readonly organisationId: string | null;
98
192
  }
193
+ /** Every reason `classify` refuses. Adding one is a major change after 1.0.0. */
194
+ export declare const CLASSIFY_REFUSAL_REASONS: readonly ["bad_request", "not_found", "already_classified"];
195
+ export type ClassifyResult = {
196
+ readonly ok: true;
197
+ } | {
198
+ readonly ok: false;
199
+ readonly reason: (typeof CLASSIFY_REFUSAL_REASONS)[number];
200
+ };
201
+ /** Every reason `revokeForCompany` refuses. Adding one is a major change after 1.0.0. */
202
+ export declare const REVOKE_FOR_COMPANY_REFUSAL_REASONS: readonly ["protected_credential", "purpose_unknown"];
203
+ export type RevokeForCompanyResult = {
204
+ readonly ok: true;
205
+ readonly revoked: readonly string[];
206
+ } | {
207
+ readonly ok: false;
208
+ readonly reason: (typeof REVOKE_FOR_COMPANY_REFUSAL_REASONS)[number];
209
+ };
99
210
  export interface CredentialIssuer<TGrant> {
100
211
  /** Calls `worker.signRow`. */
101
212
  issue(request: IssueRequest<TGrant>): Promise<IssueResult>;
102
- /** Fully local — never calls `worker`. */
103
- check(secret: string): Promise<CheckResult<TGrant>>;
213
+ /**
214
+ * Fully local — never calls `worker`. With `options.organisationId`, a row of
215
+ * any other organisation, or with none, answers exactly as a missing row does,
216
+ * before the signature, the secret, the state or the per-credential limit is
217
+ * looked at.
218
+ */
219
+ check(secret: string, options?: {
220
+ readonly organisationId?: string;
221
+ }): Promise<CheckResult<TGrant>>;
104
222
  /** Calls `worker.signRow`. */
105
223
  rotate(id: string, options: {
106
224
  readonly graceMs: number;
@@ -111,5 +229,28 @@ export interface CredentialIssuer<TGrant> {
111
229
  }): Promise<readonly string[]>;
112
230
  /** The chain from `id` to its root, `id` first. Fully local. */
113
231
  lineageOf(id: string): Promise<readonly CredentialLink<TGrant>[]>;
232
+ /**
233
+ * What company key management calls. Revokes `id` and, by default, its
234
+ * descendants, under the lifecycle lock. Refuses, and changes nothing, when
235
+ * the target or any live row the cascade would reach is `company_root`,
236
+ * `platform_master` or of unknown purpose. With `organisationId`, it also
237
+ * refuses (`protected_credential`) when any such live row belongs to another
238
+ * organisation or to none. Fully local.
239
+ */
240
+ revokeForCompany(id: string, options?: {
241
+ readonly cascade?: boolean;
242
+ readonly organisationId?: string;
243
+ }): Promise<RevokeForCompanyResult>;
244
+ /**
245
+ * For operator code: gives a row of unknown purpose its purpose, once. A row
246
+ * that already has one is refused. The Worker is not called and no
247
+ * signature changes.
248
+ */
249
+ classify(id: string, classification: {
250
+ readonly purpose: CredentialPurpose;
251
+ readonly organisationId?: string;
252
+ }): Promise<ClassifyResult>;
114
253
  }
254
+ /** The rate-limit id every `not_found` key is charged to. With an organisation, the id is `<this>:<organisation>`. */
255
+ export declare const UNKNOWN_KEY_BUCKET = "unknown-key";
115
256
  export declare function createCredentialIssuer<TGrant>(options: CreateCredentialIssuerOptions<TGrant>): CredentialIssuer<TGrant>;