@openfort/openfort-js 0.7.6 → 0.7.7

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { _TypedDataEncoder, hashMessage } from '@ethersproject/hash';
2
- import globalAxios from 'axios';
2
+ import globalAxios, { isAxiosError } from 'axios';
3
3
  import { StaticJsonRpcProvider } from '@ethersproject/providers';
4
4
  import { hexlify, joinSignature, arrayify } from '@ethersproject/bytes';
5
5
  import { EventEmitter } from 'events';
@@ -1011,15 +1011,15 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1011
1011
  },
1012
1012
  /**
1013
1013
  *
1014
- * @summary Initialize Link OAuth.
1014
+ * @summary Initialize OAuth.
1015
1015
  * @param {OAuthInitRequest} oAuthInitRequest
1016
1016
  * @param {*} [options] Override http request option.
1017
1017
  * @throws {RequiredError}
1018
1018
  */
1019
- initLinkOAuth: async (oAuthInitRequest, options = {}) => {
1019
+ initOAuth: async (oAuthInitRequest, options = {}) => {
1020
1020
  // verify required parameter 'oAuthInitRequest' is not null or undefined
1021
- assertParamExists('initLinkOAuth', 'oAuthInitRequest', oAuthInitRequest);
1022
- const localVarPath = `/iam/v1/oauth/init_link`;
1021
+ assertParamExists('initOAuth', 'oAuthInitRequest', oAuthInitRequest);
1022
+ const localVarPath = `/iam/v1/oauth/init`;
1023
1023
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1024
1024
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1025
1025
  let baseOptions;
@@ -1029,6 +1029,9 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1029
1029
  const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1030
1030
  const localVarHeaderParameter = {};
1031
1031
  const localVarQueryParameter = {};
1032
+ // authentication pk required
1033
+ // http bearer authentication required
1034
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1032
1035
  localVarHeaderParameter['Content-Type'] = 'application/json';
1033
1036
  setSearchParams(localVarUrlObj, localVarQueryParameter);
1034
1037
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
@@ -1040,16 +1043,16 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1040
1043
  };
1041
1044
  },
1042
1045
  /**
1043
- *
1044
- * @summary Initialize OAuth.
1045
- * @param {OAuthInitRequest} oAuthInitRequest
1046
+ * Create a challenge to link external wallet to the player.
1047
+ * @summary Initialize SIWE.
1048
+ * @param {SIWERequest} sIWERequest
1046
1049
  * @param {*} [options] Override http request option.
1047
1050
  * @throws {RequiredError}
1048
1051
  */
