@olyzon/sdk 0.0.0 → 0.1.0-stg.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/LICENSE +21 -0
- package/README.md +17 -1
- package/dist/client.d.ts +62 -0
- package/dist/client.js +104 -0
- package/dist/core/config.d.ts +153 -0
- package/dist/core/config.js +368 -0
- package/dist/core/contracts.d.ts +52 -0
- package/dist/core/contracts.js +12 -0
- package/dist/core/dpop.d.ts +39 -0
- package/dist/core/dpop.js +63 -0
- package/dist/core/errors.d.ts +34 -0
- package/dist/core/errors.js +43 -0
- package/dist/core/session.d.ts +82 -0
- package/dist/core/session.js +170 -0
- package/dist/core/transport.d.ts +38 -0
- package/dist/core/transport.js +84 -0
- package/dist/generated/index.d.ts +24 -0
- package/dist/generated/index.js +20 -0
- package/dist/generated/manifest.json +13 -0
- package/dist/generated/projects/client/client.gen.d.ts +2 -0
- package/dist/generated/projects/client/client.gen.js +216 -0
- package/dist/generated/projects/client/index.d.ts +10 -0
- package/dist/generated/projects/client/index.js +6 -0
- package/dist/generated/projects/client/types.gen.d.ts +120 -0
- package/dist/generated/projects/client/types.gen.js +2 -0
- package/dist/generated/projects/client/utils.gen.d.ts +37 -0
- package/dist/generated/projects/client/utils.gen.js +228 -0
- package/dist/generated/projects/client.gen.d.ts +12 -0
- package/dist/generated/projects/client.gen.js +3 -0
- package/dist/generated/projects/core/auth.gen.d.ts +25 -0
- package/dist/generated/projects/core/auth.gen.js +14 -0
- package/dist/generated/projects/core/bodySerializer.gen.d.ts +25 -0
- package/dist/generated/projects/core/bodySerializer.gen.js +57 -0
- package/dist/generated/projects/core/params.gen.d.ts +43 -0
- package/dist/generated/projects/core/params.gen.js +109 -0
- package/dist/generated/projects/core/pathSerializer.gen.d.ts +33 -0
- package/dist/generated/projects/core/pathSerializer.gen.js +106 -0
- package/dist/generated/projects/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/generated/projects/core/queryKeySerializer.gen.js +92 -0
- package/dist/generated/projects/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/generated/projects/core/serverSentEvents.gen.js +132 -0
- package/dist/generated/projects/core/types.gen.d.ts +83 -0
- package/dist/generated/projects/core/types.gen.js +2 -0
- package/dist/generated/projects/core/utils.gen.d.ts +19 -0
- package/dist/generated/projects/core/utils.gen.js +87 -0
- package/dist/generated/projects/index.d.ts +2 -0
- package/dist/generated/projects/index.js +2 -0
- package/dist/generated/projects/sdk.gen.d.ts +47 -0
- package/dist/generated/projects/sdk.gen.js +55 -0
- package/dist/generated/projects/types.gen.d.ts +388 -0
- package/dist/generated/projects/types.gen.js +2 -0
- package/dist/generated/projects.d.ts +54 -0
- package/dist/generated/projects.js +58 -0
- package/dist/generated/specs/projects.json +872 -0
- package/dist/generated/specs/sts.json +942 -0
- package/dist/generated/sts/client/client.gen.d.ts +2 -0
- package/dist/generated/sts/client/client.gen.js +216 -0
- package/dist/generated/sts/client/index.d.ts +10 -0
- package/dist/generated/sts/client/index.js +6 -0
- package/dist/generated/sts/client/types.gen.d.ts +120 -0
- package/dist/generated/sts/client/types.gen.js +2 -0
- package/dist/generated/sts/client/utils.gen.d.ts +37 -0
- package/dist/generated/sts/client/utils.gen.js +228 -0
- package/dist/generated/sts/client.gen.d.ts +12 -0
- package/dist/generated/sts/client.gen.js +3 -0
- package/dist/generated/sts/core/auth.gen.d.ts +25 -0
- package/dist/generated/sts/core/auth.gen.js +14 -0
- package/dist/generated/sts/core/bodySerializer.gen.d.ts +25 -0
- package/dist/generated/sts/core/bodySerializer.gen.js +57 -0
- package/dist/generated/sts/core/params.gen.d.ts +43 -0
- package/dist/generated/sts/core/params.gen.js +109 -0
- package/dist/generated/sts/core/pathSerializer.gen.d.ts +33 -0
- package/dist/generated/sts/core/pathSerializer.gen.js +106 -0
- package/dist/generated/sts/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/generated/sts/core/queryKeySerializer.gen.js +92 -0
- package/dist/generated/sts/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/generated/sts/core/serverSentEvents.gen.js +132 -0
- package/dist/generated/sts/core/types.gen.d.ts +83 -0
- package/dist/generated/sts/core/types.gen.js +2 -0
- package/dist/generated/sts/core/utils.gen.d.ts +19 -0
- package/dist/generated/sts/core/utils.gen.js +87 -0
- package/dist/generated/sts/index.d.ts +2 -0
- package/dist/generated/sts/index.js +2 -0
- package/dist/generated/sts/sdk.gen.d.ts +41 -0
- package/dist/generated/sts/sdk.gen.js +44 -0
- package/dist/generated/sts/types.gen.d.ts +445 -0
- package/dist/generated/sts/types.gen.js +2 -0
- package/dist/generated/sts.d.ts +44 -0
- package/dist/generated/sts.js +49 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +13 -0
- package/package.json +42 -5
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
export type ClientOptions = {
|
|
2
|
+
baseUrl: `${string}://specs` | (string & {});
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* The body is over 64 KB.
|
|
6
|
+
*/
|
|
7
|
+
export type BodyTooLarge = {
|
|
8
|
+
/**
|
|
9
|
+
* Machine-readable error code.
|
|
10
|
+
*/
|
|
11
|
+
error: 'invalid_request';
|
|
12
|
+
/**
|
|
13
|
+
* What went wrong, for people. Never contains internal details.
|
|
14
|
+
*/
|
|
15
|
+
error_description: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The caller's session, as the STS issued it: who, in which workspace, until when.
|
|
19
|
+
*/
|
|
20
|
+
export type CallerIdentity = {
|
|
21
|
+
/**
|
|
22
|
+
* Clerk's ID of the person, the org API key or the machine.
|
|
23
|
+
*/
|
|
24
|
+
sub: string;
|
|
25
|
+
/**
|
|
26
|
+
* A person, an org (its API key) or a machine.
|
|
27
|
+
*/
|
|
28
|
+
kind: 'user' | 'org' | 'service';
|
|
29
|
+
/**
|
|
30
|
+
* The workspace (Clerk org) the session acts in.
|
|
31
|
+
*/
|
|
32
|
+
org: string;
|
|
33
|
+
org_name: string;
|
|
34
|
+
/**
|
|
35
|
+
* The person's role in the org, read at exchange, or the role named for a key or machine.
|
|
36
|
+
*/
|
|
37
|
+
role: string;
|
|
38
|
+
/**
|
|
39
|
+
* The client: `web`, `desktop`, `mobile`, an API key's ID, a machine's ID.
|
|
40
|
+
*/
|
|
41
|
+
azp: string;
|
|
42
|
+
/**
|
|
43
|
+
* The credential the session was exchanged for: a Clerk credential, or a grant.
|
|
44
|
+
*/
|
|
45
|
+
cred: 'session' | 'oauth' | 'api_key' | 'm2m' | 'grant';
|
|
46
|
+
/**
|
|
47
|
+
* An API key's or machine's name, an OAuth client's ID.
|
|
48
|
+
*/
|
|
49
|
+
kn?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The session's ID.
|
|
52
|
+
*/
|
|
53
|
+
sid: string;
|
|
54
|
+
/**
|
|
55
|
+
* When the session expires, in seconds since the epoch.
|
|
56
|
+
*/
|
|
57
|
+
exp: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The session may not perform this action (Cedar).
|
|
61
|
+
*/
|
|
62
|
+
export type Forbidden = {
|
|
63
|
+
/**
|
|
64
|
+
* Machine-readable error code.
|
|
65
|
+
*/
|
|
66
|
+
error: 'forbidden';
|
|
67
|
+
/**
|
|
68
|
+
* What went wrong, for people. Never contains internal details.
|
|
69
|
+
*/
|
|
70
|
+
error_description: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* A delegation from a person to a registered service (spec §6.2).
|
|
74
|
+
*/
|
|
75
|
+
export type Grant = {
|
|
76
|
+
/**
|
|
77
|
+
* `grt_` and a UUID. Not a credential on its own: only its actor can exchange it.
|
|
78
|
+
*/
|
|
79
|
+
id: GrantId;
|
|
80
|
+
/**
|
|
81
|
+
* The workspace (Clerk org) it acts in: its subject's.
|
|
82
|
+
*/
|
|
83
|
+
org: string;
|
|
84
|
+
/**
|
|
85
|
+
* The person who gave it: the caller of the request that created it.
|
|
86
|
+
*/
|
|
87
|
+
subject: string;
|
|
88
|
+
/**
|
|
89
|
+
* The service or agent allowed to exchange it, by registry name: the service that created it, or
|
|
90
|
+
* an agent that service runs.
|
|
91
|
+
*/
|
|
92
|
+
actor: string;
|
|
93
|
+
/**
|
|
94
|
+
* When its actor is an agent: the service that runs it, which creates and revokes its grants.
|
|
95
|
+
*/
|
|
96
|
+
actorRunBy?: string;
|
|
97
|
+
/**
|
|
98
|
+
* The Cedar actions its sessions may perform, qualified: `Olyzon::Reports::Action::"refresh"`.
|
|
99
|
+
* Each service still decides with its own policies; a grant only narrows them.
|
|
100
|
+
*/
|
|
101
|
+
actions: Array<string>;
|
|
102
|
+
/**
|
|
103
|
+
* The services its sessions may call, by registry name: one exchange per service.
|
|
104
|
+
*/
|
|
105
|
+
audience: Array<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Set when only one key of its actor may exchange it: that key's JWK SHA-256 thumbprint (RFC 7638).
|
|
108
|
+
*/
|
|
109
|
+
bindJkt?: string;
|
|
110
|
+
/**
|
|
111
|
+
* At most 31 days after its creation.
|
|
112
|
+
*/
|
|
113
|
+
expiresAt: string;
|
|
114
|
+
/**
|
|
115
|
+
* Set once revoked: its next exchange fails.
|
|
116
|
+
*/
|
|
117
|
+
revokedAt?: string;
|
|
118
|
+
createdAt: string;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* A grant's ID: `grt_` and a UUID.
|
|
122
|
+
*/
|
|
123
|
+
export type GrantId = string;
|
|
124
|
+
/**
|
|
125
|
+
* The request does not match the operation's input: every invalid field is named.
|
|
126
|
+
*/
|
|
127
|
+
export type InvalidRequest = {
|
|
128
|
+
/**
|
|
129
|
+
* Machine-readable error code.
|
|
130
|
+
*/
|
|
131
|
+
error: 'invalid_request';
|
|
132
|
+
/**
|
|
133
|
+
* What went wrong, for people. Never contains internal details.
|
|
134
|
+
*/
|
|
135
|
+
error_description: string;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* The workspace is not served by this STS: another region's, or still provisioning.
|
|
139
|
+
*/
|
|
140
|
+
export type InvalidTarget = {
|
|
141
|
+
/**
|
|
142
|
+
* Machine-readable error code.
|
|
143
|
+
*/
|
|
144
|
+
error: 'invalid_target';
|
|
145
|
+
/**
|
|
146
|
+
* What went wrong, for people. Never contains internal details.
|
|
147
|
+
*/
|
|
148
|
+
error_description: string;
|
|
149
|
+
/**
|
|
150
|
+
* The region whose STS serves the workspace; absent while it is provisioning.
|
|
151
|
+
*/
|
|
152
|
+
region?: string;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* A grant to create. Its subject and org come from the forwarded credentials; its actor is the
|
|
156
|
+
* calling service unless it names an agent it runs.
|
|
157
|
+
*/
|
|
158
|
+
export type NewGrant = {
|
|
159
|
+
/**
|
|
160
|
+
* An agent the calling service runs, by registry name: it exchanges the grant instead.
|
|
161
|
+
*/
|
|
162
|
+
actor?: string;
|
|
163
|
+
actions: Array<string>;
|
|
164
|
+
audience: Array<string>;
|
|
165
|
+
expiresAt: string;
|
|
166
|
+
/**
|
|
167
|
+
* Only the actor's key with this JWK SHA-256 thumbprint (RFC 7638) may exchange it.
|
|
168
|
+
*/
|
|
169
|
+
bindJkt?: string;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* No such resource or route, or a resource the session's org cannot see.
|
|
173
|
+
*/
|
|
174
|
+
export type NotFound = {
|
|
175
|
+
/**
|
|
176
|
+
* Machine-readable error code.
|
|
177
|
+
*/
|
|
178
|
+
error: 'not_found';
|
|
179
|
+
/**
|
|
180
|
+
* What went wrong, for people. Never contains internal details.
|
|
181
|
+
*/
|
|
182
|
+
error_description: string;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Unexpected failure: logged by the service, answered without details.
|
|
186
|
+
*/
|
|
187
|
+
export type ServerError = {
|
|
188
|
+
/**
|
|
189
|
+
* Machine-readable error code.
|
|
190
|
+
*/
|
|
191
|
+
error: 'server_error';
|
|
192
|
+
/**
|
|
193
|
+
* What went wrong, for people. Never contains internal details.
|
|
194
|
+
*/
|
|
195
|
+
error_description: string;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Clerk cannot be reached: retry later.
|
|
199
|
+
*/
|
|
200
|
+
export type TemporarilyUnavailable = {
|
|
201
|
+
/**
|
|
202
|
+
* Machine-readable error code.
|
|
203
|
+
*/
|
|
204
|
+
error: 'temporarily_unavailable';
|
|
205
|
+
/**
|
|
206
|
+
* What went wrong, for people. Never contains internal details.
|
|
207
|
+
*/
|
|
208
|
+
error_description: string;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* A token exchange request (RFC 8693 §2.1): any other parameter is refused.
|
|
212
|
+
*/
|
|
213
|
+
export type TokenExchangeForm = {
|
|
214
|
+
/**
|
|
215
|
+
* `urn:ietf:params:oauth:grant-type:token-exchange`, the only grant supported.
|
|
216
|
+
*/
|
|
217
|
+
grant_type: string;
|
|
218
|
+
/**
|
|
219
|
+
* The Clerk credential (a session token, an API key, an M2M token `mt_…` or an OAuth access
|
|
220
|
+
* token), or a grant's ID.
|
|
221
|
+
*/
|
|
222
|
+
subject_token: string;
|
|
223
|
+
/**
|
|
224
|
+
* `urn:olyzon:token-type:clerk` for every Clerk credential, `urn:olyzon:token-type:grant` for a grant.
|
|
225
|
+
*/
|
|
226
|
+
subject_token_type: string;
|
|
227
|
+
/**
|
|
228
|
+
* A grant only: its actor's own session, bound to the proof's key (spec §6.3).
|
|
229
|
+
*/
|
|
230
|
+
actor_token?: string;
|
|
231
|
+
/**
|
|
232
|
+
* A grant only: `urn:ietf:params:oauth:token-type:access_token`.
|
|
233
|
+
*/
|
|
234
|
+
actor_token_type?: string;
|
|
235
|
+
/**
|
|
236
|
+
* A grant only: the one service the session is for, by registry name (RFC 8693 §2.1).
|
|
237
|
+
*/
|
|
238
|
+
audience?: string;
|
|
239
|
+
/**
|
|
240
|
+
* `urn:ietf:params:oauth:token-type:access_token` if given: the session is the only token issued.
|
|
241
|
+
*/
|
|
242
|
+
requested_token_type?: string;
|
|
243
|
+
/**
|
|
244
|
+
* The workspace (Clerk org) to act in: required, except with an org API key (its own org).
|
|
245
|
+
*/
|
|
246
|
+
org_id?: string;
|
|
247
|
+
/**
|
|
248
|
+
* The role of an org API key's or an M2M token's session: 1–64 letters, digits or `: . _ -`.
|
|
249
|
+
*/
|
|
250
|
+
role?: string;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* A refused exchange: a credential Clerk refuses or a person who is not a
|
|
254
|
+
* member (`invalid_grant`), another grant or subject token type, or a proof
|
|
255
|
+
* that does not match the request.
|
|
256
|
+
*/
|
|
257
|
+
export type TokenRefused = {
|
|
258
|
+
/**
|
|
259
|
+
* Machine-readable error code.
|
|
260
|
+
*/
|
|
261
|
+
error: 'invalid_grant' | 'unsupported_grant_type' | 'unsupported_token_type' | 'invalid_dpop_proof';
|
|
262
|
+
/**
|
|
263
|
+
* What went wrong, for people. Never contains internal details.
|
|
264
|
+
*/
|
|
265
|
+
error_description: string;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* A session (RFC 8693 §2.2.1): a JWT signed by the STS, bound to the proof's key.
|
|
269
|
+
*/
|
|
270
|
+
export type TokenResponse = {
|
|
271
|
+
/**
|
|
272
|
+
* The session.
|
|
273
|
+
*/
|
|
274
|
+
access_token: string;
|
|
275
|
+
/**
|
|
276
|
+
* Every use needs a DPoP proof of the same key.
|
|
277
|
+
*/
|
|
278
|
+
token_type: 'DPoP';
|
|
279
|
+
/**
|
|
280
|
+
* Its lifetime, in seconds: 15 minutes for a person, an hour for an org key or a machine, 5
|
|
281
|
+
* minutes for a grant's (never past the grant's expiry).
|
|
282
|
+
*/
|
|
283
|
+
expires_in: number;
|
|
284
|
+
issued_token_type: 'urn:ietf:params:oauth:token-type:access_token';
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Missing, invalid or expired session, or a proof that does not match this request.
|
|
288
|
+
*/
|
|
289
|
+
export type Unauthorized = {
|
|
290
|
+
/**
|
|
291
|
+
* Machine-readable error code.
|
|
292
|
+
*/
|
|
293
|
+
error: 'invalid_token' | 'invalid_dpop_proof';
|
|
294
|
+
/**
|
|
295
|
+
* What went wrong, for people. Never contains internal details.
|
|
296
|
+
*/
|
|
297
|
+
error_description: string;
|
|
298
|
+
};
|
|
299
|
+
/**
|
|
300
|
+
* The proof lacks the current nonce, or has an old one: retry once with `DPoP-Nonce` (RFC 9449 §8).
|
|
301
|
+
*/
|
|
302
|
+
export type UseDpopNonce = {
|
|
303
|
+
/**
|
|
304
|
+
* Machine-readable error code.
|
|
305
|
+
*/
|
|
306
|
+
error: 'use_dpop_nonce';
|
|
307
|
+
/**
|
|
308
|
+
* What went wrong, for people. Never contains internal details.
|
|
309
|
+
*/
|
|
310
|
+
error_description: string;
|
|
311
|
+
};
|
|
312
|
+
export type ExchangeTokenData = {
|
|
313
|
+
body: TokenExchangeForm;
|
|
314
|
+
path?: never;
|
|
315
|
+
query?: never;
|
|
316
|
+
url: '/oauth/token';
|
|
317
|
+
};
|
|
318
|
+
export type ExchangeTokenErrors = {
|
|
319
|
+
/**
|
|
320
|
+
* The request does not match the operation's input: every invalid field is named.
|
|
321
|
+
*/
|
|
322
|
+
400: InvalidRequest | TokenRefused | UseDpopNonce | InvalidTarget;
|
|
323
|
+
/**
|
|
324
|
+
* The body is over 64 KB.
|
|
325
|
+
*/
|
|
326
|
+
413: BodyTooLarge;
|
|
327
|
+
/**
|
|
328
|
+
* Unexpected failure: logged by the service, answered without details.
|
|
329
|
+
*/
|
|
330
|
+
500: ServerError;
|
|
331
|
+
/**
|
|
332
|
+
* Clerk cannot be reached: retry later.
|
|
333
|
+
*/
|
|
334
|
+
503: TemporarilyUnavailable;
|
|
335
|
+
};
|
|
336
|
+
export type ExchangeTokenError = ExchangeTokenErrors[keyof ExchangeTokenErrors];
|
|
337
|
+
export type ExchangeTokenResponses = {
|
|
338
|
+
/**
|
|
339
|
+
* The session issued.
|
|
340
|
+
*/
|
|
341
|
+
200: TokenResponse;
|
|
342
|
+
};
|
|
343
|
+
export type ExchangeTokenResponse = ExchangeTokenResponses[keyof ExchangeTokenResponses];
|
|
344
|
+
export type GetCallerIdentityData = {
|
|
345
|
+
body?: never;
|
|
346
|
+
path?: never;
|
|
347
|
+
query?: never;
|
|
348
|
+
url: '/v1/caller-identity';
|
|
349
|
+
};
|
|
350
|
+
export type GetCallerIdentityErrors = {
|
|
351
|
+
/**
|
|
352
|
+
* Missing, invalid or expired session, or a proof that does not match this request.
|
|
353
|
+
*/
|
|
354
|
+
401: Unauthorized;
|
|
355
|
+
/**
|
|
356
|
+
* The session may not perform this action (Cedar).
|
|
357
|
+
*/
|
|
358
|
+
403: Forbidden;
|
|
359
|
+
/**
|
|
360
|
+
* No such resource or route, or a resource the session's org cannot see.
|
|
361
|
+
*/
|
|
362
|
+
404: NotFound;
|
|
363
|
+
/**
|
|
364
|
+
* Unexpected failure: logged by the service, answered without details.
|
|
365
|
+
*/
|
|
366
|
+
500: ServerError;
|
|
367
|
+
};
|
|
368
|
+
export type GetCallerIdentityError = GetCallerIdentityErrors[keyof GetCallerIdentityErrors];
|
|
369
|
+
export type GetCallerIdentityResponses = {
|
|
370
|
+
/**
|
|
371
|
+
* The request has succeeded.
|
|
372
|
+
*/
|
|
373
|
+
200: CallerIdentity;
|
|
374
|
+
};
|
|
375
|
+
export type GetCallerIdentityResponse = GetCallerIdentityResponses[keyof GetCallerIdentityResponses];
|
|
376
|
+
export type CreateGrantData = {
|
|
377
|
+
body: NewGrant;
|
|
378
|
+
path?: never;
|
|
379
|
+
query?: never;
|
|
380
|
+
url: '/v1/grants';
|
|
381
|
+
};
|
|
382
|
+
export type CreateGrantErrors = {
|
|
383
|
+
/**
|
|
384
|
+
* The request does not match the operation's input: every invalid field is named.
|
|
385
|
+
*/
|
|
386
|
+
400: InvalidRequest;
|
|
387
|
+
/**
|
|
388
|
+
* Missing, invalid or expired session, or a proof that does not match this request.
|
|
389
|
+
*/
|
|
390
|
+
401: Unauthorized;
|
|
391
|
+
/**
|
|
392
|
+
* The session may not perform this action (Cedar).
|
|
393
|
+
*/
|
|
394
|
+
403: Forbidden;
|
|
395
|
+
/**
|
|
396
|
+
* No such resource or route, or a resource the session's org cannot see.
|
|
397
|
+
*/
|
|
398
|
+
404: NotFound;
|
|
399
|
+
/**
|
|
400
|
+
* Unexpected failure: logged by the service, answered without details.
|
|
401
|
+
*/
|
|
402
|
+
500: ServerError;
|
|
403
|
+
};
|
|
404
|
+
export type CreateGrantError = CreateGrantErrors[keyof CreateGrantErrors];
|
|
405
|
+
export type CreateGrantResponses = {
|
|
406
|
+
/**
|
|
407
|
+
* The request has succeeded and a new resource has been created as a result.
|
|
408
|
+
*/
|
|
409
|
+
201: Grant;
|
|
410
|
+
};
|
|
411
|
+
export type CreateGrantResponse = CreateGrantResponses[keyof CreateGrantResponses];
|
|
412
|
+
export type RevokeGrantData = {
|
|
413
|
+
body?: never;
|
|
414
|
+
path: {
|
|
415
|
+
id: GrantId;
|
|
416
|
+
};
|
|
417
|
+
query?: never;
|
|
418
|
+
url: '/v1/grants/{id}';
|
|
419
|
+
};
|
|
420
|
+
export type RevokeGrantErrors = {
|
|
421
|
+
/**
|
|
422
|
+
* Missing, invalid or expired session, or a proof that does not match this request.
|
|
423
|
+
*/
|
|
424
|
+
401: Unauthorized;
|
|
425
|
+
/**
|
|
426
|
+
* The session may not perform this action (Cedar).
|
|
427
|
+
*/
|
|
428
|
+
403: Forbidden;
|
|
429
|
+
/**
|
|
430
|
+
* No such resource or route, or a resource the session's org cannot see.
|
|
431
|
+
*/
|
|
432
|
+
404: NotFound;
|
|
433
|
+
/**
|
|
434
|
+
* Unexpected failure: logged by the service, answered without details.
|
|
435
|
+
*/
|
|
436
|
+
500: ServerError;
|
|
437
|
+
};
|
|
438
|
+
export type RevokeGrantError = RevokeGrantErrors[keyof RevokeGrantErrors];
|
|
439
|
+
export type RevokeGrantResponses = {
|
|
440
|
+
/**
|
|
441
|
+
* The request has succeeded.
|
|
442
|
+
*/
|
|
443
|
+
200: Grant;
|
|
444
|
+
};
|
|
445
|
+
export type RevokeGrantResponse = RevokeGrantResponses[keyof RevokeGrantResponses];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** The Olyzon STS API (`sts`). */
|
|
2
|
+
import { type Input, type Transport } from "../core/transport.ts";
|
|
3
|
+
import type * as types from "./sts/types.gen.ts";
|
|
4
|
+
export type * from "./sts/types.gen.ts";
|
|
5
|
+
/** The Olyzon STS API, each call sent through `transport` (signed, its errors `ServiceError`s). */
|
|
6
|
+
export declare function createStsApi(transport: Transport): {
|
|
7
|
+
/**
|
|
8
|
+
* Exchanges a Clerk credential for a session (RFC 8693), bound to the key of
|
|
9
|
+
* the request's DPoP proof (`DPoP` header, RFC 9449, with the server's nonce
|
|
10
|
+
* and a signed body: added by the SDKs below the generated client). A
|
|
11
|
+
* person's membership and role are read from Clerk at every exchange, and the
|
|
12
|
+
* workspace must be served in this STS's region. A grant's actor exchanges
|
|
13
|
+
* the grant, with its own session as `actor_token`, for a 5-minute session of
|
|
14
|
+
* the grant's subject, for one service of its audience (spec §6.3).
|
|
15
|
+
*
|
|
16
|
+
* `POST /oauth/token`
|
|
17
|
+
*/
|
|
18
|
+
exchangeToken: (input: Input<types.ExchangeTokenData>) => Promise<types.ExchangeTokenResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* The caller's own session: what `olyzon sts get-caller-identity` shows. Its
|
|
21
|
+
* name and email are left out. Every session may read itself.
|
|
22
|
+
*
|
|
23
|
+
* `GET /v1/caller-identity`
|
|
24
|
+
*/
|
|
25
|
+
getCallerIdentity: (input?: Input<types.GetCallerIdentityData>) => Promise<types.GetCallerIdentityResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a grant from the caller to the service calling for them: only a registered service does,
|
|
28
|
+
* with its caller's forwarded credentials (spec §6.1). The caller is the subject, the service (or
|
|
29
|
+
* the agent it runs) the actor. A direct call is refused.
|
|
30
|
+
*
|
|
31
|
+
* Only a registered service calls it, for the caller of the request it is handling: `client.onBehalfOf(caller).sts.createGrant(…)`.
|
|
32
|
+
*
|
|
33
|
+
* `POST /v1/grants`
|
|
34
|
+
*/
|
|
35
|
+
createGrant: (input: Input<types.CreateGrantData>) => Promise<types.CreateGrantResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Revokes a grant: its next exchange fails. Its subject may, directly or through any service, and
|
|
38
|
+
* so may its actor for anyone it acts for. Revoking a revoked grant changes nothing.
|
|
39
|
+
*
|
|
40
|
+
* `DELETE /v1/grants/{id}`
|
|
41
|
+
*/
|
|
42
|
+
revokeGrant: (input: Input<types.RevokeGrantData>) => Promise<types.RevokeGrantResponse>;
|
|
43
|
+
};
|
|
44
|
+
export type StsApi = ReturnType<typeof createStsApi>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Generated by `just codegen`: do not edit.
|
|
2
|
+
/** The Olyzon STS API (`sts`). */
|
|
3
|
+
import { call } from "../core/transport.js";
|
|
4
|
+
import { createClient } from "./sts/client/index.js";
|
|
5
|
+
import * as sdk from "./sts/sdk.gen.js";
|
|
6
|
+
const SERVICE = "sts";
|
|
7
|
+
/** The Olyzon STS API, each call sent through `transport` (signed, its errors `ServiceError`s). */
|
|
8
|
+
export function createStsApi(transport) {
|
|
9
|
+
const signed = createClient({ baseUrl: transport.origin, fetch: transport.signed });
|
|
10
|
+
const anonymous = createClient({ baseUrl: transport.origin, fetch: transport.anonymous });
|
|
11
|
+
return {
|
|
12
|
+
/**
|
|
13
|
+
* Exchanges a Clerk credential for a session (RFC 8693), bound to the key of
|
|
14
|
+
* the request's DPoP proof (`DPoP` header, RFC 9449, with the server's nonce
|
|
15
|
+
* and a signed body: added by the SDKs below the generated client). A
|
|
16
|
+
* person's membership and role are read from Clerk at every exchange, and the
|
|
17
|
+
* workspace must be served in this STS's region. A grant's actor exchanges
|
|
18
|
+
* the grant, with its own session as `actor_token`, for a 5-minute session of
|
|
19
|
+
* the grant's subject, for one service of its audience (spec §6.3).
|
|
20
|
+
*
|
|
21
|
+
* `POST /oauth/token`
|
|
22
|
+
*/
|
|
23
|
+
exchangeToken: (input) => call(anonymous, SERVICE, sdk.exchangeToken, input),
|
|
24
|
+
/**
|
|
25
|
+
* The caller's own session: what `olyzon sts get-caller-identity` shows. Its
|
|
26
|
+
* name and email are left out. Every session may read itself.
|
|
27
|
+
*
|
|
28
|
+
* `GET /v1/caller-identity`
|
|
29
|
+
*/
|
|
30
|
+
getCallerIdentity: (input) => call(signed, SERVICE, sdk.getCallerIdentity, input),
|
|
31
|
+
/**
|
|
32
|
+
* Creates a grant from the caller to the service calling for them: only a registered service does,
|
|
33
|
+
* with its caller's forwarded credentials (spec §6.1). The caller is the subject, the service (or
|
|
34
|
+
* the agent it runs) the actor. A direct call is refused.
|
|
35
|
+
*
|
|
36
|
+
* Only a registered service calls it, for the caller of the request it is handling: `client.onBehalfOf(caller).sts.createGrant(…)`.
|
|
37
|
+
*
|
|
38
|
+
* `POST /v1/grants`
|
|
39
|
+
*/
|
|
40
|
+
createGrant: (input) => call(signed, SERVICE, sdk.createGrant, input),
|
|
41
|
+
/**
|
|
42
|
+
* Revokes a grant: its next exchange fails. Its subject may, directly or through any service, and
|
|
43
|
+
* so may its actor for anyone it acts for. Revoking a revoked grant changes nothing.
|
|
44
|
+
*
|
|
45
|
+
* `DELETE /v1/grants/{id}`
|
|
46
|
+
*/
|
|
47
|
+
revokeGrant: (input) => call(signed, SERVICE, sdk.revokeGrant, input),
|
|
48
|
+
};
|
|
49
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@olyzon/sdk`: every Olyzon API, generated from the OpenAPI documents the
|
|
3
|
+
* services serve, each call signed with a DPoP-bound Olyzon session.
|
|
4
|
+
*
|
|
5
|
+
* import { Client } from "@olyzon/sdk";
|
|
6
|
+
* const olyzon = new Client({ region: "us" }); // OLYZON_API_KEY, OLYZON_ORG_ID, …
|
|
7
|
+
* const me = await olyzon.sts.getCallerIdentity();
|
|
8
|
+
*/
|
|
9
|
+
export { Client, type ClientOptions } from "./client.ts";
|
|
10
|
+
export * from "./generated/index.ts";
|
|
11
|
+
export { ENVIRONMENTS, REGIONS, type ClerkLike, type ClientSettings, type Environment, type Region, } from "./core/config.ts";
|
|
12
|
+
export { ConfigurationError, ServiceError, StsError } from "./core/errors.ts";
|
|
13
|
+
export type { SessionClaims } from "./core/contracts.ts";
|
|
14
|
+
export { createUserClient, type ForwardedCredentials, type GrantReference, type Session, type UserClient, type UserClientOptions, } from "./core/session.ts";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@olyzon/sdk`: every Olyzon API, generated from the OpenAPI documents the
|
|
3
|
+
* services serve, each call signed with a DPoP-bound Olyzon session.
|
|
4
|
+
*
|
|
5
|
+
* import { Client } from "@olyzon/sdk";
|
|
6
|
+
* const olyzon = new Client({ region: "us" }); // OLYZON_API_KEY, OLYZON_ORG_ID, …
|
|
7
|
+
* const me = await olyzon.sts.getCallerIdentity();
|
|
8
|
+
*/
|
|
9
|
+
export { Client } from "./client.js";
|
|
10
|
+
export * from "./generated/index.js";
|
|
11
|
+
export { ENVIRONMENTS, REGIONS, } from "./core/config.js";
|
|
12
|
+
export { ConfigurationError, ServiceError, StsError } from "./core/errors.js";
|
|
13
|
+
export { createUserClient, } from "./core/session.js";
|
package/package.json
CHANGED
|
@@ -1,9 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olyzon/sdk",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "The olyzon.ai platform SDK
|
|
3
|
+
"version": "0.1.0-stg.3",
|
|
4
|
+
"description": "The olyzon.ai platform SDK: every Olyzon API, each call signed with a DPoP-bound session.",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"homepage": "https://docs.prod.olyzon.ai",
|
|
6
|
-
"
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/olyzon-tv/shady-sdk.git",
|
|
10
|
+
"directory": "sdk/typescript"
|
|
11
|
+
},
|
|
7
12
|
"type": "module",
|
|
8
|
-
"
|
|
9
|
-
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=22"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./config": {
|
|
23
|
+
"types": "./dist/core/config.d.ts",
|
|
24
|
+
"default": "./dist/core/config.js"
|
|
25
|
+
},
|
|
26
|
+
"./manifest.json": "./dist/generated/manifest.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"jose": "^6.2.18"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^26.6.6"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "rm -rf dist && node ../../node_modules/typescript-7/bin/tsc -p tsconfig.build.json && cp -R src/generated/manifest.json src/generated/specs dist/generated/",
|
|
42
|
+
"test": "node --test 'test/**/*.test.ts'",
|
|
43
|
+
"e2e": "node --test 'e2e/**/*.test.ts'",
|
|
44
|
+
"typecheck": "node ../../node_modules/typescript-7/bin/tsc -p tsconfig.json"
|
|
45
|
+
}
|
|
46
|
+
}
|