@willyim/idp 0.1.0 → 0.2.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/README.md +83 -13
- package/dist/src/api.d.ts +31 -55
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/api.js +16 -11
- package/dist/src/claims.d.ts +9 -34
- package/dist/src/claims.d.ts.map +1 -1
- package/dist/src/claims.js +12 -40
- package/dist/src/client.d.ts +30 -34
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +16 -22
- package/dist/src/drizzle/index.d.ts +78 -13
- package/dist/src/drizzle/index.d.ts.map +1 -1
- package/dist/src/errors.d.ts +8 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +12 -0
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/schemas/index.d.ts +207 -0
- package/dist/src/schemas/index.d.ts.map +1 -0
- package/dist/src/schemas/index.js +122 -0
- package/dist/src/schemas/openapi.d.ts +31 -0
- package/dist/src/schemas/openapi.d.ts.map +1 -0
- package/dist/src/schemas/openapi.js +110 -0
- package/dist/src/schemas/operations.d.ts +297 -0
- package/dist/src/schemas/operations.d.ts.map +1 -0
- package/dist/src/schemas/operations.js +118 -0
- package/dist/src/session.d.ts +17 -3
- package/dist/src/session.d.ts.map +1 -1
- package/dist/src/session.js +12 -1
- package/dist/src/user-keys.d.ts +124 -0
- package/dist/src/user-keys.d.ts.map +1 -0
- package/dist/src/user-keys.js +174 -0
- package/dist/src/validate.d.ts +13 -0
- package/dist/src/validate.d.ts.map +1 -0
- package/dist/src/validate.js +28 -0
- package/dist/src/wire.d.ts +164 -0
- package/dist/src/wire.d.ts.map +1 -0
- package/dist/src/wire.js +100 -0
- package/openapi/idp-api.json +3 -6
- package/package.json +16 -7
- package/dist/src/generated/idp-api.d.ts +0 -1022
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* `drizzle-orm` is an optional peer dependency of this subpath only — core
|
|
10
10
|
* never imports it.
|
|
11
11
|
*/
|
|
12
|
-
import type { Actor, Workspace } from "../claims.js";
|
|
13
12
|
import type { SessionStore } from "../store.js";
|
|
14
13
|
export declare const IDP_SESSION_TABLE = "idp_session";
|
|
15
14
|
/**
|
|
@@ -140,7 +139,14 @@ export declare function idpSessionSqliteTable(name?: string): import("drizzle-or
|
|
|
140
139
|
tableName: string;
|
|
141
140
|
dataType: "json";
|
|
142
141
|
columnType: "SQLiteTextJson";
|
|
143
|
-
data:
|
|
142
|
+
data: {
|
|
143
|
+
[x: string]: unknown;
|
|
144
|
+
id: string;
|
|
145
|
+
slug: string;
|
|
146
|
+
name: string;
|
|
147
|
+
domain: string | null;
|
|
148
|
+
role: string;
|
|
149
|
+
}[];
|
|
144
150
|
driverParam: string;
|
|
145
151
|
notNull: true;
|
|
146
152
|
hasDefault: false;
|
|
@@ -152,14 +158,25 @@ export declare function idpSessionSqliteTable(name?: string): import("drizzle-or
|
|
|
152
158
|
identity: undefined;
|
|
153
159
|
generated: undefined;
|
|
154
160
|
}, {}, {
|
|
155
|
-
$type:
|
|
161
|
+
$type: {
|
|
162
|
+
[x: string]: unknown;
|
|
163
|
+
id: string;
|
|
164
|
+
slug: string;
|
|
165
|
+
name: string;
|
|
166
|
+
domain: string | null;
|
|
167
|
+
role: string;
|
|
168
|
+
}[];
|
|
156
169
|
}>;
|
|
157
170
|
actor: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
158
171
|
name: "actor";
|
|
159
172
|
tableName: string;
|
|
160
173
|
dataType: "json";
|
|
161
174
|
columnType: "SQLiteTextJson";
|
|
162
|
-
data:
|
|
175
|
+
data: {
|
|
176
|
+
[x: string]: unknown;
|
|
177
|
+
sub: string;
|
|
178
|
+
email?: string | undefined;
|
|
179
|
+
} | null;
|
|
163
180
|
driverParam: string;
|
|
164
181
|
notNull: false;
|
|
165
182
|
hasDefault: false;
|
|
@@ -171,7 +188,11 @@ export declare function idpSessionSqliteTable(name?: string): import("drizzle-or
|
|
|
171
188
|
identity: undefined;
|
|
172
189
|
generated: undefined;
|
|
173
190
|
}, {}, {
|
|
174
|
-
$type:
|
|
191
|
+
$type: {
|
|
192
|
+
[x: string]: unknown;
|
|
193
|
+
sub: string;
|
|
194
|
+
email?: string | undefined;
|
|
195
|
+
} | null;
|
|
175
196
|
}>;
|
|
176
197
|
accessToken: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
177
198
|
name: "access_token";
|
|
@@ -415,7 +436,14 @@ export declare function idpSessionPgTable(name?: string): import("drizzle-orm/pg
|
|
|
415
436
|
tableName: string;
|
|
416
437
|
dataType: "json";
|
|
417
438
|
columnType: "PgJsonb";
|
|
418
|
-
data:
|
|
439
|
+
data: {
|
|
440
|
+
[x: string]: unknown;
|
|
441
|
+
id: string;
|
|
442
|
+
slug: string;
|
|
443
|
+
name: string;
|
|
444
|
+
domain: string | null;
|
|
445
|
+
role: string;
|
|
446
|
+
}[];
|
|
419
447
|
driverParam: unknown;
|
|
420
448
|
notNull: true;
|
|
421
449
|
hasDefault: false;
|
|
@@ -427,14 +455,25 @@ export declare function idpSessionPgTable(name?: string): import("drizzle-orm/pg
|
|
|
427
455
|
identity: undefined;
|
|
428
456
|
generated: undefined;
|
|
429
457
|
}, {}, {
|
|
430
|
-
$type:
|
|
458
|
+
$type: {
|
|
459
|
+
[x: string]: unknown;
|
|
460
|
+
id: string;
|
|
461
|
+
slug: string;
|
|
462
|
+
name: string;
|
|
463
|
+
domain: string | null;
|
|
464
|
+
role: string;
|
|
465
|
+
}[];
|
|
431
466
|
}>;
|
|
432
467
|
actor: import("drizzle-orm/pg-core").PgColumn<{
|
|
433
468
|
name: "actor";
|
|
434
469
|
tableName: string;
|
|
435
470
|
dataType: "json";
|
|
436
471
|
columnType: "PgJsonb";
|
|
437
|
-
data:
|
|
472
|
+
data: {
|
|
473
|
+
[x: string]: unknown;
|
|
474
|
+
sub: string;
|
|
475
|
+
email?: string | undefined;
|
|
476
|
+
} | null;
|
|
438
477
|
driverParam: unknown;
|
|
439
478
|
notNull: false;
|
|
440
479
|
hasDefault: false;
|
|
@@ -446,7 +485,11 @@ export declare function idpSessionPgTable(name?: string): import("drizzle-orm/pg
|
|
|
446
485
|
identity: undefined;
|
|
447
486
|
generated: undefined;
|
|
448
487
|
}, {}, {
|
|
449
|
-
$type:
|
|
488
|
+
$type: {
|
|
489
|
+
[x: string]: unknown;
|
|
490
|
+
sub: string;
|
|
491
|
+
email?: string | undefined;
|
|
492
|
+
} | null;
|
|
450
493
|
}>;
|
|
451
494
|
accessToken: import("drizzle-orm/pg-core").PgColumn<{
|
|
452
495
|
name: "access_token";
|
|
@@ -694,7 +737,14 @@ export declare const idpSession: import("drizzle-orm/sqlite-core").SQLiteTableWi
|
|
|
694
737
|
tableName: string;
|
|
695
738
|
dataType: "json";
|
|
696
739
|
columnType: "SQLiteTextJson";
|
|
697
|
-
data:
|
|
740
|
+
data: {
|
|
741
|
+
[x: string]: unknown;
|
|
742
|
+
id: string;
|
|
743
|
+
slug: string;
|
|
744
|
+
name: string;
|
|
745
|
+
domain: string | null;
|
|
746
|
+
role: string;
|
|
747
|
+
}[];
|
|
698
748
|
driverParam: string;
|
|
699
749
|
notNull: true;
|
|
700
750
|
hasDefault: false;
|
|
@@ -706,14 +756,25 @@ export declare const idpSession: import("drizzle-orm/sqlite-core").SQLiteTableWi
|
|
|
706
756
|
identity: undefined;
|
|
707
757
|
generated: undefined;
|
|
708
758
|
}, {}, {
|
|
709
|
-
$type:
|
|
759
|
+
$type: {
|
|
760
|
+
[x: string]: unknown;
|
|
761
|
+
id: string;
|
|
762
|
+
slug: string;
|
|
763
|
+
name: string;
|
|
764
|
+
domain: string | null;
|
|
765
|
+
role: string;
|
|
766
|
+
}[];
|
|
710
767
|
}>;
|
|
711
768
|
actor: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
712
769
|
name: "actor";
|
|
713
770
|
tableName: string;
|
|
714
771
|
dataType: "json";
|
|
715
772
|
columnType: "SQLiteTextJson";
|
|
716
|
-
data:
|
|
773
|
+
data: {
|
|
774
|
+
[x: string]: unknown;
|
|
775
|
+
sub: string;
|
|
776
|
+
email?: string | undefined;
|
|
777
|
+
} | null;
|
|
717
778
|
driverParam: string;
|
|
718
779
|
notNull: false;
|
|
719
780
|
hasDefault: false;
|
|
@@ -725,7 +786,11 @@ export declare const idpSession: import("drizzle-orm/sqlite-core").SQLiteTableWi
|
|
|
725
786
|
identity: undefined;
|
|
726
787
|
generated: undefined;
|
|
727
788
|
}, {}, {
|
|
728
|
-
$type:
|
|
789
|
+
$type: {
|
|
790
|
+
[x: string]: unknown;
|
|
791
|
+
sub: string;
|
|
792
|
+
email?: string | undefined;
|
|
793
|
+
} | null;
|
|
729
794
|
}>;
|
|
730
795
|
accessToken: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
731
796
|
name: "access_token";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/drizzle/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/drizzle/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,aAAa,CAAA;AAE9D,eAAO,MAAM,iBAAiB,gBAAgB,CAAA;AAE9C;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,GAAE,MAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AG,EAAE,KAAK,GAAG,CAAA;CAChC,CAAA;AAED,KAAK,eAAe,GAChB,UAAU,CAAC,OAAO,qBAAqB,CAAC,GACxC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAExC,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG,YAAY,CA8BzF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The one error type this package throws. Its own module so validation and
|
|
2
|
+
* the client can both raise it without importing each other. */
|
|
3
|
+
export declare class IdpError extends Error {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly body: unknown;
|
|
6
|
+
constructor(message: string, status: number, body?: unknown);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;gEACgE;AAChE,qBAAa,QAAS,SAAQ,KAAK;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;gBACV,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;CAM5D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The one error type this package throws. Its own module so validation and
|
|
2
|
+
* the client can both raise it without importing each other. */
|
|
3
|
+
export class IdpError extends Error {
|
|
4
|
+
status;
|
|
5
|
+
body;
|
|
6
|
+
constructor(message, status, body) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "IdpError";
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.body = body;
|
|
11
|
+
}
|
|
12
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -12,10 +12,12 @@
|
|
|
12
12
|
* @willyim/idp/drizzle the session store, and the `idp_session` table
|
|
13
13
|
* @willyim/idp/react-router the auth route and the loader guards
|
|
14
14
|
*/
|
|
15
|
-
export { createIdpClient, createPkce, DEFAULT_SCOPES, IdpError, type AuthorizationUrlInput, type Discovery, type IdpClient, type IdpClientOptions, type Tokens, } from "./client.js";
|
|
15
|
+
export { createIdpClient, createPkce, DEFAULT_SCOPES, IdpError, SUPPORTED_SCOPES, type AuthorizationUrlInput, type Discovery, type IdpClient, type IdpClientOptions, type IdpScope, type Tokens, } from "./client.js";
|
|
16
16
|
export { createIdp, DEFAULT_SESSION_COOKIE, safeNext, type Idp, type IdpOptions, type Session, type SessionOptions, } from "./session.js";
|
|
17
17
|
export { memorySessions, type MemorySessionStore, type SessionRecord, type SessionStore, } from "./store.js";
|
|
18
18
|
export { grants, normalizeClaims, PERMISSIONS_CLAIM, WORKSPACES_CLAIM, type Actor, type Claims, type Workspace, } from "./claims.js";
|
|
19
|
+
export { createManagementApi, type ManagementApi, type ManagementApiOptions, } from "./api.js";
|
|
20
|
+
export { createUserKeys, readApiKey, type AuthenticatedKey, type AuthenticateOptions, type AuthenticateResult, type CreateUserApiKeyInput, type ListFilter, type MintedUserApiKey, type UserApiKey, type UserKeyCacheOptions, type UserKeys, type UserKeysOptions, type UserKeyValidation, } from "./user-keys.js";
|
|
19
21
|
export { parseDuration, type Duration } from "./duration.js";
|
|
20
22
|
export { clearCookie, parseCookies, readCookie, serializeCookie, type CookieOptions, } from "./cookie.js";
|
|
21
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,eAAe,EACf,UAAU,EACV,cAAc,EACd,QAAQ,EACR,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,MAAM,GACZ,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,QAAQ,EACR,KAAK,GAAG,EACR,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,cAAc,GACpB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,MAAM,EACN,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,SAAS,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EACL,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,eAAe,EACf,UAAU,EACV,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,MAAM,GACZ,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,QAAQ,EACR,KAAK,GAAG,EACR,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,cAAc,GACpB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,MAAM,EACN,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,SAAS,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,oBAAoB,GAC1B,MAAM,UAAU,CAAA;AAEjB,OAAO,EACL,cAAc,EACd,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EACL,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -12,9 +12,11 @@
|
|
|
12
12
|
* @willyim/idp/drizzle the session store, and the `idp_session` table
|
|
13
13
|
* @willyim/idp/react-router the auth route and the loader guards
|
|
14
14
|
*/
|
|
15
|
-
export { createIdpClient, createPkce, DEFAULT_SCOPES, IdpError, } from "./client.js";
|
|
15
|
+
export { createIdpClient, createPkce, DEFAULT_SCOPES, IdpError, SUPPORTED_SCOPES, } from "./client.js";
|
|
16
16
|
export { createIdp, DEFAULT_SESSION_COOKIE, safeNext, } from "./session.js";
|
|
17
17
|
export { memorySessions, } from "./store.js";
|
|
18
18
|
export { grants, normalizeClaims, PERMISSIONS_CLAIM, WORKSPACES_CLAIM, } from "./claims.js";
|
|
19
|
+
export { createManagementApi, } from "./api.js";
|
|
20
|
+
export { createUserKeys, readApiKey, } from "./user-keys.js";
|
|
19
21
|
export { parseDuration } from "./duration.js";
|
|
20
22
|
export { clearCookie, parseCookies, readCookie, serializeCookie, } from "./cookie.js";
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wire shapes of the IdP management API (`/api/v1/*`), as zod schemas.
|
|
3
|
+
*
|
|
4
|
+
* One definition, three consumers: `apps/idp` validates incoming requests with
|
|
5
|
+
* them, `scripts/generate-openapi.mjs` turns them into the OpenAPI document,
|
|
6
|
+
* and the SDK's `api.ts` parses responses against them. Types are `z.infer`,
|
|
7
|
+
* so there is no generated `.d.ts` to drift out of sync.
|
|
8
|
+
*
|
|
9
|
+
* The OIDC endpoints are NOT here — those are standards-defined and live in
|
|
10
|
+
* `../wire.ts`, next to the code that talks to them.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
export declare const ApplicationSchema: z.ZodObject<{
|
|
14
|
+
clientId: z.ZodString;
|
|
15
|
+
name: z.ZodNullable<z.ZodString>;
|
|
16
|
+
app: z.ZodNullable<z.ZodString>;
|
|
17
|
+
redirectUris: z.ZodArray<z.ZodString>;
|
|
18
|
+
disabled: z.ZodBoolean;
|
|
19
|
+
createdAt: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export declare const UserSchema: z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
email: z.ZodString;
|
|
24
|
+
name: z.ZodNullable<z.ZodString>;
|
|
25
|
+
emailVerified: z.ZodBoolean;
|
|
26
|
+
createdAt: z.ZodString;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export declare const WorkspaceSchema: z.ZodObject<{
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
slug: z.ZodString;
|
|
32
|
+
applicationId: z.ZodNullable<z.ZodString>;
|
|
33
|
+
createdAt: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const ApplicationListSchema: z.ZodObject<{
|
|
36
|
+
applications: z.ZodArray<z.ZodObject<{
|
|
37
|
+
clientId: z.ZodString;
|
|
38
|
+
name: z.ZodNullable<z.ZodString>;
|
|
39
|
+
app: z.ZodNullable<z.ZodString>;
|
|
40
|
+
redirectUris: z.ZodArray<z.ZodString>;
|
|
41
|
+
disabled: z.ZodBoolean;
|
|
42
|
+
createdAt: z.ZodString;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export declare const UserListSchema: z.ZodObject<{
|
|
46
|
+
users: z.ZodArray<z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
email: z.ZodString;
|
|
49
|
+
name: z.ZodNullable<z.ZodString>;
|
|
50
|
+
emailVerified: z.ZodBoolean;
|
|
51
|
+
createdAt: z.ZodString;
|
|
52
|
+
}, z.core.$strip>>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export declare const WorkspaceListSchema: z.ZodObject<{
|
|
55
|
+
workspaces: z.ZodArray<z.ZodObject<{
|
|
56
|
+
id: z.ZodString;
|
|
57
|
+
name: z.ZodString;
|
|
58
|
+
slug: z.ZodString;
|
|
59
|
+
applicationId: z.ZodNullable<z.ZodString>;
|
|
60
|
+
createdAt: z.ZodString;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
export declare const RoleSchema: z.ZodEnum<{
|
|
64
|
+
admin: "admin";
|
|
65
|
+
member: "member";
|
|
66
|
+
}>;
|
|
67
|
+
export declare const MemberSchema: z.ZodObject<{
|
|
68
|
+
userId: z.ZodString;
|
|
69
|
+
email: z.ZodString;
|
|
70
|
+
name: z.ZodNullable<z.ZodString>;
|
|
71
|
+
role: z.ZodEnum<{
|
|
72
|
+
admin: "admin";
|
|
73
|
+
member: "member";
|
|
74
|
+
}>;
|
|
75
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
export declare const MemberListSchema: z.ZodObject<{
|
|
78
|
+
members: z.ZodArray<z.ZodObject<{
|
|
79
|
+
userId: z.ZodString;
|
|
80
|
+
email: z.ZodString;
|
|
81
|
+
name: z.ZodNullable<z.ZodString>;
|
|
82
|
+
role: z.ZodEnum<{
|
|
83
|
+
admin: "admin";
|
|
84
|
+
member: "member";
|
|
85
|
+
}>;
|
|
86
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
87
|
+
}, z.core.$strip>>;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
/** Add (existing user) or invite (new email) an app member. */
|
|
90
|
+
export declare const InviteMemberInput: z.ZodObject<{
|
|
91
|
+
email: z.ZodString;
|
|
92
|
+
role: z.ZodDefault<z.ZodEnum<{
|
|
93
|
+
admin: "admin";
|
|
94
|
+
member: "member";
|
|
95
|
+
}>>;
|
|
96
|
+
permissions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
export declare const InviteMemberResult: z.ZodObject<{
|
|
99
|
+
result: z.ZodEnum<{
|
|
100
|
+
added: "added";
|
|
101
|
+
invited: "invited";
|
|
102
|
+
}>;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
export declare const UpdateMemberInput: z.ZodObject<{
|
|
105
|
+
role: z.ZodEnum<{
|
|
106
|
+
admin: "admin";
|
|
107
|
+
member: "member";
|
|
108
|
+
}>;
|
|
109
|
+
permissions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
export declare const CreateWorkspaceInput: z.ZodObject<{
|
|
112
|
+
name: z.ZodString;
|
|
113
|
+
slug: z.ZodString;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
export declare const WorkspaceCreatedSchema: z.ZodObject<{
|
|
116
|
+
id: z.ZodString;
|
|
117
|
+
name: z.ZodString;
|
|
118
|
+
slug: z.ZodString;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
export declare const OkSchema: z.ZodObject<{
|
|
121
|
+
ok: z.ZodLiteral<true>;
|
|
122
|
+
}, z.core.$strip>;
|
|
123
|
+
export declare const UserApiKeySchema: z.ZodObject<{
|
|
124
|
+
id: z.ZodString;
|
|
125
|
+
userId: z.ZodString;
|
|
126
|
+
workspaceId: z.ZodNullable<z.ZodString>;
|
|
127
|
+
name: z.ZodString;
|
|
128
|
+
prefix: z.ZodString;
|
|
129
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
130
|
+
status: z.ZodEnum<{
|
|
131
|
+
active: "active";
|
|
132
|
+
expired: "expired";
|
|
133
|
+
revoked: "revoked";
|
|
134
|
+
}>;
|
|
135
|
+
createdAt: z.ZodString;
|
|
136
|
+
lastUsedAt: z.ZodNullable<z.ZodString>;
|
|
137
|
+
expiresAt: z.ZodNullable<z.ZodString>;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
export declare const UserApiKeyListSchema: z.ZodObject<{
|
|
140
|
+
keys: z.ZodArray<z.ZodObject<{
|
|
141
|
+
id: z.ZodString;
|
|
142
|
+
userId: z.ZodString;
|
|
143
|
+
workspaceId: z.ZodNullable<z.ZodString>;
|
|
144
|
+
name: z.ZodString;
|
|
145
|
+
prefix: z.ZodString;
|
|
146
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
147
|
+
status: z.ZodEnum<{
|
|
148
|
+
active: "active";
|
|
149
|
+
expired: "expired";
|
|
150
|
+
revoked: "revoked";
|
|
151
|
+
}>;
|
|
152
|
+
createdAt: z.ZodString;
|
|
153
|
+
lastUsedAt: z.ZodNullable<z.ZodString>;
|
|
154
|
+
expiresAt: z.ZodNullable<z.ZodString>;
|
|
155
|
+
}, z.core.$strip>>;
|
|
156
|
+
}, z.core.$strip>;
|
|
157
|
+
export declare const CreateUserApiKeyInput: z.ZodObject<{
|
|
158
|
+
userId: z.ZodString;
|
|
159
|
+
name: z.ZodString;
|
|
160
|
+
scopes: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
161
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
162
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
163
|
+
}, z.core.$strip>;
|
|
164
|
+
export declare const UserApiKeyCreatedSchema: z.ZodObject<{
|
|
165
|
+
id: z.ZodString;
|
|
166
|
+
token: z.ZodString;
|
|
167
|
+
prefix: z.ZodString;
|
|
168
|
+
}, z.core.$strip>;
|
|
169
|
+
export declare const ValidateUserApiKeyInput: z.ZodObject<{
|
|
170
|
+
token: z.ZodString;
|
|
171
|
+
}, z.core.$strip>;
|
|
172
|
+
export declare const UserApiKeyValidationSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
173
|
+
valid: z.ZodLiteral<true>;
|
|
174
|
+
keyId: z.ZodString;
|
|
175
|
+
userId: z.ZodString;
|
|
176
|
+
workspaceId: z.ZodNullable<z.ZodString>;
|
|
177
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
178
|
+
name: z.ZodString;
|
|
179
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
180
|
+
valid: z.ZodLiteral<false>;
|
|
181
|
+
reason: z.ZodEnum<{
|
|
182
|
+
expired: "expired";
|
|
183
|
+
revoked: "revoked";
|
|
184
|
+
not_found: "not_found";
|
|
185
|
+
}>;
|
|
186
|
+
}, z.core.$strip>]>;
|
|
187
|
+
export declare const AuditEntrySchema: z.ZodObject<{
|
|
188
|
+
id: z.ZodNumber;
|
|
189
|
+
tableName: z.ZodString;
|
|
190
|
+
operation: z.ZodString;
|
|
191
|
+
rowId: z.ZodNullable<z.ZodString>;
|
|
192
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
193
|
+
actor: z.ZodNullable<z.ZodString>;
|
|
194
|
+
createdAt: z.ZodString;
|
|
195
|
+
}, z.core.$strip>;
|
|
196
|
+
export declare const AuditListSchema: z.ZodObject<{
|
|
197
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
198
|
+
id: z.ZodNumber;
|
|
199
|
+
tableName: z.ZodString;
|
|
200
|
+
operation: z.ZodString;
|
|
201
|
+
rowId: z.ZodNullable<z.ZodString>;
|
|
202
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
203
|
+
actor: z.ZodNullable<z.ZodString>;
|
|
204
|
+
createdAt: z.ZodString;
|
|
205
|
+
}, z.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AA0B;;;;;;;;;;;;;;mBAUrC,CAAA;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;iBAQ3B,CAAA;AACF,eAAO,MAAM,eAAe;;;;;;;;;;iBAAmD,CAAA"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wire shapes of the IdP management API (`/api/v1/*`), as zod schemas.
|
|
3
|
+
*
|
|
4
|
+
* One definition, three consumers: `apps/idp` validates incoming requests with
|
|
5
|
+
* them, `scripts/generate-openapi.mjs` turns them into the OpenAPI document,
|
|
6
|
+
* and the SDK's `api.ts` parses responses against them. Types are `z.infer`,
|
|
7
|
+
* so there is no generated `.d.ts` to drift out of sync.
|
|
8
|
+
*
|
|
9
|
+
* The OIDC endpoints are NOT here — those are standards-defined and live in
|
|
10
|
+
* `../wire.ts`, next to the code that talks to them.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
export const ApplicationSchema = z.object({
|
|
14
|
+
clientId: z.string(),
|
|
15
|
+
name: z.string().nullable(),
|
|
16
|
+
app: z.string().nullable().describe("Application key; consumer workspace claims are filtered by this"),
|
|
17
|
+
redirectUris: z.array(z.string()),
|
|
18
|
+
disabled: z.boolean(),
|
|
19
|
+
createdAt: z.string().describe("ISO 8601 timestamp"),
|
|
20
|
+
});
|
|
21
|
+
export const UserSchema = z.object({
|
|
22
|
+
id: z.string(),
|
|
23
|
+
email: z.string(),
|
|
24
|
+
name: z.string().nullable(),
|
|
25
|
+
emailVerified: z.boolean(),
|
|
26
|
+
createdAt: z.string(),
|
|
27
|
+
});
|
|
28
|
+
export const WorkspaceSchema = z.object({
|
|
29
|
+
id: z.string(),
|
|
30
|
+
name: z.string(),
|
|
31
|
+
slug: z.string(),
|
|
32
|
+
applicationId: z.string().nullable(),
|
|
33
|
+
createdAt: z.string(),
|
|
34
|
+
});
|
|
35
|
+
export const ApplicationListSchema = z.object({ applications: z.array(ApplicationSchema) });
|
|
36
|
+
export const UserListSchema = z.object({ users: z.array(UserSchema) });
|
|
37
|
+
export const WorkspaceListSchema = z.object({ workspaces: z.array(WorkspaceSchema) });
|
|
38
|
+
// --- Write management API (scoped-key authenticated, per-app) ---
|
|
39
|
+
export const RoleSchema = z.enum(["admin", "member"]);
|
|
40
|
+
export const MemberSchema = z.object({
|
|
41
|
+
userId: z.string(),
|
|
42
|
+
email: z.string(),
|
|
43
|
+
name: z.string().nullable(),
|
|
44
|
+
role: RoleSchema,
|
|
45
|
+
permissions: z.array(z.string()),
|
|
46
|
+
});
|
|
47
|
+
export const MemberListSchema = z.object({ members: z.array(MemberSchema) });
|
|
48
|
+
/** Add (existing user) or invite (new email) an app member. */
|
|
49
|
+
export const InviteMemberInput = z.object({
|
|
50
|
+
email: z.string().email(),
|
|
51
|
+
role: RoleSchema.default("member"),
|
|
52
|
+
permissions: z.array(z.string()).default([]),
|
|
53
|
+
});
|
|
54
|
+
export const InviteMemberResult = z.object({
|
|
55
|
+
// "added" = existing user joined now; "invited" = pending invite emailed.
|
|
56
|
+
result: z.enum(["added", "invited"]),
|
|
57
|
+
});
|
|
58
|
+
export const UpdateMemberInput = z.object({
|
|
59
|
+
role: RoleSchema,
|
|
60
|
+
permissions: z.array(z.string()).default([]),
|
|
61
|
+
});
|
|
62
|
+
export const CreateWorkspaceInput = z.object({
|
|
63
|
+
name: z.string().min(1),
|
|
64
|
+
slug: z
|
|
65
|
+
.string()
|
|
66
|
+
.min(1)
|
|
67
|
+
.regex(/^[a-z0-9-]+$/, "lowercase letters, numbers and dashes only"),
|
|
68
|
+
});
|
|
69
|
+
export const WorkspaceCreatedSchema = z.object({
|
|
70
|
+
id: z.string(),
|
|
71
|
+
name: z.string(),
|
|
72
|
+
slug: z.string(),
|
|
73
|
+
});
|
|
74
|
+
export const OkSchema = z.object({ ok: z.literal(true) });
|
|
75
|
+
// --- End-user API keys (the app's own API credentials, stored in the IdP) ---
|
|
76
|
+
export const UserApiKeySchema = z.object({
|
|
77
|
+
id: z.string(),
|
|
78
|
+
userId: z.string(),
|
|
79
|
+
workspaceId: z.string().nullable(),
|
|
80
|
+
name: z.string(),
|
|
81
|
+
prefix: z.string().describe("Non-secret token prefix (wak_…) for display"),
|
|
82
|
+
scopes: z.array(z.string()),
|
|
83
|
+
status: z.enum(["active", "expired", "revoked"]),
|
|
84
|
+
createdAt: z.string(),
|
|
85
|
+
lastUsedAt: z.string().nullable(),
|
|
86
|
+
expiresAt: z.string().nullable(),
|
|
87
|
+
});
|
|
88
|
+
export const UserApiKeyListSchema = z.object({ keys: z.array(UserApiKeySchema) });
|
|
89
|
+
export const CreateUserApiKeyInput = z.object({
|
|
90
|
+
userId: z.string().min(1),
|
|
91
|
+
name: z.string().min(1),
|
|
92
|
+
scopes: z.array(z.string()).default([]).describe("Subset of the app's product permission catalog"),
|
|
93
|
+
workspaceId: z.string().optional(),
|
|
94
|
+
expiresAt: z.iso.datetime().optional().describe("ISO 8601; omit for non-expiring"),
|
|
95
|
+
});
|
|
96
|
+
export const UserApiKeyCreatedSchema = z.object({
|
|
97
|
+
id: z.string(),
|
|
98
|
+
token: z.string().describe("Plaintext key — shown exactly once, never stored"),
|
|
99
|
+
prefix: z.string(),
|
|
100
|
+
});
|
|
101
|
+
export const ValidateUserApiKeyInput = z.object({ token: z.string().min(1) });
|
|
102
|
+
export const UserApiKeyValidationSchema = z.union([
|
|
103
|
+
z.object({
|
|
104
|
+
valid: z.literal(true),
|
|
105
|
+
keyId: z.string(),
|
|
106
|
+
userId: z.string(),
|
|
107
|
+
workspaceId: z.string().nullable(),
|
|
108
|
+
scopes: z.array(z.string()),
|
|
109
|
+
name: z.string(),
|
|
110
|
+
}),
|
|
111
|
+
z.object({ valid: z.literal(false), reason: z.enum(["not_found", "revoked", "expired"]) }),
|
|
112
|
+
]);
|
|
113
|
+
export const AuditEntrySchema = z.object({
|
|
114
|
+
id: z.number(),
|
|
115
|
+
tableName: z.string(),
|
|
116
|
+
operation: z.string(),
|
|
117
|
+
rowId: z.string().nullable(),
|
|
118
|
+
userId: z.string().nullable(),
|
|
119
|
+
actor: z.string().nullable(),
|
|
120
|
+
createdAt: z.string(),
|
|
121
|
+
});
|
|
122
|
+
export const AuditListSchema = z.object({ entries: z.array(AuditEntrySchema) });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The published OpenAPI document, built from `./operations.ts`.
|
|
3
|
+
*
|
|
4
|
+
* `apps/idp` serves this at `/api/v1/openapi.json`; `npm run openapi` writes
|
|
5
|
+
* the same object to `openapi/idp-api.json` so the snapshot in the repo is
|
|
6
|
+
* always what the server would answer.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildOpenApiDocument(input: {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
}): {
|
|
11
|
+
openapi: string;
|
|
12
|
+
info: {
|
|
13
|
+
title: string;
|
|
14
|
+
version: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
servers: {
|
|
18
|
+
url: string;
|
|
19
|
+
}[];
|
|
20
|
+
components: {
|
|
21
|
+
securitySchemes: {
|
|
22
|
+
bearerAuth: {
|
|
23
|
+
type: string;
|
|
24
|
+
scheme: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
paths: Record<string, Record<string, unknown>>;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=openapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../../src/schemas/openapi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoFH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;EA6B9D"}
|