zh-web-sdk 2.16.1 → 3.0.0
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/CHANGELOG.md +23 -0
- package/README.md +239 -34
- package/dist/__mocks__/@zerohash-sdk/sdk-react-mock.d.ts +1 -0
- package/dist/__tests__/explicit-env.test.d.ts +1 -0
- package/dist/__tests__/message-router-origins.test.d.ts +1 -0
- package/dist/__tests__/sdk-version-attribution.test.d.ts +1 -0
- package/dist/__tests__/styles.test.d.ts +1 -0
- package/dist/api/convert-token.d.ts +12 -0
- package/dist/iframe-container/AppContainer.d.ts +13 -3
- package/dist/iframe-container/__tests__/get-new-sdk-env.test.d.ts +1 -0
- package/dist/iframe-container/hooks/use-style-updates.d.ts +1 -0
- package/dist/index.d.ts +30 -2
- package/dist/index.js +56 -54
- package/dist/index.js.map +4 -4
- package/dist/new-sdk/env.d.ts +35 -0
- package/dist/redux/__tests__/set-theme.test.d.ts +1 -0
- package/dist/redux/__tests__/set-use-new-sdk.test.d.ts +1 -0
- package/dist/redux/actions/index.d.ts +13 -1
- package/dist/redux/reducers/constants.d.ts +2 -0
- package/dist/redux/reducers/index.d.ts +3 -1
- package/dist/redux/reducers/new-sdk-flags.d.ts +11 -0
- package/dist/redux/reducers/theme.d.ts +10 -0
- package/dist/redux/store/index.d.ts +3 -1
- package/dist/styles.d.ts +7 -0
- package/dist/types.d.ts +42 -0
- package/dist/utils/test-utils.d.ts +48 -48
- package/dist/version.d.ts +1 -0
- package/package.json +32 -13
- package/.eslintrc.js +0 -12
- package/.github/CHANGELOG_TEMPLATE.md +0 -73
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -10
- package/.github/backup/publish-tag.yaml +0 -14
- package/.github/workflows/build.yaml +0 -13
- package/.github/workflows/pr.yaml +0 -14
- package/.github/workflows/publish.yaml +0 -13
- package/.github/workflows/security.yml +0 -15
- package/.github/workflows/tag.yaml +0 -14
- package/RELEASING.md +0 -39
- package/jest.config.js +0 -8
- package/jest.setup.js +0 -24
- package/scripts/build.js +0 -34
- package/scripts/zip.js +0 -49
- package/src/__tests__/jwt-auth-detection.test.ts +0 -96
- package/src/api/convert-token.ts +0 -23
- package/src/constants.ts +0 -2
- package/src/hooks/__tests__/use-window-size.test.tsx +0 -26
- package/src/hooks/use-window-size.ts +0 -19
- package/src/iframe-container/AppContainer.tsx +0 -495
- package/src/iframe-container/__tests__/AppContainer.test.tsx +0 -300
- package/src/iframe-container/hooks/__tests__/use-style-updates.test.ts +0 -430
- package/src/iframe-container/hooks/use-style-updates.ts +0 -82
- package/src/index.tsx +0 -645
- package/src/redux/actions/index.ts +0 -27
- package/src/redux/reducers/constants.ts +0 -10
- package/src/redux/reducers/crypto-account-link-payouts.ts +0 -60
- package/src/redux/reducers/crypto-account-link.ts +0 -60
- package/src/redux/reducers/crypto-buy.ts +0 -75
- package/src/redux/reducers/crypto-sell.ts +0 -64
- package/src/redux/reducers/crypto-withdrawals.ts +0 -64
- package/src/redux/reducers/fiat-account-link.ts +0 -60
- package/src/redux/reducers/fiat-deposits.ts +0 -64
- package/src/redux/reducers/fiat-withdrawals.ts +0 -64
- package/src/redux/reducers/fund.ts +0 -75
- package/src/redux/reducers/index.ts +0 -35
- package/src/redux/reducers/onboarding.ts +0 -74
- package/src/redux/reducers/pay.ts +0 -64
- package/src/redux/reducers/payouts.ts +0 -64
- package/src/redux/reducers/profile.ts +0 -63
- package/src/redux/store/index.ts +0 -10
- package/src/styles.ts +0 -108
- package/src/types.ts +0 -578
- package/src/utils/auth-to-fund-mapper.ts +0 -174
- package/src/utils/strings.ts +0 -19
- package/src/utils/test-utils.tsx +0 -36
- package/src/utils/world-app-utils.ts +0 -8
- package/src/utils.ts +0 -27
- package/tsconfig.json +0 -26
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,29 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
## [3.0.0] - 2026-05-21
|
|
10
|
+
|
|
11
|
+
Major version bump signaling the rollout of the next-generation SDK rendering path. The integrator-facing API is unchanged for cert/prod consumers; the only public-type change is the narrowing of `env` (see Changed).
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- **Breaking (TypeScript surface):** Narrowed the public `Environment` type from `'dev' | 'cert' | 'prod'` to `'cert' | 'prod'`. The `'dev'` value targeted Zero Hash internal CDNs and was never intended for integrator use; it has been moved to a separate `InternalEnvironment` type used by our QA tooling. Integrators on cert or prod do not need to make any changes.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- Opt-in next-generation rendering for ZeroHash apps, delivering improved performance and UX across Crypto Buy/Sell, Onboarding, Fiat Deposits/Withdrawals, Crypto Withdrawals, Fund, Pay, Payouts, Profile, and Account Link flows [#97]
|
|
18
|
+
- Rolled out gradually and controlled server-side — no integration changes required
|
|
19
|
+
- Flows not yet migrated continue to render in the existing iframe
|
|
20
|
+
- SDK version is now attached to embedded-app logs to make support investigations faster [#97]
|
|
21
|
+
- New `theme` option on the SDK constructor (`'light' | 'dark' | 'auto'`, defaults to `'light'`) and `sdk.setTheme({ theme })` method to control the appearance of next-generation flows; legacy iframe and Connect Auth (Fund) appearance is unchanged [#97]
|
|
22
|
+
- New `env` option on the SDK constructor (`'cert' | 'prod'`) for explicit environment selection. When set, it takes precedence over hostname inference from `zeroHashAppsURL` and is the recommended way to target a specific deployment going forward [#97]
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
- Expanded the URL-based environment-inference allowlist to cover the full set of Zero Hash hostnames used by integrators (cert/dev, US/EU, `0hash.com`/`zerohash.com`/`zerohash.eu`/`sandbox.connect.xyz`/`gating.0hash.com`). Previously, only `web-sdk.cert.0hash.com`, `web-sdk.sandbox.connect.xyz`, and `web-sdk.dev.0hash.com` were recognized — every other Zero Hash host silently fell back to `prod`, causing cert sessions to load the production CDN. Integrators on hosts outside this list should still pass the new `env` option explicitly [#97]
|
|
26
|
+
- Removed the wrong-theme flash when opening a next-generation flow with `theme: 'dark'` or `'auto'`. The wrapper modal no longer paints a white background before the inner SDK renders, and it now becomes visible as soon as the SDK component reports it has loaded instead of waiting on a multi-second fallback. Light-mode and legacy iframe flows are unchanged [#97]
|
|
27
|
+
- Fixed Fund's Connect Auth flow targeting the wrong Connect API on non-prod hosts. The Auth env was previously inferred via a substring check against `zeroHashAppsURL` and silently fell back to `production` for dev hosts (e.g. `web-sdk.dev.0hash.com`) and partner-hosted URLs, causing the Fund modal to call `api.connect.xyz` instead of `api.sandbox.connect.xyz`. The Auth env is now resolved from the same source as the new-SDK components — explicit `env` from the SDK constructor when provided, otherwise the hostname allowlist [#97]
|
|
28
|
+
|
|
29
|
+
### Security
|
|
30
|
+
- Hardened the Connect Auth issuer check to use a strict hostname allowlist, replacing the previous substring match [#97]
|
|
31
|
+
|
|
9
32
|
## [2.16.0] - 2026-02-20
|
|
10
33
|
|
|
11
34
|
### Added
|
package/README.md
CHANGED
|
@@ -1,56 +1,261 @@
|
|
|
1
|
-
# ZeroHash
|
|
1
|
+
# ZeroHash Web SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The ZeroHash Web SDK enables platforms to integrate ZeroHash financial services on web and mobile applications. Access various UI flows including Fund, Onboarding, Crypto Buy, Crypto Sell, Crypto Withdrawals, Fiat Deposits, and Fiat Withdrawals through a single SDK instance.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install zh-web-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
or
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add zh-web-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### React Example
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import React, { useMemo } from 'react';
|
|
23
|
+
import ZeroHashSDK, { AppIdentifier } from 'zh-web-sdk';
|
|
24
|
+
|
|
25
|
+
const App = () => {
|
|
26
|
+
// Create SDK instance once - not on every render
|
|
27
|
+
const sdk = useMemo(() => new ZeroHashSDK({
|
|
28
|
+
zeroHashAppsURL: "https://web-sdk.zerohash.com",
|
|
29
|
+
env: "prod",
|
|
30
|
+
theme: "light"
|
|
31
|
+
}), []);
|
|
32
|
+
|
|
33
|
+
const handleOpenFund = () => {
|
|
34
|
+
sdk.openModal({
|
|
35
|
+
appIdentifier: AppIdentifier.FUND,
|
|
36
|
+
jwt: "<JWT_TOKEN_HERE>"
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<button onClick={handleOpenFund}>
|
|
42
|
+
Fund Account
|
|
43
|
+
</button>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default App;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Vanilla JavaScript Example
|
|
6
51
|
|
|
7
52
|
```javascript
|
|
8
|
-
import { AppIdentifier } from 'zh-web-sdk'
|
|
53
|
+
import ZeroHashSDK, { AppIdentifier } from 'zh-web-sdk';
|
|
9
54
|
|
|
10
|
-
|
|
11
|
-
sdk
|
|
55
|
+
// Initialize SDK once
|
|
56
|
+
const sdk = new ZeroHashSDK({
|
|
57
|
+
zeroHashAppsURL: "https://web-sdk.zerohash.com",
|
|
58
|
+
env: "prod",
|
|
59
|
+
theme: "light"
|
|
60
|
+
});
|
|
12
61
|
|
|
13
|
-
|
|
62
|
+
// Open a modal
|
|
63
|
+
sdk.openModal({
|
|
64
|
+
appIdentifier: AppIdentifier.FUND,
|
|
65
|
+
jwt: "<JWT_TOKEN_HERE>"
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Close when done
|
|
69
|
+
sdk.closeModal(AppIdentifier.FUND);
|
|
70
|
+
```
|
|
14
71
|
|
|
15
|
-
|
|
72
|
+
## Environments
|
|
16
73
|
|
|
17
|
-
|
|
74
|
+
Pass `env` to select the deployment the SDK should target. Accepted values are `'cert'` and `'prod'`. When set, `env` is the source of truth for environment resolution and overrides hostname-based inference from `zeroHashAppsURL`.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
const sdk = new ZeroHashSDK({
|
|
78
|
+
zeroHashAppsURL: "https://web-sdk.cert.zerohash.com",
|
|
79
|
+
env: "cert"
|
|
80
|
+
});
|
|
18
81
|
```
|
|
19
82
|
|
|
20
|
-
|
|
83
|
+
Default URLs per environment:
|
|
84
|
+
|
|
85
|
+
- **Production**: `https://web-sdk.zerohash.com`
|
|
86
|
+
- **Certification/Sandbox**: `https://web-sdk.cert.zerohash.com`
|
|
87
|
+
|
|
88
|
+
If `env` is omitted, the SDK falls back to inferring the environment from the hostname of `zeroHashAppsURL`. Hosts outside the recognized Zero Hash list resolve to `'prod'` — pass `env` explicitly when integrating from a partner-hosted domain.
|
|
89
|
+
|
|
90
|
+
## Available App Identifiers
|
|
21
91
|
|
|
22
|
-
|
|
92
|
+
The SDK supports the following application flows:
|
|
93
|
+
|
|
94
|
+
| AppIdentifier | Description |
|
|
95
|
+
|--------------|-------------|
|
|
96
|
+
| `FUND` | Fund account operations |
|
|
97
|
+
| `ONBOARDING` | User onboarding and KYC |
|
|
98
|
+
| `CRYPTO_BUY` | Purchase cryptocurrency |
|
|
99
|
+
| `CRYPTO_SELL` | Sell cryptocurrency |
|
|
100
|
+
| `CRYPTO_WITHDRAWALS` | Withdraw crypto to external wallets |
|
|
101
|
+
| `FIAT_DEPOSITS` | Deposit fiat currency |
|
|
102
|
+
| `FIAT_WITHDRAWALS` | Withdraw fiat currency |
|
|
103
|
+
| `PROFILE` | User profile management |
|
|
104
|
+
| `CRYPTO_ACCOUNT_LINK` | Link cryptocurrency accounts |
|
|
105
|
+
| `CRYPTO_ACCOUNT_LINK_PAYOUTS` | Link crypto accounts for payouts |
|
|
106
|
+
| `FIAT_ACCOUNT_LINK` | Link bank accounts |
|
|
107
|
+
| `PAYOUTS` | Payout operations |
|
|
108
|
+
| `PAY` | Payment operations |
|
|
109
|
+
|
|
110
|
+
## API Reference
|
|
111
|
+
|
|
112
|
+
### Constructor
|
|
23
113
|
|
|
24
114
|
```typescript
|
|
25
|
-
|
|
26
|
-
|
|
115
|
+
new ZeroHashSDK(config: IInitializeParameters)
|
|
116
|
+
```
|
|
27
117
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
118
|
+
**Configuration Options:**
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
{
|
|
122
|
+
zeroHashAppsURL: string; // Required: Base URL for ZeroHash apps
|
|
123
|
+
env?: 'cert' | 'prod'; // Optional: Explicit environment selection
|
|
124
|
+
theme?: 'light' | 'dark' | 'auto'; // Optional: Appearance for next-gen flows (defaults to 'light')
|
|
125
|
+
rootQuerySelector?: string; // Optional: Custom DOM element selector
|
|
126
|
+
|
|
127
|
+
// Optional: Set JWTs during initialization
|
|
128
|
+
cryptoBuyJWT?: string;
|
|
129
|
+
cryptoSellJWT?: string;
|
|
130
|
+
cryptoWithdrawalsJWT?: string;
|
|
131
|
+
fiatDepositsJWT?: string;
|
|
132
|
+
fiatWithdrawalsJWT?: string;
|
|
133
|
+
userOnboardingJWT?: string;
|
|
134
|
+
fundJWT?: string;
|
|
135
|
+
profileJWT?: string;
|
|
136
|
+
cryptoAccountLinkJWT?: string;
|
|
137
|
+
cryptoAccountLinkPayoutsJWT?: string;
|
|
138
|
+
fiatAccountLinkJWT?: string;
|
|
139
|
+
payoutsJWT?: string;
|
|
140
|
+
payJWT?: string;
|
|
38
141
|
}
|
|
142
|
+
```
|
|
39
143
|
|
|
40
|
-
|
|
144
|
+
### Methods
|
|
145
|
+
|
|
146
|
+
#### `openModal(params)`
|
|
147
|
+
|
|
148
|
+
Opens a modal for the specified app.
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
sdk.openModal({
|
|
152
|
+
appIdentifier: AppIdentifier.FUND,
|
|
153
|
+
jwt?: string, // Optional: Set or update JWT
|
|
154
|
+
filters?: Filters, // Optional: Filter options
|
|
155
|
+
navigate?: Page // Optional: Navigation parameters
|
|
156
|
+
});
|
|
41
157
|
```
|
|
42
158
|
|
|
43
|
-
|
|
159
|
+
#### `closeModal(appIdentifier)`
|
|
160
|
+
|
|
161
|
+
Closes the modal for the specified app.
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
sdk.closeModal(AppIdentifier.FUND);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### `setJWT(params)`
|
|
168
|
+
|
|
169
|
+
Set or update the JWT for a specific app.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
sdk.setJWT({
|
|
173
|
+
jwt: "<JWT_TOKEN>",
|
|
174
|
+
appIdentifier: AppIdentifier.FUND
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
#### `isModalOpen(appIdentifier)`
|
|
179
|
+
|
|
180
|
+
Check if a modal is currently open.
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
const isOpen = sdk.isModalOpen(AppIdentifier.FUND);
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### `setFilters(params)`
|
|
187
|
+
|
|
188
|
+
Set filters for a specific app.
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
sdk.setFilters({
|
|
192
|
+
appIdentifier: AppIdentifier.FUND,
|
|
193
|
+
filters: {
|
|
194
|
+
getAssets: {
|
|
195
|
+
stablecoin: true
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### `setTheme(params)`
|
|
202
|
+
|
|
203
|
+
Update the theme forwarded to the next-generation `@zerohash-sdk/*-react` flows and Connect Auth (Fund). Has no effect on the legacy iframe.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
sdk.setTheme({ theme: "dark" }); // 'light' | 'dark' | 'auto'
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## JWT Authentication
|
|
210
|
+
|
|
211
|
+
**⚠️ Security Note**: JWTs should be obtained from your backend server using the ZeroHash API with your API key. Never expose your API key or perform JWT exchanges on the client side.
|
|
212
|
+
|
|
213
|
+
### Two approaches for providing JWTs:
|
|
214
|
+
|
|
215
|
+
**1. During initialization:**
|
|
216
|
+
```typescript
|
|
217
|
+
const sdk = new ZeroHashSDK({
|
|
218
|
+
zeroHashAppsURL: "https://web-sdk.zerohash.com",
|
|
219
|
+
env: "prod",
|
|
220
|
+
fundJWT: jwt
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**2. When opening a modal:**
|
|
225
|
+
```typescript
|
|
226
|
+
sdk.openModal({
|
|
227
|
+
appIdentifier: AppIdentifier.FUND,
|
|
228
|
+
jwt: jwt
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**3. Update JWT later:**
|
|
233
|
+
```typescript
|
|
234
|
+
sdk.setJWT({
|
|
235
|
+
jwt: newJwt,
|
|
236
|
+
appIdentifier: AppIdentifier.FUND
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## TypeScript Support
|
|
241
|
+
|
|
242
|
+
The SDK is written in TypeScript and includes type definitions. Import types as needed:
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
import ZeroHashSDK, {
|
|
246
|
+
AppIdentifier,
|
|
247
|
+
IInitializeParameters,
|
|
248
|
+
IOpenModalParameters,
|
|
249
|
+
Filters
|
|
250
|
+
} from 'zh-web-sdk';
|
|
251
|
+
```
|
|
44
252
|
|
|
45
|
-
|
|
253
|
+
## Documentation & Support
|
|
46
254
|
|
|
47
|
-
- **
|
|
48
|
-
- **
|
|
49
|
-
- **
|
|
255
|
+
- **Full Documentation**: [ZeroHash SDK Documentation](https://docs.zerohash.com/reference/sdk-overview)
|
|
256
|
+
- **Changelog**: [ZeroHash Documentation Changelog](https://docs.zerohash.com/reference/changelog)
|
|
257
|
+
- **Mobile Usage**: See the [SDK Overview](https://docs.zerohash.com/reference/sdk-overview) for mobile implementation details
|
|
50
258
|
|
|
51
|
-
##
|
|
52
|
-
[zerohash Documentation Changelog](https://docs.zerohash.com/reference/changelog)
|
|
259
|
+
## License
|
|
53
260
|
|
|
54
|
-
|
|
55
|
-
For more details on how to use it on mobile apps, please refer to our full documentation:
|
|
56
|
-
[zerohash SDK Documentation](https://docs.zerohash.com/reference/sdk-overview).
|
|
261
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../index";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
export interface FundWithdrawalDetails {
|
|
2
|
+
quoted_asset?: string;
|
|
3
|
+
withdrawal_request_amount?: string | number;
|
|
4
|
+
external_account_id?: string;
|
|
5
|
+
}
|
|
1
6
|
export interface JWTPayload {
|
|
2
7
|
auth_embedded?: boolean;
|
|
3
8
|
reference_id?: string;
|
|
9
|
+
payload?: {
|
|
10
|
+
use_new_sdk?: boolean;
|
|
11
|
+
withdrawal_details?: FundWithdrawalDetails;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
4
14
|
[key: string]: unknown;
|
|
5
15
|
}
|
|
6
16
|
export declare function decodeJWT(token: string): JWTPayload | null;
|
|
17
|
+
export declare const ALLOWED_CONNECT_ISSUER_HOSTNAMES: readonly string[];
|
|
18
|
+
export declare function isConnectIssuer(iss: unknown): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppIdentifier, AuthSettings, Filters, Page } from "../types";
|
|
1
|
+
import { AppIdentifier, AuthSettings, Environment, InternalEnvironment, Filters, Page, Theme } from "../types";
|
|
2
2
|
interface AppContainerProps {
|
|
3
3
|
isAppActive?: boolean;
|
|
4
4
|
isAppLoaded?: boolean;
|
|
@@ -9,10 +9,18 @@ interface AppContainerProps {
|
|
|
9
9
|
navigate?: Page;
|
|
10
10
|
useAuth?: boolean;
|
|
11
11
|
authSettings?: AuthSettings;
|
|
12
|
+
useNewSdk?: boolean;
|
|
13
|
+
theme?: Theme;
|
|
14
|
+
/**
|
|
15
|
+
* Explicit environment forwarded by `ZeroHashSDK`. When provided, it is
|
|
16
|
+
* preferred over hostname inference from `zeroHashAppURL`.
|
|
17
|
+
*/
|
|
18
|
+
env?: Environment | InternalEnvironment;
|
|
12
19
|
}
|
|
13
|
-
declare const _default: import("react-redux").ConnectedComponent<({ isAppActive, isAppLoaded, jwt, zeroHashAppURL, appIdentifier, navigate, useAuth, authSettings, }: AppContainerProps) => import("react/jsx-runtime").JSX.Element, {
|
|
14
|
-
zeroHashAppURL: string;
|
|
20
|
+
declare const _default: import("react-redux").ConnectedComponent<({ isAppActive, isAppLoaded, jwt, zeroHashAppURL, appIdentifier, navigate, useAuth, authSettings, useNewSdk, theme, env: explicitEnv, }: AppContainerProps) => import("react/jsx-runtime").JSX.Element, {
|
|
15
21
|
appIdentifier: AppIdentifier;
|
|
22
|
+
zeroHashAppURL: string;
|
|
23
|
+
env?: (Environment | InternalEnvironment) | undefined;
|
|
16
24
|
isAppActive?: boolean | undefined;
|
|
17
25
|
isAppLoaded?: boolean | undefined;
|
|
18
26
|
jwt?: string | undefined;
|
|
@@ -20,6 +28,8 @@ declare const _default: import("react-redux").ConnectedComponent<({ isAppActive,
|
|
|
20
28
|
navigate?: Page | undefined;
|
|
21
29
|
useAuth?: boolean | undefined;
|
|
22
30
|
authSettings?: AuthSettings | undefined;
|
|
31
|
+
useNewSdk?: boolean | undefined;
|
|
32
|
+
theme?: Theme | undefined;
|
|
23
33
|
context?: import("react-redux/es/components/Context").ReactReduxContextInstance | undefined;
|
|
24
34
|
store?: import("redux").Store | undefined;
|
|
25
35
|
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import { AppIdentifier, IInitializeParameters, IOpenModalParameters, IOpenOnboardingModalParameters, ISetFiltersParameters, ISetJWTParameters, ISetNavigateParameters, ISetUserOnboardingJWTParameters, IZeroHashSDK } from "./types";
|
|
1
|
+
import { AppIdentifier, IInitializeParameters, IOpenModalParameters, IOpenOnboardingModalParameters, ISetFiltersParameters, ISetJWTParameters, ISetNavigateParameters, ISetThemeParameters, ISetUserOnboardingJWTParameters, IZeroHashSDK } from "./types";
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
/**
|
|
5
|
+
* Version of zh-web-sdk loaded on the host page. Embedded
|
|
6
|
+
* `@zerohash-sdk/*` web components read this and forward it to their
|
|
7
|
+
* iframe Faro logs as `zh_web_sdk_version`. Absent when the new SDKs
|
|
8
|
+
* are embedded directly without zh-web-sdk.
|
|
9
|
+
*/
|
|
10
|
+
__ZH_WEB_SDK_VERSION__?: string;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
2
13
|
export declare class ZeroHashSDK implements IZeroHashSDK {
|
|
3
14
|
private rootQuerySelector;
|
|
4
15
|
private onboardingInitialized;
|
|
@@ -12,7 +23,7 @@ export declare class ZeroHashSDK implements IZeroHashSDK {
|
|
|
12
23
|
*
|
|
13
24
|
* For more information, see {@code IInitializeParameters}
|
|
14
25
|
*/
|
|
15
|
-
constructor({ zeroHashOnboardingURL, rootQuerySelector, userOnboardingJWT, cryptoWithdrawalsJWT, fiatDepositsJWT, fiatWithdrawalsJWT, cryptoBuyJWT, cryptoSellJWT, fundJWT, profileJWT, cryptoAccountLinkJWT, cryptoAccountLinkPayoutsJWT, payoutsJWT, payJWT, fiatAccountLinkJWT, zeroHashAppsURL, }: IInitializeParameters);
|
|
26
|
+
constructor({ zeroHashOnboardingURL, rootQuerySelector, userOnboardingJWT, cryptoWithdrawalsJWT, fiatDepositsJWT, fiatWithdrawalsJWT, cryptoBuyJWT, cryptoSellJWT, fundJWT, profileJWT, cryptoAccountLinkJWT, cryptoAccountLinkPayoutsJWT, payoutsJWT, payJWT, fiatAccountLinkJWT, zeroHashAppsURL, env, theme, }: IInitializeParameters);
|
|
16
27
|
/**
|
|
17
28
|
* setJWT sets the JWT for the appIdentifier provided.
|
|
18
29
|
* The JWT should be the JWT provided by ZeroHash via the platform
|
|
@@ -31,6 +42,12 @@ export declare class ZeroHashSDK implements IZeroHashSDK {
|
|
|
31
42
|
* specific to Onboarding and is used to navigate to a specific page within the App.
|
|
32
43
|
*/
|
|
33
44
|
setNavigate({ appIdentifier, navigate }: ISetNavigateParameters): void;
|
|
45
|
+
/**
|
|
46
|
+
* setTheme updates the theme forwarded to new @zerohash-sdk/*-react
|
|
47
|
+
* components. Accepts 'light', 'dark', or 'auto'. Has no effect on the
|
|
48
|
+
* legacy iframe path or the Connect Auth (Fund) component.
|
|
49
|
+
*/
|
|
50
|
+
setTheme({ theme }: ISetThemeParameters): void;
|
|
34
51
|
/**
|
|
35
52
|
* setUserOnboardingJWT sets the JWT to be whatever value is provided.
|
|
36
53
|
* The JWT should be the UserJWT provided by ZeroHash via the platform
|
|
@@ -61,6 +78,11 @@ export declare class ZeroHashSDK implements IZeroHashSDK {
|
|
|
61
78
|
closeModal(appIdentifier: AppIdentifier): void;
|
|
62
79
|
/**
|
|
63
80
|
* openModal opens the modal for the appIdentifier provided.
|
|
81
|
+
*
|
|
82
|
+
* When the JWT payload contains `use_new_sdk: true`, the modal renders
|
|
83
|
+
* the corresponding `@zerohash-sdk/*-react` npm package instead of the
|
|
84
|
+
* legacy iframe. Apps that don't yet have a published React package
|
|
85
|
+
* (e.g. crypto-account-link) fall back to the iframe automatically.
|
|
64
86
|
*/
|
|
65
87
|
openModal({ jwt, appIdentifier, filters, navigate, }: IOpenModalParameters): void;
|
|
66
88
|
/**
|
|
@@ -74,5 +96,11 @@ export declare class ZeroHashSDK implements IZeroHashSDK {
|
|
|
74
96
|
*/
|
|
75
97
|
closeOnboardingModal(): void;
|
|
76
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Test-only: clear the set-once `_newSdkOrigin` pin so suites that
|
|
101
|
+
* construct `ZeroHashSDK` multiple times can exercise different envs in
|
|
102
|
+
* isolation. Not exported from the package; tests import it directly.
|
|
103
|
+
*/
|
|
104
|
+
export declare function _resetNewSdkOriginForTests(): void;
|
|
77
105
|
export default ZeroHashSDK;
|
|
78
106
|
export * from "./types";
|