@avalabs/avacloud-waas-react 1.0.7 → 1.0.8
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/README.md +1 -1
- package/dist/index.d.mts +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.js +10 -7
- package/dist/index.mjs +10 -7
- package/package.json +1 -1
- package/dist/public/avacloud.png +0 -0
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ The main provider component that wraps your application and provides wallet cont
|
|
|
89
89
|
| Prop | Type | Description |
|
|
90
90
|
|------|------|-------------|
|
|
91
91
|
| `orgId` | `string` | Required AvaCloud organization ID |
|
|
92
|
-
| `
|
|
92
|
+
| `env` | `'local' \| 'development' \| 'prod'` | (Optional) Environment to use. Defaults to 'prod'. |
|
|
93
93
|
| `chainId` | `number` | (Optional) EVM chain ID to use (defaults to Avalanche Fuji Testnet - 43113) |
|
|
94
94
|
| `darkMode` | `boolean` | (Optional) Whether to use dark mode for UI components |
|
|
95
95
|
| `onAuthSuccess` | `(user: Auth0User) => void` | (Optional) Callback called when authentication is successful |
|
package/dist/index.d.mts
CHANGED
|
@@ -289,11 +289,10 @@ type AuthMessage = IframeReadyMessage | CheckAuthStatusMessage | AuthStatusMessa
|
|
|
289
289
|
*/
|
|
290
290
|
interface AvaCloudWalletProviderProps {
|
|
291
291
|
children: React.ReactNode;
|
|
292
|
-
authServiceUrl?: string;
|
|
293
292
|
orgId: string;
|
|
294
293
|
chainId?: number;
|
|
295
294
|
darkMode?: boolean;
|
|
296
|
-
|
|
295
|
+
env?: AvaCloudEnvironment;
|
|
297
296
|
onAuthSuccess?: (user: UserInfo) => void;
|
|
298
297
|
onAuthError?: (error: Error) => void;
|
|
299
298
|
onWalletUpdate?: (wallet: WalletInfo) => void;
|
|
@@ -321,7 +320,7 @@ interface AvaCloudWalletContextType {
|
|
|
321
320
|
environment: AvaCloudEnvironment;
|
|
322
321
|
}
|
|
323
322
|
|
|
324
|
-
declare function AvaCloudWalletProvider({ children,
|
|
323
|
+
declare function AvaCloudWalletProvider({ children, orgId, chainId, darkMode, env, onAuthSuccess, onAuthError, onWalletUpdate, }: AvaCloudWalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
325
324
|
declare function useAvaCloudWallet(): AvaCloudWalletContextType;
|
|
326
325
|
|
|
327
326
|
interface ThemeContextType {
|
|
@@ -433,9 +432,7 @@ declare function useAuth(): {
|
|
|
433
432
|
|
|
434
433
|
interface NextData {
|
|
435
434
|
props: {
|
|
436
|
-
pageProps:
|
|
437
|
-
NEXT_PUBLIC_CUBIST_ORG_ID?: string;
|
|
438
|
-
};
|
|
435
|
+
pageProps: Record<string, unknown>;
|
|
439
436
|
};
|
|
440
437
|
}
|
|
441
438
|
declare global {
|
package/dist/index.d.ts
CHANGED
|
@@ -289,11 +289,10 @@ type AuthMessage = IframeReadyMessage | CheckAuthStatusMessage | AuthStatusMessa
|
|
|
289
289
|
*/
|
|
290
290
|
interface AvaCloudWalletProviderProps {
|
|
291
291
|
children: React.ReactNode;
|
|
292
|
-
authServiceUrl?: string;
|
|
293
292
|
orgId: string;
|
|
294
293
|
chainId?: number;
|
|
295
294
|
darkMode?: boolean;
|
|
296
|
-
|
|
295
|
+
env?: AvaCloudEnvironment;
|
|
297
296
|
onAuthSuccess?: (user: UserInfo) => void;
|
|
298
297
|
onAuthError?: (error: Error) => void;
|
|
299
298
|
onWalletUpdate?: (wallet: WalletInfo) => void;
|
|
@@ -321,7 +320,7 @@ interface AvaCloudWalletContextType {
|
|
|
321
320
|
environment: AvaCloudEnvironment;
|
|
322
321
|
}
|
|
323
322
|
|
|
324
|
-
declare function AvaCloudWalletProvider({ children,
|
|
323
|
+
declare function AvaCloudWalletProvider({ children, orgId, chainId, darkMode, env, onAuthSuccess, onAuthError, onWalletUpdate, }: AvaCloudWalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
325
324
|
declare function useAvaCloudWallet(): AvaCloudWalletContextType;
|
|
326
325
|
|
|
327
326
|
interface ThemeContextType {
|
|
@@ -433,9 +432,7 @@ declare function useAuth(): {
|
|
|
433
432
|
|
|
434
433
|
interface NextData {
|
|
435
434
|
props: {
|
|
436
|
-
pageProps:
|
|
437
|
-
NEXT_PUBLIC_CUBIST_ORG_ID?: string;
|
|
438
|
-
};
|
|
435
|
+
pageProps: Record<string, unknown>;
|
|
439
436
|
};
|
|
440
437
|
}
|
|
441
438
|
declare global {
|
package/dist/index.js
CHANGED
|
@@ -1645,7 +1645,9 @@ var queryClient = new import_react_query2.QueryClient({
|
|
|
1645
1645
|
}
|
|
1646
1646
|
}
|
|
1647
1647
|
});
|
|
1648
|
-
|
|
1648
|
+
function getCubistEnv(environment) {
|
|
1649
|
+
return environment === "production" ? import_cubesigner_sdk.envs.prod : import_cubesigner_sdk.envs.gamma;
|
|
1650
|
+
}
|
|
1649
1651
|
function ViemProviderWrapper({ children, chainId }) {
|
|
1650
1652
|
const { data: blockchain } = useBlockchain(chainId.toString());
|
|
1651
1653
|
if (!(blockchain == null ? void 0 : blockchain.rpcUrl)) {
|
|
@@ -1663,15 +1665,16 @@ function ViemProviderWrapper({ children, chainId }) {
|
|
|
1663
1665
|
}
|
|
1664
1666
|
function AvaCloudWalletProvider({
|
|
1665
1667
|
children,
|
|
1666
|
-
authServiceUrl = "https://ac-auth-service.vercel.app/",
|
|
1667
1668
|
orgId,
|
|
1668
1669
|
chainId = 43113,
|
|
1669
1670
|
darkMode = false,
|
|
1670
|
-
|
|
1671
|
+
env = "production",
|
|
1671
1672
|
onAuthSuccess,
|
|
1672
1673
|
onAuthError,
|
|
1673
1674
|
onWalletUpdate
|
|
1674
1675
|
}) {
|
|
1676
|
+
const authServiceUrl = env === "development" ? "http://localhost:3000" : env === "staging" ? "https://ac-auth-service-env-staging-ava-labs.vercel.app" : "https://ac-auth-service.vercel.app";
|
|
1677
|
+
const environment = env;
|
|
1675
1678
|
const [isAuthenticated, setIsAuthenticated] = (0, import_react9.useState)(false);
|
|
1676
1679
|
const [isCubistLoading, setIsCubistLoading] = (0, import_react9.useState)(true);
|
|
1677
1680
|
const [isLoading, setIsLoading] = (0, import_react9.useState)(true);
|
|
@@ -1746,7 +1749,7 @@ function AvaCloudWalletProvider({
|
|
|
1746
1749
|
try {
|
|
1747
1750
|
console.log(`[loginWithCubist] Attempting CubeSignerClient.createOidcSession for Org: ${orgConfig.walletProviderOrgID}`);
|
|
1748
1751
|
const resp = await import_cubesigner_sdk2.CubeSignerClient.createOidcSession(
|
|
1749
|
-
|
|
1752
|
+
getCubistEnv(environment),
|
|
1750
1753
|
orgConfig.walletProviderOrgID,
|
|
1751
1754
|
accessToken,
|
|
1752
1755
|
["sign:*", "manage:*", "export:*"],
|
|
@@ -1808,7 +1811,7 @@ function AvaCloudWalletProvider({
|
|
|
1808
1811
|
console.log("[loginWithCubist] Setting isCubistLoading to false.");
|
|
1809
1812
|
setIsCubistLoading(false);
|
|
1810
1813
|
}
|
|
1811
|
-
}, [wallet, onWalletUpdate, onAuthError, getWalletInfo, orgConfig]);
|
|
1814
|
+
}, [wallet, onWalletUpdate, onAuthError, getWalletInfo, orgConfig, environment]);
|
|
1812
1815
|
const { sendMessage } = usePostMessage({
|
|
1813
1816
|
authServiceUrl,
|
|
1814
1817
|
orgId,
|
|
@@ -1916,14 +1919,14 @@ function AvaCloudWalletProvider({
|
|
|
1916
1919
|
localStorage.removeItem(AUTH0_STORAGE_KEYS.EXPIRES_AT);
|
|
1917
1920
|
localStorage.removeItem(CUBIST_USER_ID_KEY);
|
|
1918
1921
|
if (orgId) {
|
|
1919
|
-
const cachedConfigKey = `${ORG_CONFIG_CACHE_KEY}-${orgId}-${
|
|
1922
|
+
const cachedConfigKey = `${ORG_CONFIG_CACHE_KEY}-${orgId}-${env}`;
|
|
1920
1923
|
localStorage.removeItem(cachedConfigKey);
|
|
1921
1924
|
}
|
|
1922
1925
|
sessionStorage.removeItem(OIDC_TOKEN_KEY);
|
|
1923
1926
|
setCubistClient(null);
|
|
1924
1927
|
setCubistError(null);
|
|
1925
1928
|
setPendingOidcToken(null);
|
|
1926
|
-
}, [sendMessage, orgId,
|
|
1929
|
+
}, [sendMessage, orgId, env]);
|
|
1927
1930
|
const addAccount = (0, import_react9.useCallback)(async (accountIndex) => {
|
|
1928
1931
|
console.log("[addAccount] Called with accountIndex:", accountIndex);
|
|
1929
1932
|
if (!isAuthenticated || !user || !wallet.mnemonicId) {
|
package/dist/index.mjs
CHANGED
|
@@ -1599,7 +1599,9 @@ var queryClient = new QueryClient({
|
|
|
1599
1599
|
}
|
|
1600
1600
|
}
|
|
1601
1601
|
});
|
|
1602
|
-
|
|
1602
|
+
function getCubistEnv(environment) {
|
|
1603
|
+
return environment === "production" ? envs.prod : envs.gamma;
|
|
1604
|
+
}
|
|
1603
1605
|
function ViemProviderWrapper({ children, chainId }) {
|
|
1604
1606
|
const { data: blockchain } = useBlockchain(chainId.toString());
|
|
1605
1607
|
if (!(blockchain == null ? void 0 : blockchain.rpcUrl)) {
|
|
@@ -1617,15 +1619,16 @@ function ViemProviderWrapper({ children, chainId }) {
|
|
|
1617
1619
|
}
|
|
1618
1620
|
function AvaCloudWalletProvider({
|
|
1619
1621
|
children,
|
|
1620
|
-
authServiceUrl = "https://ac-auth-service.vercel.app/",
|
|
1621
1622
|
orgId,
|
|
1622
1623
|
chainId = 43113,
|
|
1623
1624
|
darkMode = false,
|
|
1624
|
-
|
|
1625
|
+
env = "production",
|
|
1625
1626
|
onAuthSuccess,
|
|
1626
1627
|
onAuthError,
|
|
1627
1628
|
onWalletUpdate
|
|
1628
1629
|
}) {
|
|
1630
|
+
const authServiceUrl = env === "development" ? "http://localhost:3000" : env === "staging" ? "https://ac-auth-service-env-staging-ava-labs.vercel.app" : "https://ac-auth-service.vercel.app";
|
|
1631
|
+
const environment = env;
|
|
1629
1632
|
const [isAuthenticated, setIsAuthenticated] = useState7(false);
|
|
1630
1633
|
const [isCubistLoading, setIsCubistLoading] = useState7(true);
|
|
1631
1634
|
const [isLoading, setIsLoading] = useState7(true);
|
|
@@ -1700,7 +1703,7 @@ function AvaCloudWalletProvider({
|
|
|
1700
1703
|
try {
|
|
1701
1704
|
console.log(`[loginWithCubist] Attempting CubeSignerClient.createOidcSession for Org: ${orgConfig.walletProviderOrgID}`);
|
|
1702
1705
|
const resp = await CubeSignerClient.createOidcSession(
|
|
1703
|
-
|
|
1706
|
+
getCubistEnv(environment),
|
|
1704
1707
|
orgConfig.walletProviderOrgID,
|
|
1705
1708
|
accessToken,
|
|
1706
1709
|
["sign:*", "manage:*", "export:*"],
|
|
@@ -1762,7 +1765,7 @@ function AvaCloudWalletProvider({
|
|
|
1762
1765
|
console.log("[loginWithCubist] Setting isCubistLoading to false.");
|
|
1763
1766
|
setIsCubistLoading(false);
|
|
1764
1767
|
}
|
|
1765
|
-
}, [wallet, onWalletUpdate, onAuthError, getWalletInfo, orgConfig]);
|
|
1768
|
+
}, [wallet, onWalletUpdate, onAuthError, getWalletInfo, orgConfig, environment]);
|
|
1766
1769
|
const { sendMessage } = usePostMessage({
|
|
1767
1770
|
authServiceUrl,
|
|
1768
1771
|
orgId,
|
|
@@ -1870,14 +1873,14 @@ function AvaCloudWalletProvider({
|
|
|
1870
1873
|
localStorage.removeItem(AUTH0_STORAGE_KEYS.EXPIRES_AT);
|
|
1871
1874
|
localStorage.removeItem(CUBIST_USER_ID_KEY);
|
|
1872
1875
|
if (orgId) {
|
|
1873
|
-
const cachedConfigKey = `${ORG_CONFIG_CACHE_KEY}-${orgId}-${
|
|
1876
|
+
const cachedConfigKey = `${ORG_CONFIG_CACHE_KEY}-${orgId}-${env}`;
|
|
1874
1877
|
localStorage.removeItem(cachedConfigKey);
|
|
1875
1878
|
}
|
|
1876
1879
|
sessionStorage.removeItem(OIDC_TOKEN_KEY);
|
|
1877
1880
|
setCubistClient(null);
|
|
1878
1881
|
setCubistError(null);
|
|
1879
1882
|
setPendingOidcToken(null);
|
|
1880
|
-
}, [sendMessage, orgId,
|
|
1883
|
+
}, [sendMessage, orgId, env]);
|
|
1881
1884
|
const addAccount = useCallback5(async (accountIndex) => {
|
|
1882
1885
|
console.log("[addAccount] Called with accountIndex:", accountIndex);
|
|
1883
1886
|
if (!isAuthenticated || !user || !wallet.mnemonicId) {
|
package/package.json
CHANGED
package/dist/public/avacloud.png
DELETED
|
Binary file
|