@auth-craft/backend-sdk 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -1
- package/dist/client.d.ts +116 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +177 -0
- package/dist/client.js.map +1 -0
- package/dist/contract-types.d.ts +59 -0
- package/dist/contract-types.d.ts.map +1 -0
- package/dist/contract-types.js +10 -0
- package/dist/contract-types.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +11 -0
- package/dist/errors.js.map +1 -0
- package/dist/http-client.d.ts +29 -0
- package/dist/http-client.d.ts.map +1 -0
- package/dist/http-client.js +139 -0
- package/dist/http-client.js.map +1 -0
- package/dist/index.d.ts +8 -542
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -436
- package/dist/index.js.map +1 -1
- package/dist/jwt-signer.d.ts +22 -0
- package/dist/jwt-signer.d.ts.map +1 -0
- package/dist/jwt-signer.js +139 -0
- package/dist/jwt-signer.js.map +1 -0
- package/dist/types.d.ts +137 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +58 -0
- package/dist/types.js.map +1 -0
- package/dist/types.test-d.d.ts +2 -0
- package/dist/types.test-d.d.ts.map +1 -0
- package/dist/types.test-d.js +38 -0
- package/dist/types.test-d.js.map +1 -0
- package/package.json +22 -20
- package/dist/index.cjs +0 -437
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -568
package/README.md
CHANGED
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
Type-safe internal service SDK for Auth-Craft service-to-service calls. Uses Web Crypto API for edge compatibility
|
|
15
|
+
Type-safe internal service SDK for Auth-Craft service-to-service calls. Uses the Web Crypto API for edge compatibility (Cloudflare Workers, Deno, Node 20+).
|
|
16
|
+
|
|
17
|
+
Request and response types are **inferred from `@auth-craft/api-contract/internal`** — the same valibot schemas the backend's internal router validates with. There are no hand-written request shapes to drift: change the contract and every call site here re-types at build. The SDK covers **all 21 internal endpoints**, 1:1 with the contract and the router; a type-level guard (`src/types.test-d.ts`) fails the build if an endpoint ever gains a method-less gap or a method drifts from its schema.
|
|
18
|
+
|
|
19
|
+
**Dependencies:** `ts-micro-result` (the `Result<T>` type), `@auth-craft/api-contract` (the contract, read via `typeof` for inference), and `valibot` (type-level inference only — not bundled at runtime).
|
|
16
20
|
|
|
17
21
|
## Installation
|
|
18
22
|
|
|
@@ -90,6 +94,12 @@ Tokens are auto-cached and reused until 60 seconds before expiry.
|
|
|
90
94
|
|
|
91
95
|
## Methods
|
|
92
96
|
|
|
97
|
+
All 21 internal endpoints, grouped by domain. Every method takes a single typed
|
|
98
|
+
`request` object (inferred from the contract) and returns `Promise<Result<T>>`.
|
|
99
|
+
Paths shown are relative to `serviceRoutePath` (default `/internal`).
|
|
100
|
+
|
|
101
|
+
### Tenant (3)
|
|
102
|
+
|
|
93
103
|
#### `bootstrapTenantOwner(request)` — `POST /internal/tenant/bootstrap-owner`
|
|
94
104
|
|
|
95
105
|
Assign owner role to a user for a new tenant. Typically called by tenant-provisioning service after creating a tenant.
|
|
@@ -102,10 +112,16 @@ Get per-tenant user profile with membership and permissions.
|
|
|
102
112
|
|
|
103
113
|
Update per-tenant user profile fields.
|
|
104
114
|
|
|
115
|
+
### Tenant members (4)
|
|
116
|
+
|
|
105
117
|
#### `listTenantMembers(request)` — `POST /internal/tenant/members/list`
|
|
106
118
|
|
|
107
119
|
List members of a tenant with profiles and permissions.
|
|
108
120
|
|
|
121
|
+
#### `addMemberToTenant(request)` — `POST /internal/tenant/members/add`
|
|
122
|
+
|
|
123
|
+
Add an existing user to a tenant directly (no invite flow).
|
|
124
|
+
|
|
109
125
|
#### `updateTenantMemberStatus(request)` — `POST /internal/tenant/members/update-status`
|
|
110
126
|
|
|
111
127
|
Update a tenant member's status.
|
|
@@ -118,6 +134,8 @@ Update a tenant member's roles and permissions.
|
|
|
118
134
|
|
|
119
135
|
Remove a member from a tenant.
|
|
120
136
|
|
|
137
|
+
### Tenant invites (6)
|
|
138
|
+
|
|
121
139
|
#### `inviteToTenant(request)` — `POST /internal/tenant/invites/create`
|
|
122
140
|
|
|
123
141
|
Create a tenant invite (bypasses INVITE_MEMBERS permission — service is trusted).
|
|
@@ -142,10 +160,14 @@ List invites for a tenant.
|
|
|
142
160
|
|
|
143
161
|
Check pending invites by email or phone.
|
|
144
162
|
|
|
163
|
+
### User (1)
|
|
164
|
+
|
|
145
165
|
#### `listUserTenants(request)` — `POST /internal/user/tenants/list`
|
|
146
166
|
|
|
147
167
|
List all tenants a user belongs to.
|
|
148
168
|
|
|
169
|
+
### Accounts (7)
|
|
170
|
+
|
|
149
171
|
#### `listAccounts(request)` — `POST /internal/accounts/list`
|
|
150
172
|
|
|
151
173
|
List user accounts (requires `VIEW_ACCOUNTS` permission in system tenant).
|
|
@@ -259,6 +281,12 @@ await client.updateTenantMemberPermission({
|
|
|
259
281
|
|
|
260
282
|
## Changelog
|
|
261
283
|
|
|
284
|
+
### 0.8.x
|
|
285
|
+
|
|
286
|
+
- Request/response types are now **inferred from `@auth-craft/api-contract/internal`** — no hand-written shapes; a contract change re-types every call site at build.
|
|
287
|
+
- Added a type-level coverage/shape guard (`src/types.test-d.ts`): the build fails if any of the 21 internal endpoints lacks a method, a method has no matching endpoint, or a method's argument drifts from its contract body.
|
|
288
|
+
- Documented the previously-undocumented `addMemberToTenant` method.
|
|
289
|
+
|
|
262
290
|
### 0.2.0
|
|
263
291
|
|
|
264
292
|
- **Breaking:** `ServiceJwtConfig.privateKeyJwk` renamed to `privateKey` — accepts hex 64-char (EdDSA) or base64 JWK
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal Client
|
|
3
|
+
* Type-safe client for auth service internal (service-to-service) API.
|
|
4
|
+
*/
|
|
5
|
+
import type { Result } from 'ts-micro-result';
|
|
6
|
+
import type { AcceptInviteRequest, AcceptInviteResponse, AccountDetailResponse, AddMemberToTenantRequest, AddMemberToTenantResponse, BootstrapTenantOwnerRequest, BootstrapTenantOwnerResponse, CheckPendingInvitesRequest, CheckPendingInvitesResponse, DeclineInviteRequest, GetAccountRequest, GetTenantProfileRequest, InternalClientConfig, InviteToTenantRequest, InviteToTenantResponse, ListAccountsRequest, ListAccountsResponse, ListTenantInvitesRequest, ListTenantInvitesResponse, ListTenantMembersRequest, ListTenantMembersResponse, ListUserTenantsRequest, ListUserTenantsResponse, RemoveAccountRequest, RemoveTenantMemberRequest, ResetAccountCredentialsRequest, RevokeInviteRequest, TenantProfileResponse, UpdateAccountProfileRequest, UpdateAccountStatusRequest, UpdateTenantMemberPermissionRequest, UpdateTenantMemberStatusRequest, UpdateTenantProfileRequest } from './types';
|
|
7
|
+
export declare class InternalClient {
|
|
8
|
+
private readonly http;
|
|
9
|
+
constructor(config: InternalClientConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Bootstrap tenant owner (assign owner role to a user for a new tenant).
|
|
12
|
+
* Typically called by tenant-provisioning service after creating a tenant.
|
|
13
|
+
*/
|
|
14
|
+
bootstrapTenantOwner(request: BootstrapTenantOwnerRequest): Promise<Result<BootstrapTenantOwnerResponse>>;
|
|
15
|
+
/**
|
|
16
|
+
* Get per-tenant user profile (internal).
|
|
17
|
+
* Allows services to read tenant profiles without user authentication.
|
|
18
|
+
*/
|
|
19
|
+
getTenantProfile(request: GetTenantProfileRequest): Promise<Result<TenantProfileResponse>>;
|
|
20
|
+
/**
|
|
21
|
+
* Update per-tenant user profile (internal).
|
|
22
|
+
* jobTitle is always accepted (service is trusted).
|
|
23
|
+
*/
|
|
24
|
+
updateTenantProfile(request: UpdateTenantProfileRequest): Promise<Result<void>>;
|
|
25
|
+
/**
|
|
26
|
+
* Invite a user to a tenant (internal).
|
|
27
|
+
* Bypasses INVITE_MEMBERS permission — service is trusted.
|
|
28
|
+
*/
|
|
29
|
+
inviteToTenant(request: InviteToTenantRequest): Promise<Result<InviteToTenantResponse>>;
|
|
30
|
+
/**
|
|
31
|
+
* Accept a tenant invite (internal).
|
|
32
|
+
*/
|
|
33
|
+
acceptInvite(request: AcceptInviteRequest): Promise<Result<AcceptInviteResponse>>;
|
|
34
|
+
/**
|
|
35
|
+
* Decline a tenant invite (internal).
|
|
36
|
+
*/
|
|
37
|
+
declineInvite(request: DeclineInviteRequest): Promise<Result<void>>;
|
|
38
|
+
/**
|
|
39
|
+
* Revoke a tenant invite (internal).
|
|
40
|
+
* Bypasses INVITE_MEMBERS permission — service is trusted.
|
|
41
|
+
*/
|
|
42
|
+
revokeInvite(request: RevokeInviteRequest): Promise<Result<void>>;
|
|
43
|
+
/**
|
|
44
|
+
* Check pending invites by email or phone (internal).
|
|
45
|
+
*/
|
|
46
|
+
checkPendingInvites(request: CheckPendingInvitesRequest): Promise<Result<CheckPendingInvitesResponse>>;
|
|
47
|
+
/**
|
|
48
|
+
* List tenant invites (internal).
|
|
49
|
+
* Returns invites with authPerms as string array.
|
|
50
|
+
*/
|
|
51
|
+
listTenantInvites(request: ListTenantInvitesRequest): Promise<Result<ListTenantInvitesResponse>>;
|
|
52
|
+
/**
|
|
53
|
+
* List tenant members (internal).
|
|
54
|
+
* Returns members with authPerms as string array and tenantProfile.
|
|
55
|
+
*/
|
|
56
|
+
listTenantMembers(request: ListTenantMembersRequest): Promise<Result<ListTenantMembersResponse>>;
|
|
57
|
+
/**
|
|
58
|
+
* Update a tenant member's status (internal).
|
|
59
|
+
* Protects owner invariant — cannot update owner status.
|
|
60
|
+
*/
|
|
61
|
+
updateTenantMemberStatus(request: UpdateTenantMemberStatusRequest): Promise<Result<void>>;
|
|
62
|
+
/**
|
|
63
|
+
* Update a tenant member's permission (internal).
|
|
64
|
+
* Protects owner invariant — cannot update owner permissions.
|
|
65
|
+
*/
|
|
66
|
+
updateTenantMemberPermission(request: UpdateTenantMemberPermissionRequest): Promise<Result<void>>;
|
|
67
|
+
/**
|
|
68
|
+
* Remove a tenant member (internal).
|
|
69
|
+
* Bypasses REMOVE_MEMBERS permission — service is trusted.
|
|
70
|
+
* Protects last owner invariant.
|
|
71
|
+
*/
|
|
72
|
+
removeTenantMember(request: RemoveTenantMemberRequest): Promise<Result<void>>;
|
|
73
|
+
/**
|
|
74
|
+
* Add a user directly as an active tenant member, bypassing the invite flow.
|
|
75
|
+
* Requires INVITE_MEMBERS permission on the actor.
|
|
76
|
+
*/
|
|
77
|
+
addMemberToTenant(request: AddMemberToTenantRequest): Promise<Result<AddMemberToTenantResponse>>;
|
|
78
|
+
/**
|
|
79
|
+
* List all tenants a user belongs to (internal).
|
|
80
|
+
* No permission check — service is trusted.
|
|
81
|
+
*/
|
|
82
|
+
listUserTenants(request: ListUserTenantsRequest): Promise<Result<ListUserTenantsResponse>>;
|
|
83
|
+
/**
|
|
84
|
+
* List accounts with cursor-based pagination (internal).
|
|
85
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
86
|
+
*/
|
|
87
|
+
listAccounts(request: ListAccountsRequest): Promise<Result<ListAccountsResponse>>;
|
|
88
|
+
/**
|
|
89
|
+
* Get account details (internal).
|
|
90
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
91
|
+
*/
|
|
92
|
+
getAccount(request: GetAccountRequest): Promise<Result<AccountDetailResponse>>;
|
|
93
|
+
/**
|
|
94
|
+
* Update account profile (internal).
|
|
95
|
+
* Requires UPDATE_ACCOUNT_PROFILE permission in the specified system tenant.
|
|
96
|
+
*/
|
|
97
|
+
updateAccountProfile(request: UpdateAccountProfileRequest): Promise<Result<void>>;
|
|
98
|
+
/**
|
|
99
|
+
* Update account status (internal).
|
|
100
|
+
* Requires UPDATE_ACCOUNT_STATUS permission in the specified system tenant.
|
|
101
|
+
*/
|
|
102
|
+
updateAccountStatus(request: UpdateAccountStatusRequest): Promise<Result<void>>;
|
|
103
|
+
/**
|
|
104
|
+
* Reset account credentials (internal).
|
|
105
|
+
* Removes all credentials (or specific type) and resets MFA settings.
|
|
106
|
+
* Requires RESET_ACCOUNT_CREDENTIALS permission in the specified system tenant.
|
|
107
|
+
*/
|
|
108
|
+
resetAccountCredentials(request: ResetAccountCredentialsRequest): Promise<Result<void>>;
|
|
109
|
+
/**
|
|
110
|
+
* Remove account (internal).
|
|
111
|
+
* Hard deletes user data. Account must be suspended or deleted first.
|
|
112
|
+
* Requires REMOVE_ACCOUNTS permission in the specified system tenant.
|
|
113
|
+
*/
|
|
114
|
+
removeAccount(request: RemoveAccountRequest): Promise<Result<void>>;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,yBAAyB,EACzB,8BAA8B,EAC9B,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,0BAA0B,EAC1B,mCAAmC,EACnC,+BAA+B,EAC/B,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AAEjB,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,MAAM,EAAE,oBAAoB;IAQxC;;;OAGG;IACG,oBAAoB,CAAC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,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAInF;;;OAGG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;IAQtG;;;OAGG;IACG,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAQhG;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAIvF;;;OAGG;IACG,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAIpF;;;OAGG;IACG,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAIvF;;;OAGG;IACG,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAIrF;;;;OAIG;IACG,uBAAuB,CAAC,OAAO,EAAE,8BAA8B,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAI7F;;;;OAIG;IACG,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CAG1E"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal Client
|
|
3
|
+
* Type-safe client for auth service internal (service-to-service) API.
|
|
4
|
+
*/
|
|
5
|
+
import { HttpClient } from './http-client';
|
|
6
|
+
export class InternalClient {
|
|
7
|
+
http;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.http = new HttpClient(config);
|
|
10
|
+
}
|
|
11
|
+
// ============================================================
|
|
12
|
+
// Bootstrap
|
|
13
|
+
// ============================================================
|
|
14
|
+
/**
|
|
15
|
+
* Bootstrap tenant owner (assign owner role to a user for a new tenant).
|
|
16
|
+
* Typically called by tenant-provisioning service after creating a tenant.
|
|
17
|
+
*/
|
|
18
|
+
async bootstrapTenantOwner(request) {
|
|
19
|
+
return this.http.request('POST', '/tenant/bootstrap-owner', { body: request });
|
|
20
|
+
}
|
|
21
|
+
// ============================================================
|
|
22
|
+
// Tenant Profile
|
|
23
|
+
// ============================================================
|
|
24
|
+
/**
|
|
25
|
+
* Get per-tenant user profile (internal).
|
|
26
|
+
* Allows services to read tenant profiles without user authentication.
|
|
27
|
+
*/
|
|
28
|
+
async getTenantProfile(request) {
|
|
29
|
+
return this.http.request('POST', '/tenant/profile', { body: request });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Update per-tenant user profile (internal).
|
|
33
|
+
* jobTitle is always accepted (service is trusted).
|
|
34
|
+
*/
|
|
35
|
+
async updateTenantProfile(request) {
|
|
36
|
+
return this.http.request('POST', '/tenant/profile/update', { body: request });
|
|
37
|
+
}
|
|
38
|
+
// ============================================================
|
|
39
|
+
// Invite Management
|
|
40
|
+
// ============================================================
|
|
41
|
+
/**
|
|
42
|
+
* Invite a user to a tenant (internal).
|
|
43
|
+
* Bypasses INVITE_MEMBERS permission — service is trusted.
|
|
44
|
+
*/
|
|
45
|
+
async inviteToTenant(request) {
|
|
46
|
+
return this.http.request('POST', '/tenant/invites/create', { body: request });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Accept a tenant invite (internal).
|
|
50
|
+
*/
|
|
51
|
+
async acceptInvite(request) {
|
|
52
|
+
return this.http.request('POST', '/tenant/invites/accept', { body: request });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Decline a tenant invite (internal).
|
|
56
|
+
*/
|
|
57
|
+
async declineInvite(request) {
|
|
58
|
+
return this.http.request('POST', '/tenant/invites/decline', { body: request });
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Revoke a tenant invite (internal).
|
|
62
|
+
* Bypasses INVITE_MEMBERS permission — service is trusted.
|
|
63
|
+
*/
|
|
64
|
+
async revokeInvite(request) {
|
|
65
|
+
return this.http.request('POST', '/tenant/invites/revoke', { body: request });
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Check pending invites by email or phone (internal).
|
|
69
|
+
*/
|
|
70
|
+
async checkPendingInvites(request) {
|
|
71
|
+
return this.http.request('POST', '/tenant/invites/check-pending', { body: request });
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* List tenant invites (internal).
|
|
75
|
+
* Returns invites with authPerms as string array.
|
|
76
|
+
*/
|
|
77
|
+
async listTenantInvites(request) {
|
|
78
|
+
return this.http.request('POST', '/tenant/invites/list', { body: request });
|
|
79
|
+
}
|
|
80
|
+
// ============================================================
|
|
81
|
+
// Member Management
|
|
82
|
+
// ============================================================
|
|
83
|
+
/**
|
|
84
|
+
* List tenant members (internal).
|
|
85
|
+
* Returns members with authPerms as string array and tenantProfile.
|
|
86
|
+
*/
|
|
87
|
+
async listTenantMembers(request) {
|
|
88
|
+
return this.http.request('POST', '/tenant/members/list', { body: request });
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Update a tenant member's status (internal).
|
|
92
|
+
* Protects owner invariant — cannot update owner status.
|
|
93
|
+
*/
|
|
94
|
+
async updateTenantMemberStatus(request) {
|
|
95
|
+
return this.http.request('POST', '/tenant/members/update-status', { body: request });
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Update a tenant member's permission (internal).
|
|
99
|
+
* Protects owner invariant — cannot update owner permissions.
|
|
100
|
+
*/
|
|
101
|
+
async updateTenantMemberPermission(request) {
|
|
102
|
+
return this.http.request('POST', '/tenant/members/update-permission', { body: request });
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Remove a tenant member (internal).
|
|
106
|
+
* Bypasses REMOVE_MEMBERS permission — service is trusted.
|
|
107
|
+
* Protects last owner invariant.
|
|
108
|
+
*/
|
|
109
|
+
async removeTenantMember(request) {
|
|
110
|
+
return this.http.request('POST', '/tenant/members/remove', { body: request });
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Add a user directly as an active tenant member, bypassing the invite flow.
|
|
114
|
+
* Requires INVITE_MEMBERS permission on the actor.
|
|
115
|
+
*/
|
|
116
|
+
async addMemberToTenant(request) {
|
|
117
|
+
return this.http.request('POST', '/tenant/members/add', { body: request });
|
|
118
|
+
}
|
|
119
|
+
// ============================================================
|
|
120
|
+
// User Tenants
|
|
121
|
+
// ============================================================
|
|
122
|
+
/**
|
|
123
|
+
* List all tenants a user belongs to (internal).
|
|
124
|
+
* No permission check — service is trusted.
|
|
125
|
+
*/
|
|
126
|
+
async listUserTenants(request) {
|
|
127
|
+
return this.http.request('POST', '/user/tenants/list', { body: request });
|
|
128
|
+
}
|
|
129
|
+
// ============================================================
|
|
130
|
+
// Account Management (System-Tenant Only)
|
|
131
|
+
// ============================================================
|
|
132
|
+
/**
|
|
133
|
+
* List accounts with cursor-based pagination (internal).
|
|
134
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
135
|
+
*/
|
|
136
|
+
async listAccounts(request) {
|
|
137
|
+
return this.http.request('POST', '/accounts/list', { body: request });
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get account details (internal).
|
|
141
|
+
* Requires VIEW_ACCOUNTS permission in the specified system tenant.
|
|
142
|
+
*/
|
|
143
|
+
async getAccount(request) {
|
|
144
|
+
return this.http.request('POST', '/accounts/get', { body: request });
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Update account profile (internal).
|
|
148
|
+
* Requires UPDATE_ACCOUNT_PROFILE permission in the specified system tenant.
|
|
149
|
+
*/
|
|
150
|
+
async updateAccountProfile(request) {
|
|
151
|
+
return this.http.request('POST', '/accounts/update-profile', { body: request });
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Update account status (internal).
|
|
155
|
+
* Requires UPDATE_ACCOUNT_STATUS permission in the specified system tenant.
|
|
156
|
+
*/
|
|
157
|
+
async updateAccountStatus(request) {
|
|
158
|
+
return this.http.request('POST', '/accounts/update-status', { body: request });
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Reset account credentials (internal).
|
|
162
|
+
* Removes all credentials (or specific type) and resets MFA settings.
|
|
163
|
+
* Requires RESET_ACCOUNT_CREDENTIALS permission in the specified system tenant.
|
|
164
|
+
*/
|
|
165
|
+
async resetAccountCredentials(request) {
|
|
166
|
+
return this.http.request('POST', '/accounts/reset-credentials', { body: request });
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Remove account (internal).
|
|
170
|
+
* Hard deletes user data. Account must be suspended or deleted first.
|
|
171
|
+
* Requires REMOVE_ACCOUNTS permission in the specified system tenant.
|
|
172
|
+
*/
|
|
173
|
+
async removeAccount(request) {
|
|
174
|
+
return this.http.request('POST', '/accounts/remove', { body: request });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAqC3C,MAAM,OAAO,cAAc;IACR,IAAI,CAAa;IAElC,YAAY,MAA4B;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,+DAA+D;IAC/D,YAAY;IACZ,+DAA+D;IAE/D;;;OAGG;IACH,KAAK,CAAC,oBAAoB,CAAC,OAAoC;QAC7D,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAA+B,MAAM,EAAE,yBAAyB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/G,CAAC;IAED,+DAA+D;IAC/D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C/C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,MAAM,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request/response types — INFERRED from @auth-craft/api-contract/internal.
|
|
3
|
+
*
|
|
4
|
+
* These used to be hand-written interfaces that could drift from the routes.
|
|
5
|
+
* Now they are derived from the same valibot schemas the internal-router
|
|
6
|
+
* validates with, so an internal API change re-types every call site here at
|
|
7
|
+
* build time. Do NOT re-add hand-written shapes for these — edit the contract.
|
|
8
|
+
*/
|
|
9
|
+
import { internalContract, internalResponses } from '@auth-craft/api-contract/internal';
|
|
10
|
+
import type { InferInput, InferOutput } from 'valibot';
|
|
11
|
+
type Body<K extends keyof typeof internalContract> = (typeof internalContract)[K] extends {
|
|
12
|
+
body: infer S;
|
|
13
|
+
} ? InferInput<S extends import('valibot').GenericSchema ? S : never> : never;
|
|
14
|
+
type Resp<K extends keyof typeof internalContract> = (typeof internalContract)[K] extends {
|
|
15
|
+
response: infer S;
|
|
16
|
+
} ? InferOutput<S extends import('valibot').GenericSchema ? S : never> : never;
|
|
17
|
+
export type BootstrapTenantOwnerRequest = Body<'bootstrapTenantOwner'>;
|
|
18
|
+
export type GetTenantProfileRequest = Body<'getTenantProfile'>;
|
|
19
|
+
export type UpdateTenantProfileRequest = Body<'updateTenantProfile'>;
|
|
20
|
+
export type ListTenantMembersRequest = Body<'listTenantMembers'>;
|
|
21
|
+
export type UpdateTenantMemberStatusRequest = Body<'updateTenantMemberStatus'>;
|
|
22
|
+
export type UpdateTenantMemberPermissionRequest = Body<'updateTenantMemberPermission'>;
|
|
23
|
+
export type RemoveTenantMemberRequest = Body<'removeTenantMember'>;
|
|
24
|
+
export type AddMemberToTenantRequest = Body<'addMemberToTenant'>;
|
|
25
|
+
export type ListTenantInvitesRequest = Body<'listTenantInvites'>;
|
|
26
|
+
export type InviteToTenantRequest = Body<'inviteToTenant'>;
|
|
27
|
+
export type AcceptInviteRequest = Body<'acceptInvite'>;
|
|
28
|
+
export type DeclineInviteRequest = Body<'declineInvite'>;
|
|
29
|
+
export type RevokeInviteRequest = Body<'revokeInvite'>;
|
|
30
|
+
export type CheckPendingInvitesRequest = Body<'checkPendingInvites'>;
|
|
31
|
+
export type ListUserTenantsRequest = Body<'listUserTenants'>;
|
|
32
|
+
export type ListAccountsRequest = Body<'listAccounts'>;
|
|
33
|
+
export type GetAccountRequest = Body<'getAccount'>;
|
|
34
|
+
export type UpdateAccountProfileRequest = Body<'updateAccountProfile'>;
|
|
35
|
+
export type UpdateAccountStatusRequest = Body<'updateAccountStatus'>;
|
|
36
|
+
export type ResetAccountCredentialsRequest = Body<'resetAccountCredentials'>;
|
|
37
|
+
export type RemoveAccountRequest = Body<'removeAccount'>;
|
|
38
|
+
export type BootstrapTenantOwnerResponse = Resp<'bootstrapTenantOwner'>;
|
|
39
|
+
export type TenantProfileResponse = Resp<'getTenantProfile'>;
|
|
40
|
+
export type AddMemberToTenantResponse = Resp<'addMemberToTenant'>;
|
|
41
|
+
export type InviteToTenantResponse = Resp<'inviteToTenant'>;
|
|
42
|
+
export type AcceptInviteResponse = Resp<'acceptInvite'>;
|
|
43
|
+
export type CheckPendingInvitesResponse = Resp<'checkPendingInvites'>;
|
|
44
|
+
export type TenantMemberResponse = InferOutput<typeof internalResponses.tenantMemberResponse>;
|
|
45
|
+
export type ListTenantMembersResponse = Resp<'listTenantMembers'>;
|
|
46
|
+
export type UserTenantResponse = InferOutput<typeof internalResponses.userTenantResponse>;
|
|
47
|
+
export type ListUserTenantsResponse = Resp<'listUserTenants'>;
|
|
48
|
+
export type TenantInviteResponse = InferOutput<typeof internalResponses.tenantInviteResponse>;
|
|
49
|
+
export type ListTenantInvitesResponse = Resp<'listTenantInvites'>;
|
|
50
|
+
export type AccountSummaryResponse = InferOutput<typeof internalResponses.accountSummaryResponse>;
|
|
51
|
+
export type ListAccountsResponse = Resp<'listAccounts'>;
|
|
52
|
+
export type AccountDetailResponse = Resp<'getAccount'>;
|
|
53
|
+
/** Common permission context for account-management requests. */
|
|
54
|
+
export type AccountPermContextRequest = Pick<ListAccountsRequest, 'actorUserId' | 'systemTenantId'>;
|
|
55
|
+
export type InvitedByInfo = NonNullable<TenantInviteResponse['invitedBy']>;
|
|
56
|
+
export type TenantProfileFields = Pick<TenantProfileResponse, 'tenantId' | 'userId' | 'contactEmail' | 'contactPhone' | 'displayName' | 'displayNameSource' | 'givenName' | 'familyName' | 'avatarUrl' | 'locale' | 'jobTitle' | 'bio' | 'metadata'>;
|
|
57
|
+
export type TenantMemberProfileResponse = NonNullable<TenantMemberResponse['tenantProfile']>;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=contract-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-types.d.ts","sourceRoot":"","sources":["../src/contract-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAEtD,KAAK,IAAI,CAAC,CAAC,SAAS,MAAM,OAAO,gBAAgB,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC,CAAA;CAAE,GACvG,UAAU,CAAC,CAAC,SAAS,OAAO,SAAS,EAAE,aAAa,GAAG,CAAC,GAAG,KAAK,CAAC,GACjE,KAAK,CAAA;AACT,KAAK,IAAI,CAAC,CAAC,SAAS,MAAM,OAAO,gBAAgB,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;CAAE,GAC3G,WAAW,CAAC,CAAC,SAAS,OAAO,SAAS,EAAE,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A;AAGtD,iEAAiE;AACjE,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,gBAAgB,CAAC,CAAA;AACnG,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAA;AAC1E,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACpC,qBAAqB,EACnB,UAAU,GACV,QAAQ,GACR,cAAc,GACd,cAAc,GACd,aAAa,GACb,mBAAmB,GACnB,WAAW,GACX,YAAY,GACZ,WAAW,GACX,QAAQ,GACR,UAAU,GACV,KAAK,GACL,UAAU,CACb,CAAA;AACD,MAAM,MAAM,2BAA2B,GAAG,WAAW,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request/response types — INFERRED from @auth-craft/api-contract/internal.
|
|
3
|
+
*
|
|
4
|
+
* These used to be hand-written interfaces that could drift from the routes.
|
|
5
|
+
* Now they are derived from the same valibot schemas the internal-router
|
|
6
|
+
* validates with, so an internal API change re-types every call site here at
|
|
7
|
+
* build time. Do NOT re-add hand-written shapes for these — edit the contract.
|
|
8
|
+
*/
|
|
9
|
+
import { internalContract, internalResponses } from '@auth-craft/api-contract/internal';
|
|
10
|
+
//# sourceMappingURL=contract-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-types.js","sourceRoot":"","sources":["../src/contract-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend SDK Error Definitions
|
|
3
|
+
*/
|
|
4
|
+
export declare const sdkErrors: {
|
|
5
|
+
readonly NETWORK_ERROR: (params?: import("ts-micro-result").BaseErrorParams) => import("ts-micro-result").ErrorDetail;
|
|
6
|
+
readonly TIMEOUT: (params?: import("ts-micro-result").BaseErrorParams) => import("ts-micro-result").ErrorDetail;
|
|
7
|
+
readonly INVALID_RESPONSE: (params?: import("ts-micro-result").BaseErrorParams) => import("ts-micro-result").ErrorDetail;
|
|
8
|
+
readonly JWT_SIGN_FAILED: (params?: import("ts-micro-result").BaseErrorParams) => import("ts-micro-result").ErrorDetail;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,eAAO,MAAM,SAAS;;;;;CAKZ,CAAC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend SDK Error Definitions
|
|
3
|
+
*/
|
|
4
|
+
import { defineError } from 'ts-micro-result';
|
|
5
|
+
export const sdkErrors = {
|
|
6
|
+
NETWORK_ERROR: defineError('SDK_NETWORK_ERROR', 'Network request failed'),
|
|
7
|
+
TIMEOUT: defineError('SDK_TIMEOUT', 'Request timed out'),
|
|
8
|
+
INVALID_RESPONSE: defineError('SDK_INVALID_RESPONSE', 'Invalid response from auth service'),
|
|
9
|
+
JWT_SIGN_FAILED: defineError('SDK_JWT_SIGN_FAILED', 'Failed to sign service JWT'),
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,aAAa,EAAE,WAAW,CAAC,mBAAmB,EAAE,wBAAwB,CAAC;IACzE,OAAO,EAAE,WAAW,CAAC,aAAa,EAAE,mBAAmB,CAAC;IACxD,gBAAgB,EAAE,WAAW,CAAC,sBAAsB,EAAE,oCAAoC,CAAC;IAC3F,eAAe,EAAE,WAAW,CAAC,qBAAqB,EAAE,4BAA4B,CAAC;CACzE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level HTTP Client
|
|
3
|
+
* Wraps fetch with Service JWT signing, timeout, and Result<T> mapping.
|
|
4
|
+
*/
|
|
5
|
+
import type { Result } from 'ts-micro-result';
|
|
6
|
+
import type { InternalClientConfig } from './types';
|
|
7
|
+
type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
8
|
+
export declare class HttpClient {
|
|
9
|
+
private static readonly RESPONSE_PREVIEW_LIMIT;
|
|
10
|
+
private static readonly DEFAULT_SECRET_HEADER_NAME;
|
|
11
|
+
private readonly config;
|
|
12
|
+
private readonly baseUrl;
|
|
13
|
+
private readonly basePath;
|
|
14
|
+
private readonly serviceRoutePath;
|
|
15
|
+
private readonly fetchFn;
|
|
16
|
+
private readonly timeout;
|
|
17
|
+
private readonly customHeaders;
|
|
18
|
+
private readonly logger;
|
|
19
|
+
constructor(config: InternalClientConfig);
|
|
20
|
+
request<T>(method: HttpMethod, path: string, options?: {
|
|
21
|
+
body?: unknown;
|
|
22
|
+
query?: Record<string, string>;
|
|
23
|
+
}): Promise<Result<T>>;
|
|
24
|
+
private buildUrl;
|
|
25
|
+
private buildSecretHeader;
|
|
26
|
+
private static buildResponsePreview;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,iBAAiB,CAAC;AAI1D,OAAO,KAAK,EAAuB,oBAAoB,EAAE,MAAM,S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