@seamless-auth/types 0.1.2 → 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/CHANGELOG.md +36 -0
- package/README.md +30 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/schemas/admin/schema.d.ts +99 -0
- package/dist/schemas/admin/schema.d.ts.map +1 -0
- package/dist/schemas/admin/schema.js +38 -0
- package/dist/schemas/admin/schema.js.map +1 -0
- package/dist/schemas/auth/auth.schema.d.ts +158 -0
- package/dist/schemas/auth/auth.schema.d.ts.map +1 -1
- package/dist/schemas/auth/auth.schema.js +82 -0
- package/dist/schemas/auth/auth.schema.js.map +1 -1
- package/dist/schemas/authEvent/schema.d.ts +251 -0
- package/dist/schemas/authEvent/schema.d.ts.map +1 -1
- package/dist/schemas/authEvent/schema.js +94 -1
- package/dist/schemas/authEvent/schema.js.map +1 -1
- package/dist/schemas/common/schema.d.ts +23 -0
- package/dist/schemas/common/schema.d.ts.map +1 -0
- package/dist/schemas/common/schema.js +19 -0
- package/dist/schemas/common/schema.js.map +1 -0
- package/dist/schemas/credential/schema.d.ts +86 -0
- package/dist/schemas/credential/schema.d.ts.map +1 -1
- package/dist/schemas/credential/schema.js +31 -3
- package/dist/schemas/credential/schema.js.map +1 -1
- package/dist/schemas/me/schema.d.ts +104 -0
- package/dist/schemas/me/schema.d.ts.map +1 -0
- package/dist/schemas/me/schema.js +24 -0
- package/dist/schemas/me/schema.js.map +1 -0
- package/dist/schemas/messaging/schema.d.ts +73 -0
- package/dist/schemas/messaging/schema.d.ts.map +1 -0
- package/dist/schemas/messaging/schema.js +63 -0
- package/dist/schemas/messaging/schema.js.map +1 -0
- package/dist/schemas/metrics/schema.d.ts +86 -0
- package/dist/schemas/metrics/schema.d.ts.map +1 -0
- package/dist/schemas/metrics/schema.js +79 -0
- package/dist/schemas/metrics/schema.js.map +1 -0
- package/dist/schemas/oauth/schema.d.ts +68 -0
- package/dist/schemas/oauth/schema.d.ts.map +1 -0
- package/dist/schemas/oauth/schema.js +43 -0
- package/dist/schemas/oauth/schema.js.map +1 -0
- package/dist/schemas/organization/schema.d.ts +228 -0
- package/dist/schemas/organization/schema.d.ts.map +1 -0
- package/dist/schemas/organization/schema.js +90 -0
- package/dist/schemas/organization/schema.js.map +1 -0
- package/dist/schemas/role/schema.d.ts +20 -0
- package/dist/schemas/role/schema.d.ts.map +1 -0
- package/dist/schemas/role/schema.js +58 -0
- package/dist/schemas/role/schema.js.map +1 -0
- package/dist/schemas/session/schema.d.ts +17 -0
- package/dist/schemas/session/schema.d.ts.map +1 -1
- package/dist/schemas/session/schema.js +7 -0
- package/dist/schemas/session/schema.js.map +1 -1
- package/dist/schemas/stepUp/schema.d.ts +31 -0
- package/dist/schemas/stepUp/schema.d.ts.map +1 -0
- package/dist/schemas/stepUp/schema.js +19 -0
- package/dist/schemas/stepUp/schema.js.map +1 -0
- package/dist/schemas/systemConfig/schema.d.ts +368 -0
- package/dist/schemas/systemConfig/schema.d.ts.map +1 -0
- package/dist/schemas/systemConfig/schema.js +141 -0
- package/dist/schemas/systemConfig/schema.js.map +1 -0
- package/dist/schemas/totp/schema.d.ts +26 -0
- package/dist/schemas/totp/schema.d.ts.map +1 -0
- package/dist/schemas/totp/schema.js +23 -0
- package/dist/schemas/totp/schema.js.map +1 -0
- package/dist/schemas/user/schema.d.ts +54 -3
- package/dist/schemas/user/schema.d.ts.map +1 -1
- package/dist/schemas/user/schema.js +34 -7
- package/dist/schemas/user/schema.js.map +1 -1
- package/dist/schemas/webauthn/schema.d.ts +61 -0
- package/dist/schemas/webauthn/schema.d.ts.map +1 -0
- package/dist/schemas/webauthn/schema.js +58 -0
- package/dist/schemas/webauthn/schema.js.map +1 -0
- package/package.json +23 -7
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The caller's own user record. `lastLogin` is null until the first login, and
|
|
4
|
+
* `activeOrganizationId` is null when the access token carries no org context.
|
|
5
|
+
*/
|
|
6
|
+
export declare const MeUserSchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
email: z.ZodEmail;
|
|
9
|
+
phone: z.ZodNullable<z.ZodString>;
|
|
10
|
+
roles: z.ZodArray<z.ZodString>;
|
|
11
|
+
lastLogin: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>>>;
|
|
12
|
+
activeOrganizationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type MeUser = z.infer<typeof MeUserSchema>;
|
|
15
|
+
/** @deprecated Use {@link MeUser}. */
|
|
16
|
+
export type SeamlessUser = MeUser;
|
|
17
|
+
export declare const MeResponseSchema: z.ZodObject<{
|
|
18
|
+
user: z.ZodObject<{
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
email: z.ZodEmail;
|
|
21
|
+
phone: z.ZodNullable<z.ZodString>;
|
|
22
|
+
roles: z.ZodArray<z.ZodString>;
|
|
23
|
+
lastLogin: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>>>;
|
|
24
|
+
activeOrganizationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
credentials: z.ZodArray<z.ZodObject<{
|
|
27
|
+
platform: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
browser: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
createdAt: z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>;
|
|
31
|
+
counter: z.ZodNumber;
|
|
32
|
+
transports: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
33
|
+
ble: "ble";
|
|
34
|
+
hybrid: "hybrid";
|
|
35
|
+
internal: "internal";
|
|
36
|
+
nfc: "nfc";
|
|
37
|
+
usb: "usb";
|
|
38
|
+
cable: "cable";
|
|
39
|
+
"smart-card": "smart-card";
|
|
40
|
+
}>>>;
|
|
41
|
+
deviceType: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
singleDevice: "singleDevice";
|
|
43
|
+
multiDevice: "multiDevice";
|
|
44
|
+
}>>;
|
|
45
|
+
friendlyName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
|
+
lastUsedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>>>;
|
|
47
|
+
deviceInfo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
backedup: z.ZodBoolean;
|
|
49
|
+
backedUp: z.ZodBoolean;
|
|
50
|
+
prfCapable: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
}, z.core.$strip>>;
|
|
52
|
+
organizations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
53
|
+
id: z.ZodString;
|
|
54
|
+
name: z.ZodString;
|
|
55
|
+
slug: z.ZodString;
|
|
56
|
+
createdByUserId: z.ZodNullable<z.ZodString>;
|
|
57
|
+
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
58
|
+
createdAt: z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>;
|
|
59
|
+
updatedAt: z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>;
|
|
60
|
+
membership: z.ZodOptional<z.ZodObject<{
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
organizationId: z.ZodString;
|
|
63
|
+
userId: z.ZodString;
|
|
64
|
+
roles: z.ZodArray<z.ZodString>;
|
|
65
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
66
|
+
createdAt: z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>;
|
|
67
|
+
updatedAt: z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>;
|
|
68
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
id: z.ZodString;
|
|
70
|
+
email: z.ZodEmail;
|
|
71
|
+
phone: z.ZodNullable<z.ZodString>;
|
|
72
|
+
roles: z.ZodArray<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
}, z.core.$strip>>;
|
|
75
|
+
memberCount: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
}, z.core.$strip>>>;
|
|
77
|
+
activeOrganization: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
78
|
+
id: z.ZodString;
|
|
79
|
+
name: z.ZodString;
|
|
80
|
+
slug: z.ZodString;
|
|
81
|
+
createdByUserId: z.ZodNullable<z.ZodString>;
|
|
82
|
+
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
83
|
+
createdAt: z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>;
|
|
84
|
+
updatedAt: z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>;
|
|
85
|
+
membership: z.ZodOptional<z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
organizationId: z.ZodString;
|
|
88
|
+
userId: z.ZodString;
|
|
89
|
+
roles: z.ZodArray<z.ZodString>;
|
|
90
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
91
|
+
createdAt: z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>;
|
|
92
|
+
updatedAt: z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>;
|
|
93
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
94
|
+
id: z.ZodString;
|
|
95
|
+
email: z.ZodEmail;
|
|
96
|
+
phone: z.ZodNullable<z.ZodString>;
|
|
97
|
+
roles: z.ZodArray<z.ZodString>;
|
|
98
|
+
}, z.core.$strip>>;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
memberCount: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
}, z.core.$strip>>>;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
export type MeResponse = z.infer<typeof MeResponseSchema>;
|
|
104
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/me/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;iBAOvB,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD,sCAAsC;AACtC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { IsoDate } from '../../shared.js';
|
|
3
|
+
import { CredentialResponseSchema } from '../credential/schema.js';
|
|
4
|
+
import { OrganizationSchema } from '../organization/schema.js';
|
|
5
|
+
import { RoleNameSchema } from '../role/schema.js';
|
|
6
|
+
/**
|
|
7
|
+
* The caller's own user record. `lastLogin` is null until the first login, and
|
|
8
|
+
* `activeOrganizationId` is null when the access token carries no org context.
|
|
9
|
+
*/
|
|
10
|
+
export const MeUserSchema = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
email: z.email(),
|
|
13
|
+
phone: z.string().nullable(),
|
|
14
|
+
roles: z.array(RoleNameSchema),
|
|
15
|
+
lastLogin: IsoDate.nullable().optional(),
|
|
16
|
+
activeOrganizationId: z.string().nullable().optional(),
|
|
17
|
+
});
|
|
18
|
+
export const MeResponseSchema = z.object({
|
|
19
|
+
user: MeUserSchema,
|
|
20
|
+
credentials: z.array(CredentialResponseSchema),
|
|
21
|
+
organizations: z.array(OrganizationSchema).optional(),
|
|
22
|
+
activeOrganization: OrganizationSchema.nullable().optional(),
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/schemas/me/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACxC,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACvD,CAAC,CAAC;AAOH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC;IAC9C,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE;IACrD,kBAAkB,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC7D,CAAC,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const MessagingChannelSchema: z.ZodEnum<{
|
|
3
|
+
email: "email";
|
|
4
|
+
sms: "sms";
|
|
5
|
+
}>;
|
|
6
|
+
export type MessagingChannel = z.infer<typeof MessagingChannelSchema>;
|
|
7
|
+
export declare const DeliveryResultSchema: z.ZodObject<{
|
|
8
|
+
accepted: z.ZodBoolean;
|
|
9
|
+
provider: z.ZodString;
|
|
10
|
+
channel: z.ZodEnum<{
|
|
11
|
+
email: "email";
|
|
12
|
+
sms: "sms";
|
|
13
|
+
}>;
|
|
14
|
+
messageId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
raw: z.ZodOptional<z.ZodUnknown>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type DeliveryResult = z.infer<typeof DeliveryResultSchema>;
|
|
18
|
+
export declare const EmailMessageSchema: z.ZodObject<{
|
|
19
|
+
to: z.ZodString;
|
|
20
|
+
from: z.ZodOptional<z.ZodString>;
|
|
21
|
+
subject: z.ZodString;
|
|
22
|
+
text: z.ZodString;
|
|
23
|
+
html: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export type EmailMessage = z.infer<typeof EmailMessageSchema>;
|
|
26
|
+
export declare const SmsMessageSchema: z.ZodObject<{
|
|
27
|
+
to: z.ZodString;
|
|
28
|
+
from: z.ZodOptional<z.ZodString>;
|
|
29
|
+
body: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type SmsMessage = z.infer<typeof SmsMessageSchema>;
|
|
32
|
+
export declare const SendOtpEmailInputSchema: z.ZodObject<{
|
|
33
|
+
to: z.ZodString;
|
|
34
|
+
token: z.ZodString;
|
|
35
|
+
from: z.ZodOptional<z.ZodString>;
|
|
36
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type SendOtpEmailInput = z.infer<typeof SendOtpEmailInputSchema>;
|
|
39
|
+
export declare const SendOtpSmsInputSchema: z.ZodObject<{
|
|
40
|
+
to: z.ZodString;
|
|
41
|
+
token: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
42
|
+
from: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type SendOtpSmsInput = z.infer<typeof SendOtpSmsInputSchema>;
|
|
45
|
+
export declare const SendMagicLinkEmailInputSchema: z.ZodObject<{
|
|
46
|
+
to: z.ZodString;
|
|
47
|
+
magicLinkUrl: z.ZodString;
|
|
48
|
+
token: z.ZodOptional<z.ZodString>;
|
|
49
|
+
from: z.ZodOptional<z.ZodString>;
|
|
50
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export type SendMagicLinkEmailInput = z.infer<typeof SendMagicLinkEmailInputSchema>;
|
|
53
|
+
/**
|
|
54
|
+
* What the auth API tells a self-hosted server to deliver. The API never sends
|
|
55
|
+
* the message itself when the adopter owns delivery, so this is the contract
|
|
56
|
+
* between the two.
|
|
57
|
+
*/
|
|
58
|
+
export declare const AuthDeliverySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
59
|
+
kind: z.ZodLiteral<"otp_email">;
|
|
60
|
+
to: z.ZodString;
|
|
61
|
+
token: z.ZodString;
|
|
62
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
63
|
+
kind: z.ZodLiteral<"otp_sms">;
|
|
64
|
+
to: z.ZodString;
|
|
65
|
+
token: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
66
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
67
|
+
kind: z.ZodLiteral<"magic_link_email">;
|
|
68
|
+
to: z.ZodString;
|
|
69
|
+
token: z.ZodOptional<z.ZodString>;
|
|
70
|
+
magicLinkUrl: z.ZodString;
|
|
71
|
+
}, z.core.$strip>], "kind">;
|
|
72
|
+
export type AuthDeliveryInstruction = z.infer<typeof AuthDeliverySchema>;
|
|
73
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/messaging/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,sBAAsB;;;EAA2B,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,oBAAoB;;;;;;;;;iBAM/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,kBAAkB;;;;;;iBAM7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,uBAAuB;;;;;iBAKlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,qBAAqB;;;;iBAIhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,6BAA6B;;;;;;iBAMxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;2BAiB7B,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const MessagingChannelSchema = z.enum(['email', 'sms']);
|
|
3
|
+
export const DeliveryResultSchema = z.object({
|
|
4
|
+
accepted: z.boolean(),
|
|
5
|
+
provider: z.string(),
|
|
6
|
+
channel: MessagingChannelSchema,
|
|
7
|
+
messageId: z.string().optional(),
|
|
8
|
+
raw: z.unknown().optional(),
|
|
9
|
+
});
|
|
10
|
+
export const EmailMessageSchema = z.object({
|
|
11
|
+
to: z.string(),
|
|
12
|
+
from: z.string().optional(),
|
|
13
|
+
subject: z.string(),
|
|
14
|
+
text: z.string(),
|
|
15
|
+
html: z.string().optional(),
|
|
16
|
+
});
|
|
17
|
+
export const SmsMessageSchema = z.object({
|
|
18
|
+
to: z.string(),
|
|
19
|
+
from: z.string().optional(),
|
|
20
|
+
body: z.string(),
|
|
21
|
+
});
|
|
22
|
+
export const SendOtpEmailInputSchema = z.object({
|
|
23
|
+
to: z.string(),
|
|
24
|
+
token: z.string(),
|
|
25
|
+
from: z.string().optional(),
|
|
26
|
+
subject: z.string().optional(),
|
|
27
|
+
});
|
|
28
|
+
export const SendOtpSmsInputSchema = z.object({
|
|
29
|
+
to: z.string(),
|
|
30
|
+
token: z.union([z.string(), z.number()]),
|
|
31
|
+
from: z.string().optional(),
|
|
32
|
+
});
|
|
33
|
+
export const SendMagicLinkEmailInputSchema = z.object({
|
|
34
|
+
to: z.string(),
|
|
35
|
+
magicLinkUrl: z.string(),
|
|
36
|
+
token: z.string().optional(),
|
|
37
|
+
from: z.string().optional(),
|
|
38
|
+
subject: z.string().optional(),
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* What the auth API tells a self-hosted server to deliver. The API never sends
|
|
42
|
+
* the message itself when the adopter owns delivery, so this is the contract
|
|
43
|
+
* between the two.
|
|
44
|
+
*/
|
|
45
|
+
export const AuthDeliverySchema = z.discriminatedUnion('kind', [
|
|
46
|
+
z.object({
|
|
47
|
+
kind: z.literal('otp_email'),
|
|
48
|
+
to: z.string(),
|
|
49
|
+
token: z.string(),
|
|
50
|
+
}),
|
|
51
|
+
z.object({
|
|
52
|
+
kind: z.literal('otp_sms'),
|
|
53
|
+
to: z.string(),
|
|
54
|
+
token: z.union([z.string(), z.number()]),
|
|
55
|
+
}),
|
|
56
|
+
z.object({
|
|
57
|
+
kind: z.literal('magic_link_email'),
|
|
58
|
+
to: z.string(),
|
|
59
|
+
token: z.string().optional(),
|
|
60
|
+
magicLinkUrl: z.string(),
|
|
61
|
+
}),
|
|
62
|
+
]);
|
|
63
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/schemas/messaging/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAI/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,OAAO,EAAE,sBAAsB;IAC/B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAC5B,CA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Interval = z.infer<typeof MetricsIntervalSchema>;
|
|
7
|
+
export declare const MetricsQuerySchema: z.ZodObject<{
|
|
8
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
from: z.ZodOptional<z.ZodString>;
|
|
10
|
+
to: z.ZodOptional<z.ZodString>;
|
|
11
|
+
interval: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
day: "day";
|
|
13
|
+
hour: "hour";
|
|
14
|
+
}>>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type MetricsQuery = z.infer<typeof MetricsQuerySchema>;
|
|
17
|
+
export declare const AuthEventSummaryItemSchema: z.ZodObject<{
|
|
18
|
+
type: z.ZodString;
|
|
19
|
+
count: z.ZodNumber;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export declare const AuthEventSummaryResponseSchema: z.ZodObject<{
|
|
22
|
+
summary: z.ZodArray<z.ZodObject<{
|
|
23
|
+
type: z.ZodString;
|
|
24
|
+
count: z.ZodNumber;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export declare const AuthEventTimeseriesPointSchema: z.ZodObject<{
|
|
28
|
+
bucket: z.ZodString;
|
|
29
|
+
success: z.ZodNumber;
|
|
30
|
+
failed: z.ZodNumber;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type AuthEventTimeseriesPoint = z.infer<typeof AuthEventTimeseriesPointSchema>;
|
|
33
|
+
export declare const AuthEventTimeseriesResponseSchema: z.ZodObject<{
|
|
34
|
+
timeseries: z.ZodArray<z.ZodObject<{
|
|
35
|
+
bucket: z.ZodString;
|
|
36
|
+
success: z.ZodNumber;
|
|
37
|
+
failed: z.ZodNumber;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const LoginStatsResponseSchema: z.ZodObject<{
|
|
41
|
+
success: z.ZodNumber;
|
|
42
|
+
failed: z.ZodNumber;
|
|
43
|
+
successRate: z.ZodNumber;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
/**
|
|
46
|
+
* Anomaly rows come straight out of the event store, where a partially written
|
|
47
|
+
* event is still worth surfacing, so every field is optional here.
|
|
48
|
+
*/
|
|
49
|
+
export declare const PartialAuthEventSchema: z.ZodObject<{
|
|
50
|
+
id: z.ZodOptional<z.ZodString>;
|
|
51
|
+
user_id: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
52
|
+
type: z.ZodOptional<z.ZodString>;
|
|
53
|
+
ip_address: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
54
|
+
user_agent: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
55
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
56
|
+
created_at: z.ZodOptional<z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>>;
|
|
57
|
+
updated_at: z.ZodOptional<z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
export type PartialAuthEvent = z.infer<typeof PartialAuthEventSchema>;
|
|
60
|
+
export declare const SecurityAnomaliesResponseSchema: z.ZodObject<{
|
|
61
|
+
suspiciousEvents: z.ZodArray<z.ZodObject<{
|
|
62
|
+
id: z.ZodOptional<z.ZodString>;
|
|
63
|
+
user_id: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
64
|
+
type: z.ZodOptional<z.ZodString>;
|
|
65
|
+
ip_address: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
66
|
+
user_agent: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
67
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
68
|
+
created_at: z.ZodOptional<z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>>;
|
|
69
|
+
updated_at: z.ZodOptional<z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>>;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
total: z.ZodNumber;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
export type SecurityAnomaliesResponse = z.infer<typeof SecurityAnomaliesResponseSchema>;
|
|
74
|
+
export declare const DashboardMetricsResponseSchema: z.ZodObject<{
|
|
75
|
+
totalUsers: z.ZodNumber;
|
|
76
|
+
activeSessions: z.ZodNumber;
|
|
77
|
+
newUsers24h: z.ZodNumber;
|
|
78
|
+
loginSuccess24h: z.ZodNumber;
|
|
79
|
+
loginFailed24h: z.ZodNumber;
|
|
80
|
+
successRate24h: z.ZodNumber;
|
|
81
|
+
otpUsage24h: z.ZodNumber;
|
|
82
|
+
passkeyUsage24h: z.ZodNumber;
|
|
83
|
+
databaseSize: z.ZodNumber;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
export type DashboardMetricsResponse = z.infer<typeof DashboardMetricsResponseSchema>;
|
|
86
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/metrics/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,qBAAqB;;;EAA0B,CAAC;AAE7D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,kBAAkB;;;;;;;;iBAuC3B,CAAC;AAEL,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,0BAA0B;;;iBAGrC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;iBAEzC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;iBAIzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,eAAO,MAAM,iCAAiC;;;;;;iBAE5C,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;iBAInC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;iBAA4B,CAAC;AAEhE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,+BAA+B;;;;;;;;;;;;iBAG1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,8BAA8B;;;;;;;;;;iBAUzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AuthEventSchema } from '../authEvent/schema.js';
|
|
3
|
+
const MAX_METRICS_WINDOW_MS = 1000 * 60 * 60 * 24 * 366; // ~1 year
|
|
4
|
+
export const MetricsIntervalSchema = z.enum(['hour', 'day']);
|
|
5
|
+
export const MetricsQuerySchema = z
|
|
6
|
+
.object({
|
|
7
|
+
userId: z.string().optional(),
|
|
8
|
+
from: z.string().optional(),
|
|
9
|
+
to: z.string().optional(),
|
|
10
|
+
interval: MetricsIntervalSchema.optional().default('hour'),
|
|
11
|
+
})
|
|
12
|
+
.superRefine((data, ctx) => {
|
|
13
|
+
const fromDate = data.from ? new Date(data.from) : undefined;
|
|
14
|
+
const toDate = data.to ? new Date(data.to) : undefined;
|
|
15
|
+
const fromValid = fromDate !== undefined && !Number.isNaN(fromDate.getTime());
|
|
16
|
+
const toValid = toDate !== undefined && !Number.isNaN(toDate.getTime());
|
|
17
|
+
if (data.from !== undefined && !fromValid) {
|
|
18
|
+
ctx.addIssue({ code: 'custom', path: ['from'], message: 'Invalid from date' });
|
|
19
|
+
}
|
|
20
|
+
if (data.to !== undefined && !toValid) {
|
|
21
|
+
ctx.addIssue({ code: 'custom', path: ['to'], message: 'Invalid to date' });
|
|
22
|
+
}
|
|
23
|
+
if (!fromValid || !toValid || !fromDate || !toDate) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (fromDate.getTime() > toDate.getTime()) {
|
|
27
|
+
ctx.addIssue({ code: 'custom', path: ['to'], message: 'from must be on or before to' });
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// Unbounded windows let a single request scan the whole event table.
|
|
31
|
+
if (toDate.getTime() - fromDate.getTime() > MAX_METRICS_WINDOW_MS) {
|
|
32
|
+
ctx.addIssue({
|
|
33
|
+
code: 'custom',
|
|
34
|
+
path: ['to'],
|
|
35
|
+
message: 'time range exceeds the maximum window',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export const AuthEventSummaryItemSchema = z.object({
|
|
40
|
+
type: z.string(),
|
|
41
|
+
count: z.number(),
|
|
42
|
+
});
|
|
43
|
+
export const AuthEventSummaryResponseSchema = z.object({
|
|
44
|
+
summary: z.array(AuthEventSummaryItemSchema),
|
|
45
|
+
});
|
|
46
|
+
export const AuthEventTimeseriesPointSchema = z.object({
|
|
47
|
+
bucket: z.string(),
|
|
48
|
+
success: z.number(),
|
|
49
|
+
failed: z.number(),
|
|
50
|
+
});
|
|
51
|
+
export const AuthEventTimeseriesResponseSchema = z.object({
|
|
52
|
+
timeseries: z.array(AuthEventTimeseriesPointSchema),
|
|
53
|
+
});
|
|
54
|
+
export const LoginStatsResponseSchema = z.object({
|
|
55
|
+
success: z.number(),
|
|
56
|
+
failed: z.number(),
|
|
57
|
+
successRate: z.number(),
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Anomaly rows come straight out of the event store, where a partially written
|
|
61
|
+
* event is still worth surfacing, so every field is optional here.
|
|
62
|
+
*/
|
|
63
|
+
export const PartialAuthEventSchema = AuthEventSchema.partial();
|
|
64
|
+
export const SecurityAnomaliesResponseSchema = z.object({
|
|
65
|
+
suspiciousEvents: z.array(PartialAuthEventSchema),
|
|
66
|
+
total: z.number().int().nonnegative(),
|
|
67
|
+
});
|
|
68
|
+
export const DashboardMetricsResponseSchema = z.object({
|
|
69
|
+
totalUsers: z.number(),
|
|
70
|
+
activeSessions: z.number(),
|
|
71
|
+
newUsers24h: z.number(),
|
|
72
|
+
loginSuccess24h: z.number(),
|
|
73
|
+
loginFailed24h: z.number(),
|
|
74
|
+
successRate24h: z.number(),
|
|
75
|
+
otpUsage24h: z.number(),
|
|
76
|
+
passkeyUsage24h: z.number(),
|
|
77
|
+
databaseSize: z.number(),
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/schemas/metrics/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,UAAU;AAEnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAI7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,CAAC;IACN,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,EAAE,E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AM,CAAC;IAC/C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAC,OAAO,EAAE,CAAC;AAIhE,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAAC;IACtD,gBAAgB,EAAE,CAAC,CAAC,KAAK,CAAC,sBAAsB,CAAC;IACjD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;CACtC,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC;IACrD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;CACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const OAuthProviderParamSchema: z.ZodObject<{
|
|
3
|
+
providerId: z.ZodString;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
/** A provider as an unauthenticated client may see it: no client or secret material. */
|
|
6
|
+
export declare const PublicOAuthProviderSchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export type PublicOAuthProvider = z.infer<typeof PublicOAuthProviderSchema>;
|
|
12
|
+
export declare const OAuthProvidersResponseSchema: z.ZodObject<{
|
|
13
|
+
providers: z.ZodArray<z.ZodObject<{
|
|
14
|
+
id: z.ZodString;
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export declare const StartOAuthLoginRequestSchema: z.ZodObject<{
|
|
20
|
+
redirectUri: z.ZodOptional<z.ZodURL>;
|
|
21
|
+
returnTo: z.ZodOptional<z.ZodURL>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type StartOAuthLoginRequest = z.infer<typeof StartOAuthLoginRequestSchema>;
|
|
24
|
+
export declare const StartOAuthLoginResponseSchema: z.ZodObject<{
|
|
25
|
+
provider: z.ZodObject<{
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
name: z.ZodString;
|
|
28
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
state: z.ZodString;
|
|
31
|
+
authorizationUrl: z.ZodURL;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type StartOAuthLoginResponse = z.infer<typeof StartOAuthLoginResponseSchema>;
|
|
34
|
+
export declare const FinishOAuthLoginRequestSchema: z.ZodObject<{
|
|
35
|
+
code: z.ZodString;
|
|
36
|
+
state: z.ZodString;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type FinishOAuthLoginRequest = z.infer<typeof FinishOAuthLoginRequestSchema>;
|
|
39
|
+
export declare const OAuthLoginSuccessResponseSchema: z.ZodObject<{
|
|
40
|
+
sub: z.ZodOptional<z.ZodString>;
|
|
41
|
+
message: z.ZodString;
|
|
42
|
+
email: z.ZodOptional<z.ZodString>;
|
|
43
|
+
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
token: z.ZodOptional<z.ZodString>;
|
|
46
|
+
ttl: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
refreshToken: z.ZodOptional<z.ZodString>;
|
|
48
|
+
organizationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
refreshTtl: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export declare const OAUTH_ERROR_CODES: readonly ["oauth_missing_email", "oauth_email_not_verified", "oauth_missing_subject"];
|
|
52
|
+
export declare const OAuthErrorCodeSchema: z.ZodEnum<{
|
|
53
|
+
oauth_missing_email: "oauth_missing_email";
|
|
54
|
+
oauth_email_not_verified: "oauth_email_not_verified";
|
|
55
|
+
oauth_missing_subject: "oauth_missing_subject";
|
|
56
|
+
}>;
|
|
57
|
+
export type OAuthErrorCode = z.infer<typeof OAuthErrorCodeSchema>;
|
|
58
|
+
export declare const OAuthLoginErrorResponseSchema: z.ZodObject<{
|
|
59
|
+
message: z.ZodOptional<z.ZodString>;
|
|
60
|
+
error: z.ZodString;
|
|
61
|
+
code: z.ZodOptional<z.ZodEnum<{
|
|
62
|
+
oauth_missing_email: "oauth_missing_email";
|
|
63
|
+
oauth_email_not_verified: "oauth_email_not_verified";
|
|
64
|
+
oauth_missing_subject: "oauth_missing_subject";
|
|
65
|
+
}>>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type OAuthLoginErrorResponse = z.infer<typeof OAuthLoginErrorResponseSchema>;
|
|
68
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/oauth/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,wBAAwB;;iBAEnC,CAAC;AAEH,wFAAwF;AACxF,eAAO,MAAM,yBAAyB;;;;iBAIpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,4BAA4B;;;;;;iBAEvC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;iBAGvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF,eAAO,MAAM,6BAA6B;;;;;;;;iBAIxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,eAAO,MAAM,6BAA6B;;;iBAGxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,eAAO,MAAM,+BAA+B;;;;;;;;;;;iBAE1C,CAAC;AAEH,eAAO,MAAM,iBAAiB,uFAIpB,CAAC;AAEX,eAAO,MAAM,oBAAoB;;;;EAA4B,CAAC;AAE9D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,6BAA6B;;;;;;;;iBAIxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { RefreshSuccessResponseSchema } from '../auth/auth.schema.js';
|
|
3
|
+
import { OAuthProviderIdSchema } from '../systemConfig/schema.js';
|
|
4
|
+
export const OAuthProviderParamSchema = z.object({
|
|
5
|
+
providerId: OAuthProviderIdSchema,
|
|
6
|
+
});
|
|
7
|
+
/** A provider as an unauthenticated client may see it: no client or secret material. */
|
|
8
|
+
export const PublicOAuthProviderSchema = z.object({
|
|
9
|
+
id: z.string(),
|
|
10
|
+
name: z.string(),
|
|
11
|
+
scopes: z.array(z.string()),
|
|
12
|
+
});
|
|
13
|
+
export const OAuthProvidersResponseSchema = z.object({
|
|
14
|
+
providers: z.array(PublicOAuthProviderSchema),
|
|
15
|
+
});
|
|
16
|
+
export const StartOAuthLoginRequestSchema = z.object({
|
|
17
|
+
redirectUri: z.url().optional(),
|
|
18
|
+
returnTo: z.url().optional(),
|
|
19
|
+
});
|
|
20
|
+
export const StartOAuthLoginResponseSchema = z.object({
|
|
21
|
+
provider: PublicOAuthProviderSchema,
|
|
22
|
+
state: z.string(),
|
|
23
|
+
authorizationUrl: z.url(),
|
|
24
|
+
});
|
|
25
|
+
export const FinishOAuthLoginRequestSchema = z.object({
|
|
26
|
+
code: z.string().trim().min(1),
|
|
27
|
+
state: z.string().trim().min(1),
|
|
28
|
+
});
|
|
29
|
+
export const OAuthLoginSuccessResponseSchema = RefreshSuccessResponseSchema.omit({
|
|
30
|
+
sessionId: true,
|
|
31
|
+
});
|
|
32
|
+
export const OAUTH_ERROR_CODES = [
|
|
33
|
+
'oauth_missing_email',
|
|
34
|
+
'oauth_email_not_verified',
|
|
35
|
+
'oauth_missing_subject',
|
|
36
|
+
];
|
|
37
|
+
export const OAuthErrorCodeSchema = z.enum(OAUTH_ERROR_CODES);
|
|
38
|
+
export const OAuthLoginErrorResponseSchema = z.object({
|
|
39
|
+
message: z.string().optional(),
|
|
40
|
+
error: z.string(),
|
|
41
|
+
code: OAuthErrorCodeSchema.optional(),
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/schemas/oauth/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;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