@openfort/openfort-js 0.7.1 → 0.7.2

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 CHANGED
@@ -43,16 +43,15 @@ exports.ThirdPartyOAuthProvider = void 0;
43
43
  ThirdPartyOAuthProvider["CUSTOM"] = "custom";
44
44
  ThirdPartyOAuthProvider["OIDC"] = "oidc";
45
45
  })(exports.ThirdPartyOAuthProvider || (exports.ThirdPartyOAuthProvider = {}));
46
+ exports.BasicAuthProvider = void 0;
47
+ (function (BasicAuthProvider) {
48
+ BasicAuthProvider["EMAIL"] = "email";
49
+ BasicAuthProvider["WALLET"] = "wallet";
50
+ })(exports.BasicAuthProvider || (exports.BasicAuthProvider = {}));
46
51
  exports.OAuthProvider = void 0;
47
52
  (function (OAuthProvider) {
48
- OAuthProvider["ACCELBYTE"] = "accelbyte";
49
- OAuthProvider["FIREBASE"] = "firebase";
50
53
  OAuthProvider["GOOGLE"] = "google";
51
- OAuthProvider["LOOTLOCKER"] = "lootlocker";
52
- OAuthProvider["PLAYFAB"] = "playfab";
53
- OAuthProvider["CUSTOM"] = "custom";
54
- OAuthProvider["OIDC"] = "oidc";
55
- OAuthProvider["SUPABASE"] = "supabase";
54
+ OAuthProvider["TWITTER"] = "twitter";
56
55
  })(exports.OAuthProvider || (exports.OAuthProvider = {}));
57
56
 
58
57
  /* tslint:disable */
