Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating client libraries to add auth token authentication support #3219

Open
wants to merge 21 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tee-worker/identity/client-api/parachain-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "dist/src/index.js",
"module": "dist/src/index.js",
"sideEffects": false,
"version": "0.9.21-next.0",
"version": "0.9.21-next.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the update content in the changelog file.Thank you.

"scripts": {
"clean": "rm -rf dist build node_modules",
"update-metadata": "curl -s -H \"Content-Type: application/json\" -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9944 > prepare-build/litentry-parachain-metadata.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ export default {
Private: "(Bytes,H256)",
},
},

AuthOptions: {
expires_at: "u32",
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
_enum: {
Web3: "LitentryMultiSignature",
Email: "Text",
AuthToken: "Text",
},
},
TrustedCallAuthenticated: {
Expand Down Expand Up @@ -89,6 +90,7 @@ export default {
add_account: "(LitentryIdentity, LitentryIdentity, LitentryValidationData, bool)",
remove_accounts: "(LitentryIdentity, Vec<LitentryIdentity>)",
publicize_account: "(LitentryIdentity, LitentryIdentity)",
request_auth_token: "(LitentryIdentity, AuthOptions)",
},
},
TrustedOperationStatus: {
Expand Down Expand Up @@ -117,6 +119,7 @@ export default {
_enum: {
ExtrinsicReport: "ExtrinsicReport",
RequestVcResult: "RequestVcResultOrError",
AuthToken: "Text",
},
},
ExtrinsicReport: {
Expand Down
112 changes: 56 additions & 56 deletions tee-worker/identity/client-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
{
"name": "@litentry-client-sdk/source",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"test": "nx affected --base=dev --target=test --plain",
"lint": "nx affected --base=dev --target=lint --plain",
"clean": "pnpm clean:dist; pnpm clean:packages",
"clean:dist": "rm -rf dist",
"clean:packages": "rm -rf node_modules && pnpm -r exec rm -rf node_modules && pnpm i"
},
"private": true,
"dependencies": {
"@polkadot/api": "^15.0.1",
"@polkadot/types": "^15.0.1",
"@polkadot/types-codec": "^15.0.1",
"@polkadot/util": "^13.2.3",
"@polkadot/util-crypto": "^13.2.3",
"ts-node": "10.9.1",
"tslib": "^2.5.3",
"ws": "^8.17.1"
},
"devDependencies": {
"@altack/nx-bundlefy": "0.16.0",
"@nx/devkit": "16.10.0",
"@nx/eslint-plugin": "16.10.0",
"@nx/jest": "16.10.0",
"@nx/js": "16.10.0",
"@nx/linter": "16.10.0",
"@nx/workspace": "16.10.0",
"@polkadot/api-base": "^10.9.1",
"@polkadot/rpc-core": "^10.9.1",
"@polkadot/rpc-provider": "^10.9.1",
"@swc-node/register": "^1.8.0",
"@swc/core": "^1.4.17",
"@types/jest": "^29.4.0",
"@types/node": "18.7.1",
"@types/ws": "^8.5.9",
"@typescript-eslint/eslint-plugin": "5.x",
"@typescript-eslint/parser": "5.x",
"eslint": "~8.46.0",
"eslint-config-prettier": "^8.1.0",
"jest": "^29.4.1",
"jest-environment-node": "^29.4.1",
"nx": "^17.3.2",
"prettier": "^2.8.3",
"ts-jest": "^29.1.0",
"typedoc": "^0.25.3",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "5.4.5",
"validate-npm-package-name": "^5.0.0",
"verdaccio": "^5.0.4"
},
"nx": {
"includedScripts": []
},
"packageManager": "pnpm@8.7.6"
"name": "@litentry-client-sdk/source",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"test": "nx affected --base=dev --target=test --plain",
"lint": "nx affected --base=dev --target=lint --plain",
"clean": "pnpm clean:dist; pnpm clean:packages",
"clean:dist": "rm -rf dist",
"clean:packages": "rm -rf node_modules && pnpm -r exec rm -rf node_modules && pnpm i"
},
"private": true,
"dependencies": {
"@polkadot/api": "^15.0.1",
"@polkadot/types": "^15.0.1",
"@polkadot/types-codec": "^15.0.1",
"@polkadot/util": "^13.2.3",
"@polkadot/util-crypto": "^13.2.3",
"ts-node": "10.9.1",
"tslib": "^2.5.3",
"ws": "^8.17.1"
},
"devDependencies": {
"@altack/nx-bundlefy": "0.16.0",
"@nx/devkit": "^17.3.2",
"@nx/eslint-plugin": "^17.3.2",
"@nx/jest": "^17.3.2",
"@nx/js": "^17.3.2",
"@nx/linter": "^17.3.2",
"@nx/workspace": "^17.3.2",
"@polkadot/api-base": "^10.9.1",
"@polkadot/rpc-core": "^10.9.1",
"@polkadot/rpc-provider": "^10.9.1",
"@swc-node/register": "^1.8.0",
"@swc/core": "^1.4.17",
"@types/jest": "^29.4.0",
"@types/node": "18.7.1",
"@types/ws": "^8.5.9",
"@typescript-eslint/eslint-plugin": "5.x",
"@typescript-eslint/parser": "5.x",
"eslint": "~8.46.0",
"eslint-config-prettier": "^8.1.0",
"jest": "^29.4.1",
"jest-environment-node": "^29.4.1",
"nx": "^17.3.2",
"prettier": "^2.8.3",
"ts-jest": "^29.1.0",
"typedoc": "^0.25.3",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "5.4.5",
"validate-npm-package-name": "^5.0.0",
"verdaccio": "^5.0.4"
},
"nx": {
"includedScripts": []
},
"packageManager": "pnpm@8.7.6"
}
77 changes: 53 additions & 24 deletions tee-worker/identity/client-sdk/packages/client-sdk/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

