@redzone/taunt-logins 0.0.12 → 0.0.14

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/es/index.js CHANGED
@@ -3,28 +3,28 @@ import { Magic } from 'magic-sdk';
3
3
  import axios from 'axios';
4
4
 
5
5
  // From RFC 2616
6
- // 1xx: Informational - Request received, continuing process
7
- // 2xx: Success - The action was successfully received, understood, and accepted
6
+ // 1xx: Informational - Request received continuing process
7
+ // 2xx: Success - The action was successfully received understood and accepted
8
8
  // 3xx: Redirection - Further action must be taken in order to complete the request
9
9
  // 4xx: Client Error - The request contains bad syntax or cannot be fulfilled
10
10
  // 5xx: Server Error - The server failed to fulfill an apparently valid request
11
- // HTTP status codes are extensible. HTTP applications are not required to understand the meaning of all registered status codes,
12
- // though such understanding is obviously desirable. However, applications MUST understand the class of any status code,
13
- // as indicated by the first digit, and treat any unrecognized response as being equivalent to the x00 status code of that class,
14
- // with the exception that an unrecognized response MUST NOT be cached. For example, if an unrecognized status code of 431 is received
15
- // by the client, it can safely assume that there was something wrong with its request and treat the response as if it had
11
+ // HTTP status codes are extensible. HTTP applications are not required to understand the meaning of all registered status codes
12
+ // though such understanding is obviously desirable. However applications MUST understand the class of any status code
13
+ // as indicated by the first digit and treat any unrecognized response as being equivalent to the x00 status code of that class
14
+ // with the exception that an unrecognized response MUST NOT be cached. For example if an unrecognized status code of 431 is received
15
+ // by the client it can safely assume that there was something wrong with its request and treat the response as if it had
16
16
  // received a 400 status code.
17
17
  // 400 Bad Request - The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
18
- // 401 Unauthorized - The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.47) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field (section 14.8). If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials. If the401 response contains the same challenge as the prior response, it SHOULD be resent again. HTTP access authentication is explained in "HTTP Authentication: Basic and Digest Access Authentication" (http://www.ietf.org/rfc/rfc2617.txt).
18
+ // 401 Unauthorized - The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.47) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field (section 14.8). If the request already included Authorization credentials then the 401 response indicates that authorization has been refused for those credentials. If the401 response contains the same challenge as the prior response it SHOULD be resent again. HTTP access authentication is explained in "HTTP Authentication: Basic and Digest Access Authentication" (http://www.ietf.org/rfc/rfc2617.txt).
19
19
  // 402 Payment Required - Payment required.
20
- // 403 Forbidden - The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated.
21
- // 404 Not Found - The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when the server is unwilling to return a 401 Unauthorized response for Authentication reasons.
20
+ // 403 Forbidden - The server understood the request but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated.
21
+ // 404 Not Found - The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows through some internally configurable mechanism that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused or when the server is unwilling to return a 401 Unauthorized response for Authentication reasons.
22
22
  // 405 Method Not Allowed - The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.
23
23
  // 406 Not Acceptable - The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.
24
24
  // 407 Proxy Authentication Required - The client must first authenticate itself with the proxy.
25
25
  // 408 Request Timeout - The server timed out waiting for the request. According to W3 HTTP specifications: "The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time."
26
26
  // 409 Conflict - The request could not be completed due to a conflict with the current state of the resource.
27
- // 410 Gone - The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is cacheable unless indicated otherwise.
27
+ // 410 Gone - The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know or has no facility to determine whether or not the condition is permanent the status code 404 (Not Found) SHOULD be used instead. This response is cacheable unless indicated otherwise.
28
28
  // 411 Length Required - The server refuses to accept the request without a defined Content-Length. The client MAY repeat the request if it adds a valid Content-Length header field containing the length of the message-body in the request message.
29
29
  // 412 Precondition Failed - The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.
30
30
  // 413 Request Entity Too Large - The server is refusing to process a request because the request entity is larger than the server is willing or able to process.
@@ -32,351 +32,231 @@ import axios from 'axios';
32
32
  // 415 Unsupported Media Type - The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
33
33
  // 416 Requested Range Not Satisfiable - The server cannot meet the requirements of the Range header field in the request.
34
34
  // 417 Expectation Failed - The server could not meet the requirements of the Expect header field in the request.
35
- // 418 I'm a teapot - This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol, and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by teapots requested to brew coffee.
35
+ // 418 I'm a teapot - This code was defined in 1998 as one of the traditional IETF April Fools' jokes in RFC 2324 Hyper Text Coffee Pot Control Protocol and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by teapots requested to brew coffee.
36
36
  // 419 Authentication Timeout - The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time.
