@avalabs/avacloud-waas-react 1.4.0 → 1.4.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.js CHANGED
@@ -96,7 +96,20 @@ function getDerivationPath(vm, accountIndex) {
96
96
  // src/hooks/usePenpalAuth.ts
97
97
  var import_react = require("react");
98
98
  var import_penpal = require("penpal");
99
- var import_waas_common = require("@avacloud/waas-common");
99
+
100
+ // ../avacloud-waas-common/dist/constants/storage.js
101
+ var OIDC_TOKEN_KEY = "avacloud-auth-oidc-token";
102
+ var AUTH_TOKENS_KEY = "auth_tokens";
103
+ var AUTH0_STORAGE_KEYS = {
104
+ IS_AUTHENTICATED: "auth0.is.authenticated",
105
+ ACCESS_TOKEN: "auth0.access_token",
106
+ ID_TOKEN: "auth0.id_token",
107
+ EXPIRES_AT: "auth0.expires_at"
108
+ };
109
+ var CUBIST_USER_ID_KEY = "cubist_user_id";
110
+ var ORG_CONFIG_CACHE_KEY = "avacloud-org-config-cache";
111
+
112
+ // src/hooks/usePenpalAuth.ts
100
113
  function usePenpalAuth({
101
114
  authServiceUrl,
102
115
  orgId,
@@ -121,7 +134,7 @@ function usePenpalAuth({
121
134
  if (orgId && onOrgConfigUpdate && !hasLoadedCacheRef.current) {
122
135
  hasLoadedCacheRef.current = true;
123
136
  try {
124
- const cachedConfigKey = `${import_waas_common.ORG_CONFIG_CACHE_KEY}-${orgId}-${environment}`;
137
+ const cachedConfigKey = `${ORG_CONFIG_CACHE_KEY}-${orgId}-${environment}`;
125
138
  const cachedConfigJson = localStorage.getItem(cachedConfigKey);
126
139
  if (cachedConfigJson) {
127
140
  const cachedConfig = JSON.parse(cachedConfigJson);
@@ -161,7 +174,7 @@ function usePenpalAuth({
161
174
  onOrgConfigUpdate == null ? void 0 : onOrgConfigUpdate(status.orgConfig);
162
175
  if (orgId) {
163
176
  try {
164
- const cachedConfigKey = `${import_waas_common.ORG_CONFIG_CACHE_KEY}-${orgId}-${environment}`;
177
+ const cachedConfigKey = `${ORG_CONFIG_CACHE_KEY}-${orgId}-${environment}`;
165
178
  const configWithTimestamp = {
166
179
  ...status.orgConfig,
167
180
  _timestamp: Date.now()
@@ -336,13 +349,13 @@ function usePenpalAuth({
336
349
  await authService.logout();
337
350
  setIsAuthenticated(false);
338
351
  setUser(null);
339
- localStorage.removeItem(import_waas_common.AUTH_TOKENS_KEY);
340
- localStorage.removeItem(import_waas_common.AUTH0_STORAGE_KEYS.IS_AUTHENTICATED);
341
- localStorage.removeItem(import_waas_common.AUTH0_STORAGE_KEYS.ACCESS_TOKEN);
342
- localStorage.removeItem(import_waas_common.AUTH0_STORAGE_KEYS.ID_TOKEN);
343
- localStorage.removeItem(import_waas_common.AUTH0_STORAGE_KEYS.EXPIRES_AT);
344
- localStorage.removeItem(import_waas_common.CUBIST_USER_ID_KEY);
345
- sessionStorage.removeItem(import_waas_common.OIDC_TOKEN_KEY);
352
+ localStorage.removeItem(AUTH_TOKENS_KEY);
353
+ localStorage.removeItem(AUTH0_STORAGE_KEYS.IS_AUTHENTICATED);
354
+ localStorage.removeItem(AUTH0_STORAGE_KEYS.ACCESS_TOKEN);
355
+ localStorage.removeItem(AUTH0_STORAGE_KEYS.ID_TOKEN);
356
+ localStorage.removeItem(AUTH0_STORAGE_KEYS.EXPIRES_AT);
357
+ localStorage.removeItem(CUBIST_USER_ID_KEY);
358
+ sessionStorage.removeItem(OIDC_TOKEN_KEY);
346
359
  } catch (error) {
347
360
  onAuthError == null ? void 0 : onAuthError(error instanceof Error ? error : new Error("Logout failed"));
348
361
  throw error;
package/dist/index.mjs CHANGED
@@ -34,7 +34,20 @@ function getDerivationPath(vm, accountIndex) {
34
34
  // src/hooks/usePenpalAuth.ts
35
35
  import { useCallback, useEffect, useRef, useState } from "react";
36
36
  import { connect, WindowMessenger } from "penpal";
37
- import { AUTH_TOKENS_KEY, OIDC_TOKEN_KEY, AUTH0_STORAGE_KEYS, CUBIST_USER_ID_KEY, ORG_CONFIG_CACHE_KEY } from "@avacloud/waas-common";
37
+
38
+ // ../avacloud-waas-common/dist/constants/storage.js
39
+ var OIDC_TOKEN_KEY = "avacloud-auth-oidc-token";
40
+ var AUTH_TOKENS_KEY = "auth_tokens";
41
+ var AUTH0_STORAGE_KEYS = {
42
+ IS_AUTHENTICATED: "auth0.is.authenticated",
43
+ ACCESS_TOKEN: "auth0.access_token",
44
+ ID_TOKEN: "auth0.id_token",
45
+ EXPIRES_AT: "auth0.expires_at"
46
+ };
47
+ var CUBIST_USER_ID_KEY = "cubist_user_id";
48
+ var ORG_CONFIG_CACHE_KEY = "avacloud-org-config-cache";
49
+
50
+ // src/hooks/usePenpalAuth.ts
38
51
  function usePenpalAuth({
39
52
  authServiceUrl,
40
53
  orgId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avalabs/avacloud-waas-react",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "React SDK for AvaCloud Wallet as a Service",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -21,7 +21,8 @@
21
21
  "eslint-plugin-react-hooks": "^4.6.0",
22
22
  "react": "^18.2.0",
23
23
  "tsup": "^8.0.1",
24
- "typescript": "^5.2.2"
24
+ "typescript": "^5.2.2",
25
+ "@avacloud/waas-common": "0.1.0"
25
26
  },
26
27
  "peerDependencies": {
27
28
  "react": "^17.0.0 || ^18.0.0",
@@ -38,8 +39,7 @@
38
39
  "qrcode.react": "^3.1.0",
39
40
  "viem": "2.31.2",
40
41
  "ethers": "^5.7.2",
41
- "axios": "^1.6.0",
42
- "@avacloud/waas-common": "0.1.0"
42
+ "axios": "^1.6.0"
43
43
  },
44
44
  "keywords": [
45
45
  "avalanche",