@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.
@@ -9,28 +9,28 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
9
  var axios__default = /*#__PURE__*/_interopDefault(axios);
10
10
 
11
11
  // From RFC 2616
12
- // 1xx: Informational - Request received, continuing process
13
- // 2xx: Success - The action was successfully received, understood, and accepted
12
+ // 1xx: Informational - Request received continuing process
13
+ // 2xx: Success - The action was successfully received understood and accepted
14
14
  // 3xx: Redirection - Further action must be taken in order to complete the request
15
15
  // 4xx: Client Error - The request contains bad syntax or cannot be fulfilled
16
16
  // 5xx: Server Error - The server failed to fulfill an apparently valid request
17
- // HTTP status codes are extensible. HTTP applications are not required to understand the meaning of all registered status codes,
18
- // though such understanding is obviously desirable. However, applications MUST understand the class of any status code,
19
- // as indicated by the first digit, and treat any unrecognized response as being equivalent to the x00 status code of that class,
20
- // with the exception that an unrecognized response MUST NOT be cached. For example, if an unrecognized status code of 431 is received
21
- // by the client, it can safely assume that there was something wrong with its request and treat the response as if it had
17
+ // HTTP status codes are extensible. HTTP applications are not required to understand the meaning of all registered status codes
18
+ // though such understanding is obviously desirable. However applications MUST understand the class of any status code
19
+ // as indicated by the first digit and treat any unrecognized response as being equivalent to the x00 status code of that class
20
+ // with the exception that an unrecognized response MUST NOT be cached. For example if an unrecognized status code of 431 is received
21
+ // by the client it can safely assume that there was something wrong with its request and treat the response as if it had
22
22
  // received a 400 status code.
23
23
  // 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.
24
- // 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).
24
+ // 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).
25
25
  // 402 Payment Required - Payment required.
26
- // 403 Forbidden - The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated.
27
- // 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.
26
+ // 403 Forbidden - The server understood the request but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated.
27
+ // 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.
28
28
  // 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.
29
29
  // 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.
30
30
  // 407 Proxy Authentication Required - The client must first authenticate itself with the proxy.
31
31
  // 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."
32
32
  // 409 Conflict - The request could not be completed due to a conflict with the current state of the resource.
33
- // 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.
33
+ // 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.
34
34
  // 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.
35
35
  // 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.
36
36
  // 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.
@@ -38,351 +38,231 @@ var axios__default = /*#__PURE__*/_interopDefault(axios);
38
38
  // 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.
39
39
  // 416 Requested Range Not Satisfiable - The server cannot meet the requirements of the Range header field in the request.
40
40
  // 417 Expectation Failed - The server could not meet the requirements of the Expect header field in the request.
41
- // 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.
41
+ // 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.
42
42
  // 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.
43
43
  // 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.
44
44
  // 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.
45
45
  // 422 Unprocessable Entity - The request was well-formed but was unable to be followed due to semantic errors.
46
46
  // 423 Locked - The resource that is being accessed is locked.
47
- // 424 Failed Dependency - The request failed due to failure of a previous request (e.g., a PROPPATCH).
48
- // 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.
47
+ // 424 Failed Dependency - The request failed due to failure of a previous request (e.g. a PROPPATCH).
48
+ // 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.
49
49
  // 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.
50
- // 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.
50
+ // 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.
51
51
  // 429 Too Many Requests - The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.
52
52
  // 432-450 Unassigned
53
- // 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.
53
+ // 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.
54
54
  // 451 Unavailable For Legal Reasons - The server is denying access to the resource as a consequence of a legal demand.
55
55
  // 452-499 Unassigned
56
56
  // 500 Internal Server Error - The server encountered an unexpected condition that prevented it from fulfilling the request.
57
57
  // 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.
58
- // 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.
59
- // 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.
60
- // 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.
61
- // 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.
62
- // 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.
58
+ // 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.
59
+ // 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.
60
+ // 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.
61
+ // 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.
62
+ // 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.
63
63
  // 507 Insufficient Storage - The server is unable to store the representation needed to complete the request.
64
64
  // 508 Loop Detected - The server detected an infinite loop while processing the request.
