@fabrika/auth 0.8.2 → 0.9.0-cloudflare.1
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/package.json +6 -5
- package/src/app-schema.ts +7 -0
- package/src/index.ts +2 -2
- package/src/rpc-http.ts +64 -0
- package/types/src/app-schema.d.ts +628 -0
- package/types/src/client.d.ts +28 -0
- package/types/src/errors.d.ts +43 -0
- package/types/src/iam.d.ts +112 -0
- package/types/src/index.d.ts +20 -0
- package/types/src/membership.d.ts +46 -0
- package/types/src/provision.d.ts +37 -0
- package/types/src/request.d.ts +10 -0
- package/types/src/rpc-http.d.ts +147 -0
- package/types/src/scope.d.ts +18 -0
- package/types/src/types.d.ts +78 -0
- package/types/src/verify.d.ts +29 -0
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* An app's authz vocabulary, as an app declares it and IAM reconciles it. Every role permission must
|
|
4
|
+
* name an action the same body declares — IAM's own rule, checked wherever the vocabulary is read. A
|
|
5
|
+
* contract application's roles list exact actions, and a membership role names a declared scope. The
|
|
6
|
+
* membership and link declarations name only scopes, roles and exact actions of the same body.
|
|
7
|
+
*/
|
|
8
|
+
export declare const appSchemaSchema: z.ZodEffects<z.ZodObject<{
|
|
9
|
+
scopes: z.ZodArray<z.ZodObject<{
|
|
10
|
+
type: z.ZodString;
|
|
11
|
+
label: z.ZodOptional<z.ZodString>;
|
|
12
|
+
in: z.ZodOptional<z.ZodString>;
|
|
13
|
+
creator: z.ZodOptional<z.ZodString>;
|
|
14
|
+
members: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
manage: z.ZodString;
|
|
16
|
+
list: z.ZodString;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
manage: string;
|
|
19
|
+
list: string;
|
|
20
|
+
}, {
|
|
21
|
+
manage: string;
|
|
22
|
+
list: string;
|
|
23
|
+
}>>;
|
|
24
|
+
directory: z.ZodOptional<z.ZodLiteral<"labels">>;
|
|
25
|
+
lookups: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
type: string;
|
|
28
|
+
members?: {
|
|
29
|
+
manage: string;
|
|
30
|
+
list: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
directory?: "labels" | undefined;
|
|
33
|
+
in?: string | undefined;
|
|
34
|
+
label?: string | undefined;
|
|
35
|
+
creator?: string | undefined;
|
|
36
|
+
lookups?: string[] | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
type: string;
|
|
39
|
+
members?: {
|
|
40
|
+
manage: string;
|
|
41
|
+
list: string;
|
|
42
|
+
} | undefined;
|
|
43
|
+
directory?: "labels" | undefined;
|
|
44
|
+
in?: string | undefined;
|
|
45
|
+
label?: string | undefined;
|
|
46
|
+
creator?: string | undefined;
|
|
47
|
+
lookups?: string[] | undefined;
|
|
48
|
+
}>, "many">;
|
|
49
|
+
actions: z.ZodArray<z.ZodObject<{
|
|
50
|
+
action: z.ZodString;
|
|
51
|
+
description: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
action: string;
|
|
54
|
+
description?: string | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
action: string;
|
|
57
|
+
description?: string | undefined;
|
|
58
|
+
}>, "many">;
|
|
59
|
+
roles: z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodObject<{
|
|
60
|
+
name: z.ZodString;
|
|
61
|
+
description: z.ZodOptional<z.ZodString>;
|
|
62
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
63
|
+
member: z.ZodOptional<z.ZodObject<{
|
|
64
|
+
scope: z.ZodString;
|
|
65
|
+
assignableBy: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
scope: string;
|
|
68
|
+
assignableBy?: string[] | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
scope: string;
|
|
71
|
+
assignableBy?: string[] | undefined;
|
|
72
|
+
}>>;
|
|
73
|
+
external: z.ZodOptional<z.ZodLiteral<true>>;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
name: string;
|
|
76
|
+
permissions: string[];
|
|
77
|
+
external?: true | undefined;
|
|
78
|
+
member?: {
|
|
79
|
+
scope: string;
|
|
80
|
+
assignableBy?: string[] | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
description?: string | undefined;
|
|
83
|
+
}, {
|
|
84
|
+
name: string;
|
|
85
|
+
permissions: string[];
|
|
86
|
+
external?: true | undefined;
|
|
87
|
+
member?: {
|
|
88
|
+
scope: string;
|
|
89
|
+
assignableBy?: string[] | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
description?: string | undefined;
|
|
92
|
+
}>>;
|
|
93
|
+
contract: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
links: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodObject<{
|
|
95
|
+
dimension: z.ZodString;
|
|
96
|
+
grants: z.ZodArray<z.ZodString, "many">;
|
|
97
|
+
issuedBy: z.ZodString;
|
|
98
|
+
maxDays: z.ZodNumber;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
dimension: string;
|
|
101
|
+
grants: string[];
|
|
102
|
+
issuedBy: string;
|
|
103
|
+
maxDays: number;
|
|
104
|
+
}, {
|
|
105
|
+
dimension: string;
|
|
106
|
+
grants: string[];
|
|
107
|
+
issuedBy: string;
|
|
108
|
+
maxDays: number;
|
|
109
|
+
}>>>;
|
|
110
|
+
delegations: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodObject<{
|
|
111
|
+
action: z.ZodString;
|
|
112
|
+
dimension: z.ZodString;
|
|
113
|
+
purpose: z.ZodEnum<["members", "creates"]>;
|
|
114
|
+
}, "strip", z.ZodTypeAny, {
|
|
115
|
+
action: string;
|
|
116
|
+
dimension: string;
|
|
117
|
+
purpose: "members" | "creates";
|
|
118
|
+
}, {
|
|
119
|
+
action: string;
|
|
120
|
+
dimension: string;
|
|
121
|
+
purpose: "members" | "creates";
|
|
122
|
+
}>>>;
|
|
123
|
+
workloads: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
124
|
+
kind: z.ZodLiteral<"job">;
|
|
125
|
+
name: z.ZodString;
|
|
126
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
127
|
+
issues: z.ZodOptional<z.ZodString>;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
name: string;
|
|
130
|
+
actions: string[];
|
|
131
|
+
kind: "job";
|
|
132
|
+
issues?: string | undefined;
|
|
133
|
+
}, {
|
|
134
|
+
name: string;
|
|
135
|
+
actions: string[];
|
|
136
|
+
kind: "job";
|
|
137
|
+
issues?: string | undefined;
|
|
138
|
+
}>, z.ZodObject<{
|
|
139
|
+
kind: z.ZodLiteral<"webhook">;
|
|
140
|
+
name: z.ZodString;
|
|
141
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
142
|
+
}, "strip", z.ZodTypeAny, {
|
|
143
|
+
name: string;
|
|
144
|
+
actions: string[];
|
|
145
|
+
kind: "webhook";
|
|
146
|
+
}, {
|
|
147
|
+
name: string;
|
|
148
|
+
actions: string[];
|
|
149
|
+
kind: "webhook";
|
|
150
|
+
}>, z.ZodObject<{
|
|
151
|
+
kind: z.ZodLiteral<"public">;
|
|
152
|
+
name: z.ZodEffects<z.ZodString, string, string>;
|
|
153
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
154
|
+
}, "strip", z.ZodTypeAny, {
|
|
155
|
+
name: string;
|
|
156
|
+
actions: string[];
|
|
157
|
+
kind: "public";
|
|
158
|
+
}, {
|
|
159
|
+
name: string;
|
|
160
|
+
actions: string[];
|
|
161
|
+
kind: "public";
|
|
162
|
+
}>, z.ZodObject<{
|
|
163
|
+
kind: z.ZodLiteral<"app">;
|
|
164
|
+
name: z.ZodString;
|
|
165
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
166
|
+
}, "strip", z.ZodTypeAny, {
|
|
167
|
+
name: string;
|
|
168
|
+
actions: string[];
|
|
169
|
+
kind: "app";
|
|
170
|
+
}, {
|
|
171
|
+
name: string;
|
|
172
|
+
actions: string[];
|
|
173
|
+
kind: "app";
|
|
174
|
+
}>]>, "many">>;
|
|
175
|
+
locale: z.ZodOptional<z.ZodEnum<["en", "cs"]>>;
|
|
176
|
+
displayName: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
177
|
+
mail: z.ZodOptional<z.ZodObject<{
|
|
178
|
+
invitation: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodEnum<["en", "cs"]>, z.ZodObject<{
|
|
179
|
+
subject: z.ZodString;
|
|
180
|
+
text: z.ZodString;
|
|
181
|
+
html: z.ZodOptional<z.ZodString>;
|
|
182
|
+
}, "strict", z.ZodTypeAny, {
|
|
183
|
+
subject: string;
|
|
184
|
+
text: string;
|
|
185
|
+
html?: string | undefined;
|
|
186
|
+
}, {
|
|
187
|
+
subject: string;
|
|
188
|
+
text: string;
|
|
189
|
+
html?: string | undefined;
|
|
190
|
+
}>>, Partial<Record<"en" | "cs", {
|
|
191
|
+
subject: string;
|
|
192
|
+
text: string;
|
|
193
|
+
html?: string | undefined;
|
|
194
|
+
}>>, Partial<Record<"en" | "cs", {
|
|
195
|
+
subject: string;
|
|
196
|
+
text: string;
|
|
197
|
+
html?: string | undefined;
|
|
198
|
+
}>>>>;
|
|
199
|
+
enrollment: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodEnum<["en", "cs"]>, z.ZodObject<{
|
|
200
|
+
subject: z.ZodString;
|
|
201
|
+
text: z.ZodString;
|
|
202
|
+
html: z.ZodOptional<z.ZodString>;
|
|
203
|
+
}, "strict", z.ZodTypeAny, {
|
|
204
|
+
subject: string;
|
|
205
|
+
text: string;
|
|
206
|
+
html?: string | undefined;
|
|
207
|
+
}, {
|
|
208
|
+
subject: string;
|
|
209
|
+
text: string;
|
|
210
|
+
html?: string | undefined;
|
|
211
|
+
}>>, Partial<Record<"en" | "cs", {
|
|
212
|
+
subject: string;
|
|
213
|
+
text: string;
|
|
214
|
+
html?: string | undefined;
|
|
215
|
+
}>>, Partial<Record<"en" | "cs", {
|
|
216
|
+
subject: string;
|
|
217
|
+
text: string;
|
|
218
|
+
html?: string | undefined;
|
|
219
|
+
}>>>>;
|
|
220
|
+
reset: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodEnum<["en", "cs"]>, z.ZodObject<{
|
|
221
|
+
subject: z.ZodString;
|
|
222
|
+
text: z.ZodString;
|
|
223
|
+
html: z.ZodOptional<z.ZodString>;
|
|
224
|
+
}, "strict", z.ZodTypeAny, {
|
|
225
|
+
subject: string;
|
|
226
|
+
text: string;
|
|
227
|
+
html?: string | undefined;
|
|
228
|
+
}, {
|
|
229
|
+
subject: string;
|
|
230
|
+
text: string;
|
|
231
|
+
html?: string | undefined;
|
|
232
|
+
}>>, Partial<Record<"en" | "cs", {
|
|
233
|
+
subject: string;
|
|
234
|
+
text: string;
|
|
235
|
+
html?: string | undefined;
|
|
236
|
+
}>>, Partial<Record<"en" | "cs", {
|
|
237
|
+
subject: string;
|
|
238
|
+
text: string;
|
|
239
|
+
html?: string | undefined;
|
|
240
|
+
}>>>>;
|
|
241
|
+
}, "strict", z.ZodTypeAny, {
|
|
242
|
+
invitation?: Partial<Record<"en" | "cs", {
|
|
243
|
+
subject: string;
|
|
244
|
+
text: string;
|
|
245
|
+
html?: string | undefined;
|
|
246
|
+
}>> | undefined;
|
|
247
|
+
enrollment?: Partial<Record<"en" | "cs", {
|
|
248
|
+
subject: string;
|
|
249
|
+
text: string;
|
|
250
|
+
html?: string | undefined;
|
|
251
|
+
}>> | undefined;
|
|
252
|
+
reset?: Partial<Record<"en" | "cs", {
|
|
253
|
+
subject: string;
|
|
254
|
+
text: string;
|
|
255
|
+
html?: string | undefined;
|
|
256
|
+
}>> | undefined;
|
|
257
|
+
}, {
|
|
258
|
+
invitation?: Partial<Record<"en" | "cs", {
|
|
259
|
+
subject: string;
|
|
260
|
+
text: string;
|
|
261
|
+
html?: string | undefined;
|
|
262
|
+
}>> | undefined;
|
|
263
|
+
enrollment?: Partial<Record<"en" | "cs", {
|
|
264
|
+
subject: string;
|
|
265
|
+
text: string;
|
|
266
|
+
html?: string | undefined;
|
|
267
|
+
}>> | undefined;
|
|
268
|
+
reset?: Partial<Record<"en" | "cs", {
|
|
269
|
+
subject: string;
|
|
270
|
+
text: string;
|
|
271
|
+
html?: string | undefined;
|
|
272
|
+
}>> | undefined;
|
|
273
|
+
}>>;
|
|
274
|
+
members: z.ZodOptional<z.ZodObject<{
|
|
275
|
+
manage: z.ZodString;
|
|
276
|
+
list: z.ZodString;
|
|
277
|
+
}, "strip", z.ZodTypeAny, {
|
|
278
|
+
manage: string;
|
|
279
|
+
list: string;
|
|
280
|
+
}, {
|
|
281
|
+
manage: string;
|
|
282
|
+
list: string;
|
|
283
|
+
}>>;
|
|
284
|
+
directory: z.ZodOptional<z.ZodLiteral<"labels">>;
|
|
285
|
+
terminal: z.ZodOptional<z.ZodObject<{
|
|
286
|
+
identify: z.ZodEffects<z.ZodString, string, string>;
|
|
287
|
+
}, "strict", z.ZodTypeAny, {
|
|
288
|
+
identify: string;
|
|
289
|
+
}, {
|
|
290
|
+
identify: string;
|
|
291
|
+
}>>;
|
|
292
|
+
}, "strip", z.ZodTypeAny, {
|
|
293
|
+
actions: {
|
|
294
|
+
action: string;
|
|
295
|
+
description?: string | undefined;
|
|
296
|
+
}[];
|
|
297
|
+
roles: Record<string, {
|
|
298
|
+
name: string;
|
|
299
|
+
permissions: string[];
|
|
300
|
+
external?: true | undefined;
|
|
301
|
+
member?: {
|
|
302
|
+
scope: string;
|
|
303
|
+
assignableBy?: string[] | undefined;
|
|
304
|
+
} | undefined;
|
|
305
|
+
description?: string | undefined;
|
|
306
|
+
}>;
|
|
307
|
+
scopes: {
|
|
308
|
+
type: string;
|
|
309
|
+
members?: {
|
|
310
|
+
manage: string;
|
|
311
|
+
list: string;
|
|
312
|
+
} | undefined;
|
|
313
|
+
directory?: "labels" | undefined;
|
|
314
|
+
in?: string | undefined;
|
|
315
|
+
label?: string | undefined;
|
|
316
|
+
creator?: string | undefined;
|
|
317
|
+
lookups?: string[] | undefined;
|
|
318
|
+
}[];
|
|
319
|
+
displayName?: string | undefined;
|
|
320
|
+
terminal?: {
|
|
321
|
+
identify: string;
|
|
322
|
+
} | undefined;
|
|
323
|
+
members?: {
|
|
324
|
+
manage: string;
|
|
325
|
+
list: string;
|
|
326
|
+
} | undefined;
|
|
327
|
+
locale?: "en" | "cs" | undefined;
|
|
328
|
+
mail?: {
|
|
329
|
+
invitation?: Partial<Record<"en" | "cs", {
|
|
330
|
+
subject: string;
|
|
331
|
+
text: string;
|
|
332
|
+
html?: string | undefined;
|
|
333
|
+
}>> | undefined;
|
|
334
|
+
enrollment?: Partial<Record<"en" | "cs", {
|
|
335
|
+
subject: string;
|
|
336
|
+
text: string;
|
|
337
|
+
html?: string | undefined;
|
|
338
|
+
}>> | undefined;
|
|
339
|
+
reset?: Partial<Record<"en" | "cs", {
|
|
340
|
+
subject: string;
|
|
341
|
+
text: string;
|
|
342
|
+
html?: string | undefined;
|
|
343
|
+
}>> | undefined;
|
|
344
|
+
} | undefined;
|
|
345
|
+
directory?: "labels" | undefined;
|
|
346
|
+
contract?: boolean | undefined;
|
|
347
|
+
links?: Record<string, {
|
|
348
|
+
dimension: string;
|
|
349
|
+
grants: string[];
|
|
350
|
+
issuedBy: string;
|
|
351
|
+
maxDays: number;
|
|
352
|
+
}> | undefined;
|
|
353
|
+
delegations?: Record<string, {
|
|
354
|
+
action: string;
|
|
355
|
+
dimension: string;
|
|
356
|
+
purpose: "members" | "creates";
|
|
357
|
+
}> | undefined;
|
|
358
|
+
workloads?: ({
|
|
359
|
+
name: string;
|
|
360
|
+
actions: string[];
|
|
361
|
+
kind: "job";
|
|
362
|
+
issues?: string | undefined;
|
|
363
|
+
} | {
|
|
364
|
+
name: string;
|
|
365
|
+
actions: string[];
|
|
366
|
+
kind: "webhook";
|
|
367
|
+
} | {
|
|
368
|
+
name: string;
|
|
369
|
+
actions: string[];
|
|
370
|
+
kind: "public";
|
|
371
|
+
} | {
|
|
372
|
+
name: string;
|
|
373
|
+
actions: string[];
|
|
374
|
+
kind: "app";
|
|
375
|
+
})[] | undefined;
|
|
376
|
+
}, {
|
|
377
|
+
actions: {
|
|
378
|
+
action: string;
|
|
379
|
+
description?: string | undefined;
|
|
380
|
+
}[];
|
|
381
|
+
roles: Record<string, {
|
|
382
|
+
name: string;
|
|
383
|
+
permissions: string[];
|
|
384
|
+
external?: true | undefined;
|
|
385
|
+
member?: {
|
|
386
|
+
scope: string;
|
|
387
|
+
assignableBy?: string[] | undefined;
|
|
388
|
+
} | undefined;
|
|
389
|
+
description?: string | undefined;
|
|
390
|
+
}>;
|
|
391
|
+
scopes: {
|
|
392
|
+
type: string;
|
|
393
|
+
members?: {
|
|
394
|
+
manage: string;
|
|
395
|
+
list: string;
|
|
396
|
+
} | undefined;
|
|
397
|
+
directory?: "labels" | undefined;
|
|
398
|
+
in?: string | undefined;
|
|
399
|
+
label?: string | undefined;
|
|
400
|
+
creator?: string | undefined;
|
|
401
|
+
lookups?: string[] | undefined;
|
|
402
|
+
}[];
|
|
403
|
+
displayName?: string | undefined;
|
|
404
|
+
terminal?: {
|
|
405
|
+
identify: string;
|
|
406
|
+
} | undefined;
|
|
407
|
+
members?: {
|
|
408
|
+
manage: string;
|
|
409
|
+
list: string;
|
|
410
|
+
} | undefined;
|
|
411
|
+
locale?: "en" | "cs" | undefined;
|
|
412
|
+
mail?: {
|
|
413
|
+
invitation?: Partial<Record<"en" | "cs", {
|
|
414
|
+
subject: string;
|
|
415
|
+
text: string;
|
|
416
|
+
html?: string | undefined;
|
|
417
|
+
}>> | undefined;
|
|
418
|
+
enrollment?: Partial<Record<"en" | "cs", {
|
|
419
|
+
subject: string;
|
|
420
|
+
text: string;
|
|
421
|
+
html?: string | undefined;
|
|
422
|
+
}>> | undefined;
|
|
423
|
+
reset?: Partial<Record<"en" | "cs", {
|
|
424
|
+
subject: string;
|
|
425
|
+
text: string;
|
|
426
|
+
html?: string | undefined;
|
|
427
|
+
}>> | undefined;
|
|
428
|
+
} | undefined;
|
|
429
|
+
directory?: "labels" | undefined;
|
|
430
|
+
contract?: boolean | undefined;
|
|
431
|
+
links?: Record<string, {
|
|
432
|
+
dimension: string;
|
|
433
|
+
grants: string[];
|
|
434
|
+
issuedBy: string;
|
|
435
|
+
maxDays: number;
|
|
436
|
+
}> | undefined;
|
|
437
|
+
delegations?: Record<string, {
|
|
438
|
+
action: string;
|
|
439
|
+
dimension: string;
|
|
440
|
+
purpose: "members" | "creates";
|
|
441
|
+
}> | undefined;
|
|
442
|
+
workloads?: ({
|
|
443
|
+
name: string;
|
|
444
|
+
actions: string[];
|
|
445
|
+
kind: "job";
|
|
446
|
+
issues?: string | undefined;
|
|
447
|
+
} | {
|
|
448
|
+
name: string;
|
|
449
|
+
actions: string[];
|
|
450
|
+
kind: "webhook";
|
|
451
|
+
} | {
|
|
452
|
+
name: string;
|
|
453
|
+
actions: string[];
|
|
454
|
+
kind: "public";
|
|
455
|
+
} | {
|
|
456
|
+
name: string;
|
|
457
|
+
actions: string[];
|
|
458
|
+
kind: "app";
|
|
459
|
+
})[] | undefined;
|
|
460
|
+
}>, {
|
|
461
|
+
actions: {
|
|
462
|
+
action: string;
|
|
463
|
+
description?: string | undefined;
|
|
464
|
+
}[];
|
|
465
|
+
roles: Record<string, {
|
|
466
|
+
name: string;
|
|
467
|
+
permissions: string[];
|
|
468
|
+
external?: true | undefined;
|
|
469
|
+
member?: {
|
|
470
|
+
scope: string;
|
|
471
|
+
assignableBy?: string[] | undefined;
|
|
472
|
+
} | undefined;
|
|
473
|
+
description?: string | undefined;
|
|
474
|
+
}>;
|
|
475
|
+
scopes: {
|
|
476
|
+
type: string;
|
|
477
|
+
members?: {
|
|
478
|
+
manage: string;
|
|
479
|
+
list: string;
|
|
480
|
+
} | undefined;
|
|
481
|
+
directory?: "labels" | undefined;
|
|
482
|
+
in?: string | undefined;
|
|
483
|
+
label?: string | undefined;
|
|
484
|
+
creator?: string | undefined;
|
|
485
|
+
lookups?: string[] | undefined;
|
|
486
|
+
}[];
|
|
487
|
+
displayName?: string | undefined;
|
|
488
|
+
terminal?: {
|
|
489
|
+
identify: string;
|
|
490
|
+
} | undefined;
|
|
491
|
+
members?: {
|
|
492
|
+
manage: string;
|
|
493
|
+
list: string;
|
|
494
|
+
} | undefined;
|
|
495
|
+
locale?: "en" | "cs" | undefined;
|
|
496
|
+
mail?: {
|
|
497
|
+
invitation?: Partial<Record<"en" | "cs", {
|
|
498
|
+
subject: string;
|
|
499
|
+
text: string;
|
|
500
|
+
html?: string | undefined;
|
|
501
|
+
}>> | undefined;
|
|
502
|
+
enrollment?: Partial<Record<"en" | "cs", {
|
|
503
|
+
subject: string;
|
|
504
|
+
text: string;
|
|
505
|
+
html?: string | undefined;
|
|
506
|
+
}>> | undefined;
|
|
507
|
+
reset?: Partial<Record<"en" | "cs", {
|
|
508
|
+
subject: string;
|
|
509
|
+
text: string;
|
|
510
|
+
html?: string | undefined;
|
|
511
|
+
}>> | undefined;
|
|
512
|
+
} | undefined;
|
|
513
|
+
directory?: "labels" | undefined;
|
|
514
|
+
contract?: boolean | undefined;
|
|
515
|
+
links?: Record<string, {
|
|
516
|
+
dimension: string;
|
|
517
|
+
grants: string[];
|
|
518
|
+
issuedBy: string;
|
|
519
|
+
maxDays: number;
|
|
520
|
+
}> | undefined;
|
|
521
|
+
delegations?: Record<string, {
|
|
522
|
+
action: string;
|
|
523
|
+
dimension: string;
|
|
524
|
+
purpose: "members" | "creates";
|
|
525
|
+
}> | undefined;
|
|
526
|
+
workloads?: ({
|
|
527
|
+
name: string;
|
|
528
|
+
actions: string[];
|
|
529
|
+
kind: "job";
|
|
530
|
+
issues?: string | undefined;
|
|
531
|
+
} | {
|
|
532
|
+
name: string;
|
|
533
|
+
actions: string[];
|
|
534
|
+
kind: "webhook";
|
|
535
|
+
} | {
|
|
536
|
+
name: string;
|
|
537
|
+
actions: string[];
|
|
538
|
+
kind: "public";
|
|
539
|
+
} | {
|
|
540
|
+
name: string;
|
|
541
|
+
actions: string[];
|
|
542
|
+
kind: "app";
|
|
543
|
+
})[] | undefined;
|
|
544
|
+
}, {
|
|
545
|
+
actions: {
|
|
546
|
+
action: string;
|
|
547
|
+
description?: string | undefined;
|
|
548
|
+
}[];
|
|
549
|
+
roles: Record<string, {
|
|
550
|
+
name: string;
|
|
551
|
+
permissions: string[];
|
|
552
|
+
external?: true | undefined;
|
|
553
|
+
member?: {
|
|
554
|
+
scope: string;
|
|
555
|
+
assignableBy?: string[] | undefined;
|
|
556
|
+
} | undefined;
|
|
557
|
+
description?: string | undefined;
|
|
558
|
+
}>;
|
|
559
|
+
scopes: {
|
|
560
|
+
type: string;
|
|
561
|
+
members?: {
|
|
562
|
+
manage: string;
|
|
563
|
+
list: string;
|
|
564
|
+
} | undefined;
|
|
565
|
+
directory?: "labels" | undefined;
|
|
566
|
+
in?: string | undefined;
|
|
567
|
+
label?: string | undefined;
|
|
568
|
+
creator?: string | undefined;
|
|
569
|
+
lookups?: string[] | undefined;
|
|
570
|
+
}[];
|
|
571
|
+
displayName?: string | undefined;
|
|
572
|
+
terminal?: {
|
|
573
|
+
identify: string;
|
|
574
|
+
} | undefined;
|
|
575
|
+
members?: {
|
|
576
|
+
manage: string;
|
|
577
|
+
list: string;
|
|
578
|
+
} | undefined;
|
|
579
|
+
locale?: "en" | "cs" | undefined;
|
|
580
|
+
mail?: {
|
|
581
|
+
invitation?: Partial<Record<"en" | "cs", {
|
|
582
|
+
subject: string;
|
|
583
|
+
text: string;
|
|
584
|
+
html?: string | undefined;
|
|
585
|
+
}>> | undefined;
|
|
586
|
+
enrollment?: Partial<Record<"en" | "cs", {
|
|
587
|
+
subject: string;
|
|
588
|
+
text: string;
|
|
589
|
+
html?: string | undefined;
|
|
590
|
+
}>> | undefined;
|
|
591
|
+
reset?: Partial<Record<"en" | "cs", {
|
|
592
|
+
subject: string;
|
|
593
|
+
text: string;
|
|
594
|
+
html?: string | undefined;
|
|
595
|
+
}>> | undefined;
|
|
596
|
+
} | undefined;
|
|
597
|
+
directory?: "labels" | undefined;
|
|
598
|
+
contract?: boolean | undefined;
|
|
599
|
+
links?: Record<string, {
|
|
600
|
+
dimension: string;
|
|
601
|
+
grants: string[];
|
|
602
|
+
issuedBy: string;
|
|
603
|
+
maxDays: number;
|
|
604
|
+
}> | undefined;
|
|
605
|
+
delegations?: Record<string, {
|
|
606
|
+
action: string;
|
|
607
|
+
dimension: string;
|
|
608
|
+
purpose: "members" | "creates";
|
|
609
|
+
}> | undefined;
|
|
610
|
+
workloads?: ({
|
|
611
|
+
name: string;
|
|
612
|
+
actions: string[];
|
|
613
|
+
kind: "job";
|
|
614
|
+
issues?: string | undefined;
|
|
615
|
+
} | {
|
|
616
|
+
name: string;
|
|
617
|
+
actions: string[];
|
|
618
|
+
kind: "webhook";
|
|
619
|
+
} | {
|
|
620
|
+
name: string;
|
|
621
|
+
actions: string[];
|
|
622
|
+
kind: "public";
|
|
623
|
+
} | {
|
|
624
|
+
name: string;
|
|
625
|
+
actions: string[];
|
|
626
|
+
kind: "app";
|
|
627
|
+
})[] | undefined;
|
|
628
|
+
}>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AccessTokenClaims } from '@fabrika/auth-core';
|
|
2
|
+
import type { AuthContext, IamBinding, ListPrincipalsFailure, PrincipalList } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Build an `AuthContext` from a verified access token and its claims — the seam every authentication
|
|
5
|
+
* path uses (the proxy-injected token). The SDK has verified the token LOCALLY; this wraps its claims in the
|
|
6
|
+
* same `permits`-backed context the RPC path returns,
|
|
7
|
+
* so `can()` / `scopedTo()` / `audit()` behave identically. A token with no `ptype` is anonymous
|
|
8
|
+
* (`principal: null`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildAuthContext(binding: IamBinding, token: string, claims: AccessTokenClaims, requestId: string): AuthContext;
|
|
11
|
+
/**
|
|
12
|
+
* Thin, app-facing wrapper over the IAM Worker service binding. Bakes the caller `app` id
|
|
13
|
+
* into the constructor so app code can never forget or mistype it. Depends ONLY on the
|
|
14
|
+
* `IamRpc` contract from `@fabrika/auth-core` — never on the Worker — which is what keeps the
|
|
15
|
+
* SDK worker-independent (the binding is the deployed Worker, reached at runtime).
|
|
16
|
+
*/
|
|
17
|
+
export declare class IamClient {
|
|
18
|
+
private readonly binding;
|
|
19
|
+
private readonly appId;
|
|
20
|
+
constructor(binding: IamBinding, appId: string);
|
|
21
|
+
/**
|
|
22
|
+
* List the app's people directory — the USER principals who can access this app. Forwards the
|
|
23
|
+
* CALLER's credential; the IAM Worker resolves the caller and scopes the roster to the
|
|
24
|
+
* verified app (you only ever see your own app's people). For an assignee picker / actor
|
|
25
|
+
* label list. Authorized for any member with a permission on the app; a zero-grant user → 403.
|
|
26
|
+
*/
|
|
27
|
+
listPrincipals(req: Request): Promise<PrincipalList | ListPrincipalsFailure>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed request-time errors + a small authorization helper.
|
|
3
|
+
*
|
|
4
|
+
* These are the shared structural HTTP-error contract `@fabrika/app` maps without any
|
|
5
|
+
* cross-package `instanceof`: each error exposes `{ httpStatus, type, message }` plus an optional
|
|
6
|
+
* `issues` (validation detail). A mapper reads those fields structurally — it never imports these
|
|
7
|
+
* classes — so these shapes and the framework reader are the single contract. They live in
|
|
8
|
+
* `@fabrika/auth` because `requirePermission` consumes an `AuthContext` (a client type).
|
|
9
|
+
*
|
|
10
|
+
* There is deliberately no login-bounce error here: since ADR-0022 the proxy 302s an unauthenticated
|
|
11
|
+
* browser, so an app never has to produce a login URL of its own.
|
|
12
|
+
*/
|
|
13
|
+
import type { Scope } from '@fabrika/auth-core';
|
|
14
|
+
import type { AuthContext } from './types';
|
|
15
|
+
/**
|
|
16
|
+
* The structural HTTP-error shape. Anything thrown through a request pipeline that satisfies this can be
|
|
17
|
+
* mapped to a Response without an `instanceof` check: `httpStatus` → the status, `type` → the error
|
|
18
|
+
* envelope's `type`, `message` → its `message`, `issues` → optional detail.
|
|
19
|
+
*/
|
|
20
|
+
export interface HttpError {
|
|
21
|
+
readonly httpStatus: number;
|
|
22
|
+
readonly type: string;
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly issues?: unknown;
|
|
25
|
+
}
|
|
26
|
+
/** A caller is unauthenticated. `type: 'auth'`, status 401. */
|
|
27
|
+
export declare class UnauthenticatedError extends Error implements HttpError {
|
|
28
|
+
readonly httpStatus = 401;
|
|
29
|
+
readonly type = "auth";
|
|
30
|
+
constructor(message?: string);
|
|
31
|
+
}
|
|
32
|
+
/** A resolved caller lacks the required permission. `type: 'forbidden'`, status 403. */
|
|
33
|
+
export declare class ForbiddenError extends Error implements HttpError {
|
|
34
|
+
readonly httpStatus = 403;
|
|
35
|
+
readonly type = "forbidden";
|
|
36
|
+
constructor(message?: string);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Assert the caller may perform `action` (optionally within `scope`). Throws `ForbiddenError` when
|
|
40
|
+
* `auth.can(action, scope)` is false; otherwise returns. The thrown error satisfies the structural
|
|
41
|
+
* `HttpError` contract, so a pipeline maps it to a 403 without importing this module.
|
|
42
|
+
*/
|
|
43
|
+
export declare function requirePermission(auth: AuthContext, action: string, scope?: Scope): void;
|