@uipath/uipath-typescript 1.1.0 → 1.1.1

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.umd.js CHANGED
@@ -3888,6 +3888,15 @@
3888
3888
  */
3889
3889
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
3890
3890
 
3891
+ /**
3892
+ * Session storage keys used by the auth module
3893
+ */
3894
+ const AUTH_STORAGE_KEYS = {
3895
+ TOKEN_PREFIX: 'uipath_sdk_user_token-',
3896
+ OAUTH_CONTEXT: 'uipath_sdk_oauth_context',
3897
+ CODE_VERIFIER: 'uipath_sdk_code_verifier',
3898
+ };
3899
+
3891
3900
  // Type guard to check if config has OAuth credentials
3892
3901
  function hasOAuthConfig(config) {
3893
3902
  return Boolean(config.clientId && config.redirectUri && config.scope);
@@ -4211,7 +4220,6 @@
4211
4220
  this.executionContext = executionContext;
4212
4221
  this.config = config;
4213
4222
  this.isOAuth = isOAuth;
4214
- this.STORAGE_KEY_PREFIX = 'uipath_sdk_user_token-';
4215
4223
  this.refreshPromise = null;
4216
4224
  }
4217
4225
  /**
@@ -4265,7 +4273,7 @@
4265
4273
  * Gets the storage key for this TokenManager instance
4266
4274
  */
4267
4275
  _getStorageKey() {
4268
- return `${this.STORAGE_KEY_PREFIX}${this.config.clientId}`;
4276
+ return `${AUTH_STORAGE_KEYS.TOKEN_PREFIX}${this.config.clientId}`;
4269
4277
  }
4270
4278
  /**
4271
4279
  * Loads token from session storage if available
@@ -4627,7 +4635,7 @@
4627
4635
  return false;
4628
4636
  const urlParams = new URLSearchParams(window.location.search);
4629
4637
  const code = urlParams.get('code');
4630
- const hasCodeVerifier = sessionStorage.getItem('uipath_sdk_code_verifier');
4638
+ const hasCodeVerifier = sessionStorage.getItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
4631
4639
  return !!(code && hasCodeVerifier);
4632
4640
  }
4633
4641
  /**
@@ -4638,7 +4646,7 @@
4638
4646
  return null;
4639
4647
  }
4640
4648
  try {
4641
- const stored = sessionStorage.getItem('uipath_sdk_oauth_context');
4649
+ const stored = sessionStorage.getItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
4642
4650
  if (!stored) {
4643
4651
  return null;
4644
4652
  }
@@ -4646,13 +4654,13 @@
4646
4654
  // Validate required fields
4647
4655
  if (!context.codeVerifier || !context.clientId || !context.redirectUri ||
4648
4656
  !context.baseUrl || !context.orgName) {
4649
- sessionStorage.removeItem('uipath_sdk_oauth_context');
4657
+ sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
4650
4658
  return null;
4651
4659
  }
4652
4660
  return context;
4653
4661
  }
4654
4662
  catch (error) {
4655
- sessionStorage.removeItem('uipath_sdk_oauth_context');
4663
+ sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
4656
4664
  console.warn('Failed to parse stored OAuth context from session storage', error);
4657
4665
  return null;
4658
4666
  }
@@ -4727,7 +4735,7 @@
4727
4735
  throw new Error('OAuth flow is only supported in browser environments');
4728
4736
  }
4729
4737
  // Check if we have a stored code verifier indicating we're in an OAuth flow
4730
- const codeVerifier = sessionStorage.getItem('uipath_sdk_code_verifier');
4738
+ const codeVerifier = sessionStorage.getItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
4731
4739
  const isInOAuthFlow = codeVerifier !== null;
4732
4740
  const urlParams = new URLSearchParams(window.location.search);
4733
4741
  const code = urlParams.get('code');
@@ -4736,7 +4744,7 @@
4736
4744
  // We're expecting a callback - validate parameters
4737
4745
  if (!code) {
4738
4746
  // Clear stored state on error
4739
- sessionStorage.removeItem('uipath_sdk_code_verifier');
4747
+ sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
4740
4748
  throw new Error('Authorization code missing in OAuth callback');
4741
4749
  }
4742
4750
  // Validate the authorization code format before using it
@@ -4744,7 +4752,7 @@
4744
4752
  const codePattern = /^[A-Za-z0-9\-._~+/]+=*$/;
4745
4753
  if (!codePattern.test(code)) {
4746
4754
  // Clear stored state on error
4747
- sessionStorage.removeItem('uipath_sdk_code_verifier');
4755
+ sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
4748
4756
  throw new Error('Invalid authorization code format');
4749
4757
  }
4750
4758
  // Authorization code is present and validated, so we can exchange it for a token.
@@ -4785,6 +4793,24 @@
4785
4793
  hasValidToken() {
4786
4794
  return this.tokenManager.hasValidToken();
4787
4795
  }
4796
+ /**
4797
+ * Clears all authentication state including tokens and stored OAuth context.
4798
+ */
4799
+ logout() {
4800
+ this.tokenManager.clearToken();
4801
+ // Clear OAuth context from session storage. These are normally cleaned up in _handleOAuthCallback after a successful
4802
+ // token exchange, but if a user calls logout() while an OAuth flow is
4803
+ // mid-redirect (before callback completes), they'd be left behind.
4804
+ if (isBrowser) {
4805
+ try {
4806
+ sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
4807
+ sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
4808
+ }
4809
+ catch (error) {
4810
+ console.warn('Failed to clear OAuth context from session storage', error);
4811
+ }
4812
+ }
4813
+ }
4788
4814
  /**
4789
4815
  * Get the current token
4790
4816
  */
