@oxy.so/contracts 2.2.0 → 4.0.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/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/accountEmail.js +21 -25
- package/dist/cjs/deviceBoot.js +2 -2
- package/dist/cjs/deviceSession.js +73 -16
- package/dist/cjs/externalIdentity.js +9 -3
- package/dist/cjs/identity.js +1 -3
- package/dist/cjs/identityLink.js +22 -19
- package/dist/cjs/identityProof.js +2 -2
- package/dist/cjs/index.js +59 -28
- package/dist/cjs/reputation.js +10 -55
- package/dist/cjs/signIn.js +304 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/accountEmail.js +21 -25
- package/dist/esm/deviceBoot.js +2 -2
- package/dist/esm/deviceSession.js +72 -15
- package/dist/esm/externalIdentity.js +8 -2
- package/dist/esm/identity.js +1 -3
- package/dist/esm/identityLink.js +21 -18
- package/dist/esm/identityProof.js +2 -2
- package/dist/esm/index.js +11 -11
- package/dist/esm/reputation.js +9 -54
- package/dist/esm/signIn.js +299 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/accountEmail.d.ts +20 -28
- package/dist/types/accountGraph.d.ts +4 -4
- package/dist/types/deviceBoot.d.ts +2 -2
- package/dist/types/deviceSession.d.ts +127 -15
- package/dist/types/externalIdentity.d.ts +53 -46
- package/dist/types/identity.d.ts +4 -8
- package/dist/types/identityLink.d.ts +54 -118
- package/dist/types/identityProof.d.ts +3 -3
- package/dist/types/index.d.ts +8 -8
- package/dist/types/inference/entitlement.d.ts +2 -2
- package/dist/types/oauth.d.ts +16 -16
- package/dist/types/reputation.d.ts +32 -127
- package/dist/types/signIn.d.ts +717 -0
- package/dist/types/userResponse.d.ts +2 -2
- package/package.json +1 -1
- package/dist/cjs/webauthn.js +0 -114
- package/dist/esm/webauthn.js +0 -111
- package/dist/types/webauthn.d.ts +0 -173
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signing in: an email code or link, an optional password,
|
|
3
|
+
* and an optional authenticator app (TOTP) as a second factor.
|
|
4
|
+
*
|
|
5
|
+
* Every Oxy app runs these from its own account dialog (official apps and
|
|
6
|
+
* auth.oxy.so only; third parties sign in through OAuth on auth.oxy.so):
|
|
7
|
+
*
|
|
8
|
+
* 1. `POST /auth/signin/email/start` with a username or email. One email
|
|
9
|
+
* carries a 6-digit code AND a one-use link to auth.oxy.so; the answer is the
|
|
10
|
+
* same whether or not the account exists. The dialog keeps the
|
|
11
|
+
* `requestSecret` it is given: only it can collect the session.
|
|
12
|
+
* 2. Either the code (`POST /auth/signin/email/confirm`), or the link opened in
|
|
13
|
+
* the SAME browser (`POST /auth/signin/email/link` from auth.oxy.so, proving
|
|
14
|
+
* the browser's shared device) followed by the dialog's
|
|
15
|
+
* `POST /auth/signin/email/collect`.
|
|
16
|
+
* 3. Or a password (`POST /auth/signin/password`), when the account set one.
|
|
17
|
+
* 4. When the account has an authenticator, every first factor answers a
|
|
18
|
+
* one-use second-factor challenge instead of a session, and
|
|
19
|
+
* `POST /auth/signin/second-factor` takes the TOTP (or a backup code).
|
|
20
|
+
*
|
|
21
|
+
* `POST /auth/signup` creates an account from a username and an email confirmed
|
|
22
|
+
* with `POST /auth/email/verify/{start,confirm}` (purpose `signup`).
|
|
23
|
+
*
|
|
24
|
+
* Every body that ends in a session may carry `device`, the proof of the
|
|
25
|
+
* browser's shared device (ADR 0029 D2), so the account lands on it.
|
|
26
|
+
*/
|
|
27
|
+
import { z } from 'zod';
|
|
28
|
+
import type { LoginResult } from './deviceBoot';
|
|
29
|
+
/** How long the link in a sign-in email can be opened. */
|
|
30
|
+
export declare const EMAIL_SIGNIN_LINK_TTL_MS: number;
|
|
31
|
+
/** How long a second-factor challenge can be answered. */
|
|
32
|
+
export declare const SIGNIN_SECOND_FACTOR_TTL_MS: number;
|
|
33
|
+
/** Wrong second-factor codes one challenge accepts. */
|
|
34
|
+
export declare const SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS = 5;
|
|
35
|
+
/** Shortest password Oxy accepts when one is set. */
|
|
36
|
+
export declare const PASSWORD_MIN_LENGTH = 10;
|
|
37
|
+
/** Longest password Oxy accepts (characters). */
|
|
38
|
+
export declare const PASSWORD_MAX_LENGTH = 256;
|
|
39
|
+
/** Digits in an authenticator code. */
|
|
40
|
+
export declare const TOTP_DIGITS = 6;
|
|
41
|
+
/** Seconds each authenticator code lasts. */
|
|
42
|
+
export declare const TOTP_PERIOD_SECONDS = 30;
|
|
43
|
+
/** Backup codes issued when an authenticator is enabled or they are regenerated. */
|
|
44
|
+
export declare const TOTP_BACKUP_CODE_COUNT = 10;
|
|
45
|
+
/**
|
|
46
|
+
* The long sign-in code: ten characters of Crockford base32 without the
|
|
47
|
+
* look-alikes (no 0, O, 1, I, L, U), shown as `XXXXX-XXXXX`. An account whose
|
|
48
|
+
* sign-in codes were guessed at too often today (the per-account ceiling) is
|
|
49
|
+
* sent this instead of 6 digits for the rest of the day, so its owner can still
|
|
50
|
+
* type a code while guessing one is infeasible.
|
|
51
|
+
*/
|
|
52
|
+
export declare const EMAIL_SIGNIN_LONG_CODE_ALPHABET = "23456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
53
|
+
export declare const EMAIL_SIGNIN_LONG_CODE_LENGTH = 10;
|
|
54
|
+
/**
|
|
55
|
+
* Normalise a typed sign-in code: 6 digits stay as they are; a long code is
|
|
56
|
+
* upper-cased with its dash and spaces removed. Anything else is returned
|
|
57
|
+
* trimmed (and will simply be wrong).
|
|
58
|
+
*/
|
|
59
|
+
export declare function normalizeEmailSignInCode(code: string): string;
|
|
60
|
+
/** A username or an email. */
|
|
61
|
+
export declare const signInIdentifierSchema: z.ZodString;
|
|
62
|
+
/** A password as typed. Its policy applies only when one is set. */
|
|
63
|
+
export declare const passwordInputSchema: z.ZodString;
|
|
64
|
+
/** A new password. */
|
|
65
|
+
export declare const newPasswordSchema: z.ZodString;
|
|
66
|
+
/**
|
|
67
|
+
* An authenticator code (6 digits) or a backup code (10 characters, with or
|
|
68
|
+
* without its dash). Normalised server-side.
|
|
69
|
+
*/
|
|
70
|
+
export declare const secondFactorCodeSchema: z.ZodString;
|
|
71
|
+
/** `POST /auth/signin/email/start` */
|
|
72
|
+
export declare const emailSignInStartRequestSchema: z.ZodObject<{
|
|
73
|
+
identifier: z.ZodString;
|
|
74
|
+
/** The requester's device: the email's link approves only in this browser. */
|
|
75
|
+
device: z.ZodOptional<z.ZodObject<{
|
|
76
|
+
deviceId: z.ZodString;
|
|
77
|
+
deviceSecret: z.ZodString;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
deviceId: string;
|
|
80
|
+
deviceSecret: string;
|
|
81
|
+
}, {
|
|
82
|
+
deviceId: string;
|
|
83
|
+
deviceSecret: string;
|
|
84
|
+
}>>;
|
|
85
|
+
}, "strict", z.ZodTypeAny, {
|
|
86
|
+
identifier: string;
|
|
87
|
+
device?: {
|
|
88
|
+
deviceId: string;
|
|
89
|
+
deviceSecret: string;
|
|
90
|
+
} | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
identifier: string;
|
|
93
|
+
device?: {
|
|
94
|
+
deviceId: string;
|
|
95
|
+
deviceSecret: string;
|
|
96
|
+
} | undefined;
|
|
97
|
+
}>;
|
|
98
|
+
export type EmailSignInStartRequest = z.infer<typeof emailSignInStartRequestSchema>;
|
|
99
|
+
export interface EmailSignInStartResponse {
|
|
100
|
+
/** Names the request. Returned whether or not an email was sent. */
|
|
101
|
+
requestId: string;
|
|
102
|
+
/** Only the caller holds it; confirming or collecting needs it. Keep it in memory. */
|
|
103
|
+
requestSecret: string;
|
|
104
|
+
/** Unix milliseconds after which the code is refused. */
|
|
105
|
+
expiresAt: number;
|
|
106
|
+
/**
|
|
107
|
+
* Present ONLY when the request proved a device this account is already on
|
|
108
|
+
* and no email could be sent right now (too many were): try again later.
|
|
109
|
+
* Every other caller gets the ordinary answer whatever happened.
|
|
110
|
+
*/
|
|
111
|
+
retryLater?: true;
|
|
112
|
+
}
|
|
113
|
+
export declare const emailSignInStartResponseSchema: z.ZodType<EmailSignInStartResponse>;
|
|
114
|
+
/**
|
|
115
|
+
* The code from a sign-in email: 6 digits, or — for an account whose codes
|
|
116
|
+
* were guessed at too often today — the 10-character long code
|
|
117
|
+
* (`EMAIL_SIGNIN_LONG_CODE_ALPHABET`, with or without its dash, any case). The
|
|
118
|
+
* UI must accept BOTH in one field: the email says which was sent, and the
|
|
119
|
+
* start response is the same either way (it says nothing about the account).
|
|
120
|
+
*/
|
|
121
|
+
export declare const emailSignInCodeSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
122
|
+
/** `POST /auth/signin/email/confirm` — the code from the email. */
|
|
123
|
+
export declare const emailSignInConfirmRequestSchema: z.ZodObject<{
|
|
124
|
+
deviceName: z.ZodOptional<z.ZodString>;
|
|
125
|
+
deviceFingerprint: z.ZodOptional<z.ZodString>;
|
|
126
|
+
device: z.ZodOptional<z.ZodObject<{
|
|
127
|
+
deviceId: z.ZodString;
|
|
128
|
+
deviceSecret: z.ZodString;
|
|
129
|
+
}, "strip", z.ZodTypeAny, {
|
|
130
|
+
deviceId: string;
|
|
131
|
+
deviceSecret: string;
|
|
132
|
+
}, {
|
|
133
|
+
deviceId: string;
|
|
134
|
+
deviceSecret: string;
|
|
135
|
+
}>>;
|
|
136
|
+
requestId: z.ZodString;
|
|
137
|
+
requestSecret: z.ZodString;
|
|
138
|
+
code: z.ZodEffects<z.ZodString, string, string>;
|
|
139
|
+
}, "strict", z.ZodTypeAny, {
|
|
140
|
+
code: string;
|
|
141
|
+
requestId: string;
|
|
142
|
+
requestSecret: string;
|
|
143
|
+
device?: {
|
|
144
|
+
deviceId: string;
|
|
145
|
+
deviceSecret: string;
|
|
146
|
+
} | undefined;
|
|
147
|
+
deviceName?: string | undefined;
|
|
148
|
+
deviceFingerprint?: string | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
code: string;
|
|
151
|
+
requestId: string;
|
|
152
|
+
requestSecret: string;
|
|
153
|
+
device?: {
|
|
154
|
+
deviceId: string;
|
|
155
|
+
deviceSecret: string;
|
|
156
|
+
} | undefined;
|
|
157
|
+
deviceName?: string | undefined;
|
|
158
|
+
deviceFingerprint?: string | undefined;
|
|
159
|
+
}>;
|
|
160
|
+
export type EmailSignInConfirmRequest = z.infer<typeof emailSignInConfirmRequestSchema>;
|
|
161
|
+
/** `POST /auth/signin/email/collect` — the dialog asks whether its link was opened. */
|
|
162
|
+
export declare const emailSignInCollectRequestSchema: z.ZodObject<{
|
|
163
|
+
deviceName: z.ZodOptional<z.ZodString>;
|
|
164
|
+
deviceFingerprint: z.ZodOptional<z.ZodString>;
|
|
165
|
+
device: z.ZodOptional<z.ZodObject<{
|
|
166
|
+
deviceId: z.ZodString;
|
|
167
|
+
deviceSecret: z.ZodString;
|
|
168
|
+
}, "strip", z.ZodTypeAny, {
|
|
169
|
+
deviceId: string;
|
|
170
|
+
deviceSecret: string;
|
|
171
|
+
}, {
|
|
172
|
+
deviceId: string;
|
|
173
|
+
deviceSecret: string;
|
|
174
|
+
}>>;
|
|
175
|
+
requestId: z.ZodString;
|
|
176
|
+
requestSecret: z.ZodString;
|
|
177
|
+
}, "strict", z.ZodTypeAny, {
|
|
178
|
+
requestId: string;
|
|
179
|
+
requestSecret: string;
|
|
180
|
+
device?: {
|
|
181
|
+
deviceId: string;
|
|
182
|
+
deviceSecret: string;
|
|
183
|
+
} | undefined;
|
|
184
|
+
deviceName?: string | undefined;
|
|
185
|
+
deviceFingerprint?: string | undefined;
|
|
186
|
+
}, {
|
|
187
|
+
requestId: string;
|
|
188
|
+
requestSecret: string;
|
|
189
|
+
device?: {
|
|
190
|
+
deviceId: string;
|
|
191
|
+
deviceSecret: string;
|
|
192
|
+
} | undefined;
|
|
193
|
+
deviceName?: string | undefined;
|
|
194
|
+
deviceFingerprint?: string | undefined;
|
|
195
|
+
}>;
|
|
196
|
+
export type EmailSignInCollectRequest = z.infer<typeof emailSignInCollectRequestSchema>;
|
|
197
|
+
/**
|
|
198
|
+
* `POST /auth/signin/email/link` — auth.oxy.so, where the email's link lands.
|
|
199
|
+
* It proves auth.oxy.so's own credential for the browser's device; the request
|
|
200
|
+
* is approved only when that is the device that asked.
|
|
201
|
+
*/
|
|
202
|
+
export declare const emailSignInLinkRequestSchema: z.ZodObject<{
|
|
203
|
+
token: z.ZodString;
|
|
204
|
+
device: z.ZodObject<{
|
|
205
|
+
deviceId: z.ZodString;
|
|
206
|
+
deviceSecret: z.ZodString;
|
|
207
|
+
}, "strip", z.ZodTypeAny, {
|
|
208
|
+
deviceId: string;
|
|
209
|
+
deviceSecret: string;
|
|
210
|
+
}, {
|
|
211
|
+
deviceId: string;
|
|
212
|
+
deviceSecret: string;
|
|
213
|
+
}>;
|
|
214
|
+
}, "strict", z.ZodTypeAny, {
|
|
215
|
+
token: string;
|
|
216
|
+
device: {
|
|
217
|
+
deviceId: string;
|
|
218
|
+
deviceSecret: string;
|
|
219
|
+
};
|
|
220
|
+
}, {
|
|
221
|
+
token: string;
|
|
222
|
+
device: {
|
|
223
|
+
deviceId: string;
|
|
224
|
+
deviceSecret: string;
|
|
225
|
+
};
|
|
226
|
+
}>;
|
|
227
|
+
export type EmailSignInLinkRequest = z.infer<typeof emailSignInLinkRequestSchema>;
|
|
228
|
+
export interface EmailSignInLinkResponse {
|
|
229
|
+
/** The dialog that asked collects the session; the link page never receives one. */
|
|
230
|
+
approved: true;
|
|
231
|
+
}
|
|
232
|
+
export declare const emailSignInLinkResponseSchema: z.ZodType<EmailSignInLinkResponse>;
|
|
233
|
+
/** `POST /auth/signin/password` */
|
|
234
|
+
export declare const passwordSignInRequestSchema: z.ZodObject<{
|
|
235
|
+
deviceName: z.ZodOptional<z.ZodString>;
|
|
236
|
+
deviceFingerprint: z.ZodOptional<z.ZodString>;
|
|
237
|
+
device: z.ZodOptional<z.ZodObject<{
|
|
238
|
+
deviceId: z.ZodString;
|
|
239
|
+
deviceSecret: z.ZodString;
|
|
240
|
+
}, "strip", z.ZodTypeAny, {
|
|
241
|
+
deviceId: string;
|
|
242
|
+
deviceSecret: string;
|
|
243
|
+
}, {
|
|
244
|
+
deviceId: string;
|
|
245
|
+
deviceSecret: string;
|
|
246
|
+
}>>;
|
|
247
|
+
identifier: z.ZodString;
|
|
248
|
+
password: z.ZodString;
|
|
249
|
+
}, "strict", z.ZodTypeAny, {
|
|
250
|
+
identifier: string;
|
|
251
|
+
password: string;
|
|
252
|
+
device?: {
|
|
253
|
+
deviceId: string;
|
|
254
|
+
deviceSecret: string;
|
|
255
|
+
} | undefined;
|
|
256
|
+
deviceName?: string | undefined;
|
|
257
|
+
deviceFingerprint?: string | undefined;
|
|
258
|
+
}, {
|
|
259
|
+
identifier: string;
|
|
260
|
+
password: string;
|
|
261
|
+
device?: {
|
|
262
|
+
deviceId: string;
|
|
263
|
+
deviceSecret: string;
|
|
264
|
+
} | undefined;
|
|
265
|
+
deviceName?: string | undefined;
|
|
266
|
+
deviceFingerprint?: string | undefined;
|
|
267
|
+
}>;
|
|
268
|
+
export type PasswordSignInRequest = z.infer<typeof passwordSignInRequestSchema>;
|
|
269
|
+
/** `POST /auth/signin/second-factor` */
|
|
270
|
+
export declare const secondFactorSignInRequestSchema: z.ZodObject<{
|
|
271
|
+
deviceName: z.ZodOptional<z.ZodString>;
|
|
272
|
+
deviceFingerprint: z.ZodOptional<z.ZodString>;
|
|
273
|
+
device: z.ZodOptional<z.ZodObject<{
|
|
274
|
+
deviceId: z.ZodString;
|
|
275
|
+
deviceSecret: z.ZodString;
|
|
276
|
+
}, "strip", z.ZodTypeAny, {
|
|
277
|
+
deviceId: string;
|
|
278
|
+
deviceSecret: string;
|
|
279
|
+
}, {
|
|
280
|
+
deviceId: string;
|
|
281
|
+
deviceSecret: string;
|
|
282
|
+
}>>;
|
|
283
|
+
challengeId: z.ZodString;
|
|
284
|
+
code: z.ZodString;
|
|
285
|
+
}, "strict", z.ZodTypeAny, {
|
|
286
|
+
code: string;
|
|
287
|
+
challengeId: string;
|
|
288
|
+
device?: {
|
|
289
|
+
deviceId: string;
|
|
290
|
+
deviceSecret: string;
|
|
291
|
+
} | undefined;
|
|
292
|
+
deviceName?: string | undefined;
|
|
293
|
+
deviceFingerprint?: string | undefined;
|
|
294
|
+
}, {
|
|
295
|
+
code: string;
|
|
296
|
+
challengeId: string;
|
|
297
|
+
device?: {
|
|
298
|
+
deviceId: string;
|
|
299
|
+
deviceSecret: string;
|
|
300
|
+
} | undefined;
|
|
301
|
+
deviceName?: string | undefined;
|
|
302
|
+
deviceFingerprint?: string | undefined;
|
|
303
|
+
}>;
|
|
304
|
+
export type SecondFactorSignInRequest = z.infer<typeof secondFactorSignInRequestSchema>;
|
|
305
|
+
/** `POST /auth/signup` — the account, from a username and a confirmed email. */
|
|
306
|
+
export declare const signUpRequestSchema: z.ZodObject<{
|
|
307
|
+
deviceName: z.ZodOptional<z.ZodString>;
|
|
308
|
+
deviceFingerprint: z.ZodOptional<z.ZodString>;
|
|
309
|
+
device: z.ZodOptional<z.ZodObject<{
|
|
310
|
+
deviceId: z.ZodString;
|
|
311
|
+
deviceSecret: z.ZodString;
|
|
312
|
+
}, "strip", z.ZodTypeAny, {
|
|
313
|
+
deviceId: string;
|
|
314
|
+
deviceSecret: string;
|
|
315
|
+
}, {
|
|
316
|
+
deviceId: string;
|
|
317
|
+
deviceSecret: string;
|
|
318
|
+
}>>;
|
|
319
|
+
username: z.ZodString;
|
|
320
|
+
email: z.ZodString;
|
|
321
|
+
/** The ticket `POST /auth/email/verify/confirm` (purpose `signup`) returned. */
|
|
322
|
+
emailTicket: z.ZodString;
|
|
323
|
+
}, "strict", z.ZodTypeAny, {
|
|
324
|
+
email: string;
|
|
325
|
+
username: string;
|
|
326
|
+
emailTicket: string;
|
|
327
|
+
device?: {
|
|
328
|
+
deviceId: string;
|
|
329
|
+
deviceSecret: string;
|
|
330
|
+
} | undefined;
|
|
331
|
+
deviceName?: string | undefined;
|
|
332
|
+
deviceFingerprint?: string | undefined;
|
|
333
|
+
}, {
|
|
334
|
+
email: string;
|
|
335
|
+
username: string;
|
|
336
|
+
emailTicket: string;
|
|
337
|
+
device?: {
|
|
338
|
+
deviceId: string;
|
|
339
|
+
deviceSecret: string;
|
|
340
|
+
} | undefined;
|
|
341
|
+
deviceName?: string | undefined;
|
|
342
|
+
deviceFingerprint?: string | undefined;
|
|
343
|
+
}>;
|
|
344
|
+
export type SignUpRequest = z.infer<typeof signUpRequestSchema>;
|
|
345
|
+
/** A first factor passed and the account has an authenticator: no session yet. */
|
|
346
|
+
export interface SecondFactorRequired {
|
|
347
|
+
secondFactorRequired: true;
|
|
348
|
+
/** One use, bound to the account and the device that passed the first factor. */
|
|
349
|
+
challengeId: string;
|
|
350
|
+
/** Unix milliseconds. */
|
|
351
|
+
expiresAt: number;
|
|
352
|
+
}
|
|
353
|
+
export declare const secondFactorRequiredSchema: z.ZodType<SecondFactorRequired>;
|
|
354
|
+
/** The dialog's link has not been opened (in the right browser) yet. */
|
|
355
|
+
export interface EmailSignInPending {
|
|
356
|
+
status: 'pending';
|
|
357
|
+
expiresAt: number;
|
|
358
|
+
}
|
|
359
|
+
export declare const emailSignInPendingSchema: z.ZodType<EmailSignInPending>;
|
|
360
|
+
/** What a first factor answers: a session, or the second-factor step. */
|
|
361
|
+
export type SignInStepResult = LoginResult | SecondFactorRequired;
|
|
362
|
+
/** Narrow a {@link SignInStepResult}. */
|
|
363
|
+
export declare function isSecondFactorRequired(result: SignInStepResult | EmailSignInPending): result is SecondFactorRequired;
|
|
364
|
+
/**
|
|
365
|
+
* What a re-verification email code confirms. The code is bound to it: a code
|
|
366
|
+
* asked for one change never authorises another, and the email names it.
|
|
367
|
+
*/
|
|
368
|
+
export declare const REAUTH_ACTIONS: readonly ["change_password", "totp", "link_commons", "delete_account"];
|
|
369
|
+
export type ReauthAction = (typeof REAUTH_ACTIONS)[number];
|
|
370
|
+
/** `POST /users/me/reauth/email` */
|
|
371
|
+
export declare const reauthEmailStartRequestSchema: z.ZodObject<{
|
|
372
|
+
action: z.ZodEnum<["change_password", "totp", "link_commons", "delete_account"]>;
|
|
373
|
+
}, "strict", z.ZodTypeAny, {
|
|
374
|
+
action: "change_password" | "totp" | "link_commons" | "delete_account";
|
|
375
|
+
}, {
|
|
376
|
+
action: "change_password" | "totp" | "link_commons" | "delete_account";
|
|
377
|
+
}>;
|
|
378
|
+
export type ReauthEmailStartRequest = z.infer<typeof reauthEmailStartRequestSchema>;
|
|
379
|
+
/**
|
|
380
|
+
* A fresh proof that the person, not only their session, is asking: the
|
|
381
|
+
* current password, or a code just sent to the account's email
|
|
382
|
+
* (`POST /users/me/reauth/email`) — plus the authenticator code when the
|
|
383
|
+
* account has one. Carried inside the request it authorises.
|
|
384
|
+
*/
|
|
385
|
+
export declare const reauthProofSchema: z.ZodEffects<z.ZodObject<{
|
|
386
|
+
password: z.ZodOptional<z.ZodString>;
|
|
387
|
+
emailCode: z.ZodOptional<z.ZodObject<{
|
|
388
|
+
verificationId: z.ZodString;
|
|
389
|
+
code: z.ZodString;
|
|
390
|
+
}, "strict", z.ZodTypeAny, {
|
|
391
|
+
code: string;
|
|
392
|
+
verificationId: string;
|
|
393
|
+
}, {
|
|
394
|
+
code: string;
|
|
395
|
+
verificationId: string;
|
|
396
|
+
}>>;
|
|
397
|
+
/** Required when the account has an authenticator: its code or a backup code. */
|
|
398
|
+
totpCode: z.ZodOptional<z.ZodString>;
|
|
399
|
+
}, "strict", z.ZodTypeAny, {
|
|
400
|
+
password?: string | undefined;
|
|
401
|
+
emailCode?: {
|
|
402
|
+
code: string;
|
|
403
|
+
verificationId: string;
|
|
404
|
+
} | undefined;
|
|
405
|
+
totpCode?: string | undefined;
|
|
406
|
+
}, {
|
|
407
|
+
password?: string | undefined;
|
|
408
|
+
emailCode?: {
|
|
409
|
+
code: string;
|
|
410
|
+
verificationId: string;
|
|
411
|
+
} | undefined;
|
|
412
|
+
totpCode?: string | undefined;
|
|
413
|
+
}>, {
|
|
414
|
+
password?: string | undefined;
|
|
415
|
+
emailCode?: {
|
|
416
|
+
code: string;
|
|
417
|
+
verificationId: string;
|
|
418
|
+
} | undefined;
|
|
419
|
+
totpCode?: string | undefined;
|
|
420
|
+
}, {
|
|
421
|
+
password?: string | undefined;
|
|
422
|
+
emailCode?: {
|
|
423
|
+
code: string;
|
|
424
|
+
verificationId: string;
|
|
425
|
+
} | undefined;
|
|
426
|
+
totpCode?: string | undefined;
|
|
427
|
+
}>;
|
|
428
|
+
export type ReauthProof = z.infer<typeof reauthProofSchema>;
|
|
429
|
+
/** A proof by email code only (+ TOTP): deleting an account, linking Commons. */
|
|
430
|
+
export declare const emailReauthProofSchema: z.ZodObject<{
|
|
431
|
+
emailCode: z.ZodObject<{
|
|
432
|
+
verificationId: z.ZodString;
|
|
433
|
+
code: z.ZodString;
|
|
434
|
+
}, "strict", z.ZodTypeAny, {
|
|
435
|
+
code: string;
|
|
436
|
+
verificationId: string;
|
|
437
|
+
}, {
|
|
438
|
+
code: string;
|
|
439
|
+
verificationId: string;
|
|
440
|
+
}>;
|
|
441
|
+
totpCode: z.ZodOptional<z.ZodString>;
|
|
442
|
+
}, "strict", z.ZodTypeAny, {
|
|
443
|
+
emailCode: {
|
|
444
|
+
code: string;
|
|
445
|
+
verificationId: string;
|
|
446
|
+
};
|
|
447
|
+
totpCode?: string | undefined;
|
|
448
|
+
}, {
|
|
449
|
+
emailCode: {
|
|
450
|
+
code: string;
|
|
451
|
+
verificationId: string;
|
|
452
|
+
};
|
|
453
|
+
totpCode?: string | undefined;
|
|
454
|
+
}>;
|
|
455
|
+
export type EmailReauthProof = z.infer<typeof emailReauthProofSchema>;
|
|
456
|
+
/** `PUT /users/me/password` — set or change the password. */
|
|
457
|
+
export declare const passwordSetRequestSchema: z.ZodObject<{
|
|
458
|
+
newPassword: z.ZodString;
|
|
459
|
+
reauth: z.ZodEffects<z.ZodObject<{
|
|
460
|
+
password: z.ZodOptional<z.ZodString>;
|
|
461
|
+
emailCode: z.ZodOptional<z.ZodObject<{
|
|
462
|
+
verificationId: z.ZodString;
|
|
463
|
+
code: z.ZodString;
|
|
464
|
+
}, "strict", z.ZodTypeAny, {
|
|
465
|
+
code: string;
|
|
466
|
+
verificationId: string;
|
|
467
|
+
}, {
|
|
468
|
+
code: string;
|
|
469
|
+
verificationId: string;
|
|
470
|
+
}>>;
|
|
471
|
+
/** Required when the account has an authenticator: its code or a backup code. */
|
|
472
|
+
totpCode: z.ZodOptional<z.ZodString>;
|
|
473
|
+
}, "strict", z.ZodTypeAny, {
|
|
474
|
+
password?: string | undefined;
|
|
475
|
+
emailCode?: {
|
|
476
|
+
code: string;
|
|
477
|
+
verificationId: string;
|
|
478
|
+
} | undefined;
|
|
479
|
+
totpCode?: string | undefined;
|
|
480
|
+
}, {
|
|
481
|
+
password?: string | undefined;
|
|
482
|
+
emailCode?: {
|
|
483
|
+
code: string;
|
|
484
|
+
verificationId: string;
|
|
485
|
+
} | undefined;
|
|
486
|
+
totpCode?: string | undefined;
|
|
487
|
+
}>, {
|
|
488
|
+
password?: string | undefined;
|
|
489
|
+
emailCode?: {
|
|
490
|
+
code: string;
|
|
491
|
+
verificationId: string;
|
|
492
|
+
} | undefined;
|
|
493
|
+
totpCode?: string | undefined;
|
|
494
|
+
}, {
|
|
495
|
+
password?: string | undefined;
|
|
496
|
+
emailCode?: {
|
|
497
|
+
code: string;
|
|
498
|
+
verificationId: string;
|
|
499
|
+
} | undefined;
|
|
500
|
+
totpCode?: string | undefined;
|
|
501
|
+
}>;
|
|
502
|
+
/** Sign every other session of the account out. */
|
|
503
|
+
revokeOtherSessions: z.ZodOptional<z.ZodBoolean>;
|
|
504
|
+
}, "strict", z.ZodTypeAny, {
|
|
505
|
+
reauth: {
|
|
506
|
+
password?: string | undefined;
|
|
507
|
+
emailCode?: {
|
|
508
|
+
code: string;
|
|
509
|
+
verificationId: string;
|
|
510
|
+
} | undefined;
|
|
511
|
+
totpCode?: string | undefined;
|
|
512
|
+
};
|
|
513
|
+
newPassword: string;
|
|
514
|
+
revokeOtherSessions?: boolean | undefined;
|
|
515
|
+
}, {
|
|
516
|
+
reauth: {
|
|
517
|
+
password?: string | undefined;
|
|
518
|
+
emailCode?: {
|
|
519
|
+
code: string;
|
|
520
|
+
verificationId: string;
|
|
521
|
+
} | undefined;
|
|
522
|
+
totpCode?: string | undefined;
|
|
523
|
+
};
|
|
524
|
+
newPassword: string;
|
|
525
|
+
revokeOtherSessions?: boolean | undefined;
|
|
526
|
+
}>;
|
|
527
|
+
export type PasswordSetRequest = z.infer<typeof passwordSetRequestSchema>;
|
|
528
|
+
/** `GET /users/me/sign-in-methods` */
|
|
529
|
+
export interface SignInMethods {
|
|
530
|
+
hasEmail: boolean;
|
|
531
|
+
hasPassword: boolean;
|
|
532
|
+
totpEnabled: boolean;
|
|
533
|
+
/** Unused backup codes; 0 without an authenticator. */
|
|
534
|
+
backupCodesRemaining: number;
|
|
535
|
+
}
|
|
536
|
+
export declare const signInMethodsSchema: z.ZodType<SignInMethods>;
|
|
537
|
+
/** `POST /users/me/totp/enroll` — a new secret, not active until confirmed. */
|
|
538
|
+
export interface TotpEnrollResponse {
|
|
539
|
+
/** Base32, for typing into an authenticator by hand. */
|
|
540
|
+
secret: string;
|
|
541
|
+
/** `otpauth://totp/…`, for the QR. */
|
|
542
|
+
otpauthUri: string;
|
|
543
|
+
}
|
|
544
|
+
export declare const totpEnrollResponseSchema: z.ZodType<TotpEnrollResponse>;
|
|
545
|
+
/** `POST /users/me/totp/confirm` — the first code from the authenticator turns it on. */
|
|
546
|
+
export declare const totpConfirmRequestSchema: z.ZodObject<{
|
|
547
|
+
code: z.ZodString;
|
|
548
|
+
reauth: z.ZodEffects<z.ZodObject<{
|
|
549
|
+
password: z.ZodOptional<z.ZodString>;
|
|
550
|
+
emailCode: z.ZodOptional<z.ZodObject<{
|
|
551
|
+
verificationId: z.ZodString;
|
|
552
|
+
code: z.ZodString;
|
|
553
|
+
}, "strict", z.ZodTypeAny, {
|
|
554
|
+
code: string;
|
|
555
|
+
verificationId: string;
|
|
556
|
+
}, {
|
|
557
|
+
code: string;
|
|
558
|
+
verificationId: string;
|
|
559
|
+
}>>;
|
|
560
|
+
/** Required when the account has an authenticator: its code or a backup code. */
|
|
561
|
+
totpCode: z.ZodOptional<z.ZodString>;
|
|
562
|
+
}, "strict", z.ZodTypeAny, {
|
|
563
|
+
password?: string | undefined;
|
|
564
|
+
emailCode?: {
|
|
565
|
+
code: string;
|
|
566
|
+
verificationId: string;
|
|
567
|
+
} | undefined;
|
|
568
|
+
totpCode?: string | undefined;
|
|
569
|
+
}, {
|
|
570
|
+
password?: string | undefined;
|
|
571
|
+
emailCode?: {
|
|
572
|
+
code: string;
|
|
573
|
+
verificationId: string;
|
|
574
|
+
} | undefined;
|
|
575
|
+
totpCode?: string | undefined;
|
|
576
|
+
}>, {
|
|
577
|
+
password?: string | undefined;
|
|
578
|
+
emailCode?: {
|
|
579
|
+
code: string;
|
|
580
|
+
verificationId: string;
|
|
581
|
+
} | undefined;
|
|
582
|
+
totpCode?: string | undefined;
|
|
583
|
+
}, {
|
|
584
|
+
password?: string | undefined;
|
|
585
|
+
emailCode?: {
|
|
586
|
+
code: string;
|
|
587
|
+
verificationId: string;
|
|
588
|
+
} | undefined;
|
|
589
|
+
totpCode?: string | undefined;
|
|
590
|
+
}>;
|
|
591
|
+
}, "strict", z.ZodTypeAny, {
|
|
592
|
+
reauth: {
|
|
593
|
+
password?: string | undefined;
|
|
594
|
+
emailCode?: {
|
|
595
|
+
code: string;
|
|
596
|
+
verificationId: string;
|
|
597
|
+
} | undefined;
|
|
598
|
+
totpCode?: string | undefined;
|
|
599
|
+
};
|
|
600
|
+
code: string;
|
|
601
|
+
}, {
|
|
602
|
+
reauth: {
|
|
603
|
+
password?: string | undefined;
|
|
604
|
+
emailCode?: {
|
|
605
|
+
code: string;
|
|
606
|
+
verificationId: string;
|
|
607
|
+
} | undefined;
|
|
608
|
+
totpCode?: string | undefined;
|
|
609
|
+
};
|
|
610
|
+
code: string;
|
|
611
|
+
}>;
|
|
612
|
+
export type TotpConfirmRequest = z.infer<typeof totpConfirmRequestSchema>;
|
|
613
|
+
/** `POST /users/me/totp/disable` and `POST /users/me/totp/backup-codes` */
|
|
614
|
+
export declare const totpReauthRequestSchema: z.ZodObject<{
|
|
615
|
+
reauth: z.ZodEffects<z.ZodObject<{
|
|
616
|
+
password: z.ZodOptional<z.ZodString>;
|
|
617
|
+
emailCode: z.ZodOptional<z.ZodObject<{
|
|
618
|
+
verificationId: z.ZodString;
|
|
619
|
+
code: z.ZodString;
|
|
620
|
+
}, "strict", z.ZodTypeAny, {
|
|
621
|
+
code: string;
|
|
622
|
+
verificationId: string;
|
|
623
|
+
}, {
|
|
624
|
+
code: string;
|
|
625
|
+
verificationId: string;
|
|
626
|
+
}>>;
|
|
627
|
+
/** Required when the account has an authenticator: its code or a backup code. */
|
|
628
|
+
totpCode: z.ZodOptional<z.ZodString>;
|
|
629
|
+
}, "strict", z.ZodTypeAny, {
|
|
630
|
+
password?: string | undefined;
|
|
631
|
+
emailCode?: {
|
|
632
|
+
code: string;
|
|
633
|
+
verificationId: string;
|
|
634
|
+
} | undefined;
|
|
635
|
+
totpCode?: string | undefined;
|
|
636
|
+
}, {
|
|
637
|
+
password?: string | undefined;
|
|
638
|
+
emailCode?: {
|
|
639
|
+
code: string;
|
|
640
|
+
verificationId: string;
|
|
641
|
+
} | undefined;
|
|
642
|
+
totpCode?: string | undefined;
|
|
643
|
+
}>, {
|
|
644
|
+
password?: string | undefined;
|
|
645
|
+
emailCode?: {
|
|
646
|
+
code: string;
|
|
647
|
+
verificationId: string;
|
|
648
|
+
} | undefined;
|
|
649
|
+
totpCode?: string | undefined;
|
|
650
|
+
}, {
|
|
651
|
+
password?: string | undefined;
|
|
652
|
+
emailCode?: {
|
|
653
|
+
code: string;
|
|
654
|
+
verificationId: string;
|
|
655
|
+
} | undefined;
|
|
656
|
+
totpCode?: string | undefined;
|
|
657
|
+
}>;
|
|
658
|
+
}, "strict", z.ZodTypeAny, {
|
|
659
|
+
reauth: {
|
|
660
|
+
password?: string | undefined;
|
|
661
|
+
emailCode?: {
|
|
662
|
+
code: string;
|
|
663
|
+
verificationId: string;
|
|
664
|
+
} | undefined;
|
|
665
|
+
totpCode?: string | undefined;
|
|
666
|
+
};
|
|
667
|
+
}, {
|
|
668
|
+
reauth: {
|
|
669
|
+
password?: string | undefined;
|
|
670
|
+
emailCode?: {
|
|
671
|
+
code: string;
|
|
672
|
+
verificationId: string;
|
|
673
|
+
} | undefined;
|
|
674
|
+
totpCode?: string | undefined;
|
|
675
|
+
};
|
|
676
|
+
}>;
|
|
677
|
+
export type TotpReauthRequest = z.infer<typeof totpReauthRequestSchema>;
|
|
678
|
+
/** Shown once; each works one time. */
|
|
679
|
+
export interface TotpBackupCodesResponse {
|
|
680
|
+
backupCodes: string[];
|
|
681
|
+
}
|
|
682
|
+
export declare const totpBackupCodesResponseSchema: z.ZodType<TotpBackupCodesResponse>;
|
|
683
|
+
/**
|
|
684
|
+
* Stable error codes (`error.code` in the API error body). Clients map these
|
|
685
|
+
* through their localization, never the English message.
|
|
686
|
+
*/
|
|
687
|
+
export declare const SIGN_IN_ERROR_CODES: {
|
|
688
|
+
/** Wrong identifier or password — never says which. */
|
|
689
|
+
readonly invalidCredentials: "SIGNIN_INVALID_CREDENTIALS";
|
|
690
|
+
/** The request is unknown, expired, spent, or its secret is wrong. */
|
|
691
|
+
readonly requestInvalid: "SIGNIN_REQUEST_INVALID";
|
|
692
|
+
/** The link is unknown, expired or already used. */
|
|
693
|
+
readonly linkInvalid: "SIGNIN_LINK_INVALID";
|
|
694
|
+
/** The link was opened in another browser: type the code in the app instead. */
|
|
695
|
+
readonly linkOtherDevice: "SIGNIN_LINK_OTHER_DEVICE";
|
|
696
|
+
/** The second-factor challenge or its code is wrong, expired or spent. */
|
|
697
|
+
readonly secondFactorInvalid: "SECOND_FACTOR_INVALID";
|
|
698
|
+
/** Too many failures for this account: wait and try again. */
|
|
699
|
+
readonly locked: "SIGNIN_LOCKED";
|
|
700
|
+
/** The step needs a fresh proof (`reauth`). */
|
|
701
|
+
readonly reauthRequired: "REAUTH_REQUIRED";
|
|
702
|
+
/** The fresh proof was wrong. */
|
|
703
|
+
readonly reauthInvalid: "REAUTH_INVALID";
|
|
704
|
+
/** The account has an authenticator: the proof must carry its code. */
|
|
705
|
+
readonly totpRequired: "TOTP_REQUIRED";
|
|
706
|
+
/** Enrolling or confirming an authenticator that is already on. */
|
|
707
|
+
readonly totpAlreadyEnabled: "TOTP_ALREADY_ENABLED";
|
|
708
|
+
/** Disabling, confirming or regenerating codes with no authenticator (or no pending one). */
|
|
709
|
+
readonly totpNotEnabled: "TOTP_NOT_ENABLED";
|
|
710
|
+
/** The code the authenticator showed at enrolment is wrong. */
|
|
711
|
+
readonly totpCodeInvalid: "TOTP_CODE_INVALID";
|
|
712
|
+
/** Only official Oxy apps and auth.oxy.so may sign people in here. */
|
|
713
|
+
readonly originNotAllowed: "SIGNIN_ORIGIN_NOT_ALLOWED";
|
|
714
|
+
/** The username is taken. */
|
|
715
|
+
readonly usernameTaken: "USERNAME_TAKEN";
|
|
716
|
+
};
|
|
717
|
+
export type SignInErrorCode = (typeof SIGN_IN_ERROR_CODES)[keyof typeof SIGN_IN_ERROR_CODES];
|