37
37
  // 420 Method Failure - The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.
38
38
  // 421 Misdirected Request - The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI.
39
39
  // 422 Unprocessable Entity - The request was well-formed but was unable to be followed due to semantic errors.
40
40
  // 423 Locked - The resource that is being accessed is locked.
41
- // 424 Failed Dependency - The request failed due to failure of a previous request (e.g., a PROPPATCH).
42
- // 425 Unordered Collection - The server is unwilling to process the request because either an individual header field, or all the header fields collectively, are too large.
41
+ // 424 Failed Dependency - The request failed due to failure of a previous request (e.g. a PROPPATCH).
42
+ // 425 Unordered Collection - The server is unwilling to process the request because either an individual header field or all the header fields collectively are too large.
43
43
  // 426 Upgrade Required - The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol. The server MUST specify an Upgrade header field in a 426 response containing a list of the required upgrade methods.
44
- // 428 Precondition Required - The origin server requires the request to be conditional. Intended to prevent the 'lost update' problem, where a client GETs a resource's state, modifies it, and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a conflict.
44
+ // 428 Precondition Required - The origin server requires the request to be conditional. Intended to prevent the 'lost update' problem where a client GETs a resource's state modifies it and PUTs it back to the server when meanwhile a third party has modified the state on the server leading to a conflict.
45
45
  // 429 Too Many Requests - The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.
46
46
  // 432-450 Unassigned
47
- // 450 Blocked by Windows Parental Controls - Microsoft's Internet Explorer 4.0 does not support the HTTP protocol, and therefore cannot understand the requests for the Windows Parental Controls page.
47
+ // 450 Blocked by Windows Parental Controls - Microsoft's Internet Explorer 4.0 does not support the HTTP protocol and therefore cannot understand the requests for the Windows Parental Controls page.
48
48
  // 451 Unavailable For Legal Reasons - The server is denying access to the resource as a consequence of a legal demand.
49
49
  // 452-499 Unassigned
50
50
  // 500 Internal Server Error - The server encountered an unexpected condition that prevented it from fulfilling the request.
51
51
  // 501 Not Implemented - The server does not support the functionality required to fulfill the request. This is the appropriate response when the server does not recognize the request method and is not capable of supporting it for any resource.
52
- // 502 Bad Gateway - The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.
53
- // 503 Service Unavailable - The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.
54
- // 504 Gateway Timeout - The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.
55
- // 505 HTTP Version Not Supported - The server does not support, or refuses to support, the HTTP protocol version that was used in the request message. The server is indicating that it is unable or unwilling to complete the request using the same major version as the client, as described in section 3.1, other than with this error message. The response SHOULD contain an entity describing why that version is not supported and what other protocols are supported by that server.
56
- // 506 Variant Also Negotiates - The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.
52
+ // 502 Bad Gateway - The server while acting as a gateway or proxy received an invalid response from the upstream server it accessed in attempting to fulfill the request.
53
+ // 503 Service Unavailable - The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given the client SHOULD handle the response as it would for a 500 response.
54
+ // 504 Gateway Timeout - The server while acting as a gateway or proxy did not receive a timely response from the upstream server specified by the URI (e.g. HTTP FTP LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.
55
+ // 505 HTTP Version Not Supported - The server does not support or refuses to support the HTTP protocol version that was used in the request message. The server is indicating that it is unable or unwilling to complete the request using the same major version as the client as described in section 3.1 other than with this error message. The response SHOULD contain an entity describing why that version is not supported and what other protocols are supported by that server.
56
+ // 506 Variant Also Negotiates - The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself and is therefore not a proper end point in the negotiation process.
57
57
  // 507 Insufficient Storage - The server is unable to store the representation needed to complete the request.
58
58
  // 508 Loop Detected - The server detected an infinite loop while processing the request.
59
- // 509 Bandwidth Limit Exceeded - This status code, while used by the HTTP transport, is not specified in any RFCs.
59
+ // 509 Bandwidth Limit Exceeded - This status code while used by the HTTP transport is not specified in any RFCs.
60
60
  // 510 Not Extended - Further extensions to the request are required for the server to fulfill it.
61
61
  // 511 Network Authentication Required - The client needs to authenticate to gain network access.