@@ -865,7 +864,7 @@ class AccountsApi extends BaseAPI {
865
864
  const AuthenticationApiAxiosParamCreator = function (configuration) {
866
865
  return {
867
866
  /**
868
- *
867
+ * Deprecated
869
868
  * @summary Authenticate player with oauth token.
870
869
  * @param {AuthenticateOAuthRequest} authenticateOAuthRequest
871
870
  * @param {*} [options] Override http request option.
@@ -933,7 +932,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
933
932
  /**
934
933
  * 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.
935
934
  * @summary Authorize player with token.
936
- * @param {OAuthProvider} provider OAuth provider
935
+ * @param {AuthProvider} provider OAuth provider
937
936
  * @param {OAuthRequest} oAuthRequest
938
937
  * @param {*} [options] Override http request option.
939
938
  * @deprecated
@@ -1000,6 +999,36 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1000
999
  options: localVarRequestOptions,
1001
1000
  };
1002
1001
  },
1002
+ /**
1003
+ *
1004
+ * @summary Initialize Link OAuth.
1005
+ * @param {OAuthInitRequest} oAuthInitRequest
1006
+ * @param {*} [options] Override http request option.
1007
+ * @throws {RequiredError}
1008
+ */
1009
+ initLinkOAuth: async (oAuthInitRequest, options = {}) => {
1010
+ // verify required parameter 'oAuthInitRequest' is not null or undefined
1011
+ assertParamExists('initLinkOAuth', 'oAuthInitRequest', oAuthInitRequest);
1012
+ const localVarPath = `/iam/v1/oauth/init_link`;
1013
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1014
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1015
+ let baseOptions;
1016
+ if (configuration) {
1017
+ baseOptions = configuration.baseOptions;
1018
+ }
1019
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1020
+ const localVarHeaderParameter = {};
1021
+ const localVarQueryParameter = {};
1022
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1023
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1024
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1025
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1026
+ localVarRequestOptions.data = serializeDataIfNeeded(oAuthInitRequest, localVarRequestOptions, configuration);
1027
+ return {
1028
+ url: toPathString(localVarUrlObj),
1029
+ options: localVarRequestOptions,
1030
+ };
1031
+ },
1003
1032
  /**
1004
1033
  *
1005
1034
  * @summary Initialize OAuth.
@@ -1183,6 +1212,40 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1183
1212
  options: localVarRequestOptions,
1184
1213
  };
1185
1214
  },
1215
+ /**
1216
+ *
1217
+ * @summary Initialize OAuth.
1218
+ * @param {string} key
1219
+ * @param {*} [options] Override http request option.
1220
+ * @throws {RequiredError}
1221
+ */
1222
+ poolOAuth: async (key, options = {}) => {
1223
+ // verify required parameter 'key' is not null or undefined
1224
+ assertParamExists('poolOAuth', 'key', key);
1225
+ const localVarPath = `/iam/v1/oauth/pool`;
1226
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1227
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1228
+ let baseOptions;
1229
+ if (configuration) {
1230
+ baseOptions = configuration.baseOptions;
1231
+ }
1232
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1233
+ const localVarHeaderParameter = {};
1234
+ const localVarQueryParameter = {};
1235
+ // authentication pk required
1236
+ // http bearer authentication required
1237
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1238
+ if (key !== undefined) {
1239
+ localVarQueryParameter['key'] = key;
1240
+ }
1241
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1242
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1243
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1244
+ return {
1245
+ url: toPathString(localVarUrlObj),
1246
+ options: localVarRequestOptions,
1247
+ };
1248
+ },
1186
1249
  /**
1187
1250
  * Get or create a new session for the player based on the refresh token.
1188
1251
  * @summary Refresh or create auth session.
@@ -1213,6 +1276,105 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1213
1276
  options: localVarRequestOptions,
1214
1277
  };
1215
1278
  },
1279
+ /**
1280
+ * Start the Email Verification process for a player.
1281
+ * @summary Request an Email Verification.
1282
+ * @param {RequestResetPasswordRequest} requestResetPasswordRequest
1283
+ * @param {*} [options] Override http request option.
1284
+ * @throws {RequiredError}
1285
+ */
1286
+ requestEmailVerification: async (requestResetPasswordRequest, options = {}) => {
1287
+ // verify required parameter 'requestResetPasswordRequest' is not null or undefined
1288
+ assertParamExists('requestEmailVerification', 'requestResetPasswordRequest', requestResetPasswordRequest);
1289
+ const localVarPath = `/iam/v1/password/email/request_verification`;
1290
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1291
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1292
+ let baseOptions;
1293
+ if (configuration) {
1294
+ baseOptions = configuration.baseOptions;
1295
+ }
1296
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1297
+ const localVarHeaderParameter = {};
1298
+ const localVarQueryParameter = {};
1299
+ // authentication pk required
1300
+ // http bearer authentication required
1301
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1302
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1303
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1304
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1305
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1306
+ localVarRequestOptions.data = serializeDataIfNeeded(requestResetPasswordRequest, localVarRequestOptions, configuration);
1307
+ return {
1308
+ url: toPathString(localVarUrlObj),
1309
+ options: localVarRequestOptions,
1310
+ };
1311
+ },
1312
+ /**
1313
+ * Start the Reset process for a player\'s password.
1314
+ * @summary Request a Reset password.
1315
+ * @param {RequestResetPasswordRequest} requestResetPasswordRequest
1316
+ * @param {*} [options] Override http request option.
1317
+ * @throws {RequiredError}
1318
+ */
1319
+ requestResetPassword: async (requestResetPasswordRequest, options = {}) => {
1320
+ // verify required parameter 'requestResetPasswordRequest' is not null or undefined
1321
+ assertParamExists('requestResetPassword', 'requestResetPasswordRequest', requestResetPasswordRequest);
1322
+ const localVarPath = `/iam/v1/password/password/request_reset`;
1323
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1324
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1325
+ let baseOptions;
1326
+ if (configuration) {
1327
+ baseOptions = configuration.baseOptions;
1328
+ }
1329
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1330
+ const localVarHeaderParameter = {};
1331
+ const localVarQueryParameter = {};
1332
+ // authentication pk required
1333
+ // http bearer authentication required
1334
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1335
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1336
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1337
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1338
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1339
+ localVarRequestOptions.data = serializeDataIfNeeded(requestResetPasswordRequest, localVarRequestOptions, configuration);
1340
+ return {
1341
+ url: toPathString(localVarUrlObj),
1342
+ options: localVarRequestOptions,
1343
+ };
1344
+ },
1345
+ /**
1346
+ * Reset a player\'s password.
1347
+ * @summary Reset a password.
1348
+ * @param {ResetPasswordRequest} resetPasswordRequest
1349
+ * @param {*} [options] Override http request option.
1350
+ * @throws {RequiredError}
1351
+ */
1352
+ resetPassword: async (resetPasswordRequest, options = {}) => {
1353
+ // verify required parameter 'resetPasswordRequest' is not null or undefined
1354
+ assertParamExists('resetPassword', 'resetPasswordRequest', resetPasswordRequest);
1355
+ const localVarPath = `/iam/v1/password/password/reset`;
1356
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1357
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1358
+ let baseOptions;
1359
+ if (configuration) {
1360
+ baseOptions = configuration.baseOptions;
1361
+ }
1362
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1363
+ const localVarHeaderParameter = {};
1364
+ const localVarQueryParameter = {};
1365
+ // authentication pk required
1366
+ // http bearer authentication required
1367
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1368
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1369
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1370
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1371
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1372
+ localVarRequestOptions.data = serializeDataIfNeeded(resetPasswordRequest, localVarRequestOptions, configuration);
1373
+ return {
1374
+ url: toPathString(localVarUrlObj),
1375
+ options: localVarRequestOptions,
1376
+ };
1377
+ },
1216
1378
  /**
1217
1379
  * Create and authenticate a player based on email and password.
1218
1380
  * @summary Email and password signup.
@@ -1339,10 +1501,43 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1339
1501
  options: localVarRequestOptions,
1340
1502
  };
1341
1503
  },
1504
+ /**
1505
+ * Verify a player\'s email address.
1506
+ * @summary Verify an email.
1507
+ * @param {ResetPasswordRequest} resetPasswordRequest
1508
+ * @param {*} [options] Override http request option.
1509
+ * @throws {RequiredError}
1510
+ */
1511
+ verifyEmail: async (resetPasswordRequest, options = {}) => {
1512
+ // verify required parameter 'resetPasswordRequest' is not null or undefined
1513
+ assertParamExists('verifyEmail', 'resetPasswordRequest', resetPasswordRequest);
1514
+ const localVarPath = `/iam/v1/password/email/verify`;
1515
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1516
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1517
+ let baseOptions;
1518
+ if (configuration) {
1519
+ baseOptions = configuration.baseOptions;
1520
+ }
1521
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1522
+ const localVarHeaderParameter = {};
1523
+ const localVarQueryParameter = {};
1524
+ // authentication pk required
1525
+ // http bearer authentication required
1526
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1527
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1528
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1529
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1530
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1531
+ localVarRequestOptions.data = serializeDataIfNeeded(resetPasswordRequest, localVarRequestOptions, configuration);
1532
+ return {
1533
+ url: toPathString(localVarUrlObj),
1534
+ options: localVarRequestOptions,
1535
+ };
1536
+ },
1342
1537
  /**
1343
1538
  * The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player. Returns the latest 10 transaction intents for the player.
1344
1539
  * @summary Retrieve player by token.
1345
- * @param {OAuthProvider} provider OAuth provider
1540
+ * @param {AuthProvider} provider OAuth provider
1346
1541
  * @param {OAuthRequest} oAuthRequest
1347
1542
  * @param {*} [options] Override http request option.
1348
1543
  * @deprecated
@@ -1420,7 +1615,7 @@ const AuthenticationApiFp = function (configuration) {
1420
1615
  const localVarAxiosParamCreator = AuthenticationApiAxiosParamCreator(configuration);
1421
1616
  return {
1422
1617
  /**
1423
- *
1618
+ * Deprecated
1424
1619
  * @summary Authenticate player with oauth token.
1425
1620
  * @param {AuthenticateOAuthRequest} authenticateOAuthRequest
1426
1621
  * @param {*} [options] Override http request option.
@@ -1444,7 +1639,7 @@ const AuthenticationApiFp = function (configuration) {
1444
1639
  /**
1445
1640
  * 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.
1446
1641
  * @summary Authorize player with token.
1447
- * @param {OAuthProvider} provider OAuth provider
1642
+ * @param {AuthProvider} provider OAuth provider
1448
1643
  * @param {OAuthRequest} oAuthRequest
1449
1644
  * @param {*} [options] Override http request option.
1450
1645
  * @deprecated
@@ -1465,6 +1660,17 @@ const AuthenticationApiFp = function (configuration) {
1465
1660
  const localVarAxiosArgs = await localVarAxiosParamCreator.getJwks(publishableKey, options);
1466
1661
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1467
1662
  },
1663
+ /**
1664
+ *
1665
+ * @summary Initialize Link OAuth.
1666
+ * @param {OAuthInitRequest} oAuthInitRequest
1667
+ * @param {*} [options] Override http request option.
1668
+ * @throws {RequiredError}
1669
+ */
1670
+ async initLinkOAuth(oAuthInitRequest, options) {
1671
+ const localVarAxiosArgs = await localVarAxiosParamCreator.initLinkOAuth(oAuthInitRequest, options);
1672
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1673
+ },
1468
1674
  /**
1469
1675
  *
1470
1676
  * @summary Initialize OAuth.
@@ -1529,6 +1735,17 @@ const AuthenticationApiFp = function (configuration) {
1529
1735
  const localVarAxiosArgs = await localVarAxiosParamCreator.me(options);
1530
1736
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1531
1737
  },
1738
+ /**
1739
+ *
1740
+ * @summary Initialize OAuth.
1741
+ * @param {string} key
1742
+ * @param {*} [options] Override http request option.
1743
+ * @throws {RequiredError}
1744
+ */
1745
+ async poolOAuth(key, options) {
1746
+ const localVarAxiosArgs = await localVarAxiosParamCreator.poolOAuth(key, options);
1747
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1748
+ },
1532
1749
  /**
1533
1750
  * Get or create a new session for the player based on the refresh token.
1534
1751
  * @summary Refresh or create auth session.
@@ -1540,6 +1757,39 @@ const AuthenticationApiFp = function (configuration) {
1540
1757
  const localVarAxiosArgs = await localVarAxiosParamCreator.refresh(refreshTokenRequest, options);
1541
1758
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1542
1759
  },
1760
+ /**
1761
+ * Start the Email Verification process for a player.
1762
+ * @summary Request an Email Verification.
1763
+ * @param {RequestResetPasswordRequest} requestResetPasswordRequest
1764
+ * @param {*} [options] Override http request option.
1765
+ * @throws {RequiredError}
1766
+ */
1767
+ async requestEmailVerification(requestResetPasswordRequest, options) {
1768
+ const localVarAxiosArgs = await localVarAxiosParamCreator.requestEmailVerification(requestResetPasswordRequest, options);
1769
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1770
+ },
1771
+ /**
1772
+ * Start the Reset process for a player\'s password.
1773
+ * @summary Request a Reset password.
1774
+ * @param {RequestResetPasswordRequest} requestResetPasswordRequest
1775
+ * @param {*} [options] Override http request option.
1776
+ * @throws {RequiredError}
1777
+ */
1778
+ async requestResetPassword(requestResetPasswordRequest, options) {
1779
+ const localVarAxiosArgs = await localVarAxiosParamCreator.requestResetPassword(requestResetPasswordRequest, options);
1780
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1781
+ },
1782
+ /**
1783
+ * Reset a player\'s password.
1784
+ * @summary Reset a password.
1785
+ * @param {ResetPasswordRequest} resetPasswordRequest
1786
+ * @param {*} [options] Override http request option.
1787
+ * @throws {RequiredError}
1788
+ */
1789
+ async resetPassword(resetPasswordRequest, options) {
1790
+ const localVarAxiosArgs = await localVarAxiosParamCreator.resetPassword(resetPasswordRequest, options);
1791
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1792
+ },
1543
1793
  /**
1544
1794
  * Create and authenticate a player based on email and password.
1545
1795
  * @summary Email and password signup.
@@ -1584,10 +1834,21 @@ const AuthenticationApiFp = function (configuration) {
1584
1834
  const localVarAxiosArgs = await localVarAxiosParamCreator.unlinkSIWE(sIWERequest, options);
1585
1835
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1586
1836
  },
1837
+ /**
1838
+ * Verify a player\'s email address.
1839
+ * @summary Verify an email.
1840
+ * @param {ResetPasswordRequest} resetPasswordRequest
1841
+ * @param {*} [options] Override http request option.
1842
+ * @throws {RequiredError}
1843
+ */
1844
+ async verifyEmail(resetPasswordRequest, options) {
1845
+ const localVarAxiosArgs = await localVarAxiosParamCreator.verifyEmail(resetPasswordRequest, options);
1846
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1847
+ },
1587
1848
  /**
1588
1849
  * The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player. Returns the latest 10 transaction intents for the player.
1589
1850
  * @summary Retrieve player by token.
1590
- * @param {OAuthProvider} provider OAuth provider
1851
+ * @param {AuthProvider} provider OAuth provider
1591
1852
  * @param {OAuthRequest} oAuthRequest
1592
1853
  * @param {*} [options] Override http request option.
1593
1854
  * @deprecated
@@ -1618,7 +1879,7 @@ const AuthenticationApiFp = function (configuration) {
1618
1879
  */
1619
1880
  class AuthenticationApi extends BaseAPI {
1620
1881
  /**
1621
- *
1882
+ * Deprecated
1622
1883
  * @summary Authenticate player with oauth token.
1623
1884
  * @param {AuthenticationApiAuthenticateOAuthRequest} requestParameters Request parameters.
1624
1885
  * @param {*} [options] Override http request option.
@@ -1662,6 +1923,17 @@ class AuthenticationApi extends BaseAPI {
1662
1923
  getJwks(requestParameters, options) {
1663
1924
  return AuthenticationApiFp(this.configuration).getJwks(requestParameters.publishableKey, options).then((request) => request(this.axios, this.basePath));
1664
1925
  }
1926
+ /**
1927
+ *
1928
+ * @summary Initialize Link OAuth.
1929
+ * @param {AuthenticationApiInitLinkOAuthRequest} requestParameters Request parameters.
1930
+ * @param {*} [options] Override http request option.
1931
+ * @throws {RequiredError}
1932
+ * @memberof AuthenticationApi
1933
+ */
1934
+ initLinkOAuth(requestParameters, options) {
1935
+ return AuthenticationApiFp(this.configuration).initLinkOAuth(requestParameters.oAuthInitRequest, options).then((request) => request(this.axios, this.basePath));
1936
+ }
1665
1937
  /**
1666
1938
  *
1667
1939
  * @summary Initialize OAuth.
@@ -1726,6 +1998,17 @@ class AuthenticationApi extends BaseAPI {
1726
1998
  me(options) {
1727
1999
  return AuthenticationApiFp(this.configuration).me(options).then((request) => request(this.axios, this.basePath));
1728
2000
  }
2001
+ /**
2002
+ *
2003
+ * @summary Initialize OAuth.
2004
+ * @param {AuthenticationApiPoolOAuthRequest} requestParameters Request parameters.
2005
+ * @param {*} [options] Override http request option.
2006
+ * @throws {RequiredError}
2007
+ * @memberof AuthenticationApi
2008
+ */
2009
+ poolOAuth(requestParameters, options) {
2010
+ return AuthenticationApiFp(this.configuration).poolOAuth(requestParameters.key, options).then((request) => request(this.axios, this.basePath));
2011
+ }
1729
2012
  /**
1730
2013
  * Get or create a new session for the player based on the refresh token.
1731
2014
  * @summary Refresh or create auth session.
@@ -1737,6 +2020,39 @@ class AuthenticationApi extends BaseAPI {
1737
2020
  refresh(requestParameters, options) {
1738
2021
  return AuthenticationApiFp(this.configuration).refresh(requestParameters.refreshTokenRequest, options).then((request) => request(this.axios, this.basePath));
1739
2022
  }
2023
+ /**
2024
+ * Start the Email Verification process for a player.
2025
+ * @summary Request an Email Verification.
2026
+ * @param {AuthenticationApiRequestEmailVerificationRequest} requestParameters Request parameters.
2027
+ * @param {*} [options] Override http request option.
2028
+ * @throws {RequiredError}
2029
+ * @memberof AuthenticationApi
2030
+ */
2031
+ requestEmailVerification(requestParameters, options) {
2032
+ return AuthenticationApiFp(this.configuration).requestEmailVerification(requestParameters.requestResetPasswordRequest, options).then((request) => request(this.axios, this.basePath));
2033
+ }
2034
+ /**
2035
+ * Start the Reset process for a player\'s password.
2036
+ * @summary Request a Reset password.
2037
+ * @param {AuthenticationApiRequestResetPasswordRequest} requestParameters Request parameters.
2038
+ * @param {*} [options] Override http request option.
2039
+ * @throws {RequiredError}
2040
+ * @memberof AuthenticationApi
2041
+ */
2042
+ requestResetPassword(requestParameters, options) {
2043
+ return AuthenticationApiFp(this.configuration).requestResetPassword(requestParameters.requestResetPasswordRequest, options).then((request) => request(this.axios, this.basePath));
2044
+ }
2045
+ /**
2046
+ * Reset a player\'s password.
2047
+ * @summary Reset a password.
2048
+ * @param {AuthenticationApiResetPasswordRequest} requestParameters Request parameters.
2049
+ * @param {*} [options] Override http request option.
2050
+ * @throws {RequiredError}
2051
+ * @memberof AuthenticationApi
2052
+ */
2053
+ resetPassword(requestParameters, options) {
2054
+ return AuthenticationApiFp(this.configuration).resetPassword(requestParameters.resetPasswordRequest, options).then((request) => request(this.axios, this.basePath));
2055
+ }
1740
2056
  /**
1741
2057
  * Create and authenticate a player based on email and password.
1742
2058
  * @summary Email and password signup.
@@ -1781,6 +2097,17 @@ class AuthenticationApi extends BaseAPI {
1781
2097
  unlinkSIWE(requestParameters, options) {
1782
2098
  return AuthenticationApiFp(this.configuration).unlinkSIWE(requestParameters.sIWERequest, options).then((request) => request(this.axios, this.basePath));
1783
2099
  }
2100
+ /**
2101
+ * Verify a player\'s email address.
2102
+ * @summary Verify an email.
2103
+ * @param {AuthenticationApiVerifyEmailRequest} requestParameters Request parameters.
2104
+ * @param {*} [options] Override http request option.
2105
+ * @throws {RequiredError}
2106
+ * @memberof AuthenticationApi
2107
+ */
2108
+ verifyEmail(requestParameters, options) {
2109
+ return AuthenticationApiFp(this.configuration).verifyEmail(requestParameters.resetPasswordRequest, options).then((request) => request(this.axios, this.basePath));
2110
+ }
1784
2111
  /**
1785
2112
  * The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player. Returns the latest 10 transaction intents for the player.
1786
2113
  * @summary Retrieve player by token.
@@ -2737,11 +3064,12 @@ class AuthManager {
2737
3064
  this.config = config;
2738
3065
  this.backendApiClients = backendApiClients;
2739
3066
  }
2740
- async initOAuth(provider, options) {
3067
+ async initOAuth(provider, usePooling, options) {
2741
3068
  const request = {
2742
3069
  oAuthInitRequest: {
2743
3070
  provider,
2744
3071
  options,
3072
+ usePooling: usePooling || false,
2745
3073
  },
2746
3074
  };
2747
3075
  const result = await this.backendApiClients.authenticationApi.initOAuth(request);
@@ -2753,6 +3081,52 @@ class AuthManager {
2753
3081
  key: result.data.key,
2754
3082
  };
2755
3083
  }
3084
+ async initLinkOAuth(provider, playerToken, usePooling, options) {
3085
+ const request = {
3086
+ oAuthInitRequest: {
3087
+ provider,
3088
+ options,
3089
+ usePooling: usePooling || false,
3090
+ },
3091
+ };
3092
+ const result = await this.backendApiClients.authenticationApi.initLinkOAuth(request, {
3093
+ // eslint-disable-next-line @typescript-eslint/naming-convention
3094
+ headers: { 'x-player-token': playerToken },
3095
+ });
3096
+ if (isBrowser() && !options?.skipBrowserRedirect) {
3097
+ window.location.assign(result.data.url);
3098
+ }
3099
+ return {
3100
+ url: result.data.url,
3101
+ key: result.data.key,
3102
+ };
3103
+ }
3104
+ async poolOAuth(key) {
3105
+ const request = {
3106
+ key,
3107
+ };
3108
+ for (let i = 0; i < 600; i++) {
3109
+ try {
3110
+ // eslint-disable-next-line no-await-in-loop
3111
+ const response = await this.backendApiClients.authenticationApi.poolOAuth(request);
3112
+ if (response.status === 200) {
3113
+ return response.data;
3114
+ }
3115
+ }
3116
+ catch (error) {
3117
+ // @ts-ignore
3118
+ if (error.response && error.response.status === 404) {
3119
+ // eslint-disable-next-line no-await-in-loop
3120
+ await new Promise((resolve) => { setTimeout(resolve, 500); });
3121
+ // eslint-disable-next-line no-continue
3122
+ continue;
3123
+ }
3124
+ throw error;
3125
+ }
3126
+ }
3127
+ throw new Error('Failed to pool OAuth, try again later');
3128
+ }
3129
+ // Deprecated
2756
3130
  async authenticateOAuth(provider, token, tokenType) {
2757
3131
  const request = {
2758
3132
  authenticateOAuthRequest: {
@@ -3837,8 +4211,14 @@ class Openfort {
3837
4211
  });
3838
4212
  return result;
3839
4213
  }
3840
- async initOAuth(provider, options) {
3841
- return await this.authManager.initOAuth(provider, options);
4214
+ async initOAuth(provider, usePooling, options) {
4215
+ return await this.authManager.initOAuth(provider, usePooling, options);
4216
+ }
4217
+ async initLinkOAuth(provider, playerToken, usePooling, options) {
4218
+ return await this.authManager.initLinkOAuth(provider, playerToken, usePooling, options);
4219
+ }
4220
+ async poolOAuth(key) {
4221
+ return await this.authManager.poolOAuth(key);
3842
4222
  }
3843
4223
  async authenticateWithOAuth(provider, token, tokenType) {
3844
4224
  this.instanceManager.removeAccessToken();
@@ -4079,5 +4459,6 @@ class Openfort {
4079
4459
  }
4080
4460
 
4081
4461
  exports.OpenfortConfiguration = OpenfortConfiguration;
4462
+ exports.SDKConfiguration = SDKConfiguration;
4082
4463
  exports.ShieldConfiguration = ShieldConfiguration;
4083
4464
  exports.default = Openfort;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { SessionKey, AuthResponse, OAuthProvider as OAuthProvider$1, InitializeOAuthOptions as InitializeOAuthOptions$1, InitAuthResponse, TokenType as TokenType$1, SIWEInitResponse, ThirdPartyOAuthProvider as ThirdPartyOAuthProvider$1, AuthPlayerResponse as AuthPlayerResponse$1, TransactionIntentResponse as TransactionIntentResponse$1, SessionResponse as SessionResponse$1, EmbeddedState as EmbeddedState$1 } from 'types';
2
- import { SDKConfiguration } from 'config';
1
+ import { SessionKey, AuthResponse, OAuthProvider as OAuthProvider$1, InitializeOAuthOptions as InitializeOAuthOptions$1, InitAuthResponse, TokenType as TokenType$1, SIWEInitResponse, ThirdPartyOAuthProvider as ThirdPartyOAuthProvider$1, AuthPlayerResponse as AuthPlayerResponse$1, TransactionIntentResponse as TransactionIntentResponse$1, SessionResponse as SessionResponse$1, EmbeddedState as EmbeddedState$1, SDKOverrides as SDKOverrides$1 } from 'types';
2
+ import { SDKConfiguration as SDKConfiguration$1 } from 'config';
3
3
 
4
4
  declare type Bytes = ArrayLike<number>;
5
5
  declare type BytesLike = Bytes | string;
@@ -73,7 +73,7 @@ declare class Openfort {
73
73
  private readonly instanceManager;
74
74
  private readonly backendApiClients;
75
75
  private readonly iframeManager;
76
- constructor(sdkConfiguration: SDKConfiguration);
76
+ constructor(sdkConfiguration: SDKConfiguration$1);
77
77
  logout(): Promise<void>;
78
78
  private flushSigner;
79
79
  configureSessionKey(): SessionKey;
@@ -81,7 +81,9 @@ declare class Openfort {
81
81
  private newEmbeddedSigner;
82
82
  loginWithEmailPassword(email: string, password: string): Promise<AuthResponse>;
83
83
  signUpWithEmailPassword(email: string, password: string, name?: string): Promise<AuthResponse>;
84
- initOAuth(provider: OAuthProvider$1, options?: InitializeOAuthOptions$1): Promise<InitAuthResponse>;
84
+ initOAuth(provider: OAuthProvider$1, usePooling?: boolean, options?: InitializeOAuthOptions$1): Promise<InitAuthResponse>;
85
+ initLinkOAuth(provider: OAuthProvider$1, playerToken: string, usePooling?: boolean, options?: InitializeOAuthOptions$1): Promise<InitAuthResponse>;
86
+ poolOAuth(key: string): Promise<AuthResponse>;
85
87
  authenticateWithOAuth(provider: OAuthProvider$1, token: string, tokenType: TokenType$1): Promise<AuthResponse>;
86
88
  initSIWE(address: string): Promise<SIWEInitResponse>;
87
89
  authenticateWithThirdPartyProvider(provider: ThirdPartyOAuthProvider$1, token: string, tokenType: TokenType$1): Promise<AuthPlayerResponse$1>;
@@ -152,25 +154,27 @@ declare enum ThirdPartyOAuthProvider {
152
154
  CUSTOM = "custom",
153
155
  OIDC = "oidc"
154
156
  }
157
+ declare enum BasicAuthProvider {
158
+ EMAIL = "email",
159
+ WALLET = "wallet"
160
+ }
155
161
  declare const AUTH_PROVIDER: {
156
- email: 'email';
157
- accelbyte: 'accelbyte';
158
- firebase: 'firebase';
159
- google: 'google';
160
- lootlocker: 'lootlocker';
161
- playfab: 'playfab';
162
- wallet: 'wallet';
162
+ readonly email: "email";
163
+ readonly wallet: "wallet";
164
+ readonly google: "google";
165
+ readonly twitter: "twitter";
166
+ readonly accelbyte: "accelbyte";
167
+ readonly firebase: "firebase";
168
+ readonly lootlocker: "lootlocker";
169
+ readonly playfab: "playfab";
170
+ readonly supabase: "supabase";
171
+ readonly custom: "custom";
172
+ readonly oidc: "oidc";
163
173
  };
164
174
  type AuthProvider = typeof AUTH_PROVIDER[keyof typeof AUTH_PROVIDER];
165
175
  declare enum OAuthProvider {
166
- ACCELBYTE = "accelbyte",
167
- FIREBASE = "firebase",
168
176
  GOOGLE = "google",
169
- LOOTLOCKER = "lootlocker",
170
- PLAYFAB = "playfab",
171
- CUSTOM = "custom",
172
- OIDC = "oidc",
173
- SUPABASE = "supabase"
177
+ TWITTER = "twitter"
174
178
  }
175
179
  interface NextActionPayload {
176
180
  'userOp'?: any;
@@ -358,6 +362,98 @@ interface AuthPlayerResponse {
358
362
  'linkedAccounts': Array<LinkedAccountResponse>;
359
363
  }
360
364
 
365
+ /**
366
+ * Openfort API
367
+ * Complete Openfort API references and guides can be found at: https://openfort.xyz/docs
368
+ *
369
+ * The version of the OpenAPI document: 1.0.0
370
+ * Contact: founders@openfort.xyz
371
+ *
372
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
373
+ * https://openapi-generator.tech
374
+ * Do not edit the class manually.
375
+ */
376
+ interface ConfigurationParameters {
377
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
378
+ username?: string;
379
+ password?: string;
380
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
381
+ basePath?: string;
382
+ baseOptions?: any;
383
+ formDataCtor?: new () => any;
384
+ }
385
+ declare class Configuration {
386
+ /**
387
+ * parameter for apiKey security
388
+ * @param name security name
389
+ * @memberof Configuration
390
+ */
391
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
392
+ /**
393
+ * parameter for basic security
394
+ *
395
+ * @type {string}
396
+ * @memberof Configuration
397
+ */
398
+ username?: string;
399
+ /**
400
+ * parameter for basic security
401
+ *
402
+ * @type {string}
403
+ * @memberof Configuration
404
+ */
405
+ password?: string;
406
+ /**
407
+ * parameter for oauth2 security
408
+ * @param name security name
409
+ * @param scopes oauth2 scope
410
+ * @memberof Configuration
411
+ */
412
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
413
+ /**
414
+ * override base path
415
+ *
416
+ * @type {string}
417
+ * @memberof Configuration
418
+ */
419
+ basePath?: string;
420
+ /**
421
+ * base options for axios calls
422
+ *
423
+ * @type {any}
424
+ * @memberof Configuration
425
+ */
426
+ baseOptions?: any;
427
+ /**
428
+ * The FormData constructor that will be used to create multipart form data
429
+ * requests. You can inject this here so that execution environments that
430
+ * do not support the FormData class can still run the generated client.
431
+ *
432
+ * @type {new () => FormData}
433
+ */
434
+ formDataCtor?: new () => any;
435
+ constructor(param?: ConfigurationParameters);
436
+ /**
437
+ * Check if the given MIME is a JSON MIME.
438
+ * JSON MIME examples:
439
+ * application/json
440
+ * application/json; charset=UTF8
441
+ * APPLICATION/JSON
442
+ * application/vnd.company+json
443
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
444
+ * @return True if the given MIME is JSON, false otherwise.
445
+ */
446
+ isJsonMime(mime: string): boolean;
447
+ }
448
+
449
+ /**
450
+ * Configuration for generated clients
451
+ */
452
+ type BackendAPIConfiguration = Configuration;
453
+ type OpenfortAPIConfiguration = {
454
+ backend: BackendAPIConfiguration;
455
+ };
456
+
361
457
  declare class OpenfortConfiguration {
362
458
  readonly publishableKey: string;
363
459
  constructor(options: {
@@ -374,5 +470,18 @@ declare class ShieldConfiguration {
374
470
  shieldDebug?: boolean;
375
471
  });
376
472
  }
473
+ declare class SDKConfiguration {
474
+ readonly baseConfiguration: OpenfortConfiguration;
475
+ readonly shieldConfiguration?: ShieldConfiguration;
476
+ readonly shieldUrl: string;
477
+ readonly iframeUrl: string;
478
+ readonly backendUrl: string;
479
+ readonly openfortAPIConfig: OpenfortAPIConfiguration;
480
+ constructor({ baseConfiguration, shieldConfiguration, overrides, }: {
481
+ baseConfiguration: OpenfortConfiguration;
482
+ shieldConfiguration?: ShieldConfiguration;
483
+ overrides?: SDKOverrides$1;
484
+ });
485
+ }
377
486
 
378
- export { AuthPlayerResponse, AuthType, EmbeddedState, InitializeOAuthOptions, OAuthProvider, OpenfortConfiguration, SDKOverrides, SessionResponse, ShieldAuthOptions, ShieldAuthentication, ShieldConfiguration, ShieldOptions, ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataDomain, TypedDataField, Openfort as default };
487
+ export { AuthPlayerResponse, AuthType, BasicAuthProvider, EmbeddedState, InitializeOAuthOptions, OAuthProvider, OpenfortConfiguration, SDKConfiguration, SDKOverrides, SessionResponse, ShieldAuthOptions, ShieldAuthentication, ShieldConfiguration, ShieldOptions, ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataDomain, TypedDataField, Openfort as default };
package/dist/index.js CHANGED
@@ -39,16 +39,15 @@ var ThirdPartyOAuthProvider;
39
39
  ThirdPartyOAuthProvider["CUSTOM"] = "custom";
40
40
  ThirdPartyOAuthProvider["OIDC"] = "oidc";
41
41
  })(ThirdPartyOAuthProvider || (ThirdPartyOAuthProvider = {}));
42
+ var BasicAuthProvider;
43
+ (function (BasicAuthProvider) {
44
+ BasicAuthProvider["EMAIL"] = "email";
45
+ BasicAuthProvider["WALLET"] = "wallet";
46
+ })(BasicAuthProvider || (BasicAuthProvider = {}));
42
47
  var OAuthProvider;
43
48
  (function (OAuthProvider) {
44
- OAuthProvider["ACCELBYTE"] = "accelbyte";
45
- OAuthProvider["FIREBASE"] = "firebase";
46
49
  OAuthProvider["GOOGLE"] = "google";
47
- OAuthProvider["LOOTLOCKER"] = "lootlocker";
48
- OAuthProvider["PLAYFAB"] = "playfab";
49
- OAuthProvider["CUSTOM"] = "custom";
50
- OAuthProvider["OIDC"] = "oidc";
51
- OAuthProvider["SUPABASE"] = "supabase";
50
+ OAuthProvider["TWITTER"] = "twitter";
52
51
  })(OAuthProvider || (OAuthProvider = {}));
53
52
 
54
53
  /* tslint:disable */
@@ -861,7 +860,7 @@ class AccountsApi extends BaseAPI {
861
860
  const AuthenticationApiAxiosParamCreator = function (configuration) {
862
861
  return {
863
862
  /**
864
- *
863
+ * Deprecated
865
864
  * @summary Authenticate player with oauth token.
866
865
  * @param {AuthenticateOAuthRequest} authenticateOAuthRequest
867
866
  * @param {*} [options] Override http request option.
@@ -929,7 +928,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
929
928
  /**
930
929
  * 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.
931
930
  * @summary Authorize player with token.
932
- * @param {OAuthProvider} provider OAuth provider
931
+ * @param {AuthProvider} provider OAuth provider
933
932
  * @param {OAuthRequest} oAuthRequest
934
933
  * @param {*} [options] Override http request option.
935
934
  * @deprecated
@@ -996,6 +995,36 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
996
995
  options: localVarRequestOptions,
997
996
  };
998
997
  },
998
+ /**
999
+ *
1000
+ * @summary Initialize Link OAuth.
1001
+ * @param {OAuthInitRequest} oAuthInitRequest
1002
+ * @param {*} [options] Override http request option.
1003
+ * @throws {RequiredError}
1004
+ */
1005
+ initLinkOAuth: async (oAuthInitRequest, options = {}) => {
1006
+ // verify required parameter 'oAuthInitRequest' is not null or undefined
1007
+ assertParamExists('initLinkOAuth', 'oAuthInitRequest', oAuthInitRequest);
1008
+ const localVarPath = `/iam/v1/oauth/init_link`;
1009
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1010
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1011
+ let baseOptions;
1012
+ if (configuration) {
1013
+ baseOptions = configuration.baseOptions;
1014
+ }
1015
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1016
+ const localVarHeaderParameter = {};
1017
+ const localVarQueryParameter = {};
1018
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1019
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1020
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1021
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1022
+ localVarRequestOptions.data = serializeDataIfNeeded(oAuthInitRequest, localVarRequestOptions, configuration);
1023
+ return {
1024
+ url: toPathString(localVarUrlObj),
1025
+ options: localVarRequestOptions,
1026
+ };
1027
+ },
999
1028
  /**
1000
1029
  *
1001
1030
  * @summary Initialize OAuth.
@@ -1179,6 +1208,40 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1179
1208
  options: localVarRequestOptions,
1180
1209
  };
1181
1210
  },
1211
+ /**
1212
+ *
1213
+ * @summary Initialize OAuth.
1214
+ * @param {string} key
1215
+ * @param {*} [options] Override http request option.
1216
+ * @throws {RequiredError}
1217
+ */
1218
+ poolOAuth: async (key, options = {}) => {
1219
+ // verify required parameter 'key' is not null or undefined
1220
+ assertParamExists('poolOAuth', 'key', key);
1221
+ const localVarPath = `/iam/v1/oauth/pool`;
1222
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1223
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1224
+ let baseOptions;
1225
+ if (configuration) {
1226
+ baseOptions = configuration.baseOptions;
1227
+ }
1228
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1229
+ const localVarHeaderParameter = {};
1230
+ const localVarQueryParameter = {};
1231
+ // authentication pk required
1232
+ // http bearer authentication required
1233
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1234
+ if (key !== undefined) {
1235
+ localVarQueryParameter['key'] = key;
1236
+ }
1237
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1238
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1239
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1240
+ return {
1241
+ url: toPathString(localVarUrlObj),
1242
+ options: localVarRequestOptions,
1243
+ };
1244
+ },
1182
1245
  /**
1183
1246
  * Get or create a new session for the player based on the refresh token.
1184
1247
  * @summary Refresh or create auth session.
@@ -1209,6 +1272,105 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1209
1272
  options: localVarRequestOptions,
1210
1273
  };
1211
1274
  },
1275
+ /**
1276
+ * Start the Email Verification process for a player.
1277
+ * @summary Request an Email Verification.
1278
+ * @param {RequestResetPasswordRequest} requestResetPasswordRequest
1279
+ * @param {*} [options] Override http request option.
1280
+ * @throws {RequiredError}
1281
+ */
1282
+ requestEmailVerification: async (requestResetPasswordRequest, options = {}) => {
1283
+ // verify required parameter 'requestResetPasswordRequest' is not null or undefined
1284
+ assertParamExists('requestEmailVerification', 'requestResetPasswordRequest', requestResetPasswordRequest);
1285
+ const localVarPath = `/iam/v1/password/email/request_verification`;
1286
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1287
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1288
+ let baseOptions;
1289
+ if (configuration) {
1290
+ baseOptions = configuration.baseOptions;
1291
+ }
1292
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1293
+ const localVarHeaderParameter = {};
1294
+ const localVarQueryParameter = {};
1295
+ // authentication pk required
1296
+ // http bearer authentication required
1297
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1298
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1299
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1300
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1301
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1302
+ localVarRequestOptions.data = serializeDataIfNeeded(requestResetPasswordRequest, localVarRequestOptions, configuration);
1303
+ return {
1304
+ url: toPathString(localVarUrlObj),
1305
+ options: localVarRequestOptions,
1306
+ };
1307
+ },
1308
+ /**
1309
+ * Start the Reset process for a player\'s password.
1310
+ * @summary Request a Reset password.
1311
+ * @param {RequestResetPasswordRequest} requestResetPasswordRequest
1312
+ * @param {*} [options] Override http request option.
1313
+ * @throws {RequiredError}
1314
+ */
1315
+ requestResetPassword: async (requestResetPasswordRequest, options = {}) => {
1316
+ // verify required parameter 'requestResetPasswordRequest' is not null or undefined
1317
+ assertParamExists('requestResetPassword', 'requestResetPasswordRequest', requestResetPasswordRequest);
1318
+ const localVarPath = `/iam/v1/password/password/request_reset`;
1319
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1320
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1321
+ let baseOptions;
1322
+ if (configuration) {
1323
+ baseOptions = configuration.baseOptions;
1324
+ }
1325
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1326
+ const localVarHeaderParameter = {};
1327
+ const localVarQueryParameter = {};
1328
+ // authentication pk required
1329
+ // http bearer authentication required
1330
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1331
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1332
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1333
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1334
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1335
+ localVarRequestOptions.data = serializeDataIfNeeded(requestResetPasswordRequest, localVarRequestOptions, configuration);
1336
+ return {
1337
+ url: toPathString(localVarUrlObj),
1338
+ options: localVarRequestOptions,
1339
+ };
1340
+ },
1341
+ /**
1342
+ * Reset a player\'s password.
1343
+ * @summary Reset a password.
1344
+ * @param {ResetPasswordRequest} resetPasswordRequest
1345
+ * @param {*} [options] Override http request option.
1346
+ * @throws {RequiredError}
1347
+ */
1348
+ resetPassword: async (resetPasswordRequest, options = {}) => {
1349
+ // verify required parameter 'resetPasswordRequest' is not null or undefined
1350
+ assertParamExists('resetPassword', 'resetPasswordRequest', resetPasswordRequest);
1351
+ const localVarPath = `/iam/v1/password/password/reset`;
1352
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1353
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1354
+ let baseOptions;
1355
+ if (configuration) {
1356
+ baseOptions = configuration.baseOptions;
1357
+ }
1358
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1359
+ const localVarHeaderParameter = {};
1360
+ const localVarQueryParameter = {};
1361
+ // authentication pk required
1362
+ // http bearer authentication required
1363
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1364
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1365
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1366
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1367
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1368
+ localVarRequestOptions.data = serializeDataIfNeeded(resetPasswordRequest, localVarRequestOptions, configuration);
1369
+ return {
1370
+ url: toPathString(localVarUrlObj),
1371
+ options: localVarRequestOptions,
1372
+ };
1373
+ },
1212
1374
  /**
1213
1375
  * Create and authenticate a player based on email and password.
1214
1376
  * @summary Email and password signup.
@@ -1335,10 +1497,43 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1335
1497
  options: localVarRequestOptions,
1336
1498
  };
1337
1499
  },
1500
+ /**
1501
+ * Verify a player\'s email address.
1502
+ * @summary Verify an email.
1503
+ * @param {ResetPasswordRequest} resetPasswordRequest
1504
+ * @param {*} [options] Override http request option.
1505
+ * @throws {RequiredError}
1506
+ */
1507
+ verifyEmail: async (resetPasswordRequest, options = {}) => {
1508
+ // verify required parameter 'resetPasswordRequest' is not null or undefined
1509
+ assertParamExists('verifyEmail', 'resetPasswordRequest', resetPasswordRequest);
1510
+ const localVarPath = `/iam/v1/password/email/verify`;
1511
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1512
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1513
+ let baseOptions;
1514
+ if (configuration) {
1515
+ baseOptions = configuration.baseOptions;
1516
+ }
1517
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1518
+ const localVarHeaderParameter = {};
1519
+ const localVarQueryParameter = {};
1520
+ // authentication pk required
1521
+ // http bearer authentication required
1522
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1523
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1524
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1525
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1526
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1527
+ localVarRequestOptions.data = serializeDataIfNeeded(resetPasswordRequest, localVarRequestOptions, configuration);
1528
+ return {
1529
+ url: toPathString(localVarUrlObj),
1530
+ options: localVarRequestOptions,
1531
+ };
1532
+ },
1338
1533
  /**
1339
1534
  * The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player. Returns the latest 10 transaction intents for the player.
1340
1535
  * @summary Retrieve player by token.
1341
- * @param {OAuthProvider} provider OAuth provider
1536
+ * @param {AuthProvider} provider OAuth provider
1342
1537
  * @param {OAuthRequest} oAuthRequest
1343
1538
  * @param {*} [options] Override http request option.
1344
1539
  * @deprecated
@@ -1416,7 +1611,7 @@ const AuthenticationApiFp = function (configuration) {
1416
1611
  const localVarAxiosParamCreator = AuthenticationApiAxiosParamCreator(configuration);
1417
1612
  return {
1418
1613
  /**
1419
- *
1614
+ * Deprecated
1420
1615
  * @summary Authenticate player with oauth token.
1421
1616
  * @param {AuthenticateOAuthRequest} authenticateOAuthRequest
1422
1617
  * @param {*} [options] Override http request option.
@@ -1440,7 +1635,7 @@ const AuthenticationApiFp = function (configuration) {
1440
1635
  /**
1441
1636
  * 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.
1442
1637
  * @summary Authorize player with token.
1443
- * @param {OAuthProvider} provider OAuth provider
1638
+ * @param {AuthProvider} provider OAuth provider
1444
1639
  * @param {OAuthRequest} oAuthRequest
1445
1640
  * @param {*} [options] Override http request option.
1446
1641
  * @deprecated
@@ -1461,6 +1656,17 @@ const AuthenticationApiFp = function (configuration) {
1461
1656
  const localVarAxiosArgs = await localVarAxiosParamCreator.getJwks(publishableKey, options);
1462
1657
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1463
1658
  },
1659
+ /**
1660
+ *
1661
+ * @summary Initialize Link OAuth.
1662
+ * @param {OAuthInitRequest} oAuthInitRequest
1663
+ * @param {*} [options] Override http request option.
1664
+ * @throws {RequiredError}
1665
+ */
1666
+ async initLinkOAuth(oAuthInitRequest, options) {
1667
+ const localVarAxiosArgs = await localVarAxiosParamCreator.initLinkOAuth(oAuthInitRequest, options);
1668
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1669
+ },
1464
1670
  /**
1465
1671
  *
1466
1672
  * @summary Initialize OAuth.
@@ -1525,6 +1731,17 @@ const AuthenticationApiFp = function (configuration) {
1525
1731
  const localVarAxiosArgs = await localVarAxiosParamCreator.me(options);
1526
1732
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1527
1733
  },
1734
+ /**
1735
+ *
1736
+ * @summary Initialize OAuth.
1737
+ * @param {string} key
1738
+ * @param {*} [options] Override http request option.
1739
+ * @throws {RequiredError}
1740
+ */
1741
+ async poolOAuth(key, options) {
1742
+ const localVarAxiosArgs = await localVarAxiosParamCreator.poolOAuth(key, options);
1743
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1744
+ },
1528
1745
  /**
1529
1746
  * Get or create a new session for the player based on the refresh token.
1530
1747
  * @summary Refresh or create auth session.
@@ -1536,6 +1753,39 @@ const AuthenticationApiFp = function (configuration) {
1536
1753
  const localVarAxiosArgs = await localVarAxiosParamCreator.refresh(refreshTokenRequest, options);
1537
1754
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1538
1755
  },
1756
+ /**
1757
+ * Start the Email Verification process for a player.
1758
+ * @summary Request an Email Verification.
1759
+ * @param {RequestResetPasswordRequest} requestResetPasswordRequest
1760
+ * @param {*} [options] Override http request option.
1761
+ * @throws {RequiredError}
1762
+ */
1763
+ async requestEmailVerification(requestResetPasswordRequest, options) {
1764
+ const localVarAxiosArgs = await localVarAxiosParamCreator.requestEmailVerification(requestResetPasswordRequest, options);
1765
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1766
+ },
1767
+ /**
1768
+ * Start the Reset process for a player\'s password.
1769
+ * @summary Request a Reset password.
1770
+ * @param {RequestResetPasswordRequest} requestResetPasswordRequest
1771
+ * @param {*} [options] Override http request option.
1772
+ * @throws {RequiredError}
1773
+ */
1774
+ async requestResetPassword(requestResetPasswordRequest, options) {
1775
+ const localVarAxiosArgs = await localVarAxiosParamCreator.requestResetPassword(requestResetPasswordRequest, options);
1776
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1777
+ },
1778
+ /**
1779
+ * Reset a player\'s password.
1780
+ * @summary Reset a password.
1781
+ * @param {ResetPasswordRequest} resetPasswordRequest
1782
+ * @param {*} [options] Override http request option.
1783
+ * @throws {RequiredError}
1784
+ */
1785
+ async resetPassword(resetPasswordRequest, options) {
1786
+ const localVarAxiosArgs = await localVarAxiosParamCreator.resetPassword(resetPasswordRequest, options);
1787
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1788
+ },
1539
1789
  /**
1540
1790
  * Create and authenticate a player based on email and password.
1541
1791
  * @summary Email and password signup.
@@ -1580,10 +1830,21 @@ const AuthenticationApiFp = function (configuration) {
1580
1830
  const localVarAxiosArgs = await localVarAxiosParamCreator.unlinkSIWE(sIWERequest, options);
1581
1831
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1582
1832
  },
1833
+ /**
1834
+ * Verify a player\'s email address.
1835
+ * @summary Verify an email.
1836
+ * @param {ResetPasswordRequest} resetPasswordRequest
1837
+ * @param {*} [options] Override http request option.
1838
+ * @throws {RequiredError}
1839
+ */
1840
+ async verifyEmail(resetPasswordRequest, options) {
1841
+ const localVarAxiosArgs = await localVarAxiosParamCreator.verifyEmail(resetPasswordRequest, options);
1842
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1843
+ },
1583
1844
  /**
1584
1845
  * The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player. Returns the latest 10 transaction intents for the player.
1585
1846
  * @summary Retrieve player by token.
1586
- * @param {OAuthProvider} provider OAuth provider
1847
+ * @param {AuthProvider} provider OAuth provider
1587
1848
  * @param {OAuthRequest} oAuthRequest
1588
1849
  * @param {*} [options] Override http request option.
1589
1850
  * @deprecated
@@ -1614,7 +1875,7 @@ const AuthenticationApiFp = function (configuration) {
1614
1875
  */
1615
1876
  class AuthenticationApi extends BaseAPI {
1616
1877
  /**
1617
- *
1878
+ * Deprecated
1618
1879
  * @summary Authenticate player with oauth token.
1619
1880
  * @param {AuthenticationApiAuthenticateOAuthRequest} requestParameters Request parameters.
1620
1881
  * @param {*} [options] Override http request option.
@@ -1658,6 +1919,17 @@ class AuthenticationApi extends BaseAPI {
1658
1919
  getJwks(requestParameters, options) {
1659
1920
  return AuthenticationApiFp(this.configuration).getJwks(requestParameters.publishableKey, options).then((request) => request(this.axios, this.basePath));
1660
1921
  }
1922
+ /**
1923
+ *
1924
+ * @summary Initialize Link OAuth.
1925
+ * @param {AuthenticationApiInitLinkOAuthRequest} requestParameters Request parameters.
1926
+ * @param {*} [options] Override http request option.
1927
+ * @throws {RequiredError}
1928
+ * @memberof AuthenticationApi
1929
+ */
1930
+ initLinkOAuth(requestParameters, options) {
1931
+ return AuthenticationApiFp(this.configuration).initLinkOAuth(requestParameters.oAuthInitRequest, options).then((request) => request(this.axios, this.basePath));
1932
+ }
1661
1933
  /**
1662
1934
  *
1663
1935
  * @summary Initialize OAuth.
@@ -1722,6 +1994,17 @@ class AuthenticationApi extends BaseAPI {
1722
1994
  me(options) {
1723
1995
  return AuthenticationApiFp(this.configuration).me(options).then((request) => request(this.axios, this.basePath));
1724
1996
  }
1997
+ /**
1998
+ *
1999
+ * @summary Initialize OAuth.
2000
+ * @param {AuthenticationApiPoolOAuthRequest} requestParameters Request parameters.
2001
+ * @param {*} [options] Override http request option.
2002
+ * @throws {RequiredError}
2003
+ * @memberof AuthenticationApi
2004
+ */
2005
+ poolOAuth(requestParameters, options) {
2006
+ return AuthenticationApiFp(this.configuration).poolOAuth(requestParameters.key, options).then((request) => request(this.axios, this.basePath));
2007
+ }
1725
2008
  /**
1726
2009
  * Get or create a new session for the player based on the refresh token.
1727
2010
  * @summary Refresh or create auth session.
@@ -1733,6 +2016,39 @@ class AuthenticationApi extends BaseAPI {
1733
2016
  refresh(requestParameters, options) {
1734
2017
  return AuthenticationApiFp(this.configuration).refresh(requestParameters.refreshTokenRequest, options).then((request) => request(this.axios, this.basePath));
1735
2018
  }
2019
+ /**
2020
+ * Start the Email Verification process for a player.
2021
+ * @summary Request an Email Verification.
2022
+ * @param {AuthenticationApiRequestEmailVerificationRequest} requestParameters Request parameters.
2023
+ * @param {*} [options] Override http request option.
2024
+ * @throws {RequiredError}
2025
+ * @memberof AuthenticationApi
2026
+ */
2027
+ requestEmailVerification(requestParameters, options) {
2028
+ return AuthenticationApiFp(this.configuration).requestEmailVerification(requestParameters.requestResetPasswordRequest, options).then((request) => request(this.axios, this.basePath));
2029
+ }
2030
+ /**
2031
+ * Start the Reset process for a player\'s password.
2032
+ * @summary Request a Reset password.
2033
+ * @param {AuthenticationApiRequestResetPasswordRequest} requestParameters Request parameters.
2034
+ * @param {*} [options] Override http request option.
2035
+ * @throws {RequiredError}
2036
+ * @memberof AuthenticationApi
2037
+ */
2038
+ requestResetPassword(requestParameters, options) {
2039
+ return AuthenticationApiFp(this.configuration).requestResetPassword(requestParameters.requestResetPasswordRequest, options).then((request) => request(this.axios, this.basePath));
2040
+ }
2041
+ /**
2042
+ * Reset a player\'s password.
2043
+ * @summary Reset a password.
2044
+ * @param {AuthenticationApiResetPasswordRequest} requestParameters Request parameters.
2045
+ * @param {*} [options] Override http request option.
2046
+ * @throws {RequiredError}
2047
+ * @memberof AuthenticationApi
2048
+ */
2049
+ resetPassword(requestParameters, options) {
2050
+ return AuthenticationApiFp(this.configuration).resetPassword(requestParameters.resetPasswordRequest, options).then((request) => request(this.axios, this.basePath));
2051
+ }
1736
2052
  /**
1737
2053
  * Create and authenticate a player based on email and password.
1738
2054
  * @summary Email and password signup.
@@ -1777,6 +2093,17 @@ class AuthenticationApi extends BaseAPI {
1777
2093
  unlinkSIWE(requestParameters, options) {
1778
2094
  return AuthenticationApiFp(this.configuration).unlinkSIWE(requestParameters.sIWERequest, options).then((request) => request(this.axios, this.basePath));
1779
2095
  }
2096
+ /**
2097
+ * Verify a player\'s email address.
2098
+ * @summary Verify an email.
2099
+ * @param {AuthenticationApiVerifyEmailRequest} requestParameters Request parameters.
2100
+ * @param {*} [options] Override http request option.
2101
+ * @throws {RequiredError}
2102
+ * @memberof AuthenticationApi
2103
+ */
2104
+ verifyEmail(requestParameters, options) {
2105
+ return AuthenticationApiFp(this.configuration).verifyEmail(requestParameters.resetPasswordRequest, options).then((request) => request(this.axios, this.basePath));
2106
+ }
1780
2107
  /**
1781
2108
  * The endpoint verifies the token generated by OAuth provider and retrieves a corresponding player. Returns the latest 10 transaction intents for the player.
1782
2109
  * @summary Retrieve player by token.
@@ -2733,11 +3060,12 @@ class AuthManager {
2733
3060
  this.config = config;
2734
3061
  this.backendApiClients = backendApiClients;
2735
3062
  }
2736
- async initOAuth(provider, options) {
3063
+ async initOAuth(provider, usePooling, options) {
2737
3064
  const request = {
2738
3065
  oAuthInitRequest: {
2739
3066
  provider,
2740
3067
  options,
3068
+ usePooling: usePooling || false,
2741
3069
  },
2742
3070
  };
2743
3071
  const result = await this.backendApiClients.authenticationApi.initOAuth(request);
@@ -2749,6 +3077,52 @@ class AuthManager {
2749
3077
  key: result.data.key,
2750
3078
  };
2751
3079
  }
3080
+ async initLinkOAuth(provider, playerToken, usePooling, options) {
3081
+ const request = {
3082
+ oAuthInitRequest: {
3083
+ provider,
3084
+ options,
3085
+ usePooling: usePooling || false,
3086
+ },
3087
+ };
3088
+ const result = await this.backendApiClients.authenticationApi.initLinkOAuth(request, {
3089
+ // eslint-disable-next-line @typescript-eslint/naming-convention
3090
+ headers: { 'x-player-token': playerToken },
3091
+ });
3092
+ if (isBrowser() && !options?.skipBrowserRedirect) {
3093
+ window.location.assign(result.data.url);
3094
+ }
3095
+ return {
3096
+ url: result.data.url,
3097
+ key: result.data.key,
3098
+ };
3099
+ }
3100
+ async poolOAuth(key) {
3101
+ const request = {
3102
+ key,
3103
+ };
3104
+ for (let i = 0; i < 600; i++) {
3105
+ try {
3106
+ // eslint-disable-next-line no-await-in-loop
3107
+ const response = await this.backendApiClients.authenticationApi.poolOAuth(request);
3108
+ if (response.status === 200) {
3109
+ return response.data;
3110
+ }
3111
+ }
3112
+ catch (error) {
3113
+ // @ts-ignore
3114
+ if (error.response && error.response.status === 404) {
3115
+ // eslint-disable-next-line no-await-in-loop
3116
+ await new Promise((resolve) => { setTimeout(resolve, 500); });
3117
+ // eslint-disable-next-line no-continue
3118
+ continue;
3119
+ }
3120
+ throw error;
3121
+ }
3122
+ }
3123
+ throw new Error('Failed to pool OAuth, try again later');
3124
+ }
3125
+ // Deprecated
2752
3126
  async authenticateOAuth(provider, token, tokenType) {
2753
3127
  const request = {
2754
3128
  authenticateOAuthRequest: {
@@ -3833,8 +4207,14 @@ class Openfort {
3833
4207
  });
3834
4208
  return result;
3835
4209
  }
3836
- async initOAuth(provider, options) {
3837
- return await this.authManager.initOAuth(provider, options);
4210
+ async initOAuth(provider, usePooling, options) {
4211
+ return await this.authManager.initOAuth(provider, usePooling, options);
4212
+ }
4213
+ async initLinkOAuth(provider, playerToken, usePooling, options) {
4214
+ return await this.authManager.initLinkOAuth(provider, playerToken, usePooling, options);
4215
+ }
4216
+ async poolOAuth(key) {
4217
+ return await this.authManager.poolOAuth(key);
3838
4218
  }
3839
4219
  async authenticateWithOAuth(provider, token, tokenType) {
3840
4220
  this.instanceManager.removeAccessToken();
@@ -4074,4 +4454,4 @@ class Openfort {
4074
4454
  }
4075
4455
  }
4076
4456
 
4077
- export { AuthType, EmbeddedState, OAuthProvider, OpenfortConfiguration, ShieldConfiguration, ThirdPartyOAuthProvider, TokenType, Openfort as default };
4457
+ export { AuthType, BasicAuthProvider, EmbeddedState, OAuthProvider, OpenfortConfiguration, SDKConfiguration, ShieldConfiguration, ThirdPartyOAuthProvider, TokenType, Openfort as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfort/openfort-js",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
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",