From b7c95cf38724a3fc76eb7051a79b984d98bc928c Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Fri, 11 Oct 2024 11:55:59 -0400 Subject: [PATCH 01/17] Create docs-push.yml --- .github/workflows/docs-push.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/docs-push.yml diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml new file mode 100644 index 00000000..dd417b1a --- /dev/null +++ b/.github/workflows/docs-push.yml @@ -0,0 +1,19 @@ +on: + workflow_dispatch: + +jobs: + copy-docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: olivr/copybara-action@v1.2.3 + with: + access_token: ${{ secrets.KNOWLEDGEBASE_PR_TOKEN }} + sot_repo: docknetwork/react-native-sdk + origin_include: docs/* + destination_repo: docknetwork/knowledgebase-docs + move: | + docs/*||developer-documentation/wallet-sdk From e6a7fa50e25b6d38326bb5b2aa9eea3f4ca501a0 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Wed, 16 Oct 2024 14:59:47 -0400 Subject: [PATCH 02/17] Update docs-push.yml (#291) Push docs/* to the knowledge-base repo --- .github/workflows/docs-push.yml | 57 ++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index dd417b1a..db63971e 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -1,19 +1,54 @@ +name: Push docs to knowledgebase on: - workflow_dispatch: - + push: + branches: master + jobs: - copy-docs: + Copy-docs: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v2 + - name: Checkout source repo + uses: actions/checkout@v2 with: fetch-depth: 0 - - uses: olivr/copybara-action@v1.2.3 + - name: Checkout destination repo + uses: actions/checkout@v2 with: - access_token: ${{ secrets.KNOWLEDGEBASE_PR_TOKEN }} - sot_repo: docknetwork/react-native-sdk - origin_include: docs/* - destination_repo: docknetwork/knowledgebase-docs - move: | - docs/*||developer-documentation/wallet-sdk + repository: docknetwork/knowledgebase-docs + token: ${{ secrets.KNOWLEDGEBASE_PR_TOKEN }} + path: knowledge-base + + - name: Copy files + run: | + # Specify the files or directories you want to copy + cp -r docs/* knowledge-base/developer-documentation/wallet-sdk + + - name: Get branch name + id: get_branch + run: echo "branch_name=sync/${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV + + - name: Commit changes + env: + GH_TOKEN: ${{ secrets.KNOWLEDGEBASE_PR_TOKEN }} + run: | + cd knowledge-base + git checkout -b ${{env.branch_name}} + git config user.name "${{ github.triggering_actor }}" + git config user.email "mike@dock.io" + # Get the commit message from the merged PR + commit_message="${{ github.event.pull_request.title }}" + git add -A . + git status + git commit -m "Copy files from ${{ github.event.pull_request.head.repo.full_name }} branch $branch_name: $commit_message" + # Create PR + git ls-remote --get-url origin + git push -u origin ${{ env.branch_name }} + gh pr create \ + --body "This PR copies /docs files from ${{ github.event.pull_request.head.repo.full_name }}." \ + --title "${{ github.event.pull_request.title }}" \ + --head "${{ env.branch_name }}" \ + --base "main" + echo "Docs successfully pushed to knowledgebase-docs" + From c71c7eb66639661fdb6babbdb017d0f75b9417dc Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Wed, 16 Oct 2024 15:25:39 -0400 Subject: [PATCH 03/17] fix issue with branch-names being dependent on a pull-request (#292) --- .github/workflows/docs-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index db63971e..e96a5c58 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -27,7 +27,7 @@ jobs: - name: Get branch name id: get_branch - run: echo "branch_name=sync/${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV + run: echo "branch_name=sync/${{ github.event.ref }}" >> $GITHUB_ENV - name: Commit changes env: From e80d64e0234c86cda8c5f30e9232a74376de58e0 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Wed, 16 Oct 2024 15:36:23 -0400 Subject: [PATCH 04/17] get rid of pull_request event fields (#293) --- .github/workflows/docs-push.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index e96a5c58..54603ddc 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -27,7 +27,7 @@ jobs: - name: Get branch name id: get_branch - run: echo "branch_name=sync/${{ github.event.ref }}" >> $GITHUB_ENV + run: echo "branch_name=sync/${{ github.event.ref }}_${{github.event.head_commit.timestamp}}" >> $GITHUB_ENV - name: Commit changes env: @@ -38,16 +38,16 @@ jobs: git config user.name "${{ github.triggering_actor }}" git config user.email "mike@dock.io" # Get the commit message from the merged PR - commit_message="${{ github.event.pull_request.title }}" + commit_message="${{ github.event.head_commit.message }}" git add -A . git status - git commit -m "Copy files from ${{ github.event.pull_request.head.repo.full_name }} branch $branch_name: $commit_message" + git commit -m "Copy files from ${{ github.event.repository.full_name }} branch $branch_name: $commit_message" # Create PR git ls-remote --get-url origin git push -u origin ${{ env.branch_name }} gh pr create \ - --body "This PR copies /docs files from ${{ github.event.pull_request.head.repo.full_name }}." \ - --title "${{ github.event.pull_request.title }}" \ + --body "This PR copies /docs files from ${{ github.event.repository.full_name }}." \ + --title "${{ github.event.head_commit.message }}" \ --head "${{ env.branch_name }}" \ --base "main" echo "Docs successfully pushed to knowledgebase-docs" From 6c77d2af63c430e4bb3dcb2267072c670bbcceb4 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Wed, 16 Oct 2024 15:52:17 -0400 Subject: [PATCH 05/17] use commit id instead of timestamp in new branch name (#294) --- .github/workflows/docs-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index 54603ddc..9bd9e954 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -27,7 +27,7 @@ jobs: - name: Get branch name id: get_branch - run: echo "branch_name=sync/${{ github.event.ref }}_${{github.event.head_commit.timestamp}}" >> $GITHUB_ENV + run: echo "branch_name=sync/${{ github.event.ref }}_${{github.event.head_commit.id}}" >> $GITHUB_ENV - name: Commit changes env: From 231c7979dd3fcba935c3a3dcb7706bfebf5487d1 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Fri, 18 Oct 2024 14:36:41 -0400 Subject: [PATCH 06/17] strip refs/ from branch-name (#295) * strip refs/ from branch-name * get rid of double // --- .github/workflows/docs-push.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index 9bd9e954..63cf9f6f 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -1,7 +1,9 @@ name: Push docs to knowledgebase on: push: - branches: master + branches: + master + docs/push-to-knowledgebase-pr jobs: Copy-docs: @@ -27,13 +29,14 @@ jobs: - name: Get branch name id: get_branch - run: echo "branch_name=sync/${{ github.event.ref }}_${{github.event.head_commit.id}}" >> $GITHUB_ENV + run: echo "branch_name=sync/${{ github.event.ref }}_${{github.event.head_commit.id}}"| sed -e "s/refs\///g"| sed -e "s/\/\//\//g" >> $GITHUB_ENV - name: Commit changes env: GH_TOKEN: ${{ secrets.KNOWLEDGEBASE_PR_TOKEN }} run: | cd knowledge-base + echo ${{env.branch_name}} git checkout -b ${{env.branch_name}} git config user.name "${{ github.triggering_actor }}" git config user.email "mike@dock.io" @@ -45,6 +48,7 @@ jobs: # Create PR git ls-remote --get-url origin git push -u origin ${{ env.branch_name }} + echo "Creating PR..." gh pr create \ --body "This PR copies /docs files from ${{ github.event.repository.full_name }}." \ --title "${{ github.event.head_commit.message }}" \ From add684790977dc292411dffcaf1a5aa06b5fd7a0 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Fri, 18 Oct 2024 14:39:11 -0400 Subject: [PATCH 07/17] trigger on all pushes (temporarily) --- .github/workflows/docs-push.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index 63cf9f6f..c7046b1b 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -1,9 +1,6 @@ name: Push docs to knowledgebase on: push: - branches: - master - docs/push-to-knowledgebase-pr jobs: Copy-docs: From d2fd92f6a9efd23abe121c431a3b622664c22179 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Fri, 18 Oct 2024 14:41:18 -0400 Subject: [PATCH 08/17] only trigger docs push on master --- .github/workflows/docs-push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index c7046b1b..415b4f1f 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -1,6 +1,7 @@ name: Push docs to knowledgebase on: push: + branches: master jobs: Copy-docs: From 7f60001a9f73a49a2d3b0d8d7261117425cf5cb2 Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Fri, 18 Oct 2024 14:51:22 -0400 Subject: [PATCH 09/17] user commiter's email and name for push to kb --- .github/workflows/docs-push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index 415b4f1f..ede5f65d 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -36,8 +36,8 @@ jobs: cd knowledge-base echo ${{env.branch_name}} git checkout -b ${{env.branch_name}} - git config user.name "${{ github.triggering_actor }}" - git config user.email "mike@dock.io" + git config user.name "${{ github.event.head_commit.author.name }}" + git config user.email "${{ github.event.head_commit.author.email }}" # Get the commit message from the merged PR commit_message="${{ github.event.head_commit.message }}" git add -A . From 07f9371843b2edc659d6f9a30c0610a9f6936afe Mon Sep 17 00:00:00 2001 From: Mike Parkhill Date: Fri, 18 Oct 2024 15:01:02 -0400 Subject: [PATCH 10/17] restrict push to kb action to only fire if docs change (#296) --- .github/workflows/docs-push.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index ede5f65d..76843b32 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -2,6 +2,9 @@ name: Push docs to knowledgebase on: push: branches: master + paths: + - "docs/**" + - ".github/workflows/docs-push.yml" jobs: Copy-docs: From c4880410a4aa21d957f9aeb39691d66c438d1230 Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:09:56 +0300 Subject: [PATCH 11/17] Update biometric-plugin.md --- docs/biometric-plugin.md | 49 ++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/docs/biometric-plugin.md b/docs/biometric-plugin.md index a680a99e..d4d345e3 100644 --- a/docs/biometric-plugin.md +++ b/docs/biometric-plugin.md @@ -1,8 +1,10 @@ -# Purpose +# Biometric Plugin + +## Purpose The biometrics plugin provides a way to perform credential verification using the user's biometric data. It is useful to guarantee that only the biometric holder can perform the verification. -# How to trigger a biometric verification +## How to trigger a biometric verification To trigger a biometric verification, you need to use a verification template that asks for the biometric attributes. Check the following example: @@ -51,8 +53,10 @@ The presence of the following fields should trigger the biometric check: } ``` -# How to enable the biometric plugin in the wallet +## How to enable the biometric plugin in the wallet + To enable the biometric plugin in a white-label wallet, you need to edit the following file src/wallet-sdk-configs.ts and add your configuration: + ```typescript import { BiometricsPluginConfigs } from "@docknetwork/wallet-sdk-react-native/lib/default-biometrics-plugin"; export const biometricsPluginConfigs: BiometricsPluginConfigs = { @@ -71,29 +75,44 @@ export const biometricsPluginConfigs: BiometricsPluginConfigs = { ``` +## Credential expiration -# Credential expiration Credential expiration allows the biometric service provider to specify a maximum length to the validity of a biometric check credential. If the verifier wants to force a refresh of the biometric check more frequently, the verifier can check the credential creation timestamp during verification to ensure it’s within their business rules. -# Credential types +## Credential types + This plugin uses two types of credentials to perform the biometric verification: -- Enrollment Credential: This optional credential contains the biometric data of the user. The biometric data is stored in the credential subject field and will be used to perform the biometric match. -- Biometric Match Credential: This credential is issued by the biometric plugin after the biometric match. It contains the biometric ID, the issuer, and the creation date. The verifier can use this credential to check if the biometric match was performed recently and by the same issuer, and it will not contain any biometric data. +* Enrollment Credential: This optional credential contains the biometric data of the user. The biometric data is stored in the credential subject field and will be used to perform the biometric match. +* Biometric Match Credential: This credential is issued by the biometric plugin after the biometric match. It contains the biometric ID, the issuer, and the creation date. The verifier can use this credential to check if the biometric match was performed recently and by the same issuer, and it will not contain any biometric data. + +## How to bind a biometric to a credential -# How to bind a biometric to a credential Before issuing a credential, the issuer may request to verify the biometric check credential. If a valid credential does not exist, the wallet will trigger the biometric plugin to confirm the biometric and issue a credential. -The biometric check credential needs a unique binding ID that can only be generated by that specific user. The issuer can then include in the primary credential the biometric ID and biometric issuer as attributes that bind that credential to that holder's biometric. +The biometric check credential needs a unique binding ID that can only be generated by that specific user. The issuer can then include in the primary credential, the biometric ID and biometric issuer as attributes that bind that credential to that holder's biometric. At the time of verification, the verifier can request the biometric check credential along with the primary credential. If the biometric check credential is recent enough, from the same issuer, and contains the same biometric ID, then the verifier can know it is the same holder presenting the credential. -The biometric ID should not contain the user's actual biometric information. When enrolling a holder in the biometric service, it might be useful to issue an enrollment credential containing the biometric template, the generated biometric ID, and any other needed information to identify a returning user. This credential can be verified to get the user's information before checking their biometric. By storing this information with the holder, it avoids the biometric service having to store that PII outside of the control of the holder. The holder should only share a biometric enrollment credential with the biometric service that issued it. +The biometric ID should not contain the user's actual biometric information. When enrolling a holder in the biometric service, it might be useful to issue an enrolment credential containing the biometric template, the generated biometric ID and any other needed information to identify a returning user. This credential can be verified to get the user's information before checking their biometric. By storing this information with the holder, it avoids the biometric service having to store that PII outside of the control of the holder. The holder should only share a biometric enrollment credential with the biometric service that issued it. + +## Using the Biometric Service Plugin + +* Create a [Dock API key](../../dock-certs/creating-api-keys-and-webhook-endpoints.md) +* Wrap the Dock API in your mobile API (which is usually protected with an app username / password) +* When a specific install does a biometric check, call your mobile API to issue a biometric credential + * The biometric binding nested attributes in the primary credential should include the ecosystem and biometric issuer alongside the biometric ID + * Your mobile API calls the Dock API to do issuance to the DID + * In order to use the ecosystem definition of the credentials, the Dock API should be used to query the ecosystem that is found in the credential for the “\*biometric check” schema + * Mobile API should include the DID that the credential is pushed to + * This allows the biometric check credential to be managed in the ecosystem where other participants can rely on it and VPI can be enforced +* Biometric Service Plugin monitors credentials received. When a new biometric check credential is received, old ones can be deleted from wallet storage. +* If biometric data should not leave the device, then the biometric service provider plugin can do a local verification of the biometric enrollment credential using the credential SDK. The biometric enrollment credential is managed independent from the ecosystem, as it should only be verified by the biometric provider. -# Adding a custom biometric provider -Adding a custom biometric provider will require the development of the plugin following the interface defined at packages/react-native/lib/default-biometrics-plugin.ts. The plugin should implement the following methods: +## Adding a custom biometric provider -- hasProofOfBiometrics: Checks if the verification template is asking for biometric attributes. -- enrollBiometrics: Enrolls the biometric data. -- matchBiometrics: Performs the biometric match and if it is valid, returns a biometric match credential. It will try to reuse an existing biometric match credential if it is still valid, otherwise it will remove the expired credential and issue a new one. +Adding a custom biometric provider will require the development of the plugin following the interface defined at [packages/react-native/lib/default-biometrics-plugin.ts](https://github.com/docknetwork/react-native-sdk/blob/master/packages/react-native/lib/default-biometrics-plugin.ts). The plugin should implement the following methods: +* hasProofOfBiometrics: Checks if the verification template is asking for biometric attributes. +* enrollBiometrics: Enrolls the biometric data. +* matchBiometrics: Performs the biometric match and if it is valid, returns a biometric match credential. It will try to reuse an existing biometric match credential if it is still valid, otherwise it will remove the expired credential and issue a new one. From 8a41a7c7efa1e5d32a9e58e681a684eeff325eff Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:13:44 +0300 Subject: [PATCH 12/17] Update ecosystem-tools.md --- docs/ecosystem-tools.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/ecosystem-tools.md b/docs/ecosystem-tools.md index 56376d9a..e67240bc 100644 --- a/docs/ecosystem-tools.md +++ b/docs/ecosystem-tools.md @@ -1,12 +1,14 @@ # Ecosystem Tools + You can find the implementation of ecosystem tools in the following location: -File Path: packages/core/src/ecosystem-tools.ts +File Path: [packages/core/src/ecosystem-tools.ts](https://github.com/docknetwork/react-native-sdk/blob/5dfbcb197b848802478d2f7a697286a8c3c28823/packages/core/src/ecosystem-tools.ts#L4) + ## Usage Example + Below is an example demonstrating how to use getEcosystems to retrieve ecosystem information based on an issuer's DID. -Importing the Function -First, ensure you import getEcosystems from the SDK: +Importing the Function First, ensure you import getEcosystems from the SDK: ```js import {getEcosystems} from '@docknetwork/wallet-sdk-core/src/ecosystem-tools'; @@ -26,6 +28,7 @@ fetchEcosystemDetails(); ``` ## Expected Output + When you run the above code, you should expect an output similar to this: ```json @@ -37,10 +40,11 @@ When you run the above code, you should expect an output similar to this: } } ``` + This JSON output contains the details of the ecosystems associated with the given issuerDID. ## Integration Tests + For more examples and usage, please refer to the integration test at: -Test File Path: integration-tests/ecosystem-tools.test.ts -This test file provides comprehensive examples on how to interact with ecosystem tools effectively. \ No newline at end of file +Test File Path: https://github.com/docknetwork/react-native-sdk/blob/master/integration-tests/ecosystem-tools.test.ts This test file provides comprehensive examples on how to interact with ecosystem tools effectively. From 552121c62d9224c365b4c3069b52a87e26713abe Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:46:30 +0300 Subject: [PATCH 13/17] Update docs-push.yml Added the examples folder as well --- .github/workflows/docs-push.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index 76843b32..77c31c81 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -27,6 +27,8 @@ jobs: run: | # Specify the files or directories you want to copy cp -r docs/* knowledge-base/developer-documentation/wallet-sdk + cp README.md knowledge-base/developer-documentation/wallet-sdk + cp -r examples/* knowledge-base/developer-documentation/wallet-sdk - name: Get branch name id: get_branch From 2f9c7dd3f3a179f23060b4ea1f7557d84f719fac Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:58:31 +0300 Subject: [PATCH 14/17] Update docs-push.yml --- .github/workflows/docs-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index 77c31c81..6dcc88fd 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -28,7 +28,7 @@ jobs: # Specify the files or directories you want to copy cp -r docs/* knowledge-base/developer-documentation/wallet-sdk cp README.md knowledge-base/developer-documentation/wallet-sdk - cp -r examples/* knowledge-base/developer-documentation/wallet-sdk + cp -r examples/ knowledge-base/developer-documentation/wallet-sdk - name: Get branch name id: get_branch From d0f0ca0a446bd91256fc92a37a9ce49c8c58cdab Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:15:23 +0300 Subject: [PATCH 15/17] Update README.md Updating the readme to match the knowledgebase. --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7fea2643..99b4ba8c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,14 @@ # Dock Wallet SDK -Using [polkadot-js](https://polkadot.js.org/) libraries in React Native is a challenge, due to a lack of WebAssembly support. +The [Wallet SDK](https://github.com/docknetwork/react-native-sdk) enables you to build a Verifiable Credentials wallet inside your app and allows your users to receive, store, and manage their DOCK tokens too. This was built for native applications with added support for Polkadot-JS. The Dock Wallet SDK handles all the Polkadot Web Assembly in a WebView, sending messages to the React Native thread through a JSON RPC layer. -All you need to do is wrap your app in a `WalletSDKProvider` and start building your Polkadot wallet. +To use the wallet-sdk, all you need to do is wrap your app in a `WalletSDKProvider` and start building your wallet. + +Dock Mobile SDK supports devices that have Android 8.1 or higher and iOS 11 or higher. + +Using [polkadot-js](https://polkadot.js.org/) libraries in React Native is a challenge, due to the lack of WebAssembly support. ## Installation ```js From b41fafbd27908e63c1f636cf609227fb58b27246 Mon Sep 17 00:00:00 2001 From: Maycon Date: Tue, 22 Oct 2024 11:52:21 -0300 Subject: [PATCH 16/17] feat(DCKW-577): use the API for trust registry lookups --- integration-tests/ecosystem-tools.test.ts | 19 ++++++++- packages/core/src/ecosystem-tools.ts | 47 +++++++++++++++++------ 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/integration-tests/ecosystem-tools.test.ts b/integration-tests/ecosystem-tools.test.ts index 5a16fef0..3f82d044 100644 --- a/integration-tests/ecosystem-tools.test.ts +++ b/integration-tests/ecosystem-tools.test.ts @@ -1,6 +1,6 @@ import {IWallet} from '@docknetwork/wallet-sdk-core/lib/types'; import {closeWallet, getWallet} from './helpers/wallet-helpers'; -import {getEcosystems} from '@docknetwork/wallet-sdk-core/src/ecosystem-tools'; +import {getEcosystems, getVerifiers} from '@docknetwork/wallet-sdk-core/src/ecosystem-tools'; const biometricCredential = { '@context': [ @@ -76,6 +76,7 @@ describe('BBS+ presentations', () => { const result = await getEcosystems({ issuerDID: biometricCredential.issuer.id, + networkId: 'testnet', }); console.log(result); @@ -95,6 +96,22 @@ describe('BBS+ presentations', () => { '0xc5671b2d1552db9b47a3501109ddbeb861a55fe3f7a0cb7a26791203abe9fcc8' ].name, ).toBe('clarity partners'); + + }); + + it('should fetch verifiers for the given registry', async () => { + + const result = await getVerifiers({ + trustRegistryId: '0xdbba3dec1cb5523760480d430c3f18d96848f93a95662944a296a1753ef2860d', + schemaId: 'https://schema.dock.io/BankIdentity-V5-1721219465285.json', + networkId: 'testnet', + }); + + console.log(result); + + expect(result.length).toBeGreaterThan(0); + expect(result).toContain('did:dock:5Fv9Gxbf37DdiNrT31zKTM7ryf8H4psoP3XXxtmVuijNiTTS'); + }); afterAll(() => closeWallet()); diff --git a/packages/core/src/ecosystem-tools.ts b/packages/core/src/ecosystem-tools.ts index 28169d70..21e47568 100644 --- a/packages/core/src/ecosystem-tools.ts +++ b/packages/core/src/ecosystem-tools.ts @@ -1,35 +1,60 @@ import {dockService} from '@docknetwork/wallet-sdk-wasm/src/services/dock'; import {trustRegistryService} from '@docknetwork/wallet-sdk-wasm/src/services/trust-registry'; +import assert from 'assert'; +import axios from 'axios'; + + +function getApiURL(networkId) { + return networkId === 'mainnet' ? 'https://api.dock.io' : 'https://api-testnet.dock.io'; +} export async function getEcosystems({ issuerDID, verifierDID, schemaId, + networkId, }: { + networkId: string; issuerDID?: string; verifierDID?: string; schemaId?: string; }) { - await dockService.ensureDockReady(); - + assert(!!networkId, 'networkId is required'); + try { - return await trustRegistryService.getTrustRegistries({issuerDID, verifierDID, schemaId}); + // TODO: Use the SDK to fetch ecosystems when it's available + const {data} = await axios.post(`${getApiURL(networkId)}/trust-registries/query`,{ + issuerDID, + verifierDID, + schemaId, + }) + + const registries = {} + + data.forEach((registry) => { + registries[registry.id] = registry; + }); + + return registries; } catch (error) { console.log('error', error); return []; } } -export async function getVerifiers({trustRegistryId, issuerDID, schemaId}) { - await dockService.ensureDockReady(); +export async function getVerifiers({trustRegistryId, issuerDID, schemaId, networkId}: { + trustRegistryId: string; + issuerDID?: string; + schemaId?: string; + networkId: string; +}) { + assert(!!networkId, 'networkId is required'); + assert(!!trustRegistryId, 'trustRegistryId is required'); try { - const verifiers = await trustRegistryService.getTrustRegistryVerifiers({ - schemaId, - issuerDID: issuerDID, - trustRegistryId, - }); - return verifiers; + // TODO: Use the SDK to fetch verifiers when it's available + const { data } = await axios.get(`${getApiURL(networkId)}/trust-registries/${trustRegistryId}/verifiers?schemaId=${encodeURIComponent(schemaId)}&issuerDID=${issuerDID}`); + return data; } catch (error) { console.log('error', error); return []; From afcad5b808ef63411bae94f02f724b09ba1b5300 Mon Sep 17 00:00:00 2001 From: AgneCaunt <139773510+AgneCaunt@users.noreply.github.com> Date: Tue, 22 Oct 2024 19:27:37 +0300 Subject: [PATCH 17/17] Update README.md --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 99b4ba8c..c7cb1683 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@ # Dock Wallet SDK -The [Wallet SDK](https://github.com/docknetwork/react-native-sdk) enables you to build a Verifiable Credentials wallet inside your app and allows your users to receive, store, and manage their DOCK tokens too. This was built for native applications with added support for Polkadot-JS. - -The Dock Wallet SDK handles all the Polkadot Web Assembly in a WebView, sending messages to the React Native thread through a JSON RPC layer. +The [Wallet SDK](https://github.com/docknetwork/react-native-sdk) enables you to build a Verifiable Credentials wallet inside your app and allows your users to receive, store, and manage their DOCK tokens too. This was built for mobile applications with added support for Polkadot-JS. To use the wallet-sdk, all you need to do is wrap your app in a `WalletSDKProvider` and start building your wallet. -Dock Mobile SDK supports devices that have Android 8.1 or higher and iOS 11 or higher. - Using [polkadot-js](https://polkadot.js.org/) libraries in React Native is a challenge, due to the lack of WebAssembly support. +The Dock Wallet SDK handles all the Polkadot Web Assembly in a WebView, sending messages to the React Native thread through a JSON RPC layer. + +Dock Mobile SDK supports devices that have Android 8.1 or higher and iOS 11 or higher. ## Installation ```js