@alore/auth-react-sdk 1.0.0-alpha
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/LICENSE +504 -0
- package/dist/AloreAuth.d.ts +328 -0
- package/dist/AloreAuth.js +509 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
export declare function hashUserInfo(userInfo: string): string;
|
|
2
|
+
type KeyDerivationFunction = 'argon2d' | 'pbkdf2';
|
|
3
|
+
export declare function generateSecureHash(password: string, salt: string, keyDerivationFunction?: KeyDerivationFunction): Promise<string>;
|
|
4
|
+
export interface AloreAuthConfiguration {
|
|
5
|
+
endpoint?: string;
|
|
6
|
+
emailTemplate?: string;
|
|
7
|
+
}
|
|
8
|
+
type FetchWithProgressiveBackoffConfig = {
|
|
9
|
+
maxAttempts?: number;
|
|
10
|
+
initialDelay?: number;
|
|
11
|
+
};
|
|
12
|
+
type SessionUser = {
|
|
13
|
+
createdAt: string;
|
|
14
|
+
device: string;
|
|
15
|
+
deviceCreatedAt: string;
|
|
16
|
+
email: string;
|
|
17
|
+
id: string;
|
|
18
|
+
lastLogin: string | null;
|
|
19
|
+
lastTransaction: string | null;
|
|
20
|
+
nickname: string;
|
|
21
|
+
status: string;
|
|
22
|
+
accessToken: string;
|
|
23
|
+
refreshToken: string;
|
|
24
|
+
};
|
|
25
|
+
export type TwoFactorAuth = {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string | null;
|
|
28
|
+
twoFaTypeId: number;
|
|
29
|
+
};
|
|
30
|
+
interface ForgeData {
|
|
31
|
+
tokenAddress: string;
|
|
32
|
+
name: string;
|
|
33
|
+
symbol: string;
|
|
34
|
+
contractType: string;
|
|
35
|
+
id: string;
|
|
36
|
+
mintMethod: string;
|
|
37
|
+
maxSupply: number;
|
|
38
|
+
endTime: string;
|
|
39
|
+
contractAddress: string;
|
|
40
|
+
chainId: number;
|
|
41
|
+
}
|
|
42
|
+
interface AuthMachineContext {
|
|
43
|
+
salt?: string;
|
|
44
|
+
error?: string;
|
|
45
|
+
active2fa?: TwoFactorAuth[];
|
|
46
|
+
sessionId?: string;
|
|
47
|
+
registerUser?: {
|
|
48
|
+
email: string;
|
|
49
|
+
nickname: string;
|
|
50
|
+
salt?: string;
|
|
51
|
+
};
|
|
52
|
+
forgeData?: ForgeData;
|
|
53
|
+
googleOtpCode?: string;
|
|
54
|
+
googleUser?: {
|
|
55
|
+
email: string;
|
|
56
|
+
nickname: string;
|
|
57
|
+
};
|
|
58
|
+
sessionUser?: SessionUser;
|
|
59
|
+
CCRPublicKey?: {
|
|
60
|
+
publicKey: PublicKeyCredentialCreationOptions;
|
|
61
|
+
};
|
|
62
|
+
RCRPublicKey?: {
|
|
63
|
+
publicKey: PublicKeyCredentialRequestOptions;
|
|
64
|
+
};
|
|
65
|
+
credentialEmail?: string;
|
|
66
|
+
}
|
|
67
|
+
export declare class AloreAuth {
|
|
68
|
+
readonly apiKey: string;
|
|
69
|
+
protected readonly endpoint: string;
|
|
70
|
+
protected readonly emailTemplate: string;
|
|
71
|
+
constructor(apiKey: string, options?: AloreAuthConfiguration);
|
|
72
|
+
services: {
|
|
73
|
+
completeRegistration: (context: AuthMachineContext, event: {
|
|
74
|
+
type: 'COMPLETE_REGISTRATION';
|
|
75
|
+
payload: {
|
|
76
|
+
email: string;
|
|
77
|
+
nickname: string;
|
|
78
|
+
passwordHash: string;
|
|
79
|
+
device: string;
|
|
80
|
+
};
|
|
81
|
+
}) => Promise<any>;
|
|
82
|
+
confirmPassword: (context: AuthMachineContext, event: {
|
|
83
|
+
type: 'CONFIRM_PASSWORD';
|
|
84
|
+
payload: {
|
|
85
|
+
email: string;
|
|
86
|
+
passwordHash: string;
|
|
87
|
+
};
|
|
88
|
+
}) => Promise<{
|
|
89
|
+
error?: undefined;
|
|
90
|
+
} | {
|
|
91
|
+
error: string;
|
|
92
|
+
}>;
|
|
93
|
+
sendConfirmationEmail: (context: AuthMachineContext, event: {
|
|
94
|
+
type: 'RESEND_CODE';
|
|
95
|
+
payload: {
|
|
96
|
+
email: string;
|
|
97
|
+
nickname?: string | undefined;
|
|
98
|
+
device?: string | undefined;
|
|
99
|
+
passwordHash?: string | undefined;
|
|
100
|
+
isForgeClaim?: boolean | undefined;
|
|
101
|
+
locale?: string | undefined;
|
|
102
|
+
};
|
|
103
|
+
} | {
|
|
104
|
+
type: 'SEND_REGISTRATION_EMAIL';
|
|
105
|
+
payload: {
|
|
106
|
+
email: string;
|
|
107
|
+
nickname: string;
|
|
108
|
+
isForgeClaim?: boolean;
|
|
109
|
+
locale?: string;
|
|
110
|
+
};
|
|
111
|
+
}) => Promise<{
|
|
112
|
+
salt: any;
|
|
113
|
+
sessionId: any;
|
|
114
|
+
error?: undefined;
|
|
115
|
+
} | {
|
|
116
|
+
error: string;
|
|
117
|
+
salt?: undefined;
|
|
118
|
+
sessionId?: undefined;
|
|
119
|
+
}>;
|
|
120
|
+
retrieveSalt: (context: AuthMachineContext, _event: {
|
|
121
|
+
type: 'SELECT_PASSWORD';
|
|
122
|
+
payload: {
|
|
123
|
+
email: string;
|
|
124
|
+
};
|
|
125
|
+
}) => Promise<{
|
|
126
|
+
salt: string;
|
|
127
|
+
error?: undefined;
|
|
128
|
+
} | {
|
|
129
|
+
error: string;
|
|
130
|
+
salt?: undefined;
|
|
131
|
+
}>;
|
|
132
|
+
sendCode: (context: AuthMachineContext, event: {
|
|
133
|
+
type: 'SEND_CODE';
|
|
134
|
+
payload: {
|
|
135
|
+
email: string;
|
|
136
|
+
};
|
|
137
|
+
}) => Promise<{
|
|
138
|
+
error: string;
|
|
139
|
+
} | {
|
|
140
|
+
error?: undefined;
|
|
141
|
+
}>;
|
|
142
|
+
startRegisterPasskey: (_context: AuthMachineContext, event: {
|
|
143
|
+
type: 'START_PASSKEY_REGISTER';
|
|
144
|
+
payload: {
|
|
145
|
+
device: string;
|
|
146
|
+
email: string;
|
|
147
|
+
nickname?: string;
|
|
148
|
+
};
|
|
149
|
+
}) => Promise<any>;
|
|
150
|
+
finishRegisterPasskey: (context: AuthMachineContext, event: {
|
|
151
|
+
type: 'FINISH_PASSKEY_REGISTER';
|
|
152
|
+
payload: {
|
|
153
|
+
passkeyRegistration: {
|
|
154
|
+
id: string;
|
|
155
|
+
rawId: string;
|
|
156
|
+
response: {
|
|
157
|
+
attestationObject: string;
|
|
158
|
+
clientDataJSON: string;
|
|
159
|
+
};
|
|
160
|
+
type: string;
|
|
161
|
+
};
|
|
162
|
+
email: string;
|
|
163
|
+
nickname: string;
|
|
164
|
+
device: string;
|
|
165
|
+
};
|
|
166
|
+
}) => Promise<any>;
|
|
167
|
+
finishPasskeyAuth: (context: AuthMachineContext, event: {
|
|
168
|
+
type: 'FINISH_PASSKEY_LOGIN';
|
|
169
|
+
payload: {
|
|
170
|
+
passkeyAuth: {
|
|
171
|
+
id: string;
|
|
172
|
+
rawId: string;
|
|
173
|
+
response: {
|
|
174
|
+
authenticatorData: string;
|
|
175
|
+
clientDataJSON: string;
|
|
176
|
+
signature: string;
|
|
177
|
+
userHandle?: string;
|
|
178
|
+
};
|
|
179
|
+
type: string;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
} | {
|
|
183
|
+
type: 'FINISH_PASSKEY_AUTH';
|
|
184
|
+
payload: {
|
|
185
|
+
passkeyAuth: {
|
|
186
|
+
id: string;
|
|
187
|
+
rawId: string;
|
|
188
|
+
response: {
|
|
189
|
+
authenticatorData: string;
|
|
190
|
+
clientDataJSON: string;
|
|
191
|
+
signature: string;
|
|
192
|
+
userHandle?: string;
|
|
193
|
+
};
|
|
194
|
+
type: string;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
}) => Promise<any>;
|
|
198
|
+
startPasskeyAuth: (_: AuthMachineContext, event: {
|
|
199
|
+
type: 'START_PASSKEY_LOGIN';
|
|
200
|
+
payload: {
|
|
201
|
+
email: string;
|
|
202
|
+
};
|
|
203
|
+
}) => Promise<any>;
|
|
204
|
+
verifyLogin: (_: AuthMachineContext, event: {
|
|
205
|
+
type: 'VERIFY_LOGIN';
|
|
206
|
+
payload: {
|
|
207
|
+
email: string;
|
|
208
|
+
device: string;
|
|
209
|
+
passwordHash: string;
|
|
210
|
+
isForgeClaim?: boolean | undefined;
|
|
211
|
+
locale?: string | undefined;
|
|
212
|
+
};
|
|
213
|
+
} | {
|
|
214
|
+
type: 'RESEND_CODE';
|
|
215
|
+
payload: {
|
|
216
|
+
email: string;
|
|
217
|
+
nickname?: string | undefined;
|
|
218
|
+
device?: string | undefined;
|
|
219
|
+
passwordHash?: string | undefined;
|
|
220
|
+
isForgeClaim?: boolean | undefined;
|
|
221
|
+
locale?: string | undefined;
|
|
222
|
+
};
|
|
223
|
+
}) => Promise<any>;
|
|
224
|
+
verify2faCode: (_context: AuthMachineContext, event: {
|
|
225
|
+
type: 'CONFIRM_SW_CODE';
|
|
226
|
+
payload: {
|
|
227
|
+
email: string;
|
|
228
|
+
device: string;
|
|
229
|
+
passwordHash: string;
|
|
230
|
+
otp: string;
|
|
231
|
+
};
|
|
232
|
+
}) => Promise<any>;
|
|
233
|
+
authenticateWebauthn: (context: AuthMachineContext, event: {
|
|
234
|
+
type: 'VERIFY_HW_AUTH';
|
|
235
|
+
payload: {
|
|
236
|
+
email: string;
|
|
237
|
+
device: string;
|
|
238
|
+
passwordHash: string;
|
|
239
|
+
authId: string;
|
|
240
|
+
};
|
|
241
|
+
}) => Promise<any>;
|
|
242
|
+
verifyDeviceCode: (context: AuthMachineContext, event: {
|
|
243
|
+
type: 'CONFIRM_DEVICE_CODE';
|
|
244
|
+
payload: {
|
|
245
|
+
email: string;
|
|
246
|
+
passwordHash: string;
|
|
247
|
+
device: string;
|
|
248
|
+
secureCode: string;
|
|
249
|
+
};
|
|
250
|
+
}) => Promise<any>;
|
|
251
|
+
verifyEmail: (context: AuthMachineContext, event: {
|
|
252
|
+
type: 'VERIFY_EMAIL';
|
|
253
|
+
payload: {
|
|
254
|
+
secureCode: string;
|
|
255
|
+
};
|
|
256
|
+
}) => Promise<{}>;
|
|
257
|
+
verifyEmail2fa: (context: AuthMachineContext, event: {
|
|
258
|
+
type: 'VERIFY_EMAIL_2FA';
|
|
259
|
+
payload: {
|
|
260
|
+
email: string;
|
|
261
|
+
secureCode: string;
|
|
262
|
+
passwordHash: string;
|
|
263
|
+
};
|
|
264
|
+
}) => Promise<any>;
|
|
265
|
+
verifyEmailEligibility: (_: AuthMachineContext, event: {
|
|
266
|
+
type: 'VERIFY_EMAIL_ELIGIBILITY';
|
|
267
|
+
email: string;
|
|
268
|
+
isForgeClaim?: boolean | undefined;
|
|
269
|
+
locale?: string | undefined;
|
|
270
|
+
}) => Promise<any>;
|
|
271
|
+
verifyClaimNftEmail2fa: (context: AuthMachineContext, event: {
|
|
272
|
+
type: 'VERIFY_CLAIM_NFT_EMAIL_2FA';
|
|
273
|
+
payload: {
|
|
274
|
+
email: string;
|
|
275
|
+
emailCode: string;
|
|
276
|
+
};
|
|
277
|
+
}) => Promise<any>;
|
|
278
|
+
fetchForgeData: (_: AuthMachineContext, event: {
|
|
279
|
+
type: 'INITIALIZE';
|
|
280
|
+
forgeId?: string | null | undefined;
|
|
281
|
+
}) => Promise<ForgeData>;
|
|
282
|
+
googleLogin: (_: AuthMachineContext, event: {
|
|
283
|
+
type: 'GOOGLE_LOGIN';
|
|
284
|
+
googleToken: string;
|
|
285
|
+
}) => Promise<{
|
|
286
|
+
googleOtpCode: any;
|
|
287
|
+
salt: any;
|
|
288
|
+
googleUser: {
|
|
289
|
+
email: any;
|
|
290
|
+
nickname: any;
|
|
291
|
+
salt: any;
|
|
292
|
+
};
|
|
293
|
+
sessionId: any;
|
|
294
|
+
isNewUser?: undefined;
|
|
295
|
+
registerUser?: undefined;
|
|
296
|
+
} | {
|
|
297
|
+
isNewUser: boolean;
|
|
298
|
+
registerUser: {
|
|
299
|
+
email: any;
|
|
300
|
+
nickname: any;
|
|
301
|
+
salt: any;
|
|
302
|
+
};
|
|
303
|
+
googleOtpCode?: undefined;
|
|
304
|
+
salt?: undefined;
|
|
305
|
+
googleUser?: undefined;
|
|
306
|
+
sessionId?: undefined;
|
|
307
|
+
} | {
|
|
308
|
+
googleOtpCode?: undefined;
|
|
309
|
+
salt?: undefined;
|
|
310
|
+
googleUser?: undefined;
|
|
311
|
+
sessionId?: undefined;
|
|
312
|
+
isNewUser?: undefined;
|
|
313
|
+
registerUser?: undefined;
|
|
314
|
+
}>;
|
|
315
|
+
verifyGoogleLogin: (context: AuthMachineContext, event: {
|
|
316
|
+
type: 'COMPLETE_GOOGLE_SIGN_IN';
|
|
317
|
+
payload: {
|
|
318
|
+
email: string;
|
|
319
|
+
passwordHash: string;
|
|
320
|
+
otp: string;
|
|
321
|
+
};
|
|
322
|
+
}) => Promise<any>;
|
|
323
|
+
};
|
|
324
|
+
private delay;
|
|
325
|
+
fetchWithProgressiveBackoff(url: RequestInfo | URL, options?: RequestInit, config?: FetchWithProgressiveBackoffConfig): Promise<Response>;
|
|
326
|
+
private verifyBackendStatus;
|
|
327
|
+
}
|
|
328
|
+
export {};
|