From a4369854ded8338169dfaf87e8d0f46a69315787 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Mon, 14 Oct 2024 10:34:15 -0500 Subject: [PATCH 1/7] rename pkg to client-sdk Signed-off-by: Jonathan Alvarez --- tee-worker/identity/client-sdk/README.md | 6 ++--- tee-worker/identity/client-sdk/package.json | 2 +- .../{enclave => client-sdk}/.eslintrc.json | 0 .../{enclave => client-sdk}/CHANGELOG.md | 0 .../packages/{enclave => client-sdk}/LICENSE | 0 .../{enclave => client-sdk}/README.md | 0 .../{enclave => client-sdk}/docs/.nojekyll | 0 .../{enclave => client-sdk}/docs/README.md | 0 .../docs/classes/Enclave.md | 0 .../docs/modules/request.md | 0 .../{enclave => client-sdk}/jest.config.ts | 4 ++-- .../{enclave => client-sdk}/package.json | 4 ++-- .../{enclave => client-sdk}/project.json | 22 +++++++++---------- .../{enclave => client-sdk}/src/index.ts | 0 .../src/lib/__test__/id-graph-decoder.test.ts | 0 .../src/lib/__test__/payload-signing.test.ts | 0 .../{enclave => client-sdk}/src/lib/config.ts | 0 .../src/lib/enclave.ts | 14 +++++------- .../src/lib/requests/get-enclave-nonce.ts | 0 .../src/lib/requests/get-id-graph-hash.ts | 0 .../src/lib/requests/get-id-graph.request.ts | 0 .../requests/get-last-registered-enclave.ts | 0 .../src/lib/requests/index.ts | 0 .../link-identity-callback.request.ts | 0 .../src/lib/requests/link-identity.request.ts | 0 .../lib/requests/request-batch-vc.request.ts | 0 .../requests/set-identity-networks.request.ts | 0 .../src/lib/type-creators/id-graph.ts | 0 .../src/lib/type-creators/key-aes-output.ts | 0 .../type-creators/litentry-identity.test.ts | 0 .../lib/type-creators/litentry-identity.ts | 0 .../litentry-multi-signature.test.ts | 0 .../type-creators/litentry-multi-signature.ts | 0 .../src/lib/type-creators/nonce.test.ts | 0 .../src/lib/type-creators/nonce.ts | 0 .../src/lib/type-creators/request.ts | 0 .../lib/type-creators/trusted-call.test.ts | 0 .../src/lib/type-creators/trusted-call.ts | 0 .../lib/type-creators/validation-data.test.ts | 0 .../src/lib/type-creators/validation-data.ts | 8 +++---- .../lib/util/calculate-id-graph-hash.test.ts | 0 .../src/lib/util/calculate-id-graph-hash.ts | 0 .../lib/util/create-payload-to-sign.test.ts | 0 .../src/lib/util/create-payload-to-sign.ts | 2 +- .../src/lib/util/decode-signature.ts | 0 .../src/lib/util/get-signature-crypto-type.ts | 0 .../src/lib/util/safely-decode-option.test.ts | 0 .../src/lib/util/safely-decode-option.ts | 0 .../src/lib/util/shielding-key.ts | 0 .../src/lib/util/types.ts | 5 ++--- .../src/lib/util/u8aToBase64Url.ts | 0 .../src/lib/util/verify-signature.ts | 0 .../{enclave => client-sdk}/tsconfig.json | 0 .../{enclave => client-sdk}/tsconfig.lib.json | 0 .../tsconfig.spec.json | 0 .../{enclave => client-sdk}/typedoc.json | 0 .../client-sdk/packages/vc-sdk/jest.config.ts | 4 +--- tee-worker/identity/client-sdk/project.json | 2 +- .../identity/client-sdk/tsconfig.base.json | 2 +- 59 files changed, 34 insertions(+), 41 deletions(-) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/.eslintrc.json (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/CHANGELOG.md (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/LICENSE (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/README.md (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/docs/.nojekyll (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/docs/README.md (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/docs/classes/Enclave.md (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/docs/modules/request.md (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/jest.config.ts (79%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/package.json (89%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/project.json (68%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/index.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/__test__/id-graph-decoder.test.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/__test__/payload-signing.test.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/config.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/enclave.ts (95%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/requests/get-enclave-nonce.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/requests/get-id-graph-hash.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/requests/get-id-graph.request.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/requests/get-last-registered-enclave.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/requests/index.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/requests/link-identity-callback.request.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/requests/link-identity.request.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/requests/request-batch-vc.request.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/requests/set-identity-networks.request.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/id-graph.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/key-aes-output.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/litentry-identity.test.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/litentry-identity.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/litentry-multi-signature.test.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/litentry-multi-signature.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/nonce.test.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/nonce.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/request.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/trusted-call.test.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/trusted-call.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/validation-data.test.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/type-creators/validation-data.ts (97%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/calculate-id-graph-hash.test.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/calculate-id-graph-hash.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/create-payload-to-sign.test.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/create-payload-to-sign.ts (96%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/decode-signature.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/get-signature-crypto-type.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/safely-decode-option.test.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/safely-decode-option.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/shielding-key.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/types.ts (62%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/u8aToBase64Url.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/src/lib/util/verify-signature.ts (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/tsconfig.json (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/tsconfig.lib.json (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/tsconfig.spec.json (100%) rename tee-worker/identity/client-sdk/packages/{enclave => client-sdk}/typedoc.json (100%) diff --git a/tee-worker/identity/client-sdk/README.md b/tee-worker/identity/client-sdk/README.md index 4cde2afe6d..bd900311d7 100644 --- a/tee-worker/identity/client-sdk/README.md +++ b/tee-worker/identity/client-sdk/README.md @@ -1,6 +1,6 @@ ![Logo](https://avatars.githubusercontent.com/u/51339301?s=200&v=4) -# Litentry Client SDK +# Litentry Client Packages This repository contains packages that are published on NPM for dApps to interact with the Litentry Protocol. @@ -8,5 +8,5 @@ Learn more about it on [Litentry's official documentation](https://docs.litentry ## Packages -- `@litentry/enclave` ([go-to](packages/enclave/README.md)): provides helpers for dApps to interact with the Litentry Protocol's Enclave -- `@litentry/vc-sdk` ([go-to](packages/vc-sdk/README.md)): provides the common functionality to help dApps parse and validate Litentry issued Verifiable Credentials. +- `@litentry/client-sdk` ([go-to](packages/enclave/README.md)): provides helpers for dApps to interact with the Litentry Protocol +- `@litentry/chaindata` ([go-to](packages/chaindata/README.md)): provides chain information of Litentry networks. diff --git a/tee-worker/identity/client-sdk/package.json b/tee-worker/identity/client-sdk/package.json index cf45d8b956..b44240d43e 100644 --- a/tee-worker/identity/client-sdk/package.json +++ b/tee-worker/identity/client-sdk/package.json @@ -1,5 +1,5 @@ { - "name": "client-sdk", + "name": "@litentry-client-sdk/source", "version": "0.0.0", "license": "MIT", "scripts": { diff --git a/tee-worker/identity/client-sdk/packages/enclave/.eslintrc.json b/tee-worker/identity/client-sdk/packages/client-sdk/.eslintrc.json similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/.eslintrc.json rename to tee-worker/identity/client-sdk/packages/client-sdk/.eslintrc.json diff --git a/tee-worker/identity/client-sdk/packages/enclave/CHANGELOG.md b/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/CHANGELOG.md rename to tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md diff --git a/tee-worker/identity/client-sdk/packages/enclave/LICENSE b/tee-worker/identity/client-sdk/packages/client-sdk/LICENSE similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/LICENSE rename to tee-worker/identity/client-sdk/packages/client-sdk/LICENSE diff --git a/tee-worker/identity/client-sdk/packages/enclave/README.md b/tee-worker/identity/client-sdk/packages/client-sdk/README.md similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/README.md rename to tee-worker/identity/client-sdk/packages/client-sdk/README.md diff --git a/tee-worker/identity/client-sdk/packages/enclave/docs/.nojekyll b/tee-worker/identity/client-sdk/packages/client-sdk/docs/.nojekyll similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/docs/.nojekyll rename to tee-worker/identity/client-sdk/packages/client-sdk/docs/.nojekyll diff --git a/tee-worker/identity/client-sdk/packages/enclave/docs/README.md b/tee-worker/identity/client-sdk/packages/client-sdk/docs/README.md similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/docs/README.md rename to tee-worker/identity/client-sdk/packages/client-sdk/docs/README.md diff --git a/tee-worker/identity/client-sdk/packages/enclave/docs/classes/Enclave.md b/tee-worker/identity/client-sdk/packages/client-sdk/docs/classes/Enclave.md similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/docs/classes/Enclave.md rename to tee-worker/identity/client-sdk/packages/client-sdk/docs/classes/Enclave.md diff --git a/tee-worker/identity/client-sdk/packages/enclave/docs/modules/request.md b/tee-worker/identity/client-sdk/packages/client-sdk/docs/modules/request.md similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/docs/modules/request.md rename to tee-worker/identity/client-sdk/packages/client-sdk/docs/modules/request.md diff --git a/tee-worker/identity/client-sdk/packages/enclave/jest.config.ts b/tee-worker/identity/client-sdk/packages/client-sdk/jest.config.ts similarity index 79% rename from tee-worker/identity/client-sdk/packages/enclave/jest.config.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/jest.config.ts index 8e11a5be43..4e8d711fcd 100644 --- a/tee-worker/identity/client-sdk/packages/enclave/jest.config.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/jest.config.ts @@ -1,13 +1,13 @@ /* eslint-disable */ export default { - displayName: 'enclave', + displayName: 'client-sdk', preset: '../../jest.preset.js', testEnvironment: 'node', transform: { '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], }, moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/packages/enclave', + coverageDirectory: '../../coverage/packages/client-sdk', transformIgnorePatterns: ['node_modules/(?!(@litentry/|.pnpm/@litentry)).*'], moduleNameMapper: {}, }; diff --git a/tee-worker/identity/client-sdk/packages/enclave/package.json b/tee-worker/identity/client-sdk/packages/client-sdk/package.json similarity index 89% rename from tee-worker/identity/client-sdk/packages/enclave/package.json rename to tee-worker/identity/client-sdk/packages/client-sdk/package.json index a1994c40ed..6a67d3aa6d 100644 --- a/tee-worker/identity/client-sdk/packages/enclave/package.json +++ b/tee-worker/identity/client-sdk/packages/client-sdk/package.json @@ -1,6 +1,6 @@ { - "name": "@litentry/enclave", - "description": "This package provides helpers for dApps to interact with the Litentry Protocol Enclave.", + "name": "@litentry/client-sdk", + "description": "This package provides helpers for dApps to interact with the Litentry Protocol.", "version": "4.3.0", "license": "GPL-3.0-or-later", "dependencies": {}, diff --git a/tee-worker/identity/client-sdk/packages/enclave/project.json b/tee-worker/identity/client-sdk/packages/client-sdk/project.json similarity index 68% rename from tee-worker/identity/client-sdk/packages/enclave/project.json rename to tee-worker/identity/client-sdk/packages/client-sdk/project.json index 850ff988d1..c3b20eb28c 100644 --- a/tee-worker/identity/client-sdk/packages/enclave/project.json +++ b/tee-worker/identity/client-sdk/packages/client-sdk/project.json @@ -1,7 +1,7 @@ { - "name": "enclave", + "name": "client-sdk", "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/enclave/src", + "sourceRoot": "packages/client-sdk/src", "projectType": "library", "targets": { "publish": { @@ -16,19 +16,19 @@ "{options.outputPath}" ], "options": { - "outputPath": "dist/packages/enclave", - "main": "packages/enclave/src/index.ts", - "tsConfig": "packages/enclave/tsconfig.lib.json", + "outputPath": "dist/packages/client-sdk", + "main": "packages/client-sdk/src/index.ts", + "tsConfig": "packages/client-sdk/tsconfig.lib.json", "assets": [ - "packages/enclave/*.md", - "packages/enclave/LICENSE" + "packages/client-sdk/*.md", + "packages/client-sdk/LICENSE" ] } }, "generate-doc": { "executor": "nx:run-commands", "options": { - "cwd": "./packages/enclave", + "cwd": "./packages/client-sdk", "command": "typedoc --options ./typedoc.json" } }, @@ -39,8 +39,8 @@ ], "options": { "lintFilePatterns": [ - "packages/enclave/src/**/*.ts", - "packages/enclave/package.json" + "packages/client-sdk/src/**/*.ts", + "packages/client-sdk/package.json" ] } }, @@ -50,7 +50,7 @@ "{workspaceRoot}/coverage/{projectRoot}" ], "options": { - "jestConfig": "packages/enclave/jest.config.ts", + "jestConfig": "packages/client-sdk/jest.config.ts", "passWithNoTests": true }, "configurations": { diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/index.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/index.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/index.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/index.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/__test__/id-graph-decoder.test.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/__test__/id-graph-decoder.test.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/__test__/id-graph-decoder.test.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/__test__/id-graph-decoder.test.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/__test__/payload-signing.test.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/__test__/payload-signing.test.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/__test__/payload-signing.test.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/__test__/payload-signing.test.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/config.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/config.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/config.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/config.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/enclave.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/enclave.ts similarity index 95% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/enclave.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/enclave.ts index 8a5294d6ee..25db2b90f6 100644 --- a/tee-worker/identity/client-sdk/packages/enclave/src/lib/enclave.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/enclave.ts @@ -29,19 +29,15 @@ const log = * - Retrieve the Enclave's Shielding Key. (1) * - Retrieve the Enclave's MREnclave value which is used as the Shard value. (1) * - Encrypt data using the Enclave's Shielding Key. - * - Send request to the Enclave. This is also known as Direct Invocation. (2) + * - Send request to the Enclave. * - * (1) This is done by querying the Parachain. Its shielding key can be retrieved directly but - * since the MREnclave cannot we opted to leave both from the Parachain in the meantime. - * - * (2) This is done by using a reverse proxy API. By default, it expects the proxy API to be - * running on `/api/enclave`. See `createEnclaveHttpProxyHandler` for more details. + * (1) Querying from the Parachain, instead of directly from the Enclave Worker itself helps + * ensuring clients are connected to a trusted worker. * * @example * ```ts - * import { Enclave } from '@litentry/enclave'; + * import { enclave } from '@litentry/client-sdk'; * - * const enclave = new Enclave(); // same as the `enclave` variable exported from this module * const shard = await enclave.getShard(api); * const key = await enclave.getKey(api); * @@ -50,7 +46,7 @@ const log = * // Encrypt data using the Enclave's Shielding Key * const encrypted = await enclave.encrypt(api, { cleartext: new Uint8Array([1, 2, 3]) }); * - * // Send request to the Enclave directly. This is also known as Direct Invocation. + * // Send request to the Enclave. * const response = await enclave.send({ * jsonrpc: '2.0', * method: 'author_submitAndWatch', diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/get-enclave-nonce.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-enclave-nonce.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/get-enclave-nonce.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-enclave-nonce.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/get-id-graph-hash.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-id-graph-hash.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/get-id-graph-hash.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-id-graph-hash.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/get-id-graph.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-id-graph.request.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/get-id-graph.request.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-id-graph.request.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/get-last-registered-enclave.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-last-registered-enclave.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/get-last-registered-enclave.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/get-last-registered-enclave.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/index.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/index.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/index.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/link-identity-callback.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/link-identity-callback.request.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/link-identity-callback.request.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/link-identity-callback.request.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/link-identity.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/link-identity.request.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/link-identity.request.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/link-identity.request.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/request-batch-vc.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/request-batch-vc.request.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/request-batch-vc.request.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/request-batch-vc.request.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/set-identity-networks.request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/set-identity-networks.request.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/requests/set-identity-networks.request.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/requests/set-identity-networks.request.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/id-graph.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/id-graph.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/id-graph.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/id-graph.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/key-aes-output.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/key-aes-output.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/key-aes-output.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/key-aes-output.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/litentry-identity.test.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/litentry-identity.test.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/litentry-identity.test.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/litentry-identity.test.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/litentry-identity.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/litentry-identity.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/litentry-identity.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/litentry-identity.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/litentry-multi-signature.test.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/litentry-multi-signature.test.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/litentry-multi-signature.test.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/litentry-multi-signature.test.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/litentry-multi-signature.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/litentry-multi-signature.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/litentry-multi-signature.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/litentry-multi-signature.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/nonce.test.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/nonce.test.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/nonce.test.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/nonce.test.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/nonce.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/nonce.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/nonce.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/nonce.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/request.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/request.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/request.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/request.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/trusted-call.test.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.test.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/trusted-call.test.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.test.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/trusted-call.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/trusted-call.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/trusted-call.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/validation-data.test.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/validation-data.test.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/validation-data.test.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/validation-data.test.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/validation-data.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/validation-data.ts similarity index 97% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/validation-data.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/validation-data.ts index 8c00c0698e..cdd2f58558 100644 --- a/tee-worker/identity/client-sdk/packages/enclave/src/lib/type-creators/validation-data.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/type-creators/validation-data.ts @@ -80,8 +80,8 @@ export type EmailProof = { * * @example Web3 * ```ts - * import { createLitentryValidationDataType } from '@litentry/enclave'; - * import type { Web3Proof } from '@litentry/enclave'; + * import { createLitentryValidationDataType } from '@litentry/client-sdk'; + * import type { Web3Proof } from '@litentry/client-sdk'; * * const userAddress = '0x123'; * @@ -102,8 +102,8 @@ export type EmailProof = { * * @example Twitter * ```ts - * import { createLitentryValidationDataType } from '@litentry/enclave'; - * import type { TwitterProof } from '@litentry/enclave'; + * import { createLitentryValidationDataType } from '@litentry/client-sdk'; + * import type { TwitterProof } from '@litentry/client-sdk'; * * const userHandle = '@litentry'; * diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/calculate-id-graph-hash.test.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/calculate-id-graph-hash.test.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/calculate-id-graph-hash.test.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/calculate-id-graph-hash.test.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/calculate-id-graph-hash.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/calculate-id-graph-hash.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/calculate-id-graph-hash.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/calculate-id-graph-hash.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/create-payload-to-sign.test.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/create-payload-to-sign.test.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/create-payload-to-sign.test.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/create-payload-to-sign.test.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/create-payload-to-sign.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/create-payload-to-sign.ts similarity index 96% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/create-payload-to-sign.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/create-payload-to-sign.ts index 0d7c27dde2..ec83234f8a 100644 --- a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/create-payload-to-sign.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/create-payload-to-sign.ts @@ -6,7 +6,7 @@ import type { U8aLike } from '@polkadot/util/types'; import type { Index } from '@polkadot/types/interfaces'; /** - * Construct the message users have to sign to authorize enclave's requests + * Construct the message users have to sign to authorize Enclave's requests */ export function createPayloadToSign(args: { who: LitentryIdentity; diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/decode-signature.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/decode-signature.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/decode-signature.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/decode-signature.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/get-signature-crypto-type.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/get-signature-crypto-type.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/get-signature-crypto-type.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/get-signature-crypto-type.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/safely-decode-option.test.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/safely-decode-option.test.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/safely-decode-option.test.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/safely-decode-option.test.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/safely-decode-option.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/safely-decode-option.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/safely-decode-option.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/safely-decode-option.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/shielding-key.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/shielding-key.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/shielding-key.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/shielding-key.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/types.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/types.ts similarity index 62% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/types.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/types.ts index 07460be278..f6214407f8 100644 --- a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/types.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/types.ts @@ -5,9 +5,8 @@ export type JsonRpcRequest = { method: string; params: Array; /** - * Heads-up: it should work with string and any number but we found out - * that responses are not coming back if the number is too big or a string :sad-panda: - * @see Enclave Reverse Proxy `/apps/identity-hub/pages/api/enclave.ts` + * Use sequential numbers starting from 1 for consecutive requests. + * For one-time request that closes connections right away, using `1` is ok. */ id?: number; }; diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/u8aToBase64Url.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/u8aToBase64Url.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/u8aToBase64Url.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/u8aToBase64Url.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/src/lib/util/verify-signature.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/verify-signature.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/src/lib/util/verify-signature.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/util/verify-signature.ts diff --git a/tee-worker/identity/client-sdk/packages/enclave/tsconfig.json b/tee-worker/identity/client-sdk/packages/client-sdk/tsconfig.json similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/tsconfig.json rename to tee-worker/identity/client-sdk/packages/client-sdk/tsconfig.json diff --git a/tee-worker/identity/client-sdk/packages/enclave/tsconfig.lib.json b/tee-worker/identity/client-sdk/packages/client-sdk/tsconfig.lib.json similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/tsconfig.lib.json rename to tee-worker/identity/client-sdk/packages/client-sdk/tsconfig.lib.json diff --git a/tee-worker/identity/client-sdk/packages/enclave/tsconfig.spec.json b/tee-worker/identity/client-sdk/packages/client-sdk/tsconfig.spec.json similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/tsconfig.spec.json rename to tee-worker/identity/client-sdk/packages/client-sdk/tsconfig.spec.json diff --git a/tee-worker/identity/client-sdk/packages/enclave/typedoc.json b/tee-worker/identity/client-sdk/packages/client-sdk/typedoc.json similarity index 100% rename from tee-worker/identity/client-sdk/packages/enclave/typedoc.json rename to tee-worker/identity/client-sdk/packages/client-sdk/typedoc.json diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/jest.config.ts b/tee-worker/identity/client-sdk/packages/vc-sdk/jest.config.ts index 1b43e61cb4..a4d08b626c 100644 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/jest.config.ts +++ b/tee-worker/identity/client-sdk/packages/vc-sdk/jest.config.ts @@ -9,7 +9,5 @@ export default { moduleFileExtensions: ['ts', 'js', 'html'], coverageDirectory: '../../coverage/package/vc-sdk', transformIgnorePatterns: ['node_modules/(?!(@litentry/|.pnpm/@litentry)).*'], - moduleNameMapper: { - // '@litentry/enclave': '/../enclave/src', - }, + moduleNameMapper: {}, }; diff --git a/tee-worker/identity/client-sdk/project.json b/tee-worker/identity/client-sdk/project.json index ed095f0b5d..68538e2798 100644 --- a/tee-worker/identity/client-sdk/project.json +++ b/tee-worker/identity/client-sdk/project.json @@ -1,5 +1,5 @@ { - "name": "client-sdk", + "name": "@litentry-client-sdk/source", "$schema": "node_modules/nx/schemas/project-schema.json", "targets": { "local-registry": { diff --git a/tee-worker/identity/client-sdk/tsconfig.base.json b/tee-worker/identity/client-sdk/tsconfig.base.json index 658de831d9..e1cee4d502 100644 --- a/tee-worker/identity/client-sdk/tsconfig.base.json +++ b/tee-worker/identity/client-sdk/tsconfig.base.json @@ -16,7 +16,7 @@ "baseUrl": ".", "paths": { "@litentry/chaindata": ["packages/chaindata/src/index.ts"], - "@litentry/enclave": ["packages/enclave/src/index.ts"], + "packages/client-sdk": ["packages/client-sdk/src/index.ts"], "@litentry/vc-sdk": ["packages/vc-sdk/src/index.ts"] } }, From c6c1402d5f35d031d2cd1b9670c7a30f608dd84e Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Mon, 14 Oct 2024 10:45:50 -0500 Subject: [PATCH 2/7] merge vc-sdk into client-sdk Signed-off-by: Jonathan Alvarez --- .../packages/client-sdk/src/index.ts | 10 + .../validate-enclave-registry.test.ts | 0 .../vc-validator}/runtime-enclave-registry.ts | 0 .../src/lib/vc-validator}/validator.spec.ts | 0 .../src/lib/vc-validator}/validator.ts | 0 .../src/lib/vc-validator}/validator.types.ts | 5 - .../client-sdk/packages/vc-sdk/.eslintrc.json | 25 - .../client-sdk/packages/vc-sdk/CHANGELOG.md | 224 ------ .../client-sdk/packages/vc-sdk/LICENSE | 674 ------------------ .../client-sdk/packages/vc-sdk/README.md | 55 -- .../client-sdk/packages/vc-sdk/docs/.nojekyll | 1 - .../client-sdk/packages/vc-sdk/docs/README.md | 225 ------ .../client-sdk/packages/vc-sdk/jest.config.ts | 13 - .../client-sdk/packages/vc-sdk/package.json | 21 - .../client-sdk/packages/vc-sdk/project.json | 65 -- .../client-sdk/packages/vc-sdk/src/index.ts | 6 - .../vc-sdk/src/lib/validator.constants.ts | 9 - .../client-sdk/packages/vc-sdk/tsconfig.json | 24 - .../packages/vc-sdk/tsconfig.lib.json | 10 - .../packages/vc-sdk/tsconfig.spec.json | 14 - .../client-sdk/packages/vc-sdk/typedoc.json | 9 - 21 files changed, 10 insertions(+), 1380 deletions(-) rename tee-worker/identity/client-sdk/packages/{vc-sdk/src/lib => client-sdk/src/lib/vc-validator}/__tests__/validate-enclave-registry.test.ts (100%) rename tee-worker/identity/client-sdk/packages/{vc-sdk/src/lib => client-sdk/src/lib/vc-validator}/runtime-enclave-registry.ts (100%) rename tee-worker/identity/client-sdk/packages/{vc-sdk/src/lib => client-sdk/src/lib/vc-validator}/validator.spec.ts (100%) rename tee-worker/identity/client-sdk/packages/{vc-sdk/src/lib => client-sdk/src/lib/vc-validator}/validator.ts (100%) rename tee-worker/identity/client-sdk/packages/{vc-sdk/src/lib => client-sdk/src/lib/vc-validator}/validator.types.ts (90%) delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/.eslintrc.json delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/CHANGELOG.md delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/LICENSE delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/README.md delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/docs/.nojekyll delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/docs/README.md delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/jest.config.ts delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/package.json delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/project.json delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/src/index.ts delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/validator.constants.ts delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.json delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.lib.json delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.spec.json delete mode 100644 tee-worker/identity/client-sdk/packages/vc-sdk/typedoc.json diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/src/index.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/index.ts index 912bdf6ab3..714c913dc8 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/src/index.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/index.ts @@ -16,6 +16,16 @@ export * from './lib/type-creators/validation-data'; export type { IdGraph } from './lib/type-creators/id-graph'; export { ID_GRAPH_STRUCT } from './lib/type-creators/id-graph'; +// vc +export { + validateVc, + VerifiableCredentialLike, +} from './lib/vc-validator/validator'; +export { + ValidationResultDetail, + ValidationResult, +} from './lib/vc-validator/validator.types'; + // exposed utils export { calculateIdGraphHash } from './lib/util/calculate-id-graph-hash'; export { getIdGraphHash } from './lib/requests'; diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/__tests__/validate-enclave-registry.test.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/__tests__/validate-enclave-registry.test.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/__tests__/validate-enclave-registry.test.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/__tests__/validate-enclave-registry.test.ts diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/runtime-enclave-registry.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/runtime-enclave-registry.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/runtime-enclave-registry.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/runtime-enclave-registry.ts diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/validator.spec.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/validator.spec.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/validator.spec.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/validator.spec.ts diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/validator.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/validator.ts similarity index 100% rename from tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/validator.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/validator.ts diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/validator.types.ts b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/validator.types.ts similarity index 90% rename from tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/validator.types.ts rename to tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/validator.types.ts index 878a48152c..1d7f2accf4 100644 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/validator.types.ts +++ b/tee-worker/identity/client-sdk/packages/client-sdk/src/lib/vc-validator/validator.types.ts @@ -1,8 +1,3 @@ -import { NETWORKS } from './validator.constants'; -export { NETWORKS } from './validator.constants'; - -export type Network = keyof typeof NETWORKS; - /** * Defines the details of the validation result for each component of the Verifiable Credential (VC). */ diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/.eslintrc.json b/tee-worker/identity/client-sdk/packages/vc-sdk/.eslintrc.json deleted file mode 100644 index 77e7c5bc94..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/.eslintrc.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.json"], - "parser": "jsonc-eslint-parser", - "rules": { - "@nx/dependency-checks": ["error", {}] - } - } - ] -} diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/CHANGELOG.md b/tee-worker/identity/client-sdk/packages/vc-sdk/CHANGELOG.md deleted file mode 100644 index 968e953571..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/CHANGELOG.md +++ /dev/null @@ -1,224 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] - -## [3.4.0] - 2024-09-30 - -### Changed - -- Use `@litentry/parachain-api@0.9.20-4.1` and `@litentry/sidechain-api@0.9.20-4` - -## [3.3.0] - 2024-08-26 - -### Changed - -- Use `@litentry/parachain-api@0.9.19-7` - -## [3.2.0] - 2024-08-06 - -- Use `@litentry/parachain-api@0.9.18-11.2` - -## [3.1.0] - 2024-07-22 - -### Changed - -- `validator`: Use RPC call to retrieve blockHashes. - -## [3.0.0] - 2024-07-22 - -### Removed - -- Drop `parseVc`. Parsing a VC is now up to clients. - -## [2.0.2] - 2024-07-19 - -- Use `@litentry/parachain-api@0.9.18-11` and `@litentry/sidechain-api@0.9.18-11` stable versions. - -## [2.0.1] - 2024-07-17 - -### Added - -- Extend `PlatformUserSubject` to support `DarenMarket` and variations of `MagicKraft` and `KaratDao` for better backward compatibility. - -## [2.0.0] - 2024-07-15 - -- Migrate to `@litentry/parachain-api` and `@litentry/sidechain-api`. -- Distribute as ES Module -- Targets [parachain-release v0.9.18-10](https://github.com/litentry/litentry-parachain/releases/tag/v0.9.18-10) - -## Changed - -- Migrate to `@litentry/parachain-api` and `@litentry/sidechain-api` por chain types. Deprecates `@litentry/chain-types`. -- This library is now distributed as an ESModule - -## Fixed - -- `Active Discord ID-Hubber`: Update its `type` name. -- `EVM/Substrate Transaction Count`: add `SubstrateTestnet` to the list of supported networks. - -## Removed - -- Drop `@litentry/chain-types` from dependencies. - -## [1.5.0] - 2024-06-27 - -### Changed - -- `validateVc`: rely on `vc.proof.verificationMethod` to get the VC's pubKey. -- `validateVc`: for new VCs where `vc.issuer.id` is an enclave account, query the specific enclave used at the time of issuing the VC for validation. - -## [1.4.1] - 2024-06-27 - -### Changed - -- `TokenHoldingAmount` credential subject: optional `$network` and `$address`. - -## [1.4.0] - 2024-06-03 - -### Changed - -- Upgrade `@polkadot/api*`, `@polkadot/rpc*`, `@polkadot/types*` to 10.9.1, and `@polkadot/util*` to `12.5.1` - -### Removed - -- Drop unused `@polkadot/keyring` dependency. - -## [1.3.3] - 2024-06-03 - -### Fixed - -- Add `MagicCraft` to the Credential Subject `PlatformUserSubject` type. - -## [1.3.2] - 2024-05-29 - -### Added - -- Add `BEAN` to `BaseTokenHolderIITokenEnum` supported tokens. - -## [1.3.1] - 2024-05-28 - -### Fixed - -- Deps: split `devDependencies` and move `@litentry/enclave` as `peerDependency`. - -## [1.3.0] - 2024-05-27 - -### Added - -- Broad `BaseTokenHolderIITokenEnum` token support with: `ETH`, `USDC`, `ADA`, `DOGE`, `SHIB`, `UNI`, `BCH`, `ETC`, `ATOM`, `DAI`, `LEO`, `FIL`, `IMX`, `CRO`, `INJ`. - -## [1.2.0] - 2024-05-08 - -### Fixed - -- `BaseTokenAmountHolding` now support all the token names from the `TokenHoldingAmount` assertion. - -### Changed - -- The encoding of `address` clauses' is no longer validated. - -## [1.1.1] - 2024-04-22 - -### Added - -- Add further tests coverage for the feature released on 1.1.0 - -## [1.1.0] - 2024-04-22 - -### Added - -- Allow verifying Litentry VCs that were generated by Enclave running on `tee-dev` on this date. MREnclave: `0x585e6d8623b0f63706174025625adb163503863fe6f7cc9459df65cbc2097943`. - -## [1.0.1] - 2024-04-18 - -## Fixed - -- Restore a fix that mistakenly removed. The fix was a bug that was preventing legacy VC with `issuer.id` in base58 format to fail at validating. - -## [1.0.0] - 2024-04-02 - -### Changed - -- The Litentry's VC Registry was dropped. VCs' hash is no longer stored on-chain. VC Verification continues unaltered. -- Enclave's queries were migrated from `teerex` to `teebag` to match latest Litentry's runtime versions. - -### Added - -- Credential parser: support the new `assertionText`, `parachainBlockNumber`, and `sidechainBlockNumber` schema fields. -- New Credential Subjects: `WeirdoGhostGangHolder`, `TokenAmountHolder`, `Brc20TokenHolder`, `LitStakingAmountSubject`, `NFTHolderSubject`, `CryptoSummarySubject`, `VIP3CardHolderSubject`, `KaratDaoPlatformUserSubject`, `BaseNftHoldingSubject` - -### Removed - -- `result.vcRegistry` property was removed from the return value of `validateVc`. - -## [0.2.5] - 2023-11-27 - -### Added - -- New Credential's assertions support: `GenericDiscordRole`, `BnbDomainHolding`, `BnbDigitDomainClub`. -- New Credential Subjects: `GenericDiscordRole`, `SpaceID10KClubMember`, `SpaceID999ClubMember`, `SpaceIDDomainHoldingAmount`. - -### Fixed - -- Fix parsing issue `EVMVersionEarlyBird` assertions when value is false -- Fix validation logic for VC with `SoraQuiz` assertions - -### Changed - -- `validateVc` early return if signature verifying fails. - -## [0.2.4] - -Deprecated. Please upgrade to @latest. - -## [0.2.3] - 2023-11-14 - -### Fixed - -- OneBlock+ VC type update - -## [0.2.2] - 2023-11-09 - -### Added - -- Readme: Link to client-sdk-examples repository - -### Removed - -- Docs: Exclude `examples` folder from the build output - -## [0.2.1] - 2023-11-09 - -### Fixed - -- Fix the README's example of `validateVc`. -- Other documentation fixes and improvements - -### Added - -- Support SORA Quiz credential definitions' subject -- Include examples and docs folder in the build output - -## [0.1.1] - 2023-10-25 - -### Added - -- This changelog -- Validate VCs against previously registered Litentry Enclave versions and not only the current one. - -### Fixed - -- Fix bundle type definitions in the published package -- Fix type error in one of the README's examples - -## [0.1.0] - 2023-10-10 - -### Added - -- parseVc method -- validateVc method diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/LICENSE b/tee-worker/identity/client-sdk/packages/vc-sdk/LICENSE deleted file mode 100644 index f288702d2f..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/README.md b/tee-worker/identity/client-sdk/packages/vc-sdk/README.md deleted file mode 100644 index df97b47054..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# @litentry/vc-sdk - -This SDK provides the common functionality to help dApps parse and validate Litentry issued Verifiable Credentials. - -A live example of this SDK's consumer application is identity-hub (https://idhub.litentry.io) where users request and generate their VCs and reveal their obtained VCs and share the relevant VCs should they consent to 3rd party applications. - -## Install - -```bash -npm install @litentry/parachain-api @litentry/sidechain-api @litentry/vc-sdk -``` - -## Examples - -You can find more elaborated examples about the usage of this package on https://github.com/litentry/client-sdk-examples. - -Below you will find some code snippets to guide you through the main functionalities. - -### Validate Verifiable Credential (VC) - -Interaction with the Litentry parachain and TEE to validate whether the VC is an active VC issued by the Litentry. - -#### What the validateVc function do - -- The validateVc function can only verify that the VC was issued by Litentry. -- The VC's credentialSubject can be Substrate or EVM account that is support by Litentry. - -#### What the validateVc function can't do - -- The validateVc function cannot validate that the VC's credentialSubject is the current wallet account. It's SDK's consumer's responsibility to validate the id of VC's credentialSubject is equal to the wallet address. - -#### Example - -```typescript -import { WsProvider, ApiPromise } from '@polkadot/api'; -import { validateVc } from '@litentry/vc-sdk'; - -const api: ApiPromise = await ApiPromise.create({ - provider: new WsProvider('wss://tee-prod.litentry.io'), -}); -// vc json string -const vcJson = - '{"@context": "https://www.w3.org/2018/credentials/v1", "type": "VerifiableCredential", "issuer": "https://example.com/issuer", "subject": "did:example:123", "credentialStatus": "https://example.com/status"}'; -const result = await validateVc(api, vcJson); - -// isValid is false if any field value of the result.detail is not true -if (!result.isValid) { - // true or error message - console.log('vcSignature: ', result.detail.vcSignature); - // true or error message - console.log('enclaveRegistry: ', result.detail.enclaveRegistry); -} -``` - -Note for simplicity, in above example it's assumed that SDK consumer application has to provide the api instance of ApiPromise and manage its lifecycle as well. diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/docs/.nojekyll b/tee-worker/identity/client-sdk/packages/vc-sdk/docs/.nojekyll deleted file mode 100644 index e2ac6616ad..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/docs/.nojekyll +++ /dev/null @@ -1 +0,0 @@ -TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. \ No newline at end of file diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/docs/README.md b/tee-worker/identity/client-sdk/packages/vc-sdk/docs/README.md deleted file mode 100644 index 4c0cca3506..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/docs/README.md +++ /dev/null @@ -1,225 +0,0 @@ -@litentry/vc-sdk - -# @litentry/vc-sdk - -## Table of contents - -### Type Aliases - -- [Network](README.md#network) -- [ValidationResult](README.md#validationresult) -- [ValidationResultDetail](README.md#validationresultdetail) -- [VerifiableCredentialLike](README.md#verifiablecredentiallike) - -### Variables - -- [NETWORKS](README.md#networks) - -### Functions - -- [validateEnclaveRegistry](README.md#validateenclaveregistry) -- [validateVc](README.md#validatevc) -- [validateVcWithTrustedTeeDevEnclave](README.md#validatevcwithtrustedteedevenclave) - -## Type Aliases - -### Network - -Ƭ **Network**: keyof typeof [`NETWORKS`](README.md#networks) - -#### Defined in - -[lib/validator.types.ts:4](https://github.com/litentry/client-sdk/blob/main/lib/validator.types.ts#L4) - -___ - -### ValidationResult - -Ƭ **ValidationResult**: `Object` - -Represents the overall validation result for a Verifiable Credential (VC). - -#### Type declaration - -| Name | Type | Description | -| :------ | :------ | :------ | -| `detail` | [`ValidationResultDetail`](README.md#validationresultdetail) | Represents the whole validation result detail. | -| `isValid` | `boolean` | Represents the whole validation result status. If is true, means all fields of the detail are true, otherwise any one of it is not true. The caller should use this field to determine whether the VC is valid. | - -#### Defined in - -[lib/validator.types.ts:33](https://github.com/litentry/client-sdk/blob/main/lib/validator.types.ts#L33) - -___ - -### ValidationResultDetail - -Ƭ **ValidationResultDetail**: `Object` - -Defines the details of the validation result for each component of the Verifiable Credential (VC). - -#### Type declaration - -| Name | Type | Description | -| :------ | :------ | :------ | -| `enclaveRegistry?` | ``true`` \| `string` | Represents the validation result (vcPubkey and mrEnclave) for the Enclave registry. If validation succeeds, it's true; if validation fails, it's an error message. The vcPubkey from Enclave registry must be same as issuer.id in VC JSON. The mrEnclave from Enclave registry must be same as issuer.mrenclave in VC JSON. | -| `vcSignature?` | ``true`` \| `string` | Represents the validation result for the VC signature. If validation succeeds, it's true; if validation fails, it's an error message. Use issuer.id in VC JSON as vcPubkey, proof.proofValue in VC JSON as signature to verify VC JSON. | - -#### Defined in - -[lib/validator.types.ts:9](https://github.com/litentry/client-sdk/blob/main/lib/validator.types.ts#L9) - -___ - -### VerifiableCredentialLike - -Ƭ **VerifiableCredentialLike**: `Record`\<`string`, `unknown`\> & \{ `@context`: `string` ; `credentialSubject`: `Record`\<`string`, `unknown`\> ; `id`: `string` ; `issuer`: \{ `id`: `string` ; `mrenclave`: `string` ; `name`: `string` } ; `parachainBlockNumber?`: `number` ; `proof`: \{ `proofValue`: `string` ; `verificationMethod`: `string` } ; `sidechainBlockNumber?`: `number` ; `type`: `string`[] } - -#### Defined in - -[lib/validator.ts:11](https://github.com/litentry/client-sdk/blob/main/lib/validator.ts#L11) - -## Variables - -### NETWORKS - -• `Const` **NETWORKS**: `Object` - -Use to create WsProvider according to network. - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `litentry` | ``"wss://rpc.litentry-parachain.litentry.io"`` | -| `litentry-internal` | ``"wss://tee-internal.litentry.io"`` | -| `litentry-rococo` | ``"wss://rpc.rococo-parachain-sg.litentry.io"`` | -| `litentry-staging` | ``"wss://tee-staging.litentry.io"`` | - -#### Defined in - -[lib/validator.constants.ts:4](https://github.com/litentry/client-sdk/blob/main/lib/validator.constants.ts#L4) - -## Functions - -### validateEnclaveRegistry - -▸ **validateEnclaveRegistry**(`api`, `vc`): `Promise`\<``true`` \| `string`\> - -Validates that the VC was valid at the time it was issued. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `api` | `ApiPromise` | -| `vc` | [`VerifiableCredentialLike`](README.md#verifiablecredentiallike) | - -#### Returns - -`Promise`\<``true`` \| `string`\> - -#### Defined in - -[lib/validator.ts:231](https://github.com/litentry/client-sdk/blob/main/lib/validator.ts#L231) - -___ - -### validateVc - -▸ **validateVc**(`api`, `vc`): `Promise`\<[`ValidationResult`](README.md#validationresult)\> - -Validate Verifiable Credential (VC) - -### How to find the wallet account address in VC - -The id of VC's credentialSubject is the encoded wallet account address, using code below to encode: - -```typescript -import { decodeAddress } from '@polkadot/util-crypto'; -import { u8aToHex } from '@polkadot/util'; - -const address = u8aToHex(decodeAddress(walletAccountAddress)); -const credentialSubjectId = address.substring(2); -``` - -With the code above: -- If your Polkadot account address is `5CwPfqmormPx9wJ4ASq7ikwdJeRonoUZX9SxwUtm1px9L72W`, the credentialSubjectId will be `26a84b380d8c3226d69f9ae6e482aa6669ed34c6371c52c4dfb48596913d6f28`. -- If your Metamask account address is `0xC620b3e5BEBedA952A8AD18b83Dc4Cf3Dc9CAF4b`, the credentialSubjectId will be `c620b3e5bebeda952a8ad18b83dc4cf3dc9caf4b`. - -### What the validation function do - -- The validation function can only verify that the VC was issued by Litentry. -- The VC's credentialSubject can be Substrate or EVM account that is support by Litentry. - -### What the validation function can't do - -- The validation function cannot validate that the VC's credentialSubject is the current wallet account. It's SDK's consumer's responsibility to validate the id of VC's credentialSubject is equal to the wallet address. - -### How to use - -```typescript -import { WsProvider, ApiPromise } from '@polkadot/api'; -import { validateVc, NETWORKS } from '@litentry/vc-sdk'; - -const api: ApiPromise = await ApiPromise.create({ - provider: new WsProvider(NETWORKS['litentry-staging']) -}); -const vcJson = '{"@context": "https://www.w3.org/2018/credentials/v1", "type": "VerifiableCredential", "issuer": "https://example.com/issuer", "subject": "did:example:123", "credentialStatus": "https://example.com/status"}'; -const result = await validateVc(api, vcJson); - -// isValid is false if any field value of the result.detail is not true -if (!result.isValid) { - // true or error message - console.log('vcJson: ', result.detail.vcJson); - // true or error message - console.log('vcRegistry: ', result.detail.vcRegistry); - // true or error message - console.log('vcSignature: ', result.detail.vcSignature); - // true or error message - console.log('enclaveRegistry: ', result.detail.enclaveRegistry); -} -``` - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `api` | `ApiPromise` | The instance of ApiPromise. | -| `vc` | `string` | The VC JSON string that needs to be validated. | - -#### Returns - -`Promise`\<[`ValidationResult`](README.md#validationresult)\> - -The validation result. - -#### Defined in - -[lib/validator.ts:86](https://github.com/litentry/client-sdk/blob/main/lib/validator.ts#L86) - -___ - -### validateVcWithTrustedTeeDevEnclave - -▸ **validateVcWithTrustedTeeDevEnclave**(`api`, `vc`): ``true`` \| `string` - -Validates the VC information against the past enclave registry. -These Enclave may no longer be online but these are Enclave that issued the VC and we trust. - -exported for testing purposes. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `api` | `ApiPromise` | -| `vc` | [`VerifiableCredentialLike`](README.md#verifiablecredentiallike) | - -#### Returns - -``true`` \| `string` - -#### Defined in - -[lib/validator.ts:297](https://github.com/litentry/client-sdk/blob/main/lib/validator.ts#L297) diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/jest.config.ts b/tee-worker/identity/client-sdk/packages/vc-sdk/jest.config.ts deleted file mode 100644 index a4d08b626c..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/jest.config.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'vc-sdk', - preset: '../../jest.preset.js', - testEnvironment: 'node', - transform: { - '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/package/vc-sdk', - transformIgnorePatterns: ['node_modules/(?!(@litentry/|.pnpm/@litentry)).*'], - moduleNameMapper: {}, -}; diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/package.json b/tee-worker/identity/client-sdk/packages/vc-sdk/package.json deleted file mode 100644 index a72b1140ff..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@litentry/vc-sdk", - "version": "3.4.0", - "description": "This library the common functionality to help dApps parse and validate Litentry issued Verifiable Credentials", - "license": "GPL-3.0-or-later", - "dependencies": {}, - "devDependencies": { - "fast-glob": "^3.3.2" - }, - "peerDependencies": { - "@litentry/parachain-api": "0.9.20-4.1", - "@litentry/sidechain-api": "0.9.20-4", - "@polkadot/api": "^10.9.1", - "@polkadot/util": "^12.5.1", - "@polkadot/util-crypto": "^12.5.1", - "tslib": "^2.3.0" - }, - "type": "module", - "main": "./src/index.js", - "typings": "./src/index.d.ts" -} diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/project.json b/tee-worker/identity/client-sdk/packages/vc-sdk/project.json deleted file mode 100644 index 204a7f4203..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/project.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "vc-sdk", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/vc-sdk/src", - "projectType": "library", - "targets": { - "build": { - "executor": "@nx/js:tsc", - "outputs": [ - "{options.outputPath}" - ], - "options": { - "outputPath": "dist/packages/vc-sdk", - "main": "packages/vc-sdk/src/index.ts", - "tsConfig": "packages/vc-sdk/tsconfig.lib.json", - "assets": [ - "packages/vc-sdk/*.md", - "packages/vc-sdk/docs/*.md" - ] - } - }, - "generate-doc": { - "executor": "nx:run-commands", - "options": { - "cwd": "./packages/vc-sdk", - "command": "typedoc --options ./typedoc.json" - } - }, - "publish": { - "command": "node tools/scripts/publish.mjs vc-sdk {args.ver} {args.tag}", - "dependsOn": [ - "build" - ] - }, - "lint": { - "executor": "@nx/linter:eslint", - "outputs": [ - "{options.outputFile}" - ], - "options": { - "lintFilePatterns": [ - "packages/vc-sdk/src/**/*.ts", - "packages/vc-sdk/package.json" - ] - } - }, - "test": { - "executor": "@nx/jest:jest", - "outputs": [ - "{workspaceRoot}/coverage/{projectRoot}" - ], - "options": { - "jestConfig": "packages/vc-sdk/jest.config.ts", - "passWithNoTests": true - }, - "configurations": { - "ci": { - "ci": true, - "codeCoverage": true - } - } - } - }, - "tags": [] -} diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/src/index.ts b/tee-worker/identity/client-sdk/packages/vc-sdk/src/index.ts deleted file mode 100644 index 757f9b6a5e..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/src/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// ambience imports -import '@litentry/sidechain-api'; -import '@litentry/parachain-api'; - -export * from './lib/validator'; -export * from './lib/validator.types'; diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/validator.constants.ts b/tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/validator.constants.ts deleted file mode 100644 index f2abc91dea..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/src/lib/validator.constants.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Use to create WsProvider according to network. - */ -export const NETWORKS = { - 'litentry-internal': 'wss://tee-internal.litentry.io', - 'litentry-staging': 'wss://tee-staging.litentry.io', - 'litentry-rococo': 'wss://rpc.rococo-parachain-sg.litentry.io', - litentry: 'wss://rpc.litentry-parachain.litentry.io', -} as const; diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.json b/tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.json deleted file mode 100644 index 3c85fb0c8c..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "forceConsistentCasingInFileNames": true, - "strict": true, - "allowJs": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": false, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "resolveJsonModule": true, - "esModuleInterop": true - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.lib.json b/tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.lib.json deleted file mode 100644 index 33eca2c2cd..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.lib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "include": ["src/**/*.ts"], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] -} diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.spec.json b/tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.spec.json deleted file mode 100644 index 9b2a121d11..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/tsconfig.spec.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": [ - "jest.config.ts", - "src/**/*.test.ts", - "src/**/*.spec.ts", - "src/**/*.d.ts" - ] -} diff --git a/tee-worker/identity/client-sdk/packages/vc-sdk/typedoc.json b/tee-worker/identity/client-sdk/packages/vc-sdk/typedoc.json deleted file mode 100644 index 2e99bcc38c..0000000000 --- a/tee-worker/identity/client-sdk/packages/vc-sdk/typedoc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://typedoc.org/schema.json", - "plugin": ["typedoc-plugin-markdown"], - "entryPoints": ["./src/index.ts"], - "disableGit": true, - "sourceLinkTemplate": "https://github.com/litentry/client-sdk/blob/main/{path}#L{line}", - "readme": "none", - "out": "docs" -} From 09e89fa59eaec842c770e36453097571258bd3c0 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Mon, 14 Oct 2024 10:51:17 -0500 Subject: [PATCH 3/7] update changelog and readme Signed-off-by: Jonathan Alvarez --- .../packages/client-sdk/CHANGELOG.md | 240 +----------------- .../client-sdk/packages/client-sdk/README.md | 66 ++--- .../packages/client-sdk/package.json | 2 +- 3 files changed, 36 insertions(+), 272 deletions(-) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md b/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md index 3fec80971c..9409c9e713 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md +++ b/tee-worker/identity/client-sdk/packages/client-sdk/CHANGELOG.md @@ -7,242 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [4.3.0] - 2024-09-30 +## 2024-10-14 -### Changed - -- Use `@litentry/parachain-api@0.9.20-4.1` and `@litentry/sidechain-api@0.9.20-4` - -### Added - -- Support for `Email` Identity - -## [4.2.0] - 2024-08-26 - -### Changed - -- Use `@litentry/parachain-api@0.9.19-7` - -## [4.1.0] - 2024-08-06 - -### Added - -- Trusted call requests: add the `request.linkIdentityCallback` method. - -### Changed - -- Use `@litentry/parachain-api@0.9.18-11.2` -- `createLitentryIdentityType`: type can now be created by passing a raw value in hex or `Uint8Array` -- `request.requestBatchVc` now support and optional `signer`. - -## [4.0.1] - 2024-07-19 - -- Use `@litentry/parachain-api@0.9.18-11` and `@litentry/sidechain-api@0.9.18-11` stable versions. - -## [4.0.0] - 2024-07-15 - -- Migrate to `@litentry/parachain-api` and `@litentry/sidechain-api`. -- Distribute as ES Module -- Targets [parachain-release v0.9.18-10](https://github.com/litentry/litentry-parachain/releases/tag/v0.9.18-10) - -## Added - -- Export the type `IdGraph` and its type's struct name under `ID_GRAPH_STRUCT`. -- Challenge code now produces a prettified string for utf-8 signing for web3 identities when `options.prettify` is set to `true`. - -## Changed - -- Migrate to `@litentry/parachain-api` and `@litentry/sidechain-api` por chain types. Deprecates `@litentry/chain-types`. -- Support the new `RequestVcResultOrError` type definition. -- `KeyAesOutput` was renamed to `AesOutput`. -- renamed `global` to `globalThis` -- This library is now distributed as an ESModule - -## Removed - -- Drop `@litentry/chain-types` from dependencies. - -### Fixed - -- `request.getIdGraphHash` no longer throws when the user's id_graph is empty. - -## [3.2.1] - 2024-06-10 - -### Added - -- Adds a new dependency: `@litentry/chaindata`. - -## [3.1.2] - 2024-06-08 - -### Fixed - -- Skip `StfError` validation for verifiable credentials requests. Rely on `RequestVcResultOrError` codec. - -## [3.1.1] - 2024-06-07 - -### Fixed - -- Fix error decoding for single assertions request in `request.requestBatchVc`. - -## [3.1.0] - 2024-06-03 - -### Changed - -- Upgrade `@polkadot/api*`, `@polkadot/rpc*`, `@polkadot/types*` to 10.9.1, and `@polkadot/util*` to `12.5.1` - -### Removed - -- Drop unused `@polkadot/keyring` dependency. - -## [3.0.0] - 2024-06-03 - -- Introduce oAuth2 proofs support for Web2 identity validation - -### Added - -- Config: support `litentry-staging` for the env var `[NX_]PARACHAIN_NETWORK`. -- Config: support the new env var `[NX_]LITENTRY_NETWORK` for setting the network same as `[NX_]PARACHAIN_NETWORK` but higher precedence. -- Config: accept custom WS endpoints on `[NX_]LITENTRY_NETWORK` / `[NX_]PARACHAIN_NETWORK`. - -### Changed - -- Use `@litentry/chain-types@2.0.0` -- The type creator `createLitentryValidationDataType` now accepts building oAuth2 proofs for Discord and Twitter. - - ```ts - // twitter - const twitterOAuth2Proof = createLitentryValidationDataType( - registry, - { - addressOrHandle: 'my_twitter_handle', - type: 'Twitter', - }, - { - code: 'my_twitter_code', - state: 'my_twitter_state', - redirectUri: 'http://test-redirect-uri', - } - ); - - // Discord - const validationData = createLitentryValidationDataType( - registry, - { - addressOrHandle: 'my_discord_handle', - type: 'Discord', - }, - { - code: 'my_discord_code', - redirectUri: 'http://test-redirect-uri', - } - ); - ``` - - The legacy public message proofs are still supported. - -## [2.0.1] - 2024-05-21 - -### Changed - -- When no `PARACHAIN_NETWORK` or `NX_PARACHAIN_NETWORK` is specified, the library will default to the production (`tee-prod`) endpoint rather than to development (`tee-dev`). - -## [2.0.0] - 2024-05-17 - -### Removed - -- `createLitentryIdentityType` dropped the support deriving the identity type from the provided address. Now both `addressOrHandle` and `type` are required. - - ```ts - import { createLitentryIdentityType } from '@litentry/enclave'; - - // from - createLitentryIdentityType(registry, { - address: '5DNx1Kgis2u2SQq7EJrBdnV49PoZCxV3NqER4vV5VqjqZcat', - }); - - // To - createLitentryIdentityType(registry, { - addressOrHandle: '5DNx1Kgis2u2SQq7EJrBdnV49PoZCxV3NqER4vV5VqjqZcat', - type: 'Substrate', - }); - ``` - - consequently, the following methods require a `LitentryIdentity` for the `who` parameter instead of a plain address string: `request.getIdGraph`, `request.linkIdentity`, `request.requestBatchVc`, `request.setIdentityNetworks`, and `request.createChallengeCode`. - -## [1.0.4] - 2024-05-16 - -Routinely update - -## [1.0.3] - 2024-05-16 - -### Changed - -- `@litentry/enclave` add support for Solana hex-encoded signatures. It hex string is not provided, it will default to base58 decoding. - -## [1.0.2] - 2024-05-14 - -### Changed - -- `@litentry/chain-types` is now marked as a peerDependency - -## [1.0.1] - 2024-05-08 - -Routinely update - -## [1.0.0] - 2024-04-24 - -- Initial public version - -### Added - -- Request methods that mutate the idGraph information will have a common response. The entire idGraph will no longer be returned but the information about the updated identity only. -- `request.getIdGraphHash` Request getter to get idGraph hash with no signature. -- `calculateIdGraphHash`: Helper method to calculate the hash of a given local idGraph. -- `request.requestBatchVC`: Request trusted call to request a batch of VCs. -- `Enclave.send` now supports a third argument to subscribe to the WS streamed responses. -- Payload signature is now beautify by default to look more human. -- Use a different key for encrypting the transmitted package to the Enclave. - -### Removed - -- `request.requestVc`. Superseded by `request.requestBatchVc`. -- `createEnclaveHttpProxyHandler`. The connection to the Enclave is now done directly via WebSockets. - -### Changed - -- Migrate from `teerex` to `teebag`. -- Enclave's nonce is now retrieved through the `author_getNextNonce` getter call. -- The connection to the Enclave is now done directly via WebSockets. Setting up an HTTP proxy is no longer necessary nor suggested. -- The payload size of all operations was reduced and fixed to a 32-bytes length. - -## 2023-12-05 - -Update to `Litentry-parachain p0.9.17-9170-w0.0.1-100`. - -### Added - -- `request.getIdGraph`: fetch the user's idGraph from the Enclave Sidechain. It requires user signature. - -### Changed - -- **Shielding key**: Users no longer need to set a shielding key on-chain. The data for network transportation is now protected by ephemeral shielding keys generated on the fly. Ephemeral shielding keys increase security and enhance the user experience. -- **Direct responses**: Operation responses are no longer gathered from the Parachain but from the Enclave itself. -- `request.linkIdentity`: The method now has a two level encryption: the information is encrypted with a different key that the one used for transportation. -- `request.linkIdentity`: The call argument `data.encryptionNonce` was removed. -- `request.linkIdentity`: The returned `send` callback now returns both the idGraph and the parsed sidechain response in a `WorkerRpcReturnValue` type. -- `request.createChallengeCode`: The call argument `args.shield` was removed. The Challenge code no longer needs encrypted information. -- `request.setIdentityNetworks`: The returned `send` callback now returns the transaction hash `txHash` and the parsed sidechain response in a `WorkerRpcReturnValue` type. -- `request.requestVc`: The returned `send` callback now returns the `vcIndex`, `vcHash` and the VC's contents on `vcPayload`. As well as the parsed sidechain response in a `WorkerRpcReturnValue` type. -- `enclave.getNonce` was moved as a requestor: `request.getEnclaveNonce`. -- `KeyAesOutput` type is no longer part of the Parachain-runtime metadata and thus it can't be found on `@polkadot/types/lookup`. Use `KeyAesOutput` instead from `@litentry/chain-types` -- `enclave.send`: Error thrown during Enclave operations include more information now. -- `createEnclaveHttpProxyHandler`: HTTP errors responses are now only returned if reaching the Enclave or processing the request fails. However, `enclave.send` could still throw an execution error if the intrinsic operation contains errors. For instance, linking an already linked identity will result on a 200 HTTP response from the Enclave's proxy but `enclave.send` will throw an error about `IdentityAlreadyLinked`. - -### Removed - -- `request.setUserShieldingKey`: It is no longer needed to set the user's shielding key on-chain. See the Shielding Key point on the Changed section for more information. -- `ky-universal` dependency was dropped. - -## 2023-11-01 - -Initial version +Initial version. Merge [@litentry/enclave](https://www.npmjs.com/package/@litentry/enclave) and [@litentry/vc-sdk](https://www.npmjs.com/package/@litentry/vc-sdk) into this one. diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/README.md b/tee-worker/identity/client-sdk/packages/client-sdk/README.md index 6b4976d00b..9d289d2399 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/README.md +++ b/tee-worker/identity/client-sdk/packages/client-sdk/README.md @@ -1,6 +1,6 @@ -# @litentry/enclave +# @litentry/client-sdk -This package provides helpers for dApps to interact with the Litentry Protocol's Enclave. +This package provides helpers for dApps to interact with the Litentry Protocol. The Enclave is the Litentry's Trusted Execution Environment (TEE), that provides the hightest security and privacy for users to store their identity. @@ -10,22 +10,22 @@ This is a browser package, it may not work as-is on Node.js due to Crypto Subtle 1. Install from NPM - ``` - npm install @litentry/parachain-api @litentry/sidechain-api @litentry/enclave - ``` + ``` + npm install @litentry/parachain-api @litentry/sidechain-api @litentry/client-sdk + ``` 2. Set the right environment - Litentry's Protocol is currently available in three main stages: local (development), `tee-dev` (staging), and `tee-prod` (production). + Litentry's Protocol is currently available in three main stages: local (development), `tee-dev` (staging), and `tee-prod` (production). - You can set what stage to use by setting the `LITENTRY_NETWORK` environment variable. Valid values are: + You can set what stage to use by setting the `LITENTRY_NETWORK` environment variable. Valid values are: - - `litentry-local`: will point to a local enclave `ws://localhost:2000` - - `litentry-dev` (default): will point to `tee-dev`'s Enclave. - - `litentry-staging`: will point to `tee-staging`'s Enclave. - - `litentry-prod`: will point to `tee-prod`'s Enclave. + - `litentry-local`: will point to a local enclave `ws://localhost:2000` + - `litentry-dev` (default): will point to `tee-dev`'s Enclave. + - `litentry-staging`: will point to `tee-staging`'s Enclave. + - `litentry-prod`: will point to `tee-prod`'s Enclave. - `NX_*` prefixed env variables (NX projects) will work too. + `NX_*` prefixed env variables (NX projects) will work too. ### Versions @@ -43,29 +43,29 @@ Please refer to the `examples` folder in this repository to learn more about all 1. Install dependencies - ``` - pnpm install - ``` + ``` + pnpm install + ``` 2. Spin up an local NPM registry - ``` - pnpm nx local-registry - ``` + ``` + pnpm nx local-registry + ``` 3. Publish locally - Follow the steps of [Publish new versions](#publish-new-versions). The step 1 can be skipped. + Follow the steps of [Publish new versions](#publish-new-versions). The step 1 can be skipped. - As long as the local registry is up, any publishing will happen locally. + As long as the local registry is up, any publishing will happen locally. 4. Run test and lint checks - ``` - pnpm nx run enclave:lint + ``` + pnpm nx run client-sdk:lint - pnpm nx run enclave:test - ``` + pnpm nx run client-sdk:test + ``` ### Publish new versions @@ -73,18 +73,18 @@ Please refer to the `examples` folder in this repository to learn more about all 2. Update the latest documentation - ``` - pnpm nx run enclave:generate-doc - ``` + ``` + pnpm nx run client-sdk:generate-doc + ``` 3. Build the project - ``` - pnpm nx run enclave:build - ``` + ``` + pnpm nx run client-sdk:build + ``` 4. Publish the distribution files - ``` - pnpm nx run enclave:publish --ver 1.0.0 --tag latest - ``` + ``` + pnpm nx run client-sdk:publish --ver 1.0.0 --tag latest + ``` diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/package.json b/tee-worker/identity/client-sdk/packages/client-sdk/package.json index 6a67d3aa6d..f643c864b0 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/package.json +++ b/tee-worker/identity/client-sdk/packages/client-sdk/package.json @@ -1,7 +1,7 @@ { "name": "@litentry/client-sdk", "description": "This package provides helpers for dApps to interact with the Litentry Protocol.", - "version": "4.3.0", + "version": "1.0.0", "license": "GPL-3.0-or-later", "dependencies": {}, "devDependencies": { From 0599fdc2c053a782e7f7b9212525dda7878acf33 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Mon, 14 Oct 2024 10:51:33 -0500 Subject: [PATCH 4/7] update docs Signed-off-by: Jonathan Alvarez --- .../packages/client-sdk/docs/README.md | 234 ++++++++++++++++-- .../client-sdk/docs/classes/Enclave.md | 34 ++- .../client-sdk/docs/modules/request.md | 62 ++++- 3 files changed, 279 insertions(+), 51 deletions(-) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/docs/README.md b/tee-worker/identity/client-sdk/packages/client-sdk/docs/README.md index 6e1ae15f7f..72fdac326f 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/docs/README.md +++ b/tee-worker/identity/client-sdk/packages/client-sdk/docs/README.md @@ -1,6 +1,6 @@ -@litentry/enclave +@litentry/client-sdk -# @litentry/enclave +# @litentry/client-sdk ## Table of contents @@ -20,12 +20,18 @@ - [DiscordOAuth2Proof](README.md#discordoauth2proof) - [DiscordProof](README.md#discordproof) +- [EmailProof](README.md#emailproof) +- [IdGraph](README.md#idgraph) - [TwitterOAuth2Proof](README.md#twitteroauth2proof) - [TwitterProof](README.md#twitterproof) +- [ValidationResult](README.md#validationresult) +- [ValidationResultDetail](README.md#validationresultdetail) +- [VerifiableCredentialLike](README.md#verifiablecredentiallike) - [Web3Proof](README.md#web3proof) ### Variables +- [ID\_GRAPH\_STRUCT](README.md#id_graph_struct) - [enclave](README.md#enclave) ### Functions @@ -37,6 +43,7 @@ - [createRequestType](README.md#createrequesttype) - [createTrustedCallType](README.md#createtrustedcalltype) - [toPublicKey](README.md#topublickey) +- [validateVc](README.md#validatevc) ## References @@ -93,6 +100,41 @@ createLitentryValidationDataType ___ +### EmailProof + +Ƭ **EmailProof**: `Object` + +Ownership proof for Email + +**`See`** + +createLitentryValidationDataType + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `email` | `string` | +| `verificationCode` | `string` | + +#### Defined in + +[lib/type-creators/validation-data.ts:68](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/validation-data.ts#L68) + +___ + +### IdGraph + +Ƭ **IdGraph**: `Vec`\<`ITuple`\<[`LitentryIdentity`, `IdentityContext`]\>\> + +The Identity Graph type + +#### Defined in + +[lib/type-creators/id-graph.ts:13](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/id-graph.ts#L13) + +___ + ### TwitterOAuth2Proof Ƭ **TwitterOAuth2Proof**: `Object` @@ -139,6 +181,54 @@ createLitentryValidationDataType ___ +### ValidationResult + +Ƭ **ValidationResult**: `Object` + +Represents the overall validation result for a Verifiable Credential (VC). + +#### Type declaration + +| Name | Type | Description | +| :------ | :------ | :------ | +| `detail` | [`ValidationResultDetail`](README.md#validationresultdetail) | Represents the whole validation result detail. | +| `isValid` | `boolean` | Represents the whole validation result status. If is true, means all fields of the detail are true, otherwise any one of it is not true. The caller should use this field to determine whether the VC is valid. | + +#### Defined in + +[lib/vc-validator/validator.types.ts:28](https://github.com/litentry/client-sdk/blob/develop/lib/vc-validator/validator.types.ts#L28) + +___ + +### ValidationResultDetail + +Ƭ **ValidationResultDetail**: `Object` + +Defines the details of the validation result for each component of the Verifiable Credential (VC). + +#### Type declaration + +| Name | Type | Description | +| :------ | :------ | :------ | +| `enclaveRegistry?` | ``true`` \| `string` | Represents the validation result (vcPubkey and mrEnclave) for the Enclave registry. If validation succeeds, it's true; if validation fails, it's an error message. The vcPubkey from Enclave registry must be same as issuer.id in VC JSON. The mrEnclave from Enclave registry must be same as issuer.mrenclave in VC JSON. | +| `vcSignature?` | ``true`` \| `string` | Represents the validation result for the VC signature. If validation succeeds, it's true; if validation fails, it's an error message. Use issuer.id in VC JSON as vcPubkey, proof.proofValue in VC JSON as signature to verify VC JSON. | + +#### Defined in + +[lib/vc-validator/validator.types.ts:4](https://github.com/litentry/client-sdk/blob/develop/lib/vc-validator/validator.types.ts#L4) + +___ + +### VerifiableCredentialLike + +Ƭ **VerifiableCredentialLike**: `Record`\<`string`, `unknown`\> & \{ `@context`: `string` ; `credentialSubject`: `Record`\<`string`, `unknown`\> ; `id`: `string` ; `issuer`: \{ `id`: `string` ; `mrenclave`: `string` ; `name`: `string` } ; `parachainBlockNumber?`: `number` ; `proof`: \{ `proofValue`: `string` ; `verificationMethod`: `string` } ; `sidechainBlockNumber?`: `number` ; `type`: `string`[] } + +#### Defined in + +[lib/vc-validator/validator.ts:11](https://github.com/litentry/client-sdk/blob/develop/lib/vc-validator/validator.ts#L11) + +___ + ### Web3Proof Ƭ **Web3Proof**: `Object` @@ -164,6 +254,18 @@ createLitentryIdentityType ## Variables +### ID\_GRAPH\_STRUCT + +• `Const` **ID\_GRAPH\_STRUCT**: ``"Vec<(LitentryIdentity, IdentityContext)>"`` + +The Type Struct that represents an Identity Graph + +#### Defined in + +[lib/type-creators/id-graph.ts:18](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/id-graph.ts#L18) + +___ + ### enclave • `Const` **enclave**: [`Enclave`](classes/Enclave.md) @@ -193,7 +295,7 @@ const response = await enclave.send({ #### Defined in -[lib/enclave.ts:298](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L298) +[lib/enclave.ts:294](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L294) ## Functions @@ -207,7 +309,7 @@ Returns the hash of the given id graph. It matches the hash used in the Litentry | Name | Type | | :------ | :------ | -| `idGraph` | `IdGraph` | +| `idGraph` | [`IdGraph`](README.md#idgraph) | #### Returns @@ -279,9 +381,7 @@ For Substrate, the address is expected to be a SS58-encoded or hex-encoded addre | Name | Type | | :------ | :------ | | `registry` | `Registry` | -| `data` | `Object` | -| `data.addressOrHandle` | `string` | -| `data.type` | ``"Solana"`` \| ``"Twitter"`` \| ``"Discord"`` \| ``"Github"`` \| ``"Substrate"`` \| ``"Evm"`` \| ``"Bitcoin"`` | +| `data` | \`0x$\{string}\` \| `Uint8Array` \| \{ `addressOrHandle`: `string` ; `type`: ``"Solana"`` \| ``"Twitter"`` \| ``"Discord"`` \| ``"Github"`` \| ``"Substrate"`` \| ``"Evm"`` \| ``"Bitcoin"`` \| ``"Email"`` } | #### Returns @@ -322,7 +422,7 @@ The proof to pass depends on the identity network (IIdentityType): | Name | Type | | :------ | :------ | -| `IIdentityType` | extends ``"Solana"`` \| ``"Twitter"`` \| ``"Discord"`` \| ``"Github"`` \| ``"Substrate"`` \| ``"Evm"`` \| ``"Bitcoin"`` | +| `IIdentityType` | extends ``"Solana"`` \| ``"Twitter"`` \| ``"Discord"`` \| ``"Github"`` \| ``"Substrate"`` \| ``"Evm"`` \| ``"Bitcoin"`` \| ``"Email"`` | #### Parameters @@ -332,7 +432,7 @@ The proof to pass depends on the identity network (IIdentityType): | `identityDescriptor` | `Object` | - | | `identityDescriptor.addressOrHandle` | `string` | The address or handle of the identity | | `identityDescriptor.type` | `IIdentityType` | The identity type | -| `proof` | `IIdentityType` extends ``"Discord"`` ? [`DiscordProof`](README.md#discordproof) \| [`DiscordOAuth2Proof`](README.md#discordoauth2proof) : `IIdentityType` extends ``"Twitter"`` ? [`TwitterProof`](README.md#twitterproof) \| [`TwitterOAuth2Proof`](README.md#twitteroauth2proof) : [`Web3Proof`](README.md#web3proof) | The ownership proof | +| `proof` | `IIdentityType` extends ``"Discord"`` ? [`DiscordProof`](README.md#discordproof) \| [`DiscordOAuth2Proof`](README.md#discordoauth2proof) : `IIdentityType` extends ``"Twitter"`` ? [`TwitterProof`](README.md#twitterproof) \| [`TwitterOAuth2Proof`](README.md#twitteroauth2proof) : `IIdentityType` extends ``"Email"`` ? [`EmailProof`](README.md#emailproof) : [`Web3Proof`](README.md#web3proof) | The ownership proof | #### Returns @@ -342,8 +442,8 @@ The proof to pass depends on the identity network (IIdentityType): Web3 ```ts -import { createLitentryValidationDataType } from '@litentry/enclave'; -import type { Web3Proof } from '@litentry/enclave'; +import { createLitentryValidationDataType } from '@litentry/client-sdk'; +import type { Web3Proof } from '@litentry/client-sdk'; const userAddress = '0x123'; @@ -366,8 +466,8 @@ const validationData = createLitentryValidationDataType( Twitter ```ts -import { createLitentryValidationDataType } from '@litentry/enclave'; -import type { TwitterProof } from '@litentry/enclave'; +import { createLitentryValidationDataType } from '@litentry/client-sdk'; +import type { TwitterProof } from '@litentry/client-sdk'; const userHandle = '@litentry'; @@ -388,7 +488,7 @@ const validationData = createLitentryValidationDataType( #### Defined in -[lib/type-creators/validation-data.ts:116](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/validation-data.ts#L116) +[lib/type-creators/validation-data.ts:126](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/validation-data.ts#L126) ___ @@ -413,7 +513,7 @@ The shielding key is encrypted using the Enclave's shielding key and attached in | `data.nonce` | `Index` | | `data.shard` | `Uint8Array` | | `data.signature` | `string` | -| `data.who` | `LitentryIdentity` | +| `data.signer` | `LitentryIdentity` | #### Returns @@ -456,7 +556,7 @@ Similarly, our types definitions must match also. #### Defined in -[lib/type-creators/trusted-call.ts:69](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L69) +[lib/type-creators/trusted-call.ts:79](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L79) ▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\> @@ -475,7 +575,7 @@ Similarly, our types definitions must match also. #### Defined in -[lib/type-creators/trusted-call.ts:76](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L76) +[lib/type-creators/trusted-call.ts:86](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L86) ▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\> @@ -494,7 +594,7 @@ Similarly, our types definitions must match also. #### Defined in -[lib/type-creators/trusted-call.ts:83](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L83) +[lib/type-creators/trusted-call.ts:93](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L93) ▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\> @@ -513,7 +613,26 @@ Similarly, our types definitions must match also. #### Defined in -[lib/type-creators/trusted-call.ts:90](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L90) +[lib/type-creators/trusted-call.ts:100](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L100) + +▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `registry` | `Registry` | +| `data` | `Object` | +| `data.method` | ``"link_identity_callback"`` | +| `data.params` | `LinkIdentityCallbackParams` | + +#### Returns + +`Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\> + +#### Defined in + +[lib/type-creators/trusted-call.ts:107](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L107) ___ @@ -539,4 +658,79 @@ if the address is not a valid substrate address #### Defined in -[lib/type-creators/litentry-identity.ts:78](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/litentry-identity.ts#L78) +[lib/type-creators/litentry-identity.ts:85](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/litentry-identity.ts#L85) + +___ + +### validateVc + +▸ **validateVc**(`api`, `vc`): `Promise`\<[`ValidationResult`](README.md#validationresult)\> + +Validate Verifiable Credential (VC) + +### How to find the wallet account address in VC + +The id of VC's credentialSubject is the encoded wallet account address, using code below to encode: + +```typescript +import { decodeAddress } from '@polkadot/util-crypto'; +import { u8aToHex } from '@polkadot/util'; + +const address = u8aToHex(decodeAddress(walletAccountAddress)); +const credentialSubjectId = address.substring(2); +``` + +With the code above: +- If your Polkadot account address is `5CwPfqmormPx9wJ4ASq7ikwdJeRonoUZX9SxwUtm1px9L72W`, the credentialSubjectId will be `26a84b380d8c3226d69f9ae6e482aa6669ed34c6371c52c4dfb48596913d6f28`. +- If your Metamask account address is `0xC620b3e5BEBedA952A8AD18b83Dc4Cf3Dc9CAF4b`, the credentialSubjectId will be `c620b3e5bebeda952a8ad18b83dc4cf3dc9caf4b`. + +### What the validation function do + +- The validation function can only verify that the VC was issued by Litentry. +- The VC's credentialSubject can be Substrate or EVM account that is support by Litentry. + +### What the validation function can't do + +- The validation function cannot validate that the VC's credentialSubject is the current wallet account. It's SDK's consumer's responsibility to validate the id of VC's credentialSubject is equal to the wallet address. + +### How to use + +```typescript +import { WsProvider, ApiPromise } from '@polkadot/api'; +import { validateVc, NETWORKS } from '@litentry/vc-sdk'; + +const api: ApiPromise = await ApiPromise.create({ + provider: new WsProvider(NETWORKS['litentry-staging']) +}); +const vcJson = '{"@context": "https://www.w3.org/2018/credentials/v1", "type": "VerifiableCredential", "issuer": "https://example.com/issuer", "subject": "did:example:123", "credentialStatus": "https://example.com/status"}'; +const result = await validateVc(api, vcJson); + +// isValid is false if any field value of the result.detail is not true +if (!result.isValid) { + // true or error message + console.log('vcJson: ', result.detail.vcJson); + // true or error message + console.log('vcRegistry: ', result.detail.vcRegistry); + // true or error message + console.log('vcSignature: ', result.detail.vcSignature); + // true or error message + console.log('enclaveRegistry: ', result.detail.enclaveRegistry); +} +``` + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `api` | `ApiPromise` | The instance of ApiPromise. | +| `vc` | `string` | The VC JSON string that needs to be validated. | + +#### Returns + +`Promise`\<[`ValidationResult`](README.md#validationresult)\> + +The validation result. + +#### Defined in + +[lib/vc-validator/validator.ts:86](https://github.com/litentry/client-sdk/blob/develop/lib/vc-validator/validator.ts#L86) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/docs/classes/Enclave.md b/tee-worker/identity/client-sdk/packages/client-sdk/docs/classes/Enclave.md index 0a7b60d8be..cc7dca4e74 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/docs/classes/Enclave.md +++ b/tee-worker/identity/client-sdk/packages/client-sdk/docs/classes/Enclave.md @@ -1,4 +1,4 @@ -[@litentry/enclave](../README.md) / Enclave +[@litentry/client-sdk](../README.md) / Enclave # Class: Enclave @@ -8,20 +8,16 @@ With this class you can: - Retrieve the Enclave's Shielding Key. (1) - Retrieve the Enclave's MREnclave value which is used as the Shard value. (1) - Encrypt data using the Enclave's Shielding Key. -- Send request to the Enclave. This is also known as Direct Invocation. (2) +- Send request to the Enclave. -(1) This is done by querying the Parachain. Its shielding key can be retrieved directly but -since the MREnclave cannot we opted to leave both from the Parachain in the meantime. - -(2) This is done by using a reverse proxy API. By default, it expects the proxy API to be -running on `/api/enclave`. See `createEnclaveHttpProxyHandler` for more details. +(1) Querying from the Parachain, instead of directly from the Enclave Worker itself helps +ensuring clients are connected to a trusted worker. **`Example`** ```ts -import { Enclave } from '@litentry/enclave'; +import { enclave } from '@litentry/client-sdk'; -const enclave = new Enclave(); // same as the `enclave` variable exported from this module const shard = await enclave.getShard(api); const key = await enclave.getKey(api); @@ -30,7 +26,7 @@ console.log({ shard, key }); // Encrypt data using the Enclave's Shielding Key const encrypted = await enclave.encrypt(api, { cleartext: new Uint8Array([1, 2, 3]) }); -// Send request to the Enclave directly. This is also known as Direct Invocation. +// Send request to the Enclave. const response = await enclave.send({ jsonrpc: '2.0', method: 'author_submitAndWatch', @@ -70,7 +66,7 @@ const response = await enclave.send({ #### Defined in -[lib/enclave.ts:66](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L66) +[lib/enclave.ts:62](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L62) ## Properties @@ -80,7 +76,7 @@ const response = await enclave.send({ #### Defined in -[lib/enclave.ts:63](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L63) +[lib/enclave.ts:59](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L59) ___ @@ -90,7 +86,7 @@ ___ #### Defined in -[lib/enclave.ts:64](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L64) +[lib/enclave.ts:60](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L60) ___ @@ -100,7 +96,7 @@ ___ #### Defined in -[lib/enclave.ts:62](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L62) +[lib/enclave.ts:58](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L58) ## Methods @@ -122,7 +118,7 @@ ___ #### Defined in -[lib/enclave.ts:88](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L88) +[lib/enclave.ts:84](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L84) ___ @@ -146,7 +142,7 @@ The value will be held in memory for the duration of the session. #### Defined in -[lib/enclave.ts:112](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L112) +[lib/enclave.ts:108](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L108) ___ @@ -170,7 +166,7 @@ The value will be held in memory for the duration of the session. #### Defined in -[lib/enclave.ts:123](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L123) +[lib/enclave.ts:119](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L119) ___ @@ -190,7 +186,7 @@ ___ #### Defined in -[lib/enclave.ts:74](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L74) +[lib/enclave.ts:70](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L70) ___ @@ -221,4 +217,4 @@ For single messages, it will throw an error if the response contains an error. #### Defined in -[lib/enclave.ts:140](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L140) +[lib/enclave.ts:136](https://github.com/litentry/client-sdk/blob/develop/lib/enclave.ts#L136) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/docs/modules/request.md b/tee-worker/identity/client-sdk/packages/client-sdk/docs/modules/request.md index a9cb4a55d6..85c5cec485 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/docs/modules/request.md +++ b/tee-worker/identity/client-sdk/packages/client-sdk/docs/modules/request.md @@ -1,4 +1,4 @@ -[@litentry/enclave](../README.md) / request +[@litentry/client-sdk](../README.md) / request # Namespace: request @@ -13,6 +13,7 @@ requests - [getIdGraphHash](request.md#getidgraphhash) - [getLastRegisteredEnclave](request.md#getlastregisteredenclave) - [linkIdentity](request.md#linkidentity) +- [linkIdentityCallback](request.md#linkidentitycallback) - [requestBatchVC](request.md#requestbatchvc) - [setIdentityNetworks](request.md#setidentitynetworks) @@ -20,7 +21,7 @@ requests ### createChallengeCode -▸ **createChallengeCode**(`api`, `args`): `Promise`\<`string`\> +▸ **createChallengeCode**(`api`, `args`, `options?`): `Promise`\<`string`\> Generates the challenge code to link an identity. @@ -30,7 +31,11 @@ The challenge code is calculated from: blake2_256( + + ) ``` -The output is a hex string. For Bitcoin `identity`, the hex's prefix `0x` is removed. +When `options.prettify` is set to true, the challenge code will be prefixed +with `Token: ` for utf-8 signatures support. +Otherwise, it will be returned as a hex string. + +`options.prettify` feature is web3-specific. Ignored for web2. #### Parameters @@ -40,6 +45,8 @@ The output is a hex string. For Bitcoin `identity`, the hex's prefix `0x` is rem | `args` | `Object` | - | | `args.identity` | `LitentryIdentity` | Identity to be linked. Use `createCorePrimitivesIdentityType` helper to create this struct | | `args.who` | `LitentryIdentity` | The user's account. Use `createCorePrimitivesIdentityType` helper to create this struct | +| `options` | `Object` | - | +| `options.prettify?` | `boolean` | - | #### Returns @@ -47,13 +54,13 @@ The output is a hex string. For Bitcoin `identity`, the hex's prefix `0x` is rem #### Defined in -[lib/requests/link-identity.request.ts:34](https://github.com/litentry/client-sdk/blob/develop/lib/requests/link-identity.request.ts#L34) +[lib/requests/link-identity.request.ts:39](https://github.com/litentry/client-sdk/blob/develop/lib/requests/link-identity.request.ts#L39) ___ ### getIdGraph -▸ **getIdGraph**(`api`, `data`): `Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraph`: `IdGraph` ; `response`: `WorkerRpcReturnValue` }\> }\> +▸ **getIdGraph**(`api`, `data`): `Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraph`: [`IdGraph`](../README.md#idgraph) ; `response`: `WorkerRpcReturnValue` }\> }\> #### Parameters @@ -65,7 +72,7 @@ ___ #### Returns -`Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraph`: `IdGraph` ; `response`: `WorkerRpcReturnValue` }\> }\> +`Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraph`: [`IdGraph`](../README.md#idgraph) ; `response`: `WorkerRpcReturnValue` }\> }\> #### Defined in @@ -122,7 +129,7 @@ ___ ### linkIdentity -▸ **linkIdentity**(`api`, `data`): `Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraphHash`: \`0x$\{string}\` ; `mutatedIdentities`: `IdGraph` ; `response`: `WorkerRpcReturnValue` ; `txHash`: `string` }\> ; `txHash`: `string` }\> +▸ **linkIdentity**(`api`, `data`): `Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraphHash`: \`0x$\{string}\` ; `mutatedIdentities`: [`IdGraph`](../README.md#idgraph) ; `response`: `WorkerRpcReturnValue` ; `txHash`: `string` }\> ; `txHash`: `string` }\> Link an identity to the user's account. @@ -133,17 +140,47 @@ Link an identity to the user's account. | `api` | `ApiPromise` | Litentry Parachain API instance from Polkadot.js | | `data` | `Object` | - | | `data.identity` | `LitentryIdentity` | Identity to be linked. Use `createCorePrimitivesIdentityType` helper to create this struct | -| `data.networks` | (``"Polkadot"`` \| ``"Kusama"`` \| ``"Litentry"`` \| ``"LitentryRococo"`` \| ``"Khala"`` \| ``"SubstrateTestnet"`` \| ``"Ethereum"`` \| ``"Bsc"`` \| ``"BitcoinP2tr"`` \| ``"BitcoinP2pkh"`` \| ``"BitcoinP2sh"`` \| ``"BitcoinP2wpkh"`` \| ``"BitcoinP2wsh"`` \| ``"Polygon"`` \| ``"Arbitrum"`` \| ``"Solana"`` \| ``"Combo"``)[] | The networks to link the identity to, for web3 accounts | +| `data.networks` | (``"Polkadot"`` \| ``"Kusama"`` \| ``"Litentry"`` \| ``"Litmus"`` \| ``"LitentryRococo"`` \| ``"Khala"`` \| ``"SubstrateTestnet"`` \| ``"Ethereum"`` \| ``"Bsc"`` \| ``"BitcoinP2tr"`` \| ``"BitcoinP2pkh"`` \| ``"BitcoinP2sh"`` \| ``"BitcoinP2wpkh"`` \| ``"BitcoinP2wsh"`` \| ``"Polygon"`` \| ``"Arbitrum"`` \| ``"Solana"`` \| ``"Combo"``)[] | The networks to link the identity to, for web3 accounts | | `data.validation` | `LitentryValidationData` | The ownership proof. Use `createLitentryValidationDataType` helper to create this struct | | `data.who` | `LitentryIdentity` | The prime identity. Use `createCorePrimitivesIdentityType` helper to create this struct | #### Returns -`Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraphHash`: \`0x$\{string}\` ; `mutatedIdentities`: `IdGraph` ; `response`: `WorkerRpcReturnValue` ; `txHash`: `string` }\> ; `txHash`: `string` }\> +`Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraphHash`: \`0x$\{string}\` ; `mutatedIdentities`: [`IdGraph`](../README.md#idgraph) ; `response`: `WorkerRpcReturnValue` ; `txHash`: `string` }\> ; `txHash`: `string` }\> + +#### Defined in + +[lib/requests/link-identity.request.ts:75](https://github.com/litentry/client-sdk/blob/develop/lib/requests/link-identity.request.ts#L75) + +___ + +### linkIdentityCallback + +▸ **linkIdentityCallback**(`api`, `data`): `Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraphHash`: \`0x$\{string}\` ; `mutatedIdentities`: [`IdGraph`](../README.md#idgraph) ; `response`: `WorkerRpcReturnValue` ; `txHash`: `string` }\> ; `txHash`: `string` }\> + +(internal) Link an identity to the user's account. + +This function is only meant to be used in development networks where root or enclave_signer_account +are used as the signer. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `api` | `ApiPromise` | Litentry Parachain API instance from Polkadot.js | +| `data` | `Object` | - | +| `data.identity` | `LitentryIdentity` | Identity to be linked. Use `createCorePrimitivesIdentityType` helper to create this struct | +| `data.networks?` | (``"Polkadot"`` \| ``"Kusama"`` \| ``"Litentry"`` \| ``"Litmus"`` \| ``"LitentryRococo"`` \| ``"Khala"`` \| ``"SubstrateTestnet"`` \| ``"Ethereum"`` \| ``"Bsc"`` \| ``"BitcoinP2tr"`` \| ``"BitcoinP2pkh"`` \| ``"BitcoinP2sh"`` \| ``"BitcoinP2wpkh"`` \| ``"BitcoinP2wsh"`` \| ``"Polygon"`` \| ``"Arbitrum"`` \| ``"Solana"`` \| ``"Combo"``)[] | The networks to link the identity to, for web3 accounts | +| `data.signer` | `LitentryIdentity` | The signer. Use `createCorePrimitivesIdentityType` helper to create this struct | +| `data.who` | `LitentryIdentity` | The prime identity. Use `createCorePrimitivesIdentityType` helper to create this struct | + +#### Returns + +`Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraphHash`: \`0x$\{string}\` ; `mutatedIdentities`: [`IdGraph`](../README.md#idgraph) ; `response`: `WorkerRpcReturnValue` ; `txHash`: `string` }\> ; `txHash`: `string` }\> #### Defined in -[lib/requests/link-identity.request.ts:57](https://github.com/litentry/client-sdk/blob/develop/lib/requests/link-identity.request.ts#L57) +[lib/requests/link-identity-callback.request.ts:28](https://github.com/litentry/client-sdk/blob/develop/lib/requests/link-identity-callback.request.ts#L28) ___ @@ -169,6 +206,7 @@ The information about available assertions and their payload can be found in the | `api` | `ApiPromise` | Litentry Parachain API instance from Polkadot.js | | `data` | `Object` | - | | `data.assertions` | `Assertion`[] | the assertions to be claimed. See `Assertion` type | +| `data.signer?` | `LitentryIdentity` | The signer's account. Use `createLitentryIdentityType` helper to create this struct | | `data.who` | `LitentryIdentity` | The user's account. Use `createLitentryIdentityType` helper to create this struct | #### Returns @@ -183,7 +221,7 @@ ___ ### setIdentityNetworks -▸ **setIdentityNetworks**(`api`, `data`): `Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraphHash`: \`0x$\{string}\` ; `mutatedIdentities`: `IdGraph` ; `response`: `WorkerRpcReturnValue` ; `txHash`: `string` }\> ; `txHash`: `string` }\> +▸ **setIdentityNetworks**(`api`, `data`): `Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraphHash`: \`0x$\{string}\` ; `mutatedIdentities`: [`IdGraph`](../README.md#idgraph) ; `response`: `WorkerRpcReturnValue` ; `txHash`: `string` }\> ; `txHash`: `string` }\> Set the networks for a Web3 Identity. @@ -201,7 +239,7 @@ It allows to change the list of `networks` for an already linked web3 identity. #### Returns -`Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraphHash`: \`0x$\{string}\` ; `mutatedIdentities`: `IdGraph` ; `response`: `WorkerRpcReturnValue` ; `txHash`: `string` }\> ; `txHash`: `string` }\> +`Promise`\<\{ `payloadToSign`: `string` ; `send`: (`args`: \{ `signedPayload`: `string` }) => `Promise`\<\{ `idGraphHash`: \`0x$\{string}\` ; `mutatedIdentities`: [`IdGraph`](../README.md#idgraph) ; `response`: `WorkerRpcReturnValue` ; `txHash`: `string` }\> ; `txHash`: `string` }\> #### Defined in From 807220c23deb1e389c4c379e177774b61ecfb2dd Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 15 Oct 2024 10:26:23 -0500 Subject: [PATCH 5/7] docs Signed-off-by: Jonathan Alvarez --- tee-worker/identity/client-sdk/packages/client-sdk/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/README.md b/tee-worker/identity/client-sdk/packages/client-sdk/README.md index 9d289d2399..d678e629fe 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/README.md +++ b/tee-worker/identity/client-sdk/packages/client-sdk/README.md @@ -41,6 +41,8 @@ Please refer to the `examples` folder in this repository to learn more about all ### Quick start +These are the steps for publishing the package locally for development purposes. + 1. Install dependencies ``` From 95f38d934bf2647897f2e42b0a14c77985c747d7 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 15 Oct 2024 10:26:32 -0500 Subject: [PATCH 6/7] publish: fix target Signed-off-by: Jonathan Alvarez --- tee-worker/identity/client-sdk/packages/client-sdk/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tee-worker/identity/client-sdk/packages/client-sdk/project.json b/tee-worker/identity/client-sdk/packages/client-sdk/project.json index c3b20eb28c..e30bb6b95e 100644 --- a/tee-worker/identity/client-sdk/packages/client-sdk/project.json +++ b/tee-worker/identity/client-sdk/packages/client-sdk/project.json @@ -5,7 +5,7 @@ "projectType": "library", "targets": { "publish": { - "command": "node tools/scripts/publish.mjs enclave {args.ver} {args.tag}", + "command": "node tools/scripts/publish.mjs client-sdk {args.ver} {args.tag}", "dependsOn": [ "build" ] From 57a0f3f6b87d07d5b579ad126be83471706e3098 Mon Sep 17 00:00:00 2001 From: Jonathan Alvarez Date: Tue, 15 Oct 2024 11:32:41 -0500 Subject: [PATCH 7/7] post-checks: use @litentry/client-sdk Signed-off-by: Jonathan Alvarez --- tee-worker/identity/ts-tests/pnpm-lock.yaml | 89 ++++++++++++------- .../ts-tests/post-checks/package.json | 8 +- .../post-checks/tests/post-check.test.ts | 3 +- 3 files changed, 63 insertions(+), 37 deletions(-) diff --git a/tee-worker/identity/ts-tests/pnpm-lock.yaml b/tee-worker/identity/ts-tests/pnpm-lock.yaml index 4f1484b81c..39834bd030 100644 --- a/tee-worker/identity/ts-tests/pnpm-lock.yaml +++ b/tee-worker/identity/ts-tests/pnpm-lock.yaml @@ -114,7 +114,7 @@ importers: version: 2.0.1 ws: specifier: ^8.17.1 - version: 8.17.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) + version: 8.17.1 zx: specifier: ^7.2.3 version: 7.2.3 @@ -167,15 +167,15 @@ importers: '@litentry/chaindata': specifier: ^0.2.0 version: 0.2.0 - '@litentry/enclave': - specifier: ^4.1.0 - version: 4.1.0(@litentry/chaindata@0.2.0)(@litentry/parachain-api@0.9.18-11.2)(@litentry/sidechain-api@0.9.18-11)(@polkadot/api@10.9.1)(@polkadot/types-codec@10.9.1)(@polkadot/types@10.9.1)(@polkadot/util-crypto@12.5.1)(@polkadot/util@12.5.1)(tslib@2.6.2) + '@litentry/client-sdk': + specifier: ^1.0.0 + version: 1.0.0(@litentry/chaindata@0.2.0)(@litentry/parachain-api@0.9.20-4.1)(@litentry/sidechain-api@0.9.20-4)(@polkadot/api@10.9.1)(@polkadot/types-codec@10.9.1)(@polkadot/types@10.9.1)(@polkadot/util-crypto@12.5.1)(@polkadot/util@12.5.1)(tslib@2.6.2) '@litentry/parachain-api': - specifier: 0.9.18-11.2 - version: 0.9.18-11.2 + specifier: 0.9.20-4.1 + version: 0.9.20-4.1 '@litentry/sidechain-api': - specifier: 0.9.18-11 - version: 0.9.18-11 + specifier: 0.9.20-4 + version: 0.9.20-4 '@polkadot/api': specifier: ^10.9.1 version: 10.9.1 @@ -217,7 +217,7 @@ importers: version: 5.0.4 ws: specifier: ^8.17.1 - version: 8.17.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) + version: 8.17.1 stress: dependencies: @@ -259,7 +259,7 @@ importers: version: 2.0.1 ws: specifier: ^8.17.1 - version: 8.17.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) + version: 8.17.1 zod: specifier: ^3.22.3 version: 3.22.3 @@ -401,7 +401,7 @@ importers: version: 2.0.1 ws: specifier: ^8.17.1 - version: 8.17.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) + version: 8.17.1 devDependencies: '@ethersproject/providers': specifier: ^5.7.2 @@ -489,7 +489,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 espree: 9.6.1 globals: 13.22.0 ignore: 5.2.4 @@ -826,7 +826,7 @@ packages: engines: {node: '>=10.10.0'} dependencies: '@humanwhocodes/object-schema': 1.2.1 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -860,12 +860,12 @@ packages: tslib: 2.6.2 dev: false - /@litentry/enclave@4.1.0(@litentry/chaindata@0.2.0)(@litentry/parachain-api@0.9.18-11.2)(@litentry/sidechain-api@0.9.18-11)(@polkadot/api@10.9.1)(@polkadot/types-codec@10.9.1)(@polkadot/types@10.9.1)(@polkadot/util-crypto@12.5.1)(@polkadot/util@12.5.1)(tslib@2.6.2): - resolution: {integrity: sha512-YHo6CIqrAO1MofQZVCyZpsMuKB/WaM+lBu7pkxr+l3Phsu1cGwGu+7aFfI58+8qGjoxrVUvA/opGcW0rXSiLmg==} + /@litentry/client-sdk@1.0.0(@litentry/chaindata@0.2.0)(@litentry/parachain-api@0.9.20-4.1)(@litentry/sidechain-api@0.9.20-4)(@polkadot/api@10.9.1)(@polkadot/types-codec@10.9.1)(@polkadot/types@10.9.1)(@polkadot/util-crypto@12.5.1)(@polkadot/util@12.5.1)(tslib@2.6.2): + resolution: {integrity: sha512-htcII+AN0v99G4u7Dbe7g/KU+IPukPit5hm8bR/kA0b8FaPQySKLsvO0bdKdNvExGOeLj9uhmMo5LdwB9tXj+A==} peerDependencies: '@litentry/chaindata': '*' - '@litentry/parachain-api': 0.9.18-11.2 - '@litentry/sidechain-api': 0.9.18-11 + '@litentry/parachain-api': 0.9.20-4.1 + '@litentry/sidechain-api': 0.9.20-4 '@polkadot/api': ^10.9.1 '@polkadot/types': ^10.9.1 '@polkadot/types-codec': ^10.9.1 @@ -874,8 +874,8 @@ packages: tslib: ^2.3.0 dependencies: '@litentry/chaindata': 0.2.0 - '@litentry/parachain-api': 0.9.18-11.2 - '@litentry/sidechain-api': 0.9.18-11 + '@litentry/parachain-api': 0.9.20-4.1 + '@litentry/sidechain-api': 0.9.20-4 '@polkadot/api': 10.9.1 '@polkadot/types': 10.9.1 '@polkadot/types-codec': 10.9.1 @@ -884,8 +884,8 @@ packages: tslib: 2.6.2 dev: false - /@litentry/parachain-api@0.9.18-11.2: - resolution: {integrity: sha512-nnmX2o8j9Cbi6truI0CtIZ34dyAAKNGWmTIbfS5oXU3LVq20mdHErE8o9y/0j79yN+yFJwUvLpQMqanm6nwJYQ==} + /@litentry/parachain-api@0.9.20-4.1: + resolution: {integrity: sha512-IL3E86EXlc3YdzHghxHwy0+a+1cWAjyQ8Ynyku4BtD6lL5b/bLgS3tFRmAYhkmmIFfJnx9vLRw2gZ3LVEudcJg==} dependencies: '@polkadot/api': 10.9.1 '@polkadot/api-augment': 10.9.1 @@ -907,8 +907,8 @@ packages: - utf-8-validate dev: false - /@litentry/sidechain-api@0.9.18-11: - resolution: {integrity: sha512-iAcCyM8YkVdNjPs+CbhGpeUN2EnvTvvs8+HsiL660OTPRWHwLn7f3MuzrCcjBaHjKErtY2gJ9F/P6pskg5MOrg==} + /@litentry/sidechain-api@0.9.20-4: + resolution: {integrity: sha512-wYIS8FStKL7Nw/ViRlRMijSpZgVxJr2OKQlSRO1j9rBdNiCiOw0M5Y5Uo3eeSO7y4R04gPaSm7q0FvjByvGEMw==} dependencies: '@polkadot/api': 10.9.1 '@polkadot/api-augment': 10.9.1 @@ -1392,7 +1392,7 @@ packages: dependencies: '@polkadot/x-global': 12.5.1 tslib: 2.6.2 - ws: 8.17.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) + ws: 8.17.1 transitivePeerDependencies: - bufferutil - utf-8-validate @@ -1441,6 +1441,7 @@ packages: /@substrate/connect@0.7.26: resolution: {integrity: sha512-uuGSiroGuKWj1+38n1kY5HReer5iL9bRwPCzuoLtqAOmI1fGI0hsSI2LlNQMAbfRgr7VRHXOk5MTuQf5ulsFRw==} + deprecated: versions below 1.x are no longer maintained requiresBuild: true dependencies: '@substrate/connect-extension-protocol': 1.0.1 @@ -1565,7 +1566,7 @@ packages: '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/type-utils': 5.62.0(eslint@8.50.0)(typescript@5.0.4) '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@5.0.4) - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 eslint: 8.50.0 graphemer: 1.4.0 ignore: 5.2.4 @@ -1590,7 +1591,7 @@ packages: '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.0.4) - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 eslint: 8.50.0 typescript: 5.0.4 transitivePeerDependencies: @@ -1617,7 +1618,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.0.4) '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@5.0.4) - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 eslint: 8.50.0 tsutils: 3.21.0(typescript@5.0.4) typescript: 5.0.4 @@ -1641,7 +1642,7 @@ packages: dependencies: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/visitor-keys': 5.62.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -2173,6 +2174,17 @@ packages: engines: {node: '>= 12'} dev: false + /debug@4.3.4: + resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -2408,7 +2420,7 @@ packages: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -3312,7 +3324,7 @@ packages: resolution: {integrity: sha512-z+KUlILy9SK/RjpeXDiDUEAq4T94ADPHE3qaRkf66mpEhzc/ytOMm3Bwdrbq6k1tMWkbdujiKim3G2tfQARuJw==} engines: {node: '>= 10.13'} dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 json-stringify-safe: 5.0.1 lodash: 4.17.21 propagate: 2.0.1 @@ -3704,7 +3716,7 @@ packages: requiresBuild: true dependencies: pako: 2.1.0 - ws: 8.17.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) + ws: 8.17.1 transitivePeerDependencies: - bufferutil - utf-8-validate @@ -4103,6 +4115,19 @@ packages: utf-8-validate: optional: true + /ws@8.17.1: + resolution: {integrity: sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + dev: false + /ws@8.17.1(bufferutil@4.0.8)(utf-8-validate@5.0.10): resolution: {integrity: sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==} engines: {node: '>=10.0.0'} @@ -4212,6 +4237,7 @@ packages: file:../client-api/parachain-api: resolution: {directory: ../client-api/parachain-api, type: directory} name: '@litentry/parachain-api' + version: 0.9.20-04.1 dependencies: '@polkadot/api': 10.9.1 '@polkadot/api-augment': 10.9.1 @@ -4236,6 +4262,7 @@ packages: file:../client-api/sidechain-api: resolution: {directory: ../client-api/sidechain-api, type: directory} name: '@litentry/sidechain-api' + version: 0.9.20-04 dependencies: '@polkadot/api': 10.9.1 '@polkadot/api-augment': 10.9.1 diff --git a/tee-worker/identity/ts-tests/post-checks/package.json b/tee-worker/identity/ts-tests/post-checks/package.json index 9539aca9e3..10177e8239 100644 --- a/tee-worker/identity/ts-tests/post-checks/package.json +++ b/tee-worker/identity/ts-tests/post-checks/package.json @@ -5,13 +5,13 @@ "type": "module", "main": "index.js", "scripts": { - "start": "mocha --timeout 20000 --exit --sort -r ts-node/register --loader=ts-node/esm ./tests/**/*.test.ts" + "start": "LITENTRY_NETWORK='litentry-dev' mocha --timeout 20000 --exit --sort -r ts-node/register --loader=ts-node/esm ./tests/**/*.test.ts" }, "dependencies": { "@litentry/chaindata": "^0.2.0", - "@litentry/enclave": "^4.1.0", - "@litentry/parachain-api": "0.9.18-11.2", - "@litentry/sidechain-api": "0.9.18-11", + "@litentry/client-sdk": "^1.0.0", + "@litentry/parachain-api": "0.9.20-4.1", + "@litentry/sidechain-api": "0.9.20-4", "@polkadot/api": "^10.9.1", "@polkadot/util": "^12.5.1", "@polkadot/util-crypto": "^12.5.1", diff --git a/tee-worker/identity/ts-tests/post-checks/tests/post-check.test.ts b/tee-worker/identity/ts-tests/post-checks/tests/post-check.test.ts index 6b63ece352..9b7fafecac 100644 --- a/tee-worker/identity/ts-tests/post-checks/tests/post-check.test.ts +++ b/tee-worker/identity/ts-tests/post-checks/tests/post-check.test.ts @@ -2,10 +2,9 @@ import WebSocket from 'ws'; import { assert } from 'chai'; import { webcrypto } from 'crypto'; import { ApiPromise, Keyring, WsProvider } from '@polkadot/api'; -import { cryptoWaitReady } from '@polkadot/util-crypto'; import { identity, trusted_operations, sidechain, vc } from '@litentry/parachain-api'; -import { request, createLitentryIdentityType, createLitentryValidationDataType } from '@litentry/enclave'; +import { request, createLitentryIdentityType } from '@litentry/client-sdk'; import { nodeEndpoint, enclaveEndpoint } from '../config'; import { u8aToHex, u8aToString } from '@polkadot/util';