62
- class ErrorResponse {
63
- constructor(message, summary = "", explanation = "", status = 0){
64
- this.message = message;
65
- this.summary = summary;
66
- this.explanation = explanation;
67
- this.status = status;
62
+ class ErrorResponse extends Error {
63
+ constructor(...args){
64
+ super(...args), this.summary = "", this.explanation = "", this.status = 0;
68
65
  }
69
- }
70
- class BadRequestError {
71
- constructor(message, summary = "Bad Request", explanation = "The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.", status = 400){
72
- this.message = message;
73
- this.summary = summary;
74
- this.explanation = explanation;
75
- this.status = status;
66
+ }
67
+ class BadRequestError extends ErrorResponse {
68
+ constructor(...args){
69
+ super(...args), this.summary = "Bad Request", this.explanation = "The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.", this.status = 400;
76
70
  }
77
- }
78
- class UnauthorizedError {
79
- constructor(message, summary = "Unauthorized", explanation = "The request requires user authentication.", status = 401){
80
- this.message = message;
81
- this.summary = summary;
82
- this.explanation = explanation;
83
- this.status = status;
71
+ }
72
+ class UnauthorizedError extends ErrorResponse {
73
+ constructor(...args){
74
+ super(...args), this.summary = "Unauthorized", this.explanation = "The request requires user authentication.", this.status = 401;
84
75
  }
85
- }
86
- class PaymentRequiredError {
87
- constructor(message, summary = "Payment Required", explanation = "Payment required.", status = 402){
88
- this.message = message;
89
- this.summary = summary;
90
- this.explanation = explanation;
91
- this.status = status;
76
+ }
77
+ class PaymentRequiredError extends ErrorResponse {
78
+ constructor(...args){
79
+ super(...args), this.summary = "Payment Required", this.explanation = "Payment required.", this.status = 402;
92
80
  }
93
- }
94
- class ForbiddenError {
95
- constructor(message, summary = "Forbidden", explanation = "The server understood the request, but is refusing to fulfill it.", status = 403){
96
- this.message = message;
97
- this.summary = summary;
98
- this.explanation = explanation;
99
- this.status = status;
81
+ }
82
+ class ForbiddenError extends ErrorResponse {
83
+ constructor(...args){
84
+ super(...args), this.summary = "Forbidden", this.explanation = "The server understood the request but is refusing to fulfill it.", this.status = 403;
100
85
  }
101
- }
102
- class NotFoundError {
103
- constructor(message, summary = "Not Found", explanation = "The server has not found anything matching the Request-URI.", status = 404){
104
- this.message = message;
105
- this.summary = summary;
106
- this.explanation = explanation;
107
- this.status = status;
86
+ }
87
+ class NotFoundError extends ErrorResponse {
88
+ constructor(...args){
89
+ super(...args), this.summary = "Not Found", this.explanation = "The server has not found anything matching the Request-URI.", this.status = 404;
108
90
  }
109
- }
110
- class MethodNotAllowedError {
111
- constructor(message, summary = "Method Not Allowed", explanation = "The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.", status = 405){
112
- this.message = message;
113
- this.summary = summary;
114
- this.explanation = explanation;
115
- this.status = status;
91
+ }
92
+ class MethodNotAllowedError extends ErrorResponse {
93
+ constructor(...args){
94
+ super(...args), this.summary = "Method Not Allowed", this.explanation = "The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.", this.status = 405;
116
95
  }
117
- }
118
- class NotAcceptableError {
119
- constructor(message, summary = "Not Acceptable", explanation = "The server can only generate a response that is not accepted by the client.", status = 406){
120
- this.message = message;
121
- this.summary = summary;
122
- this.explanation = explanation;
123
- this.status = status;
96
+ }
97
+ class NotAcceptableError extends ErrorResponse {
98
+ constructor(...args){
99
+ super(...args), this.summary = "Not Acceptable", this.explanation = "The server can only generate a response that is not accepted by the client.", this.status = 406;
124
100
  }
125
- }
126
- class ProxyAuthenticationRequiredError {
127
- constructor(message, summary = "Proxy Authentication Required", explanation = "The client must first authenticate itself with the proxy.", status = 407){
128
- this.message = message;
129
- this.summary = summary;
130
- this.explanation = explanation;
131
- this.status = status;
101
+ }
102
+ class ProxyAuthenticationRequiredError extends ErrorResponse {
103
+ constructor(...args){
104
+ super(...args), this.summary = "Proxy Authentication Required", this.explanation = "The client must first authenticate itself with the proxy.", this.status = 407;
132
105
  }
133
- }
134
- class RequestTimeoutError {
135
- constructor(message, summary = "Request Timeout", explanation = "The server did not receive a complete request message within the time that it was prepared to wait.", status = 408){
136
- this.message = message;
137
- this.summary = summary;
138
- this.explanation = explanation;
139
- this.status = status;
106
+ }
107
+ class RequestTimeoutError extends ErrorResponse {
108
+ constructor(...args){
109
+ super(...args), this.summary = "Request Timeout", this.explanation = "The server did not receive a complete request message within the time that it was prepared to wait.", this.status = 408;
140
110
  }
141
- }
142
- class ConflictError {
143
- constructor(message, summary = "Conflict", explanation = "The request could not be completed due to a conflict with the current state of the resource.", status = 409){
144
- this.message = message;
145
- this.summary = summary;
146
- this.explanation = explanation;
147
- this.status = status;
111
+ }
112
+ class ConflictError extends ErrorResponse {
113
+ constructor(...args){
114
+ super(...args), this.summary = "Conflict", this.explanation = "The request could not be completed due to a conflict with the current state of the resource.", this.status = 409;
148
115
  }
149
- }
150
- class GoneError {
151
- constructor(message, summary = "Gone", explanation = "The requested resource is no longer available at the server and no forwarding address is known.", status = 410){
152
- this.message = message;
153
- this.summary = summary;
154
- this.explanation = explanation;
155
- this.status = status;
116
+ }
117
+ class GoneError extends ErrorResponse {
118
+ constructor(...args){
119
+ super(...args), this.summary = "Gone", this.explanation = "The requested resource is no longer available at the server and no forwarding address is known.", this.status = 410;
156
120
  }
157
- }
158
- class LengthRequiredError {
159
- constructor(message, summary = "Length Required", explanation = "The server refuses to accept the request without a defined Content-Length.", status = 411){
160
- this.message = message;
161
- this.summary = summary;
162
- this.explanation = explanation;
163
- this.status = status;
121
+ }
122
+ class LengthRequiredError extends ErrorResponse {
123
+ constructor(...args){
124
+ super(...args), this.summary = "Length Required", this.explanation = "The server refuses to accept the request without a defined Content-Length.", this.status = 411;
164
125
  }
165
126
  }
166
- class PreconditionFailedError {
167
- constructor(message, summary = "Precondition Failed", explanation = "The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.", status = 412){
168
- this.message = message;
169
- this.summary = summary;
170
- this.explanation = explanation;
171
- this.status = status;
127
+ class PreconditionFailedError extends ErrorResponse {
128
+ constructor(...args){
129
+ super(...args), this.summary = "Precondition Failed", this.explanation = "The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.", this.status = 412;
172
130
  }
173
131
  }
174
- class RequestEntityTooLargeError {
175
- constructor(message, summary = "Request Entity Too Large", explanation = "The server is refusing to process a request because the request entity is larger than the server is willing or able to process.", status = 413){
176
- this.message = message;
177
- this.summary = summary;
178
- this.explanation = explanation;
179
- this.status = status;
132
+ class RequestEntityTooLargeError extends ErrorResponse {
133
+ constructor(...args){
134
+ super(...args), this.summary = "Request Entity Too Large", this.explanation = "The server is refusing to process a request because the request entity is larger than the server is willing or able to process.", this.status = 413;
180
135
  }
181
136
  }
182
- class RequestUriTooLongError {
183
- constructor(message, summary = "Request-URI Too Long", explanation = "The server is refusing to service the request because the request-URI is longer than the server is willing to interpret.", status = 414){
184
- this.message = message;
185
- this.summary = summary;
186
- this.explanation = explanation;
187
- this.status = status;
137
+ class RequestUriTooLongError extends ErrorResponse {
138
+ constructor(...args){
139
+ super(...args), this.summary = "Request-URI Too Long", this.explanation = "The server is refusing to service the request because the request-URI is longer than the server is willing to interpret.", this.status = 414;
188
140
  }
189
141
  }
190
- class UnsupportedMediaTypeError {
191
- constructor(message, summary = "Unsupported Media Type", explanation = "The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.", status = 415){
192
- this.message = message;
193
- this.summary = summary;
194
- this.explanation = explanation;
195
- this.status = status;
142
+ class UnsupportedMediaTypeError extends ErrorResponse {
143
+ constructor(...args){
144
+ super(...args), this.summary = "Unsupported Media Type", this.explanation = "The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.", this.status = 415;
196
145
  }
197
146
  }
198
- class RequestedRangeNotSatisfiableError {
199
- constructor(message, summary = "Requested Range Not Satisfiable", explanation = "The server cannot supply the requested range.", status = 416){
200
- this.message = message;
201
- this.summary = summary;
202
- this.explanation = explanation;
203
- this.status = status;
147
+ class RequestedRangeNotSatisfiableError extends ErrorResponse {
148
+ constructor(...args){
149
+ super(...args), this.summary = "Requested Range Not Satisfiable", this.explanation = "The server cannot supply the requested range.", this.status = 416;
204
150
  }
205
151
  }
206
- class ExpectationFailedError {
207
- constructor(message, summary = "Expectation Failed", explanation = "The server cannot meet the requirements of the Expect request-header field.", status = 417){
208
- this.message = message;
209
- this.summary = summary;
210
- this.explanation = explanation;
211
- this.status = status;
152
+ class ExpectationFailedError extends ErrorResponse {
153
+ constructor(...args){
154
+ super(...args), this.summary = "Expectation Failed", this.explanation = "The server cannot meet the requirements of the Expect request-header field.", this.status = 417;
212
155
  }
213
156
  }
214
- class ImATeapotError {
215
- constructor(message, summary = "I'm a teapot", explanation = "The server should return this if it is a teapot.", status = 418){
216
- this.message = message;
217
- this.summary = summary;
218
- this.explanation = explanation;
219
- this.status = status;
157
+ class ImATeapotError extends ErrorResponse {
158
+ constructor(...args){
159
+ super(...args), this.summary = "I'm a teapot", this.explanation = "The server should return this if it is a teapot.", this.status = 418;
220
160
  }
221
161
  }
222
- class UnprocessableEntityError {
223
- constructor(message, summary = "Unprocessable Entity", explanation = "The request was well-formed but was unable to be followed due to semantic errors.", status = 422){
224
- this.message = message;
225
- this.summary = summary;
226
- this.explanation = explanation;
227
- this.status = status;
162
+ class UnprocessableEntityError extends ErrorResponse {
163
+ constructor(...args){
164
+ super(...args), this.summary = "Unprocessable Entity", this.explanation = "The request was well-formed but was unable to be followed due to semantic errors.", this.status = 422;
228
165
  }
229
166
  }
230
- class LockedError {
231
- constructor(message, summary = "Locked", explanation = "The resource that is being accessed is locked.", status = 423){
232
- this.message = message;
233
- this.summary = summary;
234
- this.explanation = explanation;
235
- this.status = status;
167
+ class LockedError extends ErrorResponse {
168
+ constructor(...args){
169
+ super(...args), this.summary = "Locked", this.explanation = "The resource that is being accessed is locked.", this.status = 423;
236
170
  }
237
171
  }
238
- class FailedDependencyError {
239
- constructor(message, summary = "Failed Dependency", explanation = "The request failed due to failure of a previous request.", status = 424){
240
- this.message = message;
241
- this.summary = summary;
242
- this.explanation = explanation;
243
- this.status = status;
172
+ class FailedDependencyError extends ErrorResponse {
173
+ constructor(...args){
174
+ super(...args), this.summary = "Failed Dependency", this.explanation = "The request failed due to failure of a previous request.", this.status = 424;
244
175
  }
245
176
  }
246
- class UpgradeRequiredError {
247
- constructor(message, summary = "Upgrade Required", explanation = "The client should switch to a different protocol.", status = 426){
248
- this.message = message;
249
- this.summary = summary;
250
- this.explanation = explanation;
251
- this.status = status;
177
+ class UpgradeRequiredError extends ErrorResponse {
178
+ constructor(...args){
179
+ super(...args), this.summary = "Upgrade Required", this.explanation = "The client should switch to a different protocol.", this.status = 426;
252
180
  }
253
181
  }
254
- class PreconditionRequiredError {
255
- constructor(message, summary = "Precondition Required", explanation = "The origin server requires the request to be conditional.", status = 428){
256
- this.message = message;
257
- this.summary = summary;
258
- this.explanation = explanation;
259
- this.status = status;
182
+ class PreconditionRequiredError extends ErrorResponse {
183
+ constructor(...args){
184
+ super(...args), this.summary = "Precondition Required", this.explanation = "The origin server requires the request to be conditional.", this.status = 428;
260
185
  }
261
186
  }
262
- class TooManyRequestsError {
263
- constructor(message, summary = "Too Many Requests", explanation = "The user has sent too many requests in a given amount of time.", status = 429){
264
- this.message = message;
265
- this.summary = summary;
266
- this.explanation = explanation;
267
- this.status = status;
187
+ class TooManyRequestsError extends ErrorResponse {
188
+ constructor(...args){
189
+ super(...args), this.summary = "Too Many Requests", this.explanation = "The user has sent too many requests in a given amount of time.", this.status = 429;
268
190
  }
269
191
  }
270
- class RequestHeaderFieldsTooLargeError {
271
- constructor(message, summary = "Request Header Fields Too Large", explanation = "The server is unwilling to process the request because either an individual header field, or all the header fields collectively, are too large.", status = 431){
272
- this.message = message;
273
- this.summary = summary;
274
- this.explanation = explanation;
275
- this.status = status;
192
+ class RequestHeaderFieldsTooLargeError extends ErrorResponse {
193
+ constructor(...args){
194
+ super(...args), this.summary = "Request Header Fields Too Large", this.explanation = "The server is unwilling to process the request because either an individual header field or all the header fields collectively are too large.", this.status = 431;
276
195
  }
277
196
  }
278
- class InternalServerError {
279
- constructor(message, summary = "Internal Server Error", explanation = "The server encountered an unexpected condition which prevented it from fulfilling the request.", status = 500){
280
- this.message = message;
281
- this.summary = summary;
282
- this.explanation = explanation;
283
- this.status = status;
197
+ class InternalServerError extends ErrorResponse {
198
+ constructor(...args){
199
+ super(...args), this.summary = "Internal Server Error", this.explanation = "The server encountered an unexpected condition which prevented it from fulfilling the request.", this.status = 500;
284
200
  }
285
201
  }
286
- class NotImplementedError {
287
- constructor(message, summary = "Not Implemented", explanation = "The server does not support the functionality required to fulfill the request.", status = 501){
288
- this.message = message;
289
- this.summary = summary;
290
- this.explanation = explanation;
291
- this.status = status;
202
+ class NotImplementedError extends ErrorResponse {
203
+ constructor(...args){
204
+ super(...args), this.summary = "Not Implemented", this.explanation = "The server does not support the functionality required to fulfill the request.", this.status = 501;
292
205
  }
293
206
  }
294
- class BadGatewayError {
295
- constructor(message, summary = "Bad Gateway", explanation = "The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.", status = 502){
296
- this.message = message;
297
- this.summary = summary;
298
- this.explanation = explanation;
299
- this.status = status;
207
+ class BadGatewayError extends ErrorResponse {
208
+ constructor(...args){
209
+ super(...args), this.summary = "Bad Gateway", this.explanation = "The server while acting as a gateway or proxy received an invalid response from the upstream server it accessed in attempting to fulfill the request.", this.status = 502;
300
210
  }
301
211
  }
302
- class ServiceUnavailableError {
303
- constructor(message, summary = "Service Unavailable", explanation = "The server is currently unable to handle the request due to a temporary overloading or maintenance of the server.", status = 503){
304
- this.message = message;
305
- this.summary = summary;
306
- this.explanation = explanation;
307
- this.status = status;
212
+ class ServiceUnavailableError extends ErrorResponse {
213
+ constructor(...args){
214
+ super(...args), this.summary = "Service Unavailable", this.explanation = "The server is currently unable to handle the request due to a temporary overloading or maintenance of the server.", this.status = 503;
308
215
  }
309
216
  }
310
- class GatewayTimeoutError {
311
- constructor(message, summary = "Gateway Timeout", explanation = "The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.", status = 504){
312
- this.message = message;
313
- this.summary = summary;
314
- this.explanation = explanation;
315
- this.status = status;
217
+ class GatewayTimeoutError extends ErrorResponse {
218
+ constructor(...args){
219
+ super(...args), this.summary = "Gateway Timeout", this.explanation = "The server while acting as a gateway or proxy did not receive a timely response from the upstream server specified by the URI (e.g. HTTP FTP LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.", this.status = 504;
316
220
  }
317
221
  }
318
- class HTTPVersionNotSupportedError {
319
- constructor(message, summary = "HTTP Version Not Supported", explanation = "The server does not support, or refuses to support, the HTTP protocol version that was used in the request message.", status = 505){
320
- this.message = message;
321
- this.summary = summary;
322
- this.explanation = explanation;
323
- this.status = status;
222
+ class HTTPVersionNotSupportedError extends ErrorResponse {
223
+ constructor(...args){
224
+ super(...args), this.summary = "HTTP Version Not Supported", this.explanation = "The server does not support or refuses to support the HTTP protocol version that was used in the request message.", this.status = 505;
324
225
  }
325
226
  }
326
- class VariantAlsoNegotiatesError {
327
- constructor(message, summary = "Variant Also Negotiates", explanation = "The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.", status = 506){
328
- this.message = message;
329
- this.summary = summary;
330
- this.explanation = explanation;
331
- this.status = status;
227
+ class VariantAlsoNegotiatesError extends ErrorResponse {
228
+ constructor(...args){
229
+ super(...args), this.summary = "Variant Also Negotiates", this.explanation = "The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself and is therefore not a proper end point in the negotiation process.", this.status = 506;
332
230
  }
333
231
  }
334
- class InsufficientStorageError {
335
- constructor(message, summary = "Insufficient Storage", explanation = "The server is unable to store the representation needed to complete the request.", status = 507){
336
- this.message = message;
337
- this.summary = summary;
338
- this.explanation = explanation;
339
- this.status = status;
232
+ class InsufficientStorageError extends ErrorResponse {
233
+ constructor(...args){
234
+ super(...args), this.summary = "Insufficient Storage", this.explanation = "The server is unable to store the representation needed to complete the request.", this.status = 507;
340
235
  }
341
236
  }
342
- class LoopDetectedError {
343
- constructor(message, summary = "Loop Detected", explanation = "The server detected an infinite loop while processing the request.", status = 508){
344
- this.message = message;
345
- this.summary = summary;
346
- this.explanation = explanation;
347
- this.status = status;
237
+ class LoopDetectedError extends ErrorResponse {
238
+ constructor(...args){
239
+ super(...args), this.summary = "Loop Detected", this.explanation = "The server detected an infinite loop while processing the request.", this.status = 508;
348
240
  }
349
241
  }
350
- class BandwidthLimitExceededError {
351
- constructor(message, summary = "Bandwidth Limit Exceeded", explanation = "The server has exceeded the bandwidth specified by the server administrator; this is often used by shared hosting providers to limit the bandwidth of customers.", status = 509){
352
- this.message = message;
353
- this.summary = summary;
354
- this.explanation = explanation;
355
- this.status = status;
242
+ class BandwidthLimitExceededError extends ErrorResponse {
243
+ constructor(...args){
244
+ super(...args), this.summary = "Bandwidth Limit Exceeded", this.explanation = "The server has exceeded the bandwidth specified by the server administrator; this is often used by shared hosting providers to limit the bandwidth of customers.", this.status = 509;
356
245
  }
357
246
  }
358
- class NotExtendedError {
359
- constructor(message, summary = "Not Extended", explanation = "Further extensions to the request are required for the server to fulfill it.", status = 510){
360
- this.message = message;
361
- this.summary = summary;
362
- this.explanation = explanation;
363
- this.status = status;
247
+ class NotExtendedError extends ErrorResponse {
248
+ constructor(...args){
249
+ super(...args), this.summary = "Not Extended", this.explanation = "Further extensions to the request are required for the server to fulfill it.", this.status = 510;
364
250
  }
365
251
  }
366
- class NetworkAuthenticationRequiredError {
367
- constructor(message, summary = "Network Authentication Required", explanation = "The client needs to authenticate to gain network access.", status = 511){
368
- this.message = message;
369
- this.summary = summary;
370
- this.explanation = explanation;
371
- this.status = status;
252
+ class NetworkAuthenticationRequiredError extends ErrorResponse {
253
+ constructor(...args){
254
+ super(...args), this.summary = "Network Authentication Required", this.explanation = "The client needs to authenticate to gain network access.", this.status = 511;
372
255
  }
373
256
  }
374
- class UnknownError {
375
- constructor(message, summary = "Unknown Error", explanation = "", status = 0){
376
- this.message = message;
377
- this.summary = summary;
378
- this.explanation = explanation;
379
- this.status = status;
257
+ class UnknownError extends ErrorResponse {
258
+ constructor(...args){
259
+ super(...args), this.summary = "Unknown Error", this.explanation = "", this.status = 0;
380
260
  }
381
261
  }
382
262
  function ErrorFromResponse(response) {
@@ -457,7 +337,7 @@ function ErrorFromResponse(response) {
457
337
  case 511:
458
338
  return new NetworkAuthenticationRequiredError(message);
459
339
  default:
460
- return new UnknownError(message, "Unknown Error", "An unknown error has occurred.");
340
+ return new UnknownError(message);
461
341
  }
462
342
  }
463
343
 
@@ -513,6 +393,7 @@ class TauntApi {
513
393
  try {
514
394
  signature = await provider.personalSign(message, walletAddress);
515
395
  } catch (err) {
396
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
516
397
  throw new Error(`User denied message signature, ${err}`);
517
398
  }
518
399
  if (!signature) {
@@ -642,7 +523,7 @@ class TauntApi {
642
523
  console.log("401 - refreshing token");
643
524
  try {
644
525
  await this.refresh();
645
- return this._axios(originalRequest);
526
+ return await this._axios(originalRequest);
646
527
  } catch (error) {
647
528
  console.log("Unable to refresh access token, please log in");
648
529
  this.refreshToken = null;
@@ -675,11 +556,11 @@ class TauntApi {
675
556
  // loginWithMagicDid = (did: string) => this.post("/v1/auth/login/did", { did })
676
557
  this.loginWithWeb3WalletSignature = (props)=>this.post("/v1/auth/login/signature", props);
677
558
  this.loginExtWithWeb3WalletSignature = (props)=>{
678
- props.extNonce = props.extNonce || this.randomTokenString();
559
+ props.extNonce = props.extNonce ?? this.randomTokenString();
679
560
  return this.post("/v1/auth/login/ext-signature", props);
680
561
  };
681
562
  this.refresh = (refreshToken)=>{
682
- const token = refreshToken || this.refreshToken;
563
+ const token = refreshToken ?? this.refreshToken;
683
564
  if (!token) {
684
565
  return Promise.reject(new Error("No refresh token available"));
685
566
  }
@@ -696,21 +577,22 @@ class TauntApi {
696
577
  this.getClaimrToken = async ()=>{
697
578
  if (!this.claimrToken) {
698
579
  const url = "v1/claimr/token";
699
- const data = await this.get(`${url}`);
580
+ const data = await this.get(url);
700
581
  this.claimrToken = data.data.token;
701
582
  }
702
583
  return this.claimrToken;
703
584
  };
704
- this.getClaimrData = async ()=>{
705
- const data = await this.get("/v1/beamable/inventory/skulls");
706
- return data;
585
+ this.getClaimrSkulls = ()=>this.get("/v1/beamable/inventory/skulls");
586
+ this.getClaimrReferralCode = async ()=>{
587
+ const data = await this.get("v1/claimr/referral-code");
588
+ return data.data?.ref_id;
707
589
  };
708
590
  this.randomTokenString = ()=>crypto.randomUUID().replace(/-/g, "");
709
591
  // Use the cookie stored in the browser to get the user and save user model in state and local storage
710
592
  // This assumes that the user is logged to backend in and has a cookie jwt
711
593
  this.getLoggedInUser = ()=>this.get("/v1/auth/me");
712
594
  this._axios = axios.create({
713
- baseURL: `${endpoint}`
595
+ baseURL: endpoint
714
596
  });
715
597
  // Response interceptor for API calls
716
598
  this._axios.interceptors.response.use((response)=>response, (error)=>this.onError(error));
@@ -728,13 +610,13 @@ const getMagic = (magicKey)=>new Magic(magicKey, {
728
610
  ]
729
611
  });
730
612
  function emailOTPWithMagic(magicKey, email, magic) {
731
- magic = magic || getMagic(magicKey);
613
+ magic = magic ?? getMagic(magicKey);
732
614
  return magic.auth.loginWithEmailOTP({
733
615
  email
734
616
  });
735
617
  }
736
618
  function telegramWithMagic(magicKey, magic) {
737
- magic = magic || getMagic(magicKey);
619
+ magic = magic ?? getMagic(magicKey);
738
620
  return magic.oauth2.loginWithPopup({
739
621
  provider: "telegram"
740
622
  });
@@ -746,8 +628,8 @@ function tauntMagicEmailOTPLogin(tauntServiceEndpoint, magicKey, email, tauntApi
746
628
  return withLoginTry(tauntServiceEndpoint, tauntApi, magicKey, undefined, extNonce, (magic)=>emailOTPWithMagic(magicKey, email, magic));
747
629
  }
748
630
  async function withLoginTry(endpoint, tauntApi, magicKey, magic, extNonce, fn) {
749
- tauntApi = tauntApi || new TauntApi(endpoint);
750
- magic = magic || getMagic(magicKey);
631
+ tauntApi = tauntApi ?? new TauntApi(endpoint);
632
+ magic = magic ?? getMagic(magicKey);
751
633
  try {
752
634
  if (!await magic.user.isLoggedIn()) {
753
635
  await fn(magic, tauntApi);
@@ -757,7 +639,7 @@ async function withLoginTry(endpoint, tauntApi, magicKey, magic, extNonce, fn) {
757
639
  if (!isLoggedIn) {
758
640
  throw new Error("User is not logged in");
759
641
  }
760
- return tauntApi.withProvider({
642
+ return await tauntApi.withProvider({
761
643
  getAddress: ()=>magic.rpcProvider.send("eth_accounts", []).then((accounts)=>accounts[0]),
762
644
  personalSign: (message, address)=>magic.rpcProvider.send("personal_sign", [
763
645
  message,
@@ -771,11 +653,11 @@ async function withLoginTry(endpoint, tauntApi, magicKey, magic, extNonce, fn) {
771
653
  }
772
654
 
773
655
  async function tauntMetamaskLogin(tauntServiceEndpoint, provider, tauntApi, extNonce) {
774
- provider = provider || window.ethereum;
656
+ provider = provider ?? window.ethereum;
775
657
  if (!provider) {
776
658
  throw new Error("MetaMask provider not found");
777
659
  }
778
- const taunt = tauntApi || new TauntApi(tauntServiceEndpoint);
660
+ const taunt = tauntApi ?? new TauntApi(tauntServiceEndpoint);
779
661
  return taunt.withProvider({
780
662
  getAddress: ()=>provider.request({
781
663
  method: "eth_requestAccounts"