@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.cjs CHANGED
@@ -1034,15 +1034,15 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1034
1034
  },
1035
1035
  /**
1036
1036
  *
1037
- * @summary Initialize Link OAuth.
1037
+ * @summary Initialize OAuth.
1038
1038
  * @param {OAuthInitRequest} oAuthInitRequest
1039
1039
  * @param {*} [options] Override http request option.
1040
1040
  * @throws {RequiredError}
1041
1041
  */
1042
- initLinkOAuth: async (oAuthInitRequest, options = {}) => {
1042
+ initOAuth: async (oAuthInitRequest, options = {}) => {
1043
1043
  // verify required parameter 'oAuthInitRequest' is not null or undefined
1044
- assertParamExists('initLinkOAuth', 'oAuthInitRequest', oAuthInitRequest);
1045
- const localVarPath = `/iam/v1/oauth/init_link`;
1044
+ assertParamExists('initOAuth', 'oAuthInitRequest', oAuthInitRequest);
1045
+ const localVarPath = `/iam/v1/oauth/init`;
1046
1046
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1047
1047
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1048
1048
  let baseOptions;
@@ -1052,6 +1052,9 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1052
1052
  const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1053
1053
  const localVarHeaderParameter = {};
1054
1054
  const localVarQueryParameter = {};
1055
+ // authentication pk required
1056
+ // http bearer authentication required
1057
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
1055
1058
  localVarHeaderParameter['Content-Type'] = 'application/json';
1056
1059
  setSearchParams(localVarUrlObj, localVarQueryParameter);
1057
1060
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
@@ -1063,16 +1066,16 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1063
1066
  };
1064
1067
  },
1065
1068
  /**
1066
- *
1067
- * @summary Initialize OAuth.
1068
- * @param {OAuthInitRequest} oAuthInitRequest
1069
+ * Create a challenge to link external wallet to the player.
1070
+ * @summary Initialize SIWE.
1071
+ * @param {SIWERequest} sIWERequest
1069
1072
  * @param {*} [options] Override http request option.
1070
1073
  * @throws {RequiredError}
1071
1074
  */
