zh-web-sdk 2.16.1 → 2.17.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/README.md +225 -32
- package/package.json +6 -1
- 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/README.md
CHANGED
|
@@ -1,56 +1,249 @@
|
|
|
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 Crypto Buy, Crypto Sell, Crypto Withdrawals, Fiat Deposits, Fiat Withdrawals, and Onboarding 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
|
+
}), []);
|
|
30
|
+
|
|
31
|
+
const handleOpenCryptoBuy = () => {
|
|
32
|
+
sdk.openModal({
|
|
33
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY,
|
|
34
|
+
jwt: "<JWT_TOKEN_HERE>"
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<button onClick={handleOpenCryptoBuy}>
|
|
40
|
+
Buy Crypto
|
|
41
|
+
</button>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default App;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Vanilla JavaScript Example
|
|
6
49
|
|
|
7
50
|
```javascript
|
|
8
|
-
import { AppIdentifier } from 'zh-web-sdk'
|
|
51
|
+
import ZeroHashSDK, { AppIdentifier } from 'zh-web-sdk';
|
|
52
|
+
|
|
53
|
+
// Initialize SDK once
|
|
54
|
+
const sdk = new ZeroHashSDK({
|
|
55
|
+
zeroHashAppsURL: "https://web-sdk.zerohash.com"
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Open a modal
|
|
59
|
+
sdk.openModal({
|
|
60
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY,
|
|
61
|
+
jwt: "<JWT_TOKEN_HERE>"
|
|
62
|
+
});
|
|
9
63
|
|
|
10
|
-
|
|
11
|
-
sdk.
|
|
64
|
+
// Close when done
|
|
65
|
+
sdk.closeModal(AppIdentifier.CRYPTO_BUY);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Environments
|
|
12
69
|
|
|
13
|
-
|
|
70
|
+
The SDK supports multiple environments:
|
|
14
71
|
|
|
15
|
-
|
|
72
|
+
- **Production**: `https://web-sdk.zerohash.com`
|
|
73
|
+
- **Certification/Sandbox**: `https://web-sdk.cert.zerohash.com`
|
|
16
74
|
|
|
17
|
-
|
|
75
|
+
```typescript
|
|
76
|
+
const sdk = new ZeroHashSDK({
|
|
77
|
+
zeroHashAppsURL: "https://web-sdk.cert.zerohash.com" // Use cert environment
|
|
78
|
+
});
|
|
18
79
|
```
|
|
19
80
|
|
|
20
|
-
|
|
81
|
+
## Available App Identifiers
|
|
82
|
+
|
|
83
|
+
The SDK supports the following application flows:
|
|
84
|
+
|
|
85
|
+
| AppIdentifier | Description |
|
|
86
|
+
|--------------|-------------|
|
|
87
|
+
| `ONBOARDING` | User onboarding and KYC |
|
|
88
|
+
| `CRYPTO_BUY` | Purchase cryptocurrency |
|
|
89
|
+
| `CRYPTO_SELL` | Sell cryptocurrency |
|
|
90
|
+
| `CRYPTO_WITHDRAWALS` | Withdraw crypto to external wallets |
|
|
91
|
+
| `FIAT_DEPOSITS` | Deposit fiat currency |
|
|
92
|
+
| `FIAT_WITHDRAWALS` | Withdraw fiat currency |
|
|
93
|
+
| `FUND` | Fund account operations |
|
|
94
|
+
| `PROFILE` | User profile management |
|
|
95
|
+
| `CRYPTO_ACCOUNT_LINK` | Link cryptocurrency accounts |
|
|
96
|
+
| `CRYPTO_ACCOUNT_LINK_PAYOUTS` | Link crypto accounts for payouts |
|
|
97
|
+
| `FIAT_ACCOUNT_LINK` | Link bank accounts |
|
|
98
|
+
| `PAYOUTS` | Payout operations |
|
|
99
|
+
| `PAY` | Payment operations |
|
|
21
100
|
|
|
22
|
-
##
|
|
101
|
+
## API Reference
|
|
102
|
+
|
|
103
|
+
### Constructor
|
|
23
104
|
|
|
24
105
|
```typescript
|
|
25
|
-
|
|
26
|
-
|
|
106
|
+
new ZeroHashSDK(config: IInitializeParameters)
|
|
107
|
+
```
|
|
27
108
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
109
|
+
**Configuration Options:**
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
{
|
|
113
|
+
zeroHashAppsURL: string; // Required: Base URL for ZeroHash apps
|
|
114
|
+
rootQuerySelector?: string; // Optional: Custom DOM element selector
|
|
115
|
+
|
|
116
|
+
// Optional: Set JWTs during initialization
|
|
117
|
+
cryptoBuyJWT?: string;
|
|
118
|
+
cryptoSellJWT?: string;
|
|
119
|
+
cryptoWithdrawalsJWT?: string;
|
|
120
|
+
fiatDepositsJWT?: string;
|
|
121
|
+
fiatWithdrawalsJWT?: string;
|
|
122
|
+
userOnboardingJWT?: string;
|
|
123
|
+
fundJWT?: string;
|
|
124
|
+
profileJWT?: string;
|
|
125
|
+
cryptoAccountLinkJWT?: string;
|
|
126
|
+
cryptoAccountLinkPayoutsJWT?: string;
|
|
127
|
+
fiatAccountLinkJWT?: string;
|
|
128
|
+
payoutsJWT?: string;
|
|
129
|
+
payJWT?: string;
|
|
38
130
|
}
|
|
131
|
+
```
|
|
39
132
|
|
|
40
|
-
|
|
133
|
+
### Methods
|
|
134
|
+
|
|
135
|
+
#### `openModal(params)`
|
|
136
|
+
|
|
137
|
+
Opens a modal for the specified app.
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
sdk.openModal({
|
|
141
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY,
|
|
142
|
+
jwt?: string, // Optional: Set or update JWT
|
|
143
|
+
filters?: Filters, // Optional: Filter options
|
|
144
|
+
navigate?: Page // Optional: Navigation parameters
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### `closeModal(appIdentifier)`
|
|
149
|
+
|
|
150
|
+
Closes the modal for the specified app.
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
sdk.closeModal(AppIdentifier.CRYPTO_BUY);
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### `setJWT(params)`
|
|
157
|
+
|
|
158
|
+
Set or update the JWT for a specific app.
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
sdk.setJWT({
|
|
162
|
+
jwt: "<JWT_TOKEN>",
|
|
163
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### `isModalOpen(appIdentifier)`
|
|
168
|
+
|
|
169
|
+
Check if a modal is currently open.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
const isOpen = sdk.isModalOpen(AppIdentifier.CRYPTO_BUY);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### `setFilters(params)`
|
|
176
|
+
|
|
177
|
+
Set filters for a specific app.
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
sdk.setFilters({
|
|
181
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY,
|
|
182
|
+
filters: {
|
|
183
|
+
getAssets: {
|
|
184
|
+
stablecoin: true
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## JWT Authentication
|
|
191
|
+
|
|
192
|
+
**⚠️ 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.
|
|
193
|
+
|
|
194
|
+
### Two approaches for providing JWTs:
|
|
195
|
+
|
|
196
|
+
**1. During initialization:**
|
|
197
|
+
```typescript
|
|
198
|
+
const sdk = new ZeroHashSDK({
|
|
199
|
+
zeroHashAppsURL: "https://web-sdk.zerohash.com",
|
|
200
|
+
cryptoBuyJWT: jwt
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**2. When opening a modal:**
|
|
205
|
+
```typescript
|
|
206
|
+
sdk.openModal({
|
|
207
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY,
|
|
208
|
+
jwt: jwt
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**3. Update JWT later:**
|
|
213
|
+
```typescript
|
|
214
|
+
sdk.setJWT({
|
|
215
|
+
jwt: newJwt,
|
|
216
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## TypeScript Support
|
|
221
|
+
|
|
222
|
+
The SDK is written in TypeScript and includes type definitions. Import types as needed:
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import ZeroHashSDK, {
|
|
226
|
+
AppIdentifier,
|
|
227
|
+
IInitializeParameters,
|
|
228
|
+
IOpenModalParameters,
|
|
229
|
+
Filters
|
|
230
|
+
} from 'zh-web-sdk';
|
|
41
231
|
```
|
|
42
232
|
|
|
43
233
|
## Versioning
|
|
44
234
|
|
|
45
235
|
The ZeroHash SDK uses [Semantic Versioning 2.0.0](https://semver.org/). Version numbers follow the `MAJOR.MINOR.PATCH` format:
|
|
46
236
|
|
|
47
|
-
- **MAJOR** version increments
|
|
48
|
-
- **MINOR** version increments
|
|
49
|
-
- **PATCH** version increments
|
|
237
|
+
- **MAJOR** version increments for incompatible API changes (e.g., `1.0.0` to `2.0.0`)
|
|
238
|
+
- **MINOR** version increments for backward-compatible new features (e.g., `1.0.0` to `1.1.0`)
|
|
239
|
+
- **PATCH** version increments for backward-compatible bug fixes (e.g., `1.0.0` to `1.0.1`)
|
|
240
|
+
|
|
241
|
+
## Documentation & Support
|
|
242
|
+
|
|
243
|
+
- **Full Documentation**: [ZeroHash SDK Documentation](https://docs.zerohash.com/reference/sdk-overview)
|
|
244
|
+
- **Changelog**: [ZeroHash Documentation Changelog](https://docs.zerohash.com/reference/changelog)
|
|
245
|
+
- **Mobile Usage**: See the [SDK Overview](https://docs.zerohash.com/reference/sdk-overview) for mobile implementation details
|
|
50
246
|
|
|
51
|
-
##
|
|
52
|
-
[zerohash Documentation Changelog](https://docs.zerohash.com/reference/changelog)
|
|
247
|
+
## License
|
|
53
248
|
|
|
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).
|
|
249
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zh-web-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "ZeroHash Web SDK",
|
|
6
6
|
"homepage": "https://github.com/seedcx/zh-web-sdk",
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
"module": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
10
|
"keywords": [],
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/",
|
|
13
|
+
"README.md",
|
|
14
|
+
"CHANGELOG.md"
|
|
15
|
+
],
|
|
11
16
|
"author": "support@zerohash.com",
|
|
12
17
|
"license": "MIT",
|
|
13
18
|
"scripts": {
|
package/.eslintrc.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: { browser: true, es2020: true },
|
|
3
|
-
extends: [
|
|
4
|
-
'eslint:recommended',
|
|
5
|
-
'plugin:@typescript-eslint/recommended',
|
|
6
|
-
'plugin:react-hooks/recommended',
|
|
7
|
-
],
|
|
8
|
-
parser: '@typescript-eslint/parser',
|
|
9
|
-
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
|
|
10
|
-
plugins: ['react-refresh'],
|
|
11
|
-
rules: {},
|
|
12
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# Changelog Entry Template
|
|
2
|
-
|
|
3
|
-
Use this template when adding a new version to CHANGELOG.md
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## [X.Y.Z] - YYYY-MM-DD
|
|
8
|
-
|
|
9
|
-
### Added
|
|
10
|
-
- New feature that allows users to [describe user benefit] [#PR_NUMBER]
|
|
11
|
-
- Another feature description focusing on customer value
|
|
12
|
-
|
|
13
|
-
### Changed
|
|
14
|
-
- Updated [feature/behavior] to [improvement description]
|
|
15
|
-
- [Behavior change] now [new behavior] instead of [old behavior]
|
|
16
|
-
|
|
17
|
-
### Deprecated
|
|
18
|
-
- [Feature name] is deprecated and will be removed in version [X.Y.Z]
|
|
19
|
-
- Migration path: Use [alternative approach] instead
|
|
20
|
-
- See [documentation link] for details
|
|
21
|
-
|
|
22
|
-
### Removed
|
|
23
|
-
- Removed [feature name] (deprecated since version [X.Y.Z])
|
|
24
|
-
- See [migration guide link] for alternatives
|
|
25
|
-
|
|
26
|
-
### Fixed
|
|
27
|
-
- Fixed issue where [problem description] [#PR_NUMBER]
|
|
28
|
-
- Resolved [bug description] affecting [user impact]
|
|
29
|
-
|
|
30
|
-
### Security
|
|
31
|
-
- Updated [dependency name] to address [vulnerability type]
|
|
32
|
-
- Fixed [security issue description]
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## Guidelines
|
|
37
|
-
|
|
38
|
-
### Writing Tips
|
|
39
|
-
|
|
40
|
-
1. **Focus on User Impact**
|
|
41
|
-
- ✅ Good: "Fixed SDK positioning to prevent scrolling issues"
|
|
42
|
-
- ❌ Avoid: "Refactored internal positioning logic"
|
|
43
|
-
|
|
44
|
-
2. **Be Specific and Clear**
|
|
45
|
-
- ✅ Good: "Added bank account linking feature for direct deposits"
|
|
46
|
-
- ❌ Avoid: "Added new feature"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### Breaking Changes
|
|
50
|
-
|
|
51
|
-
For MAJOR version releases, clearly mark breaking changes:
|
|
52
|
-
|
|
53
|
-
```markdown
|
|
54
|
-
## [3.0.0] - 2026-XX-XX
|
|
55
|
-
|
|
56
|
-
### Changed
|
|
57
|
-
- ⚠️ **BREAKING**: Renamed `cryptoBuyJWT` parameter to `jwt` in SDK configuration
|
|
58
|
-
|
|
59
|
-
**Migration Guide:**
|
|
60
|
-
\`\`\`typescript
|
|
61
|
-
// Before (v2.x)
|
|
62
|
-
const sdk = new ZeroHashSDK({
|
|
63
|
-
cryptoBuyJWT: token
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
// After (v3.x)
|
|
67
|
-
const sdk = new ZeroHashSDK({
|
|
68
|
-
jwt: token
|
|
69
|
-
})
|
|
70
|
-
\`\`\`
|
|
71
|
-
|
|
72
|
-
See [Migration Guide v2 to v3](link) for full details.
|
|
73
|
-
```
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
name: "Reusable NPM Publish tag"
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
tags:
|
|
6
|
-
- "v*"
|
|
7
|
-
workflow_dispatch:
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
from_reusable:
|
|
11
|
-
uses: seedcx/composite-actions/.github/workflows/rw-npm-publish-public-oidc.yml@main
|
|
12
|
-
secrets: inherit
|
|
13
|
-
with:
|
|
14
|
-
NODE_VERSION: "22.21.1"
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
name: "Reusable NPM Build"
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
branches: [ main, master ]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
from_reusable:
|
|
9
|
-
uses: seedcx/composite-actions/.github/workflows/rw-npm-build.yml@main
|
|
10
|
-
secrets: inherit
|
|
11
|
-
with:
|
|
12
|
-
NODE_VERSION: "22.22.0"
|
|
13
|
-
NPM_VERSION: "9"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
name: "Pull Request"
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
branches: [main]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
from_reusable:
|
|
9
|
-
uses: seedcx/composite-actions/.github/workflows/rw-node-pull-request.yml@main
|
|
10
|
-
secrets: inherit
|
|
11
|
-
with:
|
|
12
|
-
NODE_VERSION: "22.22.0"
|
|
13
|
-
TEST_PLATFORM: 'npm'
|
|
14
|
-
TEST_REPORTER: 'jest-junit'
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
name: 'Security Workflow'
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch:
|
|
5
|
-
pull_request:
|
|
6
|
-
branches: [main]
|
|
7
|
-
schedule:
|
|
8
|
-
- cron: '0 16 * * 2'
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
security:
|
|
12
|
-
uses: seedcx/composite-actions/.github/workflows/rw-security.yml@main
|
|
13
|
-
with:
|
|
14
|
-
NODE_VERSION: 22.12.0
|
|
15
|
-
secrets: inherit
|
package/RELEASING.md
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# Release Process
|
|
2
|
-
|
|
3
|
-
This document describes the process for releasing new versions of the zerohash Web SDK.
|
|
4
|
-
|
|
5
|
-
## Release Steps
|
|
6
|
-
|
|
7
|
-
### 1. Update CHANGELOG.md
|
|
8
|
-
|
|
9
|
-
Add a new version section at the top of `CHANGELOG.md`:
|
|
10
|
-
|
|
11
|
-
```markdown
|
|
12
|
-
## [X.Y.Z] - YYYY-MM-DD
|
|
13
|
-
|
|
14
|
-
### Added
|
|
15
|
-
- New feature description [#PR_NUMBER]
|
|
16
|
-
|
|
17
|
-
### Fixed
|
|
18
|
-
- Bug fix description [#PR_NUMBER]
|
|
19
|
-
|
|
20
|
-
### Changed
|
|
21
|
-
- Behavior change description
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
See `.github/CHANGELOG_TEMPLATE.md` for detailed guidelines.
|
|
25
|
-
|
|
26
|
-
**Commit the changelog:**
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
git add CHANGELOG.md
|
|
30
|
-
git commit -m "docs: update CHANGELOG for vX.Y.Z"
|
|
31
|
-
git push origin main
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### 2. Update ReadMe Changelog
|
|
35
|
-
|
|
36
|
-
1. Go to ReadMe dashboard: https://dash.readme.com/
|
|
37
|
-
2. Navigate to the Changelog section
|
|
38
|
-
3. Create new changelog entry with content from `CHANGELOG.md`
|
|
39
|
-
4. Publish the entry
|
package/jest.config.js
DELETED
package/jest.setup.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
3
|
-
/* eslint-disable no-undef */
|
|
4
|
-
|
|
5
|
-
const { TextEncoder, TextDecoder } = require('util');
|
|
6
|
-
|
|
7
|
-
Object.assign(global, { TextDecoder, TextEncoder })
|
|
8
|
-
global.CSS = {
|
|
9
|
-
supports: (k, v) => true,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(window, 'matchMedia', {
|
|
13
|
-
writable: true,
|
|
14
|
-
value: jest.fn().mockImplementation(query => ({
|
|
15
|
-
matches: false,
|
|
16
|
-
media: query,
|
|
17
|
-
onchange: null,
|
|
18
|
-
addListener: jest.fn(), // Deprecated
|
|
19
|
-
removeListener: jest.fn(), // Deprecated
|
|
20
|
-
addEventListener: jest.fn(),
|
|
21
|
-
removeEventListener: jest.fn(),
|
|
22
|
-
dispatchEvent: jest.fn(),
|
|
23
|
-
})),
|
|
24
|
-
});
|
package/scripts/build.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const esbuild = require("esbuild");
|
|
2
|
-
const {name, version} = require("../package.json");
|
|
3
|
-
|
|
4
|
-
const build = async () => {
|
|
5
|
-
console.log(`Building ${name}@${version}`);
|
|
6
|
-
|
|
7
|
-
const outputDir = "./dist/";
|
|
8
|
-
const minFileName = `${outputDir}zerohash_sdk.min.js`;
|
|
9
|
-
const bundleFileName = `${outputDir}zerohash_sdk.js`;
|
|
10
|
-
|
|
11
|
-
// Build minified dist
|
|
12
|
-
await esbuild
|
|
13
|
-
.build({
|
|
14
|
-
entryPoints: ['src/index.tsx'],
|
|
15
|
-
outdir: 'dist',
|
|
16
|
-
bundle: true,
|
|
17
|
-
sourcemap: true,
|
|
18
|
-
minify: true,
|
|
19
|
-
splitting: false,
|
|
20
|
-
format: 'esm',
|
|
21
|
-
target: ['esnext']
|
|
22
|
-
})
|
|
23
|
-
.catch(err => {
|
|
24
|
-
console.error('Error: build failed - unable to build minified dist');
|
|
25
|
-
throw err;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
build()
|
|
30
|
-
.then(() => console.log("successfully built"))
|
|
31
|
-
.catch(err => {
|
|
32
|
-
console.error(err);
|
|
33
|
-
process.exit(1);
|
|
34
|
-
});
|
package/scripts/zip.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const archiver = require("archiver");
|
|
3
|
-
const {name, version} = require("../package.json");
|
|
4
|
-
|
|
5
|
-
const zip = async () => {
|
|
6
|
-
const zipFile = `./build/zh_web_sdk_v${version}.zip`;
|
|
7
|
-
console.log(`Zipping to ${zipFile}`);
|
|
8
|
-
|
|
9
|
-
// create the directory forcibly
|
|
10
|
-
fs.mkdirSync("./build", {recursive: true});
|
|
11
|
-
|
|
12
|
-
// zip output as a package
|
|
13
|
-
const output = fs.createWriteStream(zipFile);
|
|
14
|
-
const archive = archiver('zip', {
|
|
15
|
-
zlib: { level: 9 }
|
|
16
|
-
});
|
|
17
|
-
output.on('close', () => {
|
|
18
|
-
console.log(archive.pointer() + ' total bytes');
|
|
19
|
-
console.log('archiver has been finalized and the output file descriptor has closed.');
|
|
20
|
-
});
|
|
21
|
-
output.on('end', () => {
|
|
22
|
-
console.log('Data has been drained');
|
|
23
|
-
});
|
|
24
|
-
archive.on('warning', (err) => {
|
|
25
|
-
if (err.code === "ENOENT") {
|
|
26
|
-
console.warn("ENOENT: ", err);
|
|
27
|
-
} else {
|
|
28
|
-
console.error(err);
|
|
29
|
-
throw err;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
archive.on('error', (err) => {
|
|
33
|
-
console.error(err);
|
|
34
|
-
throw err;
|
|
35
|
-
});
|
|
36
|
-
archive.pipe(output);
|
|
37
|
-
archive.file("README.md");
|
|
38
|
-
archive.file("package.json");
|
|
39
|
-
archive.file("package-lock.json");
|
|
40
|
-
archive.directory("./dist/");
|
|
41
|
-
await archive.finalize();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
zip()
|
|
45
|
-
.then(() => console.log("successfully zipped"))
|
|
46
|
-
.catch(err => {
|
|
47
|
-
console.error(err);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
});
|