@@ -4916,8 +4942,8 @@
4916
4942
  tenantName: this.config.tenantName,
4917
4943
  scope
4918
4944
  };
4919
- sessionStorage.setItem('uipath_sdk_oauth_context', JSON.stringify(oauthContext));
4920
- sessionStorage.setItem('uipath_sdk_code_verifier', codeVerifier);
4945
+ sessionStorage.setItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT, JSON.stringify(oauthContext));
4946
+ sessionStorage.setItem(AUTH_STORAGE_KEYS.CODE_VERIFIER, codeVerifier);
4921
4947
  const authUrl = this.getAuthorizationUrl({
4922
4948
  clientId,
4923
4949
  redirectUri,
@@ -4927,7 +4953,7 @@
4927
4953
  window.location.href = authUrl;
4928
4954
  }
4929
4955
  async _handleOAuthCallback(code, clientId, redirectUri) {
4930
- const codeVerifier = sessionStorage.getItem('uipath_sdk_code_verifier');
4956
+ const codeVerifier = sessionStorage.getItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
4931
4957
  if (!codeVerifier) {
4932
4958
  throw new Error('Code verifier not found in session storage. Authentication may have been interrupted.');
4933
4959
  }
@@ -4938,8 +4964,8 @@
4938
4964
  codeVerifier
4939
4965
  });
4940
4966
  // Clear OAuth context and code verifier after successful token exchange
4941
- sessionStorage.removeItem('uipath_sdk_oauth_context');
4942
- sessionStorage.removeItem('uipath_sdk_code_verifier');
4967
+ sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
4968
+ sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
4943
4969
  const url = new URL(window.location.href);
4944
4970
  url.searchParams.delete('code');
4945
4971
  url.searchParams.delete('state');
@@ -8720,7 +8746,7 @@
8720
8746
  // Connection string placeholder that will be replaced during build
8721
8747
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
8722
8748
  // SDK Version placeholder
8723
- const SDK_VERSION = "1.1.0";
8749
+ const SDK_VERSION = "1.1.1";
8724
8750
  const VERSION = "Version";
8725
8751
  const SERVICE = "Service";
8726
8752
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -9205,6 +9231,18 @@
9205
9231
  getToken() {
9206
9232
  return __classPrivateFieldGet(this, _UiPath_authService, "f").getToken();
9207
9233
  }