### Type Aliases

- [AuthenticationData](README.md#authenticationdata)
- [DiscordOAuth2Proof](README.md#discordoauth2proof)
- [DiscordProof](README.md#discordproof)
- [EmailProof](README.md#emailproof)
Expand Down Expand Up @@ -54,6 +55,16 @@ Re-exports [getIdGraphHash](modules/request.md#getidgraphhash)

## Type Aliases

### AuthenticationData

Ƭ **AuthenticationData**: \{ `type`: ``"Email"`` ; `verificationCode`: `string` } \| \{ `signature`: `string` ; `signer`: `LitentryIdentity` ; `type`: ``"Web3"`` } \| \{ `token`: `string` ; `type`: ``"AuthToken"`` }

#### Defined in

[lib/type-creators/tc-authentication.ts:5](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/tc-authentication.ts#L5)

___

### DiscordOAuth2Proof

Ƭ **DiscordOAuth2Proof**: `Object`
Expand Down Expand Up @@ -335,7 +346,7 @@ Heads-up: ensure data.ciphertext is in hex format. Using Uint may cause a bytes
| Name | Type |
| :------ | :------ |
| `registry` | `Registry` |
| `data` | \`0x$\{string}\` \| \{ `aad`: \`0x$\{string}\` \| `Uint8Array`\<`ArrayBufferLike`\> ; `ciphertext`: \`0x$\{string}\` ; `nonce`: \`0x$\{string}\` \| `Uint8Array`\<`ArrayBufferLike`\> } |
| `data` | \`0x$\{string}\` \| \{ `aad`: \`0x$\{string}\` \| `Uint8Array` ; `ciphertext`: \`0x$\{string}\` ; `nonce`: \`0x$\{string}\` \| `Uint8Array` } |

#### Returns

Expand Down Expand Up @@ -382,7 +393,7 @@ For Substrate, the address is expected to be a SS58-encoded or hex-encoded addre
| Name | Type |
| :------ | :------ |
| `registry` | `Registry` |
| `data` | \`0x$\{string}\` \| `Uint8Array`\<`ArrayBufferLike`\> \| \{ `addressOrHandle`: `string` ; `type`: ``"Solana"`` \| ``"Twitter"`` \| ``"Discord"`` \| ``"Github"`` \| ``"Substrate"`` \| ``"Evm"`` \| ``"Bitcoin"`` \| ``"Email"`` } |
| `data` | \`0x$\{string}\` \| `Uint8Array` \| \{ `addressOrHandle`: `string` ; `type`: ``"Solana"`` \| ``"Twitter"`` \| ``"Discord"`` \| ``"Github"`` \| ``"Substrate"`` \| ``"Evm"`` \| ``"Bitcoin"`` \| ``"Email"`` } |

#### Returns

Expand Down Expand Up @@ -504,23 +515,22 @@ The shielding key is encrypted using the Enclave's shielding key and attached in

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `api` | `ApiPromise` | - |
| `data` | `Object` | - |
| `data.authentication` | `string` | signature or verification code based on the identity type |
| `data.call` | `TrustedCall` | - |
| `data.nonce` | `Index` | - |
| `data.sender` | `LitentryIdentity` | - |
| `data.shard` | `Uint8Array`\<`ArrayBufferLike`\> | - |
| Name | Type |
| :------ | :------ |
| `api` | `ApiPromise` |
| `data` | `Object` |
| `data.authentication` | [`AuthenticationData`](README.md#authenticationdata) |
| `data.call` | `TrustedCall` |
| `data.nonce` | `Index` |
| `data.shard` | `Uint8Array` |

#### Returns

`Promise`\<`AesRequest`\>

#### Defined in

[lib/type-creators/request.ts:32](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/request.ts#L32)
[lib/type-creators/request.ts:33](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/request.ts#L33)

___

Expand All @@ -533,15 +543,15 @@ ___
| Name | Type |
| :------ | :------ |
| `registry` | `Registry` |
| `data` | `AuthenticationData` |
| `data` | [`AuthenticationData`](README.md#authenticationdata) |

#### Returns

`TCAuthentication`

#### Defined in

[lib/type-creators/tc-authentication.ts:16](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/tc-authentication.ts#L16)
[lib/type-creators/tc-authentication.ts:20](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/tc-authentication.ts#L20)

___

Expand Down Expand Up @@ -576,7 +586,7 @@ Similarly, our types definitions must match also.

#### Defined in

[lib/type-creators/trusted-call.ts:110](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L110)
[lib/type-creators/trusted-call.ts:117](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L117)

▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\>

Expand All @@ -595,7 +605,7 @@ Similarly, our types definitions must match also.

#### Defined in

[lib/type-creators/trusted-call.ts:117](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L117)
[lib/type-creators/trusted-call.ts:124](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L124)

▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\>

Expand All @@ -614,7 +624,7 @@ Similarly, our types definitions must match also.

#### Defined in

[lib/type-creators/trusted-call.ts:124](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L124)
[lib/type-creators/trusted-call.ts:131](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L131)

▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\>

Expand All @@ -633,7 +643,7 @@ Similarly, our types definitions must match also.

#### Defined in

[lib/type-creators/trusted-call.ts:131](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L131)
[lib/type-creators/trusted-call.ts:138](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L138)

▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\>

Expand All @@ -652,7 +662,7 @@ Similarly, our types definitions must match also.

#### Defined in

[lib/type-creators/trusted-call.ts:138](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L138)
[lib/type-creators/trusted-call.ts:145](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L145)

▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\>

Expand All @@ -671,7 +681,7 @@ Similarly, our types definitions must match also.

#### Defined in

[lib/type-creators/trusted-call.ts:145](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L145)
[lib/type-creators/trusted-call.ts:152](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L152)

▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\>

Expand All @@ -690,7 +700,7 @@ Similarly, our types definitions must match also.

#### Defined in

[lib/type-creators/trusted-call.ts:152](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L152)
[lib/type-creators/trusted-call.ts:159](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L159)

▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\>

Expand All @@ -709,7 +719,7 @@ Similarly, our types definitions must match also.

#### Defined in

[lib/type-creators/trusted-call.ts:159](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L159)
[lib/type-creators/trusted-call.ts:166](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L166)

▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\>

Expand All @@ -728,7 +738,26 @@ Similarly, our types definitions must match also.

#### Defined in

[lib/type-creators/trusted-call.ts:166](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L166)
[lib/type-creators/trusted-call.ts:173](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L173)

▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `registry` | `Registry` |
| `data` | `Object` |
| `data.method` | ``"request_auth_token"`` |
| `data.params` | `RequestAuthTokenParams` |

#### Returns

`Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\>

#### Defined in

[lib/type-creators/trusted-call.ts:180](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L180)

▸ **createTrustedCallType**(`registry`, `data`): `Promise`\<\{ `call`: `TrustedCall` ; `key`: `CryptoKey` }\>

Expand All @@ -747,7 +776,7 @@ Similarly, our types definitions must match also.

#### Defined in

[lib/type-creators/trusted-call.ts:173](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L173)
[lib/type-creators/trusted-call.ts:187](https://github.com/litentry/client-sdk/blob/develop/lib/type-creators/trusted-call.ts#L187)

___

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ ___

### encrypt

▸ **encrypt**(`api`, `args`): `Promise`\<\{ `ciphertext`: `Uint8Array`\<`ArrayBufferLike`\> }\>
▸ **encrypt**(`api`, `args`): `Promise`\<\{ `ciphertext`: `Uint8Array` }\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `api` | `ApiPromise` |
| `args` | `Object` |
| `args.cleartext` | `Uint8Array`\<`ArrayBufferLike`\> |
| `args.cleartext` | `Uint8Array` |

#### Returns

`Promise`\<\{ `ciphertext`: `Uint8Array`\<`ArrayBufferLike`\> }\>
`Promise`\<\{ `ciphertext`: `Uint8Array` }\>

#### Defined in

Expand Down
Loading
Loading