@redzone/taunt-logins 0.0.3 → 0.0.5

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.
@@ -0,0 +1,403 @@
1
+ import { AxiosResponse, AxiosRequestConfig, Method } from 'axios';
2
+ import * as magic_sdk from 'magic-sdk';
3
+ import { OAuthRedirectResult, OAuthRedirectError } from '@magic-ext/oauth2';
4
+ import { BaseProvider } from '@metamask/providers';
5
+
6
+ declare class ErrorResponse {
7
+ message: string;
8
+ summary: string;
9
+ explanation: string;
10
+ status: number;
11
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
12
+ }
13
+ declare class BadRequestError implements ErrorResponse {
14
+ message: string;
15
+ summary: string;
16
+ explanation: string;
17
+ status: number;
18
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
19
+ }
20
+ declare class UnauthorizedError implements ErrorResponse {
21
+ message: string;
22
+ summary: string;
23
+ explanation: string;
24
+ status: number;
25
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
26
+ }
27
+ declare class PaymentRequiredError implements ErrorResponse {
28
+ message: string;
29
+ summary: string;
30
+ explanation: string;
31
+ status: number;
32
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
33
+ }
34
+ declare class ForbiddenError implements ErrorResponse {
35
+ message: string;
36
+ summary: string;
37
+ explanation: string;
38
+ status: number;
39
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
40
+ }
41
+ declare class NotFoundError implements ErrorResponse {
42
+ message: string;
43
+ summary: string;
44
+ explanation: string;
45
+ status: number;
46
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
47
+ }
48
+ declare class MethodNotAllowedError implements ErrorResponse {
49
+ message: string;
50
+ summary: string;
51
+ explanation: string;
52
+ status: number;
53
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
54
+ }
55
+ declare class NotAcceptableError implements ErrorResponse {
56
+ message: string;
57
+ summary: string;
58
+ explanation: string;
59
+ status: number;
60
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
61
+ }
62
+ declare class ProxyAuthenticationRequiredError implements ErrorResponse {
63
+ message: string;
64
+ summary: string;
65
+ explanation: string;
66
+ status: number;
67
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
68
+ }
69
+ declare class RequestTimeoutError implements ErrorResponse {
70
+ message: string;
71
+ summary: string;
72
+ explanation: string;
73
+ status: number;
74
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
75
+ }
76
+ declare class ConflictError implements ErrorResponse {
77
+ message: string;
78
+ summary: string;
79
+ explanation: string;
80
+ status: number;
81
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
82
+ }
83
+ declare class GoneError implements ErrorResponse {
84
+ message: string;
85
+ summary: string;
86
+ explanation: string;
87
+ status: number;
88
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
89
+ }
90
+ declare class LengthRequiredError implements ErrorResponse {
91
+ message: string;
92
+ summary: string;
93
+ explanation: string;
94
+ status: number;
95
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
96
+ }
97
+ declare class PreconditionFailedError implements ErrorResponse {
98
+ message: string;
99
+ summary: string;
100
+ explanation: string;
101
+ status: number;
102
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
103
+ }
104
+ declare class RequestEntityTooLargeError implements ErrorResponse {
105
+ message: string;
106
+ summary: string;
107
+ explanation: string;
108
+ status: number;
109
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
110
+ }
111
+ declare class RequestUriTooLongError implements ErrorResponse {
112
+ message: string;
113
+ summary: string;
114
+ explanation: string;
115
+ status: number;
116
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
117
+ }
118
+ declare class UnsupportedMediaTypeError implements ErrorResponse {
119
+ message: string;
120
+ summary: string;
121
+ explanation: string;
122
+ status: number;
123
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
124
+ }
125
+ declare class RequestedRangeNotSatisfiableError implements ErrorResponse {
126
+ message: string;
127
+ summary: string;
128
+ explanation: string;
129
+ status: number;
130
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
131
+ }
132
+ declare class ExpectationFailedError implements ErrorResponse {
133
+ message: string;
134
+ summary: string;
135
+ explanation: string;
136
+ status: number;
137
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
138
+ }
139
+ declare class ImATeapotError implements ErrorResponse {
140
+ message: string;
141
+ summary: string;
142
+ explanation: string;
143
+ status: number;
144
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
145
+ }
146
+ declare class UnprocessableEntityError implements ErrorResponse {
147
+ message: string;
148
+ summary: string;
149
+ explanation: string;
150
+ status: number;
151
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
152
+ }
153
+ declare class LockedError implements ErrorResponse {
154
+ message: string;
155
+ summary: string;
156
+ explanation: string;
157
+ status: number;
158
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
159
+ }
160
+ declare class FailedDependencyError implements ErrorResponse {
161
+ message: string;
162
+ summary: string;
163
+ explanation: string;
164
+ status: number;
165
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
166
+ }
167
+ declare class UpgradeRequiredError implements ErrorResponse {
168
+ message: string;
169
+ summary: string;
170
+ explanation: string;
171
+ status: number;
172
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
173
+ }
174
+ declare class PreconditionRequiredError implements ErrorResponse {
175
+ message: string;
176
+ summary: string;
177
+ explanation: string;
178
+ status: number;
179
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
180
+ }
181
+ declare class TooManyRequestsError implements ErrorResponse {
182
+ message: string;
183
+ summary: string;
184
+ explanation: string;
185
+ status: number;
186
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
187
+ }
188
+ declare class RequestHeaderFieldsTooLargeError implements ErrorResponse {
189
+ message: string;
190
+ summary: string;
191
+ explanation: string;
192
+ status: number;
193
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
194
+ }
195
+ declare class InternalServerError implements ErrorResponse {
196
+ message: string;
197
+ summary: string;
198
+ explanation: string;
199
+ status: number;
200
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
201
+ }
202
+ declare class NotImplementedError implements ErrorResponse {
203
+ message: string;
204
+ summary: string;
205
+ explanation: string;
206
+ status: number;
207
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
208
+ }
209
+ declare class BadGatewayError implements ErrorResponse {
210
+ message: string;
211
+ summary: string;
212
+ explanation: string;
213
+ status: number;
214
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
215
+ }
216
+ declare class ServiceUnavailableError implements ErrorResponse {
217
+ message: string;
218
+ summary: string;
219
+ explanation: string;
220
+ status: number;
221
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
222
+ }
223
+ declare class GatewayTimeoutError implements ErrorResponse {
224
+ message: string;
225
+ summary: string;
226
+ explanation: string;
227
+ status: number;
228
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
229
+ }
230
+ declare class HTTPVersionNotSupportedError implements ErrorResponse {
231
+ message: string;
232
+ summary: string;
233
+ explanation: string;
234
+ status: number;
235
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
236
+ }
237
+ declare class VariantAlsoNegotiatesError implements ErrorResponse {
238
+ message: string;
239
+ summary: string;
240
+ explanation: string;
241
+ status: number;
242
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
243
+ }
244
+ declare class InsufficientStorageError implements ErrorResponse {
245
+ message: string;
246
+ summary: string;
247
+ explanation: string;
248
+ status: number;
249
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
250
+ }
251
+ declare class LoopDetectedError implements ErrorResponse {
252
+ message: string;
253
+ summary: string;
254
+ explanation: string;
255
+ status: number;
256
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
257
+ }
258
+ declare class BandwidthLimitExceededError implements ErrorResponse {
259
+ message: string;
260
+ summary: string;
261
+ explanation: string;
262
+ status: number;
263
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
264
+ }
265
+ declare class NotExtendedError implements ErrorResponse {
266
+ message: string;
267
+ summary: string;
268
+ explanation: string;
269
+ status: number;
270
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
271
+ }
272
+ declare class NetworkAuthenticationRequiredError implements ErrorResponse {
273
+ message: string;
274
+ summary: string;
275
+ explanation: string;
276
+ status: number;
277
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
278
+ }
279
+ declare class UnknownError implements ErrorResponse {
280
+ message: string;
281
+ summary: string;
282
+ explanation: string;
283
+ status: number;
284
+ constructor(message: string, summary?: string, explanation?: string, status?: number);
285
+ }
286
+ declare function ErrorFromResponse(response: AxiosResponse): ErrorResponse;
287
+
288
+ type TauntSigProps = {
289
+ walletAddress: string;
290
+ message: string;
291
+ signature: string;
292
+ };
293
+ type TauntExtSigProps = TauntSigProps & {
294
+ extNonce: string;
295
+ };
296
+ type TauntRespType = {
297
+ accessToken: string;
298
+ refreshToken: string;
299
+ isNewUser: string;
300
+ };
301
+ type TauntUser = {
302
+ id: number;
303
+ role: string;
304
+ email: string | undefined;
305
+ ethAddress: string | null;
306
+ avatar: string | null;
307
+ refreshToken: string;
308
+ accessToken: string;
309
+ };
310
+ declare class TauntApi {
311
+ private api;
312
+ private refreshToken;
313
+ private claimrToken;
314
+ constructor(endpoint: string);
315
+ onError: (error: {
316
+ config: AxiosRequestConfig & {
317
+ _retry?: boolean;
318
+ };
319
+ response: AxiosResponse;
320
+ }) => Promise<AxiosResponse<any, any, {}>>;
321
+ stdPGET<T = TauntRespType>(method: Method, url: string, body?: unknown, headers?: {}): Promise<T>;
322
+ post<T = TauntRespType>(url: string, body?: {}, headers?: {}): Promise<T>;
323
+ get<T = TauntRespType>(url: string, headers?: {}): Promise<T>;
324
+ nonceLogin: (walletAddress: string, clientNonce: string) => Promise<string>;
325
+ loginWithMagicDid: (did: string) => Promise<TauntRespType>;
326
+ loginWithWeb3WalletSignature: (props: TauntSigProps) => Promise<TauntRespType>;
327
+ loginExtWithWeb3WalletSignature: (props: TauntExtSigProps) => Promise<TauntRespType>;
328
+ refresh: (refreshToken?: string) => Promise<TauntRespType>;
329
+ logout: () => Promise<void>;
330
+ getClaimrToken: () => Promise<string | null>;
331
+ getLoggedInUser: () => Promise<AxiosResponse<TauntUser, any, {}>>;
332
+ writePlayerEvent(eventName: string, eventData?: unknown, retryIfLoginNeeded?: boolean): Promise<void>;
333
+ }
334
+
335
+ declare function emailOTPWithMagic(magicKey: string, email: string): magic_sdk.PromiEvent<string | null, {
336
+ "email-otp-sent": () => void;
337
+ "login-throttled": () => void;
338
+ "invalid-email-otp": () => void;
339
+ "invalid-mfa-otp": () => void;
340
+ "expired-email-otp": () => void;
341
+ "mfa-sent-handle": () => void;
342
+ "recovery-code-sent-handle": () => void;
343
+ "invalid-recovery-code": () => void;
344
+ "recovery-code-success": () => void;
345
+ "Auth/id-token-created": (idToken: string) => void;
346
+ "Wallet/wallet-info-fetched": () => void;
347
+ "verify-email-otp": (otp: string) => void;
348
+ "verify-mfa-code": (mfa: string) => void;
349
+ "lost-device": () => void;
350
+ "verify-recovery-code": (recoveryCode: string) => void;
351
+ cancel: () => void;
352
+ } & {
353
+ "device-needs-approval": () => void;
354
+ "device-verification-email-sent": () => void;
355
+ "device-verification-link-expired": () => void;
356
+ "device-approved": () => void;
357
+ "device-retry": () => void;
358
+ } & {
359
+ done: (result: string | null) => void;
360
+ error: (reason: any) => void;
361
+ settled: () => void;
362
+ "closed-by-user": () => void;
363
+ }>;
364
+ declare function telegramWithMagic(magicKey: string): magic_sdk.PromiEvent<OAuthRedirectResult | OAuthRedirectError, {
365
+ done: (result: OAuthRedirectResult | OAuthRedirectError) => void;
366
+ error: (reason: any) => void;
367
+ settled: () => void;
368
+ "closed-by-user": () => void;
369
+ }>;
370
+ declare function tauntMagicTelegramLogin(tauntServiceEndpoint: string, magicKey: string, tauntApi?: TauntApi): Promise<{
371
+ accessToken: string;
372
+ refreshToken: string;
373
+ isNewUser: string;
374
+ }>;
375
+ declare function tauntMagicEmailOTPLogin(tauntServiceEndpoint: string, magicKey: string, email: string, tauntApi?: TauntApi): Promise<{
376
+ accessToken: string;
377
+ refreshToken: string;
378
+ isNewUser: string;
379
+ }>;
380
+ declare function tauntMagicDidLogin(tauntServiceEndpoint: string, did: string, tauntApi?: TauntApi): Promise<{
381
+ accessToken: string;
382
+ refreshToken: string;
383
+ isNewUser: string;
384
+ }>;
385
+
386
+ declare global {
387
+ interface Window {
388
+ ethereum?: BaseProvider;
389
+ }
390
+ }
391
+ declare function tauntSignWithMetamask(tauntServiceEndpoint: string, provider?: BaseProvider, tauntApi?: TauntApi): Promise<{
392
+ walletAddress: string;
393
+ message: string;
394
+ signature: string;
395
+ }>;
396
+ declare function tauntMetamaskLogin(tauntServiceEndpoint: string, providerParam?: BaseProvider, tauntApi?: TauntApi): Promise<{
397
+ accessToken: string;
398
+ refreshToken: string;
399
+ isNewUser: string;
400
+ }>;
401
+
402
+ export { BadGatewayError, BadRequestError, BandwidthLimitExceededError, ConflictError, ErrorFromResponse, ErrorResponse, ExpectationFailedError, FailedDependencyError, ForbiddenError, GatewayTimeoutError, GoneError, HTTPVersionNotSupportedError, ImATeapotError, InsufficientStorageError, InternalServerError, LengthRequiredError, LockedError, LoopDetectedError, MethodNotAllowedError, NetworkAuthenticationRequiredError, NotAcceptableError, NotExtendedError, NotFoundError, NotImplementedError, PaymentRequiredError, PreconditionFailedError, PreconditionRequiredError, ProxyAuthenticationRequiredError, RequestEntityTooLargeError, RequestHeaderFieldsTooLargeError, RequestTimeoutError, RequestUriTooLongError, RequestedRangeNotSatisfiableError, ServiceUnavailableError, TauntApi, TooManyRequestsError, UnauthorizedError, UnknownError, UnprocessableEntityError, UnsupportedMediaTypeError, UpgradeRequiredError, VariantAlsoNegotiatesError, emailOTPWithMagic, tauntMagicDidLogin, tauntMagicEmailOTPLogin, tauntMagicTelegramLogin, tauntMetamaskLogin, tauntSignWithMetamask, telegramWithMagic };
403
+ export type { TauntExtSigProps, TauntSigProps, TauntUser };