9234
+ /**
9235
+ * Logout from the SDK, clearing all authentication state.
9236
+ * After calling this method, the user will need to re-initialize to authenticate again.
9237
+ */
9238
+ logout() {
9239
+ // Secret-based auth has no session to end — skip silently
9240
+ if (hasSecretConfig(__classPrivateFieldGet(this, _UiPath_config, "f"))) {
9241
+ return;
9242
+ }
9243
+ __classPrivateFieldGet(this, _UiPath_authService, "f").logout();
9244
+ __classPrivateFieldSet(this, _UiPath_initialized, false, "f");
9245
+ }
9208
9246
  };
9209
9247
  _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap();
9210
9248
 
@@ -1734,7 +1734,7 @@ class BpmnHelpers {
1734
1734
  // Connection string placeholder that will be replaced during build
1735
1735
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
1736
1736
  // SDK Version placeholder
1737
- const SDK_VERSION = "1.1.0";
1737
+ const SDK_VERSION = "1.1.1";
1738
1738
  const VERSION = "Version";
1739
1739
  const SERVICE = "Service";
1740
1740
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -1732,7 +1732,7 @@ class BpmnHelpers {
1732
1732
  // Connection string placeholder that will be replaced during build
1733
1733
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
1734
1734
  // SDK Version placeholder
1735
- const SDK_VERSION = "1.1.0";
1735
+ const SDK_VERSION = "1.1.1";
1736
1736
  const VERSION = "Version";
1737
1737
  const SERVICE = "Service";
1738
1738
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -1714,7 +1714,7 @@ const PROCESS_ENDPOINTS = {
1714
1714
  // Connection string placeholder that will be replaced during build
1715
1715
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
1716
1716
  // SDK Version placeholder
1717
- const SDK_VERSION = "1.1.0";
1717
+ const SDK_VERSION = "1.1.1";
1718
1718
  const VERSION = "Version";
1719
1719
  const SERVICE = "Service";
1720
1720
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -1712,7 +1712,7 @@ const PROCESS_ENDPOINTS = {
1712
1712
  // Connection string placeholder that will be replaced during build
1713
1713
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
1714
1714
  // SDK Version placeholder
1715
- const SDK_VERSION = "1.1.0";
1715
+ const SDK_VERSION = "1.1.1";
1716
1716
  const VERSION = "Version";
1717
1717
  const SERVICE = "Service";
1718
1718
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -1678,7 +1678,7 @@ const QueueMap = {
1678
1678
  // Connection string placeholder that will be replaced during build
1679
1679
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
1680
1680
  // SDK Version placeholder
1681
- const SDK_VERSION = "1.1.0";
1681
+ const SDK_VERSION = "1.1.1";
1682
1682
  const VERSION = "Version";
1683
1683
  const SERVICE = "Service";
1684
1684
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -1676,7 +1676,7 @@ const QueueMap = {
1676
1676
  // Connection string placeholder that will be replaced during build
1677
1677
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
1678
1678
  // SDK Version placeholder
1679
- const SDK_VERSION = "1.1.0";
1679
+ const SDK_VERSION = "1.1.1";
1680
1680
  const VERSION = "Version";
1681
1681
  const SERVICE = "Service";
1682
1682
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -1904,7 +1904,7 @@ const TASK_ENDPOINTS = {
1904
1904
  // Connection string placeholder that will be replaced during build
1905
1905
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
1906
1906
  // SDK Version placeholder
1907
- const SDK_VERSION = "1.1.0";
1907
+ const SDK_VERSION = "1.1.1";
1908
1908
  const VERSION = "Version";
1909
1909
  const SERVICE = "Service";
1910
1910
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -1902,7 +1902,7 @@ const TASK_ENDPOINTS = {
1902
1902
  // Connection string placeholder that will be replaced during build
1903
1903
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
1904
1904
  // SDK Version placeholder
1905
- const SDK_VERSION = "1.1.0";
1905
+ const SDK_VERSION = "1.1.1";
1906
1906
  const VERSION = "Version";
1907
1907
  const SERVICE = "Service";
1908
1908
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/uipath-typescript",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "UiPath TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "keywords": [