@baseworks/iam 1.4.0 → 1.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/client.d.ts +22 -0
- package/dist/client.js +17 -0
- package/dist/events.d.ts +4 -4
- package/package.json +1 -1
- package/src/client.ts +28 -0
package/dist/client.d.ts
CHANGED
|
@@ -193,6 +193,28 @@ declare class IamClient {
|
|
|
193
193
|
org_id?: string;
|
|
194
194
|
}): Promise<ApiToken[]>;
|
|
195
195
|
revokeToken(id: string): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* The keys that belong to an organization. Needs `iam:org_key.read` there,
|
|
198
|
+
* which org-service decides; the answer says whether the caller may also
|
|
199
|
+
* manage them. A person's token: a service uses `listTokens({ org_id })`.
|
|
200
|
+
*/
|
|
201
|
+
listOrgKeys(orgRef: string): Promise<{
|
|
202
|
+
org_id: string;
|
|
203
|
+
role: string;
|
|
204
|
+
can_manage: boolean;
|
|
205
|
+
keys: ApiToken[];
|
|
206
|
+
}>;
|
|
207
|
+
/** Create a key for an organization; the secret is returned once. Needs `iam:org_key.manage`. */
|
|
208
|
+
createOrgKey(orgRef: string, input: {
|
|
209
|
+
name: string;
|
|
210
|
+
type?: 'service' | 'agent';
|
|
211
|
+
access?: 'read' | 'write';
|
|
212
|
+
/** The role the key acts with; never above the caller's, never owner. Default `member`. */
|
|
213
|
+
role?: 'viewer' | 'member' | 'admin';
|
|
214
|
+
expires_at?: number | null;
|
|
215
|
+
}): Promise<IssuedToken>;
|
|
216
|
+
/** Revoke one of an organization's keys. Needs `iam:org_key.manage`. */
|
|
217
|
+
revokeOrgKey(orgRef: string, id: string): Promise<void>;
|
|
196
218
|
/** Verify a raw token secret → its principal, or throw IamError(401). */
|
|
197
219
|
verifyToken(secret: string): Promise<TokenPrincipal>;
|
|
198
220
|
}
|
package/dist/client.js
CHANGED
|
@@ -112,6 +112,23 @@ var IamClient = class _IamClient {
|
|
|
112
112
|
async revokeToken(id) {
|
|
113
113
|
await this.api("DELETE", `/tokens/${encodeURIComponent(id)}`);
|
|
114
114
|
}
|
|
115
|
+
// ── an organization's keys (a realm with an org-service only) ───────────────
|
|
116
|
+
/**
|
|
117
|
+
* The keys that belong to an organization. Needs `iam:org_key.read` there,
|
|
118
|
+
* which org-service decides; the answer says whether the caller may also
|
|
119
|
+
* manage them. A person's token: a service uses `listTokens({ org_id })`.
|
|
120
|
+
*/
|
|
121
|
+
async listOrgKeys(orgRef) {
|
|
122
|
+
return this.api("GET", `/orgs/${encodeURIComponent(orgRef)}/keys`);
|
|
123
|
+
}
|
|
124
|
+
/** Create a key for an organization; the secret is returned once. Needs `iam:org_key.manage`. */
|
|
125
|
+
async createOrgKey(orgRef, input) {
|
|
126
|
+
return this.api("POST", `/orgs/${encodeURIComponent(orgRef)}/keys`, input);
|
|
127
|
+
}
|
|
128
|
+
/** Revoke one of an organization's keys. Needs `iam:org_key.manage`. */
|
|
129
|
+
async revokeOrgKey(orgRef, id) {
|
|
130
|
+
await this.api("DELETE", `/orgs/${encodeURIComponent(orgRef)}/keys/${encodeURIComponent(id)}`);
|
|
131
|
+
}
|
|
115
132
|
/** Verify a raw token secret → its principal, or throw IamError(401). */
|
|
116
133
|
async verifyToken(secret) {
|
|
117
134
|
const { principal } = await this.api("POST", "/tokens/verify", { token: secret });
|
package/dist/events.d.ts
CHANGED
|
@@ -25,17 +25,17 @@ declare const UserEvents: _baseworks_foldbase.EventCatalog<{
|
|
|
25
25
|
picture: z.ZodNullable<z.ZodString>;
|
|
26
26
|
at: z.ZodNumber;
|
|
27
27
|
}, "strip", z.ZodTypeAny, {
|
|
28
|
-
email: string;
|
|
29
28
|
at: number;
|
|
30
29
|
subject: string;
|
|
31
30
|
issuer: string;
|
|
31
|
+
email: string;
|
|
32
32
|
name: string | null;
|
|
33
33
|
picture: string | null;
|
|
34
34
|
}, {
|
|
35
|
-
email: string;
|
|
36
35
|
at: number;
|
|
37
36
|
subject: string;
|
|
38
37
|
issuer: string;
|
|
38
|
+
email: string;
|
|
39
39
|
name: string | null;
|
|
40
40
|
picture: string | null;
|
|
41
41
|
}>;
|
|
@@ -45,13 +45,13 @@ declare const UserEvents: _baseworks_foldbase.EventCatalog<{
|
|
|
45
45
|
picture: z.ZodNullable<z.ZodString>;
|
|
46
46
|
at: z.ZodNumber;
|
|
47
47
|
}, "strip", z.ZodTypeAny, {
|
|
48
|
-
email: string;
|
|
49
48
|
at: number;
|
|
49
|
+
email: string;
|
|
50
50
|
name: string | null;
|
|
51
51
|
picture: string | null;
|
|
52
52
|
}, {
|
|
53
|
-
email: string;
|
|
54
53
|
at: number;
|
|
54
|
+
email: string;
|
|
55
55
|
name: string | null;
|
|
56
56
|
picture: string | null;
|
|
57
57
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baseworks/iam",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "IAM capability: identity (users) + credentials (api tokens). Typed HTTP client, foldbase event catalog, projections, and CLI plugin for iam-service. Contract-first, versioned with the service. Roles/PDP live in @baseworks/org.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
package/src/client.ts
CHANGED
|
@@ -180,6 +180,34 @@ export class IamClient {
|
|
|
180
180
|
await this.api('DELETE', `/tokens/${encodeURIComponent(id)}`)
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
// ── an organization's keys (a realm with an org-service only) ───────────────
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The keys that belong to an organization. Needs `iam:org_key.read` there,
|
|
187
|
+
* which org-service decides; the answer says whether the caller may also
|
|
188
|
+
* manage them. A person's token: a service uses `listTokens({ org_id })`.
|
|
189
|
+
*/
|
|
190
|
+
async listOrgKeys(orgRef: string): Promise<{ org_id: string; role: string; can_manage: boolean; keys: ApiToken[] }> {
|
|
191
|
+
return this.api('GET', `/orgs/${encodeURIComponent(orgRef)}/keys`)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Create a key for an organization; the secret is returned once. Needs `iam:org_key.manage`. */
|
|
195
|
+
async createOrgKey(orgRef: string, input: {
|
|
196
|
+
name: string
|
|
197
|
+
type?: 'service' | 'agent'
|
|
198
|
+
access?: 'read' | 'write'
|
|
199
|
+
/** The role the key acts with; never above the caller's, never owner. Default `member`. */
|
|
200
|
+
role?: 'viewer' | 'member' | 'admin'
|
|
201
|
+
expires_at?: number | null
|
|
202
|
+
}): Promise<IssuedToken> {
|
|
203
|
+
return this.api<IssuedToken>('POST', `/orgs/${encodeURIComponent(orgRef)}/keys`, input)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Revoke one of an organization's keys. Needs `iam:org_key.manage`. */
|
|
207
|
+
async revokeOrgKey(orgRef: string, id: string): Promise<void> {
|
|
208
|
+
await this.api('DELETE', `/orgs/${encodeURIComponent(orgRef)}/keys/${encodeURIComponent(id)}`)
|
|
209
|
+
}
|
|
210
|
+
|
|
183
211
|
/** Verify a raw token secret → its principal, or throw IamError(401). */
|
|
184
212
|
async verifyToken(secret: string): Promise<TokenPrincipal> {
|
|
185
213
|
const { principal } = await this.api<{ principal: TokenPrincipal }>('POST', '/tokens/verify', { token: secret })
|