@openfort/openfort-js 0.6.17 → 0.6.18
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/index.cjs +3557 -0
- package/dist/index.d.ts +1304 -8
- package/dist/index.js +3544 -30
- package/package.json +83 -47
- package/.eslintrc.json +0 -56
- package/.prettierignore +0 -1
- package/.prettierrc +0 -7
- package/README.md +0 -95
- package/dist/clients/iframe-client.d.ts +0 -46
- package/dist/clients/iframe-client.js +0 -214
- package/dist/clients/iframe-client.js.map +0 -1
- package/dist/clients/types.d.ts +0 -156
- package/dist/clients/types.js +0 -148
- package/dist/clients/types.js.map +0 -1
- package/dist/crypto/key-pair.d.ts +0 -23
- package/dist/crypto/key-pair.js +0 -41
- package/dist/crypto/key-pair.js.map +0 -1
- package/dist/generated/api.d.ts +0 -12482
- package/dist/generated/api.js +0 -8616
- package/dist/generated/api.js.map +0 -1
- package/dist/generated/base.d.ts +0 -54
- package/dist/generated/base.js +0 -63
- package/dist/generated/base.js.map +0 -1
- package/dist/generated/common.d.ts +0 -65
- package/dist/generated/common.js +0 -146
- package/dist/generated/common.js.map +0 -1
- package/dist/generated/configuration.d.ts +0 -83
- package/dist/generated/configuration.js +0 -43
- package/dist/generated/configuration.js.map +0 -1
- package/dist/generated/index.d.ts +0 -13
- package/dist/generated/index.js +0 -32
- package/dist/generated/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/instanceManager.d.ts +0 -48
- package/dist/instanceManager.js +0 -182
- package/dist/instanceManager.js.map +0 -1
- package/dist/lib/helpers.d.ts +0 -5
- package/dist/lib/helpers.js +0 -45
- package/dist/lib/helpers.js.map +0 -1
- package/dist/openfort.d.ts +0 -71
- package/dist/openfort.js +0 -398
- package/dist/openfort.js.map +0 -1
- package/dist/openfortAuth.d.ts +0 -46
- package/dist/openfortAuth.js +0 -117
- package/dist/openfortAuth.js.map +0 -1
- package/dist/signer/embedded.signer.d.ts +0 -19
- package/dist/signer/embedded.signer.js +0 -59
- package/dist/signer/embedded.signer.js.map +0 -1
- package/dist/signer/session.signer.d.ts +0 -14
- package/dist/signer/session.signer.js +0 -47
- package/dist/signer/session.signer.js.map +0 -1
- package/dist/signer/signer.d.ts +0 -11
- package/dist/signer/signer.js +0 -9
- package/dist/signer/signer.js.map +0 -1
- package/dist/storage/localStorage.d.ts +0 -7
- package/dist/storage/localStorage.js +0 -25
- package/dist/storage/localStorage.js.map +0 -1
- package/dist/storage/sessionStorage.d.ts +0 -7
- package/dist/storage/sessionStorage.js +0 -24
- package/dist/storage/sessionStorage.js.map +0 -1
- package/dist/storage/storage.d.ts +0 -16
- package/dist/storage/storage.js +0 -15
- package/dist/storage/storage.js.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -6
- package/dist/version.js.map +0 -1
- package/jestconfig.json +0 -7
- package/tsconfig.json +0 -29
- package/tsconfig.tsbuildinfo +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3557 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var hash = require('@ethersproject/hash');
|
|
6
|
+
var globalAxios = require('axios');
|
|
7
|
+
var jose = require('jose');
|
|
8
|
+
var secp256k1 = require('@noble/curves/secp256k1');
|
|
9
|
+
var signingKey = require('@ethersproject/signing-key');
|
|
10
|
+
var bytes = require('@ethersproject/bytes');
|
|
11
|
+
var transactions = require('@ethersproject/transactions');
|
|
12
|
+
|
|
13
|
+
/* tslint:disable */
|
|
14
|
+
/* eslint-disable */
|
|
15
|
+
/**
|
|
16
|
+
* Openfort API
|
|
17
|
+
* Complete Openfort API references and guides can be found at: https://openfort.xyz/docs
|
|
18
|
+
*
|
|
19
|
+
* The version of the OpenAPI document: 1.0.0
|
|
20
|
+
* Contact: founders@openfort.xyz
|
|
21
|
+
*
|
|
22
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
23
|
+
* https://openapi-generator.tech
|
|
24
|
+
* Do not edit the class manually.
|
|
25
|
+
*/
|
|
26
|
+
const BASE_PATH = 'https://api.openfort.xyz'.replace(/\/+$/, '');
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @export
|
|
30
|
+
* @class BaseAPI
|
|
31
|
+
*/
|
|
32
|
+
class BaseAPI {
|
|
33
|
+
basePath;
|
|
34
|
+
axios;
|
|
35
|
+
configuration;
|
|
36
|
+
constructor(configuration, basePath = BASE_PATH, axios = globalAxios) {
|
|
37
|
+
this.basePath = basePath;
|
|
38
|
+
this.axios = axios;
|
|
39
|
+
if (configuration) {
|
|
40
|
+
this.configuration = configuration;
|
|
41
|
+
this.basePath = configuration.basePath || this.basePath;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @export
|
|
48
|
+
* @class RequiredError
|
|
49
|
+
* @extends {Error}
|
|
50
|
+
*/
|
|
51
|
+
class RequiredError extends Error {
|
|
52
|
+
field;
|
|
53
|
+
constructor(field, msg) {
|
|
54
|
+
super(msg);
|
|
55
|
+
this.field = field;
|
|
56
|
+
this.name = 'RequiredError';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* tslint:disable */
|
|
61
|
+
/* eslint-disable */
|
|
62
|
+
/**
|
|
63
|
+
* Openfort API
|
|
64
|
+
* Complete Openfort API references and guides can be found at: https://openfort.xyz/docs
|
|
65
|
+
*
|
|
66
|
+
* The version of the OpenAPI document: 1.0.0
|
|
67
|
+
* Contact: founders@openfort.xyz
|
|
68
|
+
*
|
|
69
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
70
|
+
* https://openapi-generator.tech
|
|
71
|
+
* Do not edit the class manually.
|
|
72
|
+
*/
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @export
|
|
76
|
+
*/
|
|
77
|
+
const DUMMY_BASE_URL = 'https://example.com';
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* @throws {RequiredError}
|
|
81
|
+
* @export
|
|
82
|
+
*/
|
|
83
|
+
const assertParamExists = function (functionName, paramName, paramValue) {
|
|
84
|
+
if (paramValue === null || paramValue === undefined) {
|
|
85
|
+
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* @export
|
|
91
|
+
*/
|
|
92
|
+
const setBearerAuthToObject = async function (object, configuration) {
|
|
93
|
+
if (configuration && configuration.accessToken) {
|
|
94
|
+
const accessToken = typeof configuration.accessToken === 'function'
|
|
95
|
+
? await configuration.accessToken()
|
|
96
|
+
: await configuration.accessToken;
|
|
97
|
+
object['Authorization'] = 'Bearer ' + accessToken;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
function setFlattenedQueryParams(urlSearchParams, parameter, key = '') {
|
|
101
|
+
if (parameter == null)
|
|
102
|
+
return;
|
|
103
|
+
if (typeof parameter === 'object') {
|
|
104
|
+
if (Array.isArray(parameter)) {
|
|
105
|
+
parameter.forEach((item) => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
Object.keys(parameter).forEach((currentKey) => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
if (urlSearchParams.has(key)) {
|
|
113
|
+
urlSearchParams.append(key, parameter);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
urlSearchParams.set(key, parameter);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* @export
|
|
123
|
+
*/
|
|
124
|
+
const setSearchParams = function (url, ...objects) {
|
|
125
|
+
const searchParams = new URLSearchParams(url.search);
|
|
126
|
+
setFlattenedQueryParams(searchParams, objects);
|
|
127
|
+
url.search = searchParams.toString();
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
* @export
|
|
132
|
+
*/
|
|
133
|
+
const serializeDataIfNeeded = function (value, requestOptions, configuration) {
|
|
134
|
+
const nonString = typeof value !== 'string';
|
|
135
|
+
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
136
|
+
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
137
|
+
: nonString;
|
|
138
|
+
return needsSerialization
|
|
139
|
+
? JSON.stringify(value !== undefined ? value : {})
|
|
140
|
+
: value || '';
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* @export
|
|
145
|
+
*/
|
|
146
|
+
const toPathString = function (url) {
|
|
147
|
+
return url.pathname + url.search + url.hash;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
*
|
|
151
|
+
* @export
|
|
152
|
+
*/
|
|
153
|
+
const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
|
|
154
|
+
return (axios = globalAxios, basePath = BASE_PATH) => {
|
|
155
|
+
const axiosRequestArgs = {
|
|
156
|
+
...axiosArgs.options,
|
|
157
|
+
url: (configuration?.basePath || basePath) + axiosArgs.url,
|
|
158
|
+
};
|
|
159
|
+
return axios.request(axiosRequestArgs);
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/* tslint:disable */
|
|
164
|
+
/* eslint-disable */
|
|
165
|
+
/**
|
|
166
|
+
* Openfort API
|
|
167
|
+
* Complete Openfort API references and guides can be found at: https://openfort.xyz/docs
|
|
168
|
+
*
|
|
169
|
+
* The version of the OpenAPI document: 1.0.0
|
|
170
|
+
* Contact: founders@openfort.xyz
|
|
171
|
+
*
|
|
172
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
173
|
+
* https://openapi-generator.tech
|
|
174
|
+
* Do not edit the class manually.
|
|
175
|
+
*/
|
|
176
|
+
/**
|
|
177
|
+
* Enum of the supporting OAuth providers.
|
|
178
|
+
* @export
|
|
179
|
+
* @enum {string}
|
|
180
|
+
*/
|
|
181
|
+
const OAuthProvider = {
|
|
182
|
+
Accelbyte: 'accelbyte',
|
|
183
|
+
Firebase: 'firebase',
|
|
184
|
+
Google: 'google',
|
|
185
|
+
Lootlocker: 'lootlocker',
|
|
186
|
+
Playfab: 'playfab',
|
|
187
|
+
Custom: 'custom',
|
|
188
|
+
Oidc: 'oidc',
|
|
189
|
+
Supabase: 'supabase',
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Enum of the supporting third party auth providers.
|
|
193
|
+
* @export
|
|
194
|
+
* @enum {string}
|
|
195
|
+
*/
|
|
196
|
+
const ThirdPartyOAuthProvider = {
|
|
197
|
+
Accelbyte: 'accelbyte',
|
|
198
|
+
Firebase: 'firebase',
|
|
199
|
+
Lootlocker: 'lootlocker',
|
|
200
|
+
Playfab: 'playfab',
|
|
201
|
+
Supabase: 'supabase',
|
|
202
|
+
Custom: 'custom',
|
|
203
|
+
Oidc: 'oidc',
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Enum of the supporting OAuth providers.
|
|
207
|
+
* @export
|
|
208
|
+
* @enum {string}
|
|
209
|
+
*/
|
|
210
|
+
const TokenType = {
|
|
211
|
+
IdToken: 'idToken',
|
|
212
|
+
CustomToken: 'customToken',
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* AuthenticationApi - axios parameter creator
|
|
216
|
+
* @export
|
|
217
|
+
*/
|
|
218
|
+
const AuthenticationApiAxiosParamCreator = function (configuration) {
|
|
219
|
+
return {
|
|
220
|
+
/**
|
|
221
|
+
*
|
|
222
|
+
* @summary Authenticate player with oauth token.
|
|
223
|
+
* @param {AuthenticateOAuthRequest} authenticateOAuthRequest
|
|
224
|
+
* @param {*} [options] Override http request option.
|
|
225
|
+
* @throws {RequiredError}
|
|
226
|
+
*/
|
|
227
|
+
authenticateOAuth: async (authenticateOAuthRequest, options = {}) => {
|
|
228
|
+
// verify required parameter 'authenticateOAuthRequest' is not null or undefined
|
|
229
|
+
assertParamExists('authenticateOAuth', 'authenticateOAuthRequest', authenticateOAuthRequest);
|
|
230
|
+
const localVarPath = `/iam/v1/oauth/authenticate`;
|
|
231
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
232
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
233
|
+
let baseOptions;
|
|
234
|
+
if (configuration) {
|
|
235
|
+
baseOptions = configuration.baseOptions;
|
|
236
|
+
}
|
|
237
|
+
const localVarRequestOptions = {
|
|
238
|
+
method: 'POST',
|
|
239
|
+
...baseOptions,
|
|
240
|
+
...options,
|
|
241
|
+
};
|
|
242
|
+
const localVarHeaderParameter = {};
|
|
243
|
+
const localVarQueryParameter = {};
|
|
244
|
+
// authentication pk required
|
|
245
|
+
// http bearer authentication required
|
|
246
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
247
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
248
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
249
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
250
|
+
localVarRequestOptions.headers = {
|
|
251
|
+
...localVarHeaderParameter,
|
|
252
|
+
...headersFromBaseOptions,
|
|
253
|
+
...options.headers,
|
|
254
|
+
};
|
|
255
|
+
localVarRequestOptions.data = serializeDataIfNeeded(authenticateOAuthRequest, localVarRequestOptions, configuration);
|
|
256
|
+
return {
|
|
257
|
+
url: toPathString(localVarUrlObj),
|
|
258
|
+
options: localVarRequestOptions,
|
|
259
|
+
};
|
|
260
|
+
},
|
|
261
|
+
/**
|
|
262
|
+
*
|
|
263
|
+
* @summary Authenticate player with SIWE
|
|
264
|
+
* @param {SIWEAuthenticateRequest} sIWEAuthenticateRequest
|
|
265
|
+
* @param {*} [options] Override http request option.
|
|
266
|
+
* @throws {RequiredError}
|
|
267
|
+
*/
|
|
268
|
+
authenticateSIWE: async (sIWEAuthenticateRequest, options = {}) => {
|
|
269
|
+
// verify required parameter 'sIWEAuthenticateRequest' is not null or undefined
|
|
270
|
+
assertParamExists('authenticateSIWE', 'sIWEAuthenticateRequest', sIWEAuthenticateRequest);
|
|
271
|
+
const localVarPath = `/iam/v1/siwe/authenticate`;
|
|
272
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
273
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
274
|
+
let baseOptions;
|
|
275
|
+
if (configuration) {
|
|
276
|
+
baseOptions = configuration.baseOptions;
|
|
277
|
+
}
|
|
278
|
+
const localVarRequestOptions = {
|
|
279
|
+
method: 'POST',
|
|
280
|
+
...baseOptions,
|
|
281
|
+
...options,
|
|
282
|
+
};
|
|
283
|
+
const localVarHeaderParameter = {};
|
|
284
|
+
const localVarQueryParameter = {};
|
|
285
|
+
// authentication pk required
|
|
286
|
+
// http bearer authentication required
|
|
287
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
288
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
289
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
290
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
291
|
+
localVarRequestOptions.headers = {
|
|
292
|
+
...localVarHeaderParameter,
|
|
293
|
+
...headersFromBaseOptions,
|
|
294
|
+
...options.headers,
|
|
295
|
+
};
|
|
296
|
+
localVarRequestOptions.data = serializeDataIfNeeded(sIWEAuthenticateRequest, localVarRequestOptions, configuration);
|
|
297
|
+
return {
|
|
298
|
+
url: toPathString(localVarUrlObj),
|
|
299
|
+
options: localVarRequestOptions,
|
|
300
|
+
};
|
|
301
|
+
},
|
|
302
|
+
/**
|
|
303
|
+
* The endpoint verifies the token generated by OAuth provider, creates or retrieves a player based on his email, and returns the jwt token for the player together with the player id.
|
|
304
|
+
* @summary Authorize player with token.
|
|
305
|
+
* @param {OAuthProvider} provider OAuth provider
|
|
306
|
+
* @param {OAuthRequest} oAuthRequest
|
|
307
|
+
* @param {*} [options] Override http request option.
|
|
308
|
+
* @deprecated
|
|
309
|
+
* @throws {RequiredError}
|
|
310
|
+
*/
|
|
311
|
+
authorizeWithOAuthToken: async (provider, oAuthRequest, options = {}) => {
|
|
312
|
+
// verify required parameter 'provider' is not null or undefined
|
|
313
|
+
assertParamExists('authorizeWithOAuthToken', 'provider', provider);
|
|
314
|
+
// verify required parameter 'oAuthRequest' is not null or undefined
|
|
315
|
+
assertParamExists('authorizeWithOAuthToken', 'oAuthRequest', oAuthRequest);
|
|
316
|
+
const localVarPath = `/iam/v1/oauth/{provider}/authorize`.replace(`{${'provider'}}`, encodeURIComponent(String(provider)));
|
|
317
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
318
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
319
|
+
let baseOptions;
|
|
320
|
+
if (configuration) {
|
|
321
|
+
baseOptions = configuration.baseOptions;
|
|
322
|
+
}
|
|
323
|
+
const localVarRequestOptions = {
|
|
324
|
+
method: 'POST',
|
|
325
|
+
...baseOptions,
|
|
326
|
+
...options,
|
|
327
|
+
};
|
|
328
|
+
const localVarHeaderParameter = {};
|
|
329
|
+
const localVarQueryParameter = {};
|
|
330
|
+
// authentication sk required
|
|
331
|
+
// http bearer authentication required
|
|
332
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
333
|
+
// authentication pk required
|
|
334
|
+
// http bearer authentication required
|
|
335
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
336
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
337
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
338
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
339
|
+
localVarRequestOptions.headers = {
|
|
340
|
+
...localVarHeaderParameter,
|
|
341
|
+
...headersFromBaseOptions,
|
|
342
|
+
...options.headers,
|
|
343
|
+
};
|
|
344
|
+
localVarRequestOptions.data = serializeDataIfNeeded(oAuthRequest, localVarRequestOptions, configuration);
|
|
345
|
+
return {
|
|
346
|
+
url: toPathString(localVarUrlObj),
|
|
347
|
+
options: localVarRequestOptions,
|
|
348
|
+
};
|
|
349
|
+
},
|
|
350
|
+
/**
|
|
351
|
+
* Get the jwks.json file. You can use the jwks.json file to verify the signature of a JWT token issued by Openfort Auth.
|
|
352
|
+
* @summary Get the jwks.json file.
|
|
353
|
+
* @param {string} publishableKey Specifies the project publishable key (starts with pk_).
|
|
354
|
+
* @param {*} [options] Override http request option.
|
|
355
|
+
* @throws {RequiredError}
|
|
356
|
+
*/
|
|
357
|
+
getJwks: async (publishableKey, options = {}) => {
|
|
358
|
+
// verify required parameter 'publishableKey' is not null or undefined
|
|
359
|
+
assertParamExists('getJwks', 'publishableKey', publishableKey);
|
|
360
|
+
const localVarPath = `/iam/v1/{publishable_key}/jwks.json`.replace(`{${'publishable_key'}}`, encodeURIComponent(String(publishableKey)));
|
|
361
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
362
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
363
|
+
let baseOptions;
|
|
364
|
+
if (configuration) {
|
|
365
|
+
baseOptions = configuration.baseOptions;
|
|
366
|
+
}
|
|
367
|
+
const localVarRequestOptions = {
|
|
368
|
+
method: 'GET',
|
|
369
|
+
...baseOptions,
|
|
370
|
+
...options,
|
|
371
|
+
};
|
|
372
|
+
const localVarHeaderParameter = {};
|
|
373
|
+
const localVarQueryParameter = {};
|
|
374
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
375
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
376
|
+
localVarRequestOptions.headers = {
|
|
377
|
+
...localVarHeaderParameter,
|
|
378
|
+
...headersFromBaseOptions,
|
|
379
|
+
...options.headers,
|
|
380
|
+
};
|
|
381
|
+
return {
|
|
382
|
+
url: toPathString(localVarUrlObj),
|
|
383
|
+
options: localVarRequestOptions,
|
|
384
|
+
};
|
|
385
|
+
},
|
|
386
|
+
/**
|
|
387
|
+
*
|
|
388
|
+
* @summary Initialize OAuth.
|
|
389
|
+
* @param {OAuthInitRequest} oAuthInitRequest
|
|
390
|
+
* @param {*} [options] Override http request option.
|
|
391
|
+
* @throws {RequiredError}
|
|
392
|
+
*/
|
|
393
|
+
initOAuth: async (oAuthInitRequest, options = {}) => {
|
|
394
|
+
// verify required parameter 'oAuthInitRequest' is not null or undefined
|
|
395
|
+
assertParamExists('initOAuth', 'oAuthInitRequest', oAuthInitRequest);
|
|
396
|
+
const localVarPath = `/iam/v1/oauth/init`;
|
|
397
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
398
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
399
|
+
let baseOptions;
|
|
400
|
+
if (configuration) {
|
|
401
|
+
baseOptions = configuration.baseOptions;
|
|
402
|
+
}
|
|
403
|
+
const localVarRequestOptions = {
|
|
404
|
+
method: 'POST',
|
|
405
|
+
...baseOptions,
|
|
406
|
+
...options,
|
|
407
|
+
};
|
|
408
|
+
const localVarHeaderParameter = {};
|
|
409
|
+
const localVarQueryParameter = {};
|
|
410
|
+
// authentication pk required
|
|
411
|
+
// http bearer authentication required
|
|
412
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
413
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
414
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
415
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
416
|
+
localVarRequestOptions.headers = {
|
|
417
|
+
...localVarHeaderParameter,
|
|
418
|
+
...headersFromBaseOptions,
|
|
419
|
+
...options.headers,
|
|
420
|
+
};
|
|
421
|
+
localVarRequestOptions.data = serializeDataIfNeeded(oAuthInitRequest, localVarRequestOptions, configuration);
|
|
422
|
+
return {
|
|
423
|
+
url: toPathString(localVarUrlObj),
|
|
424
|
+
options: localVarRequestOptions,
|
|
425
|
+
};
|
|
426
|
+
},
|
|
427
|
+
/**
|
|
428
|
+
* Create a challenge to link external wallet to the player.
|
|
429
|
+
* @summary Initialize SIWE.
|
|
430
|
+
* @param {SIWERequest} sIWERequest
|
|
431
|
+
* @param {*} [options] Override http request option.
|
|
432
|
+
* @throws {RequiredError}
|
|
433
|
+
*/
|
|
434
|
+
initSIWE: async (sIWERequest, options = {}) => {
|
|
435
|
+
// verify required parameter 'sIWERequest' is not null or undefined
|
|
436
|
+
assertParamExists('initSIWE', 'sIWERequest', sIWERequest);
|
|
437
|
+
const localVarPath = `/iam/v1/siwe/init`;
|
|
438
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
439
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
440
|
+
let baseOptions;
|
|
441
|
+
if (configuration) {
|
|
442
|
+
baseOptions = configuration.baseOptions;
|
|
443
|
+
}
|
|
444
|
+
const localVarRequestOptions = {
|
|
445
|
+
method: 'POST',
|
|
446
|
+
...baseOptions,
|
|
447
|
+
...options,
|
|
448
|
+
};
|
|
449
|
+
const localVarHeaderParameter = {};
|
|
450
|
+
const localVarQueryParameter = {};
|
|
451
|
+
// authentication pk required
|
|
452
|
+
// http bearer authentication required
|
|
453
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
454
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
455
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
456
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
457
|
+
localVarRequestOptions.headers = {
|
|
458
|
+
...localVarHeaderParameter,
|
|
459
|
+
...headersFromBaseOptions,
|
|
460
|
+
...options.headers,
|
|
461
|
+
};
|
|
462
|
+
localVarRequestOptions.data = serializeDataIfNeeded(sIWERequest, localVarRequestOptions, configuration);
|
|
463
|
+
return {
|
|
464
|
+
url: toPathString(localVarUrlObj),
|
|
465
|
+
options: localVarRequestOptions,
|
|
466
|
+
};
|
|
467
|
+
},
|
|
468
|
+
/**
|
|
469
|
+
*
|
|
470
|
+
* @summary Link external wallet.
|
|
471
|
+
* @param {SIWEAuthenticateRequest} sIWEAuthenticateRequest
|
|
472
|
+
* @param {*} [options] Override http request option.
|
|
473
|
+
* @throws {RequiredError}
|
|
474
|
+
*/
|
|
475
|
+
linkSIWE: async (sIWEAuthenticateRequest, options = {}) => {
|
|
476
|
+
// verify required parameter 'sIWEAuthenticateRequest' is not null or undefined
|
|
477
|
+
assertParamExists('linkSIWE', 'sIWEAuthenticateRequest', sIWEAuthenticateRequest);
|
|
478
|
+
const localVarPath = `/iam/v1/siwe/link`;
|
|
479
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
480
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
481
|
+
let baseOptions;
|
|
482
|
+
if (configuration) {
|
|
483
|
+
baseOptions = configuration.baseOptions;
|
|
484
|
+
}
|
|
485
|
+
const localVarRequestOptions = {
|
|
486
|
+
method: 'POST',
|
|
487
|
+
...baseOptions,
|
|
488
|
+
...options,
|
|
489
|
+
};
|
|
490
|
+
const localVarHeaderParameter = {};
|
|
491
|
+
const localVarQueryParameter = {};
|
|
492
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
493
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
494
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
495
|
+
localVarRequestOptions.headers = {
|
|
496
|
+
...localVarHeaderParameter,
|
|
497
|
+
...headersFromBaseOptions,
|
|
498
|
+
...options.headers,
|
|
499
|
+
};
|
|
500
|
+
localVarRequestOptions.data = serializeDataIfNeeded(sIWEAuthenticateRequest, localVarRequestOptions, configuration);
|
|
501
|
+
return {
|
|
502
|
+
url: toPathString(localVarUrlObj),
|
|
503
|
+
options: localVarRequestOptions,
|
|
504
|
+
};
|
|
505
|
+
},
|
|
506
|
+
/**
|
|
507
|
+
* Authenticate a player based on email and password.
|
|
508
|
+
* @summary Email and password login.
|
|
509
|
+
* @param {LoginRequest} loginRequest
|
|
510
|
+
* @param {*} [options] Override http request option.
|
|
511
|
+
* @throws {RequiredError}
|
|
512
|
+
*/
|
|
513
|
+
loginEmailPassword: async (loginRequest, options = {}) => {
|
|
514
|
+
// verify required parameter 'loginRequest' is not null or undefined
|
|
515
|
+
assertParamExists('loginEmailPassword', 'loginRequest', loginRequest);
|
|
516
|
+
const localVarPath = `/iam/v1/password/login`;
|
|
517
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
518
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
519
|
+
let baseOptions;
|
|
520
|
+
if (configuration) {
|
|
521
|
+
baseOptions = configuration.baseOptions;
|
|
522
|
+
}
|
|
523
|
+
const localVarRequestOptions = {
|
|
524
|
+
method: 'POST',
|
|
525
|
+
...baseOptions,
|
|
526
|
+
...options,
|
|
527
|
+
};
|
|
528
|
+
const localVarHeaderParameter = {};
|
|
529
|
+
const localVarQueryParameter = {};
|
|
530
|
+
// authentication pk required
|
|
531
|
+
// http bearer authentication required
|
|
532
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
533
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
534
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
535
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
536
|
+
localVarRequestOptions.headers = {
|
|
537
|
+
...localVarHeaderParameter,
|
|
538
|
+
...headersFromBaseOptions,
|
|
539
|
+
...options.headers,
|
|
540
|
+
};
|
|
541
|
+
localVarRequestOptions.data = serializeDataIfNeeded(loginRequest, localVarRequestOptions, configuration);
|
|
542
|
+
return {
|
|
543
|
+
url: toPathString(localVarUrlObj),
|
|
544
|
+
options: localVarRequestOptions,
|
|
545
|
+
};
|
|
546
|
+
},
|
|
547
|
+
/**
|
|
548
|
+
* When using Openfort Auth, the endpoint logs out the player.
|
|
549
|
+
* @summary Log out a player.
|
|
550
|
+
* @param {LogoutRequest} logoutRequest
|
|
551
|
+
* @param {*} [options] Override http request option.
|
|
552
|
+
* @throws {RequiredError}
|
|
553
|
+
*/
|
|
554
|
+
logout: async (logoutRequest, options = {}) => {
|
|
555
|
+
// verify required parameter 'logoutRequest' is not null or undefined
|
|
556
|
+
assertParamExists('logout', 'logoutRequest', logoutRequest);
|
|
557
|
+
const localVarPath = `/iam/v1/sessions/logout`;
|
|
558
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
559
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
560
|
+
let baseOptions;
|
|
561
|
+
if (configuration) {
|
|
562
|
+
baseOptions = configuration.baseOptions;
|
|
563
|
+
}
|
|
564
|
+
const localVarRequestOptions = {
|
|
565
|
+
method: 'POST',
|
|
566
|
+
...baseOptions,
|
|
567
|
+
...options,
|
|
568
|
+
};
|
|
569
|
+
const localVarHeaderParameter = {};
|
|
570
|
+
const localVarQueryParameter = {};
|
|
571
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
572
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
573
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
574
|
+
localVarRequestOptions.headers = {
|
|
575
|
+
...localVarHeaderParameter,
|
|
576
|
+
...headersFromBaseOptions,
|
|
577
|
+
...options.headers,
|
|
578
|
+
};
|
|
579
|
+
localVarRequestOptions.data = serializeDataIfNeeded(logoutRequest, localVarRequestOptions, configuration);
|
|
580
|
+
return {
|
|
581
|
+
url: toPathString(localVarUrlObj),
|
|
582
|
+
options: localVarRequestOptions,
|
|
583
|
+
};
|
|
584
|
+
},
|
|
585
|
+
/**
|
|
586
|
+
*
|
|
587
|
+
* @param {*} [options] Override http request option.
|
|
588
|
+
* @throws {RequiredError}
|
|
589
|
+
*/
|
|
590
|
+
me: async (options = {}) => {
|
|
591
|
+
const localVarPath = `/iam/v1/me`;
|
|
592
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
593
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
594
|
+
let baseOptions;
|
|
595
|
+
if (configuration) {
|
|
596
|
+
baseOptions = configuration.baseOptions;
|
|
597
|
+
}
|
|
598
|
+
const localVarRequestOptions = {
|
|
599
|
+
method: 'GET',
|
|
600
|
+
...baseOptions,
|
|
601
|
+
...options,
|
|
602
|
+
};
|
|
603
|
+
const localVarHeaderParameter = {};
|
|
604
|
+
const localVarQueryParameter = {};
|
|
605
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
606
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
607
|
+
localVarRequestOptions.headers = {
|
|
608
|
+
...localVarHeaderParameter,
|
|
609
|
+
...headersFromBaseOptions,
|
|
610
|
+
...options.headers,
|
|
611
|
+
};
|
|
612
|
+
return {
|
|
613
|
+
url: toPathString(localVarUrlObj),
|
|
614
|
+
options: localVarRequestOptions,
|
|
615
|
+
};
|
|
616
|
+
},
|
|
617
|
+
/**
|
|
618
|
+
* Get or create a new session for the player based on the refresh token.
|
|
619
|
+
* @summary Refresh or create auth session.
|
|
620
|
+
* @param {RefreshTokenRequest} refreshTokenRequest
|
|
621
|
+
* @param {*} [options] Override http request option.
|
|
622
|
+
* @throws {RequiredError}
|
|
623
|
+
*/
|
|
624
|
+
refresh: async (refreshTokenRequest, options = {}) => {
|
|
625
|
+
// verify required parameter 'refreshTokenRequest' is not null or undefined
|
|
626
|
+
assertParamExists('refresh', 'refreshTokenRequest', refreshTokenRequest);
|
|
627
|
+
const localVarPath = `/iam/v1/sessions`;
|
|
628
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
629
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
630
|
+
let baseOptions;
|
|
631
|
+
if (configuration) {
|
|
632
|
+
baseOptions = configuration.baseOptions;
|
|
633
|
+
}
|
|
634
|
+
const localVarRequestOptions = {
|
|
635
|
+
method: 'POST',
|
|
636
|
+
...baseOptions,
|
|
637
|
+
...options,
|
|
638
|
+
};
|
|
639
|
+
const localVarHeaderParameter = {};
|
|
640
|
+
const localVarQueryParameter = {};
|
|
641
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
642
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
643
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
644
|
+
localVarRequestOptions.headers = {
|
|
645
|
+
...localVarHeaderParameter,
|
|
646
|
+
...headersFromBaseOptions,
|
|
647
|
+
...options.headers,
|
|
648
|
+
};
|
|
649
|
+
localVarRequestOptions.data = serializeDataIfNeeded(refreshTokenRequest, localVarRequestOptions, configuration);
|
|
650
|
+
return {
|
|
651
|
+
url: toPathString(localVarUrlObj),
|
|
652
|
+
options: localVarRequestOptions,
|
|
653
|
+
};
|
|
654
|
+
},
|
|
655
|
+
/**
|
|
656
|
+
* Create and authenticate a player based on email and password.
|
|
657
|
+
* @summary Email and password signup.
|
|
658
|
+
* @param {SignupRequest} signupRequest
|
|
659
|
+
* @param {*} [options] Override http request option.
|
|
660
|
+
* @throws {RequiredError}
|
|
661
|
+
*/
|
|
662
|
+
signupEmailPassword: async (signupRequest, options = {}) => {
|
|
663
|
+
// verify required parameter 'signupRequest' is not null or undefined
|
|
664
|
+
assertParamExists('signupEmailPassword', 'signupRequest', signupRequest);
|
|
665
|
+
const localVarPath = `/iam/v1/password/signup`;
|
|
666
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
667
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
668
|
+
let baseOptions;
|
|
669
|
+
if (configuration) {
|
|
670
|
+
baseOptions = configuration.baseOptions;
|
|
671
|
+
}
|
|
672
|
+
const localVarRequestOptions = {
|
|
673
|
+
method: 'POST',
|
|
674
|
+
...baseOptions,
|
|
675
|
+
...options,
|
|
676
|
+
};
|
|
677
|
+
const localVarHeaderParameter = {};
|
|
678
|
+
const localVarQueryParameter = {};
|
|
679
|
+
// authentication pk required
|
|
680
|
+
// http bearer authentication required
|
|
681
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
682
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
683
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
684
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
685
|
+
localVarRequestOptions.headers = {
|
|
686
|
+
...localVarHeaderParameter,
|
|
687
|
+
...headersFromBaseOptions,
|
|
688
|
+
...options.headers,
|
|
689
|
+
};
|
|
690
|
+
localVarRequestOptions.data = serializeDataIfNeeded(signupRequest, localVarRequestOptions, configuration);
|
|
691
|
+
return {
|
|
692
|
+
url: toPathString(localVarUrlObj),
|
|
693
|
+
options: localVarRequestOptions,
|
|
694
|
+
};
|
|
695
|
+
},
|
|
696
|
+
/**
|
|
697
|
+
*
|
|
698
|
+
* @summary Verify oauth token of a third party auth provider.
|
|
699
|
+
* @param {ThirdPartyOAuthRequest} thirdPartyOAuthRequest
|
|
700
|
+
* @param {*} [options] Override http request option.
|
|
701
|
+
* @throws {RequiredError}
|
|
702
|
+
*/
|
|
703
|
+
thirdParty: async (thirdPartyOAuthRequest, options = {}) => {
|
|
704
|
+
// verify required parameter 'thirdPartyOAuthRequest' is not null or undefined
|
|
705
|
+
assertParamExists('thirdParty', 'thirdPartyOAuthRequest', thirdPartyOAuthRequest);
|
|
706
|
+
const localVarPath = `/iam/v1/oauth/third_party`;
|
|
707
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
708
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
709
|
+
let baseOptions;
|
|
710
|
+
if (configuration) {
|
|
711
|
+
baseOptions = configuration.baseOptions;
|
|
712
|
+
}
|
|
713
|
+
const localVarRequestOptions = {
|
|
714
|
+
method: 'POST',
|
|
715
|
+
...baseOptions,
|
|
716
|
+
...options,
|
|
717
|
+
};
|
|
718
|
+
const localVarHeaderParameter = {};
|
|
719
|
+
const localVarQueryParameter = {};
|
|
720
|
+
// authentication pk required
|
|
721
|
+
// http bearer authentication required
|
|
722
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
723
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
724
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
725
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
726
|
+
localVarRequestOptions.headers = {
|
|
727
|
+
...localVarHeaderParameter,
|
|
728
|
+
...headersFromBaseOptions,
|
|
729
|
+
...options.headers,
|
|
730
|
+
};
|
|
731
|
+
localVarRequestOptions.data = serializeDataIfNeeded(thirdPartyOAuthRequest, localVarRequestOptions, configuration);
|
|
732
|
+
return {
|
|
733
|
+
url: toPathString(localVarUrlObj),
|
|
734
|
+
options: localVarRequestOptions,
|
|
735
|
+
};
|
|
736
|
+
},
|
|
737
|
+
/**
|
|
738
|
+
*
|
|
739
|
+
* @summary Unlink OAuth account
|
|
740
|
+
* @param {UnlinkRequest} unlinkRequest
|
|
741
|
+
* @param {*} [options] Override http request option.
|
|
742
|
+
* @throws {RequiredError}
|
|
743
|
+
*/
|
|
744
|
+
unlinkOAuth: async (unlinkRequest, options = {}) => {
|
|
745
|
+
// verify required parameter 'unlinkRequest' is not null or undefined
|
|
746
|
+
assertParamExists('unlinkOAuth', 'unlinkRequest', unlinkRequest);
|
|
747
|
+
const localVarPath = `/iam/v1/oauth/unlink`;
|
|
748
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
749
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
750
|
+
let baseOptions;
|
|
751
|
+
if (configuration) {
|
|
752
|
+
baseOptions = configuration.baseOptions;
|
|
753
|
+
}
|
|
754
|
+
const localVarRequestOptions = {
|
|
755
|
+
method: 'POST',
|
|
756
|
+
...baseOptions,
|
|
757
|
+
...options,
|
|
758
|
+
};
|
|
759
|
+
const localVarHeaderParameter = {};
|
|
760
|
+
const localVarQueryParameter = {};
|
|
761
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
762
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
763
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
764
|
+
localVarRequestOptions.headers = {
|
|
765
|
+
...localVarHeaderParameter,
|
|
766
|
+
...headersFromBaseOptions,
|
|
767
|
+
...options.headers,
|
|
768
|
+
};
|
|
769
|
+
localVarRequestOptions.data = serializeDataIfNeeded(unlinkRequest, localVarRequestOptions, configuration);
|
|
770
|
+
return {
|
|
771
|
+
url: toPathString(localVarUrlObj),
|
|
772
|
+
options: localVarRequestOptions,
|
|
773
|
+
};
|
|
774
|
+
},
|
|
775
|
+
/**
|
|
776
|
+
*
|
|
777
|
+
* @summary Unlink external wallet.
|
|
778
|
+
* @param {SIWERequest} sIWERequest
|
|
779
|
+
* @param {*} [options] Override http request option.
|
|
780
|
+
* @throws {RequiredError}
|
|
781
|
+
*/
|
|
782
|
+
unlinkSIWE: async (sIWERequest, options = {}) => {
|
|
783
|
+
// verify required parameter 'sIWERequest' is not null or undefined
|
|
784
|
+
assertParamExists('unlinkSIWE', 'sIWERequest', sIWERequest);
|
|
785
|
+
const localVarPath = `/iam/v1/siwe/unlink`;
|
|
786
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
787
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
788
|
+
let baseOptions;
|
|
789
|
+
if (configuration) {
|
|
790
|
+
baseOptions = configuration.baseOptions;
|
|
791
|
+
}
|
|
792
|
+
const localVarRequestOptions = {
|
|
793
|
+
method: 'POST',
|
|
794
|
+
...baseOptions,
|
|
795
|
+
...options,
|
|
796
|
+
};
|
|
797
|
+
const localVarHeaderParameter = {};
|
|
798
|
+
const localVarQueryParameter = {};
|
|
799
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
800
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
801
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
802
|
+
localVarRequestOptions.headers = {
|
|
803
|
+
...localVarHeaderParameter,
|
|
804
|
+
...headersFromBaseOptions,
|
|
805
|
+
...options.headers,
|
|
806
|
+
};
|
|
807
|
+
localVarRequestOptions.data = serializeDataIfNeeded(sIWERequest, localVarRequestOptions, configuration);
|
|
808
|
+
return {
|
|
809
|
+
url: toPathString(localVarUrlObj),
|
|
810
|
+
options: localVarRequestOptions,
|
|
811
|
+
};
|
|
812
|
+
},
|
|
813
|
+
/**
|
|
814
|
+
* The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player.
|
|
815
|
+
* @summary Retrieve player by token.
|
|
816
|
+
* @param {OAuthProvider} provider OAuth provider
|
|
817
|
+
* @param {OAuthRequest} oAuthRequest
|
|
818
|
+
* @param {*} [options] Override http request option.
|
|
819
|
+
* @deprecated
|
|
820
|
+
* @throws {RequiredError}
|
|
821
|
+
*/
|
|
822
|
+
verifyOAuth: async (provider, oAuthRequest, options = {}) => {
|
|
823
|
+
// verify required parameter 'provider' is not null or undefined
|
|
824
|
+
assertParamExists('verifyOAuth', 'provider', provider);
|
|
825
|
+
// verify required parameter 'oAuthRequest' is not null or undefined
|
|
826
|
+
assertParamExists('verifyOAuth', 'oAuthRequest', oAuthRequest);
|
|
827
|
+
const localVarPath = `/iam/v1/oauth/{provider}/verify`.replace(`{${'provider'}}`, encodeURIComponent(String(provider)));
|
|
828
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
829
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
830
|
+
let baseOptions;
|
|
831
|
+
if (configuration) {
|
|
832
|
+
baseOptions = configuration.baseOptions;
|
|
833
|
+
}
|
|
834
|
+
const localVarRequestOptions = {
|
|
835
|
+
method: 'POST',
|
|
836
|
+
...baseOptions,
|
|
837
|
+
...options,
|
|
838
|
+
};
|
|
839
|
+
const localVarHeaderParameter = {};
|
|
840
|
+
const localVarQueryParameter = {};
|
|
841
|
+
// authentication sk required
|
|
842
|
+
// http bearer authentication required
|
|
843
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
844
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
845
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
846
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
847
|
+
localVarRequestOptions.headers = {
|
|
848
|
+
...localVarHeaderParameter,
|
|
849
|
+
...headersFromBaseOptions,
|
|
850
|
+
...options.headers,
|
|
851
|
+
};
|
|
852
|
+
localVarRequestOptions.data = serializeDataIfNeeded(oAuthRequest, localVarRequestOptions, configuration);
|
|
853
|
+
return {
|
|
854
|
+
url: toPathString(localVarUrlObj),
|
|
855
|
+
options: localVarRequestOptions,
|
|
856
|
+
};
|
|
857
|
+
},
|
|
858
|
+
/**
|
|
859
|
+
* The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player.
|
|
860
|
+
* @summary Retrieve player by oauth token.
|
|
861
|
+
* @param {AuthenticateOAuthRequest} authenticateOAuthRequest
|
|
862
|
+
* @param {*} [options] Override http request option.
|
|
863
|
+
* @throws {RequiredError}
|
|
864
|
+
*/
|
|
865
|
+
verifyOAuthToken: async (authenticateOAuthRequest, options = {}) => {
|
|
866
|
+
// verify required parameter 'authenticateOAuthRequest' is not null or undefined
|
|
867
|
+
assertParamExists('verifyOAuthToken', 'authenticateOAuthRequest', authenticateOAuthRequest);
|
|
868
|
+
const localVarPath = `/iam/v1/oauth/verify`;
|
|
869
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
870
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
871
|
+
let baseOptions;
|
|
872
|
+
if (configuration) {
|
|
873
|
+
baseOptions = configuration.baseOptions;
|
|
874
|
+
}
|
|
875
|
+
const localVarRequestOptions = {
|
|
876
|
+
method: 'POST',
|
|
877
|
+
...baseOptions,
|
|
878
|
+
...options,
|
|
879
|
+
};
|
|
880
|
+
const localVarHeaderParameter = {};
|
|
881
|
+
const localVarQueryParameter = {};
|
|
882
|
+
// authentication sk required
|
|
883
|
+
// http bearer authentication required
|
|
884
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
885
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
886
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
887
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
888
|
+
localVarRequestOptions.headers = {
|
|
889
|
+
...localVarHeaderParameter,
|
|
890
|
+
...headersFromBaseOptions,
|
|
891
|
+
...options.headers,
|
|
892
|
+
};
|
|
893
|
+
localVarRequestOptions.data = serializeDataIfNeeded(authenticateOAuthRequest, localVarRequestOptions, configuration);
|
|
894
|
+
return {
|
|
895
|
+
url: toPathString(localVarUrlObj),
|
|
896
|
+
options: localVarRequestOptions,
|
|
897
|
+
};
|
|
898
|
+
},
|
|
899
|
+
};
|
|
900
|
+
};
|
|
901
|
+
/**
|
|
902
|
+
* AuthenticationApi - functional programming interface
|
|
903
|
+
* @export
|
|
904
|
+
*/
|
|
905
|
+
const AuthenticationApiFp = function (configuration) {
|
|
906
|
+
const localVarAxiosParamCreator = AuthenticationApiAxiosParamCreator(configuration);
|
|
907
|
+
return {
|
|
908
|
+
/**
|
|
909
|
+
*
|
|
910
|
+
* @summary Authenticate player with oauth token.
|
|
911
|
+
* @param {AuthenticateOAuthRequest} authenticateOAuthRequest
|
|
912
|
+
* @param {*} [options] Override http request option.
|
|
913
|
+
* @throws {RequiredError}
|
|
914
|
+
*/
|
|
915
|
+
async authenticateOAuth(authenticateOAuthRequest, options) {
|
|
916
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.authenticateOAuth(authenticateOAuthRequest, options);
|
|
917
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
918
|
+
},
|
|
919
|
+
/**
|
|
920
|
+
*
|
|
921
|
+
* @summary Authenticate player with SIWE
|
|
922
|
+
* @param {SIWEAuthenticateRequest} sIWEAuthenticateRequest
|
|
923
|
+
* @param {*} [options] Override http request option.
|
|
924
|
+
* @throws {RequiredError}
|
|
925
|
+
*/
|
|
926
|
+
async authenticateSIWE(sIWEAuthenticateRequest, options) {
|
|
927
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.authenticateSIWE(sIWEAuthenticateRequest, options);
|
|
928
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
929
|
+
},
|
|
930
|
+
/**
|
|
931
|
+
* The endpoint verifies the token generated by OAuth provider, creates or retrieves a player based on his email, and returns the jwt token for the player together with the player id.
|
|
932
|
+
* @summary Authorize player with token.
|
|
933
|
+
* @param {OAuthProvider} provider OAuth provider
|
|
934
|
+
* @param {OAuthRequest} oAuthRequest
|
|
935
|
+
* @param {*} [options] Override http request option.
|
|
936
|
+
* @deprecated
|
|
937
|
+
* @throws {RequiredError}
|
|
938
|
+
*/
|
|
939
|
+
async authorizeWithOAuthToken(provider, oAuthRequest, options) {
|
|
940
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.authorizeWithOAuthToken(provider, oAuthRequest, options);
|
|
941
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
942
|
+
},
|
|
943
|
+
/**
|
|
944
|
+
* Get the jwks.json file. You can use the jwks.json file to verify the signature of a JWT token issued by Openfort Auth.
|
|
945
|
+
* @summary Get the jwks.json file.
|
|
946
|
+
* @param {string} publishableKey Specifies the project publishable key (starts with pk_).
|
|
947
|
+
* @param {*} [options] Override http request option.
|
|
948
|
+
* @throws {RequiredError}
|
|
949
|
+
*/
|
|
950
|
+
async getJwks(publishableKey, options) {
|
|
951
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.getJwks(publishableKey, options);
|
|
952
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
953
|
+
},
|
|
954
|
+
/**
|
|
955
|
+
*
|
|
956
|
+
* @summary Initialize OAuth.
|
|
957
|
+
* @param {OAuthInitRequest} oAuthInitRequest
|
|
958
|
+
* @param {*} [options] Override http request option.
|
|
959
|
+
* @throws {RequiredError}
|
|
960
|
+
*/
|
|
961
|
+
async initOAuth(oAuthInitRequest, options) {
|
|
962
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.initOAuth(oAuthInitRequest, options);
|
|
963
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
964
|
+
},
|
|
965
|
+
/**
|
|
966
|
+
* Create a challenge to link external wallet to the player.
|
|
967
|
+
* @summary Initialize SIWE.
|
|
968
|
+
* @param {SIWERequest} sIWERequest
|
|
969
|
+
* @param {*} [options] Override http request option.
|
|
970
|
+
* @throws {RequiredError}
|
|
971
|
+
*/
|
|
972
|
+
async initSIWE(sIWERequest, options) {
|
|
973
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.initSIWE(sIWERequest, options);
|
|
974
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
975
|
+
},
|
|
976
|
+
/**
|
|
977
|
+
*
|
|
978
|
+
* @summary Link external wallet.
|
|
979
|
+
* @param {SIWEAuthenticateRequest} sIWEAuthenticateRequest
|
|
980
|
+
* @param {*} [options] Override http request option.
|
|
981
|
+
* @throws {RequiredError}
|
|
982
|
+
*/
|
|
983
|
+
async linkSIWE(sIWEAuthenticateRequest, options) {
|
|
984
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.linkSIWE(sIWEAuthenticateRequest, options);
|
|
985
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
986
|
+
},
|
|
987
|
+
/**
|
|
988
|
+
* Authenticate a player based on email and password.
|
|
989
|
+
* @summary Email and password login.
|
|
990
|
+
* @param {LoginRequest} loginRequest
|
|
991
|
+
* @param {*} [options] Override http request option.
|
|
992
|
+
* @throws {RequiredError}
|
|
993
|
+
*/
|
|
994
|
+
async loginEmailPassword(loginRequest, options) {
|
|
995
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.loginEmailPassword(loginRequest, options);
|
|
996
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
997
|
+
},
|
|
998
|
+
/**
|
|
999
|
+
* When using Openfort Auth, the endpoint logs out the player.
|
|
1000
|
+
* @summary Log out a player.
|
|
1001
|
+
* @param {LogoutRequest} logoutRequest
|
|
1002
|
+
* @param {*} [options] Override http request option.
|
|
1003
|
+
* @throws {RequiredError}
|
|
1004
|
+
*/
|
|
1005
|
+
async logout(logoutRequest, options) {
|
|
1006
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.logout(logoutRequest, options);
|
|
1007
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1008
|
+
},
|
|
1009
|
+
/**
|
|
1010
|
+
*
|
|
1011
|
+
* @param {*} [options] Override http request option.
|
|
1012
|
+
* @throws {RequiredError}
|
|
1013
|
+
*/
|
|
1014
|
+
async me(options) {
|
|
1015
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.me(options);
|
|
1016
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1017
|
+
},
|
|
1018
|
+
/**
|
|
1019
|
+
* Get or create a new session for the player based on the refresh token.
|
|
1020
|
+
* @summary Refresh or create auth session.
|
|
1021
|
+
* @param {RefreshTokenRequest} refreshTokenRequest
|
|
1022
|
+
* @param {*} [options] Override http request option.
|
|
1023
|
+
* @throws {RequiredError}
|
|
1024
|
+
*/
|
|
1025
|
+
async refresh(refreshTokenRequest, options) {
|
|
1026
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.refresh(refreshTokenRequest, options);
|
|
1027
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1028
|
+
},
|
|
1029
|
+
/**
|
|
1030
|
+
* Create and authenticate a player based on email and password.
|
|
1031
|
+
* @summary Email and password signup.
|
|
1032
|
+
* @param {SignupRequest} signupRequest
|
|
1033
|
+
* @param {*} [options] Override http request option.
|
|
1034
|
+
* @throws {RequiredError}
|
|
1035
|
+
*/
|
|
1036
|
+
async signupEmailPassword(signupRequest, options) {
|
|
1037
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.signupEmailPassword(signupRequest, options);
|
|
1038
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1039
|
+
},
|
|
1040
|
+
/**
|
|
1041
|
+
*
|
|
1042
|
+
* @summary Verify oauth token of a third party auth provider.
|
|
1043
|
+
* @param {ThirdPartyOAuthRequest} thirdPartyOAuthRequest
|
|
1044
|
+
* @param {*} [options] Override http request option.
|
|
1045
|
+
* @throws {RequiredError}
|
|
1046
|
+
*/
|
|
1047
|
+
async thirdParty(thirdPartyOAuthRequest, options) {
|
|
1048
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.thirdParty(thirdPartyOAuthRequest, options);
|
|
1049
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1050
|
+
},
|
|
1051
|
+
/**
|
|
1052
|
+
*
|
|
1053
|
+
* @summary Unlink OAuth account
|
|
1054
|
+
* @param {UnlinkRequest} unlinkRequest
|
|
1055
|
+
* @param {*} [options] Override http request option.
|
|
1056
|
+
* @throws {RequiredError}
|
|
1057
|
+
*/
|
|
1058
|
+
async unlinkOAuth(unlinkRequest, options) {
|
|
1059
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.unlinkOAuth(unlinkRequest, options);
|
|
1060
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1061
|
+
},
|
|
1062
|
+
/**
|
|
1063
|
+
*
|
|
1064
|
+
* @summary Unlink external wallet.
|
|
1065
|
+
* @param {SIWERequest} sIWERequest
|
|
1066
|
+
* @param {*} [options] Override http request option.
|
|
1067
|
+
* @throws {RequiredError}
|
|
1068
|
+
*/
|
|
1069
|
+
async unlinkSIWE(sIWERequest, options) {
|
|
1070
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.unlinkSIWE(sIWERequest, options);
|
|
1071
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1072
|
+
},
|
|
1073
|
+
/**
|
|
1074
|
+
* The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player.
|
|
1075
|
+
* @summary Retrieve player by token.
|
|
1076
|
+
* @param {OAuthProvider} provider OAuth provider
|
|
1077
|
+
* @param {OAuthRequest} oAuthRequest
|
|
1078
|
+
* @param {*} [options] Override http request option.
|
|
1079
|
+
* @deprecated
|
|
1080
|
+
* @throws {RequiredError}
|
|
1081
|
+
*/
|
|
1082
|
+
async verifyOAuth(provider, oAuthRequest, options) {
|
|
1083
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.verifyOAuth(provider, oAuthRequest, options);
|
|
1084
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1085
|
+
},
|
|
1086
|
+
/**
|
|
1087
|
+
* The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player.
|
|
1088
|
+
* @summary Retrieve player by oauth token.
|
|
1089
|
+
* @param {AuthenticateOAuthRequest} authenticateOAuthRequest
|
|
1090
|
+
* @param {*} [options] Override http request option.
|
|
1091
|
+
* @throws {RequiredError}
|
|
1092
|
+
*/
|
|
1093
|
+
async verifyOAuthToken(authenticateOAuthRequest, options) {
|
|
1094
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.verifyOAuthToken(authenticateOAuthRequest, options);
|
|
1095
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1096
|
+
},
|
|
1097
|
+
};
|
|
1098
|
+
};
|
|
1099
|
+
/**
|
|
1100
|
+
* AuthenticationApi - object-oriented interface
|
|
1101
|
+
* @export
|
|
1102
|
+
* @class AuthenticationApi
|
|
1103
|
+
* @extends {BaseAPI}
|
|
1104
|
+
*/
|
|
1105
|
+
class AuthenticationApi extends BaseAPI {
|
|
1106
|
+
/**
|
|
1107
|
+
*
|
|
1108
|
+
* @summary Authenticate player with oauth token.
|
|
1109
|
+
* @param {AuthenticateOAuthRequest} authenticateOAuthRequest
|
|
1110
|
+
* @param {*} [options] Override http request option.
|
|
1111
|
+
* @throws {RequiredError}
|
|
1112
|
+
* @memberof AuthenticationApi
|
|
1113
|
+
*/
|
|
1114
|
+
authenticateOAuth(authenticateOAuthRequest, options) {
|
|
1115
|
+
return AuthenticationApiFp(this.configuration)
|
|
1116
|
+
.authenticateOAuth(authenticateOAuthRequest, options)
|
|
1117
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
*
|
|
1121
|
+
* @summary Authenticate player with SIWE
|
|
1122
|
+
* @param {SIWEAuthenticateRequest} sIWEAuthenticateRequest
|
|
1123
|
+
* @param {*} [options] Override http request option.
|
|
1124
|
+
* @throws {RequiredError}
|
|
1125
|
+
* @memberof AuthenticationApi
|
|
1126
|
+
*/
|
|
1127
|
+
authenticateSIWE(sIWEAuthenticateRequest, options) {
|
|
1128
|
+
return AuthenticationApiFp(this.configuration)
|
|
1129
|
+
.authenticateSIWE(sIWEAuthenticateRequest, options)
|
|
1130
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* The endpoint verifies the token generated by OAuth provider, creates or retrieves a player based on his email, and returns the jwt token for the player together with the player id.
|
|
1134
|
+
* @summary Authorize player with token.
|
|
1135
|
+
* @param {OAuthProvider} provider OAuth provider
|
|
1136
|
+
* @param {OAuthRequest} oAuthRequest
|
|
1137
|
+
* @param {*} [options] Override http request option.
|
|
1138
|
+
* @deprecated
|
|
1139
|
+
* @throws {RequiredError}
|
|
1140
|
+
* @memberof AuthenticationApi
|
|
1141
|
+
*/
|
|
1142
|
+
authorizeWithOAuthToken(provider, oAuthRequest, options) {
|
|
1143
|
+
return AuthenticationApiFp(this.configuration)
|
|
1144
|
+
.authorizeWithOAuthToken(provider, oAuthRequest, options)
|
|
1145
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Get the jwks.json file. You can use the jwks.json file to verify the signature of a JWT token issued by Openfort Auth.
|
|
1149
|
+
* @summary Get the jwks.json file.
|
|
1150
|
+
* @param {string} publishableKey Specifies the project publishable key (starts with pk_).
|
|
1151
|
+
* @param {*} [options] Override http request option.
|
|
1152
|
+
* @throws {RequiredError}
|
|
1153
|
+
* @memberof AuthenticationApi
|
|
1154
|
+
*/
|
|
1155
|
+
getJwks(publishableKey, options) {
|
|
1156
|
+
return AuthenticationApiFp(this.configuration)
|
|
1157
|
+
.getJwks(publishableKey, options)
|
|
1158
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
*
|
|
1162
|
+
* @summary Initialize OAuth.
|
|
1163
|
+
* @param {OAuthInitRequest} oAuthInitRequest
|
|
1164
|
+
* @param {*} [options] Override http request option.
|
|
1165
|
+
* @throws {RequiredError}
|
|
1166
|
+
* @memberof AuthenticationApi
|
|
1167
|
+
*/
|
|
1168
|
+
initOAuth(oAuthInitRequest, options) {
|
|
1169
|
+
return AuthenticationApiFp(this.configuration)
|
|
1170
|
+
.initOAuth(oAuthInitRequest, options)
|
|
1171
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Create a challenge to link external wallet to the player.
|
|
1175
|
+
* @summary Initialize SIWE.
|
|
1176
|
+
* @param {SIWERequest} sIWERequest
|
|
1177
|
+
* @param {*} [options] Override http request option.
|
|
1178
|
+
* @throws {RequiredError}
|
|
1179
|
+
* @memberof AuthenticationApi
|
|
1180
|
+
*/
|
|
1181
|
+
initSIWE(sIWERequest, options) {
|
|
1182
|
+
return AuthenticationApiFp(this.configuration)
|
|
1183
|
+
.initSIWE(sIWERequest, options)
|
|
1184
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
*
|
|
1188
|
+
* @summary Link external wallet.
|
|
1189
|
+
* @param {SIWEAuthenticateRequest} sIWEAuthenticateRequest
|
|
1190
|
+
* @param {*} [options] Override http request option.
|
|
1191
|
+
* @throws {RequiredError}
|
|
1192
|
+
* @memberof AuthenticationApi
|
|
1193
|
+
*/
|
|
1194
|
+
linkSIWE(sIWEAuthenticateRequest, options) {
|
|
1195
|
+
return AuthenticationApiFp(this.configuration)
|
|
1196
|
+
.linkSIWE(sIWEAuthenticateRequest, options)
|
|
1197
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Authenticate a player based on email and password.
|
|
1201
|
+
* @summary Email and password login.
|
|
1202
|
+
* @param {LoginRequest} loginRequest
|
|
1203
|
+
* @param {*} [options] Override http request option.
|
|
1204
|
+
* @throws {RequiredError}
|
|
1205
|
+
* @memberof AuthenticationApi
|
|
1206
|
+
*/
|
|
1207
|
+
loginEmailPassword(loginRequest, options) {
|
|
1208
|
+
return AuthenticationApiFp(this.configuration)
|
|
1209
|
+
.loginEmailPassword(loginRequest, options)
|
|
1210
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* When using Openfort Auth, the endpoint logs out the player.
|
|
1214
|
+
* @summary Log out a player.
|
|
1215
|
+
* @param {LogoutRequest} logoutRequest
|
|
1216
|
+
* @param {*} [options] Override http request option.
|
|
1217
|
+
* @throws {RequiredError}
|
|
1218
|
+
* @memberof AuthenticationApi
|
|
1219
|
+
*/
|
|
1220
|
+
logout(logoutRequest, options) {
|
|
1221
|
+
return AuthenticationApiFp(this.configuration)
|
|
1222
|
+
.logout(logoutRequest, options)
|
|
1223
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
*
|
|
1227
|
+
* @param {*} [options] Override http request option.
|
|
1228
|
+
* @throws {RequiredError}
|
|
1229
|
+
* @memberof AuthenticationApi
|
|
1230
|
+
*/
|
|
1231
|
+
me(options) {
|
|
1232
|
+
return AuthenticationApiFp(this.configuration)
|
|
1233
|
+
.me(options)
|
|
1234
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Get or create a new session for the player based on the refresh token.
|
|
1238
|
+
* @summary Refresh or create auth session.
|
|
1239
|
+
* @param {RefreshTokenRequest} refreshTokenRequest
|
|
1240
|
+
* @param {*} [options] Override http request option.
|
|
1241
|
+
* @throws {RequiredError}
|
|
1242
|
+
* @memberof AuthenticationApi
|
|
1243
|
+
*/
|
|
1244
|
+
refresh(refreshTokenRequest, options) {
|
|
1245
|
+
return AuthenticationApiFp(this.configuration)
|
|
1246
|
+
.refresh(refreshTokenRequest, options)
|
|
1247
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Create and authenticate a player based on email and password.
|
|
1251
|
+
* @summary Email and password signup.
|
|
1252
|
+
* @param {SignupRequest} signupRequest
|
|
1253
|
+
* @param {*} [options] Override http request option.
|
|
1254
|
+
* @throws {RequiredError}
|
|
1255
|
+
* @memberof AuthenticationApi
|
|
1256
|
+
*/
|
|
1257
|
+
signupEmailPassword(signupRequest, options) {
|
|
1258
|
+
return AuthenticationApiFp(this.configuration)
|
|
1259
|
+
.signupEmailPassword(signupRequest, options)
|
|
1260
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
*
|
|
1264
|
+
* @summary Verify oauth token of a third party auth provider.
|
|
1265
|
+
* @param {ThirdPartyOAuthRequest} thirdPartyOAuthRequest
|
|
1266
|
+
* @param {*} [options] Override http request option.
|
|
1267
|
+
* @throws {RequiredError}
|
|
1268
|
+
* @memberof AuthenticationApi
|
|
1269
|
+
*/
|
|
1270
|
+
thirdParty(thirdPartyOAuthRequest, options) {
|
|
1271
|
+
return AuthenticationApiFp(this.configuration)
|
|
1272
|
+
.thirdParty(thirdPartyOAuthRequest, options)
|
|
1273
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
*
|
|
1277
|
+
* @summary Unlink OAuth account
|
|
1278
|
+
* @param {UnlinkRequest} unlinkRequest
|
|
1279
|
+
* @param {*} [options] Override http request option.
|
|
1280
|
+
* @throws {RequiredError}
|
|
1281
|
+
* @memberof AuthenticationApi
|
|
1282
|
+
*/
|
|
1283
|
+
unlinkOAuth(unlinkRequest, options) {
|
|
1284
|
+
return AuthenticationApiFp(this.configuration)
|
|
1285
|
+
.unlinkOAuth(unlinkRequest, options)
|
|
1286
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
*
|
|
1290
|
+
* @summary Unlink external wallet.
|
|
1291
|
+
* @param {SIWERequest} sIWERequest
|
|
1292
|
+
* @param {*} [options] Override http request option.
|
|
1293
|
+
* @throws {RequiredError}
|
|
1294
|
+
* @memberof AuthenticationApi
|
|
1295
|
+
*/
|
|
1296
|
+
unlinkSIWE(sIWERequest, options) {
|
|
1297
|
+
return AuthenticationApiFp(this.configuration)
|
|
1298
|
+
.unlinkSIWE(sIWERequest, options)
|
|
1299
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player.
|
|
1303
|
+
* @summary Retrieve player by token.
|
|
1304
|
+
* @param {OAuthProvider} provider OAuth provider
|
|
1305
|
+
* @param {OAuthRequest} oAuthRequest
|
|
1306
|
+
* @param {*} [options] Override http request option.
|
|
1307
|
+
* @deprecated
|
|
1308
|
+
* @throws {RequiredError}
|
|
1309
|
+
* @memberof AuthenticationApi
|
|
1310
|
+
*/
|
|
1311
|
+
verifyOAuth(provider, oAuthRequest, options) {
|
|
1312
|
+
return AuthenticationApiFp(this.configuration)
|
|
1313
|
+
.verifyOAuth(provider, oAuthRequest, options)
|
|
1314
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player.
|
|
1318
|
+
* @summary Retrieve player by oauth token.
|
|
1319
|
+
* @param {AuthenticateOAuthRequest} authenticateOAuthRequest
|
|
1320
|
+
* @param {*} [options] Override http request option.
|
|
1321
|
+
* @throws {RequiredError}
|
|
1322
|
+
* @memberof AuthenticationApi
|
|
1323
|
+
*/
|
|
1324
|
+
verifyOAuthToken(authenticateOAuthRequest, options) {
|
|
1325
|
+
return AuthenticationApiFp(this.configuration)
|
|
1326
|
+
.verifyOAuthToken(authenticateOAuthRequest, options)
|
|
1327
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* SessionsApi - axios parameter creator
|
|
1332
|
+
* @export
|
|
1333
|
+
*/
|
|
1334
|
+
const SessionsApiAxiosParamCreator = function (configuration) {
|
|
1335
|
+
return {
|
|
1336
|
+
/**
|
|
1337
|
+
* Creates a Session.
|
|
1338
|
+
* @summary Create a session key.
|
|
1339
|
+
* @param {CreateSessionRequest} createSessionRequest
|
|
1340
|
+
* @param {*} [options] Override http request option.
|
|
1341
|
+
* @throws {RequiredError}
|
|
1342
|
+
*/
|
|
1343
|
+
createSession: async (createSessionRequest, options = {}) => {
|
|
1344
|
+
// verify required parameter 'createSessionRequest' is not null or undefined
|
|
1345
|
+
assertParamExists('createSession', 'createSessionRequest', createSessionRequest);
|
|
1346
|
+
const localVarPath = `/v1/sessions`;
|
|
1347
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
1348
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
1349
|
+
let baseOptions;
|
|
1350
|
+
if (configuration) {
|
|
1351
|
+
baseOptions = configuration.baseOptions;
|
|
1352
|
+
}
|
|
1353
|
+
const localVarRequestOptions = {
|
|
1354
|
+
method: 'POST',
|
|
1355
|
+
...baseOptions,
|
|
1356
|
+
...options,
|
|
1357
|
+
};
|
|
1358
|
+
const localVarHeaderParameter = {};
|
|
1359
|
+
const localVarQueryParameter = {};
|
|
1360
|
+
// authentication sk required
|
|
1361
|
+
// http bearer authentication required
|
|
1362
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1363
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
1364
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1365
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1366
|
+
localVarRequestOptions.headers = {
|
|
1367
|
+
...localVarHeaderParameter,
|
|
1368
|
+
...headersFromBaseOptions,
|
|
1369
|
+
...options.headers,
|
|
1370
|
+
};
|
|
1371
|
+
localVarRequestOptions.data = serializeDataIfNeeded(createSessionRequest, localVarRequestOptions, configuration);
|
|
1372
|
+
return {
|
|
1373
|
+
url: toPathString(localVarUrlObj),
|
|
1374
|
+
options: localVarRequestOptions,
|
|
1375
|
+
};
|
|
1376
|
+
},
|
|
1377
|
+
/**
|
|
1378
|
+
* Returns a list of Sessions.
|
|
1379
|
+
* @summary List session keys of a player.
|
|
1380
|
+
* @param {string} player The player ID (starts with pla_)
|
|
1381
|
+
* @param {number} [limit] Specifies the maximum number of records to return.
|
|
1382
|
+
* @param {number} [skip] Specifies the offset for the first records to return.
|
|
1383
|
+
* @param {SortOrder} [order] Specifies the order in which to sort the results.
|
|
1384
|
+
* @param {Array<SessionResponseExpandable>} [expand] Specifies the fields to expand in the response.
|
|
1385
|
+
* @param {*} [options] Override http request option.
|
|
1386
|
+
* @throws {RequiredError}
|
|
1387
|
+
*/
|
|
1388
|
+
getPlayerSessions: async (player, limit, skip, order, expand, options = {}) => {
|
|
1389
|
+
// verify required parameter 'player' is not null or undefined
|
|
1390
|
+
assertParamExists('getPlayerSessions', 'player', player);
|
|
1391
|
+
const localVarPath = `/v1/sessions`;
|
|
1392
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
1393
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
1394
|
+
let baseOptions;
|
|
1395
|
+
if (configuration) {
|
|
1396
|
+
baseOptions = configuration.baseOptions;
|
|
1397
|
+
}
|
|
1398
|
+
const localVarRequestOptions = {
|
|
1399
|
+
method: 'GET',
|
|
1400
|
+
...baseOptions,
|
|
1401
|
+
...options,
|
|
1402
|
+
};
|
|
1403
|
+
const localVarHeaderParameter = {};
|
|
1404
|
+
const localVarQueryParameter = {};
|
|
1405
|
+
// authentication sk required
|
|
1406
|
+
// http bearer authentication required
|
|
1407
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1408
|
+
if (limit !== undefined) {
|
|
1409
|
+
localVarQueryParameter['limit'] = limit;
|
|
1410
|
+
}
|
|
1411
|
+
if (skip !== undefined) {
|
|
1412
|
+
localVarQueryParameter['skip'] = skip;
|
|
1413
|
+
}
|
|
1414
|
+
if (order !== undefined) {
|
|
1415
|
+
localVarQueryParameter['order'] = order;
|
|
1416
|
+
}
|
|
1417
|
+
if (player !== undefined) {
|
|
1418
|
+
localVarQueryParameter['player'] = player;
|
|
1419
|
+
}
|
|
1420
|
+
if (expand) {
|
|
1421
|
+
localVarQueryParameter['expand'] = expand;
|
|
1422
|
+
}
|
|
1423
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1424
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1425
|
+
localVarRequestOptions.headers = {
|
|
1426
|
+
...localVarHeaderParameter,
|
|
1427
|
+
...headersFromBaseOptions,
|
|
1428
|
+
...options.headers,
|
|
1429
|
+
};
|
|
1430
|
+
return {
|
|
1431
|
+
url: toPathString(localVarUrlObj),
|
|
1432
|
+
options: localVarRequestOptions,
|
|
1433
|
+
};
|
|
1434
|
+
},
|
|
1435
|
+
/**
|
|
1436
|
+
* Retrieves the details of a Session that has previously been created.
|
|
1437
|
+
* @summary Returns a player session by session id
|
|
1438
|
+
* @param {string} id Specifies the unique session ID (starts with ses_).
|
|
1439
|
+
* @param {Array<SessionResponseExpandable>} [expand] Specifies the fields to expand.
|
|
1440
|
+
* @param {*} [options] Override http request option.
|
|
1441
|
+
* @throws {RequiredError}
|
|
1442
|
+
*/
|
|
1443
|
+
getSession: async (id, expand, options = {}) => {
|
|
1444
|
+
// verify required parameter 'id' is not null or undefined
|
|
1445
|
+
assertParamExists('getSession', 'id', id);
|
|
1446
|
+
const localVarPath = `/v1/sessions/{id}`.replace(`{${'id'}}`, encodeURIComponent(String(id)));
|
|
1447
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
1448
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
1449
|
+
let baseOptions;
|
|
1450
|
+
if (configuration) {
|
|
1451
|
+
baseOptions = configuration.baseOptions;
|
|
1452
|
+
}
|
|
1453
|
+
const localVarRequestOptions = {
|
|
1454
|
+
method: 'GET',
|
|
1455
|
+
...baseOptions,
|
|
1456
|
+
...options,
|
|
1457
|
+
};
|
|
1458
|
+
const localVarHeaderParameter = {};
|
|
1459
|
+
const localVarQueryParameter = {};
|
|
1460
|
+
// authentication sk required
|
|
1461
|
+
// http bearer authentication required
|
|
1462
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1463
|
+
if (expand) {
|
|
1464
|
+
localVarQueryParameter['expand'] = expand;
|
|
1465
|
+
}
|
|
1466
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1467
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1468
|
+
localVarRequestOptions.headers = {
|
|
1469
|
+
...localVarHeaderParameter,
|
|
1470
|
+
...headersFromBaseOptions,
|
|
1471
|
+
...options.headers,
|
|
1472
|
+
};
|
|
1473
|
+
return {
|
|
1474
|
+
url: toPathString(localVarUrlObj),
|
|
1475
|
+
options: localVarRequestOptions,
|
|
1476
|
+
};
|
|
1477
|
+
},
|
|
1478
|
+
/**
|
|
1479
|
+
*
|
|
1480
|
+
* @summary Revoke the session session key.
|
|
1481
|
+
* @param {RevokeSessionRequest} revokeSessionRequest
|
|
1482
|
+
* @param {*} [options] Override http request option.
|
|
1483
|
+
* @throws {RequiredError}
|
|
1484
|
+
*/
|
|
1485
|
+
revokeSession: async (revokeSessionRequest, options = {}) => {
|
|
1486
|
+
// verify required parameter 'revokeSessionRequest' is not null or undefined
|
|
1487
|
+
assertParamExists('revokeSession', 'revokeSessionRequest', revokeSessionRequest);
|
|
1488
|
+
const localVarPath = `/v1/sessions/revoke`;
|
|
1489
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
1490
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
1491
|
+
let baseOptions;
|
|
1492
|
+
if (configuration) {
|
|
1493
|
+
baseOptions = configuration.baseOptions;
|
|
1494
|
+
}
|
|
1495
|
+
const localVarRequestOptions = {
|
|
1496
|
+
method: 'POST',
|
|
1497
|
+
...baseOptions,
|
|
1498
|
+
...options,
|
|
1499
|
+
};
|
|
1500
|
+
const localVarHeaderParameter = {};
|
|
1501
|
+
const localVarQueryParameter = {};
|
|
1502
|
+
// authentication sk required
|
|
1503
|
+
// http bearer authentication required
|
|
1504
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1505
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
1506
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1507
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1508
|
+
localVarRequestOptions.headers = {
|
|
1509
|
+
...localVarHeaderParameter,
|
|
1510
|
+
...headersFromBaseOptions,
|
|
1511
|
+
...options.headers,
|
|
1512
|
+
};
|
|
1513
|
+
localVarRequestOptions.data = serializeDataIfNeeded(revokeSessionRequest, localVarRequestOptions, configuration);
|
|
1514
|
+
return {
|
|
1515
|
+
url: toPathString(localVarUrlObj),
|
|
1516
|
+
options: localVarRequestOptions,
|
|
1517
|
+
};
|
|
1518
|
+
},
|
|
1519
|
+
/**
|
|
1520
|
+
*
|
|
1521
|
+
* @summary Send signed userOperationHash to create session.
|
|
1522
|
+
* @param {string} id Specifies the unique session ID (starts with ses_).
|
|
1523
|
+
* @param {SignatureRequest} signatureRequest
|
|
1524
|
+
* @param {*} [options] Override http request option.
|
|
1525
|
+
* @throws {RequiredError}
|
|
1526
|
+
*/
|
|
1527
|
+
signatureSession: async (id, signatureRequest, options = {}) => {
|
|
1528
|
+
// verify required parameter 'id' is not null or undefined
|
|
1529
|
+
assertParamExists('signatureSession', 'id', id);
|
|
1530
|
+
// verify required parameter 'signatureRequest' is not null or undefined
|
|
1531
|
+
assertParamExists('signatureSession', 'signatureRequest', signatureRequest);
|
|
1532
|
+
const localVarPath = `/v1/sessions/{id}/signature`.replace(`{${'id'}}`, encodeURIComponent(String(id)));
|
|
1533
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
1534
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
1535
|
+
let baseOptions;
|
|
1536
|
+
if (configuration) {
|
|
1537
|
+
baseOptions = configuration.baseOptions;
|
|
1538
|
+
}
|
|
1539
|
+
const localVarRequestOptions = {
|
|
1540
|
+
method: 'POST',
|
|
1541
|
+
...baseOptions,
|
|
1542
|
+
...options,
|
|
1543
|
+
};
|
|
1544
|
+
const localVarHeaderParameter = {};
|
|
1545
|
+
const localVarQueryParameter = {};
|
|
1546
|
+
// authentication sk required
|
|
1547
|
+
// http bearer authentication required
|
|
1548
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1549
|
+
// authentication pk required
|
|
1550
|
+
// http bearer authentication required
|
|
1551
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1552
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
1553
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1554
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1555
|
+
localVarRequestOptions.headers = {
|
|
1556
|
+
...localVarHeaderParameter,
|
|
1557
|
+
...headersFromBaseOptions,
|
|
1558
|
+
...options.headers,
|
|
1559
|
+
};
|
|
1560
|
+
localVarRequestOptions.data = serializeDataIfNeeded(signatureRequest, localVarRequestOptions, configuration);
|
|
1561
|
+
return {
|
|
1562
|
+
url: toPathString(localVarUrlObj),
|
|
1563
|
+
options: localVarRequestOptions,
|
|
1564
|
+
};
|
|
1565
|
+
},
|
|
1566
|
+
};
|
|
1567
|
+
};
|
|
1568
|
+
/**
|
|
1569
|
+
* SessionsApi - functional programming interface
|
|
1570
|
+
* @export
|
|
1571
|
+
*/
|
|
1572
|
+
const SessionsApiFp = function (configuration) {
|
|
1573
|
+
const localVarAxiosParamCreator = SessionsApiAxiosParamCreator(configuration);
|
|
1574
|
+
return {
|
|
1575
|
+
/**
|
|
1576
|
+
* Creates a Session.
|
|
1577
|
+
* @summary Create a session key.
|
|
1578
|
+
* @param {CreateSessionRequest} createSessionRequest
|
|
1579
|
+
* @param {*} [options] Override http request option.
|
|
1580
|
+
* @throws {RequiredError}
|
|
1581
|
+
*/
|
|
1582
|
+
async createSession(createSessionRequest, options) {
|
|
1583
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.createSession(createSessionRequest, options);
|
|
1584
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1585
|
+
},
|
|
1586
|
+
/**
|
|
1587
|
+
* Returns a list of Sessions.
|
|
1588
|
+
* @summary List session keys of a player.
|
|
1589
|
+
* @param {string} player The player ID (starts with pla_)
|
|
1590
|
+
* @param {number} [limit] Specifies the maximum number of records to return.
|
|
1591
|
+
* @param {number} [skip] Specifies the offset for the first records to return.
|
|
1592
|
+
* @param {SortOrder} [order] Specifies the order in which to sort the results.
|
|
1593
|
+
* @param {Array<SessionResponseExpandable>} [expand] Specifies the fields to expand in the response.
|
|
1594
|
+
* @param {*} [options] Override http request option.
|
|
1595
|
+
* @throws {RequiredError}
|
|
1596
|
+
*/
|
|
1597
|
+
async getPlayerSessions(player, limit, skip, order, expand, options) {
|
|
1598
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.getPlayerSessions(player, limit, skip, order, expand, options);
|
|
1599
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1600
|
+
},
|
|
1601
|
+
/**
|
|
1602
|
+
* Retrieves the details of a Session that has previously been created.
|
|
1603
|
+
* @summary Returns a player session by session id
|
|
1604
|
+
* @param {string} id Specifies the unique session ID (starts with ses_).
|
|
1605
|
+
* @param {Array<SessionResponseExpandable>} [expand] Specifies the fields to expand.
|
|
1606
|
+
* @param {*} [options] Override http request option.
|
|
1607
|
+
* @throws {RequiredError}
|
|
1608
|
+
*/
|
|
1609
|
+
async getSession(id, expand, options) {
|
|
1610
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.getSession(id, expand, options);
|
|
1611
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1612
|
+
},
|
|
1613
|
+
/**
|
|
1614
|
+
*
|
|
1615
|
+
* @summary Revoke the session session key.
|
|
1616
|
+
* @param {RevokeSessionRequest} revokeSessionRequest
|
|
1617
|
+
* @param {*} [options] Override http request option.
|
|
1618
|
+
* @throws {RequiredError}
|
|
1619
|
+
*/
|
|
1620
|
+
async revokeSession(revokeSessionRequest, options) {
|
|
1621
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.revokeSession(revokeSessionRequest, options);
|
|
1622
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1623
|
+
},
|
|
1624
|
+
/**
|
|
1625
|
+
*
|
|
1626
|
+
* @summary Send signed userOperationHash to create session.
|
|
1627
|
+
* @param {string} id Specifies the unique session ID (starts with ses_).
|
|
1628
|
+
* @param {SignatureRequest} signatureRequest
|
|
1629
|
+
* @param {*} [options] Override http request option.
|
|
1630
|
+
* @throws {RequiredError}
|
|
1631
|
+
*/
|
|
1632
|
+
async signatureSession(id, signatureRequest, options) {
|
|
1633
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.signatureSession(id, signatureRequest, options);
|
|
1634
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1635
|
+
},
|
|
1636
|
+
};
|
|
1637
|
+
};
|
|
1638
|
+
/**
|
|
1639
|
+
* SessionsApi - object-oriented interface
|
|
1640
|
+
* @export
|
|
1641
|
+
* @class SessionsApi
|
|
1642
|
+
* @extends {BaseAPI}
|
|
1643
|
+
*/
|
|
1644
|
+
class SessionsApi extends BaseAPI {
|
|
1645
|
+
/**
|
|
1646
|
+
* Creates a Session.
|
|
1647
|
+
* @summary Create a session key.
|
|
1648
|
+
* @param {CreateSessionRequest} createSessionRequest
|
|
1649
|
+
* @param {*} [options] Override http request option.
|
|
1650
|
+
* @throws {RequiredError}
|
|
1651
|
+
* @memberof SessionsApi
|
|
1652
|
+
*/
|
|
1653
|
+
createSession(createSessionRequest, options) {
|
|
1654
|
+
return SessionsApiFp(this.configuration)
|
|
1655
|
+
.createSession(createSessionRequest, options)
|
|
1656
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1657
|
+
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Returns a list of Sessions.
|
|
1660
|
+
* @summary List session keys of a player.
|
|
1661
|
+
* @param {string} player The player ID (starts with pla_)
|
|
1662
|
+
* @param {number} [limit] Specifies the maximum number of records to return.
|
|
1663
|
+
* @param {number} [skip] Specifies the offset for the first records to return.
|
|
1664
|
+
* @param {SortOrder} [order] Specifies the order in which to sort the results.
|
|
1665
|
+
* @param {Array<SessionResponseExpandable>} [expand] Specifies the fields to expand in the response.
|
|
1666
|
+
* @param {*} [options] Override http request option.
|
|
1667
|
+
* @throws {RequiredError}
|
|
1668
|
+
* @memberof SessionsApi
|
|
1669
|
+
*/
|
|
1670
|
+
getPlayerSessions(player, limit, skip, order, expand, options) {
|
|
1671
|
+
return SessionsApiFp(this.configuration)
|
|
1672
|
+
.getPlayerSessions(player, limit, skip, order, expand, options)
|
|
1673
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1674
|
+
}
|
|
1675
|
+
/**
|
|
1676
|
+
* Retrieves the details of a Session that has previously been created.
|
|
1677
|
+
* @summary Returns a player session by session id
|
|
1678
|
+
* @param {string} id Specifies the unique session ID (starts with ses_).
|
|
1679
|
+
* @param {Array<SessionResponseExpandable>} [expand] Specifies the fields to expand.
|
|
1680
|
+
* @param {*} [options] Override http request option.
|
|
1681
|
+
* @throws {RequiredError}
|
|
1682
|
+
* @memberof SessionsApi
|
|
1683
|
+
*/
|
|
1684
|
+
getSession(id, expand, options) {
|
|
1685
|
+
return SessionsApiFp(this.configuration)
|
|
1686
|
+
.getSession(id, expand, options)
|
|
1687
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1688
|
+
}
|
|
1689
|
+
/**
|
|
1690
|
+
*
|
|
1691
|
+
* @summary Revoke the session session key.
|
|
1692
|
+
* @param {RevokeSessionRequest} revokeSessionRequest
|
|
1693
|
+
* @param {*} [options] Override http request option.
|
|
1694
|
+
* @throws {RequiredError}
|
|
1695
|
+
* @memberof SessionsApi
|
|
1696
|
+
*/
|
|
1697
|
+
revokeSession(revokeSessionRequest, options) {
|
|
1698
|
+
return SessionsApiFp(this.configuration)
|
|
1699
|
+
.revokeSession(revokeSessionRequest, options)
|
|
1700
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1701
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
*
|
|
1704
|
+
* @summary Send signed userOperationHash to create session.
|
|
1705
|
+
* @param {string} id Specifies the unique session ID (starts with ses_).
|
|
1706
|
+
* @param {SignatureRequest} signatureRequest
|
|
1707
|
+
* @param {*} [options] Override http request option.
|
|
1708
|
+
* @throws {RequiredError}
|
|
1709
|
+
* @memberof SessionsApi
|
|
1710
|
+
*/
|
|
1711
|
+
signatureSession(id, signatureRequest, options) {
|
|
1712
|
+
return SessionsApiFp(this.configuration)
|
|
1713
|
+
.signatureSession(id, signatureRequest, options)
|
|
1714
|
+
.then((request) => request(this.axios, this.basePath));
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* TransactionIntentsApi - axios parameter creator
|
|
1719
|
+
* @export
|
|
1720
|
+
*/
|
|
1721
|
+
const TransactionIntentsApiAxiosParamCreator = function (configuration) {
|
|
1722
|
+
return {
|
|
1723
|
+
/**
|
|
1724
|
+
* Creates a TransactionIntent. A pending TransactionIntent has the `response` attribute as undefined. After the TransactionIntent is created and broadcasted to the blockchain, `response` will be populated with the transaction hash and a status (1 success, 0 fail). When using a non-custodial account, a `nextAction` attribute is returned with the `userOperationHash` that must be signed by the owner of the account.
|
|
1725
|
+
* @summary Create a transaction intent object.
|
|
1726
|
+
* @param {CreateTransactionIntentRequest} createTransactionIntentRequest
|
|
1727
|
+
* @param {*} [options] Override http request option.
|
|
1728
|
+
* @throws {RequiredError}
|
|
1729
|
+
*/
|
|
1730
|
+
createTransactionIntent: async (createTransactionIntentRequest, options = {}) => {
|
|
1731
|
+
// verify required parameter 'createTransactionIntentRequest' is not null or undefined
|
|
1732
|
+
assertParamExists('createTransactionIntent', 'createTransactionIntentRequest', createTransactionIntentRequest);
|
|
1733
|
+
const localVarPath = `/v1/transaction_intents`;
|
|
1734
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
1735
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
1736
|
+
let baseOptions;
|
|
1737
|
+
if (configuration) {
|
|
1738
|
+
baseOptions = configuration.baseOptions;
|
|
1739
|
+
}
|
|
1740
|
+
const localVarRequestOptions = {
|
|
1741
|
+
method: 'POST',
|
|
1742
|
+
...baseOptions,
|
|
1743
|
+
...options,
|
|
1744
|
+
};
|
|
1745
|
+
const localVarHeaderParameter = {};
|
|
1746
|
+
const localVarQueryParameter = {};
|
|
1747
|
+
// authentication sk required
|
|
1748
|
+
// http bearer authentication required
|
|
1749
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1750
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
1751
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1752
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1753
|
+
localVarRequestOptions.headers = {
|
|
1754
|
+
...localVarHeaderParameter,
|
|
1755
|
+
...headersFromBaseOptions,
|
|
1756
|
+
...options.headers,
|
|
1757
|
+
};
|
|
1758
|
+
localVarRequestOptions.data = serializeDataIfNeeded(createTransactionIntentRequest, localVarRequestOptions, configuration);
|
|
1759
|
+
return {
|
|
1760
|
+
url: toPathString(localVarUrlObj),
|
|
1761
|
+
options: localVarRequestOptions,
|
|
1762
|
+
};
|
|
1763
|
+
},
|
|
1764
|
+
/**
|
|
1765
|
+
* Estimate the gas cost of broadcasting a TransactionIntent. This is a simulation, it does not send the transaction on-chain. If a Policy ID is used that includes payment of gas in ERC-20 tokens, an extra field `estimatedTXGasFeeToken` is returned with the estimated amount of tokens that will be used.
|
|
1766
|
+
* @summary Estimate gas cost of creating a transaction
|
|
1767
|
+
* @param {CreateTransactionIntentRequest} createTransactionIntentRequest
|
|
1768
|
+
* @param {*} [options] Override http request option.
|
|
1769
|
+
* @throws {RequiredError}
|
|
1770
|
+
*/
|
|
1771
|
+
estimateTransactionIntentCost: async (createTransactionIntentRequest, options = {}) => {
|
|
1772
|
+
// verify required parameter 'createTransactionIntentRequest' is not null or undefined
|
|
1773
|
+
assertParamExists('estimateTransactionIntentCost', 'createTransactionIntentRequest', createTransactionIntentRequest);
|
|
1774
|
+
const localVarPath = `/v1/transaction_intents/estimate_gas_cost`;
|
|
1775
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
1776
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
1777
|
+
let baseOptions;
|
|
1778
|
+
if (configuration) {
|
|
1779
|
+
baseOptions = configuration.baseOptions;
|
|
1780
|
+
}
|
|
1781
|
+
const localVarRequestOptions = {
|
|
1782
|
+
method: 'POST',
|
|
1783
|
+
...baseOptions,
|
|
1784
|
+
...options,
|
|
1785
|
+
};
|
|
1786
|
+
const localVarHeaderParameter = {};
|
|
1787
|
+
const localVarQueryParameter = {};
|
|
1788
|
+
// authentication sk required
|
|
1789
|
+
// http bearer authentication required
|
|
1790
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1791
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
1792
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1793
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1794
|
+
localVarRequestOptions.headers = {
|
|
1795
|
+
...localVarHeaderParameter,
|
|
1796
|
+
...headersFromBaseOptions,
|
|
1797
|
+
...options.headers,
|
|
1798
|
+
};
|
|
1799
|
+
localVarRequestOptions.data = serializeDataIfNeeded(createTransactionIntentRequest, localVarRequestOptions, configuration);
|
|
1800
|
+
return {
|
|
1801
|
+
url: toPathString(localVarUrlObj),
|
|
1802
|
+
options: localVarRequestOptions,
|
|
1803
|
+
};
|
|
1804
|
+
},
|
|
1805
|
+
/**
|
|
1806
|
+
* Retrieves the details of a TransactionIntent that has previously been created.
|
|
1807
|
+
* @summary Get a transaction intent object.
|
|
1808
|
+
* @param {string} id Specifies the unique transaction intent ID (starts with tin_).
|
|
1809
|
+
* @param {Array<TransactionIntentResponseExpandable>} [expand] Specifies the expandable fields.
|
|
1810
|
+
* @param {*} [options] Override http request option.
|
|
1811
|
+
* @throws {RequiredError}
|
|
1812
|
+
*/
|
|
1813
|
+
getTransactionIntent: async (id, expand, options = {}) => {
|
|
1814
|
+
// verify required parameter 'id' is not null or undefined
|
|
1815
|
+
assertParamExists('getTransactionIntent', 'id', id);
|
|
1816
|
+
const localVarPath = `/v1/transaction_intents/{id}`.replace(`{${'id'}}`, encodeURIComponent(String(id)));
|
|
1817
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
1818
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
1819
|
+
let baseOptions;
|
|
1820
|
+
if (configuration) {
|
|
1821
|
+
baseOptions = configuration.baseOptions;
|
|
1822
|
+
}
|
|
1823
|
+
const localVarRequestOptions = {
|
|
1824
|
+
method: 'GET',
|
|
1825
|
+
...baseOptions,
|
|
1826
|
+
...options,
|
|
1827
|
+
};
|
|
1828
|
+
const localVarHeaderParameter = {};
|
|
1829
|
+
const localVarQueryParameter = {};
|
|
1830
|
+
// authentication sk required
|
|
1831
|
+
// http bearer authentication required
|
|
1832
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1833
|
+
if (expand) {
|
|
1834
|
+
localVarQueryParameter['expand'] = expand;
|
|
1835
|
+
}
|
|
1836
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1837
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1838
|
+
localVarRequestOptions.headers = {
|
|
1839
|
+
...localVarHeaderParameter,
|
|
1840
|
+
...headersFromBaseOptions,
|
|
1841
|
+
...options.headers,
|
|
1842
|
+
};
|
|
1843
|
+
return {
|
|
1844
|
+
url: toPathString(localVarUrlObj),
|
|
1845
|
+
options: localVarRequestOptions,
|
|
1846
|
+
};
|
|
1847
|
+
},
|
|
1848
|
+
/**
|
|
1849
|
+
* Returns a list of TransactionIntents.
|
|
1850
|
+
* @summary List transaction intents.
|
|
1851
|
+
* @param {number} [limit] Specifies the maximum number of records to return.
|
|
1852
|
+
* @param {number} [skip] Specifies the offset for the first records to return.
|
|
1853
|
+
* @param {SortOrder} [order] Specifies the order in which to sort the results.
|
|
1854
|
+
* @param {Array<TransactionIntentResponseExpandable>} [expand] Specifies the fields to expand in the response.
|
|
1855
|
+
* @param {number} [chainId] The chain ID. Must be a [supported chain](/chains).
|
|
1856
|
+
* @param {Array<string>} [account] Filter by account ID or developer account (starts with acc_ or dac_ respectively).
|
|
1857
|
+
* @param {Array<string>} [player] Filter by player ID (starts with pla_).
|
|
1858
|
+
* @param {number} [status] Filter by successful (1) or failed (0) transaction intents.
|
|
1859
|
+
* @param {Array<string>} [policy] Filter by policy ID (starts with pol_).
|
|
1860
|
+
* @param {*} [options] Override http request option.
|
|
1861
|
+
* @throws {RequiredError}
|
|
1862
|
+
*/
|
|
1863
|
+
getTransactionIntents: async (limit, skip, order, expand, chainId, account, player, status, policy, options = {}) => {
|
|
1864
|
+
const localVarPath = `/v1/transaction_intents`;
|
|
1865
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
1866
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
1867
|
+
let baseOptions;
|
|
1868
|
+
if (configuration) {
|
|
1869
|
+
baseOptions = configuration.baseOptions;
|
|
1870
|
+
}
|
|
1871
|
+
const localVarRequestOptions = {
|
|
1872
|
+
method: 'GET',
|
|
1873
|
+
...baseOptions,
|
|
1874
|
+
...options,
|
|
1875
|
+
};
|
|
1876
|
+
const localVarHeaderParameter = {};
|
|
1877
|
+
const localVarQueryParameter = {};
|
|
1878
|
+
// authentication sk required
|
|
1879
|
+
// http bearer authentication required
|
|
1880
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1881
|
+
if (limit !== undefined) {
|
|
1882
|
+
localVarQueryParameter['limit'] = limit;
|
|
1883
|
+
}
|
|
1884
|
+
if (skip !== undefined) {
|
|
1885
|
+
localVarQueryParameter['skip'] = skip;
|
|
1886
|
+
}
|
|
1887
|
+
if (order !== undefined) {
|
|
1888
|
+
localVarQueryParameter['order'] = order;
|
|
1889
|
+
}
|
|
1890
|
+
if (expand) {
|
|
1891
|
+
localVarQueryParameter['expand'] = expand;
|
|
1892
|
+
}
|
|
1893
|
+
if (chainId !== undefined) {
|
|
1894
|
+
localVarQueryParameter['chainId'] = chainId;
|
|
1895
|
+
}
|
|
1896
|
+
if (account) {
|
|
1897
|
+
localVarQueryParameter['account'] = account;
|
|
1898
|
+
}
|
|
1899
|
+
if (player) {
|
|
1900
|
+
localVarQueryParameter['player'] = player;
|
|
1901
|
+
}
|
|
1902
|
+
if (status !== undefined) {
|
|
1903
|
+
localVarQueryParameter['status'] = status;
|
|
1904
|
+
}
|
|
1905
|
+
if (policy) {
|
|
1906
|
+
localVarQueryParameter['policy'] = policy;
|
|
1907
|
+
}
|
|
1908
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1909
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1910
|
+
localVarRequestOptions.headers = {
|
|
1911
|
+
...localVarHeaderParameter,
|
|
1912
|
+
...headersFromBaseOptions,
|
|
1913
|
+
...options.headers,
|
|
1914
|
+
};
|
|
1915
|
+
return {
|
|
1916
|
+
url: toPathString(localVarUrlObj),
|
|
1917
|
+
options: localVarRequestOptions,
|
|
1918
|
+
};
|
|
1919
|
+
},
|
|
1920
|
+
/**
|
|
1921
|
+
* Broadcasts a signed TransactionIntent to the blockchain. Use this endpoint to send the signed `userOperationHash`. Openfort will then put it on-chain.
|
|
1922
|
+
* @summary Send a signed transaction userOperationHash.
|
|
1923
|
+
* @param {string} id Specifies the unique transaction intent ID (starts with tin_).
|
|
1924
|
+
* @param {SignatureRequest} signatureRequest
|
|
1925
|
+
* @param {*} [options] Override http request option.
|
|
1926
|
+
* @throws {RequiredError}
|
|
1927
|
+
*/
|
|
1928
|
+
signature: async (id, signatureRequest, options = {}) => {
|
|
1929
|
+
// verify required parameter 'id' is not null or undefined
|
|
1930
|
+
assertParamExists('signature', 'id', id);
|
|
1931
|
+
// verify required parameter 'signatureRequest' is not null or undefined
|
|
1932
|
+
assertParamExists('signature', 'signatureRequest', signatureRequest);
|
|
1933
|
+
const localVarPath = `/v1/transaction_intents/{id}/signature`.replace(`{${'id'}}`, encodeURIComponent(String(id)));
|
|
1934
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
1935
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
1936
|
+
let baseOptions;
|
|
1937
|
+
if (configuration) {
|
|
1938
|
+
baseOptions = configuration.baseOptions;
|
|
1939
|
+
}
|
|
1940
|
+
const localVarRequestOptions = {
|
|
1941
|
+
method: 'POST',
|
|
1942
|
+
...baseOptions,
|
|
1943
|
+
...options,
|
|
1944
|
+
};
|
|
1945
|
+
const localVarHeaderParameter = {};
|
|
1946
|
+
const localVarQueryParameter = {};
|
|
1947
|
+
// authentication sk required
|
|
1948
|
+
// http bearer authentication required
|
|
1949
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1950
|
+
// authentication pk required
|
|
1951
|
+
// http bearer authentication required
|
|
1952
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1953
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
1954
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1955
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1956
|
+
localVarRequestOptions.headers = {
|
|
1957
|
+
...localVarHeaderParameter,
|
|
1958
|
+
...headersFromBaseOptions,
|
|
1959
|
+
...options.headers,
|
|
1960
|
+
};
|
|
1961
|
+
localVarRequestOptions.data = serializeDataIfNeeded(signatureRequest, localVarRequestOptions, configuration);
|
|
1962
|
+
return {
|
|
1963
|
+
url: toPathString(localVarUrlObj),
|
|
1964
|
+
options: localVarRequestOptions,
|
|
1965
|
+
};
|
|
1966
|
+
},
|
|
1967
|
+
};
|
|
1968
|
+
};
|
|
1969
|
+
/**
|
|
1970
|
+
* TransactionIntentsApi - functional programming interface
|
|
1971
|
+
* @export
|
|
1972
|
+
*/
|
|
1973
|
+
const TransactionIntentsApiFp = function (configuration) {
|
|
1974
|
+
const localVarAxiosParamCreator = TransactionIntentsApiAxiosParamCreator(configuration);
|
|
1975
|
+
return {
|
|
1976
|
+
/**
|
|
1977
|
+
* Creates a TransactionIntent. A pending TransactionIntent has the `response` attribute as undefined. After the TransactionIntent is created and broadcasted to the blockchain, `response` will be populated with the transaction hash and a status (1 success, 0 fail). When using a non-custodial account, a `nextAction` attribute is returned with the `userOperationHash` that must be signed by the owner of the account.
|
|
1978
|
+
* @summary Create a transaction intent object.
|
|
1979
|
+
* @param {CreateTransactionIntentRequest} createTransactionIntentRequest
|
|
1980
|
+
* @param {*} [options] Override http request option.
|
|
1981
|
+
* @throws {RequiredError}
|
|
1982
|
+
*/
|
|
1983
|
+
async createTransactionIntent(createTransactionIntentRequest, options) {
|
|
1984
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.createTransactionIntent(createTransactionIntentRequest, options);
|
|
1985
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1986
|
+
},
|
|
1987
|
+
/**
|
|
1988
|
+
* Estimate the gas cost of broadcasting a TransactionIntent. This is a simulation, it does not send the transaction on-chain. If a Policy ID is used that includes payment of gas in ERC-20 tokens, an extra field `estimatedTXGasFeeToken` is returned with the estimated amount of tokens that will be used.
|
|
1989
|
+
* @summary Estimate gas cost of creating a transaction
|
|
1990
|
+
* @param {CreateTransactionIntentRequest} createTransactionIntentRequest
|
|
1991
|
+
* @param {*} [options] Override http request option.
|
|
1992
|
+
* @throws {RequiredError}
|
|
1993
|
+
*/
|
|
1994
|
+
async estimateTransactionIntentCost(createTransactionIntentRequest, options) {
|
|
1995
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.estimateTransactionIntentCost(createTransactionIntentRequest, options);
|
|
1996
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1997
|
+
},
|
|
1998
|
+
/**
|
|
1999
|
+
* Retrieves the details of a TransactionIntent that has previously been created.
|
|
2000
|
+
* @summary Get a transaction intent object.
|
|
2001
|
+
* @param {string} id Specifies the unique transaction intent ID (starts with tin_).
|
|
2002
|
+
* @param {Array<TransactionIntentResponseExpandable>} [expand] Specifies the expandable fields.
|
|
2003
|
+
* @param {*} [options] Override http request option.
|
|
2004
|
+
* @throws {RequiredError}
|
|
2005
|
+
*/
|
|
2006
|
+
async getTransactionIntent(id, expand, options) {
|
|
2007
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.getTransactionIntent(id, expand, options);
|
|
2008
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
2009
|
+
},
|
|
2010
|
+
/**
|
|
2011
|
+
* Returns a list of TransactionIntents.
|
|
2012
|
+
* @summary List transaction intents.
|
|
2013
|
+
* @param {number} [limit] Specifies the maximum number of records to return.
|
|
2014
|
+
* @param {number} [skip] Specifies the offset for the first records to return.
|
|
2015
|
+
* @param {SortOrder} [order] Specifies the order in which to sort the results.
|
|
2016
|
+
* @param {Array<TransactionIntentResponseExpandable>} [expand] Specifies the fields to expand in the response.
|
|
2017
|
+
* @param {number} [chainId] The chain ID. Must be a [supported chain](/chains).
|
|
2018
|
+
* @param {Array<string>} [account] Filter by account ID or developer account (starts with acc_ or dac_ respectively).
|
|
2019
|
+
* @param {Array<string>} [player] Filter by player ID (starts with pla_).
|
|
2020
|
+
* @param {number} [status] Filter by successful (1) or failed (0) transaction intents.
|
|
2021
|
+
* @param {Array<string>} [policy] Filter by policy ID (starts with pol_).
|
|
2022
|
+
* @param {*} [options] Override http request option.
|
|
2023
|
+
* @throws {RequiredError}
|
|
2024
|
+
*/
|
|
2025
|
+
async getTransactionIntents(limit, skip, order, expand, chainId, account, player, status, policy, options) {
|
|
2026
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.getTransactionIntents(limit, skip, order, expand, chainId, account, player, status, policy, options);
|
|
2027
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
2028
|
+
},
|
|
2029
|
+
/**
|
|
2030
|
+
* Broadcasts a signed TransactionIntent to the blockchain. Use this endpoint to send the signed `userOperationHash`. Openfort will then put it on-chain.
|
|
2031
|
+
* @summary Send a signed transaction userOperationHash.
|
|
2032
|
+
* @param {string} id Specifies the unique transaction intent ID (starts with tin_).
|
|
2033
|
+
* @param {SignatureRequest} signatureRequest
|
|
2034
|
+
* @param {*} [options] Override http request option.
|
|
2035
|
+
* @throws {RequiredError}
|
|
2036
|
+
*/
|
|
2037
|
+
async signature(id, signatureRequest, options) {
|
|
2038
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.signature(id, signatureRequest, options);
|
|
2039
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
2040
|
+
},
|
|
2041
|
+
};
|
|
2042
|
+
};
|
|
2043
|
+
/**
|
|
2044
|
+
* TransactionIntentsApi - object-oriented interface
|
|
2045
|
+
* @export
|
|
2046
|
+
* @class TransactionIntentsApi
|
|
2047
|
+
* @extends {BaseAPI}
|
|
2048
|
+
*/
|
|
2049
|
+
class TransactionIntentsApi extends BaseAPI {
|
|
2050
|
+
/**
|
|
2051
|
+
* Creates a TransactionIntent. A pending TransactionIntent has the `response` attribute as undefined. After the TransactionIntent is created and broadcasted to the blockchain, `response` will be populated with the transaction hash and a status (1 success, 0 fail). When using a non-custodial account, a `nextAction` attribute is returned with the `userOperationHash` that must be signed by the owner of the account.
|
|
2052
|
+
* @summary Create a transaction intent object.
|
|
2053
|
+
* @param {CreateTransactionIntentRequest} createTransactionIntentRequest
|
|
2054
|
+
* @param {*} [options] Override http request option.
|
|
2055
|
+
* @throws {RequiredError}
|
|
2056
|
+
* @memberof TransactionIntentsApi
|
|
2057
|
+
*/
|
|
2058
|
+
createTransactionIntent(createTransactionIntentRequest, options) {
|
|
2059
|
+
return TransactionIntentsApiFp(this.configuration)
|
|
2060
|
+
.createTransactionIntent(createTransactionIntentRequest, options)
|
|
2061
|
+
.then((request) => request(this.axios, this.basePath));
|
|
2062
|
+
}
|
|
2063
|
+
/**
|
|
2064
|
+
* Estimate the gas cost of broadcasting a TransactionIntent. This is a simulation, it does not send the transaction on-chain. If a Policy ID is used that includes payment of gas in ERC-20 tokens, an extra field `estimatedTXGasFeeToken` is returned with the estimated amount of tokens that will be used.
|
|
2065
|
+
* @summary Estimate gas cost of creating a transaction
|
|
2066
|
+
* @param {CreateTransactionIntentRequest} createTransactionIntentRequest
|
|
2067
|
+
* @param {*} [options] Override http request option.
|
|
2068
|
+
* @throws {RequiredError}
|
|
2069
|
+
* @memberof TransactionIntentsApi
|
|
2070
|
+
*/
|
|
2071
|
+
estimateTransactionIntentCost(createTransactionIntentRequest, options) {
|
|
2072
|
+
return TransactionIntentsApiFp(this.configuration)
|
|
2073
|
+
.estimateTransactionIntentCost(createTransactionIntentRequest, options)
|
|
2074
|
+
.then((request) => request(this.axios, this.basePath));
|
|
2075
|
+
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Retrieves the details of a TransactionIntent that has previously been created.
|
|
2078
|
+
* @summary Get a transaction intent object.
|
|
2079
|
+
* @param {string} id Specifies the unique transaction intent ID (starts with tin_).
|
|
2080
|
+
* @param {Array<TransactionIntentResponseExpandable>} [expand] Specifies the expandable fields.
|
|
2081
|
+
* @param {*} [options] Override http request option.
|
|
2082
|
+
* @throws {RequiredError}
|
|
2083
|
+
* @memberof TransactionIntentsApi
|
|
2084
|
+
*/
|
|
2085
|
+
getTransactionIntent(id, expand, options) {
|
|
2086
|
+
return TransactionIntentsApiFp(this.configuration)
|
|
2087
|
+
.getTransactionIntent(id, expand, options)
|
|
2088
|
+
.then((request) => request(this.axios, this.basePath));
|
|
2089
|
+
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Returns a list of TransactionIntents.
|
|
2092
|
+
* @summary List transaction intents.
|
|
2093
|
+
* @param {number} [limit] Specifies the maximum number of records to return.
|
|
2094
|
+
* @param {number} [skip] Specifies the offset for the first records to return.
|
|
2095
|
+
* @param {SortOrder} [order] Specifies the order in which to sort the results.
|
|
2096
|
+
* @param {Array<TransactionIntentResponseExpandable>} [expand] Specifies the fields to expand in the response.
|
|
2097
|
+
* @param {number} [chainId] The chain ID. Must be a [supported chain](/chains).
|
|
2098
|
+
* @param {Array<string>} [account] Filter by account ID or developer account (starts with acc_ or dac_ respectively).
|
|
2099
|
+
* @param {Array<string>} [player] Filter by player ID (starts with pla_).
|
|
2100
|
+
* @param {number} [status] Filter by successful (1) or failed (0) transaction intents.
|
|
2101
|
+
* @param {Array<string>} [policy] Filter by policy ID (starts with pol_).
|
|
2102
|
+
* @param {*} [options] Override http request option.
|
|
2103
|
+
* @throws {RequiredError}
|
|
2104
|
+
* @memberof TransactionIntentsApi
|
|
2105
|
+
*/
|
|
2106
|
+
getTransactionIntents(limit, skip, order, expand, chainId, account, player, status, policy, options) {
|
|
2107
|
+
return TransactionIntentsApiFp(this.configuration)
|
|
2108
|
+
.getTransactionIntents(limit, skip, order, expand, chainId, account, player, status, policy, options)
|
|
2109
|
+
.then((request) => request(this.axios, this.basePath));
|
|
2110
|
+
}
|
|
2111
|
+
/**
|
|
2112
|
+
* Broadcasts a signed TransactionIntent to the blockchain. Use this endpoint to send the signed `userOperationHash`. Openfort will then put it on-chain.
|
|
2113
|
+
* @summary Send a signed transaction userOperationHash.
|
|
2114
|
+
* @param {string} id Specifies the unique transaction intent ID (starts with tin_).
|
|
2115
|
+
* @param {SignatureRequest} signatureRequest
|
|
2116
|
+
* @param {*} [options] Override http request option.
|
|
2117
|
+
* @throws {RequiredError}
|
|
2118
|
+
* @memberof TransactionIntentsApi
|
|
2119
|
+
*/
|
|
2120
|
+
signature(id, signatureRequest, options) {
|
|
2121
|
+
return TransactionIntentsApiFp(this.configuration)
|
|
2122
|
+
.signature(id, signatureRequest, options)
|
|
2123
|
+
.then((request) => request(this.axios, this.basePath));
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
/* tslint:disable */
|
|
2128
|
+
/* eslint-disable */
|
|
2129
|
+
/**
|
|
2130
|
+
* Openfort API
|
|
2131
|
+
* Complete Openfort API references and guides can be found at: https://openfort.xyz/docs
|
|
2132
|
+
*
|
|
2133
|
+
* The version of the OpenAPI document: 1.0.0
|
|
2134
|
+
* Contact: founders@openfort.xyz
|
|
2135
|
+
*
|
|
2136
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
2137
|
+
* https://openapi-generator.tech
|
|
2138
|
+
* Do not edit the class manually.
|
|
2139
|
+
*/
|
|
2140
|
+
class Configuration {
|
|
2141
|
+
/**
|
|
2142
|
+
* parameter for apiKey security
|
|
2143
|
+
* @param name security name
|
|
2144
|
+
* @memberof Configuration
|
|
2145
|
+
*/
|
|
2146
|
+
apiKey;
|
|
2147
|
+
/**
|
|
2148
|
+
* parameter for basic security
|
|
2149
|
+
*
|
|
2150
|
+
* @type {string}
|
|
2151
|
+
* @memberof Configuration
|
|
2152
|
+
*/
|
|
2153
|
+
username;
|
|
2154
|
+
/**
|
|
2155
|
+
* parameter for basic security
|
|
2156
|
+
*
|
|
2157
|
+
* @type {string}
|
|
2158
|
+
* @memberof Configuration
|
|
2159
|
+
*/
|
|
2160
|
+
password;
|
|
2161
|
+
/**
|
|
2162
|
+
* parameter for oauth2 security
|
|
2163
|
+
* @param name security name
|
|
2164
|
+
* @param scopes oauth2 scope
|
|
2165
|
+
* @memberof Configuration
|
|
2166
|
+
*/
|
|
2167
|
+
accessToken;
|
|
2168
|
+
/**
|
|
2169
|
+
* override base path
|
|
2170
|
+
*
|
|
2171
|
+
* @type {string}
|
|
2172
|
+
* @memberof Configuration
|
|
2173
|
+
*/
|
|
2174
|
+
basePath;
|
|
2175
|
+
/**
|
|
2176
|
+
* base options for axios calls
|
|
2177
|
+
*
|
|
2178
|
+
* @type {any}
|
|
2179
|
+
* @memberof Configuration
|
|
2180
|
+
*/
|
|
2181
|
+
baseOptions;
|
|
2182
|
+
/**
|
|
2183
|
+
* The FormData constructor that will be used to create multipart form data
|
|
2184
|
+
* requests. You can inject this here so that execution environments that
|
|
2185
|
+
* do not support the FormData class can still run the generated client.
|
|
2186
|
+
*
|
|
2187
|
+
* @type {new () => FormData}
|
|
2188
|
+
*/
|
|
2189
|
+
formDataCtor;
|
|
2190
|
+
constructor(param = {}) {
|
|
2191
|
+
this.apiKey = param.apiKey;
|
|
2192
|
+
this.username = param.username;
|
|
2193
|
+
this.password = param.password;
|
|
2194
|
+
this.accessToken = param.accessToken;
|
|
2195
|
+
this.basePath = param.basePath;
|
|
2196
|
+
this.baseOptions = param.baseOptions;
|
|
2197
|
+
this.formDataCtor = param.formDataCtor;
|
|
2198
|
+
}
|
|
2199
|
+
/**
|
|
2200
|
+
* Check if the given MIME is a JSON MIME.
|
|
2201
|
+
* JSON MIME examples:
|
|
2202
|
+
* application/json
|
|
2203
|
+
* application/json; charset=UTF8
|
|
2204
|
+
* APPLICATION/JSON
|
|
2205
|
+
* application/vnd.company+json
|
|
2206
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
2207
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
2208
|
+
*/
|
|
2209
|
+
isJsonMime(mime) {
|
|
2210
|
+
const jsonMime = new RegExp('^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
2211
|
+
return (mime !== null &&
|
|
2212
|
+
(jsonMime.test(mime) ||
|
|
2213
|
+
mime.toLowerCase() === 'application/json-patch+json'));
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
var SignerType;
|
|
2218
|
+
(function (SignerType) {
|
|
2219
|
+
SignerType["EMBEDDED"] = "embedded";
|
|
2220
|
+
SignerType["SESSION"] = "session";
|
|
2221
|
+
})(SignerType || (SignerType = {}));
|
|
2222
|
+
|
|
2223
|
+
const isBrowser = () => typeof document !== 'undefined';
|
|
2224
|
+
const localStorageWriteTests = {
|
|
2225
|
+
tested: false,
|
|
2226
|
+
writable: false,
|
|
2227
|
+
};
|
|
2228
|
+
/**
|
|
2229
|
+
* Checks whether localStorage is supported on this browser.
|
|
2230
|
+
*/
|
|
2231
|
+
const supportsLocalStorage = () => {
|
|
2232
|
+
if (!isBrowser()) {
|
|
2233
|
+
return false;
|
|
2234
|
+
}
|
|
2235
|
+
try {
|
|
2236
|
+
if (typeof globalThis.localStorage !== 'object') {
|
|
2237
|
+
return false;
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
catch (e) {
|
|
2241
|
+
// DOM exception when accessing `localStorage`
|
|
2242
|
+
return false;
|
|
2243
|
+
}
|
|
2244
|
+
if (localStorageWriteTests.tested) {
|
|
2245
|
+
return localStorageWriteTests.writable;
|
|
2246
|
+
}
|
|
2247
|
+
const randomKey = `lswt-${Math.random()}${Math.random()}`;
|
|
2248
|
+
try {
|
|
2249
|
+
globalThis.localStorage.setItem(randomKey, randomKey);
|
|
2250
|
+
globalThis.localStorage.removeItem(randomKey);
|
|
2251
|
+
localStorageWriteTests.tested = true;
|
|
2252
|
+
localStorageWriteTests.writable = true;
|
|
2253
|
+
}
|
|
2254
|
+
catch (e) {
|
|
2255
|
+
// localStorage can't be written to
|
|
2256
|
+
// https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document
|
|
2257
|
+
localStorageWriteTests.tested = true;
|
|
2258
|
+
localStorageWriteTests.writable = false;
|
|
2259
|
+
}
|
|
2260
|
+
return localStorageWriteTests.writable;
|
|
2261
|
+
};
|
|
2262
|
+
|
|
2263
|
+
class OpenfortAuth {
|
|
2264
|
+
static async initOAuth(publishableKey, provider, options) {
|
|
2265
|
+
const oauthApi = new AuthenticationApi(new Configuration({ accessToken: publishableKey }));
|
|
2266
|
+
const result = await oauthApi.initOAuth({ provider, options });
|
|
2267
|
+
if (isBrowser() && !options?.skipBrowserRedirect) {
|
|
2268
|
+
window.location.assign(result.data.url);
|
|
2269
|
+
}
|
|
2270
|
+
return {
|
|
2271
|
+
url: result.data.url,
|
|
2272
|
+
key: result.data.key,
|
|
2273
|
+
};
|
|
2274
|
+
}
|
|
2275
|
+
static async authenticateOAuth(publishableKey, provider, token, tokenType) {
|
|
2276
|
+
const oauthApi = new AuthenticationApi(new Configuration({ accessToken: publishableKey }));
|
|
2277
|
+
const response = await oauthApi.authenticateOAuth({
|
|
2278
|
+
provider,
|
|
2279
|
+
token,
|
|
2280
|
+
tokenType,
|
|
2281
|
+
});
|
|
2282
|
+
return response.data;
|
|
2283
|
+
}
|
|
2284
|
+
static async authenticateThirdParty(publishableKey, provider, token, tokenType) {
|
|
2285
|
+
const oauthApi = new AuthenticationApi(new Configuration({ accessToken: publishableKey }));
|
|
2286
|
+
const response = await oauthApi.thirdParty({
|
|
2287
|
+
provider,
|
|
2288
|
+
token,
|
|
2289
|
+
tokenType,
|
|
2290
|
+
});
|
|
2291
|
+
return response.data;
|
|
2292
|
+
}
|
|
2293
|
+
static async initSIWE(publishableKey, address) {
|
|
2294
|
+
const oauthApi = new AuthenticationApi(new Configuration({ accessToken: publishableKey }));
|
|
2295
|
+
const result = await oauthApi.initSIWE({ address });
|
|
2296
|
+
return {
|
|
2297
|
+
address: result.data.address,
|
|
2298
|
+
nonce: result.data.nonce,
|
|
2299
|
+
expiresAt: result.data.expiresAt,
|
|
2300
|
+
};
|
|
2301
|
+
}
|
|
2302
|
+
static async authenticateSIWE(publishableKey, signature, message, walletClientType, connectorType) {
|
|
2303
|
+
const oauthApi = new AuthenticationApi(new Configuration({ accessToken: publishableKey }));
|
|
2304
|
+
const response = await oauthApi.authenticateSIWE({
|
|
2305
|
+
signature,
|
|
2306
|
+
message,
|
|
2307
|
+
walletClientType,
|
|
2308
|
+
connectorType,
|
|
2309
|
+
});
|
|
2310
|
+
return response.data;
|
|
2311
|
+
}
|
|
2312
|
+
static async loginEmailPassword(publishableKey, email, password) {
|
|
2313
|
+
const oauthApi = new AuthenticationApi(new Configuration({ accessToken: publishableKey }));
|
|
2314
|
+
const response = await oauthApi.loginEmailPassword({ email, password });
|
|
2315
|
+
return response.data;
|
|
2316
|
+
}
|
|
2317
|
+
static async signupEmailPassword(publishableKey, email, password, name) {
|
|
2318
|
+
const oauthApi = new AuthenticationApi(new Configuration({ accessToken: publishableKey }));
|
|
2319
|
+
const response = await oauthApi.signupEmailPassword({
|
|
2320
|
+
name,
|
|
2321
|
+
email,
|
|
2322
|
+
password,
|
|
2323
|
+
});
|
|
2324
|
+
return response.data;
|
|
2325
|
+
}
|
|
2326
|
+
static async getJWK(publishableKey) {
|
|
2327
|
+
const oauthApi = new AuthenticationApi(new Configuration({ accessToken: publishableKey }));
|
|
2328
|
+
const jwtks = await oauthApi.getJwks(publishableKey);
|
|
2329
|
+
if (jwtks.data.keys.length === 0) {
|
|
2330
|
+
throw new Error('No keys found');
|
|
2331
|
+
}
|
|
2332
|
+
const jwtKey = jwtks.data.keys[0];
|
|
2333
|
+
return {
|
|
2334
|
+
kty: jwtKey.kty,
|
|
2335
|
+
crv: jwtKey.crv,
|
|
2336
|
+
x: jwtKey.x,
|
|
2337
|
+
y: jwtKey.y,
|
|
2338
|
+
alg: jwtKey.alg,
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2341
|
+
static async validateCredentials(accessToken, refreshToken, jwk, publishableKey) {
|
|
2342
|
+
try {
|
|
2343
|
+
const key = (await jose.importJWK({
|
|
2344
|
+
kty: jwk.kty,
|
|
2345
|
+
crv: jwk.crv,
|
|
2346
|
+
x: jwk.x,
|
|
2347
|
+
y: jwk.y,
|
|
2348
|
+
}, jwk.alg));
|
|
2349
|
+
const verification = await jose.jwtVerify(accessToken, key);
|
|
2350
|
+
return {
|
|
2351
|
+
player: verification.payload.sub,
|
|
2352
|
+
accessToken,
|
|
2353
|
+
refreshToken,
|
|
2354
|
+
};
|
|
2355
|
+
}
|
|
2356
|
+
catch (error) {
|
|
2357
|
+
if (error instanceof jose.errors.JWTExpired) {
|
|
2358
|
+
const configuration = new Configuration({
|
|
2359
|
+
accessToken: publishableKey,
|
|
2360
|
+
baseOptions: { withCredentials: true },
|
|
2361
|
+
});
|
|
2362
|
+
const oauthApi = new AuthenticationApi(configuration);
|
|
2363
|
+
const newToken = await oauthApi.refresh({ refreshToken });
|
|
2364
|
+
return {
|
|
2365
|
+
player: newToken.data.player.id,
|
|
2366
|
+
accessToken: newToken.data.token,
|
|
2367
|
+
refreshToken: newToken.data.refreshToken,
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
throw error;
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
static async logout(publishableKey, accessToken, refreshToken) {
|
|
2374
|
+
const oauthApi = new AuthenticationApi(new Configuration({ accessToken: publishableKey }));
|
|
2375
|
+
await oauthApi.logout({ refreshToken }, {
|
|
2376
|
+
headers: {
|
|
2377
|
+
authorization: `Bearer ${publishableKey}`,
|
|
2378
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2379
|
+
'player-token': accessToken,
|
|
2380
|
+
},
|
|
2381
|
+
});
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2385
|
+
class LocalStorage {
|
|
2386
|
+
static validateLocalStorage() {
|
|
2387
|
+
if (!supportsLocalStorage()) {
|
|
2388
|
+
throw new Error('Local storage is not available');
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2392
|
+
get(key) {
|
|
2393
|
+
LocalStorage.validateLocalStorage();
|
|
2394
|
+
return localStorage.getItem(key);
|
|
2395
|
+
}
|
|
2396
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2397
|
+
save(key, value) {
|
|
2398
|
+
LocalStorage.validateLocalStorage();
|
|
2399
|
+
localStorage.setItem(key, value);
|
|
2400
|
+
}
|
|
2401
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2402
|
+
remove(key) {
|
|
2403
|
+
LocalStorage.validateLocalStorage();
|
|
2404
|
+
localStorage.removeItem(key);
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
class KeyPair extends signingKey.SigningKey {
|
|
2409
|
+
/**
|
|
2410
|
+
* Initialize keypair based on the private key, if it is provided or generate a brand new keypair.
|
|
2411
|
+
* @param privateKey Optional parameter to initialize private key from
|
|
2412
|
+
*/
|
|
2413
|
+
constructor(privateKey = secp256k1.secp256k1.utils.randomPrivateKey()) {
|
|
2414
|
+
super(privateKey);
|
|
2415
|
+
}
|
|
2416
|
+
/**
|
|
2417
|
+
* Sign the message with the private key
|
|
2418
|
+
* @param message Message to sign
|
|
2419
|
+
*/
|
|
2420
|
+
sign(message) {
|
|
2421
|
+
return bytes.joinSignature(this.signDigest(hash.hashMessage(bytes.arrayify(message))));
|
|
2422
|
+
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Load private key from the storage and generate keypair based on it.
|
|
2425
|
+
*/
|
|
2426
|
+
static load(privateKey) {
|
|
2427
|
+
return privateKey ? new KeyPair(bytes.arrayify(privateKey)) : null;
|
|
2428
|
+
}
|
|
2429
|
+
/**
|
|
2430
|
+
* Return the address for the keypair
|
|
2431
|
+
*/
|
|
2432
|
+
getPublicKey() {
|
|
2433
|
+
return transactions.computeAddress(this.privateKey);
|
|
2434
|
+
}
|
|
2435
|
+
getPrivateKey() {
|
|
2436
|
+
return this.privateKey;
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
class SessionSigner {
|
|
2441
|
+
sessionKey;
|
|
2442
|
+
instanceManager;
|
|
2443
|
+
constructor(instanceManager) {
|
|
2444
|
+
this.instanceManager = instanceManager;
|
|
2445
|
+
this.sessionKey = null;
|
|
2446
|
+
}
|
|
2447
|
+
async sign(message) {
|
|
2448
|
+
if (this.sessionKey === null) {
|
|
2449
|
+
throw new Error('Session key is not loaded.');
|
|
2450
|
+
}
|
|
2451
|
+
return this.sessionKey.sign(message);
|
|
2452
|
+
}
|
|
2453
|
+
async logout() {
|
|
2454
|
+
this.instanceManager.removeSessionKey();
|
|
2455
|
+
this.sessionKey = null;
|
|
2456
|
+
}
|
|
2457
|
+
loadKeys() {
|
|
2458
|
+
if (this.sessionKey) {
|
|
2459
|
+
return this.sessionKey.getPublicKey();
|
|
2460
|
+
}
|
|
2461
|
+
const sessionKey = this.instanceManager.getSessionKey();
|
|
2462
|
+
if (sessionKey === null) {
|
|
2463
|
+
return null;
|
|
2464
|
+
}
|
|
2465
|
+
this.sessionKey = KeyPair.load(sessionKey);
|
|
2466
|
+
if (this.sessionKey === null) {
|
|
2467
|
+
return null;
|
|
2468
|
+
}
|
|
2469
|
+
return this.sessionKey.getPublicKey();
|
|
2470
|
+
}
|
|
2471
|
+
generateKeys() {
|
|
2472
|
+
this.sessionKey = new KeyPair();
|
|
2473
|
+
this.instanceManager.setSessionKey(this.sessionKey.getPrivateKey());
|
|
2474
|
+
return this.sessionKey.getPublicKey();
|
|
2475
|
+
}
|
|
2476
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2477
|
+
getSingerType() {
|
|
2478
|
+
return SignerType.SESSION;
|
|
2479
|
+
}
|
|
2480
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2481
|
+
useCredentials() {
|
|
2482
|
+
return false;
|
|
2483
|
+
}
|
|
2484
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2485
|
+
updateAuthentication() {
|
|
2486
|
+
return Promise.resolve();
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
var Event;
|
|
2491
|
+
(function (Event) {
|
|
2492
|
+
Event["LOADED"] = "loaded";
|
|
2493
|
+
Event["CONFIGURE"] = "configure";
|
|
2494
|
+
Event["CONFIGURED"] = "configured";
|
|
2495
|
+
Event["UPDATE_AUTHENTICATION"] = "update-authentication";
|
|
2496
|
+
Event["AUTHENTICATION_UPDATED"] = "authentication-updated";
|
|
2497
|
+
Event["SIGN"] = "sign";
|
|
2498
|
+
Event["SIGNED"] = "signed";
|
|
2499
|
+
Event["LOGOUT"] = "logout";
|
|
2500
|
+
Event["LOGGED_OUT"] = "logged-out";
|
|
2501
|
+
Event["GET_CURRENT_DEVICE"] = "get-current-device";
|
|
2502
|
+
Event["CURRENT_DEVICE"] = "current-device";
|
|
2503
|
+
Event["PING"] = "ping";
|
|
2504
|
+
Event["PONG"] = "pong";
|
|
2505
|
+
})(Event || (Event = {}));
|
|
2506
|
+
const NOT_CONFIGURED_ERROR = 'not-configured-error';
|
|
2507
|
+
class GetCurrentDeviceRequest {
|
|
2508
|
+
uuid;
|
|
2509
|
+
action = Event.GET_CURRENT_DEVICE;
|
|
2510
|
+
playerID;
|
|
2511
|
+
constructor(uuid, playerId) {
|
|
2512
|
+
this.uuid = uuid;
|
|
2513
|
+
this.playerID = playerId;
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
class PingRequest {
|
|
2517
|
+
uuid;
|
|
2518
|
+
action = Event.PING;
|
|
2519
|
+
constructor(uuid) {
|
|
2520
|
+
this.uuid = uuid;
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
class LogoutRequest {
|
|
2524
|
+
uuid;
|
|
2525
|
+
action = Event.LOGOUT;
|
|
2526
|
+
constructor(uuid) {
|
|
2527
|
+
this.uuid = uuid;
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
class SignRequest {
|
|
2531
|
+
uuid;
|
|
2532
|
+
action = Event.SIGN;
|
|
2533
|
+
message;
|
|
2534
|
+
requireArrayify;
|
|
2535
|
+
requireHash;
|
|
2536
|
+
openfortConfiguration;
|
|
2537
|
+
constructor(uuid, message, requireArrayify, requireHash, openfortConfiguration) {
|
|
2538
|
+
this.uuid = uuid;
|
|
2539
|
+
this.message = message;
|
|
2540
|
+
this.requireArrayify = requireArrayify;
|
|
2541
|
+
this.requireHash = requireHash;
|
|
2542
|
+
this.openfortConfiguration = openfortConfiguration;
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
class ErrorResponse {
|
|
2546
|
+
uuid;
|
|
2547
|
+
success;
|
|
2548
|
+
error;
|
|
2549
|
+
action;
|
|
2550
|
+
version;
|
|
2551
|
+
constructor(uuid, action, error) {
|
|
2552
|
+
this.action = action;
|
|
2553
|
+
this.success = false;
|
|
2554
|
+
this.error = error;
|
|
2555
|
+
this.uuid = uuid;
|
|
2556
|
+
this.version = null;
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
class ConfigureResponse {
|
|
2560
|
+
uuid;
|
|
2561
|
+
success;
|
|
2562
|
+
deviceID;
|
|
2563
|
+
action = Event.CONFIGURED;
|
|
2564
|
+
version;
|
|
2565
|
+
constructor(uuid, deviceID) {
|
|
2566
|
+
this.success = true;
|
|
2567
|
+
this.deviceID = deviceID;
|
|
2568
|
+
this.uuid = uuid;
|
|
2569
|
+
this.version = null;
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
class UpdateAuthenticationResponse {
|
|
2573
|
+
uuid;
|
|
2574
|
+
success;
|
|
2575
|
+
action = Event.AUTHENTICATION_UPDATED;
|
|
2576
|
+
version;
|
|
2577
|
+
constructor(uuid) {
|
|
2578
|
+
this.success = true;
|
|
2579
|
+
this.uuid = uuid;
|
|
2580
|
+
this.version = null;
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
class SignResponse {
|
|
2584
|
+
uuid;
|
|
2585
|
+
success;
|
|
2586
|
+
signature;
|
|
2587
|
+
action = Event.SIGNED;
|
|
2588
|
+
version;
|
|
2589
|
+
constructor(uuid, signature) {
|
|
2590
|
+
this.success = true;
|
|
2591
|
+
this.signature = signature;
|
|
2592
|
+
this.uuid = uuid;
|
|
2593
|
+
this.version = null;
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
class LogoutResponse {
|
|
2597
|
+
uuid;
|
|
2598
|
+
success;
|
|
2599
|
+
action = Event.LOGGED_OUT;
|
|
2600
|
+
constructor(uuid) {
|
|
2601
|
+
this.success = true;
|
|
2602
|
+
this.uuid = uuid;
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
class UpdateAuthenticationRequest {
|
|
2606
|
+
uuid;
|
|
2607
|
+
action = Event.UPDATE_AUTHENTICATION;
|
|
2608
|
+
accessToken;
|
|
2609
|
+
recovery;
|
|
2610
|
+
constructor(uuid, accessToken, recovery) {
|
|
2611
|
+
this.uuid = uuid;
|
|
2612
|
+
this.accessToken = accessToken;
|
|
2613
|
+
this.recovery = recovery;
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
exports.AuthType = void 0;
|
|
2617
|
+
(function (AuthType) {
|
|
2618
|
+
AuthType["OPENFORT"] = "openfort";
|
|
2619
|
+
AuthType["CUSTOM"] = "custom";
|
|
2620
|
+
})(exports.AuthType || (exports.AuthType = {}));
|
|
2621
|
+
|
|
2622
|
+
class MissingRecoveryPasswordError extends Error {
|
|
2623
|
+
constructor() {
|
|
2624
|
+
super('Recovery password is required for this operation');
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
class NoResponseError extends Error {
|
|
2628
|
+
constructor() {
|
|
2629
|
+
super('No response from iframe');
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
class UnknownResponseError extends Error {
|
|
2633
|
+
message;
|
|
2634
|
+
constructor(message) {
|
|
2635
|
+
super(`Unknown response from iframe: ${message}`);
|
|
2636
|
+
this.message = message || '';
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
class InvalidResponseError extends Error {
|
|
2640
|
+
constructor() {
|
|
2641
|
+
super('Invalid response from iframe');
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
class NotConfiguredError extends Error {
|
|
2645
|
+
constructor() {
|
|
2646
|
+
super('Not configured');
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
class IframeClient {
|
|
2650
|
+
iframe;
|
|
2651
|
+
responses = new Map();
|
|
2652
|
+
configuration;
|
|
2653
|
+
constructor(configuration) {
|
|
2654
|
+
if (!document) {
|
|
2655
|
+
throw new Error('must be run in a browser');
|
|
2656
|
+
}
|
|
2657
|
+
this.configuration = configuration;
|
|
2658
|
+
this.configuration.iframeURL = configuration.iframeURL || 'https://iframe.openfort.xyz';
|
|
2659
|
+
window.addEventListener('message', (event) => {
|
|
2660
|
+
if (event.origin === this.configuration.iframeURL) {
|
|
2661
|
+
const { data } = event;
|
|
2662
|
+
if (data.action) {
|
|
2663
|
+
if (data.action === Event.PONG) {
|
|
2664
|
+
this.responses.set('FIRST', data);
|
|
2665
|
+
}
|
|
2666
|
+
this.responses.set(data.uuid, data);
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
});
|
|
2670
|
+
const previousIframe = document.getElementById('openfort-iframe');
|
|
2671
|
+
if (previousIframe) {
|
|
2672
|
+
document.body.removeChild(previousIframe);
|
|
2673
|
+
}
|
|
2674
|
+
this.iframe = document.createElement('iframe');
|
|
2675
|
+
this.iframe.style.display = 'none';
|
|
2676
|
+
this.iframe.id = 'openfort-iframe';
|
|
2677
|
+
document.body.appendChild(this.iframe);
|
|
2678
|
+
this.iframe.src = configuration.iframeURL;
|
|
2679
|
+
}
|
|
2680
|
+
isLoaded() {
|
|
2681
|
+
return this.responses.get('FIRST') !== undefined;
|
|
2682
|
+
}
|
|
2683
|
+
async waitForIframeLoad() {
|
|
2684
|
+
const checkAndPing = async () => {
|
|
2685
|
+
if (!this.isLoaded()) {
|
|
2686
|
+
this.iframe.contentWindow?.postMessage(new PingRequest(this.generateShortUUID()), '*');
|
|
2687
|
+
await new Promise((resolve) => {
|
|
2688
|
+
setTimeout(resolve, 100);
|
|
2689
|
+
});
|
|
2690
|
+
await checkAndPing();
|
|
2691
|
+
}
|
|
2692
|
+
};
|
|
2693
|
+
await checkAndPing();
|
|
2694
|
+
}
|
|
2695
|
+
responseConstructors = {
|
|
2696
|
+
[Event.CONFIGURED]: ConfigureResponse,
|
|
2697
|
+
[Event.AUTHENTICATION_UPDATED]: UpdateAuthenticationResponse,
|
|
2698
|
+
[Event.SIGNED]: SignResponse,
|
|
2699
|
+
[Event.LOGGED_OUT]: LogoutResponse,
|
|
2700
|
+
};
|
|
2701
|
+
waitForResponse(uuid) {
|
|
2702
|
+
return new Promise((resolve, reject) => {
|
|
2703
|
+
let retries = 0;
|
|
2704
|
+
const interval = setInterval(() => {
|
|
2705
|
+
if (retries > 100) {
|
|
2706
|
+
clearInterval(interval);
|
|
2707
|
+
reject(NoResponseError);
|
|
2708
|
+
}
|
|
2709
|
+
retries++;
|
|
2710
|
+
const response = this.responses.get(uuid);
|
|
2711
|
+
if (response) {
|
|
2712
|
+
clearInterval(interval);
|
|
2713
|
+
this.responses.delete(uuid);
|
|
2714
|
+
// @ts-ignore
|
|
2715
|
+
const responseConstructor = this.responseConstructors[response.action];
|
|
2716
|
+
if (responseConstructor) {
|
|
2717
|
+
resolve(response);
|
|
2718
|
+
}
|
|
2719
|
+
else if (response instanceof ErrorResponse) {
|
|
2720
|
+
if (response.error === NOT_CONFIGURED_ERROR) {
|
|
2721
|
+
reject(new NotConfiguredError());
|
|
2722
|
+
}
|
|
2723
|
+
reject(new UnknownResponseError(response.error));
|
|
2724
|
+
}
|
|
2725
|
+
else {
|
|
2726
|
+
reject(new InvalidResponseError());
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
}, 100);
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
async configure(password) {
|
|
2733
|
+
await this.waitForIframeLoad();
|
|
2734
|
+
const config = {
|
|
2735
|
+
uuid: this.generateShortUUID(),
|
|
2736
|
+
action: Event.CONFIGURE,
|
|
2737
|
+
chainId: this.configuration.chainId,
|
|
2738
|
+
recovery: this.configuration.recovery,
|
|
2739
|
+
publishableKey: this.configuration.publishableKey,
|
|
2740
|
+
shieldAPIKey: this.configuration.shieldAPIKey,
|
|
2741
|
+
accessToken: this.configuration.accessToken,
|
|
2742
|
+
thirdPartyProvider: this.configuration.thirdPartyProvider,
|
|
2743
|
+
thirdPartyTokenType: this.configuration.thirdPartyTokenType,
|
|
2744
|
+
encryptionKey: password,
|
|
2745
|
+
encryptionPart: this.configuration.encryptionPart,
|
|
2746
|
+
openfortURL: this.configuration.openfortURL,
|
|
2747
|
+
shieldURL: this.configuration.shieldURL,
|
|
2748
|
+
};
|
|
2749
|
+
this.iframe.contentWindow?.postMessage(config, '*');
|
|
2750
|
+
const response = await this.waitForResponse(config.uuid);
|
|
2751
|
+
sessionStorage.setItem('iframe-version', response.version ?? 'undefined');
|
|
2752
|
+
if (response.success) {
|
|
2753
|
+
return response.deviceID;
|
|
2754
|
+
}
|
|
2755
|
+
throw new MissingRecoveryPasswordError();
|
|
2756
|
+
}
|
|
2757
|
+
async sign(message, requireArrayify, requireHash) {
|
|
2758
|
+
await this.waitForIframeLoad();
|
|
2759
|
+
const uuid = this.generateShortUUID();
|
|
2760
|
+
const openfortConfiguration = {
|
|
2761
|
+
openfortURL: this.configuration.openfortURL,
|
|
2762
|
+
publishableKey: this.configuration.publishableKey,
|
|
2763
|
+
thirdPartyProvider: this.configuration.thirdPartyProvider ?? undefined,
|
|
2764
|
+
thirdPartyTokenType: this.configuration.thirdPartyTokenType ?? undefined,
|
|
2765
|
+
token: this.configuration.accessToken ?? undefined,
|
|
2766
|
+
};
|
|
2767
|
+
const request = new SignRequest(uuid, message, requireArrayify, requireHash, openfortConfiguration);
|
|
2768
|
+
this.iframe.contentWindow?.postMessage(request, '*');
|
|
2769
|
+
let response;
|
|
2770
|
+
try {
|
|
2771
|
+
response = await this.waitForResponse(uuid);
|
|
2772
|
+
}
|
|
2773
|
+
catch (e) {
|
|
2774
|
+
if (e instanceof NotConfiguredError) {
|
|
2775
|
+
await this.configure();
|
|
2776
|
+
return this.sign(message, requireArrayify, requireHash);
|
|
2777
|
+
}
|
|
2778
|
+
throw e;
|
|
2779
|
+
}
|
|
2780
|
+
sessionStorage.setItem('iframe-version', response.version ?? 'undefined');
|
|
2781
|
+
return response.signature;
|
|
2782
|
+
}
|
|
2783
|
+
async getCurrentDevice(playerId) {
|
|
2784
|
+
await this.waitForIframeLoad();
|
|
2785
|
+
const uuid = this.generateShortUUID();
|
|
2786
|
+
const request = new GetCurrentDeviceRequest(uuid, playerId);
|
|
2787
|
+
this.iframe.contentWindow?.postMessage(request, '*');
|
|
2788
|
+
let response;
|
|
2789
|
+
try {
|
|
2790
|
+
response = await this.waitForResponse(uuid);
|
|
2791
|
+
sessionStorage.setItem('iframe-version', response.version ?? 'undefined');
|
|
2792
|
+
}
|
|
2793
|
+
catch (e) {
|
|
2794
|
+
throw new NoResponseError();
|
|
2795
|
+
}
|
|
2796
|
+
return response.deviceID;
|
|
2797
|
+
}
|
|
2798
|
+
async logout() {
|
|
2799
|
+
await this.waitForIframeLoad();
|
|
2800
|
+
const uuid = this.generateShortUUID();
|
|
2801
|
+
const request = new LogoutRequest(uuid);
|
|
2802
|
+
this.iframe.contentWindow?.postMessage(request, '*');
|
|
2803
|
+
await this.waitForResponse(uuid);
|
|
2804
|
+
}
|
|
2805
|
+
async updateAuthentication(token) {
|
|
2806
|
+
this.configuration.accessToken = token;
|
|
2807
|
+
await this.waitForIframeLoad();
|
|
2808
|
+
const uuid = this.generateShortUUID();
|
|
2809
|
+
const request = new UpdateAuthenticationRequest(uuid, token);
|
|
2810
|
+
this.iframe.contentWindow?.postMessage(request, '*');
|
|
2811
|
+
try {
|
|
2812
|
+
await this.waitForResponse(uuid);
|
|
2813
|
+
}
|
|
2814
|
+
catch (e) {
|
|
2815
|
+
if (e instanceof NotConfiguredError) {
|
|
2816
|
+
await this.configure();
|
|
2817
|
+
await this.updateAuthentication(token);
|
|
2818
|
+
return;
|
|
2819
|
+
}
|
|
2820
|
+
throw e;
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2824
|
+
generateShortUUID(length = 8) {
|
|
2825
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
2826
|
+
let result = '';
|
|
2827
|
+
for (let i = 0; i < length; i++) {
|
|
2828
|
+
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
2829
|
+
}
|
|
2830
|
+
return result;
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
|
|
2834
|
+
class EmbeddedSigner {
|
|
2835
|
+
iframeClient;
|
|
2836
|
+
instanceManager;
|
|
2837
|
+
constructor(configuration, instanceManager) {
|
|
2838
|
+
this.instanceManager = instanceManager;
|
|
2839
|
+
this.iframeClient = new IframeClient(configuration);
|
|
2840
|
+
}
|
|
2841
|
+
async logout() {
|
|
2842
|
+
await this.iframeClient.logout();
|
|
2843
|
+
this.instanceManager.removeDeviceID();
|
|
2844
|
+
}
|
|
2845
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2846
|
+
useCredentials() {
|
|
2847
|
+
return true;
|
|
2848
|
+
}
|
|
2849
|
+
async updateAuthentication() {
|
|
2850
|
+
const accessToken = this.instanceManager.getAccessToken();
|
|
2851
|
+
if (!accessToken) {
|
|
2852
|
+
return;
|
|
2853
|
+
}
|
|
2854
|
+
await this.iframeClient.updateAuthentication(accessToken.token);
|
|
2855
|
+
}
|
|
2856
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2857
|
+
getSingerType() {
|
|
2858
|
+
return SignerType.EMBEDDED;
|
|
2859
|
+
}
|
|
2860
|
+
async ensureEmbeddedAccount(recoveryPassword) {
|
|
2861
|
+
let deviceID = this.instanceManager.getDeviceID();
|
|
2862
|
+
const playerID = this.instanceManager.getPlayerID();
|
|
2863
|
+
if (deviceID && !(await this.iframeClient.getCurrentDevice(playerID))) {
|
|
2864
|
+
return deviceID;
|
|
2865
|
+
}
|
|
2866
|
+
deviceID = await this.iframeClient.configure(recoveryPassword);
|
|
2867
|
+
this.instanceManager.setDeviceID(deviceID);
|
|
2868
|
+
return deviceID;
|
|
2869
|
+
}
|
|
2870
|
+
async sign(message, requireArrayify, requireHash) {
|
|
2871
|
+
const loaded = await this.isLoaded();
|
|
2872
|
+
if (!loaded) {
|
|
2873
|
+
throw new Error('Signer is not loaded');
|
|
2874
|
+
}
|
|
2875
|
+
return await this.iframeClient.sign(message, requireArrayify, requireHash);
|
|
2876
|
+
}
|
|
2877
|
+
getDeviceID() {
|
|
2878
|
+
return this.instanceManager.getDeviceID();
|
|
2879
|
+
}
|
|
2880
|
+
async isLoaded() {
|
|
2881
|
+
if (this.instanceManager.getDeviceID()) {
|
|
2882
|
+
return true;
|
|
2883
|
+
}
|
|
2884
|
+
const playerID = this.instanceManager.getPlayerID();
|
|
2885
|
+
const localStorageDevice = await this.iframeClient.getCurrentDevice(playerID);
|
|
2886
|
+
if (localStorageDevice) {
|
|
2887
|
+
this.instanceManager.setDeviceID(localStorageDevice);
|
|
2888
|
+
return true;
|
|
2889
|
+
}
|
|
2890
|
+
return false;
|
|
2891
|
+
}
|
|
2892
|
+
iFrameLoaded() {
|
|
2893
|
+
return this.iframeClient.isLoaded();
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
const authTokenStorageKey = 'openfort.auth_token';
|
|
2898
|
+
const thirdPartyProviderStorageKey = 'openfort.third_party_provider';
|
|
2899
|
+
const thirdPartyProviderTokenTypeStorageKey = 'openfort.third_party_provider_token_type';
|
|
2900
|
+
const refreshTokenStorageKey = 'openfort.refresh_token';
|
|
2901
|
+
const playerIDStorageKey = 'openfort.player_id';
|
|
2902
|
+
const sessionKeyStorageKey = 'openfort.session_key';
|
|
2903
|
+
const publishableKeyStorageKey = 'openfort.publishable_key';
|
|
2904
|
+
const signerTypeStorageKey = 'openfort.signer_type';
|
|
2905
|
+
const jwksStorageKey = 'openfort.jwk';
|
|
2906
|
+
const deviceIDStorageKey = 'openfort.device_id';
|
|
2907
|
+
|
|
2908
|
+
class InstanceManager {
|
|
2909
|
+
publishableKey = null;
|
|
2910
|
+
authToken = null;
|
|
2911
|
+
refreshToken = null;
|
|
2912
|
+
signerType = null;
|
|
2913
|
+
jwk = null;
|
|
2914
|
+
sessionKey = null;
|
|
2915
|
+
deviceID = null;
|
|
2916
|
+
temporalStorage;
|
|
2917
|
+
persistentStorage;
|
|
2918
|
+
secureStorage;
|
|
2919
|
+
playerId = null;
|
|
2920
|
+
constructor(temporalStorage, persistentStorage, secureStorage) {
|
|
2921
|
+
this.temporalStorage = temporalStorage;
|
|
2922
|
+
this.persistentStorage = persistentStorage;
|
|
2923
|
+
this.secureStorage = secureStorage;
|
|
2924
|
+
}
|
|
2925
|
+
setPublishableKey(publishableKey) {
|
|
2926
|
+
this.publishableKey = publishableKey;
|
|
2927
|
+
this.temporalStorage.save(publishableKeyStorageKey, publishableKey);
|
|
2928
|
+
}
|
|
2929
|
+
getPublishableKey() {
|
|
2930
|
+
if (!this.publishableKey) {
|
|
2931
|
+
this.publishableKey = this.temporalStorage.get(publishableKeyStorageKey);
|
|
2932
|
+
}
|
|
2933
|
+
return this.publishableKey;
|
|
2934
|
+
}
|
|
2935
|
+
removePublishableKey() {
|
|
2936
|
+
this.publishableKey = null;
|
|
2937
|
+
this.temporalStorage.remove(publishableKeyStorageKey);
|
|
2938
|
+
}
|
|
2939
|
+
getAccessToken() {
|
|
2940
|
+
if (!this.authToken) {
|
|
2941
|
+
const token = this.secureStorage.get(authTokenStorageKey);
|
|
2942
|
+
if (token === null)
|
|
2943
|
+
return null; // Early exit if no token is found
|
|
2944
|
+
this.authToken = {
|
|
2945
|
+
token,
|
|
2946
|
+
thirdPartyProvider: this.secureStorage.get(thirdPartyProviderStorageKey),
|
|
2947
|
+
thirdPartyTokenType: this.secureStorage.get(thirdPartyProviderTokenTypeStorageKey),
|
|
2948
|
+
};
|
|
2949
|
+
}
|
|
2950
|
+
return this.authToken;
|
|
2951
|
+
}
|
|
2952
|
+
setAccessToken(accessToken) {
|
|
2953
|
+
this.authToken = accessToken;
|
|
2954
|
+
this.secureStorage.save(authTokenStorageKey, accessToken.token);
|
|
2955
|
+
if (accessToken.thirdPartyProvider) {
|
|
2956
|
+
this.secureStorage.save(thirdPartyProviderStorageKey, accessToken.thirdPartyProvider);
|
|
2957
|
+
}
|
|
2958
|
+
if (accessToken.thirdPartyTokenType) {
|
|
2959
|
+
this.secureStorage.save(thirdPartyProviderTokenTypeStorageKey, accessToken.thirdPartyTokenType);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
removeAccessToken() {
|
|
2963
|
+
this.authToken = null;
|
|
2964
|
+
this.secureStorage.remove(authTokenStorageKey);
|
|
2965
|
+
this.secureStorage.remove(thirdPartyProviderStorageKey);
|
|
2966
|
+
this.secureStorage.remove(thirdPartyProviderTokenTypeStorageKey);
|
|
2967
|
+
}
|
|
2968
|
+
getRefreshToken() {
|
|
2969
|
+
if (!this.refreshToken) {
|
|
2970
|
+
this.refreshToken = this.secureStorage.get(refreshTokenStorageKey);
|
|
2971
|
+
}
|
|
2972
|
+
return this.refreshToken;
|
|
2973
|
+
}
|
|
2974
|
+
setRefreshToken(refreshToken) {
|
|
2975
|
+
this.refreshToken = refreshToken;
|
|
2976
|
+
this.secureStorage.save(refreshTokenStorageKey, refreshToken);
|
|
2977
|
+
}
|
|
2978
|
+
removeRefreshToken() {
|
|
2979
|
+
this.refreshToken = null;
|
|
2980
|
+
this.secureStorage.remove(refreshTokenStorageKey);
|
|
2981
|
+
}
|
|
2982
|
+
setPlayerID(playerID) {
|
|
2983
|
+
this.playerId = playerID;
|
|
2984
|
+
this.persistentStorage.save(playerIDStorageKey, playerID);
|
|
2985
|
+
}
|
|
2986
|
+
getPlayerID() {
|
|
2987
|
+
if (this.playerId === null) {
|
|
2988
|
+
this.playerId = this.persistentStorage.get(playerIDStorageKey);
|
|
2989
|
+
}
|
|
2990
|
+
return this.playerId;
|
|
2991
|
+
}
|
|
2992
|
+
removePlayerID() {
|
|
2993
|
+
this.playerId = null;
|
|
2994
|
+
this.persistentStorage.remove(playerIDStorageKey);
|
|
2995
|
+
}
|
|
2996
|
+
setSignerType(signerType) {
|
|
2997
|
+
this.signerType = signerType;
|
|
2998
|
+
this.temporalStorage.save(signerTypeStorageKey, signerType);
|
|
2999
|
+
}
|
|
3000
|
+
getSignerType() {
|
|
3001
|
+
if (!this.signerType) {
|
|
3002
|
+
this.signerType = this.temporalStorage.get(signerTypeStorageKey);
|
|
3003
|
+
}
|
|
3004
|
+
if (!this.signerType) {
|
|
3005
|
+
if (this.getSessionKey()) {
|
|
3006
|
+
this.signerType = SignerType.SESSION;
|
|
3007
|
+
}
|
|
3008
|
+
else if (this.getDeviceID()) {
|
|
3009
|
+
this.signerType = SignerType.EMBEDDED;
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
return this.signerType;
|
|
3013
|
+
}
|
|
3014
|
+
removeSignerType() {
|
|
3015
|
+
this.signerType = null;
|
|
3016
|
+
this.temporalStorage.remove(signerTypeStorageKey);
|
|
3017
|
+
}
|
|
3018
|
+
setJWK(jwk) {
|
|
3019
|
+
this.jwk = jwk;
|
|
3020
|
+
this.temporalStorage.save(jwksStorageKey, InstanceManager.jwkToString(jwk));
|
|
3021
|
+
}
|
|
3022
|
+
static jwkToString(jwk) {
|
|
3023
|
+
return JSON.stringify({
|
|
3024
|
+
kty: jwk.kty,
|
|
3025
|
+
crv: jwk.crv,
|
|
3026
|
+
x: jwk.x,
|
|
3027
|
+
y: jwk.y,
|
|
3028
|
+
alg: jwk.alg,
|
|
3029
|
+
});
|
|
3030
|
+
}
|
|
3031
|
+
static stringToJWK(jwkString) {
|
|
3032
|
+
const json = JSON.parse(jwkString);
|
|
3033
|
+
return {
|
|
3034
|
+
kty: json.kty,
|
|
3035
|
+
crv: json.crv,
|
|
3036
|
+
x: json.x,
|
|
3037
|
+
y: json.y,
|
|
3038
|
+
alg: json.alg,
|
|
3039
|
+
};
|
|
3040
|
+
}
|
|
3041
|
+
async getJWK() {
|
|
3042
|
+
if (!this.jwk) {
|
|
3043
|
+
const jwkString = this.temporalStorage.get(jwksStorageKey);
|
|
3044
|
+
if (jwkString) {
|
|
3045
|
+
this.jwk = InstanceManager.stringToJWK(jwkString);
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
if (!this.jwk) {
|
|
3049
|
+
const publishableKey = await this.getPublishableKey();
|
|
3050
|
+
if (publishableKey) {
|
|
3051
|
+
this.jwk = await OpenfortAuth.getJWK(publishableKey);
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
return this.jwk;
|
|
3055
|
+
}
|
|
3056
|
+
removeJWK() {
|
|
3057
|
+
this.jwk = null;
|
|
3058
|
+
this.temporalStorage.remove(jwksStorageKey);
|
|
3059
|
+
}
|
|
3060
|
+
getSessionKey() {
|
|
3061
|
+
if (!this.sessionKey) {
|
|
3062
|
+
this.sessionKey = this.persistentStorage.get(sessionKeyStorageKey);
|
|
3063
|
+
}
|
|
3064
|
+
return this.sessionKey;
|
|
3065
|
+
}
|
|
3066
|
+
setSessionKey(sessionKey) {
|
|
3067
|
+
this.sessionKey = sessionKey;
|
|
3068
|
+
this.persistentStorage.save(sessionKeyStorageKey, sessionKey);
|
|
3069
|
+
}
|
|
3070
|
+
removeSessionKey() {
|
|
3071
|
+
this.sessionKey = null;
|
|
3072
|
+
this.persistentStorage.remove(sessionKeyStorageKey);
|
|
3073
|
+
}
|
|
3074
|
+
setDeviceID(deviceID) {
|
|
3075
|
+
this.deviceID = deviceID;
|
|
3076
|
+
this.persistentStorage.save(deviceIDStorageKey, deviceID);
|
|
3077
|
+
}
|
|
3078
|
+
getDeviceID() {
|
|
3079
|
+
if (!this.deviceID) {
|
|
3080
|
+
this.deviceID = this.persistentStorage.get(deviceIDStorageKey);
|
|
3081
|
+
}
|
|
3082
|
+
return this.deviceID;
|
|
3083
|
+
}
|
|
3084
|
+
removeDeviceID() {
|
|
3085
|
+
this.deviceID = null;
|
|
3086
|
+
this.persistentStorage.remove(deviceIDStorageKey);
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3090
|
+
class SessionStorage {
|
|
3091
|
+
static validateSessionStorage() {
|
|
3092
|
+
if (!('sessionStorage' in global && !!global.sessionStorage)) {
|
|
3093
|
+
throw new Error('Session storage is not available');
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3097
|
+
get(key) {
|
|
3098
|
+
SessionStorage.validateSessionStorage();
|
|
3099
|
+
return sessionStorage.getItem(key);
|
|
3100
|
+
}
|
|
3101
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3102
|
+
save(key, value) {
|
|
3103
|
+
SessionStorage.validateSessionStorage();
|
|
3104
|
+
sessionStorage.setItem(key, value);
|
|
3105
|
+
}
|
|
3106
|
+
// eslint-disable-next-line class-methods-use-this
|
|
3107
|
+
remove(key) {
|
|
3108
|
+
SessionStorage.validateSessionStorage();
|
|
3109
|
+
sessionStorage.removeItem(key);
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3113
|
+
exports.EmbeddedState = void 0;
|
|
3114
|
+
(function (EmbeddedState) {
|
|
3115
|
+
EmbeddedState[EmbeddedState["NONE"] = 0] = "NONE";
|
|
3116
|
+
EmbeddedState[EmbeddedState["UNAUTHENTICATED"] = 1] = "UNAUTHENTICATED";
|
|
3117
|
+
EmbeddedState[EmbeddedState["EMBEDDED_SIGNER_NOT_CONFIGURED"] = 2] = "EMBEDDED_SIGNER_NOT_CONFIGURED";
|
|
3118
|
+
EmbeddedState[EmbeddedState["CREATING_ACCOUNT"] = 3] = "CREATING_ACCOUNT";
|
|
3119
|
+
EmbeddedState[EmbeddedState["READY"] = 4] = "READY";
|
|
3120
|
+
})(exports.EmbeddedState || (exports.EmbeddedState = {}));
|
|
3121
|
+
class NotLoggedIn extends Error {
|
|
3122
|
+
constructor(message) {
|
|
3123
|
+
super(message);
|
|
3124
|
+
this.name = 'NotLoggedIn';
|
|
3125
|
+
Object.setPrototypeOf(this, NotLoggedIn.prototype);
|
|
3126
|
+
}
|
|
3127
|
+
}
|
|
3128
|
+
class MissingRecoveryMethod extends Error {
|
|
3129
|
+
constructor(message) {
|
|
3130
|
+
super(message);
|
|
3131
|
+
this.name = 'MissingRecoveryMethod';
|
|
3132
|
+
Object.setPrototypeOf(this, MissingRecoveryMethod.prototype);
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
class EmbeddedNotConfigured extends Error {
|
|
3136
|
+
constructor(message) {
|
|
3137
|
+
super(message);
|
|
3138
|
+
this.name = 'EmbeddedNotConfigured';
|
|
3139
|
+
Object.setPrototypeOf(this, EmbeddedNotConfigured.prototype);
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
class NoSignerConfigured extends Error {
|
|
3143
|
+
constructor(message) {
|
|
3144
|
+
super(message);
|
|
3145
|
+
this.name = 'NoSignerConfigured';
|
|
3146
|
+
Object.setPrototypeOf(this, NoSignerConfigured.prototype);
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
class NothingToSign extends Error {
|
|
3150
|
+
constructor(message) {
|
|
3151
|
+
super(message);
|
|
3152
|
+
this.name = 'NothingToSign';
|
|
3153
|
+
Object.setPrototypeOf(this, NothingToSign.prototype);
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
class MissingPublishableKey extends Error {
|
|
3157
|
+
constructor(message) {
|
|
3158
|
+
super(message);
|
|
3159
|
+
this.name = 'MissingPublishableKey';
|
|
3160
|
+
Object.setPrototypeOf(this, MissingPublishableKey.prototype);
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
class Openfort {
|
|
3164
|
+
signer;
|
|
3165
|
+
publishableKey;
|
|
3166
|
+
shieldAPIKey;
|
|
3167
|
+
iframeURL;
|
|
3168
|
+
openfortURL;
|
|
3169
|
+
shieldURL;
|
|
3170
|
+
encryptionPart;
|
|
3171
|
+
instanceManager;
|
|
3172
|
+
constructor(publishableKey, shieldAPIKey = null, encryptionShare = null, iframeURL = 'https://iframe.openfort.xyz', openfortURL = 'https://api.openfort.xyz', shieldURL = 'https://shield.openfort.xyz') {
|
|
3173
|
+
this.instanceManager = new InstanceManager(new SessionStorage(), new LocalStorage(), new LocalStorage());
|
|
3174
|
+
this.iframeURL = iframeURL;
|
|
3175
|
+
this.openfortURL = openfortURL;
|
|
3176
|
+
this.shieldURL = shieldURL;
|
|
3177
|
+
this.publishableKey = publishableKey;
|
|
3178
|
+
this.shieldAPIKey = shieldAPIKey || publishableKey;
|
|
3179
|
+
this.encryptionPart = encryptionShare;
|
|
3180
|
+
}
|
|
3181
|
+
async logout() {
|
|
3182
|
+
await this.flushSigner();
|
|
3183
|
+
if (this.credentialsProvided()) {
|
|
3184
|
+
const accessToken = this.instanceManager.getAccessToken();
|
|
3185
|
+
if (accessToken
|
|
3186
|
+
&& accessToken.thirdPartyProvider === undefined
|
|
3187
|
+
&& accessToken.thirdPartyTokenType === undefined) {
|
|
3188
|
+
const refreshToken = this.instanceManager.getRefreshToken();
|
|
3189
|
+
if (refreshToken === null) {
|
|
3190
|
+
console.error('Refresh token is missing; cannot complete logout.');
|
|
3191
|
+
return; // Optionally handle this case differently
|
|
3192
|
+
}
|
|
3193
|
+
try {
|
|
3194
|
+
await OpenfortAuth.logout(this.publishableKey, accessToken.token, refreshToken);
|
|
3195
|
+
}
|
|
3196
|
+
catch (e) {
|
|
3197
|
+
console.error('Error logging out', e);
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
this.instanceManager.removeAccessToken();
|
|
3201
|
+
this.instanceManager.removeRefreshToken();
|
|
3202
|
+
this.instanceManager.removePlayerID();
|
|
3203
|
+
this.instanceManager.removeJWK();
|
|
3204
|
+
}
|
|
3205
|
+
this.instanceManager.removePublishableKey();
|
|
3206
|
+
}
|
|
3207
|
+
async flushSigner() {
|
|
3208
|
+
if (this.signer) {
|
|
3209
|
+
await this.signer.logout();
|
|
3210
|
+
this.instanceManager.removeSignerType();
|
|
3211
|
+
return;
|
|
3212
|
+
}
|
|
3213
|
+
const signerType = this.instanceManager.getSignerType();
|
|
3214
|
+
switch (signerType) {
|
|
3215
|
+
case SignerType.EMBEDDED: {
|
|
3216
|
+
this.recoverPublishableKey();
|
|
3217
|
+
const iframeConfiguration = this.createIFrameConfiguration();
|
|
3218
|
+
const embeddedSigner = new EmbeddedSigner(iframeConfiguration, this.instanceManager);
|
|
3219
|
+
await embeddedSigner.logout();
|
|
3220
|
+
break;
|
|
3221
|
+
}
|
|
3222
|
+
case SignerType.SESSION:
|
|
3223
|
+
this.configureSessionKey();
|
|
3224
|
+
break;
|
|
3225
|
+
}
|
|
3226
|
+
this.instanceManager.removeSignerType();
|
|
3227
|
+
}
|
|
3228
|
+
createIFrameConfiguration() {
|
|
3229
|
+
return {
|
|
3230
|
+
accessToken: this.instanceManager.getAccessToken()?.token ?? null,
|
|
3231
|
+
thirdPartyProvider: this.instanceManager.getAccessToken()?.thirdPartyProvider ?? null,
|
|
3232
|
+
thirdPartyTokenType: this.instanceManager.getAccessToken()?.thirdPartyTokenType ?? null,
|
|
3233
|
+
chainId: 0, // Default value, consider making this configurable or ensuring it's properly set
|
|
3234
|
+
iframeURL: this.iframeURL,
|
|
3235
|
+
openfortURL: this.openfortURL,
|
|
3236
|
+
publishableKey: this.publishableKey,
|
|
3237
|
+
recovery: null, // No recovery process implemented here, consider adding
|
|
3238
|
+
shieldAPIKey: this.shieldAPIKey,
|
|
3239
|
+
shieldURL: this.shieldURL,
|
|
3240
|
+
encryptionPart: this.encryptionPart,
|
|
3241
|
+
};
|
|
3242
|
+
}
|
|
3243
|
+
recoverPublishableKey() {
|
|
3244
|
+
if (!this.publishableKey) {
|
|
3245
|
+
const key = this.instanceManager.getPublishableKey();
|
|
3246
|
+
if (!key) {
|
|
3247
|
+
throw new MissingPublishableKey('Publishable key must be provided');
|
|
3248
|
+
}
|
|
3249
|
+
this.publishableKey = key;
|
|
3250
|
+
}
|
|
3251
|
+
this.instanceManager.setPublishableKey(this.publishableKey);
|
|
3252
|
+
}
|
|
3253
|
+
configureSessionKey() {
|
|
3254
|
+
const signer = new SessionSigner(this.instanceManager);
|
|
3255
|
+
this.signer = signer;
|
|
3256
|
+
const publicKey = signer.loadKeys();
|
|
3257
|
+
if (!publicKey) {
|
|
3258
|
+
const newPublicKey = signer.generateKeys();
|
|
3259
|
+
return { address: newPublicKey, isRegistered: false };
|
|
3260
|
+
}
|
|
3261
|
+
this.instanceManager.setSignerType(SignerType.SESSION);
|
|
3262
|
+
return { address: publicKey, isRegistered: true };
|
|
3263
|
+
}
|
|
3264
|
+
async configureEmbeddedSigner(chainID, shieldAuthentication) {
|
|
3265
|
+
const signer = this.newEmbeddedSigner(chainID, shieldAuthentication);
|
|
3266
|
+
try {
|
|
3267
|
+
await signer.ensureEmbeddedAccount();
|
|
3268
|
+
}
|
|
3269
|
+
catch (e) {
|
|
3270
|
+
if (e instanceof MissingRecoveryPasswordError) {
|
|
3271
|
+
throw new MissingRecoveryMethod('This device has not been configured, to recover or create your account provide recovery method.');
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
this.signer = signer;
|
|
3275
|
+
this.instanceManager.setSignerType(SignerType.EMBEDDED);
|
|
3276
|
+
}
|
|
3277
|
+
newEmbeddedSigner(chainID, shieldAuthentication) {
|
|
3278
|
+
if (!this.credentialsProvided()) {
|
|
3279
|
+
throw new NotLoggedIn('Must be logged in to configure embedded signer');
|
|
3280
|
+
}
|
|
3281
|
+
this.recoverPublishableKey();
|
|
3282
|
+
const iframeConfiguration = {
|
|
3283
|
+
accessToken: this.instanceManager.getAccessToken()?.token ?? null,
|
|
3284
|
+
thirdPartyProvider: this.instanceManager.getAccessToken()?.thirdPartyProvider ?? null,
|
|
3285
|
+
thirdPartyTokenType: this.instanceManager.getAccessToken()?.thirdPartyTokenType ?? null,
|
|
3286
|
+
chainId: chainID,
|
|
3287
|
+
iframeURL: this.iframeURL,
|
|
3288
|
+
openfortURL: this.openfortURL,
|
|
3289
|
+
publishableKey: this.publishableKey,
|
|
3290
|
+
recovery: shieldAuthentication ?? null,
|
|
3291
|
+
shieldAPIKey: this.shieldAPIKey,
|
|
3292
|
+
shieldURL: this.shieldURL,
|
|
3293
|
+
encryptionPart: this.encryptionPart,
|
|
3294
|
+
};
|
|
3295
|
+
return new EmbeddedSigner(iframeConfiguration, this.instanceManager);
|
|
3296
|
+
}
|
|
3297
|
+
async configureEmbeddedSignerRecovery(chainID, shieldAuthentication, recoveryPassword) {
|
|
3298
|
+
const signer = this.newEmbeddedSigner(chainID, shieldAuthentication);
|
|
3299
|
+
await this.validateAndRefreshToken();
|
|
3300
|
+
await signer.ensureEmbeddedAccount(recoveryPassword);
|
|
3301
|
+
this.signer = signer;
|
|
3302
|
+
this.instanceManager.setSignerType(SignerType.EMBEDDED);
|
|
3303
|
+
}
|
|
3304
|
+
async loginWithEmailPassword(email, password) {
|
|
3305
|
+
this.recoverPublishableKey();
|
|
3306
|
+
this.instanceManager.removeAccessToken();
|
|
3307
|
+
this.instanceManager.removeRefreshToken();
|
|
3308
|
+
this.instanceManager.removePlayerID();
|
|
3309
|
+
const result = await OpenfortAuth.loginEmailPassword(this.publishableKey, email, password);
|
|
3310
|
+
this.storeCredentials({
|
|
3311
|
+
player: result.player.id,
|
|
3312
|
+
accessToken: result.token,
|
|
3313
|
+
refreshToken: result.refreshToken,
|
|
3314
|
+
});
|
|
3315
|
+
return result;
|
|
3316
|
+
}
|
|
3317
|
+
async signUpWithEmailPassword(email, password, name) {
|
|
3318
|
+
this.recoverPublishableKey();
|
|
3319
|
+
this.instanceManager.removeAccessToken();
|
|
3320
|
+
this.instanceManager.removeRefreshToken();
|
|
3321
|
+
this.instanceManager.removePlayerID();
|
|
3322
|
+
const result = await OpenfortAuth.signupEmailPassword(this.publishableKey, email, password, name);
|
|
3323
|
+
this.storeCredentials({
|
|
3324
|
+
player: result.player.id,
|
|
3325
|
+
accessToken: result.token,
|
|
3326
|
+
refreshToken: result.refreshToken,
|
|
3327
|
+
});
|
|
3328
|
+
return result;
|
|
3329
|
+
}
|
|
3330
|
+
async initOAuth(provider, options) {
|
|
3331
|
+
this.recoverPublishableKey();
|
|
3332
|
+
return await OpenfortAuth.initOAuth(this.publishableKey, provider, options);
|
|
3333
|
+
}
|
|
3334
|
+
async authenticateWithOAuth(provider, token, tokenType) {
|
|
3335
|
+
this.recoverPublishableKey();
|
|
3336
|
+
this.instanceManager.removeAccessToken();
|
|
3337
|
+
this.instanceManager.removeRefreshToken();
|
|
3338
|
+
this.instanceManager.removePlayerID();
|
|
3339
|
+
const result = await OpenfortAuth.authenticateOAuth(this.publishableKey, provider, token, tokenType);
|
|
3340
|
+
this.storeCredentials({
|
|
3341
|
+
player: result.player.id,
|
|
3342
|
+
accessToken: result.token,
|
|
3343
|
+
refreshToken: result.refreshToken,
|
|
3344
|
+
});
|
|
3345
|
+
return result;
|
|
3346
|
+
}
|
|
3347
|
+
async initSIWE(address) {
|
|
3348
|
+
return await OpenfortAuth.initSIWE(this.publishableKey, address);
|
|
3349
|
+
}
|
|
3350
|
+
async authenticateWithThirdPartyProvider(provider, token, tokenType) {
|
|
3351
|
+
const result = await OpenfortAuth.authenticateThirdParty(this.publishableKey, provider, token, tokenType);
|
|
3352
|
+
this.instanceManager.setAccessToken({
|
|
3353
|
+
token,
|
|
3354
|
+
thirdPartyProvider: provider,
|
|
3355
|
+
thirdPartyTokenType: tokenType,
|
|
3356
|
+
});
|
|
3357
|
+
this.instanceManager.setPlayerID(result.id);
|
|
3358
|
+
if (this.signer && this.signer.useCredentials()) {
|
|
3359
|
+
await this.signer.updateAuthentication();
|
|
3360
|
+
}
|
|
3361
|
+
return result;
|
|
3362
|
+
}
|
|
3363
|
+
async authenticateWithSIWE(signature, message, walletClientType, connectorType) {
|
|
3364
|
+
this.recoverPublishableKey();
|
|
3365
|
+
this.instanceManager.removeAccessToken();
|
|
3366
|
+
this.instanceManager.removeRefreshToken();
|
|
3367
|
+
this.instanceManager.removePlayerID();
|
|
3368
|
+
const result = await OpenfortAuth.authenticateSIWE(this.publishableKey, signature, message, walletClientType, connectorType);
|
|
3369
|
+
this.storeCredentials({
|
|
3370
|
+
player: result.player.id,
|
|
3371
|
+
accessToken: result.token,
|
|
3372
|
+
refreshToken: result.refreshToken,
|
|
3373
|
+
});
|
|
3374
|
+
return result;
|
|
3375
|
+
}
|
|
3376
|
+
storeCredentials(auth) {
|
|
3377
|
+
this.instanceManager.setAccessToken({
|
|
3378
|
+
token: auth.accessToken,
|
|
3379
|
+
thirdPartyProvider: null,
|
|
3380
|
+
thirdPartyTokenType: null,
|
|
3381
|
+
});
|
|
3382
|
+
this.instanceManager.setRefreshToken(auth.refreshToken);
|
|
3383
|
+
this.instanceManager.setPlayerID(auth.player);
|
|
3384
|
+
}
|
|
3385
|
+
async sendSignatureTransactionIntentRequest(transactionIntentId, userOperationHash = null, signature = null) {
|
|
3386
|
+
let newSignature = signature;
|
|
3387
|
+
if (!newSignature) {
|
|
3388
|
+
if (!userOperationHash) {
|
|
3389
|
+
throw new NothingToSign('No userOperationHash or signature provided');
|
|
3390
|
+
}
|
|
3391
|
+
await this.recoverSigner();
|
|
3392
|
+
if (!this.signer) {
|
|
3393
|
+
throw new NoSignerConfigured('In order to sign a transaction intent, a signer must be configured');
|
|
3394
|
+
}
|
|
3395
|
+
if (this.signer.useCredentials()) {
|
|
3396
|
+
await this.validateAndRefreshToken();
|
|
3397
|
+
}
|
|
3398
|
+
newSignature = await this.signer.sign(userOperationHash);
|
|
3399
|
+
}
|
|
3400
|
+
this.recoverPublishableKey();
|
|
3401
|
+
const transactionsApi = new TransactionIntentsApi(new Configuration({ accessToken: this.publishableKey }));
|
|
3402
|
+
const result = await transactionsApi.signature(transactionIntentId, {
|
|
3403
|
+
signature: newSignature,
|
|
3404
|
+
});
|
|
3405
|
+
return result.data;
|
|
3406
|
+
}
|
|
3407
|
+
async signMessage(message) {
|
|
3408
|
+
await this.recoverSigner();
|
|
3409
|
+
if (!this.signer) {
|
|
3410
|
+
throw new NoSignerConfigured('No signer configured');
|
|
3411
|
+
}
|
|
3412
|
+
if (this.signer.useCredentials()) {
|
|
3413
|
+
await this.validateAndRefreshToken();
|
|
3414
|
+
}
|
|
3415
|
+
return await this.signer.sign(message, false, true);
|
|
3416
|
+
}
|
|
3417
|
+
async signTypedData(domain, types, value) {
|
|
3418
|
+
await this.recoverSigner();
|
|
3419
|
+
if (!this.signer) {
|
|
3420
|
+
throw new NoSignerConfigured('No signer configured');
|
|
3421
|
+
}
|
|
3422
|
+
if (this.signer.useCredentials()) {
|
|
3423
|
+
await this.validateAndRefreshToken();
|
|
3424
|
+
}
|
|
3425
|
+
return await this.signer.sign(hash._TypedDataEncoder.hash(domain, types, value), false, false);
|
|
3426
|
+
}
|
|
3427
|
+
async sendRegisterSessionRequest(sessionId, signature, optimistic) {
|
|
3428
|
+
await this.recoverSigner();
|
|
3429
|
+
if (!this.signer) {
|
|
3430
|
+
throw new NoSignerConfigured('No signer configured nor signature provided');
|
|
3431
|
+
}
|
|
3432
|
+
if (this.signer.getSingerType() !== SignerType.SESSION) {
|
|
3433
|
+
throw new NoSignerConfigured('Session signer must be configured to sign a session');
|
|
3434
|
+
}
|
|
3435
|
+
this.recoverPublishableKey();
|
|
3436
|
+
const sessionsApi = new SessionsApi(new Configuration({ accessToken: this.publishableKey }));
|
|
3437
|
+
const result = await sessionsApi.signatureSession(sessionId, {
|
|
3438
|
+
signature,
|
|
3439
|
+
optimistic,
|
|
3440
|
+
});
|
|
3441
|
+
return result.data;
|
|
3442
|
+
}
|
|
3443
|
+
async recoverSigner() {
|
|
3444
|
+
if (this.signer) {
|
|
3445
|
+
return;
|
|
3446
|
+
}
|
|
3447
|
+
const signerType = this.instanceManager.getSignerType();
|
|
3448
|
+
if (signerType === SignerType.EMBEDDED) {
|
|
3449
|
+
await this.configureEmbeddedSigner(80002);
|
|
3450
|
+
return;
|
|
3451
|
+
}
|
|
3452
|
+
if (signerType === SignerType.SESSION) {
|
|
3453
|
+
this.configureSessionKey();
|
|
3454
|
+
return;
|
|
3455
|
+
}
|
|
3456
|
+
await this.waitSigner();
|
|
3457
|
+
}
|
|
3458
|
+
async waitSigner() {
|
|
3459
|
+
const retries = 100;
|
|
3460
|
+
const delay = 100;
|
|
3461
|
+
const checkSignerType = async (attempt) => {
|
|
3462
|
+
if (attempt >= retries) {
|
|
3463
|
+
return;
|
|
3464
|
+
}
|
|
3465
|
+
const signerType = this.instanceManager.getSignerType();
|
|
3466
|
+
if (signerType) {
|
|
3467
|
+
return;
|
|
3468
|
+
}
|
|
3469
|
+
await new Promise((resolve) => {
|
|
3470
|
+
setTimeout(resolve, delay);
|
|
3471
|
+
});
|
|
3472
|
+
await checkSignerType(attempt + 1);
|
|
3473
|
+
};
|
|
3474
|
+
await checkSignerType(0);
|
|
3475
|
+
}
|
|
3476
|
+
getEmbeddedState() {
|
|
3477
|
+
if (!this.credentialsProvided()) {
|
|
3478
|
+
return exports.EmbeddedState.UNAUTHENTICATED;
|
|
3479
|
+
}
|
|
3480
|
+
if (this.instanceManager.getSignerType() !== SignerType.EMBEDDED) {
|
|
3481
|
+
return exports.EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED;
|
|
3482
|
+
}
|
|
3483
|
+
if (!this.signer) {
|
|
3484
|
+
this.signer = this.newEmbeddedSigner(80002);
|
|
3485
|
+
}
|
|
3486
|
+
if (!this.instanceManager.getDeviceID()) {
|
|
3487
|
+
return exports.EmbeddedState.CREATING_ACCOUNT;
|
|
3488
|
+
}
|
|
3489
|
+
return exports.EmbeddedState.READY;
|
|
3490
|
+
}
|
|
3491
|
+
credentialsProvided() {
|
|
3492
|
+
const token = this.instanceManager.getAccessToken();
|
|
3493
|
+
const refreshToken = this.instanceManager.getRefreshToken();
|
|
3494
|
+
return (token
|
|
3495
|
+
&& ((token.token && token.thirdPartyProvider && token.thirdPartyTokenType)
|
|
3496
|
+
|| (token.token && refreshToken)));
|
|
3497
|
+
}
|
|
3498
|
+
async isAuthenticated() {
|
|
3499
|
+
if (!this.credentialsProvided()) {
|
|
3500
|
+
return false;
|
|
3501
|
+
}
|
|
3502
|
+
if (!this.signer) {
|
|
3503
|
+
const signerType = this.instanceManager.getSignerType();
|
|
3504
|
+
if (signerType !== SignerType.EMBEDDED) {
|
|
3505
|
+
return false;
|
|
3506
|
+
}
|
|
3507
|
+
const signer = this.newEmbeddedSigner(80002);
|
|
3508
|
+
return await signer.isLoaded();
|
|
3509
|
+
}
|
|
3510
|
+
if (this.signer.getSingerType() !== SignerType.EMBEDDED) {
|
|
3511
|
+
return false;
|
|
3512
|
+
}
|
|
3513
|
+
return await this.signer.isLoaded();
|
|
3514
|
+
}
|
|
3515
|
+
getAccessToken() {
|
|
3516
|
+
return this.instanceManager.getAccessToken()?.token ?? null;
|
|
3517
|
+
}
|
|
3518
|
+
isLoaded() {
|
|
3519
|
+
if (!this.instanceManager.getJWK()) {
|
|
3520
|
+
return false;
|
|
3521
|
+
}
|
|
3522
|
+
if (this.signer && this.signer.getSingerType() === SignerType.EMBEDDED) {
|
|
3523
|
+
return this.signer.iFrameLoaded();
|
|
3524
|
+
}
|
|
3525
|
+
return true;
|
|
3526
|
+
}
|
|
3527
|
+
async validateAndRefreshToken() {
|
|
3528
|
+
if (!this.credentialsProvided()) {
|
|
3529
|
+
return;
|
|
3530
|
+
}
|
|
3531
|
+
const accessToken = this.instanceManager.getAccessToken();
|
|
3532
|
+
const refreshToken = this.instanceManager.getRefreshToken();
|
|
3533
|
+
const jwk = await this.instanceManager.getJWK();
|
|
3534
|
+
if (!accessToken || !refreshToken || !jwk) {
|
|
3535
|
+
return;
|
|
3536
|
+
}
|
|
3537
|
+
this.recoverPublishableKey();
|
|
3538
|
+
const auth = await OpenfortAuth.validateCredentials(accessToken.token, refreshToken, jwk, this.publishableKey);
|
|
3539
|
+
if (auth.accessToken !== accessToken.token) {
|
|
3540
|
+
this.storeCredentials(auth);
|
|
3541
|
+
}
|
|
3542
|
+
if (this.signer && this.signer.useCredentials()) {
|
|
3543
|
+
await this.signer.updateAuthentication();
|
|
3544
|
+
}
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
|
|
3548
|
+
exports.EmbeddedNotConfigured = EmbeddedNotConfigured;
|
|
3549
|
+
exports.MissingPublishableKey = MissingPublishableKey;
|
|
3550
|
+
exports.MissingRecoveryMethod = MissingRecoveryMethod;
|
|
3551
|
+
exports.NoSignerConfigured = NoSignerConfigured;
|
|
3552
|
+
exports.NotLoggedIn = NotLoggedIn;
|
|
3553
|
+
exports.NothingToSign = NothingToSign;
|
|
3554
|
+
exports.OAuthProvider = OAuthProvider;
|
|
3555
|
+
exports.ThirdPartyOAuthProvider = ThirdPartyOAuthProvider;
|
|
3556
|
+
exports.TokenType = TokenType;
|
|
3557
|
+
exports.default = Openfort;
|