@auth-craft/backend-sdk 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +98 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +119 -11
- package/dist/index.d.ts +119 -11
- package/dist/index.js +98 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -414,19 +414,30 @@ var InternalClient = class {
|
|
|
414
414
|
);
|
|
415
415
|
}
|
|
416
416
|
/**
|
|
417
|
-
* Update a tenant member (internal).
|
|
418
|
-
*
|
|
417
|
+
* Update a tenant member's status (internal).
|
|
418
|
+
* Protects owner invariant — cannot update owner status.
|
|
419
419
|
*/
|
|
420
|
-
async
|
|
420
|
+
async updateTenantMemberStatus(request) {
|
|
421
421
|
return this.http.request(
|
|
422
422
|
"POST",
|
|
423
|
-
"/tenant/members/update",
|
|
423
|
+
"/tenant/members/update-status",
|
|
424
|
+
{ body: request }
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Update a tenant member's permission (internal).
|
|
429
|
+
* Protects owner invariant — cannot update owner permissions.
|
|
430
|
+
*/
|
|
431
|
+
async updateTenantMemberPermission(request) {
|
|
432
|
+
return this.http.request(
|
|
433
|
+
"POST",
|
|
434
|
+
"/tenant/members/update-permission",
|
|
424
435
|
{ body: request }
|
|
425
436
|
);
|
|
426
437
|
}
|
|
427
438
|
/**
|
|
428
439
|
* Remove a tenant member (internal).
|
|
429
|
-
* Bypasses
|
|
440
|
+
* Bypasses REMOVE_MEMBERS permission — service is trusted.
|
|
430
441
|
* Protects last owner invariant.
|
|
431
442
|
*/
|
|
432
443
|
async removeTenantMember(request) {
|
|
@@ -436,14 +447,94 @@ var InternalClient = class {
|
|
|
436
447
|
{ body: request }
|
|
437
448
|
);
|
|
438
449
|
}
|
|
450
|
+
// ============================================================
|
|
451
|
+
// Account Management (System-Tenant Only)
|
|
452
|
+
// ============================================================
|
|
453
|
+
/**
|
|
454
|
+
* List accounts with cursor-based pagination (internal).
|
|
455
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
456
|
+
*/
|
|
457
|
+
async listAccounts(request) {
|
|
458
|
+
return this.http.request(
|
|
459
|
+
"POST",
|
|
460
|
+
"/accounts/list",
|
|
461
|
+
{ body: request }
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Get account details (internal).
|
|
466
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
467
|
+
*/
|
|
468
|
+
async getAccount(request) {
|
|
469
|
+
return this.http.request(
|
|
470
|
+
"POST",
|
|
471
|
+
"/accounts/get",
|
|
472
|
+
{ body: request }
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Update account profile (internal).
|
|
477
|
+
* Requires UPDATE_ACCOUNT_PROFILE permission in the specified system tenant.
|
|
478
|
+
*/
|
|
479
|
+
async updateAccountProfile(request) {
|
|
480
|
+
return this.http.request(
|
|
481
|
+
"POST",
|
|
482
|
+
"/accounts/update-profile",
|
|
483
|
+
{ body: request }
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Update account status (internal).
|
|
488
|
+
* Requires UPDATE_ACCOUNT_STATUS permission in the specified system tenant.
|
|
489
|
+
*/
|
|
490
|
+
async updateAccountStatus(request) {
|
|
491
|
+
return this.http.request(
|
|
492
|
+
"POST",
|
|
493
|
+
"/accounts/update-status",
|
|
494
|
+
{ body: request }
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Reset account credentials (internal).
|
|
499
|
+
* Removes all credentials (or specific type) and resets MFA settings.
|
|
500
|
+
* Requires RESET_ACCOUNT_CREDENTIALS permission in the specified system tenant.
|
|
501
|
+
*/
|
|
502
|
+
async resetAccountCredentials(request) {
|
|
503
|
+
return this.http.request(
|
|
504
|
+
"POST",
|
|
505
|
+
"/accounts/reset-credentials",
|
|
506
|
+
{ body: request }
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Remove account (internal).
|
|
511
|
+
* Hard deletes user data. Account must be suspended or deleted first.
|
|
512
|
+
* Requires REMOVE_ACCOUNTS permission in the specified system tenant.
|
|
513
|
+
*/
|
|
514
|
+
async removeAccount(request) {
|
|
515
|
+
return this.http.request(
|
|
516
|
+
"POST",
|
|
517
|
+
"/accounts/remove",
|
|
518
|
+
{ body: request }
|
|
519
|
+
);
|
|
520
|
+
}
|
|
439
521
|
};
|
|
440
522
|
|
|
441
523
|
// src/types.ts
|
|
442
524
|
var AUTH_PERM_STRINGS = {
|
|
525
|
+
// ─── Tenant Member Management ──────────────────────────────────
|
|
443
526
|
INVITE_MEMBERS: "tenant.member.invite",
|
|
444
|
-
|
|
527
|
+
REMOVE_MEMBERS: "tenant.member.remove",
|
|
445
528
|
VIEW_MEMBERS: "tenant.member.view",
|
|
446
|
-
|
|
529
|
+
CHANGE_MEMBER_PERMISSION: "tenant.member.permission",
|
|
530
|
+
UPDATE_MEMBER_PROFILE: "tenant.member.profile.update",
|
|
531
|
+
UPDATE_MEMBER_STATUS: "tenant.member.status.update",
|
|
532
|
+
// ─── Account Management ────────────────────────────────────────
|
|
533
|
+
VIEW_ACCOUNTS: "account.view",
|
|
534
|
+
UPDATE_ACCOUNT_PROFILE: "account.profile.update",
|
|
535
|
+
UPDATE_ACCOUNT_STATUS: "account.status.update",
|
|
536
|
+
RESET_ACCOUNT_CREDENTIALS: "account.credentials.reset",
|
|
537
|
+
REMOVE_ACCOUNTS: "account.remove"
|
|
447
538
|
};
|
|
448
539
|
|
|
449
540
|
// src/index.ts
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["d:\\NodeJS_Projects\\auth-craft\\packages\\backend-sdk\\dist\\index.cjs"],"names":[],"mappings":"AAAA;AAC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AAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,UAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,QAAA;AACA,UAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"D:\\NodeJS_Projects\\auth-craft\\packages\\backend-sdk\\dist\\index.cjs","sourcesContent":[null]}
|
|
1
|
+
{"version":3,"sources":["d:\\NodeJS_Projects\\auth-craft\\packages\\backend-sdk\\dist\\index.cjs"],"names":[],"mappings":"AAAA;AACA,gDAAyC;AACzC;AACA;AACA,SAAS,eAAe,CAAC,IAAI,EAAE;AAC/B,EAAE,IAAI,OAAO,EAAE,EAAE;AACjB,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACxC,IAAI,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC1C,EAAE;AACF,EAAE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK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AAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"D:\\NodeJS_Projects\\auth-craft\\packages\\backend-sdk\\dist\\index.cjs","sourcesContent":[null]}
|
package/dist/index.d.cts
CHANGED
|
@@ -65,10 +65,14 @@ interface GetTenantProfileRequest {
|
|
|
65
65
|
interface ListTenantMembersRequest {
|
|
66
66
|
tenantId: string;
|
|
67
67
|
}
|
|
68
|
-
interface
|
|
68
|
+
interface UpdateTenantMemberStatusRequest {
|
|
69
|
+
tenantId: string;
|
|
70
|
+
userId: string;
|
|
71
|
+
status: string;
|
|
72
|
+
}
|
|
73
|
+
interface UpdateTenantMemberPermissionRequest {
|
|
69
74
|
tenantId: string;
|
|
70
75
|
userId: string;
|
|
71
|
-
status?: string;
|
|
72
76
|
role?: string;
|
|
73
77
|
permMask?: number;
|
|
74
78
|
authPerms?: string[];
|
|
@@ -123,6 +127,43 @@ interface UpdateTenantProfileRequest {
|
|
|
123
127
|
jobTitle?: string;
|
|
124
128
|
metadata?: Record<string, unknown>;
|
|
125
129
|
}
|
|
130
|
+
/** Common permission context for all account management requests */
|
|
131
|
+
interface AccountPermContextRequest {
|
|
132
|
+
/** User performing the action (must have the required account permission) */
|
|
133
|
+
actorUserId: string;
|
|
134
|
+
/** System tenant where the actor's account permissions are checked */
|
|
135
|
+
systemTenantId: string;
|
|
136
|
+
}
|
|
137
|
+
interface ListAccountsRequest extends AccountPermContextRequest {
|
|
138
|
+
status?: 'active' | 'inactive';
|
|
139
|
+
limit?: number;
|
|
140
|
+
cursor?: string;
|
|
141
|
+
}
|
|
142
|
+
interface GetAccountRequest extends AccountPermContextRequest {
|
|
143
|
+
userId: string;
|
|
144
|
+
}
|
|
145
|
+
interface UpdateAccountProfileRequest extends AccountPermContextRequest {
|
|
146
|
+
userId: string;
|
|
147
|
+
displayName?: string;
|
|
148
|
+
givenName?: string;
|
|
149
|
+
familyName?: string;
|
|
150
|
+
avatarUrl?: string;
|
|
151
|
+
locale?: string;
|
|
152
|
+
contactEmail?: string;
|
|
153
|
+
contactPhone?: string;
|
|
154
|
+
metadata?: Record<string, unknown>;
|
|
155
|
+
}
|
|
156
|
+
interface UpdateAccountStatusRequest extends AccountPermContextRequest {
|
|
157
|
+
userId: string;
|
|
158
|
+
status: string;
|
|
159
|
+
}
|
|
160
|
+
interface ResetAccountCredentialsRequest extends AccountPermContextRequest {
|
|
161
|
+
userId: string;
|
|
162
|
+
credentialType?: string;
|
|
163
|
+
}
|
|
164
|
+
interface RemoveAccountRequest extends AccountPermContextRequest {
|
|
165
|
+
userId: string;
|
|
166
|
+
}
|
|
126
167
|
interface BootstrapTenantOwnerResponse {
|
|
127
168
|
message: string;
|
|
128
169
|
tenantId: string;
|
|
@@ -205,13 +246,36 @@ interface AcceptInviteResponse {
|
|
|
205
246
|
interface CheckPendingInvitesResponse {
|
|
206
247
|
invites: TenantInviteResponse[];
|
|
207
248
|
}
|
|
249
|
+
interface AccountSummaryResponse {
|
|
250
|
+
id: string;
|
|
251
|
+
contactEmail?: string;
|
|
252
|
+
contactPhone?: string;
|
|
253
|
+
displayName?: string;
|
|
254
|
+
status: string;
|
|
255
|
+
createdAt: string;
|
|
256
|
+
updatedAt: string;
|
|
257
|
+
}
|
|
258
|
+
interface AccountDetailResponse extends AccountSummaryResponse {
|
|
259
|
+
givenName?: string;
|
|
260
|
+
familyName?: string;
|
|
261
|
+
avatarUrl?: string;
|
|
262
|
+
locale?: string;
|
|
263
|
+
username?: string;
|
|
264
|
+
metadata?: Record<string, unknown>;
|
|
265
|
+
mfaRequired: boolean;
|
|
266
|
+
mfaMethods: string[] | null;
|
|
267
|
+
}
|
|
268
|
+
interface ListAccountsResponse {
|
|
269
|
+
accounts: AccountSummaryResponse[];
|
|
270
|
+
nextCursor: string | null;
|
|
271
|
+
}
|
|
208
272
|
/**
|
|
209
|
-
* Valid auth permission strings for
|
|
273
|
+
* Valid auth permission strings for operations.
|
|
210
274
|
* Use these when setting authPerms via the SDK.
|
|
211
275
|
*
|
|
212
276
|
* @example
|
|
213
277
|
* ```ts
|
|
214
|
-
* await client.
|
|
278
|
+
* await client.updateTenantMemberPermission({
|
|
215
279
|
* tenantId: 'org-123',
|
|
216
280
|
* userId: 'user-abc',
|
|
217
281
|
* authPerms: [AUTH_PERM_STRINGS.INVITE_MEMBERS, AUTH_PERM_STRINGS.VIEW_MEMBERS],
|
|
@@ -220,9 +284,16 @@ interface CheckPendingInvitesResponse {
|
|
|
220
284
|
*/
|
|
221
285
|
declare const AUTH_PERM_STRINGS: {
|
|
222
286
|
readonly INVITE_MEMBERS: "tenant.member.invite";
|
|
223
|
-
readonly
|
|
287
|
+
readonly REMOVE_MEMBERS: "tenant.member.remove";
|
|
224
288
|
readonly VIEW_MEMBERS: "tenant.member.view";
|
|
225
|
-
readonly
|
|
289
|
+
readonly CHANGE_MEMBER_PERMISSION: "tenant.member.permission";
|
|
290
|
+
readonly UPDATE_MEMBER_PROFILE: "tenant.member.profile.update";
|
|
291
|
+
readonly UPDATE_MEMBER_STATUS: "tenant.member.status.update";
|
|
292
|
+
readonly VIEW_ACCOUNTS: "account.view";
|
|
293
|
+
readonly UPDATE_ACCOUNT_PROFILE: "account.profile.update";
|
|
294
|
+
readonly UPDATE_ACCOUNT_STATUS: "account.status.update";
|
|
295
|
+
readonly RESET_ACCOUNT_CREDENTIALS: "account.credentials.reset";
|
|
296
|
+
readonly REMOVE_ACCOUNTS: "account.remove";
|
|
226
297
|
};
|
|
227
298
|
/** Union type of all valid auth permission strings */
|
|
228
299
|
type AuthPermString = typeof AUTH_PERM_STRINGS[keyof typeof AUTH_PERM_STRINGS];
|
|
@@ -283,16 +354,53 @@ declare class InternalClient {
|
|
|
283
354
|
*/
|
|
284
355
|
listTenantMembers(request: ListTenantMembersRequest): Promise<Result<ListTenantMembersResponse>>;
|
|
285
356
|
/**
|
|
286
|
-
* Update a tenant member (internal).
|
|
287
|
-
*
|
|
357
|
+
* Update a tenant member's status (internal).
|
|
358
|
+
* Protects owner invariant — cannot update owner status.
|
|
288
359
|
*/
|
|
289
|
-
|
|
360
|
+
updateTenantMemberStatus(request: UpdateTenantMemberStatusRequest): Promise<Result<void>>;
|
|
361
|
+
/**
|
|
362
|
+
* Update a tenant member's permission (internal).
|
|
363
|
+
* Protects owner invariant — cannot update owner permissions.
|
|
364
|
+
*/
|
|
365
|
+
updateTenantMemberPermission(request: UpdateTenantMemberPermissionRequest): Promise<Result<void>>;
|
|
290
366
|
/**
|
|
291
367
|
* Remove a tenant member (internal).
|
|
292
|
-
* Bypasses
|
|
368
|
+
* Bypasses REMOVE_MEMBERS permission — service is trusted.
|
|
293
369
|
* Protects last owner invariant.
|
|
294
370
|
*/
|
|
295
371
|
removeTenantMember(request: RemoveTenantMemberRequest): Promise<Result<void>>;
|
|
372
|
+
/**
|
|
373
|
+
* List accounts with cursor-based pagination (internal).
|
|
374
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
375
|
+
*/
|
|
376
|
+
listAccounts(request: ListAccountsRequest): Promise<Result<ListAccountsResponse>>;
|
|
377
|
+
/**
|
|
378
|
+
* Get account details (internal).
|
|
379
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
380
|
+
*/
|
|
381
|
+
getAccount(request: GetAccountRequest): Promise<Result<AccountDetailResponse>>;
|
|
382
|
+
/**
|
|
383
|
+
* Update account profile (internal).
|
|
384
|
+
* Requires UPDATE_ACCOUNT_PROFILE permission in the specified system tenant.
|
|
385
|
+
*/
|
|
386
|
+
updateAccountProfile(request: UpdateAccountProfileRequest): Promise<Result<void>>;
|
|
387
|
+
/**
|
|
388
|
+
* Update account status (internal).
|
|
389
|
+
* Requires UPDATE_ACCOUNT_STATUS permission in the specified system tenant.
|
|
390
|
+
*/
|
|
391
|
+
updateAccountStatus(request: UpdateAccountStatusRequest): Promise<Result<void>>;
|
|
392
|
+
/**
|
|
393
|
+
* Reset account credentials (internal).
|
|
394
|
+
* Removes all credentials (or specific type) and resets MFA settings.
|
|
395
|
+
* Requires RESET_ACCOUNT_CREDENTIALS permission in the specified system tenant.
|
|
396
|
+
*/
|
|
397
|
+
resetAccountCredentials(request: ResetAccountCredentialsRequest): Promise<Result<void>>;
|
|
398
|
+
/**
|
|
399
|
+
* Remove account (internal).
|
|
400
|
+
* Hard deletes user data. Account must be suspended or deleted first.
|
|
401
|
+
* Requires REMOVE_ACCOUNTS permission in the specified system tenant.
|
|
402
|
+
*/
|
|
403
|
+
removeAccount(request: RemoveAccountRequest): Promise<Result<void>>;
|
|
296
404
|
}
|
|
297
405
|
|
|
298
406
|
/**
|
|
@@ -334,4 +442,4 @@ declare const sdkErrors: {
|
|
|
334
442
|
*/
|
|
335
443
|
declare function createInternalClient(config: InternalClientConfig): InternalClient;
|
|
336
444
|
|
|
337
|
-
export { AUTH_PERM_STRINGS, type AcceptInviteRequest, type AcceptInviteResponse, type AuthPermString, type BootstrapTenantOwnerRequest, type BootstrapTenantOwnerResponse, type CheckPendingInvitesRequest, type CheckPendingInvitesResponse, type DeclineInviteRequest, type GetTenantProfileRequest, InternalClient, type InternalClientConfig, type InviteToTenantRequest, type InviteToTenantResponse, type JwtConfig, type JwtEddsaConfig, type JwtEs256Config, type JwtHmacConfig, type JwtRs256Config, type ListTenantInvitesRequest, type ListTenantInvitesResponse, type ListTenantMembersRequest, type ListTenantMembersResponse, type RemoveTenantMemberRequest, type RevokeInviteRequest, type TenantInviteResponse, type TenantMemberProfileResponse, type TenantMemberResponse, type TenantProfileResponse, type
|
|
445
|
+
export { AUTH_PERM_STRINGS, type AcceptInviteRequest, type AcceptInviteResponse, type AccountDetailResponse, type AccountPermContextRequest, type AccountSummaryResponse, type AuthPermString, type BootstrapTenantOwnerRequest, type BootstrapTenantOwnerResponse, type CheckPendingInvitesRequest, type CheckPendingInvitesResponse, type DeclineInviteRequest, type GetAccountRequest, type GetTenantProfileRequest, InternalClient, type InternalClientConfig, type InviteToTenantRequest, type InviteToTenantResponse, type JwtConfig, type JwtEddsaConfig, type JwtEs256Config, type JwtHmacConfig, type JwtRs256Config, type ListAccountsRequest, type ListAccountsResponse, type ListTenantInvitesRequest, type ListTenantInvitesResponse, type ListTenantMembersRequest, type ListTenantMembersResponse, type RemoveAccountRequest, type RemoveTenantMemberRequest, type ResetAccountCredentialsRequest, type RevokeInviteRequest, type TenantInviteResponse, type TenantMemberProfileResponse, type TenantMemberResponse, type TenantProfileResponse, type UpdateAccountProfileRequest, type UpdateAccountStatusRequest, type UpdateTenantMemberPermissionRequest, type UpdateTenantMemberStatusRequest, type UpdateTenantProfileRequest, createInternalClient, sdkErrors };
|
package/dist/index.d.ts
CHANGED
|
@@ -65,10 +65,14 @@ interface GetTenantProfileRequest {
|
|
|
65
65
|
interface ListTenantMembersRequest {
|
|
66
66
|
tenantId: string;
|
|
67
67
|
}
|
|
68
|
-
interface
|
|
68
|
+
interface UpdateTenantMemberStatusRequest {
|
|
69
|
+
tenantId: string;
|
|
70
|
+
userId: string;
|
|
71
|
+
status: string;
|
|
72
|
+
}
|
|
73
|
+
interface UpdateTenantMemberPermissionRequest {
|
|
69
74
|
tenantId: string;
|
|
70
75
|
userId: string;
|
|
71
|
-
status?: string;
|
|
72
76
|
role?: string;
|
|
73
77
|
permMask?: number;
|
|
74
78
|
authPerms?: string[];
|
|
@@ -123,6 +127,43 @@ interface UpdateTenantProfileRequest {
|
|
|
123
127
|
jobTitle?: string;
|
|
124
128
|
metadata?: Record<string, unknown>;
|
|
125
129
|
}
|
|
130
|
+
/** Common permission context for all account management requests */
|
|
131
|
+
interface AccountPermContextRequest {
|
|
132
|
+
/** User performing the action (must have the required account permission) */
|
|
133
|
+
actorUserId: string;
|
|
134
|
+
/** System tenant where the actor's account permissions are checked */
|
|
135
|
+
systemTenantId: string;
|
|
136
|
+
}
|
|
137
|
+
interface ListAccountsRequest extends AccountPermContextRequest {
|
|
138
|
+
status?: 'active' | 'inactive';
|
|
139
|
+
limit?: number;
|
|
140
|
+
cursor?: string;
|
|
141
|
+
}
|
|
142
|
+
interface GetAccountRequest extends AccountPermContextRequest {
|
|
143
|
+
userId: string;
|
|
144
|
+
}
|
|
145
|
+
interface UpdateAccountProfileRequest extends AccountPermContextRequest {
|
|
146
|
+
userId: string;
|
|
147
|
+
displayName?: string;
|
|
148
|
+
givenName?: string;
|
|
149
|
+
familyName?: string;
|
|
150
|
+
avatarUrl?: string;
|
|
151
|
+
locale?: string;
|
|
152
|
+
contactEmail?: string;
|
|
153
|
+
contactPhone?: string;
|
|
154
|
+
metadata?: Record<string, unknown>;
|
|
155
|
+
}
|
|
156
|
+
interface UpdateAccountStatusRequest extends AccountPermContextRequest {
|
|
157
|
+
userId: string;
|
|
158
|
+
status: string;
|
|
159
|
+
}
|
|
160
|
+
interface ResetAccountCredentialsRequest extends AccountPermContextRequest {
|
|
161
|
+
userId: string;
|
|
162
|
+
credentialType?: string;
|
|
163
|
+
}
|
|
164
|
+
interface RemoveAccountRequest extends AccountPermContextRequest {
|
|
165
|
+
userId: string;
|
|
166
|
+
}
|
|
126
167
|
interface BootstrapTenantOwnerResponse {
|
|
127
168
|
message: string;
|
|
128
169
|
tenantId: string;
|
|
@@ -205,13 +246,36 @@ interface AcceptInviteResponse {
|
|
|
205
246
|
interface CheckPendingInvitesResponse {
|
|
206
247
|
invites: TenantInviteResponse[];
|
|
207
248
|
}
|
|
249
|
+
interface AccountSummaryResponse {
|
|
250
|
+
id: string;
|
|
251
|
+
contactEmail?: string;
|
|
252
|
+
contactPhone?: string;
|
|
253
|
+
displayName?: string;
|
|
254
|
+
status: string;
|
|
255
|
+
createdAt: string;
|
|
256
|
+
updatedAt: string;
|
|
257
|
+
}
|
|
258
|
+
interface AccountDetailResponse extends AccountSummaryResponse {
|
|
259
|
+
givenName?: string;
|
|
260
|
+
familyName?: string;
|
|
261
|
+
avatarUrl?: string;
|
|
262
|
+
locale?: string;
|
|
263
|
+
username?: string;
|
|
264
|
+
metadata?: Record<string, unknown>;
|
|
265
|
+
mfaRequired: boolean;
|
|
266
|
+
mfaMethods: string[] | null;
|
|
267
|
+
}
|
|
268
|
+
interface ListAccountsResponse {
|
|
269
|
+
accounts: AccountSummaryResponse[];
|
|
270
|
+
nextCursor: string | null;
|
|
271
|
+
}
|
|
208
272
|
/**
|
|
209
|
-
* Valid auth permission strings for
|
|
273
|
+
* Valid auth permission strings for operations.
|
|
210
274
|
* Use these when setting authPerms via the SDK.
|
|
211
275
|
*
|
|
212
276
|
* @example
|
|
213
277
|
* ```ts
|
|
214
|
-
* await client.
|
|
278
|
+
* await client.updateTenantMemberPermission({
|
|
215
279
|
* tenantId: 'org-123',
|
|
216
280
|
* userId: 'user-abc',
|
|
217
281
|
* authPerms: [AUTH_PERM_STRINGS.INVITE_MEMBERS, AUTH_PERM_STRINGS.VIEW_MEMBERS],
|
|
@@ -220,9 +284,16 @@ interface CheckPendingInvitesResponse {
|
|
|
220
284
|
*/
|
|
221
285
|
declare const AUTH_PERM_STRINGS: {
|
|
222
286
|
readonly INVITE_MEMBERS: "tenant.member.invite";
|
|
223
|
-
readonly
|
|
287
|
+
readonly REMOVE_MEMBERS: "tenant.member.remove";
|
|
224
288
|
readonly VIEW_MEMBERS: "tenant.member.view";
|
|
225
|
-
readonly
|
|
289
|
+
readonly CHANGE_MEMBER_PERMISSION: "tenant.member.permission";
|
|
290
|
+
readonly UPDATE_MEMBER_PROFILE: "tenant.member.profile.update";
|
|
291
|
+
readonly UPDATE_MEMBER_STATUS: "tenant.member.status.update";
|
|
292
|
+
readonly VIEW_ACCOUNTS: "account.view";
|
|
293
|
+
readonly UPDATE_ACCOUNT_PROFILE: "account.profile.update";
|
|
294
|
+
readonly UPDATE_ACCOUNT_STATUS: "account.status.update";
|
|
295
|
+
readonly RESET_ACCOUNT_CREDENTIALS: "account.credentials.reset";
|
|
296
|
+
readonly REMOVE_ACCOUNTS: "account.remove";
|
|
226
297
|
};
|
|
227
298
|
/** Union type of all valid auth permission strings */
|
|
228
299
|
type AuthPermString = typeof AUTH_PERM_STRINGS[keyof typeof AUTH_PERM_STRINGS];
|
|
@@ -283,16 +354,53 @@ declare class InternalClient {
|
|
|
283
354
|
*/
|
|
284
355
|
listTenantMembers(request: ListTenantMembersRequest): Promise<Result<ListTenantMembersResponse>>;
|
|
285
356
|
/**
|
|
286
|
-
* Update a tenant member (internal).
|
|
287
|
-
*
|
|
357
|
+
* Update a tenant member's status (internal).
|
|
358
|
+
* Protects owner invariant — cannot update owner status.
|
|
288
359
|
*/
|
|
289
|
-
|
|
360
|
+
updateTenantMemberStatus(request: UpdateTenantMemberStatusRequest): Promise<Result<void>>;
|
|
361
|
+
/**
|
|
362
|
+
* Update a tenant member's permission (internal).
|
|
363
|
+
* Protects owner invariant — cannot update owner permissions.
|
|
364
|
+
*/
|
|
365
|
+
updateTenantMemberPermission(request: UpdateTenantMemberPermissionRequest): Promise<Result<void>>;
|
|
290
366
|
/**
|
|
291
367
|
* Remove a tenant member (internal).
|
|
292
|
-
* Bypasses
|
|
368
|
+
* Bypasses REMOVE_MEMBERS permission — service is trusted.
|
|
293
369
|
* Protects last owner invariant.
|
|
294
370
|
*/
|
|
295
371
|
removeTenantMember(request: RemoveTenantMemberRequest): Promise<Result<void>>;
|
|
372
|
+
/**
|
|
373
|
+
* List accounts with cursor-based pagination (internal).
|
|
374
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
375
|
+
*/
|
|
376
|
+
listAccounts(request: ListAccountsRequest): Promise<Result<ListAccountsResponse>>;
|
|
377
|
+
/**
|
|
378
|
+
* Get account details (internal).
|
|
379
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
380
|
+
*/
|
|
381
|
+
getAccount(request: GetAccountRequest): Promise<Result<AccountDetailResponse>>;
|
|
382
|
+
/**
|
|
383
|
+
* Update account profile (internal).
|
|
384
|
+
* Requires UPDATE_ACCOUNT_PROFILE permission in the specified system tenant.
|
|
385
|
+
*/
|
|
386
|
+
updateAccountProfile(request: UpdateAccountProfileRequest): Promise<Result<void>>;
|
|
387
|
+
/**
|
|
388
|
+
* Update account status (internal).
|
|
389
|
+
* Requires UPDATE_ACCOUNT_STATUS permission in the specified system tenant.
|
|
390
|
+
*/
|
|
391
|
+
updateAccountStatus(request: UpdateAccountStatusRequest): Promise<Result<void>>;
|
|
392
|
+
/**
|
|
393
|
+
* Reset account credentials (internal).
|
|
394
|
+
* Removes all credentials (or specific type) and resets MFA settings.
|
|
395
|
+
* Requires RESET_ACCOUNT_CREDENTIALS permission in the specified system tenant.
|
|
396
|
+
*/
|
|
397
|
+
resetAccountCredentials(request: ResetAccountCredentialsRequest): Promise<Result<void>>;
|
|
398
|
+
/**
|
|
399
|
+
* Remove account (internal).
|
|
400
|
+
* Hard deletes user data. Account must be suspended or deleted first.
|
|
401
|
+
* Requires REMOVE_ACCOUNTS permission in the specified system tenant.
|
|
402
|
+
*/
|
|
403
|
+
removeAccount(request: RemoveAccountRequest): Promise<Result<void>>;
|
|
296
404
|
}
|
|
297
405
|
|
|
298
406
|
/**
|
|
@@ -334,4 +442,4 @@ declare const sdkErrors: {
|
|
|
334
442
|
*/
|
|
335
443
|
declare function createInternalClient(config: InternalClientConfig): InternalClient;
|
|
336
444
|
|
|
337
|
-
export { AUTH_PERM_STRINGS, type AcceptInviteRequest, type AcceptInviteResponse, type AuthPermString, type BootstrapTenantOwnerRequest, type BootstrapTenantOwnerResponse, type CheckPendingInvitesRequest, type CheckPendingInvitesResponse, type DeclineInviteRequest, type GetTenantProfileRequest, InternalClient, type InternalClientConfig, type InviteToTenantRequest, type InviteToTenantResponse, type JwtConfig, type JwtEddsaConfig, type JwtEs256Config, type JwtHmacConfig, type JwtRs256Config, type ListTenantInvitesRequest, type ListTenantInvitesResponse, type ListTenantMembersRequest, type ListTenantMembersResponse, type RemoveTenantMemberRequest, type RevokeInviteRequest, type TenantInviteResponse, type TenantMemberProfileResponse, type TenantMemberResponse, type TenantProfileResponse, type
|
|
445
|
+
export { AUTH_PERM_STRINGS, type AcceptInviteRequest, type AcceptInviteResponse, type AccountDetailResponse, type AccountPermContextRequest, type AccountSummaryResponse, type AuthPermString, type BootstrapTenantOwnerRequest, type BootstrapTenantOwnerResponse, type CheckPendingInvitesRequest, type CheckPendingInvitesResponse, type DeclineInviteRequest, type GetAccountRequest, type GetTenantProfileRequest, InternalClient, type InternalClientConfig, type InviteToTenantRequest, type InviteToTenantResponse, type JwtConfig, type JwtEddsaConfig, type JwtEs256Config, type JwtHmacConfig, type JwtRs256Config, type ListAccountsRequest, type ListAccountsResponse, type ListTenantInvitesRequest, type ListTenantInvitesResponse, type ListTenantMembersRequest, type ListTenantMembersResponse, type RemoveAccountRequest, type RemoveTenantMemberRequest, type ResetAccountCredentialsRequest, type RevokeInviteRequest, type TenantInviteResponse, type TenantMemberProfileResponse, type TenantMemberResponse, type TenantProfileResponse, type UpdateAccountProfileRequest, type UpdateAccountStatusRequest, type UpdateTenantMemberPermissionRequest, type UpdateTenantMemberStatusRequest, type UpdateTenantProfileRequest, createInternalClient, sdkErrors };
|
package/dist/index.js
CHANGED
|
@@ -414,19 +414,30 @@ var InternalClient = class {
|
|
|
414
414
|
);
|
|
415
415
|
}
|
|
416
416
|
/**
|
|
417
|
-
* Update a tenant member (internal).
|
|
418
|
-
*
|
|
417
|
+
* Update a tenant member's status (internal).
|
|
418
|
+
* Protects owner invariant — cannot update owner status.
|
|
419
419
|
*/
|
|
420
|
-
async
|
|
420
|
+
async updateTenantMemberStatus(request) {
|
|
421
421
|
return this.http.request(
|
|
422
422
|
"POST",
|
|
423
|
-
"/tenant/members/update",
|
|
423
|
+
"/tenant/members/update-status",
|
|
424
|
+
{ body: request }
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Update a tenant member's permission (internal).
|
|
429
|
+
* Protects owner invariant — cannot update owner permissions.
|
|
430
|
+
*/
|
|
431
|
+
async updateTenantMemberPermission(request) {
|
|
432
|
+
return this.http.request(
|
|
433
|
+
"POST",
|
|
434
|
+
"/tenant/members/update-permission",
|
|
424
435
|
{ body: request }
|
|
425
436
|
);
|
|
426
437
|
}
|
|
427
438
|
/**
|
|
428
439
|
* Remove a tenant member (internal).
|
|
429
|
-
* Bypasses
|
|
440
|
+
* Bypasses REMOVE_MEMBERS permission — service is trusted.
|
|
430
441
|
* Protects last owner invariant.
|
|
431
442
|
*/
|
|
432
443
|
async removeTenantMember(request) {
|
|
@@ -436,14 +447,94 @@ var InternalClient = class {
|
|
|
436
447
|
{ body: request }
|
|
437
448
|
);
|
|
438
449
|
}
|
|
450
|
+
// ============================================================
|
|
451
|
+
// Account Management (System-Tenant Only)
|
|
452
|
+
// ============================================================
|
|
453
|
+
/**
|
|
454
|
+
* List accounts with cursor-based pagination (internal).
|
|
455
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
456
|
+
*/
|
|
457
|
+
async listAccounts(request) {
|
|
458
|
+
return this.http.request(
|
|
459
|
+
"POST",
|
|
460
|
+
"/accounts/list",
|
|
461
|
+
{ body: request }
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Get account details (internal).
|
|
466
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
467
|
+
*/
|
|
468
|
+
async getAccount(request) {
|
|
469
|
+
return this.http.request(
|
|
470
|
+
"POST",
|
|
471
|
+
"/accounts/get",
|
|
472
|
+
{ body: request }
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Update account profile (internal).
|
|
477
|
+
* Requires UPDATE_ACCOUNT_PROFILE permission in the specified system tenant.
|
|
478
|
+
*/
|
|
479
|
+
async updateAccountProfile(request) {
|
|
480
|
+
return this.http.request(
|
|
481
|
+
"POST",
|
|
482
|
+
"/accounts/update-profile",
|
|
483
|
+
{ body: request }
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Update account status (internal).
|
|
488
|
+
* Requires UPDATE_ACCOUNT_STATUS permission in the specified system tenant.
|
|
489
|
+
*/
|
|
490
|
+
async updateAccountStatus(request) {
|
|
491
|
+
return this.http.request(
|
|
492
|
+
"POST",
|
|
493
|
+
"/accounts/update-status",
|
|
494
|
+
{ body: request }
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Reset account credentials (internal).
|
|
499
|
+
* Removes all credentials (or specific type) and resets MFA settings.
|
|
500
|
+
* Requires RESET_ACCOUNT_CREDENTIALS permission in the specified system tenant.
|
|
501
|
+
*/
|
|
502
|
+
async resetAccountCredentials(request) {
|
|
503
|
+
return this.http.request(
|
|
504
|
+
"POST",
|
|
505
|
+
"/accounts/reset-credentials",
|
|
506
|
+
{ body: request }
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Remove account (internal).
|
|
511
|
+
* Hard deletes user data. Account must be suspended or deleted first.
|
|
512
|
+
* Requires REMOVE_ACCOUNTS permission in the specified system tenant.
|
|
513
|
+
*/
|
|
514
|
+
async removeAccount(request) {
|
|
515
|
+
return this.http.request(
|
|
516
|
+
"POST",
|
|
517
|
+
"/accounts/remove",
|
|
518
|
+
{ body: request }
|
|
519
|
+
);
|
|
520
|
+
}
|
|
439
521
|
};
|
|
440
522
|
|
|
441
523
|
// src/types.ts
|
|
442
524
|
var AUTH_PERM_STRINGS = {
|
|
525
|
+
// ─── Tenant Member Management ──────────────────────────────────
|
|
443
526
|
INVITE_MEMBERS: "tenant.member.invite",
|
|
444
|
-
|
|
527
|
+
REMOVE_MEMBERS: "tenant.member.remove",
|
|
445
528
|
VIEW_MEMBERS: "tenant.member.view",
|
|
446
|
-
|
|
529
|
+
CHANGE_MEMBER_PERMISSION: "tenant.member.permission",
|
|
530
|
+
UPDATE_MEMBER_PROFILE: "tenant.member.profile.update",
|
|
531
|
+
UPDATE_MEMBER_STATUS: "tenant.member.status.update",
|
|
532
|
+
// ─── Account Management ────────────────────────────────────────
|
|
533
|
+
VIEW_ACCOUNTS: "account.view",
|
|
534
|
+
UPDATE_ACCOUNT_PROFILE: "account.profile.update",
|
|
535
|
+
UPDATE_ACCOUNT_STATUS: "account.status.update",
|
|
536
|
+
RESET_ACCOUNT_CREDENTIALS: "account.credentials.reset",
|
|
537
|
+
REMOVE_ACCOUNTS: "account.remove"
|
|
447
538
|
};
|
|
448
539
|
|
|
449
540
|
// src/index.ts
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/http-client.ts","../src/jwt-signer.ts","../src/errors.ts","../src/client.ts","../src/types.ts","../src/index.ts"],"sourcesContent":["/**\r\n * Low-level HTTP Client\r\n * Wraps fetch with JWT auth, timeout, and Result<T> mapping.\r\n */\r\n\r\nimport { ok, err } from 'ts-micro-result';\r\nimport type { Result } from 'ts-micro-result';\r\nimport type { InternalClientConfig, ApiResponseEnvelope } from './types';\r\nimport { JwtSigner } from './jwt-signer';\r\nimport { sdkErrors } from './errors';\r\n\r\ntype HttpMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';\r\n\r\nexport class HttpClient {\r\n private readonly signer: JwtSigner;\r\n private readonly baseUrl: string;\r\n private readonly basePath: string;\r\n private readonly fetchFn: typeof fetch;\r\n private readonly timeout: number;\r\n private readonly customHeaders: Record<string, string>;\r\n\r\n constructor(config: InternalClientConfig) {\r\n this.signer = new JwtSigner(config.jwt);\r\n this.baseUrl = config.baseUrl.replace(/\\/$/, '');\r\n this.basePath = config.basePath ?? '';\r\n this.fetchFn = config.fetchImpl ?? globalThis.fetch;\r\n this.timeout = config.timeout ?? 30000;\r\n this.customHeaders = config.headers ?? {};\r\n }\r\n\r\n async request<T>(\r\n method: HttpMethod,\r\n path: string,\r\n options?: {\r\n body?: unknown;\r\n query?: Record<string, string>;\r\n }\r\n ): Promise<Result<T>> {\r\n try {\r\n // Get service JWT\r\n let token: string;\r\n try {\r\n token = await this.signer.getToken();\r\n } catch (signError) {\r\n const message = signError instanceof Error ? signError.message : String(signError);\r\n return err(sdkErrors.JWT_SIGN_FAILED({ message }));\r\n }\r\n\r\n // Build URL\r\n const url = this.buildUrl(path, options?.query);\r\n\r\n // Build headers\r\n const headers: Record<string, string> = {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': `Bearer ${token}`,\r\n ...this.customHeaders,\r\n };\r\n\r\n // Timeout\r\n const controller = new AbortController();\r\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\r\n\r\n // Make request — use conditional init to satisfy exactOptionalPropertyTypes\r\n let response: Response;\r\n try {\r\n const init: RequestInit = { method, headers, signal: controller.signal };\r\n if (options?.body !== undefined) {\r\n init.body = JSON.stringify(options.body);\r\n }\r\n response = await this.fetchFn(url, init);\r\n } finally {\r\n clearTimeout(timeoutId);\r\n }\r\n\r\n // Parse response\r\n let envelope: ApiResponseEnvelope<T>;\r\n try {\r\n envelope = await response.json() as ApiResponseEnvelope<T>;\r\n } catch {\r\n return err(\r\n sdkErrors.INVALID_RESPONSE({ message: `HTTP ${response.status}: non-JSON response` })\r\n );\r\n }\r\n\r\n // Map to Result\r\n if (envelope.ok && envelope.data !== undefined) {\r\n return ok(envelope.data, envelope.meta);\r\n }\r\n\r\n const errors = envelope.errors ?? [{ code: 'UNKNOWN_ERROR', message: `HTTP ${response.status}` }];\r\n return err(errors, envelope.meta);\r\n\r\n } catch (error) {\r\n if (error instanceof Error && error.name === 'AbortError') {\r\n return err(sdkErrors.TIMEOUT({ message: `Request timed out after ${this.timeout}ms` }));\r\n }\r\n\r\n const message = error instanceof Error ? error.message : String(error);\r\n return err(sdkErrors.NETWORK_ERROR({ message }));\r\n }\r\n }\r\n\r\n private buildUrl(path: string, query?: Record<string, string>): string {\r\n let url = `${this.baseUrl}${this.basePath}/internal${path}`;\r\n\r\n if (query) {\r\n const entries = Object.entries(query).filter(([, v]) => v !== undefined);\r\n if (entries.length > 0) {\r\n const params = new URLSearchParams(entries);\r\n url += `?${params.toString()}`;\r\n }\r\n }\r\n\r\n return url;\r\n }\r\n}\r\n","/**\r\n * Service JWT Signer\r\n * Creates and auto-refreshes JWTs for service-to-service authentication.\r\n * Uses Web Crypto API for edge compatibility — zero dependencies.\r\n *\r\n * Reuses pattern from auth-http-core/middleware/internal-auth.ts\r\n */\r\n\r\nimport type { JwtConfig, JwtHmacConfig, JwtEddsaConfig, JwtRs256Config, JwtEs256Config } from './types';\r\n\r\n// ============================================================\r\n// Base64url helpers\r\n// ============================================================\r\n\r\nfunction base64urlEncode(data: Uint8Array): string {\r\n let binary = '';\r\n for (let i = 0; i < data.length; i++) {\r\n binary += String.fromCharCode(data[i]!);\r\n }\r\n return btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\r\n}\r\n\r\nfunction hexToUint8Array(hex: string): Uint8Array {\r\n const bytes = new Uint8Array(hex.length / 2);\r\n for (let i = 0; i < hex.length; i += 2) {\r\n bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);\r\n }\r\n return bytes;\r\n}\r\n\r\nfunction parsePemToSpki(pem: string): Uint8Array {\r\n const pemBody = pem\r\n .replace(/-----BEGIN PRIVATE KEY-----/g, '')\r\n .replace(/-----END PRIVATE KEY-----/g, '')\r\n .replace(/\\s/g, '');\r\n\r\n const binary = atob(pemBody);\r\n const bytes = new Uint8Array(binary.length);\r\n for (let i = 0; i < binary.length; i++) {\r\n bytes[i] = binary.charCodeAt(i);\r\n }\r\n return bytes;\r\n}\r\n\r\n// ============================================================\r\n// Key import helpers (Web Crypto API)\r\n// ============================================================\r\n\r\nasync function importHmacSigningKey(secret: string): Promise<CryptoKey> {\r\n const encoder = new TextEncoder();\r\n const keyData = encoder.encode(secret);\r\n return crypto.subtle.importKey(\r\n 'raw',\r\n keyData.buffer as ArrayBuffer,\r\n { name: 'HMAC', hash: 'SHA-256' },\r\n false,\r\n ['sign']\r\n );\r\n}\r\n\r\n/** PKCS8 ASN.1 prefix for Ed25519 private key (RFC 8410) */\r\nconst ED25519_PKCS8_PREFIX = new Uint8Array([\r\n 0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06,\r\n 0x03, 0x2b, 0x65, 0x70, 0x04, 0x22, 0x04, 0x20,\r\n]);\r\n\r\nasync function importEdDSAPrivateKey(privateKey: string | Uint8Array): Promise<CryptoKey> {\r\n const keyBytes = typeof privateKey === 'string'\r\n ? hexToUint8Array(privateKey)\r\n : privateKey;\r\n\r\n // Wrap 32-byte seed in PKCS8 envelope — Node.js 20+ requires \"pkcs8\" format for signing keys\r\n const pkcs8 = new Uint8Array(ED25519_PKCS8_PREFIX.length + keyBytes.length);\r\n pkcs8.set(ED25519_PKCS8_PREFIX);\r\n pkcs8.set(keyBytes, ED25519_PKCS8_PREFIX.length);\r\n\r\n return crypto.subtle.importKey(\r\n 'pkcs8',\r\n pkcs8.buffer as ArrayBuffer,\r\n { name: 'Ed25519' } as Algorithm,\r\n false,\r\n ['sign']\r\n );\r\n}\r\n\r\nasync function importRsaPrivateKey(privateKey: string | JsonWebKey): Promise<CryptoKey> {\r\n if (typeof privateKey === 'object') {\r\n return crypto.subtle.importKey(\r\n 'jwk',\r\n privateKey,\r\n { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },\r\n false,\r\n ['sign']\r\n );\r\n }\r\n\r\n const pkcs8Bytes = parsePemToSpki(privateKey);\r\n return crypto.subtle.importKey(\r\n 'pkcs8',\r\n pkcs8Bytes.buffer as ArrayBuffer,\r\n { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },\r\n false,\r\n ['sign']\r\n );\r\n}\r\n\r\nasync function importEcdsaPrivateKey(privateKey: string | JsonWebKey): Promise<CryptoKey> {\r\n if (typeof privateKey === 'object') {\r\n return crypto.subtle.importKey(\r\n 'jwk',\r\n privateKey,\r\n { name: 'ECDSA', namedCurve: 'P-256' },\r\n false,\r\n ['sign']\r\n );\r\n }\r\n\r\n const pkcs8Bytes = parsePemToSpki(privateKey);\r\n return crypto.subtle.importKey(\r\n 'pkcs8',\r\n pkcs8Bytes.buffer as ArrayBuffer,\r\n { name: 'ECDSA', namedCurve: 'P-256' },\r\n false,\r\n ['sign']\r\n );\r\n}\r\n\r\n// ============================================================\r\n// Sign key info\r\n// ============================================================\r\n\r\ninterface SignKeyInfo {\r\n key: CryptoKey;\r\n jwtAlgorithm: string;\r\n cryptoAlgorithm: AlgorithmIdentifier;\r\n}\r\n\r\nasync function resolveSignKey(config: JwtConfig): Promise<SignKeyInfo> {\r\n const strategy = config.strategy;\r\n\r\n switch (strategy) {\r\n case 'hmac': {\r\n const c = config as JwtHmacConfig;\r\n return {\r\n key: await importHmacSigningKey(c.secret),\r\n jwtAlgorithm: 'HS256',\r\n cryptoAlgorithm: 'HMAC',\r\n };\r\n }\r\n case 'eddsa': {\r\n const c = config as JwtEddsaConfig;\r\n return {\r\n key: await importEdDSAPrivateKey(c.privateKey),\r\n jwtAlgorithm: 'EdDSA',\r\n cryptoAlgorithm: { name: 'Ed25519' } as Algorithm,\r\n };\r\n }\r\n case 'rs256': {\r\n const c = config as JwtRs256Config;\r\n return {\r\n key: await importRsaPrivateKey(c.privateKey),\r\n jwtAlgorithm: 'RS256',\r\n cryptoAlgorithm: 'RSASSA-PKCS1-v1_5',\r\n };\r\n }\r\n case 'es256': {\r\n const c = config as JwtEs256Config;\r\n return {\r\n key: await importEcdsaPrivateKey(c.privateKey),\r\n jwtAlgorithm: 'ES256',\r\n cryptoAlgorithm: { name: 'ECDSA', hash: 'SHA-256' } as EcdsaParams,\r\n };\r\n }\r\n }\r\n}\r\n\r\n// ============================================================\r\n// JWT Signer\r\n// ============================================================\r\n\r\n/** Minimum remaining TTL (seconds) before auto-refreshing the token */\r\nconst REFRESH_BUFFER_SECONDS = 60;\r\n\r\nexport class JwtSigner {\r\n private cachedKeyInfo: SignKeyInfo | null = null;\r\n private cachedToken: string | null = null;\r\n private cachedExp: number = 0;\r\n\r\n constructor(private readonly config: JwtConfig) {}\r\n\r\n /**\r\n * Get a valid service JWT token.\r\n * Automatically signs a new token when the current one is about to expire.\r\n */\r\n async getToken(): Promise<string> {\r\n const nowSeconds = Math.floor(Date.now() / 1000);\r\n\r\n // Return cached token if still valid (with buffer)\r\n if (this.cachedToken && nowSeconds < this.cachedExp - REFRESH_BUFFER_SECONDS) {\r\n return this.cachedToken;\r\n }\r\n\r\n // Sign new token\r\n return this.signNewToken();\r\n }\r\n\r\n private async signNewToken(): Promise<string> {\r\n const keyInfo = await this.getKeyInfo();\r\n const encoder = new TextEncoder();\r\n const expiresInSeconds = this.config.expiresInSeconds ?? 300;\r\n const nowSeconds = Math.floor(Date.now() / 1000);\r\n\r\n // Header\r\n const header = base64urlEncode(\r\n encoder.encode(JSON.stringify({ alg: keyInfo.jwtAlgorithm, typ: 'JWT' }))\r\n );\r\n\r\n // Payload\r\n const payload: Record<string, unknown> = {\r\n iat: nowSeconds,\r\n exp: nowSeconds + expiresInSeconds,\r\n };\r\n\r\n if (this.config.issuer !== undefined) {\r\n payload.iss = this.config.issuer;\r\n }\r\n if (this.config.audience !== undefined) {\r\n payload.aud = this.config.audience;\r\n }\r\n\r\n const payloadB64 = base64urlEncode(encoder.encode(JSON.stringify(payload)));\r\n\r\n // Sign\r\n const signData = encoder.encode(`${header}.${payloadB64}`);\r\n const signatureBytes = new Uint8Array(\r\n await crypto.subtle.sign(\r\n keyInfo.cryptoAlgorithm,\r\n keyInfo.key,\r\n signData.buffer as ArrayBuffer\r\n )\r\n );\r\n const signature = base64urlEncode(signatureBytes);\r\n\r\n const token = `${header}.${payloadB64}.${signature}`;\r\n\r\n // Cache\r\n this.cachedToken = token;\r\n this.cachedExp = nowSeconds + expiresInSeconds;\r\n\r\n return token;\r\n }\r\n\r\n private async getKeyInfo(): Promise<SignKeyInfo> {\r\n if (!this.cachedKeyInfo) {\r\n this.cachedKeyInfo = await resolveSignKey(this.config);\r\n }\r\n return this.cachedKeyInfo;\r\n }\r\n}\r\n","/**\r\n * Backend SDK Error Definitions\r\n */\r\n\r\nimport { defineError } from 'ts-micro-result';\r\n\r\nexport const sdkErrors = {\r\n NETWORK_ERROR: defineError('SDK_NETWORK_ERROR', 'Network request failed'),\r\n TIMEOUT: defineError('SDK_TIMEOUT', 'Request timed out'),\r\n INVALID_RESPONSE: defineError('SDK_INVALID_RESPONSE', 'Invalid response from auth service'),\r\n JWT_SIGN_FAILED: defineError('SDK_JWT_SIGN_FAILED', 'Failed to sign service JWT'),\r\n} as const;\r\n","/**\r\n * Internal Client\r\n * Type-safe client for auth service internal (service-to-service) API.\r\n */\r\n\r\nimport type { Result } from 'ts-micro-result';\r\nimport type {\r\n InternalClientConfig,\r\n BootstrapTenantOwnerRequest,\r\n BootstrapTenantOwnerResponse,\r\n GetTenantProfileRequest,\r\n TenantProfileResponse,\r\n InviteToTenantRequest,\r\n InviteToTenantResponse,\r\n AcceptInviteRequest,\r\n AcceptInviteResponse,\r\n DeclineInviteRequest,\r\n RevokeInviteRequest,\r\n CheckPendingInvitesRequest,\r\n CheckPendingInvitesResponse,\r\n ListTenantMembersRequest,\r\n ListTenantMembersResponse,\r\n UpdateTenantMemberRequest,\r\n RemoveTenantMemberRequest,\r\n ListTenantInvitesRequest,\r\n ListTenantInvitesResponse,\r\n UpdateTenantProfileRequest,\r\n} from './types';\r\nimport { HttpClient } from './http-client';\r\n\r\nexport class InternalClient {\r\n private readonly http: HttpClient;\r\n\r\n constructor(config: InternalClientConfig) {\r\n this.http = new HttpClient(config);\r\n }\r\n\r\n // ============================================================\r\n // Bootstrap\r\n // ============================================================\r\n\r\n /**\r\n * Bootstrap tenant owner (assign owner role to a user for a new tenant).\r\n * Typically called by tenant-provisioning service after creating a tenant.\r\n */\r\n async bootstrapTenantOwner(\r\n request: BootstrapTenantOwnerRequest\r\n ): Promise<Result<BootstrapTenantOwnerResponse>> {\r\n return this.http.request<BootstrapTenantOwnerResponse>(\r\n 'POST',\r\n '/tenant/bootstrap-owner',\r\n { body: request }\r\n );\r\n }\r\n\r\n // ============================================================\r\n // Tenant Profile\r\n // ============================================================\r\n\r\n /**\r\n * Get per-tenant user profile (internal).\r\n * Allows services to read tenant profiles without user authentication.\r\n */\r\n async getTenantProfile(\r\n request: GetTenantProfileRequest\r\n ): Promise<Result<TenantProfileResponse>> {\r\n return this.http.request<TenantProfileResponse>(\r\n 'POST',\r\n '/tenant/profile',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Update per-tenant user profile (internal).\r\n * jobTitle is always accepted (service is trusted).\r\n */\r\n async updateTenantProfile(\r\n request: UpdateTenantProfileRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/tenant/profile/update',\r\n { body: request }\r\n );\r\n }\r\n\r\n // ============================================================\r\n // Invite Management\r\n // ============================================================\r\n\r\n /**\r\n * Invite a user to a tenant (internal).\r\n * Bypasses INVITE_MEMBERS permission — service is trusted.\r\n */\r\n async inviteToTenant(\r\n request: InviteToTenantRequest\r\n ): Promise<Result<InviteToTenantResponse>> {\r\n return this.http.request<InviteToTenantResponse>(\r\n 'POST',\r\n '/tenant/invites/create',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Accept a tenant invite (internal).\r\n */\r\n async acceptInvite(\r\n request: AcceptInviteRequest\r\n ): Promise<Result<AcceptInviteResponse>> {\r\n return this.http.request<AcceptInviteResponse>(\r\n 'POST',\r\n '/tenant/invites/accept',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Decline a tenant invite (internal).\r\n */\r\n async declineInvite(\r\n request: DeclineInviteRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/tenant/invites/decline',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Revoke a tenant invite (internal).\r\n * Bypasses INVITE_MEMBERS permission — service is trusted.\r\n */\r\n async revokeInvite(\r\n request: RevokeInviteRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/tenant/invites/revoke',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Check pending invites by email or phone (internal).\r\n */\r\n async checkPendingInvites(\r\n request: CheckPendingInvitesRequest\r\n ): Promise<Result<CheckPendingInvitesResponse>> {\r\n return this.http.request<CheckPendingInvitesResponse>(\r\n 'POST',\r\n '/tenant/invites/check-pending',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * List tenant invites (internal).\r\n * Returns invites with authPerms as string array.\r\n */\r\n async listTenantInvites(\r\n request: ListTenantInvitesRequest\r\n ): Promise<Result<ListTenantInvitesResponse>> {\r\n return this.http.request<ListTenantInvitesResponse>(\r\n 'POST',\r\n '/tenant/invites/list',\r\n { body: request }\r\n );\r\n }\r\n\r\n // ============================================================\r\n // Member Management\r\n // ============================================================\r\n\r\n /**\r\n * List tenant members (internal).\r\n * Returns members with authPerms as string array and tenantProfile.\r\n */\r\n async listTenantMembers(\r\n request: ListTenantMembersRequest\r\n ): Promise<Result<ListTenantMembersResponse>> {\r\n return this.http.request<ListTenantMembersResponse>(\r\n 'POST',\r\n '/tenant/members/list',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Update a tenant member (internal).\r\n * Bypasses MANAGE_MEMBERS permission — service is trusted.\r\n */\r\n async updateTenantMember(\r\n request: UpdateTenantMemberRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/tenant/members/update',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Remove a tenant member (internal).\r\n * Bypasses MANAGE_MEMBERS permission — service is trusted.\r\n * Protects last owner invariant.\r\n */\r\n async removeTenantMember(\r\n request: RemoveTenantMemberRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/tenant/members/remove',\r\n { body: request }\r\n );\r\n }\r\n}\r\n","/**\r\n * Backend SDK Types\r\n * Configuration, request, and response types for internal service-to-service calls\r\n */\r\n\r\n// ============================================================\r\n// JWT Configuration\r\n// ============================================================\r\n\r\n/** HMAC-SHA256 symmetric signing */\r\nexport interface JwtHmacConfig {\r\n strategy: 'hmac';\r\n /** Shared HMAC secret. MUST be different from user-facing JWT secret. */\r\n secret: string;\r\n}\r\n\r\n/** EdDSA (Ed25519) asymmetric signing */\r\nexport interface JwtEddsaConfig {\r\n strategy: 'eddsa';\r\n /** Ed25519 private key as hex string or raw bytes */\r\n privateKey: string | Uint8Array;\r\n}\r\n\r\n/** RS256 (RSA-SHA256) asymmetric signing */\r\nexport interface JwtRs256Config {\r\n strategy: 'rs256';\r\n /** RSA private key in PEM or JWK format */\r\n privateKey: string | JsonWebKey;\r\n}\r\n\r\n/** ES256 (ECDSA P-256) asymmetric signing */\r\nexport interface JwtEs256Config {\r\n strategy: 'es256';\r\n /** ECDSA P-256 private key in PEM or JWK format */\r\n privateKey: string | JsonWebKey;\r\n}\r\n\r\nexport type JwtConfig = (JwtHmacConfig | JwtEddsaConfig | JwtRs256Config | JwtEs256Config) & {\r\n /** JWT issuer claim (e.g., 'tenant-provisioning-service') */\r\n issuer?: string;\r\n /** JWT audience claim (e.g., 'auth-service') */\r\n audience?: string;\r\n /** Token TTL in seconds @default 300 (5 minutes) */\r\n expiresInSeconds?: number;\r\n};\r\n\r\n// ============================================================\r\n// Client Configuration\r\n// ============================================================\r\n\r\nexport interface InternalClientConfig {\r\n /** Base URL of the auth service (e.g., 'https://auth.example.com') */\r\n baseUrl: string;\r\n\r\n /**\r\n * Base path prefix before /internal (e.g., '/system' → /system/internal/*)\r\n * @default ''\r\n */\r\n basePath?: string;\r\n\r\n /** Service JWT signing configuration */\r\n jwt: JwtConfig;\r\n\r\n /** Custom fetch implementation (for testing or middleware) */\r\n fetchImpl?: typeof fetch;\r\n\r\n /** Request timeout in milliseconds @default 30000 */\r\n timeout?: number;\r\n\r\n /** Custom headers to include in all requests */\r\n headers?: Record<string, string>;\r\n}\r\n\r\n// ============================================================\r\n// Request Types\r\n// ============================================================\r\n\r\nexport interface BootstrapTenantOwnerRequest {\r\n tenantId: string;\r\n userId: string;\r\n}\r\n\r\nexport interface GetTenantProfileRequest {\r\n tenantId: string;\r\n userId: string;\r\n}\r\n\r\nexport interface ListTenantMembersRequest {\r\n tenantId: string;\r\n}\r\n\r\nexport interface UpdateTenantMemberRequest {\r\n tenantId: string;\r\n userId: string;\r\n status?: string;\r\n role?: string;\r\n permMask?: number;\r\n authPerms?: string[];\r\n}\r\n\r\nexport interface ListTenantInvitesRequest {\r\n tenantId: string;\r\n status?: string;\r\n}\r\n\r\nexport interface InviteToTenantRequest {\r\n tenantId: string;\r\n invitedBy: string;\r\n inviteeUserId?: string;\r\n inviteeEmail?: string;\r\n inviteePhone?: string;\r\n role?: string;\r\n permMask?: number;\r\n authPerms?: string[];\r\n}\r\n\r\nexport interface AcceptInviteRequest {\r\n userId: string;\r\n inviteId?: string;\r\n inviteToken?: string;\r\n}\r\n\r\nexport interface DeclineInviteRequest {\r\n userId: string;\r\n inviteId?: string;\r\n inviteToken?: string;\r\n}\r\n\r\nexport interface RevokeInviteRequest {\r\n inviteId: string;\r\n revokedBy: string;\r\n}\r\n\r\nexport interface CheckPendingInvitesRequest {\r\n email?: string;\r\n phone?: string;\r\n}\r\n\r\nexport interface RemoveTenantMemberRequest {\r\n tenantId: string;\r\n userId: string;\r\n}\r\n\r\nexport interface UpdateTenantProfileRequest {\r\n tenantId: string;\r\n userId: string;\r\n contactEmail?: string;\r\n contactPhone?: string;\r\n displayName?: string;\r\n givenName?: string;\r\n familyName?: string;\r\n avatarUrl?: string;\r\n locale?: string;\r\n bio?: string;\r\n jobTitle?: string;\r\n metadata?: Record<string, unknown>;\r\n}\r\n\r\n// ============================================================\r\n// Response Types\r\n// ============================================================\r\n\r\nexport interface BootstrapTenantOwnerResponse {\r\n message: string;\r\n tenantId: string;\r\n userId: string;\r\n role: string;\r\n}\r\n\r\nexport interface TenantProfileResponse {\r\n // Membership\r\n tenantId: string;\r\n userId: string;\r\n status: string;\r\n role?: string;\r\n permMask: number;\r\n authPerms: string[];\r\n isOwner: boolean;\r\n\r\n // Profile (optional — may not exist yet)\r\n displayName?: string;\r\n avatarUrl?: string;\r\n title?: string;\r\n bio?: string;\r\n metadata?: Record<string, unknown>;\r\n}\r\n\r\nexport interface TenantMemberProfileResponse {\r\n tenantId: string;\r\n userId: string;\r\n contactEmail?: string;\r\n contactPhone?: string;\r\n displayName?: string;\r\n displayNameSource?: 'user' | 'admin' | 'system';\r\n givenName?: string;\r\n familyName?: string;\r\n avatarUrl?: string;\r\n locale?: string;\r\n jobTitle?: string;\r\n bio?: string;\r\n metadata?: Record<string, unknown>;\r\n createdAt: string;\r\n updatedAt: string;\r\n}\r\n\r\nexport interface TenantMemberResponse {\r\n tenantId: string;\r\n userId: string;\r\n status: string;\r\n role?: string;\r\n permMask?: number;\r\n authPerms: string[];\r\n isOwner: boolean;\r\n createdAt: string;\r\n updatedAt: string;\r\n tenantProfile?: TenantMemberProfileResponse;\r\n}\r\n\r\nexport interface ListTenantMembersResponse {\r\n members: TenantMemberResponse[];\r\n}\r\n\r\nexport interface TenantInviteResponse {\r\n id: string;\r\n tenantId: string;\r\n invitedBy: string;\r\n inviteeUserId?: string;\r\n inviteeEmail?: string;\r\n inviteePhone?: string;\r\n role?: string;\r\n permMask?: number;\r\n authPerms: string[];\r\n status: string;\r\n expiresAt: string;\r\n createdAt: string;\r\n updatedAt: string;\r\n}\r\n\r\nexport interface ListTenantInvitesResponse {\r\n invites: TenantInviteResponse[];\r\n}\r\n\r\nexport interface InviteToTenantResponse {\r\n inviteId: string;\r\n inviteToken: string;\r\n expiresAt: string;\r\n}\r\n\r\nexport interface AcceptInviteResponse {\r\n tenantId: string;\r\n userId: string;\r\n}\r\n\r\nexport interface CheckPendingInvitesResponse {\r\n invites: TenantInviteResponse[];\r\n}\r\n\r\n// ============================================================\r\n// Auth Permission String Constants\r\n// ============================================================\r\n\r\n/**\r\n * Valid auth permission strings for tenant member operations.\r\n * Use these when setting authPerms via the SDK.\r\n *\r\n * @example\r\n * ```ts\r\n * await client.updateTenantMember({\r\n * tenantId: 'org-123',\r\n * userId: 'user-abc',\r\n * authPerms: [AUTH_PERM_STRINGS.INVITE_MEMBERS, AUTH_PERM_STRINGS.VIEW_MEMBERS],\r\n * });\r\n * ```\r\n */\r\nexport const AUTH_PERM_STRINGS = {\r\n INVITE_MEMBERS: 'tenant.member.invite',\r\n MANAGE_MEMBERS: 'tenant.member.manage',\r\n VIEW_MEMBERS: 'tenant.member.view',\r\n MANAGE_TENANT_PERMISSIONS: 'tenant.permission.manage',\r\n} as const;\r\n\r\n/** Union type of all valid auth permission strings */\r\nexport type AuthPermString = typeof AUTH_PERM_STRINGS[keyof typeof AUTH_PERM_STRINGS];\r\n\r\n// ============================================================\r\n// Internal Types (API response envelope)\r\n// ============================================================\r\n\r\n/** Standard API response envelope from auth service */\r\nexport interface ApiResponseEnvelope<T = unknown> {\r\n ok: boolean;\r\n data?: T;\r\n errors?: Array<{ code: string; message: string; field?: string }>;\r\n meta?: Record<string, unknown>;\r\n}\r\n","/**\r\n * @auth-craft/backend-sdk\r\n * Type-safe internal service SDK for Auth-Craft service-to-service calls.\r\n *\r\n * @example\r\n * ```ts\r\n * import { createInternalClient } from '@auth-craft/backend-sdk';\r\n *\r\n * const client = createInternalClient({\r\n * baseUrl: 'https://auth.example.com',\r\n * basePath: '/system',\r\n * jwt: {\r\n * strategy: 'hmac',\r\n * secret: process.env.INTERNAL_JWT_SECRET!,\r\n * issuer: 'tenant-provisioning-service',\r\n * },\r\n * });\r\n *\r\n * const result = await client.bootstrapTenantOwner({ tenantId, userId });\r\n * ```\r\n */\r\n\r\nimport { InternalClient } from './client';\r\nimport type { InternalClientConfig } from './types';\r\n\r\n/**\r\n * Create an internal service client for Auth-Craft.\r\n *\r\n * The client auto-signs service JWTs and refreshes them before expiry.\r\n */\r\nexport function createInternalClient(config: InternalClientConfig): InternalClient {\r\n return new InternalClient(config);\r\n}\r\n\r\n// Explicit type exports\r\nexport type {\r\n InternalClientConfig,\r\n JwtConfig,\r\n JwtHmacConfig,\r\n JwtEddsaConfig,\r\n JwtRs256Config,\r\n JwtEs256Config,\r\n BootstrapTenantOwnerRequest,\r\n BootstrapTenantOwnerResponse,\r\n GetTenantProfileRequest,\r\n TenantProfileResponse,\r\n InviteToTenantRequest,\r\n InviteToTenantResponse,\r\n AcceptInviteRequest,\r\n AcceptInviteResponse,\r\n DeclineInviteRequest,\r\n RevokeInviteRequest,\r\n CheckPendingInvitesRequest,\r\n CheckPendingInvitesResponse,\r\n ListTenantMembersRequest,\r\n ListTenantMembersResponse,\r\n TenantMemberResponse,\r\n TenantMemberProfileResponse,\r\n UpdateTenantMemberRequest,\r\n RemoveTenantMemberRequest,\r\n ListTenantInvitesRequest,\r\n ListTenantInvitesResponse,\r\n TenantInviteResponse,\r\n UpdateTenantProfileRequest,\r\n} from './types';\r\n\r\nexport { InternalClient } from './client';\r\nexport { sdkErrors } from './errors';\r\nexport { AUTH_PERM_STRINGS } from './types';\r\nexport type { AuthPermString } from './types';\r\n"],"mappings":";AAKA,SAAS,IAAI,WAAW;;;ACSxB,SAAS,gBAAgB,MAA0B;AACjD,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,cAAU,OAAO,aAAa,KAAK,CAAC,CAAE;AAAA,EACxC;AACA,SAAO,KAAK,MAAM,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,EAAE;AAC/E;AAEA,SAAS,gBAAgB,KAAyB;AAChD,QAAM,QAAQ,IAAI,WAAW,IAAI,SAAS,CAAC;AAC3C,WAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK,GAAG;AACtC,UAAM,IAAI,CAAC,IAAI,SAAS,IAAI,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE;AAAA,EACrD;AACA,SAAO;AACT;AAEA,SAAS,eAAe,KAAyB;AAC/C,QAAM,UAAU,IACb,QAAQ,gCAAgC,EAAE,EAC1C,QAAQ,8BAA8B,EAAE,EACxC,QAAQ,OAAO,EAAE;AAEpB,QAAM,SAAS,KAAK,OAAO;AAC3B,QAAM,QAAQ,IAAI,WAAW,OAAO,MAAM;AAC1C,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,UAAM,CAAC,IAAI,OAAO,WAAW,CAAC;AAAA,EAChC;AACA,SAAO;AACT;AAMA,eAAe,qBAAqB,QAAoC;AACtE,QAAM,UAAU,IAAI,YAAY;AAChC,QAAM,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AAQ;AAAA,IAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,oBACJ,SAC8C;AAC9C,WAAO,KAAK,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,EAAE,MAAM,QAAQ;AAAA,IAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,kBACJ,SAC4C;AAC5C,WAAO,KAAK,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,EAAE,MAAM,QAAQ;AAAA,IAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,kBACJ,SAC4C;AAC5C,WAAO,KAAK,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,EAAE,MAAM,QAAQ;AAAA,IAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,mBACJ,SACuB;AACvB,WAAO,KAAK,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,EAAE,MAAM,QAAQ;AAAA,IAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,mBACJ,SACuB;AACvB,WAAO,KAAK,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,EAAE,MAAM,QAAQ;AAAA,IAClB;AAAA,EACF;AACF;;;ACwDO,IAAM,oBAAoB;AAAA,EAC/B,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,2BAA2B;AAC7B;;;ACzPO,SAAS,qBAAqB,QAA8C;AACjF,SAAO,IAAI,eAAe,MAAM;AAClC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/http-client.ts","../src/jwt-signer.ts","../src/errors.ts","../src/client.ts","../src/types.ts","../src/index.ts"],"sourcesContent":["/**\r\n * Low-level HTTP Client\r\n * Wraps fetch with JWT auth, timeout, and Result<T> mapping.\r\n */\r\n\r\nimport { ok, err } from 'ts-micro-result';\r\nimport type { Result } from 'ts-micro-result';\r\nimport type { InternalClientConfig, ApiResponseEnvelope } from './types';\r\nimport { JwtSigner } from './jwt-signer';\r\nimport { sdkErrors } from './errors';\r\n\r\ntype HttpMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';\r\n\r\nexport class HttpClient {\r\n private readonly signer: JwtSigner;\r\n private readonly baseUrl: string;\r\n private readonly basePath: string;\r\n private readonly fetchFn: typeof fetch;\r\n private readonly timeout: number;\r\n private readonly customHeaders: Record<string, string>;\r\n\r\n constructor(config: InternalClientConfig) {\r\n this.signer = new JwtSigner(config.jwt);\r\n this.baseUrl = config.baseUrl.replace(/\\/$/, '');\r\n this.basePath = config.basePath ?? '';\r\n this.fetchFn = config.fetchImpl ?? globalThis.fetch;\r\n this.timeout = config.timeout ?? 30000;\r\n this.customHeaders = config.headers ?? {};\r\n }\r\n\r\n async request<T>(\r\n method: HttpMethod,\r\n path: string,\r\n options?: {\r\n body?: unknown;\r\n query?: Record<string, string>;\r\n }\r\n ): Promise<Result<T>> {\r\n try {\r\n // Get service JWT\r\n let token: string;\r\n try {\r\n token = await this.signer.getToken();\r\n } catch (signError) {\r\n const message = signError instanceof Error ? signError.message : String(signError);\r\n return err(sdkErrors.JWT_SIGN_FAILED({ message }));\r\n }\r\n\r\n // Build URL\r\n const url = this.buildUrl(path, options?.query);\r\n\r\n // Build headers\r\n const headers: Record<string, string> = {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': `Bearer ${token}`,\r\n ...this.customHeaders,\r\n };\r\n\r\n // Timeout\r\n const controller = new AbortController();\r\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\r\n\r\n // Make request — use conditional init to satisfy exactOptionalPropertyTypes\r\n let response: Response;\r\n try {\r\n const init: RequestInit = { method, headers, signal: controller.signal };\r\n if (options?.body !== undefined) {\r\n init.body = JSON.stringify(options.body);\r\n }\r\n response = await this.fetchFn(url, init);\r\n } finally {\r\n clearTimeout(timeoutId);\r\n }\r\n\r\n // Parse response\r\n let envelope: ApiResponseEnvelope<T>;\r\n try {\r\n envelope = await response.json() as ApiResponseEnvelope<T>;\r\n } catch {\r\n return err(\r\n sdkErrors.INVALID_RESPONSE({ message: `HTTP ${response.status}: non-JSON response` })\r\n );\r\n }\r\n\r\n // Map to Result\r\n if (envelope.ok && envelope.data !== undefined) {\r\n return ok(envelope.data, envelope.meta);\r\n }\r\n\r\n const errors = envelope.errors ?? [{ code: 'UNKNOWN_ERROR', message: `HTTP ${response.status}` }];\r\n return err(errors, envelope.meta);\r\n\r\n } catch (error) {\r\n if (error instanceof Error && error.name === 'AbortError') {\r\n return err(sdkErrors.TIMEOUT({ message: `Request timed out after ${this.timeout}ms` }));\r\n }\r\n\r\n const message = error instanceof Error ? error.message : String(error);\r\n return err(sdkErrors.NETWORK_ERROR({ message }));\r\n }\r\n }\r\n\r\n private buildUrl(path: string, query?: Record<string, string>): string {\r\n let url = `${this.baseUrl}${this.basePath}/internal${path}`;\r\n\r\n if (query) {\r\n const entries = Object.entries(query).filter(([, v]) => v !== undefined);\r\n if (entries.length > 0) {\r\n const params = new URLSearchParams(entries);\r\n url += `?${params.toString()}`;\r\n }\r\n }\r\n\r\n return url;\r\n }\r\n}\r\n","/**\r\n * Service JWT Signer\r\n * Creates and auto-refreshes JWTs for service-to-service authentication.\r\n * Uses Web Crypto API for edge compatibility — zero dependencies.\r\n *\r\n * Reuses pattern from auth-http-core/middleware/internal-auth.ts\r\n */\r\n\r\nimport type { JwtConfig, JwtHmacConfig, JwtEddsaConfig, JwtRs256Config, JwtEs256Config } from './types';\r\n\r\n// ============================================================\r\n// Base64url helpers\r\n// ============================================================\r\n\r\nfunction base64urlEncode(data: Uint8Array): string {\r\n let binary = '';\r\n for (let i = 0; i < data.length; i++) {\r\n binary += String.fromCharCode(data[i]!);\r\n }\r\n return btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\r\n}\r\n\r\nfunction hexToUint8Array(hex: string): Uint8Array {\r\n const bytes = new Uint8Array(hex.length / 2);\r\n for (let i = 0; i < hex.length; i += 2) {\r\n bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);\r\n }\r\n return bytes;\r\n}\r\n\r\nfunction parsePemToSpki(pem: string): Uint8Array {\r\n const pemBody = pem\r\n .replace(/-----BEGIN PRIVATE KEY-----/g, '')\r\n .replace(/-----END PRIVATE KEY-----/g, '')\r\n .replace(/\\s/g, '');\r\n\r\n const binary = atob(pemBody);\r\n const bytes = new Uint8Array(binary.length);\r\n for (let i = 0; i < binary.length; i++) {\r\n bytes[i] = binary.charCodeAt(i);\r\n }\r\n return bytes;\r\n}\r\n\r\n// ============================================================\r\n// Key import helpers (Web Crypto API)\r\n// ============================================================\r\n\r\nasync function importHmacSigningKey(secret: string): Promise<CryptoKey> {\r\n const encoder = new TextEncoder();\r\n const keyData = encoder.encode(secret);\r\n return crypto.subtle.importKey(\r\n 'raw',\r\n keyData.buffer as ArrayBuffer,\r\n { name: 'HMAC', hash: 'SHA-256' },\r\n false,\r\n ['sign']\r\n );\r\n}\r\n\r\n/** PKCS8 ASN.1 prefix for Ed25519 private key (RFC 8410) */\r\nconst ED25519_PKCS8_PREFIX = new Uint8Array([\r\n 0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06,\r\n 0x03, 0x2b, 0x65, 0x70, 0x04, 0x22, 0x04, 0x20,\r\n]);\r\n\r\nasync function importEdDSAPrivateKey(privateKey: string | Uint8Array): Promise<CryptoKey> {\r\n const keyBytes = typeof privateKey === 'string'\r\n ? hexToUint8Array(privateKey)\r\n : privateKey;\r\n\r\n // Wrap 32-byte seed in PKCS8 envelope — Node.js 20+ requires \"pkcs8\" format for signing keys\r\n const pkcs8 = new Uint8Array(ED25519_PKCS8_PREFIX.length + keyBytes.length);\r\n pkcs8.set(ED25519_PKCS8_PREFIX);\r\n pkcs8.set(keyBytes, ED25519_PKCS8_PREFIX.length);\r\n\r\n return crypto.subtle.importKey(\r\n 'pkcs8',\r\n pkcs8.buffer as ArrayBuffer,\r\n { name: 'Ed25519' } as Algorithm,\r\n false,\r\n ['sign']\r\n );\r\n}\r\n\r\nasync function importRsaPrivateKey(privateKey: string | JsonWebKey): Promise<CryptoKey> {\r\n if (typeof privateKey === 'object') {\r\n return crypto.subtle.importKey(\r\n 'jwk',\r\n privateKey,\r\n { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },\r\n false,\r\n ['sign']\r\n );\r\n }\r\n\r\n const pkcs8Bytes = parsePemToSpki(privateKey);\r\n return crypto.subtle.importKey(\r\n 'pkcs8',\r\n pkcs8Bytes.buffer as ArrayBuffer,\r\n { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },\r\n false,\r\n ['sign']\r\n );\r\n}\r\n\r\nasync function importEcdsaPrivateKey(privateKey: string | JsonWebKey): Promise<CryptoKey> {\r\n if (typeof privateKey === 'object') {\r\n return crypto.subtle.importKey(\r\n 'jwk',\r\n privateKey,\r\n { name: 'ECDSA', namedCurve: 'P-256' },\r\n false,\r\n ['sign']\r\n );\r\n }\r\n\r\n const pkcs8Bytes = parsePemToSpki(privateKey);\r\n return crypto.subtle.importKey(\r\n 'pkcs8',\r\n pkcs8Bytes.buffer as ArrayBuffer,\r\n { name: 'ECDSA', namedCurve: 'P-256' },\r\n false,\r\n ['sign']\r\n );\r\n}\r\n\r\n// ============================================================\r\n// Sign key info\r\n// ============================================================\r\n\r\ninterface SignKeyInfo {\r\n key: CryptoKey;\r\n jwtAlgorithm: string;\r\n cryptoAlgorithm: AlgorithmIdentifier;\r\n}\r\n\r\nasync function resolveSignKey(config: JwtConfig): Promise<SignKeyInfo> {\r\n const strategy = config.strategy;\r\n\r\n switch (strategy) {\r\n case 'hmac': {\r\n const c = config as JwtHmacConfig;\r\n return {\r\n key: await importHmacSigningKey(c.secret),\r\n jwtAlgorithm: 'HS256',\r\n cryptoAlgorithm: 'HMAC',\r\n };\r\n }\r\n case 'eddsa': {\r\n const c = config as JwtEddsaConfig;\r\n return {\r\n key: await importEdDSAPrivateKey(c.privateKey),\r\n jwtAlgorithm: 'EdDSA',\r\n cryptoAlgorithm: { name: 'Ed25519' } as Algorithm,\r\n };\r\n }\r\n case 'rs256': {\r\n const c = config as JwtRs256Config;\r\n return {\r\n key: await importRsaPrivateKey(c.privateKey),\r\n jwtAlgorithm: 'RS256',\r\n cryptoAlgorithm: 'RSASSA-PKCS1-v1_5',\r\n };\r\n }\r\n case 'es256': {\r\n const c = config as JwtEs256Config;\r\n return {\r\n key: await importEcdsaPrivateKey(c.privateKey),\r\n jwtAlgorithm: 'ES256',\r\n cryptoAlgorithm: { name: 'ECDSA', hash: 'SHA-256' } as EcdsaParams,\r\n };\r\n }\r\n }\r\n}\r\n\r\n// ============================================================\r\n// JWT Signer\r\n// ============================================================\r\n\r\n/** Minimum remaining TTL (seconds) before auto-refreshing the token */\r\nconst REFRESH_BUFFER_SECONDS = 60;\r\n\r\nexport class JwtSigner {\r\n private cachedKeyInfo: SignKeyInfo | null = null;\r\n private cachedToken: string | null = null;\r\n private cachedExp: number = 0;\r\n\r\n constructor(private readonly config: JwtConfig) {}\r\n\r\n /**\r\n * Get a valid service JWT token.\r\n * Automatically signs a new token when the current one is about to expire.\r\n */\r\n async getToken(): Promise<string> {\r\n const nowSeconds = Math.floor(Date.now() / 1000);\r\n\r\n // Return cached token if still valid (with buffer)\r\n if (this.cachedToken && nowSeconds < this.cachedExp - REFRESH_BUFFER_SECONDS) {\r\n return this.cachedToken;\r\n }\r\n\r\n // Sign new token\r\n return this.signNewToken();\r\n }\r\n\r\n private async signNewToken(): Promise<string> {\r\n const keyInfo = await this.getKeyInfo();\r\n const encoder = new TextEncoder();\r\n const expiresInSeconds = this.config.expiresInSeconds ?? 300;\r\n const nowSeconds = Math.floor(Date.now() / 1000);\r\n\r\n // Header\r\n const header = base64urlEncode(\r\n encoder.encode(JSON.stringify({ alg: keyInfo.jwtAlgorithm, typ: 'JWT' }))\r\n );\r\n\r\n // Payload\r\n const payload: Record<string, unknown> = {\r\n iat: nowSeconds,\r\n exp: nowSeconds + expiresInSeconds,\r\n };\r\n\r\n if (this.config.issuer !== undefined) {\r\n payload.iss = this.config.issuer;\r\n }\r\n if (this.config.audience !== undefined) {\r\n payload.aud = this.config.audience;\r\n }\r\n\r\n const payloadB64 = base64urlEncode(encoder.encode(JSON.stringify(payload)));\r\n\r\n // Sign\r\n const signData = encoder.encode(`${header}.${payloadB64}`);\r\n const signatureBytes = new Uint8Array(\r\n await crypto.subtle.sign(\r\n keyInfo.cryptoAlgorithm,\r\n keyInfo.key,\r\n signData.buffer as ArrayBuffer\r\n )\r\n );\r\n const signature = base64urlEncode(signatureBytes);\r\n\r\n const token = `${header}.${payloadB64}.${signature}`;\r\n\r\n // Cache\r\n this.cachedToken = token;\r\n this.cachedExp = nowSeconds + expiresInSeconds;\r\n\r\n return token;\r\n }\r\n\r\n private async getKeyInfo(): Promise<SignKeyInfo> {\r\n if (!this.cachedKeyInfo) {\r\n this.cachedKeyInfo = await resolveSignKey(this.config);\r\n }\r\n return this.cachedKeyInfo;\r\n }\r\n}\r\n","/**\r\n * Backend SDK Error Definitions\r\n */\r\n\r\nimport { defineError } from 'ts-micro-result';\r\n\r\nexport const sdkErrors = {\r\n NETWORK_ERROR: defineError('SDK_NETWORK_ERROR', 'Network request failed'),\r\n TIMEOUT: defineError('SDK_TIMEOUT', 'Request timed out'),\r\n INVALID_RESPONSE: defineError('SDK_INVALID_RESPONSE', 'Invalid response from auth service'),\r\n JWT_SIGN_FAILED: defineError('SDK_JWT_SIGN_FAILED', 'Failed to sign service JWT'),\r\n} as const;\r\n","/**\r\n * Internal Client\r\n * Type-safe client for auth service internal (service-to-service) API.\r\n */\r\n\r\nimport type { Result } from 'ts-micro-result';\r\nimport type {\r\n InternalClientConfig,\r\n BootstrapTenantOwnerRequest,\r\n BootstrapTenantOwnerResponse,\r\n GetTenantProfileRequest,\r\n TenantProfileResponse,\r\n InviteToTenantRequest,\r\n InviteToTenantResponse,\r\n AcceptInviteRequest,\r\n AcceptInviteResponse,\r\n DeclineInviteRequest,\r\n RevokeInviteRequest,\r\n CheckPendingInvitesRequest,\r\n CheckPendingInvitesResponse,\r\n ListTenantMembersRequest,\r\n ListTenantMembersResponse,\r\n UpdateTenantMemberStatusRequest,\r\n UpdateTenantMemberPermissionRequest,\r\n RemoveTenantMemberRequest,\r\n ListTenantInvitesRequest,\r\n ListTenantInvitesResponse,\r\n UpdateTenantProfileRequest,\r\n ListAccountsRequest,\r\n ListAccountsResponse,\r\n GetAccountRequest,\r\n AccountDetailResponse,\r\n UpdateAccountProfileRequest,\r\n UpdateAccountStatusRequest,\r\n ResetAccountCredentialsRequest,\r\n RemoveAccountRequest,\r\n} from './types';\r\nimport { HttpClient } from './http-client';\r\n\r\nexport class InternalClient {\r\n private readonly http: HttpClient;\r\n\r\n constructor(config: InternalClientConfig) {\r\n this.http = new HttpClient(config);\r\n }\r\n\r\n // ============================================================\r\n // Bootstrap\r\n // ============================================================\r\n\r\n /**\r\n * Bootstrap tenant owner (assign owner role to a user for a new tenant).\r\n * Typically called by tenant-provisioning service after creating a tenant.\r\n */\r\n async bootstrapTenantOwner(\r\n request: BootstrapTenantOwnerRequest\r\n ): Promise<Result<BootstrapTenantOwnerResponse>> {\r\n return this.http.request<BootstrapTenantOwnerResponse>(\r\n 'POST',\r\n '/tenant/bootstrap-owner',\r\n { body: request }\r\n );\r\n }\r\n\r\n // ============================================================\r\n // Tenant Profile\r\n // ============================================================\r\n\r\n /**\r\n * Get per-tenant user profile (internal).\r\n * Allows services to read tenant profiles without user authentication.\r\n */\r\n async getTenantProfile(\r\n request: GetTenantProfileRequest\r\n ): Promise<Result<TenantProfileResponse>> {\r\n return this.http.request<TenantProfileResponse>(\r\n 'POST',\r\n '/tenant/profile',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Update per-tenant user profile (internal).\r\n * jobTitle is always accepted (service is trusted).\r\n */\r\n async updateTenantProfile(\r\n request: UpdateTenantProfileRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/tenant/profile/update',\r\n { body: request }\r\n );\r\n }\r\n\r\n // ============================================================\r\n // Invite Management\r\n // ============================================================\r\n\r\n /**\r\n * Invite a user to a tenant (internal).\r\n * Bypasses INVITE_MEMBERS permission — service is trusted.\r\n */\r\n async inviteToTenant(\r\n request: InviteToTenantRequest\r\n ): Promise<Result<InviteToTenantResponse>> {\r\n return this.http.request<InviteToTenantResponse>(\r\n 'POST',\r\n '/tenant/invites/create',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Accept a tenant invite (internal).\r\n */\r\n async acceptInvite(\r\n request: AcceptInviteRequest\r\n ): Promise<Result<AcceptInviteResponse>> {\r\n return this.http.request<AcceptInviteResponse>(\r\n 'POST',\r\n '/tenant/invites/accept',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Decline a tenant invite (internal).\r\n */\r\n async declineInvite(\r\n request: DeclineInviteRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/tenant/invites/decline',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Revoke a tenant invite (internal).\r\n * Bypasses INVITE_MEMBERS permission — service is trusted.\r\n */\r\n async revokeInvite(\r\n request: RevokeInviteRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/tenant/invites/revoke',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Check pending invites by email or phone (internal).\r\n */\r\n async checkPendingInvites(\r\n request: CheckPendingInvitesRequest\r\n ): Promise<Result<CheckPendingInvitesResponse>> {\r\n return this.http.request<CheckPendingInvitesResponse>(\r\n 'POST',\r\n '/tenant/invites/check-pending',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * List tenant invites (internal).\r\n * Returns invites with authPerms as string array.\r\n */\r\n async listTenantInvites(\r\n request: ListTenantInvitesRequest\r\n ): Promise<Result<ListTenantInvitesResponse>> {\r\n return this.http.request<ListTenantInvitesResponse>(\r\n 'POST',\r\n '/tenant/invites/list',\r\n { body: request }\r\n );\r\n }\r\n\r\n // ============================================================\r\n // Member Management\r\n // ============================================================\r\n\r\n /**\r\n * List tenant members (internal).\r\n * Returns members with authPerms as string array and tenantProfile.\r\n */\r\n async listTenantMembers(\r\n request: ListTenantMembersRequest\r\n ): Promise<Result<ListTenantMembersResponse>> {\r\n return this.http.request<ListTenantMembersResponse>(\r\n 'POST',\r\n '/tenant/members/list',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Update a tenant member's status (internal).\r\n * Protects owner invariant — cannot update owner status.\r\n */\r\n async updateTenantMemberStatus(\r\n request: UpdateTenantMemberStatusRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/tenant/members/update-status',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Update a tenant member's permission (internal).\r\n * Protects owner invariant — cannot update owner permissions.\r\n */\r\n async updateTenantMemberPermission(\r\n request: UpdateTenantMemberPermissionRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/tenant/members/update-permission',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Remove a tenant member (internal).\r\n * Bypasses REMOVE_MEMBERS permission — service is trusted.\r\n * Protects last owner invariant.\r\n */\r\n async removeTenantMember(\r\n request: RemoveTenantMemberRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/tenant/members/remove',\r\n { body: request }\r\n );\r\n }\r\n\r\n // ============================================================\r\n // Account Management (System-Tenant Only)\r\n // ============================================================\r\n\r\n /**\r\n * List accounts with cursor-based pagination (internal).\r\n * Requires VIEW_ACCOUNTS permission in the specified system tenant.\r\n */\r\n async listAccounts(\r\n request: ListAccountsRequest\r\n ): Promise<Result<ListAccountsResponse>> {\r\n return this.http.request<ListAccountsResponse>(\r\n 'POST',\r\n '/accounts/list',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Get account details (internal).\r\n * Requires VIEW_ACCOUNTS permission in the specified system tenant.\r\n */\r\n async getAccount(\r\n request: GetAccountRequest\r\n ): Promise<Result<AccountDetailResponse>> {\r\n return this.http.request<AccountDetailResponse>(\r\n 'POST',\r\n '/accounts/get',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Update account profile (internal).\r\n * Requires UPDATE_ACCOUNT_PROFILE permission in the specified system tenant.\r\n */\r\n async updateAccountProfile(\r\n request: UpdateAccountProfileRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/accounts/update-profile',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Update account status (internal).\r\n * Requires UPDATE_ACCOUNT_STATUS permission in the specified system tenant.\r\n */\r\n async updateAccountStatus(\r\n request: UpdateAccountStatusRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/accounts/update-status',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Reset account credentials (internal).\r\n * Removes all credentials (or specific type) and resets MFA settings.\r\n * Requires RESET_ACCOUNT_CREDENTIALS permission in the specified system tenant.\r\n */\r\n async resetAccountCredentials(\r\n request: ResetAccountCredentialsRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/accounts/reset-credentials',\r\n { body: request }\r\n );\r\n }\r\n\r\n /**\r\n * Remove account (internal).\r\n * Hard deletes user data. Account must be suspended or deleted first.\r\n * Requires REMOVE_ACCOUNTS permission in the specified system tenant.\r\n */\r\n async removeAccount(\r\n request: RemoveAccountRequest\r\n ): Promise<Result<void>> {\r\n return this.http.request<void>(\r\n 'POST',\r\n '/accounts/remove',\r\n { body: request }\r\n );\r\n }\r\n}\r\n","/**\r\n * Backend SDK Types\r\n * Configuration, request, and response types for internal service-to-service calls\r\n */\r\n\r\n// ============================================================\r\n// JWT Configuration\r\n// ============================================================\r\n\r\n/** HMAC-SHA256 symmetric signing */\r\nexport interface JwtHmacConfig {\r\n strategy: 'hmac';\r\n /** Shared HMAC secret. MUST be different from user-facing JWT secret. */\r\n secret: string;\r\n}\r\n\r\n/** EdDSA (Ed25519) asymmetric signing */\r\nexport interface JwtEddsaConfig {\r\n strategy: 'eddsa';\r\n /** Ed25519 private key as hex string or raw bytes */\r\n privateKey: string | Uint8Array;\r\n}\r\n\r\n/** RS256 (RSA-SHA256) asymmetric signing */\r\nexport interface JwtRs256Config {\r\n strategy: 'rs256';\r\n /** RSA private key in PEM or JWK format */\r\n privateKey: string | JsonWebKey;\r\n}\r\n\r\n/** ES256 (ECDSA P-256) asymmetric signing */\r\nexport interface JwtEs256Config {\r\n strategy: 'es256';\r\n /** ECDSA P-256 private key in PEM or JWK format */\r\n privateKey: string | JsonWebKey;\r\n}\r\n\r\nexport type JwtConfig = (JwtHmacConfig | JwtEddsaConfig | JwtRs256Config | JwtEs256Config) & {\r\n /** JWT issuer claim (e.g., 'tenant-provisioning-service') */\r\n issuer?: string;\r\n /** JWT audience claim (e.g., 'auth-service') */\r\n audience?: string;\r\n /** Token TTL in seconds @default 300 (5 minutes) */\r\n expiresInSeconds?: number;\r\n};\r\n\r\n// ============================================================\r\n// Client Configuration\r\n// ============================================================\r\n\r\nexport interface InternalClientConfig {\r\n /** Base URL of the auth service (e.g., 'https://auth.example.com') */\r\n baseUrl: string;\r\n\r\n /**\r\n * Base path prefix before /internal (e.g., '/system' → /system/internal/*)\r\n * @default ''\r\n */\r\n basePath?: string;\r\n\r\n /** Service JWT signing configuration */\r\n jwt: JwtConfig;\r\n\r\n /** Custom fetch implementation (for testing or middleware) */\r\n fetchImpl?: typeof fetch;\r\n\r\n /** Request timeout in milliseconds @default 30000 */\r\n timeout?: number;\r\n\r\n /** Custom headers to include in all requests */\r\n headers?: Record<string, string>;\r\n}\r\n\r\n// ============================================================\r\n// Request Types\r\n// ============================================================\r\n\r\nexport interface BootstrapTenantOwnerRequest {\r\n tenantId: string;\r\n userId: string;\r\n}\r\n\r\nexport interface GetTenantProfileRequest {\r\n tenantId: string;\r\n userId: string;\r\n}\r\n\r\nexport interface ListTenantMembersRequest {\r\n tenantId: string;\r\n}\r\n\r\nexport interface UpdateTenantMemberStatusRequest {\r\n tenantId: string;\r\n userId: string;\r\n status: string;\r\n}\r\n\r\nexport interface UpdateTenantMemberPermissionRequest {\r\n tenantId: string;\r\n userId: string;\r\n role?: string;\r\n permMask?: number;\r\n authPerms?: string[];\r\n}\r\n\r\nexport interface ListTenantInvitesRequest {\r\n tenantId: string;\r\n status?: string;\r\n}\r\n\r\nexport interface InviteToTenantRequest {\r\n tenantId: string;\r\n invitedBy: string;\r\n inviteeUserId?: string;\r\n inviteeEmail?: string;\r\n inviteePhone?: string;\r\n role?: string;\r\n permMask?: number;\r\n authPerms?: string[];\r\n}\r\n\r\nexport interface AcceptInviteRequest {\r\n userId: string;\r\n inviteId?: string;\r\n inviteToken?: string;\r\n}\r\n\r\nexport interface DeclineInviteRequest {\r\n userId: string;\r\n inviteId?: string;\r\n inviteToken?: string;\r\n}\r\n\r\nexport interface RevokeInviteRequest {\r\n inviteId: string;\r\n revokedBy: string;\r\n}\r\n\r\nexport interface CheckPendingInvitesRequest {\r\n email?: string;\r\n phone?: string;\r\n}\r\n\r\nexport interface RemoveTenantMemberRequest {\r\n tenantId: string;\r\n userId: string;\r\n}\r\n\r\nexport interface UpdateTenantProfileRequest {\r\n tenantId: string;\r\n userId: string;\r\n contactEmail?: string;\r\n contactPhone?: string;\r\n displayName?: string;\r\n givenName?: string;\r\n familyName?: string;\r\n avatarUrl?: string;\r\n locale?: string;\r\n bio?: string;\r\n jobTitle?: string;\r\n metadata?: Record<string, unknown>;\r\n}\r\n\r\n// ============================================================\r\n// Account Management Request Types (Internal, System-Tenant)\r\n// ============================================================\r\n\r\n/** Common permission context for all account management requests */\r\nexport interface AccountPermContextRequest {\r\n /** User performing the action (must have the required account permission) */\r\n actorUserId: string;\r\n /** System tenant where the actor's account permissions are checked */\r\n systemTenantId: string;\r\n}\r\n\r\nexport interface ListAccountsRequest extends AccountPermContextRequest {\r\n status?: 'active' | 'inactive';\r\n limit?: number;\r\n cursor?: string;\r\n}\r\n\r\nexport interface GetAccountRequest extends AccountPermContextRequest {\r\n userId: string;\r\n}\r\n\r\nexport interface UpdateAccountProfileRequest extends AccountPermContextRequest {\r\n userId: string;\r\n displayName?: string;\r\n givenName?: string;\r\n familyName?: string;\r\n avatarUrl?: string;\r\n locale?: string;\r\n contactEmail?: string;\r\n contactPhone?: string;\r\n metadata?: Record<string, unknown>;\r\n}\r\n\r\nexport interface UpdateAccountStatusRequest extends AccountPermContextRequest {\r\n userId: string;\r\n status: string;\r\n}\r\n\r\nexport interface ResetAccountCredentialsRequest extends AccountPermContextRequest {\r\n userId: string;\r\n credentialType?: string;\r\n}\r\n\r\nexport interface RemoveAccountRequest extends AccountPermContextRequest {\r\n userId: string;\r\n}\r\n\r\n// ============================================================\r\n// Response Types\r\n// ============================================================\r\n\r\nexport interface BootstrapTenantOwnerResponse {\r\n message: string;\r\n tenantId: string;\r\n userId: string;\r\n role: string;\r\n}\r\n\r\nexport interface TenantProfileResponse {\r\n // Membership\r\n tenantId: string;\r\n userId: string;\r\n status: string;\r\n role?: string;\r\n permMask: number;\r\n authPerms: string[];\r\n isOwner: boolean;\r\n\r\n // Profile (optional — may not exist yet)\r\n displayName?: string;\r\n avatarUrl?: string;\r\n title?: string;\r\n bio?: string;\r\n metadata?: Record<string, unknown>;\r\n}\r\n\r\nexport interface TenantMemberProfileResponse {\r\n tenantId: string;\r\n userId: string;\r\n contactEmail?: string;\r\n contactPhone?: string;\r\n displayName?: string;\r\n displayNameSource?: 'user' | 'admin' | 'system';\r\n givenName?: string;\r\n familyName?: string;\r\n avatarUrl?: string;\r\n locale?: string;\r\n jobTitle?: string;\r\n bio?: string;\r\n metadata?: Record<string, unknown>;\r\n createdAt: string;\r\n updatedAt: string;\r\n}\r\n\r\nexport interface TenantMemberResponse {\r\n tenantId: string;\r\n userId: string;\r\n status: string;\r\n role?: string;\r\n permMask?: number;\r\n authPerms: string[];\r\n isOwner: boolean;\r\n createdAt: string;\r\n updatedAt: string;\r\n tenantProfile?: TenantMemberProfileResponse;\r\n}\r\n\r\nexport interface ListTenantMembersResponse {\r\n members: TenantMemberResponse[];\r\n}\r\n\r\nexport interface TenantInviteResponse {\r\n id: string;\r\n tenantId: string;\r\n invitedBy: string;\r\n inviteeUserId?: string;\r\n inviteeEmail?: string;\r\n inviteePhone?: string;\r\n role?: string;\r\n permMask?: number;\r\n authPerms: string[];\r\n status: string;\r\n expiresAt: string;\r\n createdAt: string;\r\n updatedAt: string;\r\n}\r\n\r\nexport interface ListTenantInvitesResponse {\r\n invites: TenantInviteResponse[];\r\n}\r\n\r\nexport interface InviteToTenantResponse {\r\n inviteId: string;\r\n inviteToken: string;\r\n expiresAt: string;\r\n}\r\n\r\nexport interface AcceptInviteResponse {\r\n tenantId: string;\r\n userId: string;\r\n}\r\n\r\nexport interface CheckPendingInvitesResponse {\r\n invites: TenantInviteResponse[];\r\n}\r\n\r\n// ============================================================\r\n// Account Management Response Types\r\n// ============================================================\r\n\r\nexport interface AccountSummaryResponse {\r\n id: string;\r\n contactEmail?: string;\r\n contactPhone?: string;\r\n displayName?: string;\r\n status: string;\r\n createdAt: string;\r\n updatedAt: string;\r\n}\r\n\r\nexport interface AccountDetailResponse extends AccountSummaryResponse {\r\n givenName?: string;\r\n familyName?: string;\r\n avatarUrl?: string;\r\n locale?: string;\r\n username?: string;\r\n metadata?: Record<string, unknown>;\r\n mfaRequired: boolean;\r\n mfaMethods: string[] | null;\r\n}\r\n\r\nexport interface ListAccountsResponse {\r\n accounts: AccountSummaryResponse[];\r\n nextCursor: string | null;\r\n}\r\n\r\n// ============================================================\r\n// Auth Permission String Constants\r\n// ============================================================\r\n\r\n/**\r\n * Valid auth permission strings for operations.\r\n * Use these when setting authPerms via the SDK.\r\n *\r\n * @example\r\n * ```ts\r\n * await client.updateTenantMemberPermission({\r\n * tenantId: 'org-123',\r\n * userId: 'user-abc',\r\n * authPerms: [AUTH_PERM_STRINGS.INVITE_MEMBERS, AUTH_PERM_STRINGS.VIEW_MEMBERS],\r\n * });\r\n * ```\r\n */\r\nexport const AUTH_PERM_STRINGS = {\r\n // ─── Tenant Member Management ──────────────────────────────────\r\n INVITE_MEMBERS: 'tenant.member.invite',\r\n REMOVE_MEMBERS: 'tenant.member.remove',\r\n VIEW_MEMBERS: 'tenant.member.view',\r\n CHANGE_MEMBER_PERMISSION: 'tenant.member.permission',\r\n UPDATE_MEMBER_PROFILE: 'tenant.member.profile.update',\r\n UPDATE_MEMBER_STATUS: 'tenant.member.status.update',\r\n // ─── Account Management ────────────────────────────────────────\r\n VIEW_ACCOUNTS: 'account.view',\r\n UPDATE_ACCOUNT_PROFILE: 'account.profile.update',\r\n UPDATE_ACCOUNT_STATUS: 'account.status.update',\r\n RESET_ACCOUNT_CREDENTIALS: 'account.credentials.reset',\r\n REMOVE_ACCOUNTS: 'account.remove',\r\n} as const;\r\n\r\n/** Union type of all valid auth permission strings */\r\nexport type AuthPermString = typeof AUTH_PERM_STRINGS[keyof typeof AUTH_PERM_STRINGS];\r\n\r\n// ============================================================\r\n// Internal Types (API response envelope)\r\n// ============================================================\r\n\r\n/** Standard API response envelope from auth service */\r\nexport interface ApiResponseEnvelope<T = unknown> {\r\n ok: boolean;\r\n data?: T;\r\n errors?: Array<{ code: string; message: string; field?: string }>;\r\n meta?: Record<string, unknown>;\r\n}\r\n","/**\r\n * @auth-craft/backend-sdk\r\n * Type-safe internal service SDK for Auth-Craft service-to-service calls.\r\n *\r\n * @example\r\n * ```ts\r\n * import { createInternalClient } from '@auth-craft/backend-sdk';\r\n *\r\n * const client = createInternalClient({\r\n * baseUrl: 'https://auth.example.com',\r\n * basePath: '/system',\r\n * jwt: {\r\n * strategy: 'hmac',\r\n * secret: process.env.INTERNAL_JWT_SECRET!,\r\n * issuer: 'tenant-provisioning-service',\r\n * },\r\n * });\r\n *\r\n * const result = await client.bootstrapTenantOwner({ tenantId, userId });\r\n * ```\r\n */\r\n\r\nimport { InternalClient } from './client';\r\nimport type { InternalClientConfig } from './types';\r\n\r\n/**\r\n * Create an internal service client for Auth-Craft.\r\n *\r\n * The client auto-signs service JWTs and refreshes them before expiry.\r\n */\r\nexport function createInternalClient(config: InternalClientConfig): InternalClient {\r\n return new InternalClient(config);\r\n}\r\n\r\n// Explicit type exports\r\nexport type {\r\n InternalClientConfig,\r\n JwtConfig,\r\n JwtHmacConfig,\r\n JwtEddsaConfig,\r\n JwtRs256Config,\r\n JwtEs256Config,\r\n BootstrapTenantOwnerRequest,\r\n BootstrapTenantOwnerResponse,\r\n GetTenantProfileRequest,\r\n TenantProfileResponse,\r\n InviteToTenantRequest,\r\n InviteToTenantResponse,\r\n AcceptInviteRequest,\r\n AcceptInviteResponse,\r\n DeclineInviteRequest,\r\n RevokeInviteRequest,\r\n CheckPendingInvitesRequest,\r\n CheckPendingInvitesResponse,\r\n ListTenantMembersRequest,\r\n ListTenantMembersResponse,\r\n TenantMemberResponse,\r\n TenantMemberProfileResponse,\r\n UpdateTenantMemberStatusRequest,\r\n UpdateTenantMemberPermissionRequest,\r\n RemoveTenantMemberRequest,\r\n ListTenantInvitesRequest,\r\n ListTenantInvitesResponse,\r\n TenantInviteResponse,\r\n UpdateTenantProfileRequest,\r\n // Account Management\r\n AccountPermContextRequest,\r\n ListAccountsRequest,\r\n ListAccountsResponse,\r\n AccountSummaryResponse,\r\n GetAccountRequest,\r\n AccountDetailResponse,\r\n UpdateAccountProfileRequest,\r\n UpdateAccountStatusRequest,\r\n ResetAccountCredentialsRequest,\r\n RemoveAccountRequest,\r\n} from './types';\r\n\r\nexport { InternalClient } from './client';\r\nexport { sdkErrors } from './errors';\r\nexport { AUTH_PERM_STRINGS } from './types';\r\nexport type { AuthPermString } from './types';\r\n"],"mappings":";AAKA,SAAS,IAAI,WAAW;;;ACSxB,SAAS,gBAAgB,MAA0B;AACjD,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,KAAK,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