@avalabs/avacloud-waas-react 1.1.0 → 1.3.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/README.md +24 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +19 -2
- package/dist/index.mjs +19 -2
- package/package.json +12 -10
package/README.md
CHANGED
|
@@ -89,13 +89,36 @@ The main provider component that wraps your application and provides wallet cont
|
|
|
89
89
|
| Prop | Type | Description |
|
|
90
90
|
|------|------|-------------|
|
|
91
91
|
| `orgId` | `string` | **Required** - Your AvaCloud organization ID used to fetch wallet configuration |
|
|
92
|
-
| `env` | `'
|
|
92
|
+
| `env` | `'development' \| 'staging' \| 'production'` | Environment to use (default: `'production'`) |
|
|
93
93
|
| `chainId` | `number` | EVM chain ID (default: `43113` - Avalanche Fuji Testnet) |
|
|
94
94
|
| `darkMode` | `boolean` | Enable dark mode for UI components (default: `false`) |
|
|
95
|
+
| `authServiceUrl` | `string` | Optional custom auth service URL. Overrides default environment-based URLs |
|
|
95
96
|
| `onAuthSuccess` | `(user: Auth0User) => void` | Callback on successful authentication |
|
|
96
97
|
| `onAuthError` | `(error: Error) => void` | Callback on authentication error |
|
|
97
98
|
| `onWalletUpdate` | `(wallet: WalletInfo) => void` | Callback when wallet information updates |
|
|
98
99
|
|
|
100
|
+
#### Configuring Auth Service URL
|
|
101
|
+
|
|
102
|
+
The auth service URL can be configured in three ways (in order of precedence):
|
|
103
|
+
|
|
104
|
+
1. **Direct prop**: Pass `authServiceUrl` directly to the provider
|
|
105
|
+
```tsx
|
|
106
|
+
<AvaCloudWalletProvider
|
|
107
|
+
orgId="your-org-id"
|
|
108
|
+
authServiceUrl="https://your-custom-auth-service.com"
|
|
109
|
+
>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
2. **Environment variable**: Set `NEXT_PUBLIC_AUTH_SERVICE_URL` in your `.env` file
|
|
113
|
+
```bash
|
|
114
|
+
NEXT_PUBLIC_AUTH_SERVICE_URL=https://your-custom-auth-service.com
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
3. **Default URLs**: Falls back to environment-based defaults
|
|
118
|
+
- `development`: `http://localhost:3000`
|
|
119
|
+
- `staging`: `https://ac-auth-service-env-staging-ava-labs.vercel.app`
|
|
120
|
+
- `production`: `https://ac-auth-service.vercel.app`
|
|
121
|
+
|
|
99
122
|
### UI Components
|
|
100
123
|
|
|
101
124
|
- `LoginButton`: Button component for initiating the login flow
|
package/dist/index.d.mts
CHANGED
|
@@ -295,6 +295,7 @@ interface AvaCloudWalletProviderProps {
|
|
|
295
295
|
chainId?: number;
|
|
296
296
|
darkMode?: boolean;
|
|
297
297
|
env?: AvaCloudEnvironment;
|
|
298
|
+
authServiceUrl?: string;
|
|
298
299
|
onAuthSuccess?: (user: UserInfo) => void;
|
|
299
300
|
onAuthError?: (error: Error) => void;
|
|
300
301
|
onWalletUpdate?: (wallet: WalletInfo) => void;
|
|
@@ -322,7 +323,7 @@ interface AvaCloudWalletContextType {
|
|
|
322
323
|
environment: AvaCloudEnvironment;
|
|
323
324
|
}
|
|
324
325
|
|
|
325
|
-
declare function AvaCloudWalletProvider({ children, orgId, chainId, darkMode, env, onAuthSuccess, onAuthError, onWalletUpdate, }: AvaCloudWalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
326
|
+
declare function AvaCloudWalletProvider({ children, orgId, chainId, darkMode, env, authServiceUrl: customAuthServiceUrl, onAuthSuccess, onAuthError, onWalletUpdate, }: AvaCloudWalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
326
327
|
declare function useAvaCloudWallet(): AvaCloudWalletContextType;
|
|
327
328
|
|
|
328
329
|
interface ThemeContextType {
|
package/dist/index.d.ts
CHANGED
|
@@ -295,6 +295,7 @@ interface AvaCloudWalletProviderProps {
|
|
|
295
295
|
chainId?: number;
|
|
296
296
|
darkMode?: boolean;
|
|
297
297
|
env?: AvaCloudEnvironment;
|
|
298
|
+
authServiceUrl?: string;
|
|
298
299
|
onAuthSuccess?: (user: UserInfo) => void;
|
|
299
300
|
onAuthError?: (error: Error) => void;
|
|
300
301
|
onWalletUpdate?: (wallet: WalletInfo) => void;
|
|
@@ -322,7 +323,7 @@ interface AvaCloudWalletContextType {
|
|
|
322
323
|
environment: AvaCloudEnvironment;
|
|
323
324
|
}
|
|
324
325
|
|
|
325
|
-
declare function AvaCloudWalletProvider({ children, orgId, chainId, darkMode, env, onAuthSuccess, onAuthError, onWalletUpdate, }: AvaCloudWalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
326
|
+
declare function AvaCloudWalletProvider({ children, orgId, chainId, darkMode, env, authServiceUrl: customAuthServiceUrl, onAuthSuccess, onAuthError, onWalletUpdate, }: AvaCloudWalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
326
327
|
declare function useAvaCloudWallet(): AvaCloudWalletContextType;
|
|
327
328
|
|
|
328
329
|
interface ThemeContextType {
|
package/dist/index.js
CHANGED
|
@@ -1638,6 +1638,7 @@ function AvaCloudWalletProvider({
|
|
|
1638
1638
|
chainId = 43113,
|
|
1639
1639
|
darkMode = false,
|
|
1640
1640
|
env = "production",
|
|
1641
|
+
authServiceUrl: customAuthServiceUrl,
|
|
1641
1642
|
onAuthSuccess,
|
|
1642
1643
|
onAuthError,
|
|
1643
1644
|
onWalletUpdate
|
|
@@ -1646,7 +1647,23 @@ function AvaCloudWalletProvider({
|
|
|
1646
1647
|
(0, import_react9.useEffect)(() => {
|
|
1647
1648
|
setChainId(chainId);
|
|
1648
1649
|
}, [chainId, setChainId]);
|
|
1649
|
-
const
|
|
1650
|
+
const getAuthServiceUrl = () => {
|
|
1651
|
+
var _a;
|
|
1652
|
+
if (customAuthServiceUrl) {
|
|
1653
|
+
return customAuthServiceUrl;
|
|
1654
|
+
}
|
|
1655
|
+
if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.NEXT_PUBLIC_AUTH_SERVICE_URL)) {
|
|
1656
|
+
return process.env.NEXT_PUBLIC_AUTH_SERVICE_URL;
|
|
1657
|
+
}
|
|
1658
|
+
if (env === "development") {
|
|
1659
|
+
return "http://localhost:3000";
|
|
1660
|
+
} else if (env === "staging") {
|
|
1661
|
+
return "https://ac-auth-service-env-staging-ava-labs.vercel.app";
|
|
1662
|
+
} else {
|
|
1663
|
+
return "https://ac-auth-service.vercel.app";
|
|
1664
|
+
}
|
|
1665
|
+
};
|
|
1666
|
+
const authServiceUrl = getAuthServiceUrl();
|
|
1650
1667
|
const environment = env;
|
|
1651
1668
|
const [isAuthenticated, setIsAuthenticated] = (0, import_react9.useState)(false);
|
|
1652
1669
|
const [isCubistLoading, setIsCubistLoading] = (0, import_react9.useState)(true);
|
|
@@ -1711,7 +1728,7 @@ function AvaCloudWalletProvider({
|
|
|
1711
1728
|
}
|
|
1712
1729
|
try {
|
|
1713
1730
|
const resp = await import_cubesigner_sdk2.CubeSignerClient.createOidcSession(
|
|
1714
|
-
getCubistEnv(environment
|
|
1731
|
+
getCubistEnv(environment),
|
|
1715
1732
|
orgConfig.walletProviderOrgID,
|
|
1716
1733
|
accessToken,
|
|
1717
1734
|
["sign:*", "manage:*", "export:*"],
|
package/dist/index.mjs
CHANGED
|
@@ -1577,6 +1577,7 @@ function AvaCloudWalletProvider({
|
|
|
1577
1577
|
chainId = 43113,
|
|
1578
1578
|
darkMode = false,
|
|
1579
1579
|
env = "production",
|
|
1580
|
+
authServiceUrl: customAuthServiceUrl,
|
|
1580
1581
|
onAuthSuccess,
|
|
1581
1582
|
onAuthError,
|
|
1582
1583
|
onWalletUpdate
|
|
@@ -1585,7 +1586,23 @@ function AvaCloudWalletProvider({
|
|
|
1585
1586
|
useEffect5(() => {
|
|
1586
1587
|
setChainId(chainId);
|
|
1587
1588
|
}, [chainId, setChainId]);
|
|
1588
|
-
const
|
|
1589
|
+
const getAuthServiceUrl = () => {
|
|
1590
|
+
var _a;
|
|
1591
|
+
if (customAuthServiceUrl) {
|
|
1592
|
+
return customAuthServiceUrl;
|
|
1593
|
+
}
|
|
1594
|
+
if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.NEXT_PUBLIC_AUTH_SERVICE_URL)) {
|
|
1595
|
+
return process.env.NEXT_PUBLIC_AUTH_SERVICE_URL;
|
|
1596
|
+
}
|
|
1597
|
+
if (env === "development") {
|
|
1598
|
+
return "http://localhost:3000";
|
|
1599
|
+
} else if (env === "staging") {
|
|
1600
|
+
return "https://ac-auth-service-env-staging-ava-labs.vercel.app";
|
|
1601
|
+
} else {
|
|
1602
|
+
return "https://ac-auth-service.vercel.app";
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
const authServiceUrl = getAuthServiceUrl();
|
|
1589
1606
|
const environment = env;
|
|
1590
1607
|
const [isAuthenticated, setIsAuthenticated] = useState7(false);
|
|
1591
1608
|
const [isCubistLoading, setIsCubistLoading] = useState7(true);
|
|
@@ -1650,7 +1667,7 @@ function AvaCloudWalletProvider({
|
|
|
1650
1667
|
}
|
|
1651
1668
|
try {
|
|
1652
1669
|
const resp = await CubeSignerClient.createOidcSession(
|
|
1653
|
-
getCubistEnv(environment
|
|
1670
|
+
getCubistEnv(environment),
|
|
1654
1671
|
orgConfig.walletProviderOrgID,
|
|
1655
1672
|
accessToken,
|
|
1656
1673
|
["sign:*", "manage:*", "export:*"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avalabs/avacloud-waas-react",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "React SDK for AvaCloud Wallet as a Service",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -10,13 +10,6 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist/**"
|
|
12
12
|
],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "tsup src/index.ts --format esm,cjs --dts --external react && cp -r public/* dist/",
|
|
15
|
-
"dev": "tsup src/index.ts --format esm,cjs --watch --dts --external react",
|
|
16
|
-
"lint": "eslint \"src/**/*.ts*\"",
|
|
17
|
-
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
18
|
-
"prepublishOnly": "npm run build"
|
|
19
|
-
},
|
|
20
13
|
"devDependencies": {
|
|
21
14
|
"@iconify/types": "^2.0.0",
|
|
22
15
|
"@types/node": "^20.9.0",
|
|
@@ -60,5 +53,14 @@
|
|
|
60
53
|
"url": "https://github.com/ava-labs/avacloud-auth-react/issues"
|
|
61
54
|
},
|
|
62
55
|
"homepage": "https://github.com/ava-labs/avacloud-auth-react#readme",
|
|
63
|
-
"author": "Ava Labs, Inc."
|
|
64
|
-
|
|
56
|
+
"author": "Ava Labs, Inc.",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --external react && cp -r public/* dist/",
|
|
62
|
+
"dev": "tsup src/index.ts --format esm,cjs --watch --dts --external react",
|
|
63
|
+
"lint": "eslint \"src/**/*.ts*\"",
|
|
64
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
65
|
+
}
|
|
66
|
+
}
|