65
- // 509 Bandwidth Limit Exceeded - This status code, while used by the HTTP transport, is not specified in any RFCs.
65
+ // 509 Bandwidth Limit Exceeded - This status code while used by the HTTP transport is not specified in any RFCs.
66
66
  // 510 Not Extended - Further extensions to the request are required for the server to fulfill it.
67
67
  // 511 Network Authentication Required - The client needs to authenticate to gain network access.
68
- class ErrorResponse {
69
- constructor(message, summary = "", explanation = "", status = 0){
70
- this.message = message;
71
- this.summary = summary;
72
- this.explanation = explanation;
73
- this.status = status;
68
+ class ErrorResponse extends Error {
69
+ constructor(...args){
70
+ super(...args), this.summary = "", this.explanation = "", this.status = 0;
74
71
  }
75
- }
76
- class BadRequestError {
77
- 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){
78
- this.message = message;
79
- this.summary = summary;
80
- this.explanation = explanation;
81
- this.status = status;
72
+ }
73
+ class BadRequestError extends ErrorResponse {
74
+ constructor(...args){
75
+ 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;
82
76
  }
83
- }
84
- class UnauthorizedError {
85
- constructor(message, summary = "Unauthorized", explanation = "The request requires user authentication.", status = 401){
86
- this.message = message;
87
- this.summary = summary;
88
- this.explanation = explanation;
89
- this.status = status;
77
+ }
78
+ class UnauthorizedError extends ErrorResponse {
79
+ constructor(...args){
80
+ super(...args), this.summary = "Unauthorized", this.explanation = "The request requires user authentication.", this.status = 401;
90
81
  }
91
- }
92
- class PaymentRequiredError {
93
- constructor(message, summary = "Payment Required", explanation = "Payment required.", status = 402){
94
- this.message = message;
95
- this.summary = summary;
96
- this.explanation = explanation;
97
- this.status = status;
82
+ }
83
+ class PaymentRequiredError extends ErrorResponse {
84
+ constructor(...args){
85
+ super(...args), this.summary = "Payment Required", this.explanation = "Payment required.", this.status = 402;
98
86
  }
99
- }
100
- class ForbiddenError {
101
- constructor(message, summary = "Forbidden", explanation = "The server understood the request, but is refusing to fulfill it.", status = 403){
102
- this.message = message;
103
- this.summary = summary;
104
- this.explanation = explanation;
105
- this.status = status;
87
+ }
88
+ class ForbiddenError extends ErrorResponse {
89
+ constructor(...args){
90
+ super(...args), this.summary = "Forbidden", this.explanation = "The server understood the request but is refusing to fulfill it.", this.status = 403;
106
91
  }
107
- }
108
- class NotFoundError {
109
- constructor(message, summary = "Not Found", explanation = "The server has not found anything matching the Request-URI.", status = 404){
110
- this.message = message;
111
- this.summary = summary;
112
- this.explanation = explanation;
113
- this.status = status;
92
+ }
93
+ class NotFoundError extends ErrorResponse {
94
+ constructor(...args){
95
+ super(...args), this.summary = "Not Found", this.explanation = "The server has not found anything matching the Request-URI.", this.status = 404;
114
96
  }
115
- }
116
- class MethodNotAllowedError {
117
- 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){
118
- this.message = message;
119
- this.summary = summary;
120
- this.explanation = explanation;
121
- this.status = status;
97
+ }
98
+ class MethodNotAllowedError extends ErrorResponse {
99
+ constructor(...args){
100
+ 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;
122
101
  }
123
- }
124
- class NotAcceptableError {
125
- constructor(message, summary = "Not Acceptable", explanation = "The server can only generate a response that is not accepted by the client.", status = 406){
126
- this.message = message;
127
- this.summary = summary;
128
- this.explanation = explanation;
129
- this.status = status;
102
+ }
103
+ class NotAcceptableError extends ErrorResponse {
104
+ constructor(...args){
105
+ 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;
130
106
  }
131
- }
132
- class ProxyAuthenticationRequiredError {
133
- constructor(message, summary = "Proxy Authentication Required", explanation = "The client must first authenticate itself with the proxy.", status = 407){
134
- this.message = message;
135
- this.summary = summary;
136
- this.explanation = explanation;
137
- this.status = status;
107
+ }
108
+ class ProxyAuthenticationRequiredError extends ErrorResponse {
109
+ constructor(...args){
110
+ super(...args), this.summary = "Proxy Authentication Required", this.explanation = "The client must first authenticate itself with the proxy.", this.status = 407;
138
111
  }
139
- }
140
- class RequestTimeoutError {
141
- 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){
142
- this.message = message;
143
- this.summary = summary;
144
- this.explanation = explanation;
145
- this.status = status;
112
+ }
113
+ class RequestTimeoutError extends ErrorResponse {
114
+ constructor(...args){
115
+ 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;
146
116
  }
147
- }
148
- class ConflictError {
149
- constructor(message, summary = "Conflict", explanation = "The request could not be completed due to a conflict with the current state of the resource.", status = 409){
150
- this.message = message;
151
- this.summary = summary;
152
- this.explanation = explanation;
153
- this.status = status;
117
+ }
118
+ class ConflictError extends ErrorResponse {
119
+ constructor(...args){
120
+ 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;
154
121
  }
155
- }
156
- class GoneError {
157
- constructor(message, summary = "Gone", explanation = "The requested resource is no longer available at the server and no forwarding address is known.", status = 410){
158
- this.message = message;
159
- this.summary = summary;
160
- this.explanation = explanation;
161
- this.status = status;
122
+ }
123
+ class GoneError extends ErrorResponse {
124
+ constructor(...args){
125
+ 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;
162
126
  }
163
- }
164
- class LengthRequiredError {
165
- constructor(message, summary = "Length Required", explanation = "The server refuses to accept the request without a defined Content-Length.", status = 411){
166
- this.message = message;
167
- this.summary = summary;
168
- this.explanation = explanation;
169
- this.status = status;
127
+ }
128
+ class LengthRequiredError extends ErrorResponse {
129
+ constructor(...args){
130
+ super(...args), this.summary = "Length Required", this.explanation = "The server refuses to accept the request without a defined Content-Length.", this.status = 411;
170
131
  }
171
132
  }
172
- class PreconditionFailedError {
173
- 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){
174
- this.message = message;
175
- this.summary = summary;
176
- this.explanation = explanation;
177
- this.status = status;
133
+ class PreconditionFailedError extends ErrorResponse {
134
+ constructor(...args){
135
+ 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;
178
136
  }
179
137
  }
180
- class RequestEntityTooLargeError {
181
- 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){
182
- this.message = message;
183
- this.summary = summary;
184
- this.explanation = explanation;
185
- this.status = status;
138
+ class RequestEntityTooLargeError extends ErrorResponse {
139
+ constructor(...args){
140
+ 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;
186
141
  }
187
142
  }
188
- class RequestUriTooLongError {
189
- 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){
190
- this.message = message;
191
- this.summary = summary;
192
- this.explanation = explanation;
193
- this.status = status;
143
+ class RequestUriTooLongError extends ErrorResponse {
144
+ constructor(...args){
145
+ 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;
194
146
  }
195
147
  }
196
- class UnsupportedMediaTypeError {
197
- 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){
198
- this.message = message;
199
- this.summary = summary;
200
- this.explanation = explanation;
201
- this.status = status;
148
+ class UnsupportedMediaTypeError extends ErrorResponse {
149
+ constructor(...args){
150
+ 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;
202
151
  }
203
152
  }
204
- class RequestedRangeNotSatisfiableError {
205
- constructor(message, summary = "Requested Range Not Satisfiable", explanation = "The server cannot supply the requested range.", status = 416){
206
- this.message = message;
207
- this.summary = summary;
208
- this.explanation = explanation;
209
- this.status = status;
153
+ class RequestedRangeNotSatisfiableError extends ErrorResponse {
154
+ constructor(...args){
155
+ super(...args), this.summary = "Requested Range Not Satisfiable", this.explanation = "The server cannot supply the requested range.", this.status = 416;
210
156
  }
211
157
  }
212
- class ExpectationFailedError {
213
- constructor(message, summary = "Expectation Failed", explanation = "The server cannot meet the requirements of the Expect request-header field.", status = 417){
214
- this.message = message;
215
- this.summary = summary;
216
- this.explanation = explanation;
217
- this.status = status;
158
+ class ExpectationFailedError extends ErrorResponse {
159
+ constructor(...args){
160
+ super(...args), this.summary = "Expectation Failed", this.explanation = "The server cannot meet the requirements of the Expect request-header field.", this.status = 417;
218
161
  }
219
162
  }
220
- class ImATeapotError {
221
- constructor(message, summary = "I'm a teapot", explanation = "The server should return this if it is a teapot.", status = 418){
222
- this.message = message;
223
- this.summary = summary;
224
- this.explanation = explanation;
225
- this.status = status;
163
+ class ImATeapotError extends ErrorResponse {
164
+ constructor(...args){
165
+ super(...args), this.summary = "I'm a teapot", this.explanation = "The server should return this if it is a teapot.", this.status = 418;
226
166
  }
227
167
  }
228
- class UnprocessableEntityError {
229
- constructor(message, summary = "Unprocessable Entity", explanation = "The request was well-formed but was unable to be followed due to semantic errors.", status = 422){
230
- this.message = message;
231
- this.summary = summary;
232
- this.explanation = explanation;
233
- this.status = status;
168
+ class UnprocessableEntityError extends ErrorResponse {
169
+ constructor(...args){
170
+ 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;
234
171
  }
235
172
  }
236
- class LockedError {
237
- constructor(message, summary = "Locked", explanation = "The resource that is being accessed is locked.", status = 423){
238
- this.message = message;
239
- this.summary = summary;
240
- this.explanation = explanation;
241
- this.status = status;
173
+ class LockedError extends ErrorResponse {
174
+ constructor(...args){
175
+ super(...args), this.summary = "Locked", this.explanation = "The resource that is being accessed is locked.", this.status = 423;
242
176
  }
243
177
  }
244
- class FailedDependencyError {
245
- constructor(message, summary = "Failed Dependency", explanation = "The request failed due to failure of a previous request.", status = 424){
246
- this.message = message;
247
- this.summary = summary;
248
- this.explanation = explanation;
249
- this.status = status;
178
+ class FailedDependencyError extends ErrorResponse {
179
+ constructor(...args){
180
+ super(...args), this.summary = "Failed Dependency", this.explanation = "The request failed due to failure of a previous request.", this.status = 424;
250
181
  }
251
182
  }
252
- class UpgradeRequiredError {
253
- constructor(message, summary = "Upgrade Required", explanation = "The client should switch to a different protocol.", status = 426){
254
- this.message = message;
255
- this.summary = summary;
256
- this.explanation = explanation;
257
- this.status = status;
183
+ class UpgradeRequiredError extends ErrorResponse {
184
+ constructor(...args){
185
+ super(...args), this.summary = "Upgrade Required", this.explanation = "The client should switch to a different protocol.", this.status = 426;
258
186
  }
259
187
  }
260
- class PreconditionRequiredError {
261
- constructor(message, summary = "Precondition Required", explanation = "The origin server requires the request to be conditional.", status = 428){
262
- this.message = message;
263
- this.summary = summary;
264
- this.explanation = explanation;
265
- this.status = status;
188
+ class PreconditionRequiredError extends ErrorResponse {
189
+ constructor(...args){
190
+ super(...args), this.summary = "Precondition Required", this.explanation = "The origin server requires the request to be conditional.", this.status = 428;
266
191
  }
267
192
  }
268
- class TooManyRequestsError {
269
- constructor(message, summary = "Too Many Requests", explanation = "The user has sent too many requests in a given amount of time.", status = 429){
270
- this.message = message;
271
- this.summary = summary;
272
- this.explanation = explanation;
273
- this.status = status;
193
+ class TooManyRequestsError extends ErrorResponse {
194
+ constructor(...args){
195
+ 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;
274
196
  }
275
197
  }
276
- class RequestHeaderFieldsTooLargeError {
277
- 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){
278
- this.message = message;
279
- this.summary = summary;
280
- this.explanation = explanation;
281
- this.status = status;
198
+ class RequestHeaderFieldsTooLargeError extends ErrorResponse {
199
+ constructor(...args){
200
+ 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;
282
201
  }
283
202
  }
284
- class InternalServerError {
285
- constructor(message, summary = "Internal Server Error", explanation = "The server encountered an unexpected condition which prevented it from fulfilling the request.", status = 500){
286
- this.message = message;
287
- this.summary = summary;
288
- this.explanation = explanation;
289
- this.status = status;
203
+ class InternalServerError extends ErrorResponse {
204
+ constructor(...args){
205
+ 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;
290
206
  }
291
207
  }
292
- class NotImplementedError {
293
- constructor(message, summary = "Not Implemented", explanation = "The server does not support the functionality required to fulfill the request.", status = 501){
294
- this.message = message;
295
- this.summary = summary;
296
- this.explanation = explanation;
297
- this.status = status;
208
+ class NotImplementedError extends ErrorResponse {
209
+ constructor(...args){
210
+ super(...args), this.summary = "Not Implemented", this.explanation = "The server does not support the functionality required to fulfill the request.", this.status = 501;
298
211
  }
299
212
  }
300
- class BadGatewayError {
301
- 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){
302
- this.message = message;
303
- this.summary = summary;
304
- this.explanation = explanation;
305
- this.status = status;
213
+ class BadGatewayError extends ErrorResponse {
214
+ constructor(...args){
215
+ 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;
306
216
  }
307
217
  }
308
- class ServiceUnavailableError {
309
- 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){
310
- this.message = message;
311
- this.summary = summary;
312
- this.explanation = explanation;
313
- this.status = status;
218
+ class ServiceUnavailableError extends ErrorResponse {
219
+ constructor(...args){
220
+ 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;
314
221
  }
315
222
  }
316
- class GatewayTimeoutError {
317
- 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){
318
- this.message = message;
319
- this.summary = summary;
320
- this.explanation = explanation;
321
- this.status = status;
223
+ class GatewayTimeoutError extends ErrorResponse {
224
+ constructor(...args){
225
+ 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;
322
226
  }
323
227
  }
324
- class HTTPVersionNotSupportedError {
325
- 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){
326
- this.message = message;
327
- this.summary = summary;
328
- this.explanation = explanation;
329
- this.status = status;
228
+ class HTTPVersionNotSupportedError extends ErrorResponse {
229
+ constructor(...args){
230
+ 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;
330
231
  }
331
232
  }
332
- class VariantAlsoNegotiatesError {
333
- 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){
334
- this.message = message;
335
- this.summary = summary;
336
- this.explanation = explanation;
337
- this.status = status;
233
+ class VariantAlsoNegotiatesError extends ErrorResponse {
234
+ constructor(...args){
235
+ 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;
338
236
  }
339
237
  }
340
- class InsufficientStorageError {
341
- constructor(message, summary = "Insufficient Storage", explanation = "The server is unable to store the representation needed to complete the request.", status = 507){
342
- this.message = message;
343
- this.summary = summary;
344
- this.explanation = explanation;
345
- this.status = status;
238
+ class InsufficientStorageError extends ErrorResponse {
239
+ constructor(...args){
240
+ super(...args), this.summary = "Insufficient Storage", this.explanation = "The server is unable to store the representation needed to complete the request.", this.status = 507;
346
241
  }
347
242
  }
348
- class LoopDetectedError {
349
- constructor(message, summary = "Loop Detected", explanation = "The server detected an infinite loop while processing the request.", status = 508){
350
- this.message = message;
351
- this.summary = summary;
352
- this.explanation = explanation;
353
- this.status = status;
243
+ class LoopDetectedError extends ErrorResponse {
244
+ constructor(...args){
245
+ super(...args), this.summary = "Loop Detected", this.explanation = "The server detected an infinite loop while processing the request.", this.status = 508;
354
246
  }
355
247
  }
356
- class BandwidthLimitExceededError {
357
- 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){
358
- this.message = message;
359
- this.summary = summary;
360
- this.explanation = explanation;
361
- this.status = status;
248
+ class BandwidthLimitExceededError extends ErrorResponse {
249
+ constructor(...args){
250
+ 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;
362
251
  }
363
252
  }
364
- class NotExtendedError {
365
- constructor(message, summary = "Not Extended", explanation = "Further extensions to the request are required for the server to fulfill it.", status = 510){
366
- this.message = message;
367
- this.summary = summary;
368
- this.explanation = explanation;
369
- this.status = status;
253
+ class NotExtendedError extends ErrorResponse {
254
+ constructor(...args){
255
+ super(...args), this.summary = "Not Extended", this.explanation = "Further extensions to the request are required for the server to fulfill it.", this.status = 510;
370
256
  }
371
257
  }
372
- class NetworkAuthenticationRequiredError {
373
- constructor(message, summary = "Network Authentication Required", explanation = "The client needs to authenticate to gain network access.", status = 511){
374
- this.message = message;
375
- this.summary = summary;
376
- this.explanation = explanation;
377
- this.status = status;
258
+ class NetworkAuthenticationRequiredError extends ErrorResponse {
259
+ constructor(...args){
260
+ super(...args), this.summary = "Network Authentication Required", this.explanation = "The client needs to authenticate to gain network access.", this.status = 511;
378
261
  }
379
262
  }
380
- class UnknownError {
381
- constructor(message, summary = "Unknown Error", explanation = "", status = 0){
382
- this.message = message;
383
- this.summary = summary;
384
- this.explanation = explanation;
385
- this.status = status;
263
+ class UnknownError extends ErrorResponse {
264
+ constructor(...args){
265
+ super(...args), this.summary = "Unknown Error", this.explanation = "", this.status = 0;
386
266
  }
387
267
  }
388
268
  function ErrorFromResponse(response) {
@@ -463,7 +343,7 @@ function ErrorFromResponse(response) {
463
343
  case 511:
464
344
  return new NetworkAuthenticationRequiredError(message);
465
345
  default:
466
- return new UnknownError(message, "Unknown Error", "An unknown error has occurred.");
346
+ return new UnknownError(message);
467
347
  }
468
348
  }
469
349
 
@@ -519,6 +399,7 @@ class TauntApi {
519
399
  try {
520
400
  signature = await provider.personalSign(message, walletAddress);
521
401
  } catch (err) {
402
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
522
403
  throw new Error(`User denied message signature, ${err}`);
523
404
  }
524
405
  if (!signature) {
@@ -648,7 +529,7 @@ class TauntApi {
648
529
  console.log("401 - refreshing token");
649
530
  try {
650
531
  await this.refresh();
651
- return this._axios(originalRequest);
532
+ return await this._axios(originalRequest);
652
533
  } catch (error) {
653
534
  console.log("Unable to refresh access token, please log in");
654
535
  this.refreshToken = null;
@@ -681,11 +562,11 @@ class TauntApi {
681
562
  // loginWithMagicDid = (did: string) => this.post("/v1/auth/login/did", { did })
682
563
  this.loginWithWeb3WalletSignature = (props)=>this.post("/v1/auth/login/signature", props);
683
564
  this.loginExtWithWeb3WalletSignature = (props)=>{
684
- props.extNonce = props.extNonce || this.randomTokenString();
565
+ props.extNonce = props.extNonce ?? this.randomTokenString();
685
566
  return this.post("/v1/auth/login/ext-signature", props);
686
567
  };
687
568
  this.refresh = (refreshToken)=>{
688
- const token = refreshToken || this.refreshToken;
569
+ const token = refreshToken ?? this.refreshToken;
689
570
  if (!token) {
690
571
  return Promise.reject(new Error("No refresh token available"));
691
572
  }
@@ -702,21 +583,22 @@ class TauntApi {
702
583
  this.getClaimrToken = async ()=>{
703
584
  if (!this.claimrToken) {
704
585
  const url = "v1/claimr/token";
705
- const data = await this.get(`${url}`);
586
+ const data = await this.get(url);
706
587
  this.claimrToken = data.data.token;
707
588
  }
708
589
  return this.claimrToken;
709
590
  };
710
- this.getClaimrData = async ()=>{
711
- const data = await this.get("/v1/beamable/inventory/skulls");
712
- return data;
591
+ this.getClaimrSkulls = ()=>this.get("/v1/beamable/inventory/skulls");
592
+ this.getClaimrReferralCode = async ()=>{
593
+ const data = await this.get("v1/claimr/referral-code");
594
+ return data.data?.ref_id;
713
595
  };
714
596
  this.randomTokenString = ()=>crypto.randomUUID().replace(/-/g, "");
715
597
  // Use the cookie stored in the browser to get the user and save user model in state and local storage
716
598
  // This assumes that the user is logged to backend in and has a cookie jwt
717
599
  this.getLoggedInUser = ()=>this.get("/v1/auth/me");
718
600
  this._axios = axios__default.default.create({
719
- baseURL: `${endpoint}`
601
+ baseURL: endpoint
720
602
  });
721
603
  // Response interceptor for API calls
722
604
  this._axios.interceptors.response.use((response)=>response, (error)=>this.onError(error));
@@ -734,13 +616,13 @@ const getMagic = (magicKey)=>new magicSdk.Magic(magicKey, {
734
616
  ]
735
617
  });
736
618
  function emailOTPWithMagic(magicKey, email, magic) {
737
- magic = magic || getMagic(magicKey);
619
+ magic = magic ?? getMagic(magicKey);
738
620
  return magic.auth.loginWithEmailOTP({
739
621
  email
740
622
  });
741
623
  }
742
624
  function telegramWithMagic(magicKey, magic) {
743
- magic = magic || getMagic(magicKey);
625
+ magic = magic ?? getMagic(magicKey);
744
626
  return magic.oauth2.loginWithPopup({
745
627
  provider: "telegram"
746
628
  });
@@ -752,8 +634,8 @@ function tauntMagicEmailOTPLogin(tauntServiceEndpoint, magicKey, email, tauntApi
752
634
  return withLoginTry(tauntServiceEndpoint, tauntApi, magicKey, undefined, extNonce, (magic)=>emailOTPWithMagic(magicKey, email, magic));
753
635
  }
754
636
  async function withLoginTry(endpoint, tauntApi, magicKey, magic, extNonce, fn) {
755
- tauntApi = tauntApi || new TauntApi(endpoint);
756
- magic = magic || getMagic(magicKey);
637
+ tauntApi = tauntApi ?? new TauntApi(endpoint);
638
+ magic = magic ?? getMagic(magicKey);
757
639
  try {
758
640
  if (!await magic.user.isLoggedIn()) {
759
641
  await fn(magic, tauntApi);
@@ -763,7 +645,7 @@ async function withLoginTry(endpoint, tauntApi, magicKey, magic, extNonce, fn) {
763
645
  if (!isLoggedIn) {
764
646
  throw new Error("User is not logged in");
765
647
  }
766
- return tauntApi.withProvider({
648
+ return await tauntApi.withProvider({
767
649
  getAddress: ()=>magic.rpcProvider.send("eth_accounts", []).then((accounts)=>accounts[0]),
768
650
  personalSign: (message, address)=>magic.rpcProvider.send("personal_sign", [
769
651
  message,
@@ -777,11 +659,11 @@ async function withLoginTry(endpoint, tauntApi, magicKey, magic, extNonce, fn) {
777
659
  }
778
660
 
779
661
  async function tauntMetamaskLogin(tauntServiceEndpoint, provider, tauntApi, extNonce) {
780
- provider = provider || window.ethereum;
662
+ provider = provider ?? window.ethereum;
781
663
  if (!provider) {
782
664
  throw new Error("MetaMask provider not found");
783
665
  }
784
- const taunt = tauntApi || new TauntApi(tauntServiceEndpoint);
666
+ const taunt = tauntApi ?? new TauntApi(tauntServiceEndpoint);
785
667
  return taunt.withProvider({
786
668
  getAddress: ()=>provider.request({
787
669
  method: "eth_requestAccounts"