terrascale 0.3.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.
Files changed (71) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +143 -0
  3. package/package.json +159 -0
  4. package/sdk-current-contract.json +27 -0
  5. package/sdk-route-manifest.json +67 -0
  6. package/src/admin.js +9 -0
  7. package/src/better-auth.js +14 -0
  8. package/src/config.js +121 -0
  9. package/src/database-codec.js +845 -0
  10. package/src/database-types.js +237 -0
  11. package/src/database-view.js +422 -0
  12. package/src/database.js +420 -0
  13. package/src/discovery.js +374 -0
  14. package/src/http.js +887 -0
  15. package/src/index.js +79 -0
  16. package/src/local/authentication.js +47 -0
  17. package/src/local/better-auth.js +517 -0
  18. package/src/local/cli.js +51 -0
  19. package/src/local/context.js +23 -0
  20. package/src/local/environment.js +109 -0
  21. package/src/local/index.js +204 -0
  22. package/src/local/router.js +999 -0
  23. package/src/local/server.js +664 -0
  24. package/src/local/store.js +530 -0
  25. package/src/local/test-environment.js +74 -0
  26. package/src/management-contracts.js +72 -0
  27. package/src/management.js +12 -0
  28. package/src/native-origin.js +75 -0
  29. package/src/postgres.js +494 -0
  30. package/src/react/core.js +743 -0
  31. package/src/react/index.js +99 -0
  32. package/src/result.js +251 -0
  33. package/src/schema.js +366 -0
  34. package/src/sql.js +996 -0
  35. package/src/svelte/index.js +129 -0
  36. package/src/tanstack/index.js +511 -0
  37. package/src/ts-auth-discovery.js +190 -0
  38. package/src/ts-auth.js +3497 -0
  39. package/types/admin.d.ts +6 -0
  40. package/types/better-auth.d.ts +8 -0
  41. package/types/config.d.ts +58 -0
  42. package/types/database-codec.d.ts +111 -0
  43. package/types/database-types.d.ts +213 -0
  44. package/types/database-view.d.ts +183 -0
  45. package/types/database.d.ts +98 -0
  46. package/types/discovery.d.ts +114 -0
  47. package/types/http.d.ts +46 -0
  48. package/types/index.d.ts +52 -0
  49. package/types/local/authentication.d.ts +11 -0
  50. package/types/local/better-auth.d.ts +33 -0
  51. package/types/local/cli.d.ts +2 -0
  52. package/types/local/context.d.ts +14 -0
  53. package/types/local/environment.d.ts +23 -0
  54. package/types/local/index.d.ts +94 -0
  55. package/types/local/router.d.ts +66 -0
  56. package/types/local/server.d.ts +54 -0
  57. package/types/local/store.d.ts +106 -0
  58. package/types/local/test-environment.d.ts +25 -0
  59. package/types/management-contracts.d.ts +44 -0
  60. package/types/management.d.ts +6 -0
  61. package/types/native-origin.d.ts +23 -0
  62. package/types/postgres.d.ts +123 -0
  63. package/types/react/core.d.ts +366 -0
  64. package/types/react/index.d.ts +54 -0
  65. package/types/result.d.ts +161 -0
  66. package/types/schema.d.ts +145 -0
  67. package/types/sql.d.ts +288 -0
  68. package/types/svelte/index.d.ts +81 -0
  69. package/types/tanstack/index.d.ts +165 -0
  70. package/types/ts-auth-discovery.d.ts +11 -0
  71. package/types/ts-auth.d.ts +1826 -0
