@openfort/openfort-js 0.8.13 → 0.8.15
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 +191 -40
- package/dist/index.d.ts +7 -0
- package/dist/index.js +191 -40
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -8,8 +8,9 @@ var secp256k1 = require('@noble/curves/secp256k1');
|
|
|
8
8
|
var signingKey = require('@ethersproject/signing-key');
|
|
9
9
|
var bytes = require('@ethersproject/bytes');
|
|
10
10
|
var transactions = require('@ethersproject/transactions');
|
|
11
|
-
var jose = require('jose');
|
|
12
11
|
var crypto = require('crypto');
|
|
12
|
+
var jose = require('jose');
|
|
13
|
+
var jsrsasign = require('jsrsasign');
|
|
13
14
|
var providers = require('@ethersproject/providers');
|
|
14
15
|
var events = require('events');
|
|
15
16
|
var uuid = require('uuid');
|
|
@@ -1379,6 +1380,38 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
|
|
|
1379
1380
|
options: localVarRequestOptions,
|
|
1380
1381
|
};
|
|
1381
1382
|
},
|
|
1383
|
+
/**
|
|
1384
|
+
* Create a guest player.
|
|
1385
|
+
* @summary Create a guest player.
|
|
1386
|
+
* @param {string} [xGame]
|
|
1387
|
+
* @param {*} [options] Override http request option.
|
|
1388
|
+
* @throws {RequiredError}
|
|
1389
|
+
*/
|
|
1390
|
+
registerGuest: async (xGame, options = {}) => {
|
|
1391
|
+
const localVarPath = `/iam/v1/guest`;
|
|
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 = { method: 'POST', ...baseOptions, ...options };
|
|
1399
|
+
const localVarHeaderParameter = {};
|
|
1400
|
+
const localVarQueryParameter = {};
|
|
1401
|
+
// authentication pk required
|
|
1402
|
+
// http bearer authentication required
|
|
1403
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1404
|
+
if (xGame != null) {
|
|
1405
|
+
localVarHeaderParameter['x-game'] = String(xGame);
|
|
1406
|
+
}
|
|
1407
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1408
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1409
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
1410
|
+
return {
|
|
1411
|
+
url: toPathString(localVarUrlObj),
|
|
1412
|
+
options: localVarRequestOptions,
|
|
1413
|
+
};
|
|
1414
|
+
},
|
|
1382
1415
|
/**
|
|
1383
1416
|
* Start the Email Verification process for a player.
|
|
1384
1417
|
* @summary Request an Email Verification.
|
|
@@ -1937,6 +1970,17 @@ const AuthenticationApiFp = function (configuration) {
|
|
|
1937
1970
|
const localVarAxiosArgs = await localVarAxiosParamCreator.refresh(refreshTokenRequest, options);
|
|
1938
1971
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1939
1972
|
},
|
|
1973
|
+
/**
|
|
1974
|
+
* Create a guest player.
|
|
1975
|
+
* @summary Create a guest player.
|
|
1976
|
+
* @param {string} [xGame]
|
|
1977
|
+
* @param {*} [options] Override http request option.
|
|
1978
|
+
* @throws {RequiredError}
|
|
1979
|
+
*/
|
|
1980
|
+
async registerGuest(xGame, options) {
|
|
1981
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.registerGuest(xGame, options);
|
|
1982
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1983
|
+
},
|
|
1940
1984
|
/**
|
|
1941
1985
|
* Start the Email Verification process for a player.
|
|
1942
1986
|
* @summary Request an Email Verification.
|
|
@@ -2245,6 +2289,17 @@ class AuthenticationApi extends BaseAPI {
|
|
|
2245
2289
|
refresh(requestParameters, options) {
|
|
2246
2290
|
return AuthenticationApiFp(this.configuration).refresh(requestParameters.refreshTokenRequest, options).then((request) => request(this.axios, this.basePath));
|
|
2247
2291
|
}
|
|
2292
|
+
/**
|
|
2293
|
+
* Create a guest player.
|
|
2294
|
+
* @summary Create a guest player.
|
|
2295
|
+
* @param {AuthenticationApiRegisterGuestRequest} requestParameters Request parameters.
|
|
2296
|
+
* @param {*} [options] Override http request option.
|
|
2297
|
+
* @throws {RequiredError}
|
|
2298
|
+
* @memberof AuthenticationApi
|
|
2299
|
+
*/
|
|
2300
|
+
registerGuest(requestParameters = {}, options) {
|
|
2301
|
+
return AuthenticationApiFp(this.configuration).registerGuest(requestParameters.xGame, options).then((request) => request(this.axios, this.basePath));
|
|
2302
|
+
}
|
|
2248
2303
|
/**
|
|
2249
2304
|
* Start the Email Verification process for a player.
|
|
2250
2305
|
* @summary Request an Email Verification.
|
|
@@ -3190,11 +3245,13 @@ class BackendApiClients {
|
|
|
3190
3245
|
sessionsApi;
|
|
3191
3246
|
authenticationApi;
|
|
3192
3247
|
constructor(config) {
|
|
3248
|
+
// @ts-ignore
|
|
3249
|
+
const axios = globalAxios.default ? globalAxios.default : globalAxios;
|
|
3193
3250
|
this.config = config;
|
|
3194
|
-
this.transactionIntentsApi = new TransactionIntentsApi(config.backend);
|
|
3195
|
-
this.accountsApi = new AccountsApi(config.backend);
|
|
3196
|
-
this.sessionsApi = new SessionsApi(config.backend);
|
|
3197
|
-
this.authenticationApi = new AuthenticationApi(config.backend);
|
|
3251
|
+
this.transactionIntentsApi = new TransactionIntentsApi(config.backend, undefined, axios);
|
|
3252
|
+
this.accountsApi = new AccountsApi(config.backend, undefined, axios);
|
|
3253
|
+
this.sessionsApi = new SessionsApi(config.backend, undefined, axios);
|
|
3254
|
+
this.authenticationApi = new AuthenticationApi(config.backend, undefined, axios);
|
|
3198
3255
|
}
|
|
3199
3256
|
}
|
|
3200
3257
|
|
|
@@ -3282,7 +3339,7 @@ class KeyPair extends signingKey.SigningKey {
|
|
|
3282
3339
|
}
|
|
3283
3340
|
}
|
|
3284
3341
|
|
|
3285
|
-
const VERSION = '0.8.
|
|
3342
|
+
const VERSION = '0.8.15';
|
|
3286
3343
|
|
|
3287
3344
|
var Event;
|
|
3288
3345
|
(function (Event) {
|
|
@@ -3418,15 +3475,17 @@ class ConfigureResponse {
|
|
|
3418
3475
|
address;
|
|
3419
3476
|
chainId;
|
|
3420
3477
|
accountType;
|
|
3478
|
+
ownerAddress;
|
|
3421
3479
|
action = Event.CONFIGURED;
|
|
3422
3480
|
version;
|
|
3423
|
-
constructor(uuid, deviceID, accountType, chainId, address) {
|
|
3481
|
+
constructor(uuid, deviceID, accountType, chainId, address, ownerAddress) {
|
|
3424
3482
|
this.success = true;
|
|
3425
3483
|
this.deviceID = deviceID;
|
|
3426
3484
|
this.uuid = uuid;
|
|
3427
3485
|
this.accountType = accountType;
|
|
3428
3486
|
this.chainId = chainId;
|
|
3429
3487
|
this.address = address;
|
|
3488
|
+
this.ownerAddress = ownerAddress;
|
|
3430
3489
|
this.version = null;
|
|
3431
3490
|
}
|
|
3432
3491
|
}
|
|
@@ -3525,30 +3584,56 @@ class IframeManager {
|
|
|
3525
3584
|
this.sdkConfiguration = configuration;
|
|
3526
3585
|
}
|
|
3527
3586
|
async iframeSetup() {
|
|
3528
|
-
window.addEventListener
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
if (data.action
|
|
3533
|
-
|
|
3587
|
+
if (window.addEventListener) {
|
|
3588
|
+
window.addEventListener('message', (event) => {
|
|
3589
|
+
if (event.origin === this.sdkConfiguration.iframeUrl) {
|
|
3590
|
+
const { data } = event;
|
|
3591
|
+
if (data.action) {
|
|
3592
|
+
if (data.action === Event.PONG) {
|
|
3593
|
+
this.responses.set('FIRST', data);
|
|
3594
|
+
}
|
|
3595
|
+
this.responses.set(data.uuid, data);
|
|
3534
3596
|
}
|
|
3535
|
-
this.responses.set(data.uuid, data);
|
|
3536
3597
|
}
|
|
3598
|
+
});
|
|
3599
|
+
const previousIframe = document.getElementById('openfort-iframe');
|
|
3600
|
+
if (previousIframe) {
|
|
3601
|
+
document.body.removeChild(previousIframe);
|
|
3537
3602
|
}
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
document.body.
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
this.iframe
|
|
3603
|
+
const iframe = document.createElement('iframe');
|
|
3604
|
+
iframe.style.display = 'none';
|
|
3605
|
+
iframe.id = 'openfort-iframe';
|
|
3606
|
+
document.body.appendChild(iframe);
|
|
3607
|
+
if (this.sdkConfiguration.shieldConfiguration?.debug) {
|
|
3608
|
+
iframe.src = `${this.sdkConfiguration.iframeUrl}?debug=true`;
|
|
3609
|
+
}
|
|
3610
|
+
else {
|
|
3611
|
+
iframe.src = this.sdkConfiguration.iframeUrl;
|
|
3612
|
+
}
|
|
3613
|
+
this.iframe = iframe;
|
|
3549
3614
|
}
|
|
3550
3615
|
else {
|
|
3551
|
-
|
|
3616
|
+
if (!global.openfortListener)
|
|
3617
|
+
return;
|
|
3618
|
+
global.openfortListener((event) => {
|
|
3619
|
+
if (event.origin === this.sdkConfiguration.iframeUrl) {
|
|
3620
|
+
let { data } = event;
|
|
3621
|
+
if (typeof data === 'string')
|
|
3622
|
+
data = JSON.parse(data);
|
|
3623
|
+
if (data.action) {
|
|
3624
|
+
this.responses.set(data.uuid, data);
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
});
|
|
3628
|
+
this.iframe = {
|
|
3629
|
+
contentWindow: {
|
|
3630
|
+
postMessage: (message) => {
|
|
3631
|
+
if (!global.openfortPostMessage)
|
|
3632
|
+
return;
|
|
3633
|
+
global.openfortPostMessage(message);
|
|
3634
|
+
},
|
|
3635
|
+
},
|
|
3636
|
+
};
|
|
3552
3637
|
}
|
|
3553
3638
|
}
|
|
3554
3639
|
isLoaded() {
|
|
@@ -4015,11 +4100,13 @@ class SessionSigner {
|
|
|
4015
4100
|
class Account {
|
|
4016
4101
|
type;
|
|
4017
4102
|
address;
|
|
4103
|
+
ownerAddress;
|
|
4018
4104
|
chainId;
|
|
4019
|
-
constructor(type, address, chainId) {
|
|
4105
|
+
constructor(type, address, chainId, ownerAddress) {
|
|
4020
4106
|
this.type = type;
|
|
4021
4107
|
this.address = address;
|
|
4022
4108
|
this.chainId = chainId;
|
|
4109
|
+
this.ownerAddress = ownerAddress;
|
|
4023
4110
|
}
|
|
4024
4111
|
static fromStorage(storage) {
|
|
4025
4112
|
const account = storage.get(StorageKeys.ACCOUNT);
|
|
@@ -4027,7 +4114,7 @@ class Account {
|
|
|
4027
4114
|
return null;
|
|
4028
4115
|
}
|
|
4029
4116
|
const accountObj = JSON.parse(account);
|
|
4030
|
-
return new Account(accountObj.type, accountObj.address, accountObj.chainId);
|
|
4117
|
+
return new Account(accountObj.type, accountObj.address, accountObj.chainId, accountObj.ownerAddress);
|
|
4031
4118
|
}
|
|
4032
4119
|
save(storage) {
|
|
4033
4120
|
storage.save(StorageKeys.ACCOUNT, JSON.stringify(this));
|
|
@@ -4139,7 +4226,7 @@ class SignerManager {
|
|
|
4139
4226
|
};
|
|
4140
4227
|
SignerManager.storage.save(StorageKeys.SIGNER, JSON.stringify(signerConfiguration));
|
|
4141
4228
|
const resp = await iframeManager.configure(iframeConfiguration);
|
|
4142
|
-
new Account(resp.accountType, resp.address, resp.chainId).save(this.storage);
|
|
4229
|
+
new Account(resp.accountType, resp.address, resp.chainId, resp.ownerAddress).save(this.storage);
|
|
4143
4230
|
return new EmbeddedSigner(iframeManager, iframeConfiguration, this.storage);
|
|
4144
4231
|
}
|
|
4145
4232
|
static shieldAuthentication(recovery, authentication, entropy) {
|
|
@@ -4302,6 +4389,11 @@ class AuthManager {
|
|
|
4302
4389
|
key: result.data.key,
|
|
4303
4390
|
};
|
|
4304
4391
|
}
|
|
4392
|
+
async registerGuest() {
|
|
4393
|
+
const request = {};
|
|
4394
|
+
const response = await this.backendApiClients.authenticationApi.registerGuest(request);
|
|
4395
|
+
return response.data;
|
|
4396
|
+
}
|
|
4305
4397
|
async poolOAuth(key) {
|
|
4306
4398
|
const request = {
|
|
4307
4399
|
key,
|
|
@@ -4480,13 +4572,40 @@ class AuthManager {
|
|
|
4480
4572
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4481
4573
|
}, { default: exports.OpenfortErrorType.USER_REGISTRATION_ERROR, 403: exports.OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM });
|
|
4482
4574
|
}
|
|
4483
|
-
|
|
4484
|
-
|
|
4575
|
+
// Slower validation function for browsers that do not support crypto.subtle
|
|
4576
|
+
async validateCredentialsWithoutCrypto(jwk, authentication) {
|
|
4485
4577
|
if (!authentication.refreshToken) {
|
|
4486
4578
|
throw new OpenfortError('No refresh token provided', exports.OpenfortErrorType.AUTHENTICATION_ERROR);
|
|
4487
4579
|
}
|
|
4488
|
-
|
|
4489
|
-
|
|
4580
|
+
const ecKey = jsrsasign.KEYUTIL.getKey({
|
|
4581
|
+
kty: jwk.kty,
|
|
4582
|
+
crv: jwk.crv,
|
|
4583
|
+
x: jwk.x,
|
|
4584
|
+
y: jwk.y,
|
|
4585
|
+
});
|
|
4586
|
+
const parsedJWT = jsrsasign.KJUR.jws.JWS.parse(authentication.token);
|
|
4587
|
+
const isValid = jsrsasign.KJUR.jws.JWS.verifyJWT(authentication.token, ecKey, { alg: [jwk.alg] });
|
|
4588
|
+
if (!isValid) {
|
|
4589
|
+
throw new OpenfortError('Invalid token signature', exports.OpenfortErrorType.AUTHENTICATION_ERROR);
|
|
4590
|
+
}
|
|
4591
|
+
const payload = JSON.parse(parsedJWT.payloadPP);
|
|
4592
|
+
if (!payload.exp) {
|
|
4593
|
+
return this.refreshTokens(authentication.refreshToken);
|
|
4594
|
+
}
|
|
4595
|
+
const now = jsrsasign.KJUR.jws.IntDate.getNow();
|
|
4596
|
+
if (payload.exp < now) {
|
|
4597
|
+
return this.refreshTokens(authentication.refreshToken);
|
|
4598
|
+
}
|
|
4599
|
+
return {
|
|
4600
|
+
player: payload.sub,
|
|
4601
|
+
accessToken: authentication.token,
|
|
4602
|
+
refreshToken: authentication.refreshToken,
|
|
4603
|
+
};
|
|
4604
|
+
}
|
|
4605
|
+
// Faster validation function for browsers that support crypto.subtle
|
|
4606
|
+
async validateCredentialsWithCrypto(jwk, authentication) {
|
|
4607
|
+
if (!authentication.refreshToken) {
|
|
4608
|
+
throw new OpenfortError('No refresh token provided', exports.OpenfortErrorType.AUTHENTICATION_ERROR);
|
|
4490
4609
|
}
|
|
4491
4610
|
try {
|
|
4492
4611
|
const key = (await jose.importJWK({
|
|
@@ -4509,6 +4628,19 @@ class AuthManager {
|
|
|
4509
4628
|
throw error;
|
|
4510
4629
|
}
|
|
4511
4630
|
}
|
|
4631
|
+
async validateCredentials(authentication, forceRefresh) {
|
|
4632
|
+
const jwk = await this.getJWK();
|
|
4633
|
+
if (!authentication.refreshToken) {
|
|
4634
|
+
throw new OpenfortError('No refresh token provided', exports.OpenfortErrorType.AUTHENTICATION_ERROR);
|
|
4635
|
+
}
|
|
4636
|
+
if (forceRefresh) {
|
|
4637
|
+
return this.refreshTokens(authentication.refreshToken, forceRefresh);
|
|
4638
|
+
}
|
|
4639
|
+
if (crypto__namespace.subtle) {
|
|
4640
|
+
return this.validateCredentialsWithCrypto(jwk, authentication);
|
|
4641
|
+
}
|
|
4642
|
+
return this.validateCredentialsWithoutCrypto(jwk, authentication);
|
|
4643
|
+
}
|
|
4512
4644
|
jwksStorageKey = 'openfort.jwk';
|
|
4513
4645
|
// eslint-disable-next-line class-methods-use-this
|
|
4514
4646
|
stringToJWK(jwkString) {
|
|
@@ -6235,10 +6367,10 @@ const buildOpenfortTransactions$3 = async (params, backendApiClients, account, a
|
|
|
6235
6367
|
function formatRequest(result) {
|
|
6236
6368
|
return {
|
|
6237
6369
|
expiry: result.validUntil ? Number(result.validUntil) : 0,
|
|
6238
|
-
grantedPermissions: result.whitelist
|
|
6370
|
+
grantedPermissions: result.whitelist ? result.whitelist.map((address) => ({
|
|
6239
6371
|
type: 'contract-call',
|
|
6240
6372
|
data: {
|
|
6241
|
-
address,
|
|
6373
|
+
address: address,
|
|
6242
6374
|
calls: [],
|
|
6243
6375
|
},
|
|
6244
6376
|
policies: [{
|
|
@@ -6247,7 +6379,7 @@ function formatRequest(result) {
|
|
|
6247
6379
|
},
|
|
6248
6380
|
type: { custom: 'usage-limit' },
|
|
6249
6381
|
}],
|
|
6250
|
-
})),
|
|
6382
|
+
})) : [],
|
|
6251
6383
|
permissionsContext: result.id,
|
|
6252
6384
|
};
|
|
6253
6385
|
}
|
|
@@ -6355,7 +6487,8 @@ const buildOpenfortTransactions$1 = async (calls, backendApiClients, account, au
|
|
|
6355
6487
|
return transactionResponse.data;
|
|
6356
6488
|
};
|
|
6357
6489
|
const sendCalls = async ({ params, signer, account, authentication, backendClient, policyId, }) => {
|
|
6358
|
-
const
|
|
6490
|
+
const policy = params[0]?.capabilities?.paymasterService?.policy ?? policyId;
|
|
6491
|
+
const openfortTransaction = await buildOpenfortTransactions$1(params[0].calls, backendClient, account, authentication, policy);
|
|
6359
6492
|
let response;
|
|
6360
6493
|
if (openfortTransaction?.nextAction?.payload?.signableHash) {
|
|
6361
6494
|
const signature = await signer.sign(openfortTransaction.nextAction.payload.signableHash);
|
|
@@ -6597,6 +6730,9 @@ class EvmProvider {
|
|
|
6597
6730
|
keyTypes: ['secp256k1'],
|
|
6598
6731
|
permissionTypes: ['contract-calls'],
|
|
6599
6732
|
},
|
|
6733
|
+
paymasterService: {
|
|
6734
|
+
supported: true,
|
|
6735
|
+
},
|
|
6600
6736
|
},
|
|
6601
6737
|
};
|
|
6602
6738
|
return capabilities;
|
|
@@ -6739,7 +6875,7 @@ class Openfort {
|
|
|
6739
6875
|
storage;
|
|
6740
6876
|
constructor(sdkConfiguration) {
|
|
6741
6877
|
this.storage = new LocalStorage();
|
|
6742
|
-
const configuration = new Configuration(sdkConfiguration.baseConfiguration.publishableKey, sdkConfiguration.overrides?.backendUrl || 'https://api.openfort.xyz', sdkConfiguration.shieldConfiguration?.shieldPublishableKey || '', sdkConfiguration.shieldConfiguration?.shieldEncryptionKey || '', sdkConfiguration.overrides?.shieldUrl || 'https://shield.openfort.xyz', sdkConfiguration.overrides?.iframeUrl || 'https://
|
|
6878
|
+
const configuration = new Configuration(sdkConfiguration.baseConfiguration.publishableKey, sdkConfiguration.overrides?.backendUrl || 'https://api.openfort.xyz', sdkConfiguration.shieldConfiguration?.shieldPublishableKey || '', sdkConfiguration.shieldConfiguration?.shieldEncryptionKey || '', sdkConfiguration.overrides?.shieldUrl || 'https://shield.openfort.xyz', sdkConfiguration.overrides?.iframeUrl || 'https://embedded.openfort.xyz', sdkConfiguration.shieldConfiguration?.debug || false);
|
|
6743
6879
|
configuration.save();
|
|
6744
6880
|
}
|
|
6745
6881
|
/**
|
|
@@ -6924,6 +7060,20 @@ class Openfort {
|
|
|
6924
7060
|
new Authentication('jwt', result.token, result.player.id, result.refreshToken).save(this.storage);
|
|
6925
7061
|
return result;
|
|
6926
7062
|
}
|
|
7063
|
+
/**
|
|
7064
|
+
* Registers a new guest user.
|
|
7065
|
+
*
|
|
7066
|
+
* @returns An AuthResponse object containing authentication details.
|
|
7067
|
+
*/
|
|
7068
|
+
async signUpGuest() {
|
|
7069
|
+
const previousAuth = Authentication.fromStorage(this.storage);
|
|
7070
|
+
const result = await this.authManager.registerGuest();
|
|
7071
|
+
if (previousAuth && previousAuth.player !== result.player.id) {
|
|
7072
|
+
this.logout();
|
|
7073
|
+
}
|
|
7074
|
+
new Authentication('jwt', result.token, result.player.id, result.refreshToken).save(this.storage);
|
|
7075
|
+
return result;
|
|
7076
|
+
}
|
|
6927
7077
|
/**
|
|
6928
7078
|
* Signs up a new user with email and password.
|
|
6929
7079
|
*
|
|
@@ -7208,6 +7358,7 @@ class Openfort {
|
|
|
7208
7358
|
return {
|
|
7209
7359
|
chainId: account.chainId,
|
|
7210
7360
|
address: account.address,
|
|
7361
|
+
ownerAddress: account.ownerAddress,
|
|
7211
7362
|
accountType: account.type,
|
|
7212
7363
|
};
|
|
7213
7364
|
}
|
|
@@ -7350,7 +7501,7 @@ class SDKConfiguration {
|
|
|
7350
7501
|
this.baseConfiguration = baseConfiguration;
|
|
7351
7502
|
if (overrides) {
|
|
7352
7503
|
this.backendUrl = overrides.backendUrl || 'https://api.openfort.xyz';
|
|
7353
|
-
this.iframeUrl = overrides.iframeUrl || 'https://
|
|
7504
|
+
this.iframeUrl = overrides.iframeUrl || 'https://embedded.openfort.xyz';
|
|
7354
7505
|
this.shieldUrl = overrides.shieldUrl || 'https://shield.openfort.xyz';
|
|
7355
7506
|
this.openfortAPIConfig = {
|
|
7356
7507
|
backend: createConfig({
|
|
@@ -7361,7 +7512,7 @@ class SDKConfiguration {
|
|
|
7361
7512
|
}
|
|
7362
7513
|
else {
|
|
7363
7514
|
this.backendUrl = 'https://api.openfort.xyz';
|
|
7364
|
-
this.iframeUrl = 'https://
|
|
7515
|
+
this.iframeUrl = 'https://embedded.openfort.xyz';
|
|
7365
7516
|
this.shieldUrl = 'https://shield.openfort.xyz';
|
|
7366
7517
|
this.openfortAPIConfig = {
|
|
7367
7518
|
backend: createConfig({
|
package/dist/index.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ type SessionKey = {
|
|
|
77
77
|
};
|
|
78
78
|
type CurrentAccount = {
|
|
79
79
|
address: string;
|
|
80
|
+
ownerAddress: string;
|
|
80
81
|
accountType: AccountType;
|
|
81
82
|
chainId: number;
|
|
82
83
|
};
|
|
@@ -657,6 +658,12 @@ declare class Openfort {
|
|
|
657
658
|
password: string;
|
|
658
659
|
ecosystemGame?: string;
|
|
659
660
|
}): Promise<AuthResponse>;
|
|
661
|
+
/**
|
|
662
|
+
* Registers a new guest user.
|
|
663
|
+
*
|
|
664
|
+
* @returns An AuthResponse object containing authentication details.
|
|
665
|
+
*/
|
|
666
|
+
signUpGuest(): Promise<AuthResponse>;
|
|
660
667
|
/**
|
|
661
668
|
* Signs up a new user with email and password.
|
|
662
669
|
*
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,9 @@ import { secp256k1 } from '@noble/curves/secp256k1';
|
|
|
4
4
|
import { SigningKey } from '@ethersproject/signing-key';
|
|
5
5
|
import { joinSignature, arrayify, hexlify } from '@ethersproject/bytes';
|
|
6
6
|
import { computeAddress } from '@ethersproject/transactions';
|
|
7
|
-
import { importJWK, jwtVerify, errors } from 'jose';
|
|
8
7
|
import * as crypto from 'crypto';
|
|
8
|
+
import { importJWK, jwtVerify, errors } from 'jose';
|
|
9
|
+
import { KEYUTIL, KJUR } from 'jsrsasign';
|
|
9
10
|
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
10
11
|
import { EventEmitter } from 'events';
|
|
11
12
|
import { v4 } from 'uuid';
|
|
@@ -1356,6 +1357,38 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
|
|
|
1356
1357
|
options: localVarRequestOptions,
|
|
1357
1358
|
};
|
|
1358
1359
|
},
|
|
1360
|
+
/**
|
|
1361
|
+
* Create a guest player.
|
|
1362
|
+
* @summary Create a guest player.
|
|
1363
|
+
* @param {string} [xGame]
|
|
1364
|
+
* @param {*} [options] Override http request option.
|
|
1365
|
+
* @throws {RequiredError}
|
|
1366
|
+
*/
|
|
1367
|
+
registerGuest: async (xGame, options = {}) => {
|
|
1368
|
+
const localVarPath = `/iam/v1/guest`;
|
|
1369
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
1370
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
1371
|
+
let baseOptions;
|
|
1372
|
+
if (configuration) {
|
|
1373
|
+
baseOptions = configuration.baseOptions;
|
|
1374
|
+
}
|
|
1375
|
+
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
|
|
1376
|
+
const localVarHeaderParameter = {};
|
|
1377
|
+
const localVarQueryParameter = {};
|
|
1378
|
+
// authentication pk required
|
|
1379
|
+
// http bearer authentication required
|
|
1380
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
1381
|
+
if (xGame != null) {
|
|
1382
|
+
localVarHeaderParameter['x-game'] = String(xGame);
|
|
1383
|
+
}
|
|
1384
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1385
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
1386
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
1387
|
+
return {
|
|
1388
|
+
url: toPathString(localVarUrlObj),
|
|
1389
|
+
options: localVarRequestOptions,
|
|
1390
|
+
};
|
|
1391
|
+
},
|
|
1359
1392
|
/**
|
|
1360
1393
|
* Start the Email Verification process for a player.
|
|
1361
1394
|
* @summary Request an Email Verification.
|
|
@@ -1914,6 +1947,17 @@ const AuthenticationApiFp = function (configuration) {
|
|
|
1914
1947
|
const localVarAxiosArgs = await localVarAxiosParamCreator.refresh(refreshTokenRequest, options);
|
|
1915
1948
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1916
1949
|
},
|
|
1950
|
+
/**
|
|
1951
|
+
* Create a guest player.
|
|
1952
|
+
* @summary Create a guest player.
|
|
1953
|
+
* @param {string} [xGame]
|
|
1954
|
+
* @param {*} [options] Override http request option.
|
|
1955
|
+
* @throws {RequiredError}
|
|
1956
|
+
*/
|
|
1957
|
+
async registerGuest(xGame, options) {
|
|
1958
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.registerGuest(xGame, options);
|
|
1959
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
1960
|
+
},
|
|
1917
1961
|
/**
|
|
1918
1962
|
* Start the Email Verification process for a player.
|
|
1919
1963
|
* @summary Request an Email Verification.
|
|
@@ -2222,6 +2266,17 @@ class AuthenticationApi extends BaseAPI {
|
|
|
2222
2266
|
refresh(requestParameters, options) {
|
|
2223
2267
|
return AuthenticationApiFp(this.configuration).refresh(requestParameters.refreshTokenRequest, options).then((request) => request(this.axios, this.basePath));
|
|
2224
2268
|
}
|
|
2269
|
+
/**
|
|
2270
|
+
* Create a guest player.
|
|
2271
|
+
* @summary Create a guest player.
|
|
2272
|
+
* @param {AuthenticationApiRegisterGuestRequest} requestParameters Request parameters.
|
|
2273
|
+
* @param {*} [options] Override http request option.
|
|
2274
|
+
* @throws {RequiredError}
|
|
2275
|
+
* @memberof AuthenticationApi
|
|
2276
|
+
*/
|
|
2277
|
+
registerGuest(requestParameters = {}, options) {
|
|
2278
|
+
return AuthenticationApiFp(this.configuration).registerGuest(requestParameters.xGame, options).then((request) => request(this.axios, this.basePath));
|
|
2279
|
+
}
|
|
2225
2280
|
/**
|
|
2226
2281
|
* Start the Email Verification process for a player.
|
|
2227
2282
|
* @summary Request an Email Verification.
|
|
@@ -3167,11 +3222,13 @@ class BackendApiClients {
|
|
|
3167
3222
|
sessionsApi;
|
|
3168
3223
|
authenticationApi;
|
|
3169
3224
|
constructor(config) {
|
|
3225
|
+
// @ts-ignore
|
|
3226
|
+
const axios = globalAxios.default ? globalAxios.default : globalAxios;
|
|
3170
3227
|
this.config = config;
|
|
3171
|
-
this.transactionIntentsApi = new TransactionIntentsApi(config.backend);
|
|
3172
|
-
this.accountsApi = new AccountsApi(config.backend);
|
|
3173
|
-
this.sessionsApi = new SessionsApi(config.backend);
|
|
3174
|
-
this.authenticationApi = new AuthenticationApi(config.backend);
|
|
3228
|
+
this.transactionIntentsApi = new TransactionIntentsApi(config.backend, undefined, axios);
|
|
3229
|
+
this.accountsApi = new AccountsApi(config.backend, undefined, axios);
|
|
3230
|
+
this.sessionsApi = new SessionsApi(config.backend, undefined, axios);
|
|
3231
|
+
this.authenticationApi = new AuthenticationApi(config.backend, undefined, axios);
|
|
3175
3232
|
}
|
|
3176
3233
|
}
|
|
3177
3234
|
|
|
@@ -3259,7 +3316,7 @@ class KeyPair extends SigningKey {
|
|
|
3259
3316
|
}
|
|
3260
3317
|
}
|
|
3261
3318
|
|
|
3262
|
-
const VERSION = '0.8.
|
|
3319
|
+
const VERSION = '0.8.15';
|
|
3263
3320
|
|
|
3264
3321
|
var Event;
|
|
3265
3322
|
(function (Event) {
|
|
@@ -3395,15 +3452,17 @@ class ConfigureResponse {
|
|
|
3395
3452
|
address;
|
|
3396
3453
|
chainId;
|
|
3397
3454
|
accountType;
|
|
3455
|
+
ownerAddress;
|
|
3398
3456
|
action = Event.CONFIGURED;
|
|
3399
3457
|
version;
|
|
3400
|
-
constructor(uuid, deviceID, accountType, chainId, address) {
|
|
3458
|
+
constructor(uuid, deviceID, accountType, chainId, address, ownerAddress) {
|
|
3401
3459
|
this.success = true;
|
|
3402
3460
|
this.deviceID = deviceID;
|
|
3403
3461
|
this.uuid = uuid;
|
|
3404
3462
|
this.accountType = accountType;
|
|
3405
3463
|
this.chainId = chainId;
|
|
3406
3464
|
this.address = address;
|
|
3465
|
+
this.ownerAddress = ownerAddress;
|
|
3407
3466
|
this.version = null;
|
|
3408
3467
|
}
|
|
3409
3468
|
}
|
|
@@ -3502,30 +3561,56 @@ class IframeManager {
|
|
|
3502
3561
|
this.sdkConfiguration = configuration;
|
|
3503
3562
|
}
|
|
3504
3563
|
async iframeSetup() {
|
|
3505
|
-
window.addEventListener
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
if (data.action
|
|
3510
|
-
|
|
3564
|
+
if (window.addEventListener) {
|
|
3565
|
+
window.addEventListener('message', (event) => {
|
|
3566
|
+
if (event.origin === this.sdkConfiguration.iframeUrl) {
|
|
3567
|
+
const { data } = event;
|
|
3568
|
+
if (data.action) {
|
|
3569
|
+
if (data.action === Event.PONG) {
|
|
3570
|
+
this.responses.set('FIRST', data);
|
|
3571
|
+
}
|
|
3572
|
+
this.responses.set(data.uuid, data);
|
|
3511
3573
|
}
|
|
3512
|
-
this.responses.set(data.uuid, data);
|
|
3513
3574
|
}
|
|
3575
|
+
});
|
|
3576
|
+
const previousIframe = document.getElementById('openfort-iframe');
|
|
3577
|
+
if (previousIframe) {
|
|
3578
|
+
document.body.removeChild(previousIframe);
|
|
3514
3579
|
}
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
document.body.
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
this.iframe
|
|
3580
|
+
const iframe = document.createElement('iframe');
|
|
3581
|
+
iframe.style.display = 'none';
|
|
3582
|
+
iframe.id = 'openfort-iframe';
|
|
3583
|
+
document.body.appendChild(iframe);
|
|
3584
|
+
if (this.sdkConfiguration.shieldConfiguration?.debug) {
|
|
3585
|
+
iframe.src = `${this.sdkConfiguration.iframeUrl}?debug=true`;
|
|
3586
|
+
}
|
|
3587
|
+
else {
|
|
3588
|
+
iframe.src = this.sdkConfiguration.iframeUrl;
|
|
3589
|
+
}
|
|
3590
|
+
this.iframe = iframe;
|
|
3526
3591
|
}
|
|
3527
3592
|
else {
|
|
3528
|
-
|
|
3593
|
+
if (!global.openfortListener)
|
|
3594
|
+
return;
|
|
3595
|
+
global.openfortListener((event) => {
|
|
3596
|
+
if (event.origin === this.sdkConfiguration.iframeUrl) {
|
|
3597
|
+
let { data } = event;
|
|
3598
|
+
if (typeof data === 'string')
|
|
3599
|
+
data = JSON.parse(data);
|
|
3600
|
+
if (data.action) {
|
|
3601
|
+
this.responses.set(data.uuid, data);
|
|
3602
|
+
}
|
|
3603
|
+
}
|
|
3604
|
+
});
|
|
3605
|
+
this.iframe = {
|
|
3606
|
+
contentWindow: {
|
|
3607
|
+
postMessage: (message) => {
|
|
3608
|
+
if (!global.openfortPostMessage)
|
|
3609
|
+
return;
|
|
3610
|
+
global.openfortPostMessage(message);
|
|
3611
|
+
},
|
|
3612
|
+
},
|
|
3613
|
+
};
|
|
3529
3614
|
}
|
|
3530
3615
|
}
|
|
3531
3616
|
isLoaded() {
|
|
@@ -3992,11 +4077,13 @@ class SessionSigner {
|
|
|
3992
4077
|
class Account {
|
|
3993
4078
|
type;
|
|
3994
4079
|
address;
|
|
4080
|
+
ownerAddress;
|
|
3995
4081
|
chainId;
|
|
3996
|
-
constructor(type, address, chainId) {
|
|
4082
|
+
constructor(type, address, chainId, ownerAddress) {
|
|
3997
4083
|
this.type = type;
|
|
3998
4084
|
this.address = address;
|
|
3999
4085
|
this.chainId = chainId;
|
|
4086
|
+
this.ownerAddress = ownerAddress;
|
|
4000
4087
|
}
|
|
4001
4088
|
static fromStorage(storage) {
|
|
4002
4089
|
const account = storage.get(StorageKeys.ACCOUNT);
|
|
@@ -4004,7 +4091,7 @@ class Account {
|
|
|
4004
4091
|
return null;
|
|
4005
4092
|
}
|
|
4006
4093
|
const accountObj = JSON.parse(account);
|
|
4007
|
-
return new Account(accountObj.type, accountObj.address, accountObj.chainId);
|
|
4094
|
+
return new Account(accountObj.type, accountObj.address, accountObj.chainId, accountObj.ownerAddress);
|
|
4008
4095
|
}
|
|
4009
4096
|
save(storage) {
|
|
4010
4097
|
storage.save(StorageKeys.ACCOUNT, JSON.stringify(this));
|
|
@@ -4116,7 +4203,7 @@ class SignerManager {
|
|
|
4116
4203
|
};
|
|
4117
4204
|
SignerManager.storage.save(StorageKeys.SIGNER, JSON.stringify(signerConfiguration));
|
|
4118
4205
|
const resp = await iframeManager.configure(iframeConfiguration);
|
|
4119
|
-
new Account(resp.accountType, resp.address, resp.chainId).save(this.storage);
|
|
4206
|
+
new Account(resp.accountType, resp.address, resp.chainId, resp.ownerAddress).save(this.storage);
|
|
4120
4207
|
return new EmbeddedSigner(iframeManager, iframeConfiguration, this.storage);
|
|
4121
4208
|
}
|
|
4122
4209
|
static shieldAuthentication(recovery, authentication, entropy) {
|
|
@@ -4279,6 +4366,11 @@ class AuthManager {
|
|
|
4279
4366
|
key: result.data.key,
|
|
4280
4367
|
};
|
|
4281
4368
|
}
|
|
4369
|
+
async registerGuest() {
|
|
4370
|
+
const request = {};
|
|
4371
|
+
const response = await this.backendApiClients.authenticationApi.registerGuest(request);
|
|
4372
|
+
return response.data;
|
|
4373
|
+
}
|
|
4282
4374
|
async poolOAuth(key) {
|
|
4283
4375
|
const request = {
|
|
4284
4376
|
key,
|
|
@@ -4457,13 +4549,40 @@ class AuthManager {
|
|
|
4457
4549
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4458
4550
|
}, { default: OpenfortErrorType.USER_REGISTRATION_ERROR, 403: OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM });
|
|
4459
4551
|
}
|
|
4460
|
-
|
|
4461
|
-
|
|
4552
|
+
// Slower validation function for browsers that do not support crypto.subtle
|
|
4553
|
+
async validateCredentialsWithoutCrypto(jwk, authentication) {
|
|
4462
4554
|
if (!authentication.refreshToken) {
|
|
4463
4555
|
throw new OpenfortError('No refresh token provided', OpenfortErrorType.AUTHENTICATION_ERROR);
|
|
4464
4556
|
}
|
|
4465
|
-
|
|
4466
|
-
|
|
4557
|
+
const ecKey = KEYUTIL.getKey({
|
|
4558
|
+
kty: jwk.kty,
|
|
4559
|
+
crv: jwk.crv,
|
|
4560
|
+
x: jwk.x,
|
|
4561
|
+
y: jwk.y,
|
|
4562
|
+
});
|
|
4563
|
+
const parsedJWT = KJUR.jws.JWS.parse(authentication.token);
|
|
4564
|
+
const isValid = KJUR.jws.JWS.verifyJWT(authentication.token, ecKey, { alg: [jwk.alg] });
|
|
4565
|
+
if (!isValid) {
|
|
4566
|
+
throw new OpenfortError('Invalid token signature', OpenfortErrorType.AUTHENTICATION_ERROR);
|
|
4567
|
+
}
|
|
4568
|
+
const payload = JSON.parse(parsedJWT.payloadPP);
|
|
4569
|
+
if (!payload.exp) {
|
|
4570
|
+
return this.refreshTokens(authentication.refreshToken);
|
|
4571
|
+
}
|
|
4572
|
+
const now = KJUR.jws.IntDate.getNow();
|
|
4573
|
+
if (payload.exp < now) {
|
|
4574
|
+
return this.refreshTokens(authentication.refreshToken);
|
|
4575
|
+
}
|
|
4576
|
+
return {
|
|
4577
|
+
player: payload.sub,
|
|
4578
|
+
accessToken: authentication.token,
|
|
4579
|
+
refreshToken: authentication.refreshToken,
|
|
4580
|
+
};
|
|
4581
|
+
}
|
|
4582
|
+
// Faster validation function for browsers that support crypto.subtle
|
|
4583
|
+
async validateCredentialsWithCrypto(jwk, authentication) {
|
|
4584
|
+
if (!authentication.refreshToken) {
|
|
4585
|
+
throw new OpenfortError('No refresh token provided', OpenfortErrorType.AUTHENTICATION_ERROR);
|
|
4467
4586
|
}
|
|
4468
4587
|
try {
|
|
4469
4588
|
const key = (await importJWK({
|
|
@@ -4486,6 +4605,19 @@ class AuthManager {
|
|
|
4486
4605
|
throw error;
|
|
4487
4606
|
}
|
|
4488
4607
|
}
|
|
4608
|
+
async validateCredentials(authentication, forceRefresh) {
|
|
4609
|
+
const jwk = await this.getJWK();
|
|
4610
|
+
if (!authentication.refreshToken) {
|
|
4611
|
+
throw new OpenfortError('No refresh token provided', OpenfortErrorType.AUTHENTICATION_ERROR);
|
|
4612
|
+
}
|
|
4613
|
+
if (forceRefresh) {
|
|
4614
|
+
return this.refreshTokens(authentication.refreshToken, forceRefresh);
|
|
4615
|
+
}
|
|
4616
|
+
if (crypto.subtle) {
|
|
4617
|
+
return this.validateCredentialsWithCrypto(jwk, authentication);
|
|
4618
|
+
}
|
|
4619
|
+
return this.validateCredentialsWithoutCrypto(jwk, authentication);
|
|
4620
|
+
}
|
|
4489
4621
|
jwksStorageKey = 'openfort.jwk';
|
|
4490
4622
|
// eslint-disable-next-line class-methods-use-this
|
|
4491
4623
|
stringToJWK(jwkString) {
|
|
@@ -6212,10 +6344,10 @@ const buildOpenfortTransactions$3 = async (params, backendApiClients, account, a
|
|
|
6212
6344
|
function formatRequest(result) {
|
|
6213
6345
|
return {
|
|
6214
6346
|
expiry: result.validUntil ? Number(result.validUntil) : 0,
|
|
6215
|
-
grantedPermissions: result.whitelist
|
|
6347
|
+
grantedPermissions: result.whitelist ? result.whitelist.map((address) => ({
|
|
6216
6348
|
type: 'contract-call',
|
|
6217
6349
|
data: {
|
|
6218
|
-
address,
|
|
6350
|
+
address: address,
|
|
6219
6351
|
calls: [],
|
|
6220
6352
|
},
|
|
6221
6353
|
policies: [{
|
|
@@ -6224,7 +6356,7 @@ function formatRequest(result) {
|
|
|
6224
6356
|
},
|
|
6225
6357
|
type: { custom: 'usage-limit' },
|
|
6226
6358
|
}],
|
|
6227
|
-
})),
|
|
6359
|
+
})) : [],
|
|
6228
6360
|
permissionsContext: result.id,
|
|
6229
6361
|
};
|
|
6230
6362
|
}
|
|
@@ -6332,7 +6464,8 @@ const buildOpenfortTransactions$1 = async (calls, backendApiClients, account, au
|
|
|
6332
6464
|
return transactionResponse.data;
|
|
6333
6465
|
};
|
|
6334
6466
|
const sendCalls = async ({ params, signer, account, authentication, backendClient, policyId, }) => {
|
|
6335
|
-
const
|
|
6467
|
+
const policy = params[0]?.capabilities?.paymasterService?.policy ?? policyId;
|
|
6468
|
+
const openfortTransaction = await buildOpenfortTransactions$1(params[0].calls, backendClient, account, authentication, policy);
|
|
6336
6469
|
let response;
|
|
6337
6470
|
if (openfortTransaction?.nextAction?.payload?.signableHash) {
|
|
6338
6471
|
const signature = await signer.sign(openfortTransaction.nextAction.payload.signableHash);
|
|
@@ -6574,6 +6707,9 @@ class EvmProvider {
|
|
|
6574
6707
|
keyTypes: ['secp256k1'],
|
|
6575
6708
|
permissionTypes: ['contract-calls'],
|
|
6576
6709
|
},
|
|
6710
|
+
paymasterService: {
|
|
6711
|
+
supported: true,
|
|
6712
|
+
},
|
|
6577
6713
|
},
|
|
6578
6714
|
};
|
|
6579
6715
|
return capabilities;
|
|
@@ -6716,7 +6852,7 @@ class Openfort {
|
|
|
6716
6852
|
storage;
|
|
6717
6853
|
constructor(sdkConfiguration) {
|
|
6718
6854
|
this.storage = new LocalStorage();
|
|
6719
|
-
const configuration = new Configuration(sdkConfiguration.baseConfiguration.publishableKey, sdkConfiguration.overrides?.backendUrl || 'https://api.openfort.xyz', sdkConfiguration.shieldConfiguration?.shieldPublishableKey || '', sdkConfiguration.shieldConfiguration?.shieldEncryptionKey || '', sdkConfiguration.overrides?.shieldUrl || 'https://shield.openfort.xyz', sdkConfiguration.overrides?.iframeUrl || 'https://
|
|
6855
|
+
const configuration = new Configuration(sdkConfiguration.baseConfiguration.publishableKey, sdkConfiguration.overrides?.backendUrl || 'https://api.openfort.xyz', sdkConfiguration.shieldConfiguration?.shieldPublishableKey || '', sdkConfiguration.shieldConfiguration?.shieldEncryptionKey || '', sdkConfiguration.overrides?.shieldUrl || 'https://shield.openfort.xyz', sdkConfiguration.overrides?.iframeUrl || 'https://embedded.openfort.xyz', sdkConfiguration.shieldConfiguration?.debug || false);
|
|
6720
6856
|
configuration.save();
|
|
6721
6857
|
}
|
|
6722
6858
|
/**
|
|
@@ -6901,6 +7037,20 @@ class Openfort {
|
|
|
6901
7037
|
new Authentication('jwt', result.token, result.player.id, result.refreshToken).save(this.storage);
|
|
6902
7038
|
return result;
|
|
6903
7039
|
}
|
|
7040
|
+
/**
|
|
7041
|
+
* Registers a new guest user.
|
|
7042
|
+
*
|
|
7043
|
+
* @returns An AuthResponse object containing authentication details.
|
|
7044
|
+
*/
|
|
7045
|
+
async signUpGuest() {
|
|
7046
|
+
const previousAuth = Authentication.fromStorage(this.storage);
|
|
7047
|
+
const result = await this.authManager.registerGuest();
|
|
7048
|
+
if (previousAuth && previousAuth.player !== result.player.id) {
|
|
7049
|
+
this.logout();
|
|
7050
|
+
}
|
|
7051
|
+
new Authentication('jwt', result.token, result.player.id, result.refreshToken).save(this.storage);
|
|
7052
|
+
return result;
|
|
7053
|
+
}
|
|
6904
7054
|
/**
|
|
6905
7055
|
* Signs up a new user with email and password.
|
|
6906
7056
|
*
|
|
@@ -7185,6 +7335,7 @@ class Openfort {
|
|
|
7185
7335
|
return {
|
|
7186
7336
|
chainId: account.chainId,
|
|
7187
7337
|
address: account.address,
|
|
7338
|
+
ownerAddress: account.ownerAddress,
|
|
7188
7339
|
accountType: account.type,
|
|
7189
7340
|
};
|
|
7190
7341
|
}
|
|
@@ -7327,7 +7478,7 @@ class SDKConfiguration {
|
|
|
7327
7478
|
this.baseConfiguration = baseConfiguration;
|
|
7328
7479
|
if (overrides) {
|
|
7329
7480
|
this.backendUrl = overrides.backendUrl || 'https://api.openfort.xyz';
|
|
7330
|
-
this.iframeUrl = overrides.iframeUrl || 'https://
|
|
7481
|
+
this.iframeUrl = overrides.iframeUrl || 'https://embedded.openfort.xyz';
|
|
7331
7482
|
this.shieldUrl = overrides.shieldUrl || 'https://shield.openfort.xyz';
|
|
7332
7483
|
this.openfortAPIConfig = {
|
|
7333
7484
|
backend: createConfig({
|
|
@@ -7338,7 +7489,7 @@ class SDKConfiguration {
|
|
|
7338
7489
|
}
|
|
7339
7490
|
else {
|
|
7340
7491
|
this.backendUrl = 'https://api.openfort.xyz';
|
|
7341
|
-
this.iframeUrl = 'https://
|
|
7492
|
+
this.iframeUrl = 'https://embedded.openfort.xyz';
|
|
7342
7493
|
this.shieldUrl = 'https://shield.openfort.xyz';
|
|
7343
7494
|
this.openfortAPIConfig = {
|
|
7344
7495
|
backend: createConfig({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfort/openfort-js",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.15",
|
|
4
4
|
"author": "Openfort (https://www.openfort.xyz)",
|
|
5
5
|
"bugs": "https://github.com/openfort-xyz/openfort-js/issues",
|
|
6
6
|
"repository": "openfort-xyz/openfort-js.git",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"crypto-js": "^4.2.0",
|
|
46
46
|
"es6-promise": "^4.2.8",
|
|
47
47
|
"jose": "^5.2.2",
|
|
48
|
+
"jsrsasign": "^11.1.0",
|
|
48
49
|
"path": "^0.12.7",
|
|
49
50
|
"stream-browserify": "^3.0.0",
|
|
50
51
|
"uuid": "^8.3.2"
|
|
@@ -72,6 +73,7 @@
|
|
|
72
73
|
"@swc/jest": "^0.2.24",
|
|
73
74
|
"@types/crypto-js": "^4.2.2",
|
|
74
75
|
"@types/jest": "^29.4.3",
|
|
76
|
+
"@types/jsrsasign": "^10.5.15",
|
|
75
77
|
"@types/uuid": "^8.3.4",
|
|
76
78
|
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
|
77
79
|
"@typescript-eslint/parser": "^5.57.1",
|