prostgles-types 4.0.122 → 4.0.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth.d.ts +87 -4
- package/dist/auth.d.ts.map +1 -1
- package/lib/auth.ts +57 -4
- package/package.json +1 -1
package/dist/auth.d.ts
CHANGED
|
@@ -4,8 +4,11 @@ export type UserLike = {
|
|
|
4
4
|
type: string;
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* - withPassword: email and password required
|
|
9
|
+
* - withMagicLink: email required
|
|
10
|
+
*/
|
|
11
|
+
export type AuthType = "withPassword" | "withMagicLink";
|
|
9
12
|
/**
|
|
10
13
|
* Auth object sent from server to client
|
|
11
14
|
*/
|
|
@@ -25,12 +28,12 @@ export type AuthSocketSchema = {
|
|
|
25
28
|
/**
|
|
26
29
|
* Email login methods enabled on the server
|
|
27
30
|
*/
|
|
28
|
-
loginType:
|
|
31
|
+
loginType: AuthType | undefined;
|
|
29
32
|
/**
|
|
30
33
|
* Email registration methods enabled on the server
|
|
31
34
|
*/
|
|
32
35
|
register: {
|
|
33
|
-
type:
|
|
36
|
+
type: AuthType;
|
|
34
37
|
url: string;
|
|
35
38
|
} | undefined;
|
|
36
39
|
/**
|
|
@@ -39,4 +42,84 @@ export type AuthSocketSchema = {
|
|
|
39
42
|
*/
|
|
40
43
|
pathGuard?: boolean;
|
|
41
44
|
};
|
|
45
|
+
export type CommonAuthFailure = {
|
|
46
|
+
success: false;
|
|
47
|
+
code: "rate-limit-exceeded";
|
|
48
|
+
message?: string;
|
|
49
|
+
} | {
|
|
50
|
+
success: false;
|
|
51
|
+
code: "something-went-wrong";
|
|
52
|
+
message?: string;
|
|
53
|
+
};
|
|
54
|
+
export type AuthFailure = CommonAuthFailure | {
|
|
55
|
+
success: false;
|
|
56
|
+
code: "no-match";
|
|
57
|
+
message?: string;
|
|
58
|
+
} | {
|
|
59
|
+
success: false;
|
|
60
|
+
code: "inactive-account";
|
|
61
|
+
message?: string;
|
|
62
|
+
};
|
|
63
|
+
export type MagicLinkAuthFailure = AuthFailure | {
|
|
64
|
+
success: false;
|
|
65
|
+
code: "expired-magic-link";
|
|
66
|
+
message?: string;
|
|
67
|
+
};
|
|
68
|
+
export type AuthSuccess = {
|
|
69
|
+
success: true;
|
|
70
|
+
code?: undefined;
|
|
71
|
+
message?: string;
|
|
72
|
+
};
|
|
73
|
+
export type RegisterSuccess = {
|
|
74
|
+
success: true;
|
|
75
|
+
code: "email-verification-code-sent";
|
|
76
|
+
message?: string;
|
|
77
|
+
} | {
|
|
78
|
+
success: true;
|
|
79
|
+
code: "magic-link-sent";
|
|
80
|
+
message?: string;
|
|
81
|
+
} | {
|
|
82
|
+
success: true;
|
|
83
|
+
code: "already-registered-but-did-not-confirm-email";
|
|
84
|
+
message?: string;
|
|
85
|
+
};
|
|
86
|
+
export type RegisterFailure = CommonAuthFailure | {
|
|
87
|
+
success: false;
|
|
88
|
+
code: "weak-password";
|
|
89
|
+
message?: string;
|
|
90
|
+
} | {
|
|
91
|
+
success: false;
|
|
92
|
+
code: "totp-token-missing";
|
|
93
|
+
message?: string;
|
|
94
|
+
} | {
|
|
95
|
+
success: false;
|
|
96
|
+
code: "invalid-totp-recovery-code";
|
|
97
|
+
message?: string;
|
|
98
|
+
} | {
|
|
99
|
+
success: false;
|
|
100
|
+
code: "invalid-totp-code";
|
|
101
|
+
message?: string;
|
|
102
|
+
} | {
|
|
103
|
+
success: false;
|
|
104
|
+
code: "provider-issue";
|
|
105
|
+
message?: string;
|
|
106
|
+
};
|
|
107
|
+
export type PasswordAuthFailure = CommonAuthFailure | {
|
|
108
|
+
success: false;
|
|
109
|
+
code: "email-not-confirmed";
|
|
110
|
+
message?: string;
|
|
111
|
+
};
|
|
112
|
+
export type LoginData = {
|
|
113
|
+
/**
|
|
114
|
+
* Email or username
|
|
115
|
+
*/
|
|
116
|
+
username: string;
|
|
117
|
+
/**
|
|
118
|
+
* Undefined if loginType is withMagicLink
|
|
119
|
+
*/
|
|
120
|
+
password?: string;
|
|
121
|
+
remember_me?: boolean;
|
|
122
|
+
totp_token?: string;
|
|
123
|
+
totp_recovery_code?: string;
|
|
124
|
+
};
|
|
42
125
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../lib/auth.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,OAAO,GACP,UAAU,GACV,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../lib/auth.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,OAAO,GACP,UAAU,GACV,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,eAAe,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAE3B;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,GAAG,SA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@ -13,8 +13,11 @@ export type UserLike = {
|
|
|
13
13
|
[key: string]: any;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* - withPassword: email and password required
|
|
18
|
+
* - withMagicLink: email required
|
|
19
|
+
*/
|
|
20
|
+
export type AuthType = "withPassword" | "withMagicLink";
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
23
|
* Auth object sent from server to client
|
|
@@ -35,12 +38,12 @@ export type AuthSocketSchema = {
|
|
|
35
38
|
/**
|
|
36
39
|
* Email login methods enabled on the server
|
|
37
40
|
*/
|
|
38
|
-
loginType:
|
|
41
|
+
loginType: AuthType | undefined;
|
|
39
42
|
|
|
40
43
|
/**
|
|
41
44
|
* Email registration methods enabled on the server
|
|
42
45
|
*/
|
|
43
|
-
register: { type:
|
|
46
|
+
register: { type: AuthType; url: string } | undefined;
|
|
44
47
|
|
|
45
48
|
/**
|
|
46
49
|
* If server auth publicRoutes is set up and AuthGuard is not explicitly disabled ( disableSocketAuthGuard: true ):
|
|
@@ -48,3 +51,53 @@ export type AuthSocketSchema = {
|
|
|
48
51
|
*/
|
|
49
52
|
pathGuard?: boolean;
|
|
50
53
|
};
|
|
54
|
+
|
|
55
|
+
export type CommonAuthFailure =
|
|
56
|
+
| { success: false; code: "rate-limit-exceeded"; message?: string }
|
|
57
|
+
| { success: false; code: "something-went-wrong"; message?: string };
|
|
58
|
+
|
|
59
|
+
export type AuthFailure =
|
|
60
|
+
| CommonAuthFailure
|
|
61
|
+
| { success: false; code: "no-match"; message?: string }
|
|
62
|
+
| { success: false; code: "inactive-account"; message?: string };
|
|
63
|
+
|
|
64
|
+
export type MagicLinkAuthFailure =
|
|
65
|
+
| AuthFailure
|
|
66
|
+
| { success: false; code: "expired-magic-link"; message?: string };
|
|
67
|
+
|
|
68
|
+
export type AuthSuccess = {
|
|
69
|
+
success: true;
|
|
70
|
+
code?: undefined;
|
|
71
|
+
message?: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type RegisterSuccess =
|
|
75
|
+
| { success: true; code: "email-verification-code-sent"; message?: string }
|
|
76
|
+
| { success: true; code: "magic-link-sent"; message?: string }
|
|
77
|
+
| { success: true; code: "already-registered-but-did-not-confirm-email"; message?: string };
|
|
78
|
+
|
|
79
|
+
export type RegisterFailure =
|
|
80
|
+
| CommonAuthFailure
|
|
81
|
+
| { success: false; code: "weak-password"; message?: string }
|
|
82
|
+
| { success: false; code: "totp-token-missing"; message?: string }
|
|
83
|
+
| { success: false; code: "invalid-totp-recovery-code"; message?: string }
|
|
84
|
+
| { success: false; code: "invalid-totp-code"; message?: string }
|
|
85
|
+
| { success: false; code: "provider-issue"; message?: string };
|
|
86
|
+
|
|
87
|
+
export type PasswordAuthFailure =
|
|
88
|
+
| CommonAuthFailure
|
|
89
|
+
| { success: false; code: "email-not-confirmed"; message?: string };
|
|
90
|
+
|
|
91
|
+
export type LoginData = {
|
|
92
|
+
/**
|
|
93
|
+
* Email or username
|
|
94
|
+
*/
|
|
95
|
+
username: string;
|
|
96
|
+
/**
|
|
97
|
+
* Undefined if loginType is withMagicLink
|
|
98
|
+
*/
|
|
99
|
+
password?: string;
|
|
100
|
+
remember_me?: boolean;
|
|
101
|
+
totp_token?: string;
|
|
102
|
+
totp_recovery_code?: string;
|
|
103
|
+
};
|