1072
- initOAuth: async (oAuthInitRequest, options = {}) => {
1073
- // verify required parameter 'oAuthInitRequest' is not null or undefined
1074
- assertParamExists('initOAuth', 'oAuthInitRequest', oAuthInitRequest);
1075
- const localVarPath = `/iam/v1/oauth/init`;
1075
+ initSIWE: async (sIWERequest, options = {}) => {
1076
+ // verify required parameter 'sIWERequest' is not null or undefined
1077
+ assertParamExists('initSIWE', 'sIWERequest', sIWERequest);
1078
+ const localVarPath = `/iam/v1/siwe/init`;
1076
1079
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1077
1080
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1078
1081
  let baseOptions;
@@ -1089,23 +1092,22 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1089
1092
  setSearchParams(localVarUrlObj, localVarQueryParameter);
1090
1093
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1091
1094
  localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1092
- localVarRequestOptions.data = serializeDataIfNeeded(oAuthInitRequest, localVarRequestOptions, configuration);
1095
+ localVarRequestOptions.data = serializeDataIfNeeded(sIWERequest, localVarRequestOptions, configuration);
1093
1096
  return {
1094
1097
  url: toPathString(localVarUrlObj),
1095
1098
  options: localVarRequestOptions,
1096
1099
  };
1097
1100
  },
1098
1101
  /**
1099
- * Create a challenge to link external wallet to the player.
1100
- * @summary Initialize SIWE.
1101
- * @param {SIWERequest} sIWERequest
1102
+ *
1103
+ * @param {LoginRequest} loginRequest
1102
1104
  * @param {*} [options] Override http request option.
1103
1105
  * @throws {RequiredError}
1104
1106
  */
1105
- initSIWE: async (sIWERequest, options = {}) => {
1106
- // verify required parameter 'sIWERequest' is not null or undefined
1107
- assertParamExists('initSIWE', 'sIWERequest', sIWERequest);
1108
- const localVarPath = `/iam/v1/siwe/init`;
1107
+ linkEmail: async (loginRequest, options = {}) => {
1108
+ // verify required parameter 'loginRequest' is not null or undefined
1109
+ assertParamExists('linkEmail', 'loginRequest', loginRequest);
1110
+ const localVarPath = `/iam/v1/password/link`;
1109
1111
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1110
1112
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1111
1113
  let baseOptions;
@@ -1115,14 +1117,41 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1115
1117
  const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1116
1118
  const localVarHeaderParameter = {};
1117
1119
  const localVarQueryParameter = {};
1118
- // authentication pk required
1119
- // http bearer authentication required
1120
- await setBearerAuthToObject(localVarHeaderParameter, configuration);
1121
1120
  localVarHeaderParameter['Content-Type'] = 'application/json';
1122
1121
  setSearchParams(localVarUrlObj, localVarQueryParameter);
1123
1122
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1124
1123
  localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1125
- localVarRequestOptions.data = serializeDataIfNeeded(sIWERequest, localVarRequestOptions, configuration);
1124
+ localVarRequestOptions.data = serializeDataIfNeeded(loginRequest, localVarRequestOptions, configuration);
1125
+ return {
1126
+ url: toPathString(localVarUrlObj),
1127
+ options: localVarRequestOptions,
1128
+ };
1129
+ },
1130
+ /**
1131
+ *
1132
+ * @summary Initialize Link OAuth.
1133
+ * @param {OAuthInitRequest} oAuthInitRequest
1134
+ * @param {*} [options] Override http request option.
1135
+ * @throws {RequiredError}
1136
+ */
1137
+ linkOAuth: async (oAuthInitRequest, options = {}) => {
1138
+ // verify required parameter 'oAuthInitRequest' is not null or undefined
1139
+ assertParamExists('linkOAuth', 'oAuthInitRequest', oAuthInitRequest);
1140
+ const localVarPath = `/iam/v1/oauth/init_link`;
1141
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1142
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1143
+ let baseOptions;
1144
+ if (configuration) {
1145
+ baseOptions = configuration.baseOptions;
1146
+ }
1147
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1148
+ const localVarHeaderParameter = {};
1149
+ const localVarQueryParameter = {};
1150
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1151
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1152
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1153
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1154
+ localVarRequestOptions.data = serializeDataIfNeeded(oAuthInitRequest, localVarRequestOptions, configuration);
1126
1155
  return {
1127
1156
  url: toPathString(localVarUrlObj),
1128
1157
  options: localVarRequestOptions,
@@ -1319,7 +1348,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1319
1348
  requestEmailVerification: async (requestVerifyEmailRequest, options = {}) => {
1320
1349
  // verify required parameter 'requestVerifyEmailRequest' is not null or undefined
1321
1350
  assertParamExists('requestEmailVerification', 'requestVerifyEmailRequest', requestVerifyEmailRequest);
1322
- const localVarPath = `/iam/v1/password/email/request_verification`;
1351
+ const localVarPath = `/iam/v1/password/request_email_verification`;
1323
1352
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1324
1353
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1325
1354
  let baseOptions;
@@ -1352,7 +1381,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1352
1381
  requestResetPassword: async (requestResetPasswordRequest, options = {}) => {
1353
1382
  // verify required parameter 'requestResetPasswordRequest' is not null or undefined
1354
1383
  assertParamExists('requestResetPassword', 'requestResetPasswordRequest', requestResetPasswordRequest);
1355
- const localVarPath = `/iam/v1/password/password/request_reset`;
1384
+ const localVarPath = `/iam/v1/password/request_reset`;
1356
1385
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1357
1386
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1358
1387
  let baseOptions;
@@ -1385,7 +1414,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1385
1414
  resetPassword: async (resetPasswordRequest, options = {}) => {
1386
1415
  // verify required parameter 'resetPasswordRequest' is not null or undefined
1387
1416
  assertParamExists('resetPassword', 'resetPasswordRequest', resetPasswordRequest);
1388
- const localVarPath = `/iam/v1/password/password/reset`;
1417
+ const localVarPath = `/iam/v1/password/reset`;
1389
1418
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1390
1419
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1391
1420
  let baseOptions;
@@ -1474,16 +1503,45 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1474
1503
  options: localVarRequestOptions,
1475
1504
  };
1476
1505
  },
1506
+ /**
1507
+ *
1508
+ * @param {UnlinkEmailRequest} unlinkEmailRequest
1509
+ * @param {*} [options] Override http request option.
1510
+ * @throws {RequiredError}
1511
+ */
1512
+ unlinkEmail: async (unlinkEmailRequest, options = {}) => {
1513
+ // verify required parameter 'unlinkEmailRequest' is not null or undefined
1514
+ assertParamExists('unlinkEmail', 'unlinkEmailRequest', unlinkEmailRequest);
1515
+ const localVarPath = `/iam/v1/password/unlink`;
1516
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1517
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1518
+ let baseOptions;
1519
+ if (configuration) {
1520
+ baseOptions = configuration.baseOptions;
1521
+ }
1522
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1523
+ const localVarHeaderParameter = {};
1524
+ const localVarQueryParameter = {};
1525
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1526
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1527
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1528
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1529
+ localVarRequestOptions.data = serializeDataIfNeeded(unlinkEmailRequest, localVarRequestOptions, configuration);
1530
+ return {
1531
+ url: toPathString(localVarUrlObj),
1532
+ options: localVarRequestOptions,
1533
+ };
1534
+ },
1477
1535
  /**
1478
1536
  *
1479
1537
  * @summary Unlink OAuth account
1480
- * @param {UnlinkRequest} unlinkRequest
1538
+ * @param {UnlinkOAuthRequest} unlinkOAuthRequest
1481
1539
  * @param {*} [options] Override http request option.
1482
1540
  * @throws {RequiredError}
1483
1541
  */
1484
- unlinkOAuth: async (unlinkRequest, options = {}) => {
1485
- // verify required parameter 'unlinkRequest' is not null or undefined
1486
- assertParamExists('unlinkOAuth', 'unlinkRequest', unlinkRequest);
1542
+ unlinkOAuth: async (unlinkOAuthRequest, options = {}) => {
1543
+ // verify required parameter 'unlinkOAuthRequest' is not null or undefined
1544
+ assertParamExists('unlinkOAuth', 'unlinkOAuthRequest', unlinkOAuthRequest);
1487
1545
  const localVarPath = `/iam/v1/oauth/unlink`;
1488
1546
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1489
1547
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
@@ -1498,7 +1556,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1498
1556
  setSearchParams(localVarUrlObj, localVarQueryParameter);
1499
1557
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1500
1558
  localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1501
- localVarRequestOptions.data = serializeDataIfNeeded(unlinkRequest, localVarRequestOptions, configuration);
1559
+ localVarRequestOptions.data = serializeDataIfNeeded(unlinkOAuthRequest, localVarRequestOptions, configuration);
1502
1560
  return {
1503
1561
  url: toPathString(localVarUrlObj),
1504
1562
  options: localVarRequestOptions,
@@ -1544,7 +1602,7 @@ const AuthenticationApiAxiosParamCreator = function (configuration) {
1544
1602
  verifyEmail: async (verifyEmailRequest, options = {}) => {
1545
1603
  // verify required parameter 'verifyEmailRequest' is not null or undefined
1546
1604
  assertParamExists('verifyEmail', 'verifyEmailRequest', verifyEmailRequest);
1547
- const localVarPath = `/iam/v1/password/email/verify`;
1605
+ const localVarPath = `/iam/v1/password/verify_email`;
1548
1606
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1549
1607
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1550
1608
  let baseOptions;
@@ -1693,17 +1751,6 @@ const AuthenticationApiFp = function (configuration) {
1693
1751
  const localVarAxiosArgs = await localVarAxiosParamCreator.getJwks(publishableKey, options);
1694
1752
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1695
1753
  },
1696
- /**
1697
- *
1698
- * @summary Initialize Link OAuth.
1699
- * @param {OAuthInitRequest} oAuthInitRequest
1700
- * @param {*} [options] Override http request option.
1701
- * @throws {RequiredError}
1702
- */
1703
- async initLinkOAuth(oAuthInitRequest, options) {
1704
- const localVarAxiosArgs = await localVarAxiosParamCreator.initLinkOAuth(oAuthInitRequest, options);
1705
- return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1706
- },
1707
1754
  /**
1708
1755
  *
1709
1756
  * @summary Initialize OAuth.
@@ -1726,6 +1773,27 @@ const AuthenticationApiFp = function (configuration) {
1726
1773
  const localVarAxiosArgs = await localVarAxiosParamCreator.initSIWE(sIWERequest, options);
1727
1774
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1728
1775
  },
1776
+ /**
1777
+ *
1778
+ * @param {LoginRequest} loginRequest
1779
+ * @param {*} [options] Override http request option.
1780
+ * @throws {RequiredError}
1781
+ */
1782
+ async linkEmail(loginRequest, options) {
1783
+ const localVarAxiosArgs = await localVarAxiosParamCreator.linkEmail(loginRequest, options);
1784
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1785
+ },
1786
+ /**
1787
+ *
1788
+ * @summary Initialize Link OAuth.
1789
+ * @param {OAuthInitRequest} oAuthInitRequest
1790
+ * @param {*} [options] Override http request option.
1791
+ * @throws {RequiredError}
1792
+ */
1793
+ async linkOAuth(oAuthInitRequest, options) {
1794
+ const localVarAxiosArgs = await localVarAxiosParamCreator.linkOAuth(oAuthInitRequest, options);
1795
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1796
+ },
1729
1797
  /**
1730
1798
  *
1731
1799
  * @summary Link external wallet.
@@ -1845,15 +1913,25 @@ const AuthenticationApiFp = function (configuration) {
1845
1913
  const localVarAxiosArgs = await localVarAxiosParamCreator.thirdParty(thirdPartyOAuthRequest, options);
1846
1914
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1847
1915
  },
1916
+ /**
1917
+ *
1918
+ * @param {UnlinkEmailRequest} unlinkEmailRequest
1919
+ * @param {*} [options] Override http request option.
1920
+ * @throws {RequiredError}
1921
+ */
1922
+ async unlinkEmail(unlinkEmailRequest, options) {
1923
+ const localVarAxiosArgs = await localVarAxiosParamCreator.unlinkEmail(unlinkEmailRequest, options);
1924
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1925
+ },
1848
1926
  /**
1849
1927
  *
1850
1928
  * @summary Unlink OAuth account
1851
- * @param {UnlinkRequest} unlinkRequest
1929
+ * @param {UnlinkOAuthRequest} unlinkOAuthRequest
1852
1930
  * @param {*} [options] Override http request option.
1853
1931
  * @throws {RequiredError}
1854
1932
  */
1855
- async unlinkOAuth(unlinkRequest, options) {
1856
- const localVarAxiosArgs = await localVarAxiosParamCreator.unlinkOAuth(unlinkRequest, options);
1933
+ async unlinkOAuth(unlinkOAuthRequest, options) {
1934
+ const localVarAxiosArgs = await localVarAxiosParamCreator.unlinkOAuth(unlinkOAuthRequest, options);
1857
1935
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1858
1936
  },
1859
1937
  /**
@@ -1956,17 +2034,6 @@ class AuthenticationApi extends BaseAPI {
1956
2034
  getJwks(requestParameters, options) {
1957
2035
  return AuthenticationApiFp(this.configuration).getJwks(requestParameters.publishableKey, options).then((request) => request(this.axios, this.basePath));
1958
2036
  }
1959
- /**
1960
- *
1961
- * @summary Initialize Link OAuth.
1962
- * @param {AuthenticationApiInitLinkOAuthRequest} requestParameters Request parameters.
1963
- * @param {*} [options] Override http request option.
1964
- * @throws {RequiredError}
1965
- * @memberof AuthenticationApi
1966
- */
1967
- initLinkOAuth(requestParameters, options) {
1968
- return AuthenticationApiFp(this.configuration).initLinkOAuth(requestParameters.oAuthInitRequest, options).then((request) => request(this.axios, this.basePath));
1969
- }
1970
2037
  /**
1971
2038
  *
1972
2039
  * @summary Initialize OAuth.
@@ -1989,6 +2056,27 @@ class AuthenticationApi extends BaseAPI {
1989
2056
  initSIWE(requestParameters, options) {
1990
2057
  return AuthenticationApiFp(this.configuration).initSIWE(requestParameters.sIWERequest, options).then((request) => request(this.axios, this.basePath));
1991
2058
  }
2059
+ /**
2060
+ *
2061
+ * @param {AuthenticationApiLinkEmailRequest} requestParameters Request parameters.
2062
+ * @param {*} [options] Override http request option.
2063
+ * @throws {RequiredError}
2064
+ * @memberof AuthenticationApi
2065
+ */
2066
+ linkEmail(requestParameters, options) {
2067
+ return AuthenticationApiFp(this.configuration).linkEmail(requestParameters.loginRequest, options).then((request) => request(this.axios, this.basePath));
2068
+ }
2069
+ /**
2070
+ *
2071
+ * @summary Initialize Link OAuth.
2072
+ * @param {AuthenticationApiLinkOAuthRequest} requestParameters Request parameters.
2073
+ * @param {*} [options] Override http request option.
2074
+ * @throws {RequiredError}
2075
+ * @memberof AuthenticationApi
2076
+ */
2077
+ linkOAuth(requestParameters, options) {
2078
+ return AuthenticationApiFp(this.configuration).linkOAuth(requestParameters.oAuthInitRequest, options).then((request) => request(this.axios, this.basePath));
2079
+ }
1992
2080
  /**
1993
2081
  *
1994
2082
  * @summary Link external wallet.
@@ -2108,6 +2196,16 @@ class AuthenticationApi extends BaseAPI {
2108
2196
  thirdParty(requestParameters, options) {
2109
2197
  return AuthenticationApiFp(this.configuration).thirdParty(requestParameters.thirdPartyOAuthRequest, options).then((request) => request(this.axios, this.basePath));
2110
2198
  }
2199
+ /**
2200
+ *
2201
+ * @param {AuthenticationApiUnlinkEmailRequest} requestParameters Request parameters.
2202
+ * @param {*} [options] Override http request option.
2203
+ * @throws {RequiredError}
2204
+ * @memberof AuthenticationApi
2205
+ */
2206
+ unlinkEmail(requestParameters, options) {
2207
+ return AuthenticationApiFp(this.configuration).unlinkEmail(requestParameters.unlinkEmailRequest, options).then((request) => request(this.axios, this.basePath));
2208
+ }
2111
2209
  /**
2112
2210
  *
2113
2211
  * @summary Unlink OAuth account
@@ -2117,7 +2215,7 @@ class AuthenticationApi extends BaseAPI {
2117
2215
  * @memberof AuthenticationApi
2118
2216
  */
2119
2217
  unlinkOAuth(requestParameters, options) {
2120
- return AuthenticationApiFp(this.configuration).unlinkOAuth(requestParameters.unlinkRequest, options).then((request) => request(this.axios, this.basePath));
2218
+ return AuthenticationApiFp(this.configuration).unlinkOAuth(requestParameters.unlinkOAuthRequest, options).then((request) => request(this.axios, this.basePath));
2121
2219
  }
2122
2220
  /**
2123
2221
  *
@@ -2996,16 +3094,18 @@ var OpenfortErrorType;
2996
3094
  (function (OpenfortErrorType) {
2997
3095
  OpenfortErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
2998
3096
  OpenfortErrorType["INVALID_CONFIGURATION"] = "INVALID_CONFIGURATION";
2999
- OpenfortErrorType["WALLET_CONNECTION_ERROR"] = "WALLET_CONNECTION_ERROR";
3000
3097
  OpenfortErrorType["NOT_LOGGED_IN_ERROR"] = "NOT_LOGGED_IN_ERROR";
3001
- OpenfortErrorType["SILENT_LOGIN_ERROR"] = "SILENT_LOGIN_ERROR";
3002
3098
  OpenfortErrorType["REFRESH_TOKEN_ERROR"] = "REFRESH_TOKEN_ERROR";
3003
3099
  OpenfortErrorType["USER_REGISTRATION_ERROR"] = "USER_REGISTRATION_ERROR";
3004
- OpenfortErrorType["USER_NOT_REGISTERED_ERROR"] = "USER_NOT_REGISTERED_ERROR";
3005
3100
  OpenfortErrorType["LOGOUT_ERROR"] = "LOGOUT_ERROR";
3006
- OpenfortErrorType["TRANSFER_ERROR"] = "TRANSFER_ERROR";
3007
3101
  OpenfortErrorType["OPERATION_NOT_SUPPORTED_ERROR"] = "OPERATION_NOT_SUPPORTED_ERROR";
3102
+ OpenfortErrorType["MISSING_SESSION_SIGNER_ERROR"] = "MISSING_SESSION_SIGNER_ERROR";
3103
+ OpenfortErrorType["MISSING_EMBEDDED_SIGNER_ERROR"] = "MISSING_EMBEDDED_SIGNER_ERROR";
3104
+ OpenfortErrorType["MISSING_SIGNER_ERROR"] = "MISSING_SIGNER_ERROR";
3008
3105
  })(OpenfortErrorType || (OpenfortErrorType = {}));
3106
+ function isAPIError(error) {
3107
+ return 'code' in error && 'message' in error;
3108
+ }
3009
3109
  class OpenfortError extends Error {
3010
3110
  type;
3011
3111
  constructor(message, type) {
@@ -3013,6 +3113,21 @@ class OpenfortError extends Error {
3013
3113
  this.type = type;
3014
3114
  }
3015
3115
  }
3116
+ const withOpenfortError = async (fn, customErrorType) => {
3117
+ try {
3118
+ return await fn();
3119
+ }
3120
+ catch (error) {
3121
+ let errorMessage;
3122
+ if (globalAxios.isAxiosError(error) && error.response?.data && isAPIError(error.response.data)) {
3123
+ errorMessage = error.response.data.message;
3124
+ }
3125
+ else {
3126
+ errorMessage = error.message;
3127
+ }
3128
+ throw new OpenfortError(errorMessage, customErrorType);
3129
+ }
3130
+ };
3016
3131
 
3017
3132
  const validateConfiguration = (configuration, requiredKeys, prefix) => {
3018
3133
  const missingKeys = requiredKeys
@@ -4567,12 +4682,12 @@ class AuthManager {
4567
4682
  this.backendApiClients = backendApiClients;
4568
4683
  this.instanceManager = instanceManager;
4569
4684
  }
4570
- async initOAuth(provider, usePooling, options) {
4685
+ async initOAuth(provider, options) {
4571
4686
  const request = {
4572
4687
  oAuthInitRequest: {
4573
4688
  provider,
4574
4689
  options,
4575
- usePooling: usePooling || false,
4690
+ usePooling: options?.usePooling || false,
4576
4691
  },
4577
4692
  };
4578
4693
  const result = await this.backendApiClients.authenticationApi.initOAuth(request);
@@ -4584,26 +4699,6 @@ class AuthManager {
4584
4699
  key: result.data.key,
4585
4700
  };
4586
4701
  }
4587
- async initLinkOAuth(provider, playerToken, usePooling, options) {
4588
- const request = {
4589
- oAuthInitRequest: {
4590
- provider,
4591
- options,
4592
- usePooling: usePooling || false,
4593
- },
4594
- };
4595
- const result = await this.backendApiClients.authenticationApi.initLinkOAuth(request, {
4596
- // eslint-disable-next-line @typescript-eslint/naming-convention
4597
- headers: { 'x-player-token': playerToken },
4598
- });
4599
- if (isBrowser() && !options?.skipBrowserRedirect) {
4600
- window.location.assign(result.data.url);
4601
- }
4602
- return {
4603
- url: result.data.url,
4604
- key: result.data.key,
4605
- };
4606
- }
4607
4702
  async poolOAuth(key) {
4608
4703
  const request = {
4609
4704
  key,
@@ -4636,18 +4731,6 @@ class AuthManager {
4636
4731
  }
4637
4732
  throw new Error('Failed to pool OAuth, try again later');
4638
4733
  }
4639
- // @deprecated
4640
- async authenticateOAuth(provider, token, tokenType) {
4641
- const request = {
4642
- authenticateOAuthRequest: {
4643
- provider,
4644
- token,
4645
- tokenType,
4646
- },
4647
- };
4648
- const response = await this.backendApiClients.authenticationApi.authenticateOAuth(request);
4649
- return response.data;
4650
- }
4651
4734
  async authenticateThirdParty(provider, token, tokenType) {
4652
4735
  const request = {
4653
4736
  thirdPartyOAuthRequest: {
@@ -4656,8 +4739,10 @@ class AuthManager {
4656
4739
  tokenType,
4657
4740
  },
4658
4741
  };
4659
- const response = await this.backendApiClients.authenticationApi.thirdParty(request);
4660
- return response.data;
4742
+ return withOpenfortError(async () => {
4743
+ const response = await this.backendApiClients.authenticationApi.thirdParty(request);
4744
+ return response.data;
4745
+ }, OpenfortErrorType.AUTHENTICATION_ERROR);
4661
4746
  }
4662
4747
  async initSIWE(address) {
4663
4748
  const request = {
@@ -4681,8 +4766,10 @@ class AuthManager {
4681
4766
  connectorType,
4682
4767
  },
4683
4768
  };
4684
- const response = await this.backendApiClients.authenticationApi.authenticateSIWE(request);
4685
- return response.data;
4769
+ return withOpenfortError(async () => {
4770
+ const response = await this.backendApiClients.authenticationApi.authenticateSIWE(request);
4771
+ return response.data;
4772
+ }, OpenfortErrorType.AUTHENTICATION_ERROR);
4686
4773
  }
4687
4774
  async loginEmailPassword(email, password) {
4688
4775
  const request = {
@@ -4691,8 +4778,10 @@ class AuthManager {
4691
4778
  password,
4692
4779
  },
4693
4780
  };
4694
- const response = await this.backendApiClients.authenticationApi.loginEmailPassword(request);
4695
- return response.data;
4781
+ return withOpenfortError(async () => {
4782
+ const response = await this.backendApiClients.authenticationApi.loginEmailPassword(request);
4783
+ return response.data;
4784
+ }, OpenfortErrorType.AUTHENTICATION_ERROR);
4696
4785
  }
4697
4786
  async requestResetPassword(email, redirectUrl) {
4698
4787
  const verifier = base64URLEncode(crypto__namespace.randomBytes(32));
@@ -4713,25 +4802,23 @@ class AuthManager {
4713
4802
  await this.backendApiClients.authenticationApi.requestResetPassword(request);
4714
4803
  }
4715
4804
  async resetPassword(email, password, state) {
4716
- const pkceData = this.deviceCredentialsManager.getPKCEData();
4717
- if (!pkceData) {
4718
- throw new Error('No code verifier or state for PKCE');
4719
- }
4720
- if (state !== pkceData.state) {
4721
- throw new Error('Provided state does not match stored state');
4722
- }
4723
- const request = {
4724
- resetPasswordRequest: {
4725
- email,
4726
- password,
4727
- state,
4728
- challenge: {
4729
- codeVerifier: pkceData.verifier,
4730
- method: CodeChallengeMethodEnum.S256,
4805
+ return withOpenfortError(async () => {
4806
+ const pkceData = this.deviceCredentialsManager.getPKCEData();
4807
+ if (!pkceData) {
4808
+ throw new Error('No code verifier or state for PKCE');
4809
+ }
4810
+ const request = {
4811
+ resetPasswordRequest: {
4812
+ email,
4813
+ password,
4814
+ state,
4815
+ challenge: {
4816
+ codeVerifier: pkceData.verifier,
4817
+ },
4731
4818
  },
4732
- },
4733
- };
4734
- await this.backendApiClients.authenticationApi.resetPassword(request);
4819
+ };
4820
+ await this.backendApiClients.authenticationApi.resetPassword(request);
4821
+ }, OpenfortErrorType.AUTHENTICATION_ERROR);
4735
4822
  }
4736
4823
  async requestEmailVerification(email, redirectUrl) {
4737
4824
  const verifier = base64URLEncode(crypto__namespace.randomBytes(32));
@@ -4752,24 +4839,22 @@ class AuthManager {
4752
4839
  await this.backendApiClients.authenticationApi.requestEmailVerification(request);
4753
4840
  }
4754
4841
  async verifyEmail(email, state) {
4755
- const pkceData = this.deviceCredentialsManager.getPKCEData();
4756
- if (!pkceData) {
4757
- throw new Error('No code verifier or state for PKCE');
4758
- }
4759
- if (state !== pkceData.state) {
4760
- throw new Error('Provided state does not match stored state');
4761
- }
4762
- const request = {
4763
- verifyEmailRequest: {
4764
- email,
4765
- token: state,
4766
- challenge: {
4767
- codeVerifier: pkceData.verifier,
4768
- method: CodeChallengeMethodEnum.S256,
4842
+ return withOpenfortError(async () => {
4843
+ const pkceData = this.deviceCredentialsManager.getPKCEData();
4844
+ if (!pkceData) {
4845
+ throw new Error('No code verifier or state for PKCE');
4846
+ }
4847
+ const request = {
4848
+ verifyEmailRequest: {
4849
+ email,
4850
+ token: state,
4851
+ challenge: {
4852
+ codeVerifier: pkceData.verifier,
4853
+ },
4769
4854
  },
4770
- },
4771
- };
4772
- await this.backendApiClients.authenticationApi.verifyEmail(request);
4855
+ };
4856
+ await this.backendApiClients.authenticationApi.verifyEmail(request);
4857
+ }, OpenfortErrorType.AUTHENTICATION_ERROR);
4773
4858
  }
4774
4859
  async signupEmailPassword(email, password, name) {
4775
4860
  const request = {
@@ -4779,8 +4864,10 @@ class AuthManager {
4779
4864
  name,
4780
4865
  },
4781
4866
  };
4782
- const response = await this.backendApiClients.authenticationApi.signupEmailPassword(request);
4783
- return response.data;
4867
+ return withOpenfortError(async () => {
4868
+ const response = await this.backendApiClients.authenticationApi.signupEmailPassword(request);
4869
+ return response.data;
4870
+ }, OpenfortErrorType.USER_REGISTRATION_ERROR);
4784
4871
  }
4785
4872
  async validateCredentials(accessToken, refreshToken, jwk) {
4786
4873
  try {
@@ -4804,12 +4891,14 @@ class AuthManager {
4804
4891
  refreshToken,
4805
4892
  },
4806
4893
  };
4807
- const newToken = await this.backendApiClients.authenticationApi.refresh(request);
4808
- return {
4809
- player: newToken.data.player.id,
4810
- accessToken: newToken.data.token,
4811
- refreshToken: newToken.data.refreshToken,
4812
- };
4894
+ return withOpenfortError(async () => {
4895
+ const newToken = await this.backendApiClients.authenticationApi.refresh(request);
4896
+ return {
4897
+ player: newToken.data.player.id,
4898
+ accessToken: newToken.data.token,
4899
+ refreshToken: newToken.data.refreshToken,
4900
+ };
4901
+ }, OpenfortErrorType.REFRESH_TOKEN_ERROR);
4813
4902
  }
4814
4903
  throw error;
4815
4904
  }
@@ -4820,13 +4909,128 @@ class AuthManager {
4820
4909
  refreshToken,
4821
4910
  },
4822
4911
  };
4823
- await this.backendApiClients.authenticationApi.logout(request, {
4912
+ withOpenfortError(async () => {
4913
+ await this.backendApiClients.authenticationApi.logout(request, {
4914
+ headers: {
4915
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4916
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4917
+ 'x-player-token': accessToken,
4918
+ },
4919
+ });
4920
+ }, OpenfortErrorType.LOGOUT_ERROR);
4921
+ }
4922
+ async getUser(accessToken) {
4923
+ // TODO: Add storage of user info
4924
+ const response = await this.backendApiClients.authenticationApi.me({
4925
+ headers: {
4926
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4927
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4928
+ 'x-player-token': accessToken,
4929
+ },
4930
+ });
4931
+ return response.data;
4932
+ }
4933
+ async linkOAuth(provider, playerToken, options) {
4934
+ const request = {
4935
+ oAuthInitRequest: {
4936
+ provider,
4937
+ options,
4938
+ usePooling: options?.usePooling || false,
4939
+ },
4940
+ };
4941
+ const result = await this.backendApiClients.authenticationApi.linkOAuth(request, {
4942
+ headers: {
4943
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4944
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4945
+ 'x-player-token': playerToken,
4946
+ },
4947
+ });
4948
+ if (isBrowser() && !options?.skipBrowserRedirect) {
4949
+ window.location.assign(result.data.url);
4950
+ }
4951
+ return {
4952
+ url: result.data.url,
4953
+ key: result.data.key,
4954
+ };
4955
+ }
4956
+ async unlinkOAuth(provider, accessToken) {
4957
+ const request = {
4958
+ unlinkOAuthRequest: {
4959
+ provider,
4960
+ },
4961
+ };
4962
+ const authPlayerResponse = await this.backendApiClients.authenticationApi.unlinkOAuth(request, {
4963
+ headers: {
4964
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4965
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4966
+ 'x-player-token': accessToken,
4967
+ },
4968
+ });
4969
+ return authPlayerResponse.data;
4970
+ }
4971
+ async unlinkWallet(address, accessToken) {
4972
+ const request = {
4973
+ sIWERequest: {
4974
+ address,
4975
+ },
4976
+ };
4977
+ const authPlayerResponse = await this.backendApiClients.authenticationApi.unlinkSIWE(request, {
4824
4978
  headers: {
4825
4979
  authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4826
4980
  // eslint-disable-next-line @typescript-eslint/naming-convention
4827
4981
  'x-player-token': accessToken,
4828
4982
  },
4829
4983
  });
4984
+ return authPlayerResponse.data;
4985
+ }
4986
+ async linkWallet(signature, message, walletClientType, connectorType, accessToken) {
4987
+ const request = {
4988
+ sIWEAuthenticateRequest: {
4989
+ signature,
4990
+ message,
4991
+ walletClientType,
4992
+ connectorType,
4993
+ },
4994
+ };
4995
+ const authPlayerResponse = await this.backendApiClients.authenticationApi.linkSIWE(request, {
4996
+ headers: {
4997
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
4998
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4999
+ 'x-player-token': accessToken,
5000
+ },
5001
+ });
5002
+ return authPlayerResponse.data;
5003
+ }
5004
+ async unlinkEmail(email, accessToken) {
5005
+ const request = {
5006
+ unlinkEmailRequest: {
5007
+ email,
5008
+ },
5009
+ };
5010
+ const authPlayerResponse = await this.backendApiClients.authenticationApi.unlinkEmail(request, {
5011
+ headers: {
5012
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
5013
+ // eslint-disable-next-line @typescript-eslint/naming-convention
5014
+ 'x-player-token': accessToken,
5015
+ },
5016
+ });
5017
+ return authPlayerResponse.data;
5018
+ }
5019
+ async linkEmail(email, password, accessToken) {
5020
+ const request = {
5021
+ loginRequest: {
5022
+ email,
5023
+ password,
5024
+ },
5025
+ };
5026
+ const authPlayerResponse = await this.backendApiClients.authenticationApi.linkEmail(request, {
5027
+ headers: {
5028
+ authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
5029
+ // eslint-disable-next-line @typescript-eslint/naming-convention
5030
+ 'x-player-token': accessToken,
5031
+ },
5032
+ });
5033
+ return authPlayerResponse.data;
4830
5034
  }
4831
5035
  }
4832
5036
 
@@ -4870,7 +5074,7 @@ class InstanceManager {
4870
5074
  if (!this.authToken) {
4871
5075
  const token = this.secureStorage.get(authTokenStorageKey);
4872
5076
  if (token === null)
4873
- return null; // Early exit if no token is found
5077
+ return null;
4874
5078
  this.authToken = {
4875
5079
  token,
4876
5080
  thirdPartyProvider: this.secureStorage.get(thirdPartyProviderStorageKey),
@@ -5652,34 +5856,6 @@ class IframeManager {
5652
5856
  }
5653
5857
  }
5654
5858
 
5655
- class NotLoggedIn extends Error {
5656
- constructor(message) {
5657
- super(message);
5658
- this.name = 'NotLoggedIn';
5659
- Object.setPrototypeOf(this, NotLoggedIn.prototype);
5660
- }
5661
- }
5662
- class EmbeddedNotConfigured extends Error {
5663
- constructor(message) {
5664
- super(message);
5665
- this.name = 'EmbeddedNotConfigured';
5666
- Object.setPrototypeOf(this, EmbeddedNotConfigured.prototype);
5667
- }
5668
- }
5669
- class NoSignerConfigured extends Error {
5670
- constructor(message) {
5671
- super(message);
5672
- this.name = 'NoSignerConfigured';
5673
- Object.setPrototypeOf(this, NoSignerConfigured.prototype);
5674
- }
5675
- }
5676
- class NothingToSign extends Error {
5677
- constructor(message) {
5678
- super(message);
5679
- this.name = 'NothingToSign';
5680
- Object.setPrototypeOf(this, NothingToSign.prototype);
5681
- }
5682
- }
5683
5859
  class Openfort {
5684
5860
  signer;
5685
5861
  authManager;
@@ -5729,7 +5905,7 @@ class Openfort {
5729
5905
  announceProvider: true,
5730
5906
  }) {
5731
5907
  if (!(this.signer instanceof EmbeddedSigner)) {
5732
- throw new EmbeddedNotConfigured('Embedded signer must be configured to get Ethereum provider');
5908
+ throw new OpenfortError('Embedded signer must be configured to get Ethereum provider', OpenfortErrorType.NOT_LOGGED_IN_ERROR);
5733
5909
  }
5734
5910
  const address = this.instanceManager.getAccountAddress();
5735
5911
  const provider = new EvmProvider({
@@ -5794,18 +5970,18 @@ class Openfort {
5794
5970
  }
5795
5971
  newEmbeddedSigner(chainId, shieldAuthentication) {
5796
5972
  if (!this.credentialsProvided()) {
5797
- throw new NotLoggedIn('Must be logged in to configure embedded signer');
5973
+ throw new OpenfortError('Must be logged in to configure embedded signer', OpenfortErrorType.NOT_LOGGED_IN_ERROR);
5798
5974
  }
5799
5975
  const iframeConfiguration = {
5800
5976
  accessToken: this.instanceManager.getAccessToken()?.token ?? null,
5801
5977
  thirdPartyProvider: this.instanceManager.getAccessToken()?.thirdPartyProvider ?? null,
5802
5978
  thirdPartyTokenType: this.instanceManager.getAccessToken()?.thirdPartyTokenType ?? null,
5803
- chainId: chainId ?? null,
5979
+ chainId: !chainId ? Number(this.instanceManager.getChainID()) ?? null : chainId,
5804
5980
  recovery: shieldAuthentication ?? null,
5805
5981
  };
5806
5982
  return new EmbeddedSigner(this.iframeManager, this.instanceManager, iframeConfiguration);
5807
5983
  }
5808
- async loginWithEmailPassword(email, password) {
5984
+ async loginWithEmailPassword({ email, password, }) {
5809
5985
  this.instanceManager.removeAccessToken();
5810
5986
  this.instanceManager.removeRefreshToken();
5811
5987
  this.instanceManager.removePlayerID();
@@ -5817,11 +5993,11 @@ class Openfort {
5817
5993
  });
5818
5994
  return result;
5819
5995
  }
5820
- async signUpWithEmailPassword(email, password, name) {
5996
+ async signUpWithEmailPassword({ email, password, options, }) {
5821
5997
  this.instanceManager.removeAccessToken();
5822
5998
  this.instanceManager.removeRefreshToken();
5823
5999
  this.instanceManager.removePlayerID();
5824
- const result = await this.authManager.signupEmailPassword(email, password, name);
6000
+ const result = await this.authManager.signupEmailPassword(email, password, options?.data.name);
5825
6001
  this.storeCredentials({
5826
6002
  player: result.player.id,
5827
6003
  accessToken: result.token,
@@ -5829,45 +6005,32 @@ class Openfort {
5829
6005
  });
5830
6006
  return result;
5831
6007
  }
5832
- async requestEmailVerification(email, redirectUrl) {
6008
+ async requestEmailVerification({ email, redirectUrl }) {
5833
6009
  await this.authManager.requestEmailVerification(email, redirectUrl);
5834
6010
  }
5835
- async resetPassword(email, password, state) {
6011
+ async resetPassword({ email, password, state }) {
5836
6012
  await this.authManager.resetPassword(email, password, state);
5837
6013
  }
5838
- async requestResetPassword(email, redirectUrl) {
6014
+ async requestResetPassword({ email, redirectUrl }) {
5839
6015
  await this.authManager.requestResetPassword(email, redirectUrl);
5840
6016
  }
5841
- async verifyEmail(email, state) {
6017
+ async verifyEmail({ email, state }) {
5842
6018
  await this.authManager.verifyEmail(email, state);
5843
6019
  }
5844
- async initOAuth(provider, usePooling, options) {
5845
- const authResponse = await this.authManager.initOAuth(provider, usePooling, options);
6020
+ async initOAuth({ provider, options }) {
6021
+ const authResponse = await this.authManager.initOAuth(provider, options);
5846
6022
  return authResponse;
5847
6023
  }
5848
- async initLinkOAuth(provider, playerToken, usePooling, options) {
5849
- return await this.authManager.initLinkOAuth(provider, playerToken, usePooling, options);
6024
+ async initLinkOAuth({ provider, playerToken, options }) {
6025
+ return await this.authManager.linkOAuth(provider, playerToken, options);
5850
6026
  }
5851
6027
  async poolOAuth(key) {
5852
6028
  return await this.authManager.poolOAuth(key);
5853
6029
  }
5854
- // @deprecated
5855
- async authenticateWithOAuth(provider, token, tokenType) {
5856
- this.instanceManager.removeAccessToken();
5857
- this.instanceManager.removeRefreshToken();
5858
- this.instanceManager.removePlayerID();
5859
- const result = await this.authManager.authenticateOAuth(provider, token, tokenType);
5860
- this.storeCredentials({
5861
- player: result.player.id,
5862
- accessToken: result.token,
5863
- refreshToken: result.refreshToken,
5864
- });
5865
- return result;
5866
- }
5867
- async initSIWE(address) {
6030
+ async initSIWE({ address }) {
5868
6031
  return await this.authManager.initSIWE(address);
5869
6032
  }
5870
- async authenticateWithThirdPartyProvider(provider, token, tokenType) {
6033
+ async authenticateWithThirdPartyProvider({ provider, token, tokenType }) {
5871
6034
  const result = await this.authManager.authenticateThirdParty(provider, token, tokenType);
5872
6035
  this.instanceManager.setAccessToken({
5873
6036
  token,
@@ -5880,7 +6043,7 @@ class Openfort {
5880
6043
  }
5881
6044
  return result;
5882
6045
  }
5883
- async authenticateWithSIWE(signature, message, walletClientType, connectorType) {
6046
+ async authenticateWithSIWE({ signature, message, walletClientType, connectorType, }) {
5884
6047
  this.instanceManager.removeAccessToken();
5885
6048
  this.instanceManager.removeRefreshToken();
5886
6049
  this.instanceManager.removePlayerID();
@@ -5905,11 +6068,11 @@ class Openfort {
5905
6068
  let newSignature = signature;
5906
6069
  if (!newSignature) {
5907
6070
  if (!userOperationHash) {
5908
- throw new NothingToSign('No userOperationHash or signature provided');
6071
+ throw new OpenfortError('No userOperationHash or signature provided', OpenfortErrorType.OPERATION_NOT_SUPPORTED_ERROR);
5909
6072
  }
5910
6073
  await this.recoverSigner();
5911
6074
  if (!this.signer) {
5912
- throw new NoSignerConfigured('In order to sign a transaction intent, a signer must be configured');
6075
+ throw new OpenfortError('In order to sign a transaction intent, a signer must be configured', OpenfortErrorType.MISSING_SIGNER_ERROR);
5913
6076
  }
5914
6077
  if (this.signer.useCredentials()) {
5915
6078
  await this.validateAndRefreshToken();
@@ -5928,7 +6091,7 @@ class Openfort {
5928
6091
  async signMessage(message, options) {
5929
6092
  await this.recoverSigner();
5930
6093
  if (!this.signer) {
5931
- throw new NoSignerConfigured('No signer configured');
6094
+ throw new OpenfortError('In order to sign a message, an embedded signer must be configured', OpenfortErrorType.MISSING_EMBEDDED_SIGNER_ERROR);
5932
6095
  }
5933
6096
  if (this.signer.useCredentials()) {
5934
6097
  await this.validateAndRefreshToken();
@@ -5939,7 +6102,7 @@ class Openfort {
5939
6102
  async signTypedData(domain, types, value) {
5940
6103
  await this.recoverSigner();
5941
6104
  if (!this.signer) {
5942
- throw new NoSignerConfigured('No signer configured');
6105
+ throw new OpenfortError('In order to sign a message, an embedded signer must be configured', OpenfortErrorType.MISSING_EMBEDDED_SIGNER_ERROR);
5943
6106
  }
5944
6107
  if (this.signer.useCredentials()) {
5945
6108
  await this.validateAndRefreshToken();
@@ -5972,10 +6135,10 @@ class Openfort {
5972
6135
  async sendRegisterSessionRequest(sessionId, signature, optimistic) {
5973
6136
  await this.recoverSigner();
5974
6137
  if (!this.signer) {
5975
- throw new NoSignerConfigured('No signer configured nor signature provided');
6138
+ throw new OpenfortError('No signer configured nor signature provided', OpenfortErrorType.MISSING_SIGNER_ERROR);
5976
6139
  }
5977
6140
  if (this.signer.getSingerType() !== SignerType.SESSION) {
5978
- throw new NoSignerConfigured('Session signer must be configured to sign a session');
6141
+ throw new OpenfortError('Session signer must be configured to sign a session', OpenfortErrorType.MISSING_SESSION_SIGNER_ERROR);
5979
6142
  }
5980
6143
  const request = {
5981
6144
  id: sessionId,
@@ -6042,23 +6205,6 @@ class Openfort {
6042
6205
  && ((token.token && token.thirdPartyProvider && token.thirdPartyTokenType)
6043
6206
  || (token.token && refreshToken)));
6044
6207
  }
6045
- async isAuthenticated() {
6046
- if (!this.credentialsProvided()) {
6047
- return false;
6048
- }
6049
- if (!this.signer) {
6050
- const signerType = this.instanceManager.getSignerType();
6051
- if (signerType !== SignerType.EMBEDDED) {
6052
- return false;
6053
- }
6054
- const signer = this.newEmbeddedSigner();
6055
- return await signer.isLoaded();
6056
- }
6057
- if (this.signer.getSingerType() !== SignerType.EMBEDDED) {
6058
- return false;
6059
- }
6060
- return await this.signer.isLoaded();
6061
- }
6062
6208
  getAccessToken() {
6063
6209
  return this.instanceManager.getAccessToken()?.token ?? null;
6064
6210
  }
@@ -6071,6 +6217,14 @@ class Openfort {
6071
6217
  }
6072
6218
  return true;
6073
6219
  }
6220
+ async getUser() {
6221
+ await this.validateAndRefreshToken();
6222
+ const accessToken = this.instanceManager.getAccessToken();
6223
+ if (!accessToken) {
6224
+ throw new OpenfortError('No accessToken found', OpenfortErrorType.NOT_LOGGED_IN_ERROR);
6225
+ }
6226
+ return await this.authManager.getUser(accessToken.token);
6227
+ }
6074
6228
  async validateAndRefreshToken() {
6075
6229
  if (!this.credentialsProvided()) {
6076
6230
  return;