1049
- initOAuth: async (oAuthInitRequest, options = {}) => {
1050
- // verify required parameter 'oAuthInitRequest' is not null or undefined
1051
- assertParamExists('initOAuth', 'oAuthInitRequest', oAuthInitRequest);
1052
- const localVarPath = `/iam/v1/oauth/init`;
1052
+ initSIWE: async (sIWERequest, options = {}) => {
1053
+ // verify required parameter 'sIWERequest' is not null or undefined
1054
+ assertParamExists('initSIWE', 'sIWERequest', sIWERequest);
1055
+ const localVarPath = `/iam/v1/siwe/init`;
1053
1056
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1054
1057
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1055
1058
  let baseOptions;
@@ -1066,23 +1069,22 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1066
1069
  setSearchParams(localVarUrlObj, localVarQueryParameter);
1067
1070
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1068
1071
  localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1069
- localVarRequestOptions.data = serializeDataIfNeeded(oAuthInitRequest, localVarRequestOptions, configuration);
1072
+ localVarRequestOptions.data = serializeDataIfNeeded(sIWERequest, localVarRequestOptions, configuration);
1070
1073
  return {
1071
1074
  url: toPathString(localVarUrlObj),
1072
1075
  options: localVarRequestOptions,
1073
1076
  };
1074
1077
  },
1075
1078
  /**
1076
- * Create a challenge to link external wallet to the player.
1077
- * @summary Initialize SIWE.
1078
- * @param {SIWERequest} sIWERequest
1079
+ *
1080
+ * @param {LoginRequest} loginRequest
1079
1081
  * @param {*} [options] Override http request option.
1080
1082
  * @throws {RequiredError}
1081
1083
  */
1082
- initSIWE: async (sIWERequest, options = {}) => {
1083
- // verify required parameter 'sIWERequest' is not null or undefined
1084
- assertParamExists('initSIWE', 'sIWERequest', sIWERequest);
1085
- const localVarPath = `/iam/v1/siwe/init`;
1084
+ linkEmail: async (loginRequest, options = {}) => {
1085
+ // verify required parameter 'loginRequest' is not null or undefined
1086
+ assertParamExists('linkEmail', 'loginRequest', loginRequest);
1087
+ const localVarPath = `/iam/v1/password/link`;
1086
1088
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1087
1089
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1088
1090
  let baseOptions;
@@ -1092,14 +1094,41 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1092
1094
  const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1093
1095
  const localVarHeaderParameter = {};
1094
1096
  const localVarQueryParameter = {};
1095
- // authentication pk required
1096
- // http bearer authentication required
1097
- await setBearerAuthToObject(localVarHeaderParameter, configuration);
1098
1097
  localVarHeaderParameter['Content-Type'] = 'application/json';
1099
1098
  setSearchParams(localVarUrlObj, localVarQueryParameter);
1100
1099
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1101
1100
  localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1102
- localVarRequestOptions.data = serializeDataIfNeeded(sIWERequest, localVarRequestOptions, configuration);
1101
+ localVarRequestOptions.data = serializeDataIfNeeded(loginRequest, localVarRequestOptions, configuration);
1102
+ return {
1103
+ url: toPathString(localVarUrlObj),
1104
+ options: localVarRequestOptions,
1105
+ };
1106
+ },
1107
+ /**
1108
+ *
1109
+ * @summary Initialize Link OAuth.
1110
+ * @param {OAuthInitRequest} oAuthInitRequest
1111
+ * @param {*} [options] Override http request option.
1112
+ * @throws {RequiredError}
1113
+ */
1114
+ linkOAuth: async (oAuthInitRequest, options = {}) => {
1115
+ // verify required parameter 'oAuthInitRequest' is not null or undefined
1116
+ assertParamExists('linkOAuth', 'oAuthInitRequest', oAuthInitRequest);
1117
+ const localVarPath = `/iam/v1/oauth/init_link`;
1118
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1119
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1120
+ let baseOptions;
1121
+ if (configuration) {
1122
+ baseOptions = configuration.baseOptions;
1123
+ }
1124
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1125
+ const localVarHeaderParameter = {};
1126
+ const localVarQueryParameter = {};
1127
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1128
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1129
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1130
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1131
+ localVarRequestOptions.data = serializeDataIfNeeded(oAuthInitRequest, localVarRequestOptions, configuration);
1103
1132
  return {
1104
1133
  url: toPathString(localVarUrlObj),
1105
1134
  options: localVarRequestOptions,
@@ -1296,7 +1325,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1296
1325
  requestEmailVerification: async (requestVerifyEmailRequest, options = {}) => {
1297
1326
  // verify required parameter 'requestVerifyEmailRequest' is not null or undefined
1298
1327
  assertParamExists('requestEmailVerification', 'requestVerifyEmailRequest', requestVerifyEmailRequest);
1299
- const localVarPath = `/iam/v1/password/email/request_verification`;
1328
+ const localVarPath = `/iam/v1/password/request_email_verification`;
1300
1329
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1301
1330
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1302
1331
  let baseOptions;
@@ -1329,7 +1358,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1329
1358
  requestResetPassword: async (requestResetPasswordRequest, options = {}) => {
1330
1359
  // verify required parameter 'requestResetPasswordRequest' is not null or undefined
1331
1360
  assertParamExists('requestResetPassword', 'requestResetPasswordRequest', requestResetPasswordRequest);
1332
- const localVarPath = `/iam/v1/password/password/request_reset`;
1361
+ const localVarPath = `/iam/v1/password/request_reset`;
1333
1362
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1334
1363
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1335
1364
  let baseOptions;
@@ -1362,7 +1391,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1362
1391
  resetPassword: async (resetPasswordRequest, options = {}) => {
1363
1392
  // verify required parameter 'resetPasswordRequest' is not null or undefined
1364
1393
  assertParamExists('resetPassword', 'resetPasswordRequest', resetPasswordRequest);
1365
- const localVarPath = `/iam/v1/password/password/reset`;
1394
+ const localVarPath = `/iam/v1/password/reset`;
1366
1395
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1367
1396
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1368
1397
  let baseOptions;
@@ -1451,16 +1480,45 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1451
1480
  options: localVarRequestOptions,
1452
1481
  };
1453
1482
  },
1483
+ /**
1484
+ *
1485
+ * @param {UnlinkEmailRequest} unlinkEmailRequest
1486
+ * @param {*} [options] Override http request option.
1487
+ * @throws {RequiredError}
1488
+ */
1489
+ unlinkEmail: async (unlinkEmailRequest, options = {}) => {
1490
+ // verify required parameter 'unlinkEmailRequest' is not null or undefined
1491
+ assertParamExists('unlinkEmail', 'unlinkEmailRequest', unlinkEmailRequest);
1492
+ const localVarPath = `/iam/v1/password/unlink`;
1493
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1494
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1495
+ let baseOptions;
1496
+ if (configuration) {
1497
+ baseOptions = configuration.baseOptions;
1498
+ }
1499
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1500
+ const localVarHeaderParameter = {};
1501
+ const localVarQueryParameter = {};
1502
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1503
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1504
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1505
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1506
+ localVarRequestOptions.data = serializeDataIfNeeded(unlinkEmailRequest, localVarRequestOptions, configuration);
1507
+ return {
1508
+ url: toPathString(localVarUrlObj),
1509
+ options: localVarRequestOptions,
1510
+ };
1511
+ },
1454
1512
  /**
1455
1513
  *
1456
1514
  * @summary Unlink OAuth account
1457
- * @param {UnlinkRequest} unlinkRequest
1515
+ * @param {UnlinkOAuthRequest} unlinkOAuthRequest
1458
1516
  * @param {*} [options] Override http request option.
1459
1517
  * @throws {RequiredError}
1460
1518
  */
1461
- unlinkOAuth: async (unlinkRequest, options = {}) => {
1462
- // verify required parameter 'unlinkRequest' is not null or undefined
1463
- assertParamExists('unlinkOAuth', 'unlinkRequest', unlinkRequest);
1519
+ unlinkOAuth: async (unlinkOAuthRequest, options = {}) => {
1520
+ // verify required parameter 'unlinkOAuthRequest' is not null or undefined
1521
+ assertParamExists('unlinkOAuth', 'unlinkOAuthRequest', unlinkOAuthRequest);
1464
1522
  const localVarPath = `/iam/v1/oauth/unlink`;
1465
1523
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1466
1524
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
@@ -1475,7 +1533,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1475
1533
  setSearchParams(localVarUrlObj, localVarQueryParameter);
1476
1534
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1477
1535
  localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1478
- localVarRequestOptions.data = serializeDataIfNeeded(unlinkRequest, localVarRequestOptions, configuration);
1536
+ localVarRequestOptions.data = serializeDataIfNeeded(unlinkOAuthRequest, localVarRequestOptions, configuration);
1479
1537
  return {
1480
1538
  url: toPathString(localVarUrlObj),
1481
1539
  options: localVarRequestOptions,
@@ -1521,7 +1579,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1521
1579
  verifyEmail: async (verifyEmailRequest, options = {}) => {
1522
1580
  // verify required parameter 'verifyEmailRequest' is not null or undefined
1523
1581
  assertParamExists('verifyEmail', 'verifyEmailRequest', verifyEmailRequest);
1524
- const localVarPath = `/iam/v1/password/email/verify`;
1582
+ const localVarPath = `/iam/v1/password/verify_email`;
1525
1583
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1526
1584
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1527
1585
  let baseOptions;
@@ -1670,17 +1728,6 @@ const AuthenticationApiFp = function (configuration) {
1670
1728
  const localVarAxiosArgs = await localVarAxiosParamCreator.getJwks(publishableKey, options);
1671
1729
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1672
1730
  },
1673
- /**
1674
- *
1675
- * @summary Initialize Link OAuth.
1676
- * @param {OAuthInitRequest} oAuthInitRequest
1677
- * @param {*} [options] Override http request option.
1678
- * @throws {RequiredError}
1679
- */
1680
- async initLinkOAuth(oAuthInitRequest, options) {
1681
- const localVarAxiosArgs = await localVarAxiosParamCreator.initLinkOAuth(oAuthInitRequest, options);
1682
- return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1683
- },
1684
1731
  /**
1685
1732
  *
1686
1733
  * @summary Initialize OAuth.
@@ -1703,6 +1750,27 @@ const AuthenticationApiFp = function (configuration) {
1703
1750
  const localVarAxiosArgs = await localVarAxiosParamCreator.initSIWE(sIWERequest, options);
1704
1751
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1705
1752
  },
1753
+ /**
1754
+ *
1755
+ * @param {LoginRequest} loginRequest
1756
+ * @param {*} [options] Override http request option.
1757
+ * @throws {RequiredError}
1758
+ */
1759
+ async linkEmail(loginRequest, options) {
1760
+ const localVarAxiosArgs = await localVarAxiosParamCreator.linkEmail(loginRequest, options);
1761
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1762
+ },
1763
+ /**
1764
+ *
1765
+ * @summary Initialize Link OAuth.
1766
+ * @param {OAuthInitRequest} oAuthInitRequest
1767
+ * @param {*} [options] Override http request option.
1768
+ * @throws {RequiredError}
1769
+ */
1770
+ async linkOAuth(oAuthInitRequest, options) {
1771
+ const localVarAxiosArgs = await localVarAxiosParamCreator.linkOAuth(oAuthInitRequest, options);
1772
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1773
+ },
1706
1774
  /**
1707
1775
  *
1708
1776
  * @summary Link external wallet.
@@ -1822,15 +1890,25 @@ const AuthenticationApiFp = function (configuration) {
1822
1890
  const localVarAxiosArgs = await localVarAxiosParamCreator.thirdParty(thirdPartyOAuthRequest, options);
1823
1891
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1824
1892
  },
1893
+ /**
1894
+ *
1895
+ * @param {UnlinkEmailRequest} unlinkEmailRequest
1896
+ * @param {*} [options] Override http request option.
1897
+ * @throws {RequiredError}
1898
+ */
1899
+ async unlinkEmail(unlinkEmailRequest, options) {
1900
+ const localVarAxiosArgs = await localVarAxiosParamCreator.unlinkEmail(unlinkEmailRequest, options);
1901
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1902
+ },
1825
1903
  /**
1826
1904
  *
1827
1905
  * @summary Unlink OAuth account
1828
- * @param {UnlinkRequest} unlinkRequest
1906
+ * @param {UnlinkOAuthRequest} unlinkOAuthRequest
1829
1907
  * @param {*} [options] Override http request option.
1830
1908
  * @throws {RequiredError}
1831
1909
  */
1832
- async unlinkOAuth(unlinkRequest, options) {
1833
- const localVarAxiosArgs = await localVarAxiosParamCreator.unlinkOAuth(unlinkRequest, options);
1910
+ async unlinkOAuth(unlinkOAuthRequest, options) {
1911
+ const localVarAxiosArgs = await localVarAxiosParamCreator.unlinkOAuth(unlinkOAuthRequest, options);
1834
1912
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1835
1913
  },
1836
1914
  /**
@@ -1933,17 +2011,6 @@ class AuthenticationApi extends BaseAPI {
1933
2011
  getJwks(requestParameters, options) {
1934
2012
  return AuthenticationApiFp(this.configuration).getJwks(requestParameters.publishableKey, options).then((request) => request(this.axios, this.basePath));
1935
2013
  }
1936
- /**
1937
- *
1938
- * @summary Initialize Link OAuth.
1939
- * @param {AuthenticationApiInitLinkOAuthRequest} requestParameters Request parameters.
1940
- * @param {*} [options] Override http request option.
1941
- * @throws {RequiredError}
1942
- * @memberof AuthenticationApi
1943
- */
1944
- initLinkOAuth(requestParameters, options) {
1945
- return AuthenticationApiFp(this.configuration).initLinkOAuth(requestParameters.oAuthInitRequest, options).then((request) => request(this.axios, this.basePath));
1946
- }
1947
2014
  /**
1948
2015
  *
1949
2016
  * @summary Initialize OAuth.
@@ -1966,6 +2033,27 @@ class AuthenticationApi extends BaseAPI {
1966
2033
  initSIWE(requestParameters, options) {
1967
2034
  return AuthenticationApiFp(this.configuration).initSIWE(requestParameters.sIWERequest, options).then((request) => request(this.axios, this.basePath));
1968
2035
  }
2036
+ /**
2037
+ *
2038
+ * @param {AuthenticationApiLinkEmailRequest} requestParameters Request parameters.
2039
+ * @param {*} [options] Override http request option.
2040
+ * @throws {RequiredError}
2041
+ * @memberof AuthenticationApi
2042
+ */
2043
+ linkEmail(requestParameters, options) {
2044
+ return AuthenticationApiFp(this.configuration).linkEmail(requestParameters.loginRequest, options).then((request) => request(this.axios, this.basePath));
2045
+ }
2046
+ /**
2047
+ *
2048
+ * @summary Initialize Link OAuth.
2049
+ * @param {AuthenticationApiLinkOAuthRequest} requestParameters Request parameters.
2050
+ * @param {*} [options] Override http request option.
2051
+ * @throws {RequiredError}
2052
+ * @memberof AuthenticationApi
2053
+ */
2054
+ linkOAuth(requestParameters, options) {
2055
+ return AuthenticationApiFp(this.configuration).linkOAuth(requestParameters.oAuthInitRequest, options).then((request) => request(this.axios, this.basePath));
2056
+ }
1969
2057
  /**
1970
2058
  *
1971
2059
  * @summary Link external wallet.
@@ -2085,6 +2173,16 @@ class AuthenticationApi extends BaseAPI {
2085
2173
  thirdParty(requestParameters, options) {
2086
2174
  return AuthenticationApiFp(this.configuration).thirdParty(requestParameters.thirdPartyOAuthRequest, options).then((request) => request(this.axios, this.basePath));
2087
2175
  }
2176
+ /**
2177
+ *
2178
+ * @param {AuthenticationApiUnlinkEmailRequest} requestParameters Request parameters.
2179
+ * @param {*} [options] Override http request option.
2180
+ * @throws {RequiredError}
2181
+ * @memberof AuthenticationApi
2182
+ */
2183
+ unlinkEmail(requestParameters, options) {
2184
+ return AuthenticationApiFp(this.configuration).unlinkEmail(requestParameters.unlinkEmailRequest, options).then((request) => request(this.axios, this.basePath));
2185
+ }
2088
2186
  /**
2089
2187
  *
2090
2188
  * @summary Unlink OAuth account
@@ -2094,7 +2192,7 @@ class AuthenticationApi extends BaseAPI {
2094
2192
  * @memberof AuthenticationApi
2095
2193
  */
2096
2194
  unlinkOAuth(requestParameters, options) {
2097
- return AuthenticationApiFp(this.configuration).unlinkOAuth(requestParameters.unlinkRequest, options).then((request) => request(this.axios, this.basePath));
2195
+ return AuthenticationApiFp(this.configuration).unlinkOAuth(requestParameters.unlinkOAuthRequest, options).then((request) => request(this.axios, this.basePath));
2098
2196
  }
2099
2197
  /**
2100
2198
  *
@@ -2973,16 +3071,18 @@ var OpenfortErrorType;
2973
3071
  (function (OpenfortErrorType) {
2974
3072
  OpenfortErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
2975
3073
  OpenfortErrorType["INVALID_CONFIGURATION"] = "INVALID_CONFIGURATION";
2976
- OpenfortErrorType["WALLET_CONNECTION_ERROR"] = "WALLET_CONNECTION_ERROR";
2977
3074
  OpenfortErrorType["NOT_LOGGED_IN_ERROR"] = "NOT_LOGGED_IN_ERROR";
2978
- OpenfortErrorType["SILENT_LOGIN_ERROR"] = "SILENT_LOGIN_ERROR";
2979
3075
  OpenfortErrorType["REFRESH_TOKEN_ERROR"] = "REFRESH_TOKEN_ERROR";
2980
3076
  OpenfortErrorType["USER_REGISTRATION_ERROR"] = "USER_REGISTRATION_ERROR";
2981
- OpenfortErrorType["USER_NOT_REGISTERED_ERROR"] = "USER_NOT_REGISTERED_ERROR";
2982
3077
  OpenfortErrorType["LOGOUT_ERROR"] = "LOGOUT_ERROR";
2983
- OpenfortErrorType["TRANSFER_ERROR"] = "TRANSFER_ERROR";
2984
3078
  OpenfortErrorType["OPERATION_NOT_SUPPORTED_ERROR"] = "OPERATION_NOT_SUPPORTED_ERROR";
3079
+ OpenfortErrorType["MISSING_SESSION_SIGNER_ERROR"] = "MISSING_SESSION_SIGNER_ERROR";
3080
+ OpenfortErrorType["MISSING_EMBEDDED_SIGNER_ERROR"] = "MISSING_EMBEDDED_SIGNER_ERROR";
3081
+ OpenfortErrorType["MISSING_SIGNER_ERROR"] = "MISSING_SIGNER_ERROR";
2985
3082
  })(OpenfortErrorType || (OpenfortErrorType = {}));
3083
+ function isAPIError(error) {
3084
+ return 'code' in error && 'message' in error;
3085
+ }
2986
3086
  class OpenfortError extends Error {
2987
3087
  type;
2988
3088
  constructor(message, type) {
@@ -2990,6 +3090,21 @@ class OpenfortError extends Error {
2990
3090
  this.type = type;
2991
3091
  }
2992
3092
  }
3093
+ const withOpenfortError = async (fn, customErrorType) => {
3094
+ try {
3095
+ return await fn();
3096
+ }
3097
+ catch (error) {
3098
+ let errorMessage;
3099
+ if (isAxiosError(error) && error.response?.data && isAPIError(error.response.data)) {
3100
+ errorMessage = error.response.data.message;
3101
+ }
3102
+ else {
3103
+ errorMessage = error.message;
3104
+ }
3105
+ throw new OpenfortError(errorMessage, customErrorType);
3106
+ }
3107
+ };
2993
3108
 
2994
3109
  const validateConfiguration = (configuration, requiredKeys, prefix) => {
2995
3110
  const missingKeys = requiredKeys
@@ -4544,12 +4659,12 @@ class AuthManager {
4544
4659
  this.backendApiClients = backendApiClients;
4545
4660
  this.instanceManager = instanceManager;
4546
4661
  }
4547
- async initOAuth(provider, usePooling, options) {
4662
+ async initOAuth(provider, options) {
4548
4663
  const request = {
4549
4664
  oAuthInitRequest: {
4550
4665
  provider,
4551
4666
  options,
4552
- usePooling: usePooling || false,
4667
+ usePooling: options?.usePooling || false,
4553
4668
  },
4554
4669
  };
4555
4670
  const result = await this.backendApiClients.authenticationApi.initOAuth(request);
@@ -4561,26 +4676,6 @@ class AuthManager {
4561
4676
  key: result.data.key,
4562
4677
  };
4563
4678
  }
4564
- async initLinkOAuth(provider, playerToken, usePooling, options) {
4565
- const request = {
4566
- oAuthInitRequest: {
4567
- provider,
4568
- options,
4569
- usePooling: usePooling || false,
4570
- },
4571
- };
4572
- const result = await this.backendApiClients.authenticationApi.initLinkOAuth(request, {
4573
- // eslint-disable-next-line @typescript-eslint/naming-convention
4574
- headers: { 'x-player-token': playerToken },
4575
- });
4576
- if (isBrowser() && !options?.skipBrowserRedirect) {
4577
- window.location.assign(result.data.url);
4578
- }
4579
- return {
4580
- url: result.data.url,
4581
- key: result.data.key,
4582
- };
4583
- }
4584
4679
  async poolOAuth(key) {
4585
4680
  const request = {
4586
4681
  key,
@@ -4613,18 +4708,6 @@ class AuthManager {
4613
4708
  }
4614
4709
  throw new Error('Failed to pool OAuth, try again later');
4615
4710
  }
4616
- // @deprecated
4617
- async authenticateOAuth(provider, token, tokenType) {
4618
- const request = {
4619
- authenticateOAuthRequest: {
4620
- provider,
4621
- token,
4622
- tokenType,
4623
- },
4624
- };
4625
- const response = await this.backendApiClients.authenticationApi.authenticateOAuth(request);
4626
- return response.data;
4627
- }
4628
4711
  async authenticateThirdParty(provider, token, tokenType) {
4629
4712
  const request = {
4630
4713
  thirdPartyOAuthRequest: {
@@ -4633,8 +4716,10 @@ class AuthManager {
4633
4716
  tokenType,
4634
4717
  },
4635
4718
  };
4636
- const response = await this.backendApiClients.authenticationApi.thirdParty(request);
4637
- return response.data;
4719
+ return withOpenfortError(async () => {
4720
+ const response = await this.backendApiClients.authenticationApi.thirdParty(request);
4721
+ return response.data;
4722
+ }, OpenfortErrorType.AUTHENTICATION_ERROR);
4638
4723
  }
4639
4724
  async initSIWE(address) {
4640
4725
  const request = {
@@ -4658,8 +4743,10 @@ class AuthManager {
4658
4743
  connectorType,
4659
4744
  },
4660
4745
  };
4661
- const response = await this.backendApiClients.authenticationApi.authenticateSIWE(request);
4662
- return response.data;
4746
+ return withOpenfortError(async () => {
4747
+ const response = await this.backendApiClients.authenticationApi.authenticateSIWE(request);
4748
+ return response.data;
4749
+ }, OpenfortErrorType.AUTHENTICATION_ERROR);
4663
4750
  }
4664
4751
  async loginEmailPassword(email, password) {
4665
4752
  const request = {
@@ -4668,8 +4755,10 @@ class AuthManager {
4668
4755
  password,
4669
4756
  },
4670
4757
  };
4671
- const response = await this.backendApiClients.authenticationApi.loginEmailPassword(request);
4672
- return response.data;
4758
+ return withOpenfortError(async () => {
4759
+ const response = await this.backendApiClients.authenticationApi.loginEmailPassword(request);
4760
+ return response.data;
4761
+ }, OpenfortErrorType.AUTHENTICATION_ERROR);
4673
4762
  }
4674
4763
  async requestResetPassword(email, redirectUrl) {
4675
4764
  const verifier = base64URLEncode(crypto.randomBytes(32));
@@ -4690,25 +4779,23 @@ class AuthManager {
4690
4779
  await this.backendApiClients.authenticationApi.requestResetPassword(request);
4691
4780
  }
4692
4781
  async resetPassword(email, password, state) {
4693
- const pkceData = this.deviceCredentialsManager.getPKCEData();
4694
- if (!pkceData) {
4695
- throw new Error('No code verifier or state for PKCE');
4696
- }
4697
- if (state !== pkceData.state) {
4698
- throw new Error('Provided state does not match stored state');
4699
- }
4700
- const request = {
4701
- resetPasswordRequest: {
4702
- email,
4703
- password,
4704
- state,
4705
- challenge: {
4706
- codeVerifier: pkceData.verifier,
4707
- method: CodeChallengeMethodEnum.S256,
4782
+ return withOpenfortError(async () => {
4783
+ const pkceData = this.deviceCredentialsManager.getPKCEData();
4784
+ if (!pkceData) {
4785
+ throw new Error('No code verifier or state for PKCE');
4786
+ }
4787
+ const request = {
4788
+ resetPasswordRequest: {
4789
+ email,
4790
+ password,
4791
+ state,
4792
+ challenge: {
4793
+ codeVerifier: pkceData.verifier,
4794
+ },
4708
4795
  },
4709
- },
4710
- };
4711
- await this.backendApiClients.authenticationApi.resetPassword(request);
4796
+ };
4797
+ await this.backendApiClients.authenticationApi.resetPassword(request);
4798
+ }, OpenfortErrorType.AUTHENTICATION_ERROR);
4712
4799
  }
4713
4800
  async requestEmailVerification(email, redirectUrl) {
4714
4801
  const verifier = base64URLEncode(crypto.randomBytes(32));
@@ -4729,24 +4816,22 @@ class AuthManager {
4729
4816
  await this.backendApiClients.authenticationApi.requestEmailVerification(request);
4730
4817
  }
4731
4818
  async verifyEmail(email, state) {
4732
- const pkceData = this.deviceCredentialsManager.getPKCEData();
4733
- if (!pkceData) {
4734
- throw new Error('No code verifier or state for PKCE');
4735
- }
4736
- if (state !== pkceData.state) {
4737
- throw new Error('Provided state does not match stored state');
4738
- }
4739
- const request = {
4740
- verifyEmailRequest: {
4741
- email,
4742
- token: state,
4743
- challenge: {
4744
- codeVerifier: pkceData.verifier,
4745
- method: CodeChallengeMethodEnum.S256,
4819
+ return withOpenfortError(async () => {
4820
+ const pkceData = this.deviceCredentialsManager.getPKCEData();
4821
+ if (!pkceData) {
4822
+ throw new Error('No code verifier or state for PKCE');
4823
+ }
4824
+ const request = {
4825
+ verifyEmailRequest: {
4826
+ email,
4827
+ token: state,
4828
+ challenge: {
4829
+ codeVerifier: pkceData.verifier,
4830
+ },
4746
4831
  },
4747
- },
4748
- };
4749
- await this.backendApiClients.authenticationApi.verifyEmail(request);
4832
+ };
4833
+ await this.backendApiClients.authenticationApi.verifyEmail(request);
4834
+ }, OpenfortErrorType.AUTHENTICATION_ERROR);
4750
4835
  }
4751
4836
  async signupEmailPassword(email, password, name) {
4752
4837
  const request = {
@@ -4756,8 +4841,10 @@ class AuthManager {
4756
4841
  name,
4757
4842
  },
4758
4843
  };
4759
- const response = await this.backendApiClients.authenticationApi.signupEmailPassword(request);
4760
- return response.data;
4844
+ return withOpenfortError(async () => {
4845
+ const response = await this.backendApiClients.authenticationApi.signupEmailPassword(request);
4846
+ return response.data;
4847
+ }, OpenfortErrorType.USER_REGISTRATION_ERROR);
4761
4848
  }
4762
4849
  async validateCredentials(accessToken, refreshToken, jwk) {
4763
4850
  try {
@@ -4781,12 +4868,14 @@ class AuthManager {
4781
4868
  refreshToken,
4782
4869
  },
4783
4870
  };
4784
- const newToken = await this.backendApiClients.authenticationApi.refresh(request);
4785
- return {
4786
- player: newToken.data.player.id,
4787
- accessToken: newToken.data.token,
4788
- refreshToken: newToken.data.refreshToken,
4789
- };
4871
+ return withOpenfortError(async () => {
4872
+ const newToken = await this.backendApiClients.authenticationApi.refresh(request);
4873
+ return {
4874
+ player: newToken.data.player.id,
4875
+ accessToken: newToken.data.token,
4876
+ refreshToken: newToken.data.refreshToken,
4877
+ };
4878
+ }, OpenfortErrorType.REFRESH_TOKEN_ERROR);
4790
4879
  }
4791
4880
  throw error;
4792
4881
  }
@@ -4797,13 +4886,128 @@ class AuthManager {
4797
4886
  refreshToken,
4798
4887
  },
4799
4888
  };
4800
- await this.backendApiClients.authenticationApi.logout(request, {
4889
+ withOpenfortError(async () => {
4890
+ await this.backendApiClients.authenticationApi.logout(request, {
4891
+ headers: {
4892
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4893
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4894
+ 'x-player-token': accessToken,
4895
+ },
4896
+ });
4897
+ }, OpenfortErrorType.LOGOUT_ERROR);
4898
+ }
4899
+ async getUser(accessToken) {
4900
+ // TODO: Add storage of user info
4901
+ const response = await this.backendApiClients.authenticationApi.me({
4902
+ headers: {
4903
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4904
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4905
+ 'x-player-token': accessToken,
4906
+ },
4907
+ });
4908
+ return response.data;
4909
+ }
4910
+ async linkOAuth(provider, playerToken, options) {
4911
+ const request = {
4912
+ oAuthInitRequest: {
4913
+ provider,
4914
+ options,
4915
+ usePooling: options?.usePooling || false,
4916
+ },
4917
+ };
4918
+ const result = await this.backendApiClients.authenticationApi.linkOAuth(request, {
4919
+ headers: {
4920
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4921
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4922
+ 'x-player-token': playerToken,
4923
+ },
4924
+ });
4925
+ if (isBrowser() && !options?.skipBrowserRedirect) {
4926
+ window.location.assign(result.data.url);
4927
+ }
4928
+ return {
4929
+ url: result.data.url,
4930
+ key: result.data.key,
4931
+ };
4932
+ }
4933
+ async unlinkOAuth(provider, accessToken) {
4934
+ const request = {
4935
+ unlinkOAuthRequest: {
4936
+ provider,
4937
+ },
4938
+ };
4939
+ const authPlayerResponse = await this.backendApiClients.authenticationApi.unlinkOAuth(request, {
4940
+ headers: {
4941
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4942
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4943
+ 'x-player-token': accessToken,
4944
+ },
4945
+ });
4946
+ return authPlayerResponse.data;
4947
+ }
4948
+ async unlinkWallet(address, accessToken) {
4949
+ const request = {
4950
+ sIWERequest: {
4951
+ address,
4952
+ },
4953
+ };
4954
+ const authPlayerResponse = await this.backendApiClients.authenticationApi.unlinkSIWE(request, {
4801
4955
  headers: {
4802
4956
  authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4803
4957
  // eslint-disable-next-line @typescript-eslint/naming-convention
4804
4958
  'x-player-token': accessToken,
4805
4959
  },
4806
4960
  });
4961
+ return authPlayerResponse.data;
4962
+ }
4963
+ async linkWallet(signature, message, walletClientType, connectorType, accessToken) {
4964
+ const request = {
4965
+ sIWEAuthenticateRequest: {
4966
+ signature,
4967
+ message,
4968
+ walletClientType,
4969
+ connectorType,
4970
+ },
4971
+ };
4972
+ const authPlayerResponse = await this.backendApiClients.authenticationApi.linkSIWE(request, {
4973
+ headers: {
4974
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4975
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4976
+ 'x-player-token': accessToken,
4977
+ },
4978
+ });
4979
+ return authPlayerResponse.data;
4980
+ }
4981
+ async unlinkEmail(email, accessToken) {
4982
+ const request = {
4983
+ unlinkEmailRequest: {
4984
+ email,
4985
+ },
4986
+ };
4987
+ const authPlayerResponse = await this.backendApiClients.authenticationApi.unlinkEmail(request, {
4988
+ headers: {
4989
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4990
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4991
+ 'x-player-token': accessToken,
4992
+ },
4993
+ });
4994
+ return authPlayerResponse.data;
4995
+ }
4996
+ async linkEmail(email, password, accessToken) {
4997
+ const request = {
4998
+ loginRequest: {
4999
+ email,
5000
+ password,
5001
+ },
5002
+ };
5003
+ const authPlayerResponse = await this.backendApiClients.authenticationApi.linkEmail(request, {
5004
+ headers: {
5005
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
5006
+ // eslint-disable-next-line @typescript-eslint/naming-convention
5007
+ 'x-player-token': accessToken,
5008
+ },
5009
+ });
5010
+ return authPlayerResponse.data;
4807
5011
  }
4808
5012
  }
4809
5013
 
@@ -4847,7 +5051,7 @@ class InstanceManager {
4847
5051
  if (!this.authToken) {
4848
5052
  const token = this.secureStorage.get(authTokenStorageKey);
4849
5053
  if (token === null)
4850
- return null; // Early exit if no token is found
5054
+ return null;
4851
5055
  this.authToken = {
4852
5056
  token,
4853
5057
  thirdPartyProvider: this.secureStorage.get(thirdPartyProviderStorageKey),
@@ -5629,34 +5833,6 @@ class IframeManager {
5629
5833
  }
5630
5834
  }
5631
5835
 
5632
- class NotLoggedIn extends Error {
5633
- constructor(message) {
5634
- super(message);
5635
- this.name = 'NotLoggedIn';
5636
- Object.setPrototypeOf(this, NotLoggedIn.prototype);
5637
- }
5638
- }
5639
- class EmbeddedNotConfigured extends Error {
5640
- constructor(message) {
5641
- super(message);
5642
- this.name = 'EmbeddedNotConfigured';
5643
- Object.setPrototypeOf(this, EmbeddedNotConfigured.prototype);
5644
- }
5645
- }
5646
- class NoSignerConfigured extends Error {
5647
- constructor(message) {
5648
- super(message);
5649
- this.name = 'NoSignerConfigured';
5650
- Object.setPrototypeOf(this, NoSignerConfigured.prototype);
5651
- }
5652
- }
5653
- class NothingToSign extends Error {
5654
- constructor(message) {
5655
- super(message);
5656
- this.name = 'NothingToSign';
5657
- Object.setPrototypeOf(this, NothingToSign.prototype);
5658
- }
5659
- }
5660
5836
  class Openfort {
5661
5837
  signer;
5662
5838
  authManager;
@@ -5706,7 +5882,7 @@ class Openfort {
5706
5882
  announceProvider: true,
5707
5883
  }) {
5708
5884
  if (!(this.signer instanceof EmbeddedSigner)) {
5709
- throw new EmbeddedNotConfigured('Embedded signer must be configured to get Ethereum provider');
5885
+ throw new OpenfortError('Embedded signer must be configured to get Ethereum provider', OpenfortErrorType.NOT_LOGGED_IN_ERROR);
5710
5886
  }
5711
5887
  const address = this.instanceManager.getAccountAddress();
5712
5888
  const provider = new EvmProvider({
@@ -5771,18 +5947,18 @@ class Openfort {
5771
5947
  }
5772
5948
  newEmbeddedSigner(chainId, shieldAuthentication) {
5773
5949
  if (!this.credentialsProvided()) {
5774
- throw new NotLoggedIn('Must be logged in to configure embedded signer');
5950
+ throw new OpenfortError('Must be logged in to configure embedded signer', OpenfortErrorType.NOT_LOGGED_IN_ERROR);
5775
5951
  }
5776
5952
  const iframeConfiguration = {
5777
5953
  accessToken: this.instanceManager.getAccessToken()?.token ?? null,
5778
5954
  thirdPartyProvider: this.instanceManager.getAccessToken()?.thirdPartyProvider ?? null,
5779
5955
  thirdPartyTokenType: this.instanceManager.getAccessToken()?.thirdPartyTokenType ?? null,
5780
- chainId: chainId ?? null,
5956
+ chainId: !chainId ? Number(this.instanceManager.getChainID()) ?? null : chainId,
5781
5957
  recovery: shieldAuthentication ?? null,
5782
5958
  };
5783
5959
  return new EmbeddedSigner(this.iframeManager, this.instanceManager, iframeConfiguration);
5784
5960
  }
5785
- async loginWithEmailPassword(email, password) {
5961
+ async loginWithEmailPassword({ email, password, }) {
5786
5962
  this.instanceManager.removeAccessToken();
5787
5963
  this.instanceManager.removeRefreshToken();
5788
5964
  this.instanceManager.removePlayerID();
@@ -5794,11 +5970,11 @@ class Openfort {
5794
5970
  });
5795
5971
  return result;
5796
5972
  }
5797
- async signUpWithEmailPassword(email, password, name) {
5973
+ async signUpWithEmailPassword({ email, password, options, }) {
5798
5974
  this.instanceManager.removeAccessToken();
5799
5975
  this.instanceManager.removeRefreshToken();
5800
5976
  this.instanceManager.removePlayerID();
5801
- const result = await this.authManager.signupEmailPassword(email, password, name);
5977
+ const result = await this.authManager.signupEmailPassword(email, password, options?.data.name);
5802
5978
  this.storeCredentials({
5803
5979
  player: result.player.id,
5804
5980
  accessToken: result.token,
@@ -5806,45 +5982,32 @@ class Openfort {
5806
5982
  });
5807
5983
  return result;
5808
5984
  }
5809
- async requestEmailVerification(email, redirectUrl) {
5985
+ async requestEmailVerification({ email, redirectUrl }) {
5810
5986
  await this.authManager.requestEmailVerification(email, redirectUrl);
5811
5987
  }
5812
- async resetPassword(email, password, state) {
5988
+ async resetPassword({ email, password, state }) {
5813
5989
  await this.authManager.resetPassword(email, password, state);
5814
5990
  }
5815
- async requestResetPassword(email, redirectUrl) {
5991
+ async requestResetPassword({ email, redirectUrl }) {
5816
5992
  await this.authManager.requestResetPassword(email, redirectUrl);
5817
5993
  }
5818
- async verifyEmail(email, state) {
5994
+ async verifyEmail({ email, state }) {
5819
5995
  await this.authManager.verifyEmail(email, state);
5820
5996
  }
5821
- async initOAuth(provider, usePooling, options) {
5822
- const authResponse = await this.authManager.initOAuth(provider, usePooling, options);
5997
+ async initOAuth({ provider, options }) {
5998
+ const authResponse = await this.authManager.initOAuth(provider, options);
5823
5999
  return authResponse;
5824
6000
  }
5825
- async initLinkOAuth(provider, playerToken, usePooling, options) {
5826
- return await this.authManager.initLinkOAuth(provider, playerToken, usePooling, options);
6001
+ async initLinkOAuth({ provider, playerToken, options }) {
6002
+ return await this.authManager.linkOAuth(provider, playerToken, options);
5827
6003
  }
5828
6004
  async poolOAuth(key) {
5829
6005
  return await this.authManager.poolOAuth(key);
5830
6006
  }
5831
- // @deprecated
5832
- async authenticateWithOAuth(provider, token, tokenType) {
5833
- this.instanceManager.removeAccessToken();
5834
- this.instanceManager.removeRefreshToken();
5835
- this.instanceManager.removePlayerID();
5836
- const result = await this.authManager.authenticateOAuth(provider, token, tokenType);
5837
- this.storeCredentials({
5838
- player: result.player.id,
5839
- accessToken: result.token,
5840
- refreshToken: result.refreshToken,
5841
- });
5842
- return result;
5843
- }
5844
- async initSIWE(address) {
6007
+ async initSIWE({ address }) {
5845
6008
  return await this.authManager.initSIWE(address);
5846
6009
  }
5847
- async authenticateWithThirdPartyProvider(provider, token, tokenType) {
6010
+ async authenticateWithThirdPartyProvider({ provider, token, tokenType }) {
5848
6011
  const result = await this.authManager.authenticateThirdParty(provider, token, tokenType);
5849
6012
  this.instanceManager.setAccessToken({
5850
6013
  token,
@@ -5857,7 +6020,7 @@ class Openfort {
5857
6020
  }
5858
6021
  return result;
5859
6022
  }
5860
- async authenticateWithSIWE(signature, message, walletClientType, connectorType) {
6023
+ async authenticateWithSIWE({ signature, message, walletClientType, connectorType, }) {
5861
6024
  this.instanceManager.removeAccessToken();
5862
6025
  this.instanceManager.removeRefreshToken();
5863
6026
  this.instanceManager.removePlayerID();
@@ -5882,11 +6045,11 @@ class Openfort {
5882
6045
  let newSignature = signature;
5883
6046
  if (!newSignature) {
5884
6047
  if (!userOperationHash) {
5885
- throw new NothingToSign('No userOperationHash or signature provided');
6048
+ throw new OpenfortError('No userOperationHash or signature provided', OpenfortErrorType.OPERATION_NOT_SUPPORTED_ERROR);
5886
6049
  }
5887
6050
  await this.recoverSigner();
5888
6051
  if (!this.signer) {
5889
- throw new NoSignerConfigured('In order to sign a transaction intent, a signer must be configured');
6052
+ throw new OpenfortError('In order to sign a transaction intent, a signer must be configured', OpenfortErrorType.MISSING_SIGNER_ERROR);
5890
6053
  }
5891
6054
  if (this.signer.useCredentials()) {
5892
6055
  await this.validateAndRefreshToken();
@@ -5905,7 +6068,7 @@ class Openfort {
5905
6068
  async signMessage(message, options) {
5906
6069
  await this.recoverSigner();
5907
6070
  if (!this.signer) {
5908
- throw new NoSignerConfigured('No signer configured');
6071
+ throw new OpenfortError('In order to sign a message, an embedded signer must be configured', OpenfortErrorType.MISSING_EMBEDDED_SIGNER_ERROR);
5909
6072
  }
5910
6073
  if (this.signer.useCredentials()) {
5911
6074
  await this.validateAndRefreshToken();
@@ -5916,7 +6079,7 @@ class Openfort {
5916
6079
  async signTypedData(domain, types, value) {
5917
6080
  await this.recoverSigner();
5918
6081
  if (!this.signer) {
5919
- throw new NoSignerConfigured('No signer configured');
6082
+ throw new OpenfortError('In order to sign a message, an embedded signer must be configured', OpenfortErrorType.MISSING_EMBEDDED_SIGNER_ERROR);
5920
6083
  }
5921
6084
  if (this.signer.useCredentials()) {
5922
6085
  await this.validateAndRefreshToken();
@@ -5949,10 +6112,10 @@ class Openfort {
5949
6112
  async sendRegisterSessionRequest(sessionId, signature, optimistic) {
5950
6113
  await this.recoverSigner();
5951
6114
  if (!this.signer) {
5952
- throw new NoSignerConfigured('No signer configured nor signature provided');
6115
+ throw new OpenfortError('No signer configured nor signature provided', OpenfortErrorType.MISSING_SIGNER_ERROR);
5953
6116
  }
5954
6117
  if (this.signer.getSingerType() !== SignerType.SESSION) {
5955
- throw new NoSignerConfigured('Session signer must be configured to sign a session');
6118
+ throw new OpenfortError('Session signer must be configured to sign a session', OpenfortErrorType.MISSING_SESSION_SIGNER_ERROR);
5956
6119
  }
5957
6120
  const request = {
5958
6121
  id: sessionId,
@@ -6019,23 +6182,6 @@ class Openfort {
6019
6182
  && ((token.token && token.thirdPartyProvider && token.thirdPartyTokenType)
6020
6183
  || (token.token && refreshToken)));
6021
6184
  }
6022
- async isAuthenticated() {
6023
- if (!this.credentialsProvided()) {
6024
- return false;
6025
- }
6026
- if (!this.signer) {
6027
- const signerType = this.instanceManager.getSignerType();
6028
- if (signerType !== SignerType.EMBEDDED) {
6029
- return false;
6030
- }
6031
- const signer = this.newEmbeddedSigner();
6032
- return await signer.isLoaded();
6033
- }
6034
- if (this.signer.getSingerType() !== SignerType.EMBEDDED) {
6035
- return false;
6036
- }
6037
- return await this.signer.isLoaded();
6038
- }
6039
6185
  getAccessToken() {
6040
6186
  return this.instanceManager.getAccessToken()?.token ?? null;
6041
6187
  }
@@ -6048,6 +6194,14 @@ class Openfort {
6048
6194
  }
6049
6195
  return true;
6050
6196
  }
6197
+ async getUser() {
6198
+ await this.validateAndRefreshToken();
6199
+ const accessToken = this.instanceManager.getAccessToken();
6200
+ if (!accessToken) {
6201
+ throw new OpenfortError('No accessToken found', OpenfortErrorType.NOT_LOGGED_IN_ERROR);
6202
+ }
6203
+ return await this.authManager.getUser(accessToken.token);
6204
+ }
6051
6205
  async validateAndRefreshToken() {
6052
6206
  if (!this.credentialsProvided()) {
6053
6207
  return;