@auth-craft/backend-sdk 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -1
- package/dist/client.d.ts +116 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +177 -0
- package/dist/client.js.map +1 -0
- package/dist/contract-types.d.ts +59 -0
- package/dist/contract-types.d.ts.map +1 -0
- package/dist/contract-types.js +10 -0
- package/dist/contract-types.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +11 -0
- package/dist/errors.js.map +1 -0
- package/dist/http-client.d.ts +29 -0
- package/dist/http-client.d.ts.map +1 -0
- package/dist/http-client.js +139 -0
- package/dist/http-client.js.map +1 -0
- package/dist/index.d.ts +8 -542
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -436
- package/dist/index.js.map +1 -1
- package/dist/jwt-signer.d.ts +22 -0
- package/dist/jwt-signer.d.ts.map +1 -0
- package/dist/jwt-signer.js +139 -0
- package/dist/jwt-signer.js.map +1 -0
- package/dist/types.d.ts +137 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +58 -0
- package/dist/types.js.map +1 -0
- package/dist/types.test-d.d.ts +2 -0
- package/dist/types.test-d.d.ts.map +1 -0
- package/dist/types.test-d.js +38 -0
- package/dist/types.test-d.js.map +1 -0
- package/package.json +22 -20
- package/dist/index.cjs +0 -437
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -568
package/dist/index.d.cts
DELETED
|
@@ -1,568 +0,0 @@
|
|
|
1
|
-
import * as ts_micro_result from 'ts-micro-result';
|
|
2
|
-
import { Result } from 'ts-micro-result';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Backend SDK Types
|
|
6
|
-
* Configuration, request, and response types for internal service-to-service calls
|
|
7
|
-
*/
|
|
8
|
-
interface ServiceJwtConfig {
|
|
9
|
-
/**
|
|
10
|
-
* Private key for signing service tokens. Accepts two formats:
|
|
11
|
-
*
|
|
12
|
-
* - **Hex string (64 chars)** — Ed25519 only. 32-byte seed in hex encoding.
|
|
13
|
-
* Example: `INTERNAL_JWT_PRIVATE_KEY=06A70CB7...`
|
|
14
|
-
*
|
|
15
|
-
* - **Base64-encoded JWK** — All algorithms (EdDSA, ES256, RS256, PS256).
|
|
16
|
-
* Generate (Node.js): `subtle.generateKey(...)` → `exportKey('jwk', key)` → `JSON.stringify` → `btoa`
|
|
17
|
-
*/
|
|
18
|
-
privateKey: string;
|
|
19
|
-
/**
|
|
20
|
-
* Signing algorithm. Must be in the Worker's SERVICE_JWT_ALLOWED_ALGORITHMS whitelist.
|
|
21
|
-
* @default 'EdDSA'
|
|
22
|
-
*/
|
|
23
|
-
alg?: 'EdDSA' | 'ES256' | 'RS256' | 'PS256';
|
|
24
|
-
/** Service identity — becomes the `sub` claim (e.g. 'svc_billing') */
|
|
25
|
-
serviceId: string;
|
|
26
|
-
/** Service roles embedded in token (e.g. ['internal-service']) */
|
|
27
|
-
roles?: string[];
|
|
28
|
-
/** Audience claim — must match Worker's SERVICE_JWT_AUDIENCE @default 'auth-craft:internal' */
|
|
29
|
-
audience?: string;
|
|
30
|
-
/** Token expiry in minutes @default 10 */
|
|
31
|
-
expiresInMinutes?: number;
|
|
32
|
-
/** Issuer claim — must match Worker's SERVICE_JWT_ISSUER if set @default 'auth-craft' */
|
|
33
|
-
issuer?: string;
|
|
34
|
-
}
|
|
35
|
-
interface InternalClientConfig {
|
|
36
|
-
/** Base URL of the auth service (e.g., 'https://auth.example.com') */
|
|
37
|
-
baseUrl: string;
|
|
38
|
-
/**
|
|
39
|
-
* Base path prefix (e.g., '/system' → /system/{serviceRoutePath}/*)
|
|
40
|
-
* @default ''
|
|
41
|
-
*/
|
|
42
|
-
basePath?: string;
|
|
43
|
-
/**
|
|
44
|
-
* Path segment for service-to-service routes.
|
|
45
|
-
* Must match SERVICE_ROUTE_PREFIX configured on the Worker/Lambda.
|
|
46
|
-
* Can be changed to obscure the internal API surface.
|
|
47
|
-
*
|
|
48
|
-
* @default '/internal'
|
|
49
|
-
* @example '/svc' → requests go to {baseUrl}{basePath}/svc/*
|
|
50
|
-
*/
|
|
51
|
-
serviceRoutePath?: string;
|
|
52
|
-
/** Service JWT signing configuration */
|
|
53
|
-
jwt: ServiceJwtConfig;
|
|
54
|
-
/** Custom fetch implementation (for testing or middleware) */
|
|
55
|
-
fetchImpl?: typeof fetch;
|
|
56
|
-
/** Request timeout in milliseconds @default 30000 */
|
|
57
|
-
timeout?: number;
|
|
58
|
-
/** Custom headers to include in all requests */
|
|
59
|
-
headers?: Record<string, string>;
|
|
60
|
-
/**
|
|
61
|
-
* Optional secret header for direct backend access.
|
|
62
|
-
* Useful when calling Lambda/Docker directly and the backend expects
|
|
63
|
-
* a shared secret header such as X-Gateway-Secret.
|
|
64
|
-
*/
|
|
65
|
-
secretHeader?: {
|
|
66
|
-
/** Header value to send */
|
|
67
|
-
value: string;
|
|
68
|
-
/** Header name override @default 'X-Gateway-Secret' */
|
|
69
|
-
name?: string;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Optional logger hook for transport-level diagnostics.
|
|
73
|
-
* The SDK never logs by default; provide a logger if you want runtime visibility.
|
|
74
|
-
*/
|
|
75
|
-
logger?: {
|
|
76
|
-
warn(message: string, context?: Record<string, unknown>): void;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
interface BootstrapTenantOwnerRequest {
|
|
80
|
-
tenantId: string;
|
|
81
|
-
userId: string;
|
|
82
|
-
tenantType?: string;
|
|
83
|
-
contactEmail?: string;
|
|
84
|
-
contactPhone?: string;
|
|
85
|
-
displayName?: string;
|
|
86
|
-
displayNameSource?: 'user' | 'admin' | 'system';
|
|
87
|
-
givenName?: string;
|
|
88
|
-
familyName?: string;
|
|
89
|
-
avatarUrl?: string;
|
|
90
|
-
locale?: string;
|
|
91
|
-
jobTitle?: string;
|
|
92
|
-
bio?: string;
|
|
93
|
-
metadata?: Record<string, unknown>;
|
|
94
|
-
}
|
|
95
|
-
interface GetTenantProfileRequest {
|
|
96
|
-
tenantId: string;
|
|
97
|
-
userId: string;
|
|
98
|
-
}
|
|
99
|
-
interface ListTenantMembersRequest {
|
|
100
|
-
tenantId: string;
|
|
101
|
-
actorUserId: string;
|
|
102
|
-
limit?: number;
|
|
103
|
-
cursor?: string;
|
|
104
|
-
}
|
|
105
|
-
interface UpdateTenantMemberStatusRequest {
|
|
106
|
-
tenantId: string;
|
|
107
|
-
userId: string;
|
|
108
|
-
actorUserId: string;
|
|
109
|
-
status: string;
|
|
110
|
-
}
|
|
111
|
-
interface UpdateTenantMemberPermissionRequest {
|
|
112
|
-
tenantId: string;
|
|
113
|
-
userId: string;
|
|
114
|
-
actorUserId: string;
|
|
115
|
-
roles?: string[];
|
|
116
|
-
perms?: Record<string, number>;
|
|
117
|
-
authPerms?: string[];
|
|
118
|
-
}
|
|
119
|
-
interface ListTenantInvitesRequest {
|
|
120
|
-
tenantId: string;
|
|
121
|
-
actorUserId: string;
|
|
122
|
-
status?: string;
|
|
123
|
-
limit?: number;
|
|
124
|
-
cursor?: string;
|
|
125
|
-
}
|
|
126
|
-
interface InviteToTenantRequest {
|
|
127
|
-
tenantId: string;
|
|
128
|
-
invitedBy: string;
|
|
129
|
-
inviteeUserId?: string;
|
|
130
|
-
inviteeEmail?: string;
|
|
131
|
-
inviteePhone?: string;
|
|
132
|
-
roles?: string[];
|
|
133
|
-
perms?: Record<string, number>;
|
|
134
|
-
authPerms?: string[];
|
|
135
|
-
displayName?: string;
|
|
136
|
-
givenName?: string;
|
|
137
|
-
familyName?: string;
|
|
138
|
-
jobTitle?: string;
|
|
139
|
-
}
|
|
140
|
-
interface AcceptInviteRequest {
|
|
141
|
-
userId: string;
|
|
142
|
-
inviteId?: string;
|
|
143
|
-
inviteToken?: string;
|
|
144
|
-
}
|
|
145
|
-
interface DeclineInviteRequest {
|
|
146
|
-
userId: string;
|
|
147
|
-
inviteId?: string;
|
|
148
|
-
inviteToken?: string;
|
|
149
|
-
}
|
|
150
|
-
interface RevokeInviteRequest {
|
|
151
|
-
inviteId: string;
|
|
152
|
-
revokedBy: string;
|
|
153
|
-
}
|
|
154
|
-
interface CheckPendingInvitesRequest {
|
|
155
|
-
email?: string;
|
|
156
|
-
phone?: string;
|
|
157
|
-
}
|
|
158
|
-
interface AddMemberToTenantRequest {
|
|
159
|
-
tenantId: string;
|
|
160
|
-
userId: string;
|
|
161
|
-
actorUserId: string;
|
|
162
|
-
roles?: string[];
|
|
163
|
-
perms?: Record<string, number>;
|
|
164
|
-
authPerms?: string[];
|
|
165
|
-
contactEmail?: string;
|
|
166
|
-
contactPhone?: string;
|
|
167
|
-
displayName?: string;
|
|
168
|
-
givenName?: string;
|
|
169
|
-
familyName?: string;
|
|
170
|
-
avatarUrl?: string;
|
|
171
|
-
locale?: string;
|
|
172
|
-
jobTitle?: string;
|
|
173
|
-
bio?: string;
|
|
174
|
-
metadata?: Record<string, unknown>;
|
|
175
|
-
}
|
|
176
|
-
interface AddMemberToTenantResponse {
|
|
177
|
-
tenantId: string;
|
|
178
|
-
userId: string;
|
|
179
|
-
}
|
|
180
|
-
interface RemoveTenantMemberRequest {
|
|
181
|
-
tenantId: string;
|
|
182
|
-
userId: string;
|
|
183
|
-
actorUserId: string;
|
|
184
|
-
}
|
|
185
|
-
interface ListUserTenantsRequest {
|
|
186
|
-
userId: string;
|
|
187
|
-
/** Filter by tenant type. Defaults to 'org' if not provided. */
|
|
188
|
-
tenantType?: string;
|
|
189
|
-
/**
|
|
190
|
-
* Filter by parent tenant ID.
|
|
191
|
-
* When provided, returns only direct children of that parent the user belongs to.
|
|
192
|
-
* When omitted, returns all tenants of the given type (root + children).
|
|
193
|
-
*/
|
|
194
|
-
parentTenantId?: string;
|
|
195
|
-
limit?: number;
|
|
196
|
-
cursor?: string;
|
|
197
|
-
}
|
|
198
|
-
interface UpdateTenantProfileRequest {
|
|
199
|
-
tenantId: string;
|
|
200
|
-
userId: string;
|
|
201
|
-
contactEmail?: string;
|
|
202
|
-
contactPhone?: string;
|
|
203
|
-
displayName?: string;
|
|
204
|
-
givenName?: string;
|
|
205
|
-
familyName?: string;
|
|
206
|
-
avatarUrl?: string;
|
|
207
|
-
locale?: string;
|
|
208
|
-
bio?: string;
|
|
209
|
-
jobTitle?: string;
|
|
210
|
-
metadata?: Record<string, unknown>;
|
|
211
|
-
}
|
|
212
|
-
/** Common permission context for all account management requests */
|
|
213
|
-
interface AccountPermContextRequest {
|
|
214
|
-
/** User performing the action (must have the required account permission) */
|
|
215
|
-
actorUserId: string;
|
|
216
|
-
/** System tenant where the actor's account permissions are checked */
|
|
217
|
-
systemTenantId: string;
|
|
218
|
-
}
|
|
219
|
-
interface ListAccountsRequest extends AccountPermContextRequest {
|
|
220
|
-
status?: 'active' | 'suspended' | 'deleted';
|
|
221
|
-
limit?: number;
|
|
222
|
-
cursor?: string;
|
|
223
|
-
}
|
|
224
|
-
interface GetAccountRequest extends AccountPermContextRequest {
|
|
225
|
-
userId: string;
|
|
226
|
-
}
|
|
227
|
-
interface UpdateAccountProfileRequest extends AccountPermContextRequest {
|
|
228
|
-
userId: string;
|
|
229
|
-
displayName?: string;
|
|
230
|
-
givenName?: string;
|
|
231
|
-
familyName?: string;
|
|
232
|
-
avatarUrl?: string;
|
|
233
|
-
locale?: string;
|
|
234
|
-
contactEmail?: string;
|
|
235
|
-
contactPhone?: string;
|
|
236
|
-
metadata?: Record<string, unknown>;
|
|
237
|
-
}
|
|
238
|
-
interface UpdateAccountStatusRequest extends AccountPermContextRequest {
|
|
239
|
-
userId: string;
|
|
240
|
-
status: string;
|
|
241
|
-
}
|
|
242
|
-
interface ResetAccountCredentialsRequest extends AccountPermContextRequest {
|
|
243
|
-
userId: string;
|
|
244
|
-
credentialType?: string;
|
|
245
|
-
}
|
|
246
|
-
interface RemoveAccountRequest extends AccountPermContextRequest {
|
|
247
|
-
userId: string;
|
|
248
|
-
}
|
|
249
|
-
interface BootstrapTenantOwnerResponse {
|
|
250
|
-
message: string;
|
|
251
|
-
tenantId: string;
|
|
252
|
-
userId: string;
|
|
253
|
-
}
|
|
254
|
-
interface TenantProfileFields {
|
|
255
|
-
tenantId: string;
|
|
256
|
-
userId: string;
|
|
257
|
-
contactEmail?: string;
|
|
258
|
-
contactPhone?: string;
|
|
259
|
-
displayName?: string;
|
|
260
|
-
displayNameSource?: 'user' | 'admin' | 'system';
|
|
261
|
-
givenName?: string;
|
|
262
|
-
familyName?: string;
|
|
263
|
-
avatarUrl?: string;
|
|
264
|
-
locale?: string;
|
|
265
|
-
jobTitle?: string;
|
|
266
|
-
bio?: string;
|
|
267
|
-
metadata?: Record<string, unknown>;
|
|
268
|
-
}
|
|
269
|
-
interface TenantProfileResponse extends TenantProfileFields {
|
|
270
|
-
status: string;
|
|
271
|
-
roles?: string[];
|
|
272
|
-
perms?: Record<string, number>;
|
|
273
|
-
authPerms: string[];
|
|
274
|
-
isOwner: boolean;
|
|
275
|
-
createdAt: string;
|
|
276
|
-
memberUpdatedAt: string;
|
|
277
|
-
profileUpdatedAt?: string;
|
|
278
|
-
}
|
|
279
|
-
interface TenantMemberProfileResponse extends TenantProfileFields {
|
|
280
|
-
createdAt: string;
|
|
281
|
-
updatedAt: string;
|
|
282
|
-
}
|
|
283
|
-
interface TenantMemberResponse {
|
|
284
|
-
tenantId: string;
|
|
285
|
-
userId: string;
|
|
286
|
-
status: string;
|
|
287
|
-
roles?: string[];
|
|
288
|
-
perms?: Record<string, number>;
|
|
289
|
-
authPerms: string[];
|
|
290
|
-
isOwner: boolean;
|
|
291
|
-
createdAt: string;
|
|
292
|
-
updatedAt: string;
|
|
293
|
-
tenantProfile?: TenantMemberProfileResponse;
|
|
294
|
-
}
|
|
295
|
-
type ListTenantMembersResponse = TenantMemberResponse[];
|
|
296
|
-
interface UserTenantResponse extends TenantProfileFields {
|
|
297
|
-
status: string;
|
|
298
|
-
roles?: string[];
|
|
299
|
-
perms?: Record<string, number>;
|
|
300
|
-
authPerm?: number;
|
|
301
|
-
isOwner: boolean;
|
|
302
|
-
createdAt: string;
|
|
303
|
-
updatedAt: string;
|
|
304
|
-
}
|
|
305
|
-
type ListUserTenantsResponse = UserTenantResponse[];
|
|
306
|
-
interface InvitedByInfo {
|
|
307
|
-
id: string;
|
|
308
|
-
name?: string;
|
|
309
|
-
email?: string;
|
|
310
|
-
jobTitle?: string;
|
|
311
|
-
}
|
|
312
|
-
interface TenantInviteResponse {
|
|
313
|
-
id: string;
|
|
314
|
-
tenantId: string;
|
|
315
|
-
invitedBy: InvitedByInfo;
|
|
316
|
-
inviteeUserId?: string;
|
|
317
|
-
inviteeEmail?: string;
|
|
318
|
-
inviteePhone?: string;
|
|
319
|
-
roles?: string[];
|
|
320
|
-
perms?: Record<string, number>;
|
|
321
|
-
authPerms: string[];
|
|
322
|
-
displayName?: string;
|
|
323
|
-
givenName?: string;
|
|
324
|
-
familyName?: string;
|
|
325
|
-
jobTitle?: string;
|
|
326
|
-
status: string;
|
|
327
|
-
expiresAt: string;
|
|
328
|
-
createdAt: string;
|
|
329
|
-
updatedAt: string;
|
|
330
|
-
}
|
|
331
|
-
type ListTenantInvitesResponse = TenantInviteResponse[];
|
|
332
|
-
interface InviteToTenantResponse {
|
|
333
|
-
inviteId: string;
|
|
334
|
-
inviteToken: string;
|
|
335
|
-
expiresAt: string;
|
|
336
|
-
}
|
|
337
|
-
interface AcceptInviteResponse {
|
|
338
|
-
tenantId: string;
|
|
339
|
-
userId: string;
|
|
340
|
-
}
|
|
341
|
-
interface CheckPendingInvitesResponse {
|
|
342
|
-
invites: TenantInviteResponse[];
|
|
343
|
-
}
|
|
344
|
-
interface AccountSummaryResponse {
|
|
345
|
-
id: string;
|
|
346
|
-
contactEmail?: string;
|
|
347
|
-
contactPhone?: string;
|
|
348
|
-
displayName?: string;
|
|
349
|
-
status: string;
|
|
350
|
-
createdAt: string;
|
|
351
|
-
updatedAt: string;
|
|
352
|
-
}
|
|
353
|
-
interface AccountDetailResponse extends AccountSummaryResponse {
|
|
354
|
-
givenName?: string;
|
|
355
|
-
familyName?: string;
|
|
356
|
-
avatarUrl?: string;
|
|
357
|
-
locale?: string;
|
|
358
|
-
username?: string;
|
|
359
|
-
metadata?: Record<string, unknown>;
|
|
360
|
-
mfaRequired: boolean;
|
|
361
|
-
mfaMethods: string[] | null;
|
|
362
|
-
}
|
|
363
|
-
type ListAccountsResponse = AccountSummaryResponse[];
|
|
364
|
-
/**
|
|
365
|
-
* Valid auth permission strings for operations.
|
|
366
|
-
* Use these when setting authPerms via the SDK.
|
|
367
|
-
*
|
|
368
|
-
* @example
|
|
369
|
-
* ```ts
|
|
370
|
-
* await client.updateTenantMemberPermission({
|
|
371
|
-
* tenantId: 'org-123',
|
|
372
|
-
* userId: 'user-abc',
|
|
373
|
-
* authPerms: [AUTH_PERM_STRINGS.INVITE_MEMBERS, AUTH_PERM_STRINGS.VIEW_MEMBERS],
|
|
374
|
-
* });
|
|
375
|
-
* ```
|
|
376
|
-
*/
|
|
377
|
-
declare const AUTH_PERM_STRINGS: {
|
|
378
|
-
readonly INVITE_MEMBERS: "tenant.member.invite";
|
|
379
|
-
readonly REMOVE_MEMBERS: "tenant.member.remove";
|
|
380
|
-
readonly VIEW_MEMBERS: "tenant.member.view";
|
|
381
|
-
readonly CHANGE_MEMBER_PERMISSION: "tenant.member.permission";
|
|
382
|
-
readonly UPDATE_MEMBER_PROFILE: "tenant.member.profile.update";
|
|
383
|
-
readonly UPDATE_MEMBER_STATUS: "tenant.member.status.update";
|
|
384
|
-
readonly VIEW_ACCOUNTS: "account.view";
|
|
385
|
-
readonly UPDATE_ACCOUNT_PROFILE: "account.profile.update";
|
|
386
|
-
readonly UPDATE_ACCOUNT_STATUS: "account.status.update";
|
|
387
|
-
readonly RESET_ACCOUNT_CREDENTIALS: "account.credentials.reset";
|
|
388
|
-
readonly REMOVE_ACCOUNTS: "account.remove";
|
|
389
|
-
};
|
|
390
|
-
/** Union type of all valid auth permission strings */
|
|
391
|
-
type AuthPermString = (typeof AUTH_PERM_STRINGS)[keyof typeof AUTH_PERM_STRINGS];
|
|
392
|
-
/**
|
|
393
|
-
* Extract the HTTP status code from a Result returned by the SDK.
|
|
394
|
-
*
|
|
395
|
-
* Every Result from InternalClient includes `meta.params.httpStatus`
|
|
396
|
-
* carrying the original HTTP status code from the auth service.
|
|
397
|
-
*
|
|
398
|
-
* @example
|
|
399
|
-
* ```ts
|
|
400
|
-
* const result = await client.getTenantProfile({ tenantId, userId });
|
|
401
|
-
* const status = getHttpStatus(result); // 200 | 404 | 403 | ...
|
|
402
|
-
*
|
|
403
|
-
* if (!result.ok && status === 404) {
|
|
404
|
-
* // handle not found
|
|
405
|
-
* }
|
|
406
|
-
* ```
|
|
407
|
-
*/
|
|
408
|
-
declare function getHttpStatus(result: {
|
|
409
|
-
meta?: {
|
|
410
|
-
params?: Record<string, unknown>;
|
|
411
|
-
};
|
|
412
|
-
}): number | undefined;
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Internal Client
|
|
416
|
-
* Type-safe client for auth service internal (service-to-service) API.
|
|
417
|
-
*/
|
|
418
|
-
|
|
419
|
-
declare class InternalClient {
|
|
420
|
-
private readonly http;
|
|
421
|
-
constructor(config: InternalClientConfig);
|
|
422
|
-
/**
|
|
423
|
-
* Bootstrap tenant owner (assign owner role to a user for a new tenant).
|
|
424
|
-
* Typically called by tenant-provisioning service after creating a tenant.
|
|
425
|
-
*/
|
|
426
|
-
bootstrapTenantOwner(request: BootstrapTenantOwnerRequest): Promise<Result<BootstrapTenantOwnerResponse>>;
|
|
427
|
-
/**
|
|
428
|
-
* Get per-tenant user profile (internal).
|
|
429
|
-
* Allows services to read tenant profiles without user authentication.
|
|
430
|
-
*/
|
|
431
|
-
getTenantProfile(request: GetTenantProfileRequest): Promise<Result<TenantProfileResponse>>;
|
|
432
|
-
/**
|
|
433
|
-
* Update per-tenant user profile (internal).
|
|
434
|
-
* jobTitle is always accepted (service is trusted).
|
|
435
|
-
*/
|
|
436
|
-
updateTenantProfile(request: UpdateTenantProfileRequest): Promise<Result<void>>;
|
|
437
|
-
/**
|
|
438
|
-
* Invite a user to a tenant (internal).
|
|
439
|
-
* Bypasses INVITE_MEMBERS permission — service is trusted.
|
|
440
|
-
*/
|
|
441
|
-
inviteToTenant(request: InviteToTenantRequest): Promise<Result<InviteToTenantResponse>>;
|
|
442
|
-
/**
|
|
443
|
-
* Accept a tenant invite (internal).
|
|
444
|
-
*/
|
|
445
|
-
acceptInvite(request: AcceptInviteRequest): Promise<Result<AcceptInviteResponse>>;
|
|
446
|
-
/**
|
|
447
|
-
* Decline a tenant invite (internal).
|
|
448
|
-
*/
|
|
449
|
-
declineInvite(request: DeclineInviteRequest): Promise<Result<void>>;
|
|
450
|
-
/**
|
|
451
|
-
* Revoke a tenant invite (internal).
|
|
452
|
-
* Bypasses INVITE_MEMBERS permission — service is trusted.
|
|
453
|
-
*/
|
|
454
|
-
revokeInvite(request: RevokeInviteRequest): Promise<Result<void>>;
|
|
455
|
-
/**
|
|
456
|
-
* Check pending invites by email or phone (internal).
|
|
457
|
-
*/
|
|
458
|
-
checkPendingInvites(request: CheckPendingInvitesRequest): Promise<Result<CheckPendingInvitesResponse>>;
|
|
459
|
-
/**
|
|
460
|
-
* List tenant invites (internal).
|
|
461
|
-
* Returns invites with authPerms as string array.
|
|
462
|
-
*/
|
|
463
|
-
listTenantInvites(request: ListTenantInvitesRequest): Promise<Result<ListTenantInvitesResponse>>;
|
|
464
|
-
/**
|
|
465
|
-
* List tenant members (internal).
|
|
466
|
-
* Returns members with authPerms as string array and tenantProfile.
|
|
467
|
-
*/
|
|
468
|
-
listTenantMembers(request: ListTenantMembersRequest): Promise<Result<ListTenantMembersResponse>>;
|
|
469
|
-
/**
|
|
470
|
-
* Update a tenant member's status (internal).
|
|
471
|
-
* Protects owner invariant — cannot update owner status.
|
|
472
|
-
*/
|
|
473
|
-
updateTenantMemberStatus(request: UpdateTenantMemberStatusRequest): Promise<Result<void>>;
|
|
474
|
-
/**
|
|
475
|
-
* Update a tenant member's permission (internal).
|
|
476
|
-
* Protects owner invariant — cannot update owner permissions.
|
|
477
|
-
*/
|
|
478
|
-
updateTenantMemberPermission(request: UpdateTenantMemberPermissionRequest): Promise<Result<void>>;
|
|
479
|
-
/**
|
|
480
|
-
* Remove a tenant member (internal).
|
|
481
|
-
* Bypasses REMOVE_MEMBERS permission — service is trusted.
|
|
482
|
-
* Protects last owner invariant.
|
|
483
|
-
*/
|
|
484
|
-
removeTenantMember(request: RemoveTenantMemberRequest): Promise<Result<void>>;
|
|
485
|
-
/**
|
|
486
|
-
* Add a user directly as an active tenant member, bypassing the invite flow.
|
|
487
|
-
* Requires INVITE_MEMBERS permission on the actor.
|
|
488
|
-
*/
|
|
489
|
-
addMemberToTenant(request: AddMemberToTenantRequest): Promise<Result<AddMemberToTenantResponse>>;
|
|
490
|
-
/**
|
|
491
|
-
* List all tenants a user belongs to (internal).
|
|
492
|
-
* No permission check — service is trusted.
|
|
493
|
-
*/
|
|
494
|
-
listUserTenants(request: ListUserTenantsRequest): Promise<Result<ListUserTenantsResponse>>;
|
|
495
|
-
/**
|
|
496
|
-
* List accounts with cursor-based pagination (internal).
|
|
497
|
-
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
498
|
-
*/
|
|
499
|
-
listAccounts(request: ListAccountsRequest): Promise<Result<ListAccountsResponse>>;
|
|
500
|
-
/**
|
|
501
|
-
* Get account details (internal).
|
|
502
|
-
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
503
|
-
*/
|
|
504
|
-
getAccount(request: GetAccountRequest): Promise<Result<AccountDetailResponse>>;
|
|
505
|
-
/**
|
|
506
|
-
* Update account profile (internal).
|
|
507
|
-
* Requires UPDATE_ACCOUNT_PROFILE permission in the specified system tenant.
|
|
508
|
-
*/
|
|
509
|
-
updateAccountProfile(request: UpdateAccountProfileRequest): Promise<Result<void>>;
|
|
510
|
-
/**
|
|
511
|
-
* Update account status (internal).
|
|
512
|
-
* Requires UPDATE_ACCOUNT_STATUS permission in the specified system tenant.
|
|
513
|
-
*/
|
|
514
|
-
updateAccountStatus(request: UpdateAccountStatusRequest): Promise<Result<void>>;
|
|
515
|
-
/**
|
|
516
|
-
* Reset account credentials (internal).
|
|
517
|
-
* Removes all credentials (or specific type) and resets MFA settings.
|
|
518
|
-
* Requires RESET_ACCOUNT_CREDENTIALS permission in the specified system tenant.
|
|
519
|
-
*/
|
|
520
|
-
resetAccountCredentials(request: ResetAccountCredentialsRequest): Promise<Result<void>>;
|
|
521
|
-
/**
|
|
522
|
-
* Remove account (internal).
|
|
523
|
-
* Hard deletes user data. Account must be suspended or deleted first.
|
|
524
|
-
* Requires REMOVE_ACCOUNTS permission in the specified system tenant.
|
|
525
|
-
*/
|
|
526
|
-
removeAccount(request: RemoveAccountRequest): Promise<Result<void>>;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* Backend SDK Error Definitions
|
|
531
|
-
*/
|
|
532
|
-
declare const sdkErrors: {
|
|
533
|
-
readonly NETWORK_ERROR: (params?: ts_micro_result.BaseErrorParams) => ts_micro_result.ErrorDetail;
|
|
534
|
-
readonly TIMEOUT: (params?: ts_micro_result.BaseErrorParams) => ts_micro_result.ErrorDetail;
|
|
535
|
-
readonly INVALID_RESPONSE: (params?: ts_micro_result.BaseErrorParams) => ts_micro_result.ErrorDetail;
|
|
536
|
-
readonly JWT_SIGN_FAILED: (params?: ts_micro_result.BaseErrorParams) => ts_micro_result.ErrorDetail;
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* @auth-craft/backend-sdk
|
|
541
|
-
* Type-safe internal service SDK for Auth-Craft service-to-service calls.
|
|
542
|
-
*
|
|
543
|
-
* @example
|
|
544
|
-
* ```ts
|
|
545
|
-
* import { createInternalClient } from '@auth-craft/backend-sdk';
|
|
546
|
-
*
|
|
547
|
-
* const client = createInternalClient({
|
|
548
|
-
* baseUrl: 'https://auth.example.com',
|
|
549
|
-
* basePath: '/system',
|
|
550
|
-
* jwt: {
|
|
551
|
-
* privateKeyJwk: process.env.SERVICE_PRIVATE_KEY_JWK!,
|
|
552
|
-
* alg: 'EdDSA', // or 'ES256', 'RS256', 'PS256'
|
|
553
|
-
* serviceId: 'tenant-provisioning-service',
|
|
554
|
-
* roles: ['internal-service'],
|
|
555
|
-
* },
|
|
556
|
-
* });
|
|
557
|
-
*
|
|
558
|
-
* const result = await client.bootstrapTenantOwner({ tenantId, userId });
|
|
559
|
-
* ```
|
|
560
|
-
*/
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* Create an internal service client for Auth-Craft.
|
|
564
|
-
* Requests are authenticated using short-lived Service JWT (EdDSA/ES256/RS256/PS256).
|
|
565
|
-
*/
|
|
566
|
-
declare function createInternalClient(config: InternalClientConfig): InternalClient;
|
|
567
|
-
|
|
568
|
-
export { AUTH_PERM_STRINGS, type AcceptInviteRequest, type AcceptInviteResponse, type AccountDetailResponse, type AccountPermContextRequest, type AccountSummaryResponse, type AddMemberToTenantRequest, type AddMemberToTenantResponse, type AuthPermString, type BootstrapTenantOwnerRequest, type BootstrapTenantOwnerResponse, type CheckPendingInvitesRequest, type CheckPendingInvitesResponse, type DeclineInviteRequest, type GetAccountRequest, type GetTenantProfileRequest, InternalClient, type InternalClientConfig, type InviteToTenantRequest, type InviteToTenantResponse, type InvitedByInfo, type ListAccountsRequest, type ListAccountsResponse, type ListTenantInvitesRequest, type ListTenantInvitesResponse, type ListTenantMembersRequest, type ListTenantMembersResponse, type ListUserTenantsRequest, type ListUserTenantsResponse, type RemoveAccountRequest, type RemoveTenantMemberRequest, type ResetAccountCredentialsRequest, type RevokeInviteRequest, type ServiceJwtConfig, type TenantInviteResponse, type TenantMemberProfileResponse, type TenantMemberResponse, type TenantProfileFields, type TenantProfileResponse, type UpdateAccountProfileRequest, type UpdateAccountStatusRequest, type UpdateTenantMemberPermissionRequest, type UpdateTenantMemberStatusRequest, type UpdateTenantProfileRequest, type UserTenantResponse, createInternalClient, getHttpStatus, sdkErrors };
|