zh-web-sdk 1.0.2

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/.eslintrc.js ADDED
@@ -0,0 +1,14 @@
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
+ 'react-refresh/only-export-components': 'warn',
13
+ },
14
+ }
@@ -0,0 +1,13 @@
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: "16.13.0"
13
+ TEST_ENABLED: false
@@ -0,0 +1,57 @@
1
+ name: "Release"
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "*"
7
+
8
+ jobs:
9
+ release:
10
+ name: Release
11
+ env:
12
+ NODE_VERSION: '16.13.0'
13
+ runs-on: ["builder","x64","linux","self-hosted"]
14
+ steps:
15
+ - uses: actions/checkout@v3
16
+
17
+ - uses: actions/setup-node@v3
18
+ with:
19
+ node-version: ${{ env.NODE_VERSION }}
20
+ cache: 'npm'
21
+
22
+ - name: NPM CI
23
+ run: npm ci
24
+
25
+ - name: NPM Build
26
+ run: echo "BUILD=$(npm run build:zip | grep Zipping | awk '{print $3}') " >> $GITHUB_OUTPUT
27
+ id: build
28
+
29
+ - name: Create a GitHub release
30
+ uses: ncipollo/release-action@v1
31
+ with:
32
+ tag: ${{ github.ref_name }}
33
+ name: Release ${{ github.ref_name }}
34
+ body: |
35
+ ${{ github.ref.outputs.changelog }}
36
+ generateReleaseNotes: true
37
+ token: ${{ secrets.GITHUB_TOKEN }}
38
+ artifacts: |
39
+ ${{ steps.build.outputs.BUILD }}
40
+
41
+ publish:
42
+ name: Publish
43
+ env:
44
+ NODE_VERSION: '16.13.0'
45
+ runs-on: ["builder","x64","linux","self-hosted"]
46
+ steps:
47
+ - uses: actions/checkout@v3
48
+ - uses: actions/setup-node@v3
49
+ with:
50
+ node-version: ${{ env.NODE_VERSION }}
51
+ cache: 'npm'
52
+ registry-url: 'https://registry.npmjs.org'
53
+ - name: NPM CI
54
+ run: npm ci
55
+ - run: npm publish
56
+ env:
57
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
@@ -0,0 +1,55 @@
1
+ name: 'Tag New Version'
2
+
3
+ on:
4
+ push:
5
+ # Run the action only on pushes to the main branch
6
+ branches:
7
+ - main
8
+
9
+ permissions:
10
+ contents: write
11
+
12
+ jobs:
13
+ push-to-main:
14
+ if: github.event.pusher.name != 'seedcx-deploy'
15
+ env:
16
+ NODE_VERSION: '16.13.0'
17
+ BUMP: ${{ contains(github.event.head_commit.message, 'BREAKING CHANGE') && 'major' || contains(github.event.head_commit.message, 'feat') && 'minor' || 'patch' }}
18
+ GITHUB_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
19
+ runs-on: ["builder","x64","linux","self-hosted"]
20
+ steps:
21
+ - uses: actions/checkout@v3
22
+ with:
23
+ token: ${{ secrets.GH_TAG_TOKEN }}
24
+
25
+ - name: Import bot's GPG key for signing commits
26
+ id: import-gpg
27
+ uses: crazy-max/ghaction-import-gpg@v5
28
+ with:
29
+ gpg_private_key: ${{ secrets.SEEDCX_DEPLOY_GPG_PRIVATE_KEY }}
30
+ passphrase: ${{ secrets.SEEDCX_DEPLOY_GPG_PASSPHRASE }}
31
+ git_config_global: true
32
+ git_user_signingkey: true
33
+ git_commit_gpgsign: true
34
+
35
+ - uses: actions/setup-node@v3
36
+ with:
37
+ node-version: ${{ env.NODE_VERSION }}
38
+
39
+ # Set git config
40
+ - uses: nodef/git-config.action@v1.0.0
41
+ with:
42
+ credentials: auto
43
+ entries: |-
44
+ user.name = seedcx-deploy
45
+ user.email = 22893110+seedcx-deploy@users.noreply.github.com>
46
+
47
+ - name: Update Version
48
+ run: echo "VERSION=$(npm version ${{ env.BUMP }})" >> $GITHUB_OUTPUT
49
+ id: version
50
+
51
+ - name: Push version update
52
+ run: git push
53
+
54
+ - name: Push tag
55
+ run: git push origin ${{ steps.version.outputs.VERSION }}
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # ZeroHash Platform SDK
2
+
3
+ This SDK exposes functionality that allows platforms to integrate with ZeroHash on the web.
4
+
5
+ ## Quick setup
6
+
7
+ ```javascript
8
+ import ZeroHashSDK from "zh-web-sdk";
9
+
10
+ // Initialize SDK
11
+ const sdk = new ZeroHashSDK({
12
+ zeroHashOnboardingURL: "https://onboarding.zerohash.com/"
13
+ });
14
+
15
+ // Set the user onboarding JWT retrieved for a particular user
16
+ // A user onboarding JWT before the user can proceed with the onboarding flow.
17
+ sdk.openOnboardingModal({
18
+ userOnboardingJWT: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9." +
19
+ "eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ." +
20
+ "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
21
+ });
22
+ ```
23
+
24
+ ## API
25
+
26
+ See the `ZeroHashSDK` class in `index.d.ts` in `/dist`.
27
+
28
+ If you are browsing this repository, you can find the implementation in `index.tsx`.
29
+
30
+ ## Versioning
31
+
32
+ The pipeline automatically updates the version in package.json after merge to main. It uses conventional commits to determine the type of bump to use:
33
+
34
+ - `BREAKING CHANGE` is a major release (`1.0.0` to `2.0.0`)
35
+ - `feat` is a minor release (`1.0.0` to `1.1.0`)
36
+ - default is a patch release (`1.0.0` to `1.0.1`)
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_ZH_ONBOARDING_URL = "https://onboarding.zerohash.com/";
2
+ export declare const DEFAULT_ROOT_ID_PREFIX = "zerohash";
@@ -0,0 +1,37 @@
1
+ import { IInitializeParameters, IOpenOnboardingModalParameters, ISetUserOnboardingJWTParameters, IZeroHashSDK } from './types';
2
+ export declare class ZeroHashSDK implements IZeroHashSDK {
3
+ private rootQuerySelector;
4
+ private onboardingInitialized;
5
+ /**
6
+ * Sets up the ZeroHash SDK and appends the ZeroHash DOM elements onto the page.
7
+ *
8
+ * For more information, see {@code IInitializeParameters}
9
+ */
10
+ constructor({ zeroHashOnboardingURL, rootQuerySelector, userOnboardingJWT }: IInitializeParameters);
11
+ /**
12
+ * setUserOnboardingJWT sets the JWT to be whatever value is provided.
13
+ * The JWT should be the UserJWT provided by ZeroHash via the platform
14
+ * API proxied through your servers. As ZeroHash cannot authenticate
15
+ * your users' requests, it is paramount that the user be authenticated
16
+ * and validated on your servers, and exchanged for the JWT using your
17
+ * API key. DO NOT have the JWT exchange logic be on your front-end.
18
+ *
19
+ * As a precaution, we may restrict traffic to the JWT exchange API to
20
+ * whitelisted IPs that come from your server.
21
+ */
22
+ setUserOnboardingJWT(params: ISetUserOnboardingJWTParameters): void;
23
+ /**
24
+ * isOnboardingModalOpen returns true if the onboarding modal is open,
25
+ * false otherwise
26
+ */
27
+ isOnboardingModalOpen(): boolean;
28
+ /**
29
+ * openOnboardingModal opens the onboarding modal
30
+ */
31
+ openOnboardingModal(params: IOpenOnboardingModalParameters): void;
32
+ /**
33
+ * closeOnboardingModalModal hides the onboarding modal
34
+ */
35
+ closeOnboardingModal(): void;
36
+ }
37
+ export default ZeroHashSDK;