@@ -0,0 +1,1826 @@
1
+ /**
2
+ * @param {TsAuthClientConfig} config
3
+ * @returns {TsAuthClient}
4
+ */
5
+ export function createTsAuthClient(config: TsAuthClientConfig): TsAuthClient;
6
+ /**
7
+ * Verifies a ts-auth webhook delivery signature: sha256=lowercaseHex(HMAC-
8
+ * SHA256(key = UTF8(signingSecret), message = UTF8(timestamp + "." + rawBody)))
9
+ * compared in constant time over the RAW body bytes. Malformed input returns
10
+ * false; this function never throws.
11
+ * @param {string} signingSecret
12
+ * @param {string | undefined} timestamp
13
+ * @param {string | undefined} signature
14
+ * @param {Uint8Array} payload
15
+ * @returns {Promise<boolean>}
16
+ */
17
+ export function verifyTsAuthWebhook(signingSecret: string, timestamp: string | undefined, signature: string | undefined, payload: Uint8Array): Promise<boolean>;
18
+ /**
19
+ * verifyTsAuthWebhook plus a replay window: the timestamp header must be
20
+ * within ±toleranceMs of `now` (milliseconds).
21
+ * @param {string} signingSecret
22
+ * @param {string | undefined} timestamp
23
+ * @param {string | undefined} signature
24
+ * @param {Uint8Array} payload
25
+ * @param {number} toleranceMs
26
+ * @param {number} now
27
+ * @returns {Promise<boolean>}
28
+ */
29
+ export function verifyTsAuthWebhookWithTolerance(signingSecret: string, timestamp: string | undefined, signature: string | undefined, payload: Uint8Array, toleranceMs: number, now: number): Promise<boolean>;
30
+ /** @import { TerraScaleResult } from "./result.js" */
31
+ /** @typedef {import("./config.js").TsAuthRuntimeConfig} TsAuthRuntimeConfig */
32
+ /**
33
+ * ts-auth is a separate hosted IdP service on its own origin. This client
34
+ * speaks that service's published management and OIDC contract, which mirrors
35
+ * the ts-auth service routes — not the TerraScale product /api/v1 producer
36
+ * contract. The deployment's public origin is `apiBaseUrl` and the instance
37
+ * `sk_` management key is `accessToken`.
38
+ * @typedef {Omit<TsAuthRuntimeConfig, "apiBaseUrl"> & {
39
+ * readonly apiBaseUrl: string; // The ts-auth deployment's public origin; there is no default.
40
+ * readonly instanceSlug: string; // The instance the `sk_` key belongs to; it prefixes every route.
41
+ * readonly useReverseProxy?: boolean; // Route public auth calls through the reverse proxy instead of regional discovery.
42
+ * }} TsAuthClientConfig
43
+ */
44
+ /**
45
+ * @typedef {{
46
+ * readonly signal?: AbortSignal | undefined;
47
+ * }} TsAuthRequestOptions
48
+ */
49
+ /**
50
+ * @typedef {{
51
+ * readonly id: string;
52
+ * readonly email: string | null;
53
+ * readonly email_verified: boolean;
54
+ * readonly username: string | null;
55
+ * readonly name: string | null;
56
+ * readonly banned: boolean;
57
+ * readonly ban_reason?: string | null | undefined; // Omitted by list responses; present on the full single-user view.
58
+ * readonly created_at: number; // Unix seconds.
59
+ * readonly last_sign_in_at?: number | null | undefined;
60
+ * readonly public_metadata: Record<string, unknown>;
61
+ * readonly private_metadata?: Record<string, unknown> | undefined;
62
+ * }} TsAuthUser
63
+ */
64
+ /**
65
+ * @typedef {{
66
+ * readonly id: string;
67
+ * readonly status: string;
68
+ * readonly created_at: number; // Unix seconds.
69
+ * readonly expires_at: number; // Unix seconds.
70
+ * readonly last_active_at?: number | null | undefined;
71
+ * readonly user_agent?: string | null | undefined;
72
+ * readonly ip_address?: string | null | undefined;
73
+ * }} TsAuthSession
74
+ */
75
+ /**
76
+ * @typedef {{
77
+ * readonly id: string;
78
+ * readonly type: string;
79
+ * readonly confirmed: boolean;
80
+ * readonly createdAt: number; // Unix seconds.
81
+ * }} TsAuthMfaFactor
82
+ */
83
+ /**
84
+ * @typedef {{
85
+ * readonly id: string;
86
+ * readonly nickname: string | null;
87
+ * readonly algorithm: string;
88
+ * readonly createdAt: number; // Unix seconds.
89
+ * readonly lastUsedAt: number | null; // Unix seconds.
90
+ * }} TsAuthPasskey
91
+ */
92
+ /**
93
+ * @typedef {{
94
+ * readonly id: string;
95
+ * readonly name: string;
96
+ * readonly slug: string;
97
+ * readonly created_at: number; // Unix seconds.
98
+ * }} TsAuthOrganization
99
+ */
100
+ /**
101
+ * @typedef {{
102
+ * readonly id: string;
103
+ * readonly role: string;
104
+ * readonly created_at: number; // Unix seconds.
105
+ * readonly organization: TsAuthOrganization | null;
106
+ * }} TsAuthUserOrganizationMembership
107
+ */
108
+ /**
109
+ * @typedef {{
110
+ * readonly token: string;
111
+ * readonly expires_at: number; // Unix seconds.
112
+ * }} TsAuthImpersonationSession
113
+ */
114
+ /** @typedef {{ readonly data: readonly TsAuthUser[] }} TsAuthUserPage */
115
+ /** @typedef {{ readonly data: readonly TsAuthSession[] }} TsAuthSessionPage */
116
+ /**
117
+ * @typedef {{ readonly data: readonly TsAuthMfaFactor[] }} TsAuthMfaFactorPage
118
+ */
119
+ /**
120
+ * @typedef {{ readonly passkeys: readonly TsAuthPasskey[] }} TsAuthPasskeyPage
121
+ */
122
+ /** @typedef {{ readonly data: readonly string[] }} TsAuthRecoveryCodePage */
123
+ /**
124
+ * @typedef {TsAuthRequestOptions & {
125
+ * readonly limit?: number | undefined; // 1 to 100; the service default is 20.
126
+ * readonly startingAfter?: string | undefined;
127
+ * }} TsAuthUserListOptions
128
+ */
129
+ /**
130
+ * @typedef {TsAuthRequestOptions & {
131
+ * readonly pageSize?: number | undefined;
132
+ * }} TsAuthUserListAllOptions
133
+ */
134
+ /**
135
+ * @typedef {{
136
+ * readonly email?: string | undefined;
137
+ * readonly username?: string | undefined;
138
+ * readonly password?: string | undefined;
139
+ * readonly name?: string | undefined;
140
+ * }} TsAuthCreateUserRequest
141
+ */
142
+ /**
143
+ * Tri-state user patch: an absent field leaves the stored value unchanged, an
144
+ * explicit unset sends JSON null, and a with-call sends the value. Email can
145
+ * only be set — the service rejects `email: null` with a 400.
146
+ */
147
+ export class TsAuthUserPatch {
148
+ /**
149
+ * @param {string} name
150
+ * @returns {this}
151
+ */
152
+ withName(name: string): this;
153
+ /** @returns {this} */
154
+ unsetName(): this;
155
+ /**
156
+ * @param {string} username
157
+ * @returns {this}
158
+ */
159
+ withUsername(username: string): this;
160
+ /** @returns {this} */
161
+ unsetUsername(): this;
162
+ /**
163
+ * @param {string} password
164
+ * @returns {this}
165
+ */
166
+ withPassword(password: string): this;
167
+ /** @returns {this} */
168
+ unsetPassword(): this;
169
+ /**
170
+ * @param {string} email
171
+ * @returns {this}
172
+ */
173
+ withEmail(email: string): this;
174
+ /**
175
+ * @param {boolean} banned
176
+ * @returns {this}
177
+ */
178
+ withBanned(banned: boolean): this;
179
+ /**
180
+ * @param {string} banReason
181
+ * @returns {this}
182
+ */
183
+ withBanReason(banReason: string): this;
184
+ /** @returns {this} */
185
+ unsetBanReason(): this;
186
+ /**
187
+ * @param {Record<string, unknown>} metadata
188
+ * @returns {this}
189
+ */
190
+ withPublicMetadata(metadata: Record<string, unknown>): this;
191
+ /** @returns {this} */
192
+ unsetPublicMetadata(): this;
193
+ /**
194
+ * @param {Record<string, unknown>} metadata
195
+ * @returns {this}
196
+ */
197
+ withPrivateMetadata(metadata: Record<string, unknown>): this;
198
+ /** @returns {this} */
199
+ unsetPrivateMetadata(): this;
200
+ /**
201
+ * The exact wire record: only configured fields are present.
202
+ * @returns {Record<string, unknown>}
203
+ */
204
+ toJSON(): Record<string, unknown>;
205
+ #private;
206
+ }
207
+ export class TsAuthUsersClient {
208
+ /**
209
+ * @param {TsAuthHttp} http
210
+ * @param {string} instanceSlug
211
+ */
212
+ constructor(http: TsAuthHttp, instanceSlug: string);
213
+ /**
214
+ * @param {TsAuthUserListOptions} [options={}]
215
+ * @returns {Promise<TerraScaleResult<TsAuthUserPage>>}
216
+ */
217
+ list(options?: TsAuthUserListOptions): Promise<TerraScaleResult<TsAuthUserPage>>;
218
+ /**
219
+ * Walks the id cursor until a short page; one request per page.
220
+ * @param {TsAuthUserListAllOptions} [options={}]
221
+ * @returns {Promise<TerraScaleResult<readonly TsAuthUser[]>>}
222
+ */
223
+ listAll(options?: TsAuthUserListAllOptions): Promise<TerraScaleResult<readonly TsAuthUser[]>>;
224
+ /**
225
+ * @param {string} userId
226
+ * @returns {Promise<TerraScaleResult<TsAuthUser>>}
227
+ */
228
+ get(userId: string): Promise<TerraScaleResult<TsAuthUser>>;
229
+ /**
230
+ * @param {TsAuthCreateUserRequest} request
231
+ * @returns {Promise<TerraScaleResult<TsAuthUser>>}
232
+ */
233
+ create(request: TsAuthCreateUserRequest): Promise<TerraScaleResult<TsAuthUser>>;
234
+ /**
235
+ * @param {string} userId
236
+ * @param {TsAuthUserPatch} patch
237
+ * @returns {Promise<TerraScaleResult<TsAuthUser>>}
238
+ */
239
+ update(userId: string, patch: TsAuthUserPatch): Promise<TerraScaleResult<TsAuthUser>>;
240
+ /**
241
+ * @param {string} userId
242
+ * @returns {Promise<TerraScaleResult<void>>}
243
+ */
244
+ delete(userId: string): Promise<TerraScaleResult<void>>;
245
+ /**
246
+ * @param {string} userId
247
+ * @returns {Promise<TerraScaleResult<TsAuthImpersonationSession>>}
248
+ */
249
+ impersonate(userId: string): Promise<TerraScaleResult<TsAuthImpersonationSession>>;
250
+ /**
251
+ * @param {string} userId
252
+ * @returns {Promise<TerraScaleResult<TsAuthSessionPage>>}
253
+ */
254
+ sessions(userId: string): Promise<TerraScaleResult<TsAuthSessionPage>>;
255
+ /**
256
+ * @param {string} userId
257
+ * @returns {Promise<TerraScaleResult<void>>}
258
+ */
259
+ revokeAllSessions(userId: string): Promise<TerraScaleResult<void>>;
260
+ /**
261
+ * @param {string} userId
262
+ * @returns {Promise<TerraScaleResult<TsAuthMfaFactorPage>>}
263
+ */
264
+ mfaFactors(userId: string): Promise<TerraScaleResult<TsAuthMfaFactorPage>>;
265
+ /**
266
+ * @param {string} userId
267
+ * @param {string} factorId
268
+ * @returns {Promise<TerraScaleResult<void>>}
269
+ */
270
+ deleteMfaFactor(userId: string, factorId: string): Promise<TerraScaleResult<void>>;
271
+ /**
272
+ * @param {string} userId
273
+ * @param {string} factorId
274
+ * @returns {Promise<TerraScaleResult<TsAuthRecoveryCodePage>>}
275
+ */
276
+ regenerateRecoveryCodes(userId: string, factorId: string): Promise<TerraScaleResult<TsAuthRecoveryCodePage>>;
277
+ /**
278
+ * @param {string} userId
279
+ * @returns {Promise<TerraScaleResult<TsAuthPasskeyPage>>}
280
+ */
281
+ passkeys(userId: string): Promise<TerraScaleResult<TsAuthPasskeyPage>>;
282
+ /**
283
+ * @param {string} userId
284
+ * @param {string} passkeyId
285
+ * @returns {Promise<TerraScaleResult<void>>}
286
+ */
287
+ deletePasskey(userId: string, passkeyId: string): Promise<TerraScaleResult<void>>;
288
+ /**
289
+ * @param {string} userId
290
+ * @returns {Promise<TerraScaleResult<readonly TsAuthUserOrganizationMembership[]>>}
291
+ */
292
+ organizations(userId: string): Promise<TerraScaleResult<readonly TsAuthUserOrganizationMembership[]>>;
293
+ #private;
294
+ }
295
+ export class TsAuthSessionsClient {
296
+ /**
297
+ * @param {TsAuthHttp} http
298
+ * @param {string} instanceSlug
299
+ */
300
+ constructor(http: TsAuthHttp, instanceSlug: string);
301
+ /**
302
+ * @param {string} sessionId
303
+ * @returns {Promise<TerraScaleResult<void>>}
304
+ */
305
+ revoke(sessionId: string): Promise<TerraScaleResult<void>>;
306
+ #private;
307
+ }
308
+ /**
309
+ * @typedef {{
310
+ * readonly id: string;
311
+ * readonly name: string;
312
+ * readonly api_key: string; // One-time full sk_ bearer; only the creating call returns it.
313
+ * readonly scopes: readonly string[];
314
+ * }} TsAuthApiKeyWithSecret
315
+ */
316
+ /**
317
+ * @typedef {{
318
+ * readonly id: string;
319
+ * readonly name: string;
320
+ * readonly scopes: readonly string[];
321
+ * readonly created_at: number; // Unix seconds.
322
+ * readonly last_used_at?: number | null | undefined;
323
+ * readonly revoked: boolean;
324
+ * }} TsAuthApiKey
325
+ */
326
+ /** @typedef {{ readonly data: readonly TsAuthApiKey[] }} TsAuthApiKeyPage */
327
+ /**
328
+ * @typedef {{
329
+ * readonly name: string;
330
+ * readonly scopes?: readonly string[] | undefined;
331
+ * }} TsAuthCreateApiKeyRequest
332
+ */
333
+ export class TsAuthApiKeysClient {
334
+ /**
335
+ * @param {TsAuthHttp} http
336
+ * @param {string} instanceSlug
337
+ */
338
+ constructor(http: TsAuthHttp, instanceSlug: string);
339
+ /**
340
+ * @param {TsAuthCreateApiKeyRequest} request
341
+ * @returns {Promise<TerraScaleResult<TsAuthApiKeyWithSecret>>}
342
+ */
343
+ create(request: TsAuthCreateApiKeyRequest): Promise<TerraScaleResult<TsAuthApiKeyWithSecret>>;
344
+ /** @returns {Promise<TerraScaleResult<TsAuthApiKeyPage>>} */
345
+ list(): Promise<TerraScaleResult<TsAuthApiKeyPage>>;
346
+ /**
347
+ * @param {string} keyId
348
+ * @returns {Promise<TerraScaleResult<void>>}
349
+ */
350
+ delete(keyId: string): Promise<TerraScaleResult<void>>;
351
+ #private;
352
+ }
353
+ /**
354
+ * @typedef {{
355
+ * readonly id: string;
356
+ * readonly organization_id: string;
357
+ * readonly user_id: string;
358
+ * readonly role: string;
359
+ * readonly created_at: number; // Unix seconds.
360
+ * }} TsAuthMembership
361
+ */
362
+ /**
363
+ * @typedef {TsAuthMembership & {
364
+ * readonly user: {
365
+ * readonly id: string;
366
+ * readonly email: string;
367
+ * readonly name: string;
368
+ * } | null;
369
+ * }} TsAuthMembershipWithUser
370
+ */
371
+ /**
372
+ * @typedef {{
373
+ * readonly id: string;
374
+ * readonly organization_id: string;
375
+ * readonly email: string;
376
+ * readonly role: string;
377
+ * readonly status: string;
378
+ * readonly expires_at: number; // Unix seconds.
379
+ * readonly created_at: number; // Unix seconds.
380
+ * }} TsAuthInvitation
381
+ */
382
+ /**
383
+ * @typedef {{
384
+ * readonly id: string;
385
+ * readonly organization_id: string;
386
+ * readonly domain: string;
387
+ * readonly created_at: number; // Unix seconds.
388
+ * }} TsAuthOrganizationDomain
389
+ */
390
+ /** @typedef {{ readonly org_id: string }} TsAuthDomainEnrollment */
391
+ /**
392
+ * @typedef {{
393
+ * readonly name: string;
394
+ * readonly slug?: string | undefined;
395
+ * }} TsAuthCreateOrganizationRequest
396
+ */
397
+ /**
398
+ * @typedef {{
399
+ * readonly name: string;
400
+ * }} TsAuthUpdateOrganizationRequest
401
+ */
402
+ /**
403
+ * @typedef {{
404
+ * readonly user_id: string;
405
+ * readonly role: string;
406
+ * }} TsAuthCreateMembershipRequest
407
+ */
408
+ /**
409
+ * @typedef {{
410
+ * readonly email: string;
411
+ * readonly role: string;
412
+ * }} TsAuthCreateInvitationRequest
413
+ */
414
+ /**
415
+ * @typedef {{
416
+ * readonly domain: string;
417
+ * }} TsAuthAddDomainRequest
418
+ */
419
+ /**
420
+ * @typedef {{
421
+ * readonly user_id: string;
422
+ * }} TsAuthEnrollRequest
423
+ */
424
+ export class TsAuthOrganizationsClient {
425
+ /**
426
+ * @param {TsAuthHttp} http
427
+ * @param {string} instanceSlug
428
+ */
429
+ constructor(http: TsAuthHttp, instanceSlug: string);
430
+ /**
431
+ * @param {TsAuthCreateOrganizationRequest} request
432
+ * @returns {Promise<TerraScaleResult<TsAuthOrganization>>}
433
+ */
434
+ create(request: TsAuthCreateOrganizationRequest): Promise<TerraScaleResult<TsAuthOrganization>>;
435
+ /** @returns {Promise<TerraScaleResult<readonly TsAuthOrganization[]>>} */
436
+ list(): Promise<TerraScaleResult<readonly TsAuthOrganization[]>>;
437
+ /**
438
+ * @param {string} organizationId
439
+ * @returns {Promise<TerraScaleResult<TsAuthOrganization>>}
440
+ */
441
+ get(organizationId: string): Promise<TerraScaleResult<TsAuthOrganization>>;
442
+ /**
443
+ * @param {string} organizationId
444
+ * @param {TsAuthUpdateOrganizationRequest} request
445
+ * @returns {Promise<TerraScaleResult<TsAuthOrganization>>}
446
+ */
447
+ update(organizationId: string, request: TsAuthUpdateOrganizationRequest): Promise<TerraScaleResult<TsAuthOrganization>>;
448
+ /**
449
+ * @param {string} organizationId
450
+ * @returns {Promise<TerraScaleResult<void>>}
451
+ */
452
+ delete(organizationId: string): Promise<TerraScaleResult<void>>;
453
+ /**
454
+ * @param {string} organizationId
455
+ * @param {TsAuthCreateMembershipRequest} request
456
+ * @returns {Promise<TerraScaleResult<TsAuthMembership>>}
457
+ */
458
+ createMembership(organizationId: string, request: TsAuthCreateMembershipRequest): Promise<TerraScaleResult<TsAuthMembership>>;
459
+ /**
460
+ * @param {string} organizationId
461
+ * @returns {Promise<TerraScaleResult<readonly TsAuthMembershipWithUser[]>>}
462
+ */
463
+ listMemberships(organizationId: string): Promise<TerraScaleResult<readonly TsAuthMembershipWithUser[]>>;
464
+ /**
465
+ * @param {string} organizationId
466
+ * @param {string} membershipId
467
+ * @param {{ readonly role: string }} request
468
+ * @returns {Promise<TerraScaleResult<TsAuthMembership>>}
469
+ */
470
+ updateMembership(organizationId: string, membershipId: string, request: {
471
+ readonly role: string;
472
+ }): Promise<TerraScaleResult<TsAuthMembership>>;
473
+ /**
474
+ * @param {string} organizationId
475
+ * @param {string} membershipId
476
+ * @returns {Promise<TerraScaleResult<void>>}
477
+ */
478
+ deleteMembership(organizationId: string, membershipId: string): Promise<TerraScaleResult<void>>;
479
+ /**
480
+ * @param {string} organizationId
481
+ * @param {TsAuthCreateInvitationRequest} request
482
+ * @returns {Promise<TerraScaleResult<TsAuthInvitation>>}
483
+ */
484
+ createInvitation(organizationId: string, request: TsAuthCreateInvitationRequest): Promise<TerraScaleResult<TsAuthInvitation>>;
485
+ /**
486
+ * @param {string} organizationId
487
+ * @returns {Promise<TerraScaleResult<readonly TsAuthInvitation[]>>}
488
+ */
489
+ listInvitations(organizationId: string): Promise<TerraScaleResult<readonly TsAuthInvitation[]>>;
490
+ /**
491
+ * @param {string} organizationId
492
+ * @param {string} invitationId
493
+ * @returns {Promise<TerraScaleResult<TsAuthInvitation>>}
494
+ */
495
+ revokeInvitation(organizationId: string, invitationId: string): Promise<TerraScaleResult<TsAuthInvitation>>;
496
+ /**
497
+ * @param {string} organizationId
498
+ * @param {TsAuthAddDomainRequest} request
499
+ * @returns {Promise<TerraScaleResult<TsAuthOrganizationDomain>>}
500
+ */
501
+ createDomain(organizationId: string, request: TsAuthAddDomainRequest): Promise<TerraScaleResult<TsAuthOrganizationDomain>>;
502
+ /**
503
+ * @param {string} organizationId
504
+ * @returns {Promise<TerraScaleResult<readonly TsAuthOrganizationDomain[]>>}
505
+ */
506
+ listDomains(organizationId: string): Promise<TerraScaleResult<readonly TsAuthOrganizationDomain[]>>;
507
+ /**
508
+ * @param {string} organizationId
509
+ * @param {string} domainId
510
+ * @returns {Promise<TerraScaleResult<void>>}
511
+ */
512
+ deleteDomain(organizationId: string, domainId: string): Promise<TerraScaleResult<void>>;
513
+ /**
514
+ * @param {string} domain
515
+ * @param {TsAuthEnrollRequest} request
516
+ * @returns {Promise<TerraScaleResult<TsAuthDomainEnrollment>>}
517
+ */
518
+ enrollDomain(domain: string, request: TsAuthEnrollRequest): Promise<TerraScaleResult<TsAuthDomainEnrollment>>;
519
+ #private;
520
+ }
521
+ /**
522
+ * @typedef {"authorization_code"
523
+ * | "refresh_token"
524
+ * | "client_credentials"
525
+ * | "urn:ietf:params:oauth:grant-type:device_code"} TsAuthOauthGrantType
526
+ */
527
+ /**
528
+ * @typedef {"none"
529
+ * | "client_secret_post"
530
+ * | "client_secret_basic"} TsAuthOauthClientAuthMethod
531
+ */
532
+ /**
533
+ * @typedef {{
534
+ * readonly name?: string | undefined;
535
+ * readonly redirect_uris?: readonly string[] | undefined;
536
+ * readonly post_logout_redirect_uris?: readonly string[] | undefined;
537
+ * readonly public?: boolean | undefined;
538
+ * readonly token_endpoint_auth_method?: TsAuthOauthClientAuthMethod | undefined;
539
+ * readonly allowed_origins?: readonly string[] | undefined;
540
+ * readonly allow_anonymous?: boolean | undefined;
541
+ * readonly allowed_resource_audiences?: readonly string[] | undefined;
542
+ * readonly allowed_scopes?: readonly string[] | undefined;
543
+ * readonly allowed_grant_types?: readonly TsAuthOauthGrantType[] | undefined;
544
+ * }} TsAuthCreateOauthClientRequest
545
+ */
546
+ /**
547
+ * @typedef {Omit<TsAuthCreateOauthClientRequest, "public" | "token_endpoint_auth_method"> & {
548
+ * readonly expected_auth_epoch?: number | undefined;
549
+ * readonly enabled?: boolean | undefined;
550
+ * readonly rotate_secret?: boolean | undefined;
551
+ * }} TsAuthUpdateOauthClientRequest
552
+ */
553
+ /**
554
+ * @typedef {{
555
+ * readonly id: string;
556
+ * readonly client_id: string;
557
+ * readonly name: string;
558
+ * readonly redirect_uris: readonly string[];
559
+ * readonly post_logout_redirect_uris: readonly string[];
560
+ * readonly token_endpoint_auth_method: TsAuthOauthClientAuthMethod;
561
+ * readonly public: boolean;
562
+ * readonly allowed_origins: readonly string[];
563
+ * readonly allow_anonymous: boolean;
564
+ * readonly created_at: number;
565
+ * readonly allowed_resource_audiences: readonly string[];
566
+ * readonly allowed_scopes: readonly string[];
567
+ * readonly allowed_grant_types: readonly TsAuthOauthGrantType[];
568
+ * readonly auth_epoch: number; // JSON u64 values outside JavaScript's exact integer range are rejected.
569
+ * readonly enabled: boolean;
570
+ * }} TsAuthOauthClientView
571
+ */
572
+ /**
573
+ * @typedef {{
574
+ * readonly client: TsAuthOauthClientView;
575
+ * readonly client_secret: string | null;
576
+ * }} TsAuthOauthClientWithSecret
577
+ */
578
+ /**
579
+ * @typedef {{
580
+ * readonly clients: readonly TsAuthOauthClientView[];
581
+ * }} TsAuthOauthClientList
582
+ */
583
+ /**
584
+ * @typedef {TsAuthOauthClientView
585
+ * | TsAuthOauthClientWithSecret} TsAuthOauthClientUpdate
586
+ */
587
+ export class TsAuthOauthClientsClient {
588
+ /**
589
+ * @param {TsAuthHttp} http
590
+ * @param {string} instanceSlug
591
+ */
592
+ constructor(http: TsAuthHttp, instanceSlug: string);
593
+ /**
594
+ * @param {TsAuthCreateOauthClientRequest} request
595
+ * @returns {Promise<TerraScaleResult<TsAuthOauthClientWithSecret>>}
596
+ */
597
+ create(request: TsAuthCreateOauthClientRequest): Promise<TerraScaleResult<TsAuthOauthClientWithSecret>>;
598
+ /** @returns {Promise<TerraScaleResult<TsAuthOauthClientList>>} */
599
+ list(): Promise<TerraScaleResult<TsAuthOauthClientList>>;
600
+ /**
601
+ * @param {string} clientId
602
+ * @param {TsAuthUpdateOauthClientRequest} request
603
+ * @returns {Promise<TerraScaleResult<TsAuthOauthClientUpdate>>}
604
+ */
605
+ update(clientId: string, request: TsAuthUpdateOauthClientRequest): Promise<TerraScaleResult<TsAuthOauthClientUpdate>>;
606
+ /**
607
+ * @param {string} clientId
608
+ * @returns {Promise<TerraScaleResult<void>>}
609
+ */
610
+ delete(clientId: string): Promise<TerraScaleResult<void>>;
611
+ #private;
612
+ }
613
+ /**
614
+ * @typedef {{
615
+ * readonly audience: string;
616
+ * readonly allowed_client_ids: readonly string[];
617
+ * readonly allowed_grant_types: readonly TsAuthOauthGrantType[];
618
+ * readonly allowed_scopes: readonly string[];
619
+ * }} TsAuthCreateOauthResourceRequest
620
+ */
621
+ /**
622
+ * @typedef {{
623
+ * readonly expected_auth_epoch: number;
624
+ * readonly allowed_client_ids?: readonly string[] | undefined;
625
+ * readonly allowed_grant_types?: readonly TsAuthOauthGrantType[] | undefined;
626
+ * readonly allowed_scopes?: readonly string[] | undefined;
627
+ * readonly enabled?: boolean | undefined;
628
+ * readonly rotate_secret?: boolean | undefined;
629
+ * }} TsAuthUpdateOauthResourceRequest
630
+ */
631
+ /**
632
+ * @typedef {TsAuthCreateOauthResourceRequest & {
633
+ * readonly id: string;
634
+ * readonly introspection_client_id: string;
635
+ * readonly token_endpoint_auth_method: "client_secret_basic";
636
+ * readonly auth_epoch: number;
637
+ * readonly enabled: boolean;
638
+ * readonly created_at: number;
639
+ * readonly updated_at: number;
640
+ * }} TsAuthOauthResourceView
641
+ */
642
+ /**
643
+ * @typedef {{
644
+ * readonly resource: TsAuthOauthResourceView;
645
+ * readonly introspection_secret: string | null;
646
+ * }} TsAuthOauthResourceWithSecret
647
+ */
648
+ /**
649
+ * @typedef {{
650
+ * readonly resources: readonly TsAuthOauthResourceView[];
651
+ * }} TsAuthOauthResourceList
652
+ */
653
+ export class TsAuthOauthResourcesClient {
654
+ /**
655
+ * @param {TsAuthHttp} http
656
+ * @param {string} instanceSlug
657
+ */
658
+ constructor(http: TsAuthHttp, instanceSlug: string);
659
+ /**
660
+ * @param {TsAuthCreateOauthResourceRequest} request
661
+ * @returns {Promise<TerraScaleResult<TsAuthOauthResourceWithSecret>>}
662
+ */
663
+ create(request: TsAuthCreateOauthResourceRequest): Promise<TerraScaleResult<TsAuthOauthResourceWithSecret>>;
664
+ /** @returns {Promise<TerraScaleResult<TsAuthOauthResourceList>>} */
665
+ list(): Promise<TerraScaleResult<TsAuthOauthResourceList>>;
666
+ /**
667
+ * @param {string} resourceId
668
+ * @param {TsAuthUpdateOauthResourceRequest} request
669
+ * @returns {Promise<TerraScaleResult<TsAuthOauthResourceWithSecret>>}
670
+ */
671
+ update(resourceId: string, request: TsAuthUpdateOauthResourceRequest): Promise<TerraScaleResult<TsAuthOauthResourceWithSecret>>;
672
+ /**
673
+ * Disables the resource; its registered identity remains reserved.
674
+ * @param {string} resourceId
675
+ * @returns {Promise<TerraScaleResult<void>>}
676
+ */
677
+ revoke(resourceId: string): Promise<TerraScaleResult<void>>;
678
+ #private;
679
+ }
680
+ /**
681
+ * @typedef {{
682
+ * readonly id: string;
683
+ * readonly type: "oidc" | "saml";
684
+ * readonly name: string;
685
+ * readonly enabled: boolean;
686
+ * readonly org_id: string | null;
687
+ * readonly issuer_url: string | null;
688
+ * readonly client_id: string | null;
689
+ * readonly authorization_endpoint: string | null;
690
+ * readonly token_endpoint: string | null;
691
+ * readonly userinfo_endpoint: string | null;
692
+ * readonly idp_entity_id: string | null;
693
+ * readonly sso_redirect_url: string | null;
694
+ * readonly sp_entity_id: string | null;
695
+ * readonly created_at: number; // Unix seconds.
696
+ * }} TsAuthConnectionView
697
+ */
698
+ /**
699
+ * @typedef {{
700
+ * readonly type: "oidc";
701
+ * readonly name: string;
702
+ * readonly org_id?: string | undefined;
703
+ * readonly issuer_url: string;
704
+ * readonly client_id: string;
705
+ * readonly client_secret: string;
706
+ * readonly scopes?: readonly string[] | undefined;
707
+ * readonly authorization_endpoint?: string | undefined;
708
+ * readonly token_endpoint?: string | undefined;
709
+ * readonly userinfo_endpoint?: string | undefined;
710
+ * }
711
+ * | {
712
+ * readonly type: "saml";
713
+ * readonly name: string;
714
+ * readonly org_id?: string | undefined;
715
+ * readonly idp_entity_id: string;
716
+ * readonly sso_redirect_url: string;
717
+ * readonly x509_certificate_pem: string;
718
+ * }} TsAuthCreateConnectionRequest
719
+ */
720
+ /**
721
+ * @typedef {{
722
+ * readonly enabled?: boolean | undefined;
723
+ * readonly name?: string | undefined;
724
+ * readonly client_secret?: string | undefined;
725
+ * }} TsAuthConnectionPatch
726
+ */
727
+ export class TsAuthConnectionsClient {
728
+ /**
729
+ * @param {TsAuthHttp} http
730
+ * @param {string} instanceSlug
731
+ */
732
+ constructor(http: TsAuthHttp, instanceSlug: string);
733
+ /**
734
+ * @param {TsAuthCreateConnectionRequest} request
735
+ * @returns {Promise<TerraScaleResult<TsAuthConnectionView>>}
736
+ */
737
+ create(request: TsAuthCreateConnectionRequest): Promise<TerraScaleResult<TsAuthConnectionView>>;
738
+ /**
739
+ * @returns {Promise<TerraScaleResult<{ readonly data: readonly TsAuthConnectionView[] }>>}
740
+ */
741
+ list(): Promise<TerraScaleResult<{
742
+ readonly data: readonly TsAuthConnectionView[];
743
+ }>>;
744
+ /**
745
+ * @param {string} connectionId
746
+ * @param {TsAuthConnectionPatch} request
747
+ * @returns {Promise<TerraScaleResult<TsAuthConnectionView>>}
748
+ */
749
+ update(connectionId: string, request: TsAuthConnectionPatch): Promise<TerraScaleResult<TsAuthConnectionView>>;
750
+ /**
751
+ * @param {string} connectionId
752
+ * @returns {Promise<TerraScaleResult<void>>}
753
+ */
754
+ delete(connectionId: string): Promise<TerraScaleResult<void>>;
755
+ #private;
756
+ }
757
+ /**
758
+ * @typedef {{
759
+ * readonly id: string;
760
+ * readonly org_id: string | null;
761
+ * readonly token: string; // One-time SCIM bearer; only create and rotate return it.
762
+ * }} TsAuthDirectoryWithToken
763
+ */
764
+ /**
765
+ * @typedef {{
766
+ * readonly id: string;
767
+ * readonly org_id: string | null;
768
+ * readonly created_at: number; // Unix seconds.
769
+ * }} TsAuthDirectory
770
+ */
771
+ export class TsAuthDirectoriesClient {
772
+ /**
773
+ * @param {TsAuthHttp} http
774
+ * @param {string} instanceSlug
775
+ */
776
+ constructor(http: TsAuthHttp, instanceSlug: string);
777
+ /**
778
+ * @param {{ readonly org_id?: string | undefined }} [request={}]
779
+ * @returns {Promise<TerraScaleResult<TsAuthDirectoryWithToken>>}
780
+ */
781
+ create(request?: {
782
+ readonly org_id?: string | undefined;
783
+ }): Promise<TerraScaleResult<TsAuthDirectoryWithToken>>;
784
+ /**
785
+ * @returns {Promise<TerraScaleResult<{ readonly data: readonly TsAuthDirectory[] }>>}
786
+ */
787
+ list(): Promise<TerraScaleResult<{
788
+ readonly data: readonly TsAuthDirectory[];
789
+ }>>;
790
+ /**
791
+ * @param {string} directoryId
792
+ * @returns {Promise<TerraScaleResult<TsAuthDirectoryWithToken>>}
793
+ */
794
+ rotate(directoryId: string): Promise<TerraScaleResult<TsAuthDirectoryWithToken>>;
795
+ /**
796
+ * @param {string} directoryId
797
+ * @returns {Promise<TerraScaleResult<void>>}
798
+ */
799
+ delete(directoryId: string): Promise<TerraScaleResult<void>>;
800
+ #private;
801
+ }
802
+ export class TsAuthJwtTemplatesClient {
803
+ /**
804
+ * @param {TsAuthHttp} http
805
+ * @param {string} instanceSlug
806
+ */
807
+ constructor(http: TsAuthHttp, instanceSlug: string);
808
+ /**
809
+ * @param {TsAuthCreateJwtTemplateRequest} request
810
+ * @returns {Promise<TerraScaleResult<TsAuthJwtTemplate>>}
811
+ */
812
+ create(request: TsAuthCreateJwtTemplateRequest): Promise<TerraScaleResult<TsAuthJwtTemplate>>;
813
+ /** @returns {Promise<TerraScaleResult<readonly TsAuthJwtTemplate[]>>} */
814
+ list(): Promise<TerraScaleResult<readonly TsAuthJwtTemplate[]>>;
815
+ /**
816
+ * @param {string} name
817
+ * @param {TsAuthUpdateJwtTemplateRequest} request
818
+ * @returns {Promise<TerraScaleResult<TsAuthJwtTemplate>>}
819
+ */
820
+ update(name: string, request: TsAuthUpdateJwtTemplateRequest): Promise<TerraScaleResult<TsAuthJwtTemplate>>;
821
+ /**
822
+ * @param {string} name
823
+ * @returns {Promise<TerraScaleResult<void>>}
824
+ */
825
+ delete(name: string): Promise<TerraScaleResult<void>>;
826
+ /**
827
+ * @param {string} name
828
+ * @param {{ readonly user_id: string }} request
829
+ * @returns {Promise<TerraScaleResult<TsAuthJwtTokenResponse>>}
830
+ */
831
+ issueToken(name: string, request: {
832
+ readonly user_id: string;
833
+ }): Promise<TerraScaleResult<TsAuthJwtTokenResponse>>;
834
+ #private;
835
+ }
836
+ /**
837
+ * @typedef {{
838
+ * readonly id: string;
839
+ * readonly url: string;
840
+ * readonly events: readonly string[];
841
+ * readonly signing_secret: string; // One-time HMAC key for verifying deliveries; only create returns it.
842
+ * }} TsAuthWebhookWithSecret
843
+ */
844
+ /**
845
+ * @typedef {{
846
+ * readonly id: string;
847
+ * readonly url: string;
848
+ * readonly events: readonly string[];
849
+ * readonly enabled: boolean;
850
+ * readonly created_at: number; // Unix seconds.
851
+ * }} TsAuthWebhook
852
+ */
853
+ /**
854
+ * @typedef {{
855
+ * readonly id: string; // endpointId:eventId
856
+ * readonly endpoint_id: string;
857
+ * readonly event_id: string;
858
+ * readonly attempts: number;
859
+ * readonly last_error?: string | undefined;
860
+ * readonly updated_at: number; // Unix seconds.
861
+ * }} TsAuthDeadLetterEntry
862
+ */
863
+ export class TsAuthWebhooksClient {
864
+ /**
865
+ * @param {TsAuthHttp} http
866
+ * @param {string} instanceSlug
867
+ */
868
+ constructor(http: TsAuthHttp, instanceSlug: string);
869
+ /**
870
+ * @param {{ readonly url: string; readonly events: readonly string[] }} request
871
+ * @returns {Promise<TerraScaleResult<TsAuthWebhookWithSecret>>}
872
+ */
873
+ create(request: {
874
+ readonly url: string;
875
+ readonly events: readonly string[];
876
+ }): Promise<TerraScaleResult<TsAuthWebhookWithSecret>>;
877
+ /** @returns {Promise<TerraScaleResult<readonly TsAuthWebhook[]>>} */
878
+ list(): Promise<TerraScaleResult<readonly TsAuthWebhook[]>>;
879
+ /**
880
+ * @param {string} webhookId
881
+ * @returns {Promise<TerraScaleResult<void>>}
882
+ */
883
+ delete(webhookId: string): Promise<TerraScaleResult<void>>;
884
+ /**
885
+ * @param {string} webhookId
886
+ * @returns {Promise<TerraScaleResult<{ readonly queued: boolean }>>}
887
+ */
888
+ test(webhookId: string): Promise<TerraScaleResult<{
889
+ readonly queued: boolean;
890
+ }>>;
891
+ /** @returns {Promise<TerraScaleResult<readonly TsAuthDeadLetterEntry[]>>} */
892
+ deadLetter(): Promise<TerraScaleResult<readonly TsAuthDeadLetterEntry[]>>;
893
+ /**
894
+ * @param {string} entryId
895
+ * @returns {Promise<TerraScaleResult<{ readonly replayed: boolean }>>}
896
+ */
897
+ replayDeadLetter(entryId: string): Promise<TerraScaleResult<{
898
+ readonly replayed: boolean;
899
+ }>>;
900
+ #private;
901
+ }
902
+ /**
903
+ * @typedef {{
904
+ * readonly id: string;
905
+ * readonly instance_id: string;
906
+ * readonly type: string;
907
+ * readonly actor_id?: string | undefined; // Omitted from the wire when null.
908
+ * readonly data: Record<string, unknown>;
909
+ * readonly created_at: number; // Unix seconds.
910
+ * readonly integrity_version: number;
911
+ * readonly integrity_hash: string;
912
+ * readonly integrity_signature: string | null; // Both are null when the instance has no audit signing key.
913
+ * readonly integrity_key_fingerprint: string | null;
914
+ * }} TsAuthAuditEvent
915
+ */
916
+ export class TsAuthAuditEventsClient {
917
+ /**
918
+ * @param {TsAuthHttp} http
919
+ * @param {string} instanceSlug
920
+ */
921
+ constructor(http: TsAuthHttp, instanceSlug: string);
922
+ /**
923
+ * @param {TsAuthRequestOptions & { readonly limit?: number | undefined }} [options={}]
924
+ * @returns {Promise<TerraScaleResult<readonly TsAuthAuditEvent[]>>}
925
+ */
926
+ list(options?: TsAuthRequestOptions & {
927
+ readonly limit?: number | undefined;
928
+ }): Promise<TerraScaleResult<readonly TsAuthAuditEvent[]>>;
929
+ #private;
930
+ }
931
+ /**
932
+ * @typedef {{
933
+ * readonly plan: "free" | "pro" | "enterprise";
934
+ * readonly status: string;
935
+ * readonly stripe_customer_id?: string | undefined;
936
+ * readonly stripe_subscription_id?: string | undefined;
937
+ * readonly current_period_end?: number | undefined;
938
+ * readonly user_count: number;
939
+ * readonly quota: number;
940
+ * }} TsAuthBillingOverview
941
+ */
942
+ export class TsAuthBillingClient {
943
+ /**
944
+ * @param {TsAuthHttp} http
945
+ * @param {string} instanceSlug
946
+ */
947
+ constructor(http: TsAuthHttp, instanceSlug: string);
948
+ /** @returns {Promise<TerraScaleResult<TsAuthBillingOverview>>} */
949
+ get(): Promise<TerraScaleResult<TsAuthBillingOverview>>;
950
+ /**
951
+ * @param {{ readonly plan: "pro" | "enterprise" }} request
952
+ * @returns {Promise<TerraScaleResult<{ readonly checkout_url: string }>>}
953
+ */
954
+ checkout(request: {
955
+ readonly plan: "pro" | "enterprise";
956
+ }): Promise<TerraScaleResult<{
957
+ readonly checkout_url: string;
958
+ }>>;
959
+ /** @returns {Promise<TerraScaleResult<{ readonly portal_url: string }>>} */
960
+ portal(): Promise<TerraScaleResult<{
961
+ readonly portal_url: string;
962
+ }>>;
963
+ /**
964
+ * @param {{ readonly current_users: number }} request
965
+ * @returns {Promise<TerraScaleResult<{ readonly allowed: boolean; readonly plan: string; readonly quota: number }>>}
966
+ */
967
+ enforceCheck(request: {
968
+ readonly current_users: number;
969
+ }): Promise<TerraScaleResult<{
970
+ readonly allowed: boolean;
971
+ readonly plan: string;
972
+ readonly quota: number;
973
+ }>>;
974
+ /**
975
+ * @returns {Promise<TerraScaleResult<{ readonly claims_examined: number; readonly claims_removed: number; readonly claims_retained: number }>>}
976
+ */
977
+ reconcileQuota(): Promise<TerraScaleResult<{
978
+ readonly claims_examined: number;
979
+ readonly claims_removed: number;
980
+ readonly claims_retained: number;
981
+ }>>;
982
+ #private;
983
+ }
984
+ /**
985
+ * @typedef {{
986
+ * readonly id: string;
987
+ * readonly slug: string;
988
+ * readonly name: string;
989
+ * readonly logo_url?: string | null | undefined;
990
+ * readonly theme_color?: string | null | undefined;
991
+ * readonly created_at: number; // Unix seconds.
992
+ * }} TsAuthInstance
993
+ */
994
+ /**
995
+ * The PATCH response omits created_at.
996
+ * @typedef {Omit<TsAuthInstance, "created_at">} TsAuthInstanceUpdateResponse
997
+ */
998
+ /**
999
+ * Absent leaves the stored value unchanged; the service treats null the same as absent.
1000
+ * @typedef {{
1001
+ * readonly name?: string | undefined;
1002
+ * readonly logo_url?: string | undefined;
1003
+ * readonly theme_color?: string | undefined;
1004
+ * }} TsAuthInstanceUpdateRequest
1005
+ */
1006
+ export class TsAuthInstanceClient {
1007
+ /**
1008
+ * @param {TsAuthHttp} http
1009
+ * @param {string} instanceSlug
1010
+ */
1011
+ constructor(http: TsAuthHttp, instanceSlug: string);
1012
+ /** @returns {Promise<TerraScaleResult<TsAuthInstance>>} */
1013
+ get(): Promise<TerraScaleResult<TsAuthInstance>>;
1014
+ /**
1015
+ * @param {TsAuthInstanceUpdateRequest} request
1016
+ * @returns {Promise<TerraScaleResult<TsAuthInstanceUpdateResponse>>}
1017
+ */
1018
+ update(request: TsAuthInstanceUpdateRequest): Promise<TerraScaleResult<TsAuthInstanceUpdateResponse>>;
1019
+ #private;
1020
+ }
1021
+ /**
1022
+ * @typedef {{
1023
+ * readonly issuer: string;
1024
+ * readonly authorization_endpoint: string;
1025
+ * readonly token_endpoint: string;
1026
+ * readonly userinfo_endpoint: string;
1027
+ * readonly jwks_uri: string;
1028
+ * readonly revocation_endpoint: string;
1029
+ * readonly introspection_endpoint: string;
1030
+ * readonly device_authorization_endpoint: string;
1031
+ * readonly end_session_endpoint: string;
1032
+ * readonly response_types_supported: readonly string[];
1033
+ * readonly grant_types_supported: readonly string[];
1034
+ * readonly code_challenge_methods_supported: readonly string[];
1035
+ * readonly subject_types_supported: readonly string[];
1036
+ * readonly id_token_signing_alg_values_supported: readonly string[];
1037
+ * readonly token_endpoint_auth_methods_supported: readonly string[];
1038
+ * readonly scopes_supported: readonly string[];
1039
+ * }} TsAuthOidcDiscovery
1040
+ */
1041
+ /**
1042
+ * @typedef {{
1043
+ * readonly kty: "EC";
1044
+ * readonly crv: "P-256";
1045
+ * readonly alg: "ES256";
1046
+ * readonly use: "sig";
1047
+ * readonly kid: string;
1048
+ * readonly x: string;
1049
+ * readonly y: string;
1050
+ * }} TsAuthOidcJwk
1051
+ */
1052
+ /** @typedef {{ readonly keys: readonly TsAuthOidcJwk[] }} TsAuthOidcJwks */
1053
+ /**
1054
+ * @typedef {{
1055
+ * readonly client_id: string;
1056
+ * readonly redirect_uri: string;
1057
+ * readonly response_type: "code";
1058
+ * readonly scope?: string | undefined;
1059
+ * readonly resource?: string | undefined;
1060
+ * readonly state?: string | undefined;
1061
+ * readonly nonce?: string | undefined;
1062
+ * readonly code_challenge?: string | undefined;
1063
+ * readonly code_challenge_method?: "S256" | undefined;
1064
+ * readonly prompt?:
1065
+ * | "none"
1066
+ * | "login"
1067
+ * | "consent"
1068
+ * | "login consent"
1069
+ * | "consent login"
1070
+ * | undefined;
1071
+ * }} TsAuthOidcAuthorizationRequest
1072
+ */
1073
+ /**
1074
+ * @typedef {{
1075
+ * readonly scope?: string | undefined;
1076
+ * readonly resource?: string | undefined;
1077
+ * }} TsAuthOidcDeviceAuthorizationRequest
1078
+ */
1079
+ /**
1080
+ * @typedef {{
1081
+ * readonly device_code: string;
1082
+ * readonly user_code: string;
1083
+ * readonly verification_uri: string;
1084
+ * readonly verification_uri_complete: string;
1085
+ * readonly expires_in: number;
1086
+ * readonly interval: number;
1087
+ * }} TsAuthOidcDeviceAuthorizationResponse
1088
+ */
1089
+ /**
1090
+ * @typedef {{
1091
+ * readonly grant_type: "authorization_code";
1092
+ * readonly code: string;
1093
+ * readonly redirect_uri: string;
1094
+ * readonly code_verifier?: string | undefined;
1095
+ * readonly resource?: string | undefined;
1096
+ * }
1097
+ * | {
1098
+ * readonly grant_type: "refresh_token";
1099
+ * readonly refresh_token: string;
1100
+ * readonly scope?: string | undefined;
1101
+ * readonly resource?: string | undefined;
1102
+ * }
1103
+ * | {
1104
+ * readonly grant_type: "client_credentials";
1105
+ * readonly scope: string;
1106
+ * readonly resource: string;
1107
+ * }
1108
+ * | {
1109
+ * readonly grant_type: "urn:ietf:params:oauth:grant-type:device_code";
1110
+ * readonly device_code: string;
1111
+ * readonly resource?: string | undefined;
1112
+ * }} TsAuthOidcTokenRequest
1113
+ */
1114
+ /**
1115
+ * @typedef {{
1116
+ * readonly access_token: string;
1117
+ * readonly token_type: "Bearer";
1118
+ * readonly expires_in: number;
1119
+ * readonly scope: string;
1120
+ * readonly refresh_token?: string | null | undefined; // Omitted for client_credentials; nullable for user code/device issuance.
1121
+ * readonly id_token?: string | undefined; // Present only on code/device issuance with openid scope; omitted on refresh.
1122
+ * }} TsAuthOidcTokenResponse
1123
+ */
1124
+ /** @typedef {{ readonly active: false }} TsAuthOidcInactiveIntrospection */
1125
+ /**
1126
+ * @typedef {{
1127
+ * readonly active: true;
1128
+ * readonly token_type: "Bearer";
1129
+ * readonly iss: string;
1130
+ * readonly sub: string;
1131
+ * readonly aud: string;
1132
+ * readonly client_id: string;
1133
+ * readonly scope: string;
1134
+ * readonly exp: number;
1135
+ * readonly iat: number;
1136
+ * readonly sid: string | null;
1137
+ * readonly principal_kind: "user" | "service";
1138
+ * }} TsAuthOidcAccessIntrospection
1139
+ */
1140
+ /**
1141
+ * @typedef {Omit<TsAuthOidcAccessIntrospection, "token_type" | "principal_kind"> & {
1142
+ * readonly token_type: "refresh_token";
1143
+ * readonly family_id: string;
1144
+ * }} TsAuthOidcRefreshIntrospection
1145
+ */
1146
+ /**
1147
+ * @typedef {TsAuthOidcInactiveIntrospection
1148
+ * | TsAuthOidcAccessIntrospection
1149
+ * | TsAuthOidcRefreshIntrospection} TsAuthOidcIntrospection
1150
+ */
1151
+ /**
1152
+ * @typedef {Omit<TsAuthOidcAccessIntrospection, "sid" | "principal_kind"> &
1153
+ * (
1154
+ * | { readonly principal_kind: "user"; readonly sid: string }
1155
+ * | { readonly principal_kind: "service"; readonly sid: null }
1156
+ * )} TsAuthOidcResourceAccessIntrospection
1157
+ */
1158
+ /**
1159
+ * @typedef {TsAuthOidcInactiveIntrospection
1160
+ * | TsAuthOidcResourceAccessIntrospection} TsAuthOidcResourceIntrospection
1161
+ */
1162
+ /**
1163
+ * @typedef {{
1164
+ * readonly issuer: string; // Configured canonical provider issuer, independently trusted by the caller.
1165
+ * readonly audience: string; // Exact registered resource URI; never derived from the response.
1166
+ * readonly introspection_client_id: string;
1167
+ * readonly introspection_secret: string;
1168
+ * }} TsAuthOidcResourceCredentials
1169
+ */
1170
+ /**
1171
+ * @typedef {{
1172
+ * readonly sub: string;
1173
+ * readonly email?: string | undefined;
1174
+ * readonly email_verified?: boolean | undefined;
1175
+ * readonly name?: string | undefined;
1176
+ * }} TsAuthOidcUserInfo
1177
+ */
1178
+ export class TsAuthOidcClient {
1179
+ /**
1180
+ * @param {TsAuthHttp} http
1181
+ * @param {string} instanceSlug
1182
+ */
1183
+ constructor(http: TsAuthHttp, instanceSlug: string);
1184
+ /**
1185
+ * Public discovery document; sent without any authorization header.
1186
+ * @returns {Promise<TerraScaleResult<TsAuthOidcDiscovery>>}
1187
+ */
1188
+ discovery(): Promise<TerraScaleResult<TsAuthOidcDiscovery>>;
1189
+ /**
1190
+ * Public signing keys; sent without any authorization header.
1191
+ * @returns {Promise<TerraScaleResult<TsAuthOidcJwks>>}
1192
+ */
1193
+ jwks(): Promise<TerraScaleResult<TsAuthOidcJwks>>;
1194
+ /**
1195
+ * Builds the named authorize URL without dispatching or changing resource bytes.
1196
+ * @param {TsAuthOidcAuthorizationRequest} request
1197
+ * @returns {URL}
1198
+ */
1199
+ authorizationUrl(request: TsAuthOidcAuthorizationRequest): URL;
1200
+ /**
1201
+ * Explicit client_secret_post device flow; polling is caller-controlled.
1202
+ * @param {string} clientId
1203
+ * @param {string} clientSecret
1204
+ * @param {TsAuthOidcDeviceAuthorizationRequest} [request={}]
1205
+ * @returns {Promise<TerraScaleResult<TsAuthOidcDeviceAuthorizationResponse>>}
1206
+ */
1207
+ deviceAuthorization(clientId: string, clientSecret: string, request?: TsAuthOidcDeviceAuthorizationRequest): Promise<TerraScaleResult<TsAuthOidcDeviceAuthorizationResponse>>;
1208
+ /**
1209
+ * client_secret_post only. Omitted resource retains the stored code/device/refresh binding.
1210
+ * @param {string} clientId
1211
+ * @param {string} clientSecret
1212
+ * @param {TsAuthOidcTokenRequest} request
1213
+ * @returns {Promise<TerraScaleResult<TsAuthOidcTokenResponse>>}
1214
+ */
1215
+ token(clientId: string, clientSecret: string, request: TsAuthOidcTokenRequest): Promise<TerraScaleResult<TsAuthOidcTokenResponse>>;
1216
+ /**
1217
+ * Originating-client client_secret_post introspection, including browser refresh tokens.
1218
+ * @param {string} clientId
1219
+ * @param {string} clientSecret
1220
+ * @param {string} token
1221
+ * @returns {Promise<TerraScaleResult<TsAuthOidcIntrospection>>}
1222
+ */
1223
+ introspect(clientId: string, clientSecret: string, token: string): Promise<TerraScaleResult<TsAuthOidcIntrospection>>;
1224
+ /**
1225
+ * Resource Basic-only access-token introspection. Acceptance checks exact issuer/audience,
1226
+ * current local time and principal/session shape; product ownership stays caller-owned.
1227
+ * @param {TsAuthOidcResourceCredentials} credentials
1228
+ * @param {string} token
1229
+ * @param {"access_token"} [tokenTypeHint]
1230
+ * @returns {Promise<TerraScaleResult<TsAuthOidcResourceIntrospection>>}
1231
+ */
1232
+ introspectResource(credentials: TsAuthOidcResourceCredentials, token: string, tokenTypeHint?: "access_token"): Promise<TerraScaleResult<TsAuthOidcResourceIntrospection>>;
1233
+ /**
1234
+ * RFC 7009 semantics: the service answers 200 with an empty body even for
1235
+ * unknown tokens, so success carries no payload.
1236
+ * @param {string} clientId
1237
+ * @param {string} clientSecret
1238
+ * @param {string} token
1239
+ * @returns {Promise<TerraScaleResult<void>>}
1240
+ */
1241
+ revoke(clientId: string, clientSecret: string, token: string): Promise<TerraScaleResult<void>>;
1242
+ /**
1243
+ * Bearer access token issued by the token endpoint, not the sk_ key.
1244
+ * @param {string} accessToken
1245
+ * @returns {Promise<TerraScaleResult<TsAuthOidcUserInfo>>}
1246
+ */
1247
+ userinfo(accessToken: string): Promise<TerraScaleResult<TsAuthOidcUserInfo>>;
1248
+ #private;
1249
+ }
1250
+ /** The ts-auth management client: one hosted identity instance. */
1251
+ export class TsAuthClient {
1252
+ /** @param {TsAuthClientConfig} config */
1253
+ constructor(config: TsAuthClientConfig);
1254
+ /**
1255
+ * @type {TsAuthUsersClient}
1256
+ * @readonly
1257
+ */
1258
+ readonly users: TsAuthUsersClient;
1259
+ /**
1260
+ * @type {TsAuthSessionsClient}
1261
+ * @readonly
1262
+ */
1263
+ readonly sessions: TsAuthSessionsClient;
1264
+ /**
1265
+ * @type {TsAuthApiKeysClient}
1266
+ * @readonly
1267
+ */
1268
+ readonly apiKeys: TsAuthApiKeysClient;
1269
+ /**
1270
+ * @type {TsAuthOrganizationsClient}
1271
+ * @readonly
1272
+ */
1273
+ readonly organizations: TsAuthOrganizationsClient;
1274
+ /**
1275
+ * @type {TsAuthConnectionsClient}
1276
+ * @readonly
1277
+ */
1278
+ readonly connections: TsAuthConnectionsClient;
1279
+ /**
1280
+ * @type {TsAuthDirectoriesClient}
1281
+ * @readonly
1282
+ */
1283
+ readonly directories: TsAuthDirectoriesClient;
1284
+ /**
1285
+ * @type {TsAuthJwtTemplatesClient}
1286
+ * @readonly
1287
+ */
1288
+ readonly jwtTemplates: TsAuthJwtTemplatesClient;
1289
+ /**
1290
+ * @type {TsAuthWebhooksClient}
1291
+ * @readonly
1292
+ */
1293
+ readonly webhooks: TsAuthWebhooksClient;
1294
+ /**
1295
+ * @type {TsAuthAuditEventsClient}
1296
+ * @readonly
1297
+ */
1298
+ readonly auditEvents: TsAuthAuditEventsClient;
1299
+ /**
1300
+ * @type {TsAuthBillingClient}
1301
+ * @readonly
1302
+ */
1303
+ readonly billing: TsAuthBillingClient;
1304
+ /**
1305
+ * @type {TsAuthInstanceClient}
1306
+ * @readonly
1307
+ */
1308
+ readonly instance: TsAuthInstanceClient;
1309
+ /**
1310
+ * @type {TsAuthOauthClientsClient}
1311
+ * @readonly
1312
+ */
1313
+ readonly oauthClients: TsAuthOauthClientsClient;
1314
+ /**
1315
+ * @type {TsAuthOauthResourcesClient}
1316
+ * @readonly
1317
+ */
1318
+ readonly oauthResources: TsAuthOauthResourcesClient;
1319
+ /**
1320
+ * @type {TsAuthOidcClient}
1321
+ * @readonly
1322
+ */
1323
+ readonly oidc: TsAuthOidcClient;
1324
+ get config(): import("./config.js").ResolvedTsAuthRuntimeConfig;
1325
+ #private;
1326
+ }
1327
+ export type TsAuthRuntimeConfig = import("./config.js").TsAuthRuntimeConfig;
1328
+ /**
1329
+ * ts-auth is a separate hosted IdP service on its own origin. This client
1330
+ * speaks that service's published management and OIDC contract, which mirrors
1331
+ * the ts-auth service routes — not the TerraScale product /api/v1 producer
1332
+ * contract. The deployment's public origin is `apiBaseUrl` and the instance
1333
+ * `sk_` management key is `accessToken`.
1334
+ */
1335
+ export type TsAuthClientConfig = Omit<TsAuthRuntimeConfig, "apiBaseUrl"> & {
1336
+ readonly apiBaseUrl: string;
1337
+ readonly instanceSlug: string;
1338
+ readonly useReverseProxy?: boolean;
1339
+ };
1340
+ export type TsAuthRequestOptions = {
1341
+ readonly signal?: AbortSignal | undefined;
1342
+ };
1343
+ export type TsAuthUser = {
1344
+ readonly id: string;
1345
+ readonly email: string | null;
1346
+ readonly email_verified: boolean;
1347
+ readonly username: string | null;
1348
+ readonly name: string | null;
1349
+ readonly banned: boolean;
1350
+ readonly ban_reason?: string | null | undefined;
1351
+ readonly created_at: number;
1352
+ readonly last_sign_in_at?: number | null | undefined;
1353
+ readonly public_metadata: Record<string, unknown>;
1354
+ readonly private_metadata?: Record<string, unknown> | undefined;
1355
+ };
1356
+ export type TsAuthSession = {
1357
+ readonly id: string;
1358
+ readonly status: string;
1359
+ readonly created_at: number;
1360
+ readonly expires_at: number;
1361
+ readonly last_active_at?: number | null | undefined;
1362
+ readonly user_agent?: string | null | undefined;
1363
+ readonly ip_address?: string | null | undefined;
1364
+ };
1365
+ export type TsAuthMfaFactor = {
1366
+ readonly id: string;
1367
+ readonly type: string;
1368
+ readonly confirmed: boolean;
1369
+ readonly createdAt: number;
1370
+ };
1371
+ export type TsAuthPasskey = {
1372
+ readonly id: string;
1373
+ readonly nickname: string | null;
1374
+ readonly algorithm: string;
1375
+ readonly createdAt: number;
1376
+ readonly lastUsedAt: number | null;
1377
+ };
1378
+ export type TsAuthOrganization = {
1379
+ readonly id: string;
1380
+ readonly name: string;
1381
+ readonly slug: string;
1382
+ readonly created_at: number;
1383
+ };
1384
+ export type TsAuthUserOrganizationMembership = {
1385
+ readonly id: string;
1386
+ readonly role: string;
1387
+ readonly created_at: number;
1388
+ readonly organization: TsAuthOrganization | null;
1389
+ };
1390
+ export type TsAuthImpersonationSession = {
1391
+ readonly token: string;
1392
+ readonly expires_at: number;
1393
+ };
1394
+ export type TsAuthUserPage = {
1395
+ readonly data: readonly TsAuthUser[];
1396
+ };
1397
+ export type TsAuthSessionPage = {
1398
+ readonly data: readonly TsAuthSession[];
1399
+ };
1400
+ export type TsAuthMfaFactorPage = {
1401
+ readonly data: readonly TsAuthMfaFactor[];
1402
+ };
1403
+ export type TsAuthPasskeyPage = {
1404
+ readonly passkeys: readonly TsAuthPasskey[];
1405
+ };
1406
+ export type TsAuthRecoveryCodePage = {
1407
+ readonly data: readonly string[];
1408
+ };
1409
+ export type TsAuthUserListOptions = TsAuthRequestOptions & {
1410
+ readonly limit?: number | undefined;
1411
+ readonly startingAfter?: string | undefined;
1412
+ };
1413
+ export type TsAuthUserListAllOptions = TsAuthRequestOptions & {
1414
+ readonly pageSize?: number | undefined;
1415
+ };
1416
+ export type TsAuthCreateUserRequest = {
1417
+ readonly email?: string | undefined;
1418
+ readonly username?: string | undefined;
1419
+ readonly password?: string | undefined;
1420
+ readonly name?: string | undefined;
1421
+ };
1422
+ export type TsAuthApiKeyWithSecret = {
1423
+ readonly id: string;
1424
+ readonly name: string;
1425
+ readonly api_key: string;
1426
+ readonly scopes: readonly string[];
1427
+ };
1428
+ export type TsAuthApiKey = {
1429
+ readonly id: string;
1430
+ readonly name: string;
1431
+ readonly scopes: readonly string[];
1432
+ readonly created_at: number;
1433
+ readonly last_used_at?: number | null | undefined;
1434
+ readonly revoked: boolean;
1435
+ };
1436
+ export type TsAuthApiKeyPage = {
1437
+ readonly data: readonly TsAuthApiKey[];
1438
+ };
1439
+ export type TsAuthCreateApiKeyRequest = {
1440
+ readonly name: string;
1441
+ readonly scopes?: readonly string[] | undefined;
1442
+ };
1443
+ export type TsAuthMembership = {
1444
+ readonly id: string;
1445
+ readonly organization_id: string;
1446
+ readonly user_id: string;
1447
+ readonly role: string;
1448
+ readonly created_at: number;
1449
+ };
1450
+ export type TsAuthMembershipWithUser = TsAuthMembership & {
1451
+ readonly user: {
1452
+ readonly id: string;
1453
+ readonly email: string;
1454
+ readonly name: string;
1455
+ } | null;
1456
+ };
1457
+ export type TsAuthInvitation = {
1458
+ readonly id: string;
1459
+ readonly organization_id: string;
1460
+ readonly email: string;
1461
+ readonly role: string;
1462
+ readonly status: string;
1463
+ readonly expires_at: number;
1464
+ readonly created_at: number;
1465
+ };
1466
+ export type TsAuthOrganizationDomain = {
1467
+ readonly id: string;
1468
+ readonly organization_id: string;
1469
+ readonly domain: string;
1470
+ readonly created_at: number;
1471
+ };
1472
+ export type TsAuthDomainEnrollment = {
1473
+ readonly org_id: string;
1474
+ };
1475
+ export type TsAuthCreateOrganizationRequest = {
1476
+ readonly name: string;
1477
+ readonly slug?: string | undefined;
1478
+ };
1479
+ export type TsAuthUpdateOrganizationRequest = {
1480
+ readonly name: string;
1481
+ };
1482
+ export type TsAuthCreateMembershipRequest = {
1483
+ readonly user_id: string;
1484
+ readonly role: string;
1485
+ };
1486
+ export type TsAuthCreateInvitationRequest = {
1487
+ readonly email: string;
1488
+ readonly role: string;
1489
+ };
1490
+ export type TsAuthAddDomainRequest = {
1491
+ readonly domain: string;
1492
+ };
1493
+ export type TsAuthEnrollRequest = {
1494
+ readonly user_id: string;
1495
+ };
1496
+ export type TsAuthOauthGrantType = "authorization_code" | "refresh_token" | "client_credentials" | "urn:ietf:params:oauth:grant-type:device_code";
1497
+ export type TsAuthOauthClientAuthMethod = "none" | "client_secret_post" | "client_secret_basic";
1498
+ export type TsAuthCreateOauthClientRequest = {
1499
+ readonly name?: string | undefined;
1500
+ readonly redirect_uris?: readonly string[] | undefined;
1501
+ readonly post_logout_redirect_uris?: readonly string[] | undefined;
1502
+ readonly public?: boolean | undefined;
1503
+ readonly token_endpoint_auth_method?: TsAuthOauthClientAuthMethod | undefined;
1504
+ readonly allowed_origins?: readonly string[] | undefined;
1505
+ readonly allow_anonymous?: boolean | undefined;
1506
+ readonly allowed_resource_audiences?: readonly string[] | undefined;
1507
+ readonly allowed_scopes?: readonly string[] | undefined;
1508
+ readonly allowed_grant_types?: readonly TsAuthOauthGrantType[] | undefined;
1509
+ };
1510
+ export type TsAuthUpdateOauthClientRequest = Omit<TsAuthCreateOauthClientRequest, "public" | "token_endpoint_auth_method"> & {
1511
+ readonly expected_auth_epoch?: number | undefined;
1512
+ readonly enabled?: boolean | undefined;
1513
+ readonly rotate_secret?: boolean | undefined;
1514
+ };
1515
+ export type TsAuthOauthClientView = {
1516
+ readonly id: string;
1517
+ readonly client_id: string;
1518
+ readonly name: string;
1519
+ readonly redirect_uris: readonly string[];
1520
+ readonly post_logout_redirect_uris: readonly string[];
1521
+ readonly token_endpoint_auth_method: TsAuthOauthClientAuthMethod;
1522
+ readonly public: boolean;
1523
+ readonly allowed_origins: readonly string[];
1524
+ readonly allow_anonymous: boolean;
1525
+ readonly created_at: number;
1526
+ readonly allowed_resource_audiences: readonly string[];
1527
+ readonly allowed_scopes: readonly string[];
1528
+ readonly allowed_grant_types: readonly TsAuthOauthGrantType[];
1529
+ readonly auth_epoch: number;
1530
+ readonly enabled: boolean;
1531
+ };
1532
+ export type TsAuthOauthClientWithSecret = {
1533
+ readonly client: TsAuthOauthClientView;
1534
+ readonly client_secret: string | null;
1535
+ };
1536
+ export type TsAuthOauthClientList = {
1537
+ readonly clients: readonly TsAuthOauthClientView[];
1538
+ };
1539
+ export type TsAuthOauthClientUpdate = TsAuthOauthClientView | TsAuthOauthClientWithSecret;
1540
+ export type TsAuthCreateOauthResourceRequest = {
1541
+ readonly audience: string;
1542
+ readonly allowed_client_ids: readonly string[];
1543
+ readonly allowed_grant_types: readonly TsAuthOauthGrantType[];
1544
+ readonly allowed_scopes: readonly string[];
1545
+ };
1546
+ export type TsAuthUpdateOauthResourceRequest = {
1547
+ readonly expected_auth_epoch: number;
1548
+ readonly allowed_client_ids?: readonly string[] | undefined;
1549
+ readonly allowed_grant_types?: readonly TsAuthOauthGrantType[] | undefined;
1550
+ readonly allowed_scopes?: readonly string[] | undefined;
1551
+ readonly enabled?: boolean | undefined;
1552
+ readonly rotate_secret?: boolean | undefined;
1553
+ };
1554
+ export type TsAuthOauthResourceView = TsAuthCreateOauthResourceRequest & {
1555
+ readonly id: string;
1556
+ readonly introspection_client_id: string;
1557
+ readonly token_endpoint_auth_method: "client_secret_basic";
1558
+ readonly auth_epoch: number;
1559
+ readonly enabled: boolean;
1560
+ readonly created_at: number;
1561
+ readonly updated_at: number;
1562
+ };
1563
+ export type TsAuthOauthResourceWithSecret = {
1564
+ readonly resource: TsAuthOauthResourceView;
1565
+ readonly introspection_secret: string | null;
1566
+ };
1567
+ export type TsAuthOauthResourceList = {
1568
+ readonly resources: readonly TsAuthOauthResourceView[];
1569
+ };
1570
+ export type TsAuthConnectionView = {
1571
+ readonly id: string;
1572
+ readonly type: "oidc" | "saml";
1573
+ readonly name: string;
1574
+ readonly enabled: boolean;
1575
+ readonly org_id: string | null;
1576
+ readonly issuer_url: string | null;
1577
+ readonly client_id: string | null;
1578
+ readonly authorization_endpoint: string | null;
1579
+ readonly token_endpoint: string | null;
1580
+ readonly userinfo_endpoint: string | null;
1581
+ readonly idp_entity_id: string | null;
1582
+ readonly sso_redirect_url: string | null;
1583
+ readonly sp_entity_id: string | null;
1584
+ readonly created_at: number;
1585
+ };
1586
+ export type TsAuthCreateConnectionRequest = {
1587
+ readonly type: "oidc";
1588
+ readonly name: string;
1589
+ readonly org_id?: string | undefined;
1590
+ readonly issuer_url: string;
1591
+ readonly client_id: string;
1592
+ readonly client_secret: string;
1593
+ readonly scopes?: readonly string[] | undefined;
1594
+ readonly authorization_endpoint?: string | undefined;
1595
+ readonly token_endpoint?: string | undefined;
1596
+ readonly userinfo_endpoint?: string | undefined;
1597
+ } | {
1598
+ readonly type: "saml";
1599
+ readonly name: string;
1600
+ readonly org_id?: string | undefined;
1601
+ readonly idp_entity_id: string;
1602
+ readonly sso_redirect_url: string;
1603
+ readonly x509_certificate_pem: string;
1604
+ };
1605
+ export type TsAuthConnectionPatch = {
1606
+ readonly enabled?: boolean | undefined;
1607
+ readonly name?: string | undefined;
1608
+ readonly client_secret?: string | undefined;
1609
+ };
1610
+ export type TsAuthDirectoryWithToken = {
1611
+ readonly id: string;
1612
+ readonly org_id: string | null;
1613
+ readonly token: string;
1614
+ };
1615
+ export type TsAuthDirectory = {
1616
+ readonly id: string;
1617
+ readonly org_id: string | null;
1618
+ readonly created_at: number;
1619
+ };
1620
+ export type TsAuthJwtTemplate = {
1621
+ readonly id: string;
1622
+ readonly name: string;
1623
+ readonly claims: Record<string, string>;
1624
+ readonly lifetime_seconds: number;
1625
+ readonly created_at: number;
1626
+ };
1627
+ export type TsAuthJwtTokenResponse = {
1628
+ readonly jwt: string;
1629
+ };
1630
+ export type TsAuthCreateJwtTemplateRequest = {
1631
+ readonly name: string;
1632
+ readonly claims: Record<string, string>;
1633
+ readonly lifetime_seconds?: number | undefined;
1634
+ };
1635
+ export type TsAuthUpdateJwtTemplateRequest = {
1636
+ readonly name?: string | undefined;
1637
+ readonly claims?: Record<string, string> | undefined;
1638
+ readonly lifetime_seconds?: number | undefined;
1639
+ };
1640
+ export type TsAuthWebhookWithSecret = {
1641
+ readonly id: string;
1642
+ readonly url: string;
1643
+ readonly events: readonly string[];
1644
+ readonly signing_secret: string;
1645
+ };
1646
+ export type TsAuthWebhook = {
1647
+ readonly id: string;
1648
+ readonly url: string;
1649
+ readonly events: readonly string[];
1650
+ readonly enabled: boolean;
1651
+ readonly created_at: number;
1652
+ };
1653
+ export type TsAuthDeadLetterEntry = {
1654
+ readonly id: string;
1655
+ readonly endpoint_id: string;
1656
+ readonly event_id: string;
1657
+ readonly attempts: number;
1658
+ readonly last_error?: string | undefined;
1659
+ readonly updated_at: number;
1660
+ };
1661
+ export type TsAuthAuditEvent = {
1662
+ readonly id: string;
1663
+ readonly instance_id: string;
1664
+ readonly type: string;
1665
+ readonly actor_id?: string | undefined;
1666
+ readonly data: Record<string, unknown>;
1667
+ readonly created_at: number;
1668
+ readonly integrity_version: number;
1669
+ readonly integrity_hash: string;
1670
+ readonly integrity_signature: string | null;
1671
+ readonly integrity_key_fingerprint: string | null;
1672
+ };
1673
+ export type TsAuthBillingOverview = {
1674
+ readonly plan: "free" | "pro" | "enterprise";
1675
+ readonly status: string;
1676
+ readonly stripe_customer_id?: string | undefined;
1677
+ readonly stripe_subscription_id?: string | undefined;
1678
+ readonly current_period_end?: number | undefined;
1679
+ readonly user_count: number;
1680
+ readonly quota: number;
1681
+ };
1682
+ export type TsAuthInstance = {
1683
+ readonly id: string;
1684
+ readonly slug: string;
1685
+ readonly name: string;
1686
+ readonly logo_url?: string | null | undefined;
1687
+ readonly theme_color?: string | null | undefined;
1688
+ readonly created_at: number;
1689
+ };
1690
+ /**
1691
+ * The PATCH response omits created_at.
1692
+ */
1693
+ export type TsAuthInstanceUpdateResponse = Omit<TsAuthInstance, "created_at">;
1694
+ /**
1695
+ * Absent leaves the stored value unchanged; the service treats null the same as absent.
1696
+ */
1697
+ export type TsAuthInstanceUpdateRequest = {
1698
+ readonly name?: string | undefined;
1699
+ readonly logo_url?: string | undefined;
1700
+ readonly theme_color?: string | undefined;
1701
+ };
1702
+ export type TsAuthOidcDiscovery = {
1703
+ readonly issuer: string;
1704
+ readonly authorization_endpoint: string;
1705
+ readonly token_endpoint: string;
1706
+ readonly userinfo_endpoint: string;
1707
+ readonly jwks_uri: string;
1708
+ readonly revocation_endpoint: string;
1709
+ readonly introspection_endpoint: string;
1710
+ readonly device_authorization_endpoint: string;
1711
+ readonly end_session_endpoint: string;
1712
+ readonly response_types_supported: readonly string[];
1713
+ readonly grant_types_supported: readonly string[];
1714
+ readonly code_challenge_methods_supported: readonly string[];
1715
+ readonly subject_types_supported: readonly string[];
1716
+ readonly id_token_signing_alg_values_supported: readonly string[];
1717
+ readonly token_endpoint_auth_methods_supported: readonly string[];
1718
+ readonly scopes_supported: readonly string[];
1719
+ };
1720
+ export type TsAuthOidcJwk = {
1721
+ readonly kty: "EC";
1722
+ readonly crv: "P-256";
1723
+ readonly alg: "ES256";
1724
+ readonly use: "sig";
1725
+ readonly kid: string;
1726
+ readonly x: string;
1727
+ readonly y: string;
1728
+ };
1729
+ export type TsAuthOidcJwks = {
1730
+ readonly keys: readonly TsAuthOidcJwk[];
1731
+ };
1732
+ export type TsAuthOidcAuthorizationRequest = {
1733
+ readonly client_id: string;
1734
+ readonly redirect_uri: string;
1735
+ readonly response_type: "code";
1736
+ readonly scope?: string | undefined;
1737
+ readonly resource?: string | undefined;
1738
+ readonly state?: string | undefined;
1739
+ readonly nonce?: string | undefined;
1740
+ readonly code_challenge?: string | undefined;
1741
+ readonly code_challenge_method?: "S256" | undefined;
1742
+ readonly prompt?: "none" | "login" | "consent" | "login consent" | "consent login" | undefined;
1743
+ };
1744
+ export type TsAuthOidcDeviceAuthorizationRequest = {
1745
+ readonly scope?: string | undefined;
1746
+ readonly resource?: string | undefined;
1747
+ };
1748
+ export type TsAuthOidcDeviceAuthorizationResponse = {
1749
+ readonly device_code: string;
1750
+ readonly user_code: string;
1751
+ readonly verification_uri: string;
1752
+ readonly verification_uri_complete: string;
1753
+ readonly expires_in: number;
1754
+ readonly interval: number;
1755
+ };
1756
+ export type TsAuthOidcTokenRequest = {
1757
+ readonly grant_type: "authorization_code";
1758
+ readonly code: string;
1759
+ readonly redirect_uri: string;
1760
+ readonly code_verifier?: string | undefined;
1761
+ readonly resource?: string | undefined;
1762
+ } | {
1763
+ readonly grant_type: "refresh_token";
1764
+ readonly refresh_token: string;
1765
+ readonly scope?: string | undefined;
1766
+ readonly resource?: string | undefined;
1767
+ } | {
1768
+ readonly grant_type: "client_credentials";
1769
+ readonly scope: string;
1770
+ readonly resource: string;
1771
+ } | {
1772
+ readonly grant_type: "urn:ietf:params:oauth:grant-type:device_code";
1773
+ readonly device_code: string;
1774
+ readonly resource?: string | undefined;
1775
+ };
1776
+ export type TsAuthOidcTokenResponse = {
1777
+ readonly access_token: string;
1778
+ readonly token_type: "Bearer";
1779
+ readonly expires_in: number;
1780
+ readonly scope: string;
1781
+ readonly refresh_token?: string | null | undefined;
1782
+ readonly id_token?: string | undefined;
1783
+ };
1784
+ export type TsAuthOidcInactiveIntrospection = {
1785
+ readonly active: false;
1786
+ };
1787
+ export type TsAuthOidcAccessIntrospection = {
1788
+ readonly active: true;
1789
+ readonly token_type: "Bearer";
1790
+ readonly iss: string;
1791
+ readonly sub: string;
1792
+ readonly aud: string;
1793
+ readonly client_id: string;
1794
+ readonly scope: string;
1795
+ readonly exp: number;
1796
+ readonly iat: number;
1797
+ readonly sid: string | null;
1798
+ readonly principal_kind: "user" | "service";
1799
+ };
1800
+ export type TsAuthOidcRefreshIntrospection = Omit<TsAuthOidcAccessIntrospection, "token_type" | "principal_kind"> & {
1801
+ readonly token_type: "refresh_token";
1802
+ readonly family_id: string;
1803
+ };
1804
+ export type TsAuthOidcIntrospection = TsAuthOidcInactiveIntrospection | TsAuthOidcAccessIntrospection | TsAuthOidcRefreshIntrospection;
1805
+ export type TsAuthOidcResourceAccessIntrospection = Omit<TsAuthOidcAccessIntrospection, "sid" | "principal_kind"> & ({
1806
+ readonly principal_kind: "user";
1807
+ readonly sid: string;
1808
+ } | {
1809
+ readonly principal_kind: "service";
1810
+ readonly sid: null;
1811
+ });
1812
+ export type TsAuthOidcResourceIntrospection = TsAuthOidcInactiveIntrospection | TsAuthOidcResourceAccessIntrospection;
1813
+ export type TsAuthOidcResourceCredentials = {
1814
+ readonly issuer: string;
1815
+ readonly audience: string;
1816
+ readonly introspection_client_id: string;
1817
+ readonly introspection_secret: string;
1818
+ };
1819
+ export type TsAuthOidcUserInfo = {
1820
+ readonly sub: string;
1821
+ readonly email?: string | undefined;
1822
+ readonly email_verified?: boolean | undefined;
1823
+ readonly name?: string | undefined;
1824
+ };
1825
+ import type { TerraScaleResult } from "./result.js";
1826
+ import { TsAuthHttp } from "./http.js";