@redzone/taunt-logins 0.0.12 → 0.0.13

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.
@@ -5,306 +5,228 @@ import * as magic_sdk from 'magic-sdk';
5
5
  import * as _magic_sdk_provider from '@magic-sdk/provider';
6
6
  import { BaseProvider } from '@metamask/providers';
7
7
 
8
- declare class ErrorResponse {
9
- message: string;
8
+ declare class ErrorResponse extends Error {
10
9
  summary: string;
11
10
  explanation: string;
12
11
  status: number;
13
- constructor(message: string, summary?: string, explanation?: string, status?: number);
14
12
  }
15
- declare class BadRequestError implements ErrorResponse {
16
- message: string;
13
+ declare class BadRequestError extends ErrorResponse {
17
14
  summary: string;
18
15
  explanation: string;
19
16
  status: number;
20
- constructor(message: string, summary?: string, explanation?: string, status?: number);
21
17
  }
22
- declare class UnauthorizedError implements ErrorResponse {
23
- message: string;
18
+ declare class UnauthorizedError extends ErrorResponse {
24
19
  summary: string;
25
20
  explanation: string;
26
21
  status: number;
27
- constructor(message: string, summary?: string, explanation?: string, status?: number);
28
22
  }
29
- declare class PaymentRequiredError implements ErrorResponse {
30
- message: string;
23
+ declare class PaymentRequiredError extends ErrorResponse {
31
24
  summary: string;
32
25
  explanation: string;
33
26
  status: number;
34
- constructor(message: string, summary?: string, explanation?: string, status?: number);
35
27
  }
36
- declare class ForbiddenError implements ErrorResponse {
37
- message: string;
28
+ declare class ForbiddenError extends ErrorResponse {
38
29
  summary: string;
39
30
  explanation: string;
40
31
  status: number;
41
- constructor(message: string, summary?: string, explanation?: string, status?: number);
42
32
  }
43
- declare class NotFoundError implements ErrorResponse {
44
- message: string;
33
+ declare class NotFoundError extends ErrorResponse {
45
34
  summary: string;
46
35
  explanation: string;
47
36
  status: number;
48
- constructor(message: string, summary?: string, explanation?: string, status?: number);
49
37
  }
50
- declare class MethodNotAllowedError implements ErrorResponse {
51
- message: string;
38
+ declare class MethodNotAllowedError extends ErrorResponse {
52
39
  summary: string;
53
40
  explanation: string;
54
41
  status: number;
55
- constructor(message: string, summary?: string, explanation?: string, status?: number);
56
42
  }
57
- declare class NotAcceptableError implements ErrorResponse {
58
- message: string;
43
+ declare class NotAcceptableError extends ErrorResponse {
59
44
  summary: string;
60
45
  explanation: string;
61
46
  status: number;
62
- constructor(message: string, summary?: string, explanation?: string, status?: number);
63
47
  }
64
- declare class ProxyAuthenticationRequiredError implements ErrorResponse {
65
- message: string;
48
+ declare class ProxyAuthenticationRequiredError extends ErrorResponse {
66
49
  summary: string;
67
50
  explanation: string;
68
51
  status: number;
69
- constructor(message: string, summary?: string, explanation?: string, status?: number);
70
52
  }
71
- declare class RequestTimeoutError implements ErrorResponse {
72
- message: string;
53
+ declare class RequestTimeoutError extends ErrorResponse {
73
54
  summary: string;
74
55
  explanation: string;
75
56
  status: number;
76
- constructor(message: string, summary?: string, explanation?: string, status?: number);
77
57
  }
78
- declare class ConflictError implements ErrorResponse {
79
- message: string;
58
+ declare class ConflictError extends ErrorResponse {
80
59
  summary: string;
81
60
  explanation: string;
82
61
  status: number;
83
- constructor(message: string, summary?: string, explanation?: string, status?: number);
84
62
  }
85
- declare class GoneError implements ErrorResponse {
86
- message: string;
63
+ declare class GoneError extends ErrorResponse {
87
64
  summary: string;
88
65
  explanation: string;
89
66
  status: number;
90
- constructor(message: string, summary?: string, explanation?: string, status?: number);
91
67
  }
92
- declare class LengthRequiredError implements ErrorResponse {
93
- message: string;
68
+ declare class LengthRequiredError extends ErrorResponse {
94
69
  summary: string;
95
70
  explanation: string;
96
71
  status: number;
97
- constructor(message: string, summary?: string, explanation?: string, status?: number);
98
72
  }
99
- declare class PreconditionFailedError implements ErrorResponse {
100
- message: string;
73
+ declare class PreconditionFailedError extends ErrorResponse {
101
74
  summary: string;
102
75
  explanation: string;
103
76
  status: number;
104
- constructor(message: string, summary?: string, explanation?: string, status?: number);
105
77
  }
106
- declare class RequestEntityTooLargeError implements ErrorResponse {
107
- message: string;
78
+ declare class RequestEntityTooLargeError extends ErrorResponse {
108
79
  summary: string;
109
80
  explanation: string;
110
81
  status: number;
111
- constructor(message: string, summary?: string, explanation?: string, status?: number);
112
82
  }
113
- declare class RequestUriTooLongError implements ErrorResponse {
114
- message: string;
83
+ declare class RequestUriTooLongError extends ErrorResponse {
115
84
  summary: string;
116
85
  explanation: string;
117
86
  status: number;
118
- constructor(message: string, summary?: string, explanation?: string, status?: number);
119
87
  }
120
- declare class UnsupportedMediaTypeError implements ErrorResponse {
121
- message: string;
88
+ declare class UnsupportedMediaTypeError extends ErrorResponse {
122
89
  summary: string;
123
90
  explanation: string;
124
91
  status: number;
125
- constructor(message: string, summary?: string, explanation?: string, status?: number);
126
92
  }
127
- declare class RequestedRangeNotSatisfiableError implements ErrorResponse {
128
- message: string;
93
+ declare class RequestedRangeNotSatisfiableError extends ErrorResponse {
129
94
  summary: string;
130
95
  explanation: string;
131
96
  status: number;
132
- constructor(message: string, summary?: string, explanation?: string, status?: number);
133
97
  }
134
- declare class ExpectationFailedError implements ErrorResponse {
135
- message: string;
98
+ declare class ExpectationFailedError extends ErrorResponse {
136
99
  summary: string;
137
100
  explanation: string;
138
101
  status: number;
139
- constructor(message: string, summary?: string, explanation?: string, status?: number);
140
102
  }
141
- declare class ImATeapotError implements ErrorResponse {
142
- message: string;
103
+ declare class ImATeapotError extends ErrorResponse {
143
104
  summary: string;
144
105
  explanation: string;
145
106
  status: number;
146
- constructor(message: string, summary?: string, explanation?: string, status?: number);
147
107
  }
148
- declare class UnprocessableEntityError implements ErrorResponse {
149
- message: string;
108
+ declare class UnprocessableEntityError extends ErrorResponse {
150
109
  summary: string;
151
110
  explanation: string;
152
111
  status: number;
153
- constructor(message: string, summary?: string, explanation?: string, status?: number);
154
112
  }
155
- declare class LockedError implements ErrorResponse {
156
- message: string;
113
+ declare class LockedError extends ErrorResponse {
157
114
  summary: string;
158
115
  explanation: string;
159
116
  status: number;
160
- constructor(message: string, summary?: string, explanation?: string, status?: number);
161
117
  }
162
- declare class FailedDependencyError implements ErrorResponse {
163
- message: string;
118
+ declare class FailedDependencyError extends ErrorResponse {
164
119
  summary: string;
165
120
  explanation: string;
166
121
  status: number;
167
- constructor(message: string, summary?: string, explanation?: string, status?: number);
168
122
  }
169
- declare class UpgradeRequiredError implements ErrorResponse {
170
- message: string;
123
+ declare class UpgradeRequiredError extends ErrorResponse {
171
124
  summary: string;
172
125
  explanation: string;
173
126
  status: number;
174
- constructor(message: string, summary?: string, explanation?: string, status?: number);
175
127
  }
176
- declare class PreconditionRequiredError implements ErrorResponse {
177
- message: string;
128
+ declare class PreconditionRequiredError extends ErrorResponse {
178
129
  summary: string;
179
130
  explanation: string;
180
131
  status: number;
181
- constructor(message: string, summary?: string, explanation?: string, status?: number);
182
132
  }
183
- declare class TooManyRequestsError implements ErrorResponse {
184
- message: string;
133
+ declare class TooManyRequestsError extends ErrorResponse {
185
134
  summary: string;
186
135
  explanation: string;
187
136
  status: number;
188
- constructor(message: string, summary?: string, explanation?: string, status?: number);
189
137
  }
190
- declare class RequestHeaderFieldsTooLargeError implements ErrorResponse {
191
- message: string;
138
+ declare class RequestHeaderFieldsTooLargeError extends ErrorResponse {
192
139
  summary: string;
193
140
  explanation: string;
194
141
  status: number;
195
- constructor(message: string, summary?: string, explanation?: string, status?: number);
196
142
  }
197
- declare class InternalServerError implements ErrorResponse {
198
- message: string;
143
+ declare class InternalServerError extends ErrorResponse {
199
144
  summary: string;
200
145
  explanation: string;
201
146
  status: number;
202
- constructor(message: string, summary?: string, explanation?: string, status?: number);
203
147
  }
204
- declare class NotImplementedError implements ErrorResponse {
205
- message: string;
148
+ declare class NotImplementedError extends ErrorResponse {
206
149
  summary: string;
207
150
  explanation: string;
208
151
  status: number;
209
- constructor(message: string, summary?: string, explanation?: string, status?: number);
210
152
  }
211
- declare class BadGatewayError implements ErrorResponse {
212
- message: string;
153
+ declare class BadGatewayError extends ErrorResponse {
213
154
  summary: string;
214
155
  explanation: string;
215
156
  status: number;
216
- constructor(message: string, summary?: string, explanation?: string, status?: number);
217
157
  }
218
- declare class ServiceUnavailableError implements ErrorResponse {
219
- message: string;
158
+ declare class ServiceUnavailableError extends ErrorResponse {
220
159
  summary: string;
221
160
  explanation: string;
222
161
  status: number;
223
- constructor(message: string, summary?: string, explanation?: string, status?: number);
224
162
  }
225
- declare class GatewayTimeoutError implements ErrorResponse {
226
- message: string;
163
+ declare class GatewayTimeoutError extends ErrorResponse {
227
164
  summary: string;
228
165
  explanation: string;
229
166
  status: number;
230
- constructor(message: string, summary?: string, explanation?: string, status?: number);
231
167
  }
232
- declare class HTTPVersionNotSupportedError implements ErrorResponse {
233
- message: string;
168
+ declare class HTTPVersionNotSupportedError extends ErrorResponse {
234
169
  summary: string;
235
170
  explanation: string;
236
171
  status: number;
237
- constructor(message: string, summary?: string, explanation?: string, status?: number);
238
172
  }
239
- declare class VariantAlsoNegotiatesError implements ErrorResponse {
240
- message: string;
173
+ declare class VariantAlsoNegotiatesError extends ErrorResponse {
241
174
  summary: string;
242
175
  explanation: string;
243
176
  status: number;
244
- constructor(message: string, summary?: string, explanation?: string, status?: number);
245
177
  }
246
- declare class InsufficientStorageError implements ErrorResponse {
247
- message: string;
178
+ declare class InsufficientStorageError extends ErrorResponse {
248
179
  summary: string;
249
180
  explanation: string;
250
181
  status: number;
251
- constructor(message: string, summary?: string, explanation?: string, status?: number);
252
182
  }
253
- declare class LoopDetectedError implements ErrorResponse {
254
- message: string;
183
+ declare class LoopDetectedError extends ErrorResponse {
255
184
  summary: string;
256
185
  explanation: string;
257
186
  status: number;
258
- constructor(message: string, summary?: string, explanation?: string, status?: number);
259
187
  }
260
- declare class BandwidthLimitExceededError implements ErrorResponse {
261
- message: string;
188
+ declare class BandwidthLimitExceededError extends ErrorResponse {
262
189
  summary: string;
263
190
  explanation: string;
264
191
  status: number;
265
- constructor(message: string, summary?: string, explanation?: string, status?: number);
266
192
  }
267
- declare class NotExtendedError implements ErrorResponse {
268
- message: string;
193
+ declare class NotExtendedError extends ErrorResponse {
269
194
  summary: string;
270
195
  explanation: string;
271
196
  status: number;
272
- constructor(message: string, summary?: string, explanation?: string, status?: number);
273
197
  }
274
- declare class NetworkAuthenticationRequiredError implements ErrorResponse {
275
- message: string;
198
+ declare class NetworkAuthenticationRequiredError extends ErrorResponse {
276
199
  summary: string;
277
200
  explanation: string;
278
201
  status: number;
279
- constructor(message: string, summary?: string, explanation?: string, status?: number);
280
202
  }
281
- declare class UnknownError implements ErrorResponse {
282
- message: string;
203
+ declare class UnknownError extends ErrorResponse {
283
204
  summary: string;
284
205
  explanation: string;
285
206
  status: number;
286
- constructor(message: string, summary?: string, explanation?: string, status?: number);
287
207
  }
288
- declare function ErrorFromResponse(response: AxiosResponse): ErrorResponse;
208
+ declare function ErrorFromResponse(response: AxiosResponse<{
209
+ message?: string;
210
+ }>): ErrorResponse;
289
211
 
290
- type TauntSigProps = {
212
+ interface TauntSigProps {
291
213
  walletAddress: string;
292
214
  message: string;
293
215
  signature: string;
294
- };
216
+ }
295
217
  type TauntExtSigProps = TauntSigProps & {
296
218
  extNonce?: string;
297
219
  };
298
- type TauntAccessDetails = {
220
+ interface TauntAccessDetails {
299
221
  accessToken: string;
300
222
  refreshToken: string;
301
- };
302
- type TauntRespType = {
223
+ }
224
+ interface TauntRespType {
303
225
  accessToken: string;
304
226
  refreshToken: string;
305
227
  isNewUser: string;
306
- };
307
- type TauntUser = {
228
+ }
229
+ interface TauntUser {
308
230
  id: number;
309
231
  role: string;
310
232
  email: string | undefined;
@@ -312,24 +234,27 @@ type TauntUser = {
312
234
  avatar: string | null;
313
235
  refreshToken: string;
314
236
  accessToken: string;
315
- };
316
- type ClaimrCampaignData = {
237
+ }
238
+ interface ClaimrCampaignData {
317
239
  redSkulls: number;
318
240
  numActionsComplete: number;
319
241
  questComplete: boolean;
320
- };
242
+ }
243
+ interface AxiosErrorResponse {
244
+ config: AxiosRequestConfig & {
245
+ _retry?: boolean;
246
+ };
247
+ response: AxiosResponse<{
248
+ message?: string;
249
+ }>;
250
+ }
321
251
  declare class TauntApi {
322
252
  private _axios;
323
253
  private refreshToken;
324
254
  private accessToken;
325
255
  private claimrToken;
326
256
  constructor(endpoint: string);
327
- onError: (error: {
328
- config: AxiosRequestConfig & {
329
- _retry?: boolean;
330
- };
331
- response: AxiosResponse;
332
- }) => Promise<AxiosResponse<any, any, {}>>;
257
+ onError: (error: AxiosErrorResponse) => Promise<AxiosResponse<any, any, {}>>;
333
258
  private _api;
334
259
  setLoginDetails: (props: TauntAccessDetails, checkGet?: boolean) => Promise<{
335
260
  accessToken: string;
@@ -343,13 +268,14 @@ declare class TauntApi {
343
268
  refresh: (refreshToken?: string) => Promise<TauntRespType>;
344
269
  logout: () => Promise<void>;
345
270
  getClaimrToken: () => Promise<string>;
346
- getClaimrData: () => Promise<ClaimrCampaignData>;
271
+ getClaimrSkulls: () => Promise<ClaimrCampaignData>;
272
+ getClaimrReferralCode: () => Promise<string | undefined>;
347
273
  randomTokenString: () => string;
348
274
  withProvider(provider: {
349
275
  getAddress: () => Promise<string | undefined | null>;
350
276
  personalSign: (message: string, address: string) => Promise<string | undefined | null>;
351
277
  }, extNonce?: string): Promise<TauntRespType>;
352
- getLoggedInUser: () => Promise<TauntUser>;
278
+ getLoggedInUser: () => Promise<TauntUser | undefined>;
353
279
  writePlayerEvent(eventName: string, eventData?: unknown, retryIfLoginNeeded?: boolean): Promise<void>;
354
280
  }
355
281
 
@@ -390,27 +316,15 @@ declare function telegramWithMagic(magicKey: string, magic?: MagicType): magic_s
390
316
  settled: () => void;
391
317
  "closed-by-user": () => void;
392
318
  }>;
393
- declare function tauntMagicTelegramLogin(tauntServiceEndpoint: string, magicKey: string, tauntApi?: TauntApi, extNonce?: string): Promise<{
394
- accessToken: string;
395
- refreshToken: string;
396
- isNewUser: string;
397
- }>;
398
- declare function tauntMagicEmailOTPLogin(tauntServiceEndpoint: string, magicKey: string, email: string, tauntApi?: TauntApi, extNonce?: string): Promise<{
399
- accessToken: string;
400
- refreshToken: string;
401
- isNewUser: string;
402
- }>;
319
+ declare function tauntMagicTelegramLogin(tauntServiceEndpoint: string, magicKey: string, tauntApi?: TauntApi, extNonce?: string): Promise<TauntRespType>;
320
+ declare function tauntMagicEmailOTPLogin(tauntServiceEndpoint: string, magicKey: string, email: string, tauntApi?: TauntApi, extNonce?: string): Promise<TauntRespType>;
403
321
 
404
322
  declare global {
405
323
  interface Window {
406
324
  ethereum?: BaseProvider;
407
325
  }
408
326
  }
409
- declare function tauntMetamaskLogin(tauntServiceEndpoint: string, provider?: BaseProvider, tauntApi?: TauntApi, extNonce?: string): Promise<{
410
- accessToken: string;
411
- refreshToken: string;
412
- isNewUser: string;
413
- }>;
327
+ declare function tauntMetamaskLogin(tauntServiceEndpoint: string, provider?: BaseProvider, tauntApi?: TauntApi, extNonce?: string): Promise<TauntRespType>;
414
328
 
415
329
  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, tauntMagicEmailOTPLogin, tauntMagicTelegramLogin, tauntMetamaskLogin, telegramWithMagic };
416
- export type { ClaimrCampaignData, TauntAccessDetails, TauntExtSigProps, TauntSigProps, TauntUser };
330
+ export type { ClaimrCampaignData, TauntAccessDetails, TauntExtSigProps, TauntRespType, TauntSigProps, TauntUser };