Repository navigation
Expand file tree
/
Copy pathtypes.ts
More file actions
69 lines (62 loc) · 2.58 KB
/
Copy pathtypes.ts
File metadata and controls
69 lines (62 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { BaseListTypeInfo, KeystoneContext } from '@keystone-6/core/types';
export type AuthGqlNames = {
CreateInitialInput: string;
createInitialItem: string;
authenticateItemWithPassword: string;
ItemAuthenticationWithPasswordResult: string;
ItemAuthenticationWithPasswordSuccess: string;
ItemAuthenticationWithPasswordFailure: string;
sendItemPasswordResetLink: string;
SendItemPasswordResetLinkResult: string;
validateItemPasswordResetToken: string;
ValidateItemPasswordResetTokenResult: string;
redeemItemPasswordResetToken: string;
RedeemItemPasswordResetTokenResult: string;
sendItemMagicAuthLink: string;
SendItemMagicAuthLinkResult: string;
redeemItemMagicAuthToken: string;
RedeemItemMagicAuthTokenResult: string;
RedeemItemMagicAuthTokenSuccess: string;
RedeemItemMagicAuthTokenFailure: string;
};
export type SendTokenFn = (args: {
itemId: string | number | bigint;
identity: string;
token: string;
context: KeystoneContext;
}) => Promise<void> | void;
export type AuthTokenTypeConfig = {
/** Called when a user should be sent the magic signin token they requested */
sendToken: SendTokenFn;
/** How long do tokens stay valid for from time of issue, in minutes **/
tokensValidForMins?: number;
};
export type AuthConfig<ListTypeInfo extends BaseListTypeInfo> = {
/** The key of the list to authenticate users with */
listKey: ListTypeInfo['key'];
/** The path of the field the identity is stored in; must be text-ish */
identityField: ListTypeInfo['fields'];
/** The path of the field the secret is stored in; must be password-ish */
secretField: ListTypeInfo['fields'];
/** The initial user/db seeding functionality */
initFirstItem?: InitFirstItemConfig<ListTypeInfo>;
/** Password reset link functionality */
passwordResetLink?: AuthTokenTypeConfig;
/** "Magic link" functionality */
magicAuthLink?: AuthTokenTypeConfig;
/** Session data population */
sessionData?: string;
};
export type InitFirstItemConfig<ListTypeInfo extends BaseListTypeInfo> = {
/** Array of fields to collect, e.g ['name', 'email', 'password'] */
fields: readonly ListTypeInfo['fields'][];
/** Suppresses the second screen where we ask people to subscribe and follow Keystone */
skipKeystoneWelcome?: boolean;
/** Extra input to add for the create mutation */
itemData?: Partial<ListTypeInfo['inputs']['create']>;
};
export type AuthTokenRedemptionErrorCode = 'FAILURE' | 'TOKEN_EXPIRED' | 'TOKEN_REDEEMED';
export type SecretFieldImpl = {
generateHash: (secret: string) => Promise<string>;
compare: (secret: string, hash: string) => Promise<string>;
};