diff --git a/docs/assets/highlight.css b/docs/assets/highlight.css index 9e039a4..5674cf3 100644 --- a/docs/assets/highlight.css +++ b/docs/assets/highlight.css @@ -1,85 +1,22 @@ :root { - --light-hl-0: #000000; - --dark-hl-0: #D4D4D4; - --light-hl-1: #A31515; - --dark-hl-1: #CE9178; - --light-hl-2: #AF00DB; - --dark-hl-2: #C586C0; - --light-hl-3: #001080; - --dark-hl-3: #9CDCFE; - --light-hl-4: #795E26; - --dark-hl-4: #DCDCAA; - --light-hl-5: #267F99; - --dark-hl-5: #4EC9B0; - --light-hl-6: #0000FF; - --dark-hl-6: #569CD6; - --light-hl-7: #0070C1; - --dark-hl-7: #4FC1FF; - --light-hl-8: #008000; - --dark-hl-8: #6A9955; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } @media (prefers-color-scheme: light) { :root { - --hl-0: var(--light-hl-0); - --hl-1: var(--light-hl-1); - --hl-2: var(--light-hl-2); - --hl-3: var(--light-hl-3); - --hl-4: var(--light-hl-4); - --hl-5: var(--light-hl-5); - --hl-6: var(--light-hl-6); - --hl-7: var(--light-hl-7); - --hl-8: var(--light-hl-8); --code-background: var(--light-code-background); } } @media (prefers-color-scheme: dark) { :root { - --hl-0: var(--dark-hl-0); - --hl-1: var(--dark-hl-1); - --hl-2: var(--dark-hl-2); - --hl-3: var(--dark-hl-3); - --hl-4: var(--dark-hl-4); - --hl-5: var(--dark-hl-5); - --hl-6: var(--dark-hl-6); - --hl-7: var(--dark-hl-7); - --hl-8: var(--dark-hl-8); --code-background: var(--dark-code-background); } } :root[data-theme='light'] { - --hl-0: var(--light-hl-0); - --hl-1: var(--light-hl-1); - --hl-2: var(--light-hl-2); - --hl-3: var(--light-hl-3); - --hl-4: var(--light-hl-4); - --hl-5: var(--light-hl-5); - --hl-6: var(--light-hl-6); - --hl-7: var(--light-hl-7); - --hl-8: var(--light-hl-8); --code-background: var(--light-code-background); } :root[data-theme='dark'] { - --hl-0: var(--dark-hl-0); - --hl-1: var(--dark-hl-1); - --hl-2: var(--dark-hl-2); - --hl-3: var(--dark-hl-3); - --hl-4: var(--dark-hl-4); - --hl-5: var(--dark-hl-5); - --hl-6: var(--dark-hl-6); - --hl-7: var(--dark-hl-7); - --hl-8: var(--dark-hl-8); --code-background: var(--dark-code-background); } -.hl-0 { color: var(--hl-0); } -.hl-1 { color: var(--hl-1); } -.hl-2 { color: var(--hl-2); } -.hl-3 { color: var(--hl-3); } -.hl-4 { color: var(--hl-4); } -.hl-5 { color: var(--hl-5); } -.hl-6 { color: var(--hl-6); } -.hl-7 { color: var(--hl-7); } -.hl-8 { color: var(--hl-8); } pre, code { background: var(--code-background); } diff --git a/docs/assets/search.js b/docs/assets/search.js index 1c85112..447e9ae 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = JSON.parse("{\"kinds\":{\"32\":\"Variable\",\"64\":\"Function\",\"128\":\"Class\",\"512\":\"Constructor\",\"2048\":\"Method\"},\"rows\":[{\"kind\":32,\"name\":\"SIGN_X_LOGIN\",\"url\":\"variables/SIGN_X_LOGIN.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":32,\"name\":\"SIGN_X_LOGIN_SUCCESS\",\"url\":\"variables/SIGN_X_LOGIN_SUCCESS.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":32,\"name\":\"SIGN_X_LOGIN_ERROR\",\"url\":\"variables/SIGN_X_LOGIN_ERROR.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":32,\"name\":\"SIGN_X_TRANSACT\",\"url\":\"variables/SIGN_X_TRANSACT.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":32,\"name\":\"SIGN_X_TRANSACT_SUCCESS\",\"url\":\"variables/SIGN_X_TRANSACT_SUCCESS.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":32,\"name\":\"SIGN_X_TRANSACT_ERROR\",\"url\":\"variables/SIGN_X_TRANSACT_ERROR.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":64,\"name\":\"hashTransactData\",\"url\":\"functions/hashTransactData.html\",\"classes\":\"tsd-kind-function\"},{\"kind\":64,\"name\":\"generateSecureHash\",\"url\":\"functions/generateSecureHash.html\",\"classes\":\"tsd-kind-function\"},{\"kind\":128,\"name\":\"Random\",\"url\":\"classes/Random.html\",\"classes\":\"tsd-kind-class\"},{\"kind\":2048,\"name\":\"getBytes\",\"url\":\"classes/Random.html#getBytes\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Random\"},{\"kind\":2048,\"name\":\"getHex\",\"url\":\"classes/Random.html#getHex\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Random\"},{\"kind\":512,\"name\":\"constructor\",\"url\":\"classes/Random.html#constructor\",\"classes\":\"tsd-kind-constructor tsd-parent-kind-class\",\"parent\":\"Random\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"comment\"],\"fieldVectors\":[[\"name/0\",[0,21.595]],[\"comment/0\",[]],[\"name/1\",[1,21.595]],[\"comment/1\",[]],[\"name/2\",[2,21.595]],[\"comment/2\",[]],[\"name/3\",[3,21.595]],[\"comment/3\",[]],[\"name/4\",[4,21.595]],[\"comment/4\",[]],[\"name/5\",[5,21.595]],[\"comment/5\",[]],[\"name/6\",[6,21.595]],[\"comment/6\",[]],[\"name/7\",[7,21.595]],[\"comment/7\",[]],[\"name/8\",[8,21.595]],[\"comment/8\",[]],[\"name/9\",[9,21.595]],[\"comment/9\",[]],[\"name/10\",[10,21.595]],[\"comment/10\",[]],[\"name/11\",[11,21.595]],[\"comment/11\",[]]],\"invertedIndex\":[[\"constructor\",{\"_index\":11,\"name\":{\"11\":{}},\"comment\":{}}],[\"generatesecurehash\",{\"_index\":7,\"name\":{\"7\":{}},\"comment\":{}}],[\"getbytes\",{\"_index\":9,\"name\":{\"9\":{}},\"comment\":{}}],[\"gethex\",{\"_index\":10,\"name\":{\"10\":{}},\"comment\":{}}],[\"hashtransactdata\",{\"_index\":6,\"name\":{\"6\":{}},\"comment\":{}}],[\"random\",{\"_index\":8,\"name\":{\"8\":{}},\"comment\":{}}],[\"sign_x_login\",{\"_index\":0,\"name\":{\"0\":{}},\"comment\":{}}],[\"sign_x_login_error\",{\"_index\":2,\"name\":{\"2\":{}},\"comment\":{}}],[\"sign_x_login_success\",{\"_index\":1,\"name\":{\"1\":{}},\"comment\":{}}],[\"sign_x_transact\",{\"_index\":3,\"name\":{\"3\":{}},\"comment\":{}}],[\"sign_x_transact_error\",{\"_index\":5,\"name\":{\"5\":{}},\"comment\":{}}],[\"sign_x_transact_success\",{\"_index\":4,\"name\":{\"4\":{}},\"comment\":{}}]],\"pipeline\":[]}}"); \ No newline at end of file +window.searchData = JSON.parse("{\"kinds\":{\"32\":\"Variable\",\"64\":\"Function\",\"128\":\"Class\",\"512\":\"Constructor\",\"2048\":\"Method\"},\"rows\":[{\"kind\":32,\"name\":\"SIGN_X_LOGIN\",\"url\":\"variables/SIGN_X_LOGIN.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":32,\"name\":\"SIGN_X_LOGIN_SUCCESS\",\"url\":\"variables/SIGN_X_LOGIN_SUCCESS.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":32,\"name\":\"SIGN_X_LOGIN_ERROR\",\"url\":\"variables/SIGN_X_LOGIN_ERROR.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":32,\"name\":\"SIGN_X_TRANSACT\",\"url\":\"variables/SIGN_X_TRANSACT.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":32,\"name\":\"SIGN_X_TRANSACT_SUCCESS\",\"url\":\"variables/SIGN_X_TRANSACT_SUCCESS.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":32,\"name\":\"SIGN_X_TRANSACT_ERROR\",\"url\":\"variables/SIGN_X_TRANSACT_ERROR.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":32,\"name\":\"VERSION\",\"url\":\"variables/VERSION.html\",\"classes\":\"tsd-kind-variable\"},{\"kind\":64,\"name\":\"hashTransactData\",\"url\":\"functions/hashTransactData.html\",\"classes\":\"tsd-kind-function\"},{\"kind\":64,\"name\":\"generateSecureHash\",\"url\":\"functions/generateSecureHash.html\",\"classes\":\"tsd-kind-function\"},{\"kind\":64,\"name\":\"convertDataToDeeplink\",\"url\":\"functions/convertDataToDeeplink.html\",\"classes\":\"tsd-kind-function\"},{\"kind\":128,\"name\":\"Random\",\"url\":\"classes/Random.html\",\"classes\":\"tsd-kind-class\"},{\"kind\":2048,\"name\":\"getBytes\",\"url\":\"classes/Random.html#getBytes\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Random\"},{\"kind\":2048,\"name\":\"getHex\",\"url\":\"classes/Random.html#getHex\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Random\"},{\"kind\":512,\"name\":\"constructor\",\"url\":\"classes/Random.html#constructor\",\"classes\":\"tsd-kind-constructor tsd-parent-kind-class\",\"parent\":\"Random\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"comment\"],\"fieldVectors\":[[\"name/0\",[0,23.026]],[\"comment/0\",[]],[\"name/1\",[1,23.026]],[\"comment/1\",[]],[\"name/2\",[2,23.026]],[\"comment/2\",[]],[\"name/3\",[3,23.026]],[\"comment/3\",[]],[\"name/4\",[4,23.026]],[\"comment/4\",[]],[\"name/5\",[5,23.026]],[\"comment/5\",[]],[\"name/6\",[6,23.026]],[\"comment/6\",[]],[\"name/7\",[7,23.026]],[\"comment/7\",[]],[\"name/8\",[8,23.026]],[\"comment/8\",[]],[\"name/9\",[9,23.026]],[\"comment/9\",[]],[\"name/10\",[10,23.026]],[\"comment/10\",[]],[\"name/11\",[11,23.026]],[\"comment/11\",[]],[\"name/12\",[12,23.026]],[\"comment/12\",[]],[\"name/13\",[13,23.026]],[\"comment/13\",[]]],\"invertedIndex\":[[\"constructor\",{\"_index\":13,\"name\":{\"13\":{}},\"comment\":{}}],[\"convertdatatodeeplink\",{\"_index\":9,\"name\":{\"9\":{}},\"comment\":{}}],[\"generatesecurehash\",{\"_index\":8,\"name\":{\"8\":{}},\"comment\":{}}],[\"getbytes\",{\"_index\":11,\"name\":{\"11\":{}},\"comment\":{}}],[\"gethex\",{\"_index\":12,\"name\":{\"12\":{}},\"comment\":{}}],[\"hashtransactdata\",{\"_index\":7,\"name\":{\"7\":{}},\"comment\":{}}],[\"random\",{\"_index\":10,\"name\":{\"10\":{}},\"comment\":{}}],[\"sign_x_login\",{\"_index\":0,\"name\":{\"0\":{}},\"comment\":{}}],[\"sign_x_login_error\",{\"_index\":2,\"name\":{\"2\":{}},\"comment\":{}}],[\"sign_x_login_success\",{\"_index\":1,\"name\":{\"1\":{}},\"comment\":{}}],[\"sign_x_transact\",{\"_index\":3,\"name\":{\"3\":{}},\"comment\":{}}],[\"sign_x_transact_error\",{\"_index\":5,\"name\":{\"5\":{}},\"comment\":{}}],[\"sign_x_transact_success\",{\"_index\":4,\"name\":{\"4\":{}},\"comment\":{}}],[\"version\",{\"_index\":6,\"name\":{\"6\":{}},\"comment\":{}}]],\"pipeline\":[]}}"); \ No newline at end of file diff --git a/docs/functions/convertDataToDeeplink.html b/docs/functions/convertDataToDeeplink.html new file mode 100644 index 0000000..cc08a7e --- /dev/null +++ b/docs/functions/convertDataToDeeplink.html @@ -0,0 +1,68 @@ +convertDataToDeeplink | @ixo/signx
+
+ +
+
+
+
+ +

Function convertDataToDeeplink

+
+
    + +
  • +
    +

    Parameters

    +
      +
    • +
      data: LOGIN_DATA | TRANSACT_DATA
    • +
    • +
      scheme: string = 'impactsx'
    +

    Returns string

+
+
+

Generated using TypeDoc

+
\ No newline at end of file diff --git a/docs/functions/generateSecureHash.html b/docs/functions/generateSecureHash.html index 0d89076..1d79dc0 100644 --- a/docs/functions/generateSecureHash.html +++ b/docs/functions/generateSecureHash.html @@ -28,7 +28,7 @@
hash: string
nonce: string

Returns string

+
  • Defined in utils/encoding.ts:17
  • Generated using TypeDoc

    diff --git a/docs/functions/hashTransactData.html b/docs/functions/hashTransactData.html index 102da11..15e582b 100644 --- a/docs/functions/hashTransactData.html +++ b/docs/functions/hashTransactData.html @@ -26,7 +26,7 @@

    Parameters

    data: TRANSACT_DTO

    Returns string

    +
  • Defined in utils/encoding.ts:6
  • Generated using TypeDoc

    diff --git a/docs/index.html b/docs/index.html index f19159a..a3287e6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -12,106 +12,7 @@

    @ixo/signx

    -
    - -

    COSMOS CHAIN RESOLVER 🔗

    -
    -

    GitHub contributors -GitHub repo size -Twitter Follow -Medium

    -

    NodeJSTypeScript

    -

    - -

    - -
    - -

    - An SDK to fetch and filter chain information -

    - -
    - -

    This repo and product is intentionally managed as Open Source and we aim to use this guide to light our way https://opensource.guide/. -Let us know how we are doing!

    - - -

    🔨 Install

    -
    -
    npm install @ixo/cosmos-chain-resolver

    yarn add @ixo/cosmos-chain-resolver -
    - - -

    💻 Usage

    -
    -

    To use the Cosmos Chain Resolver, you can import the function(s) you want to use and execute it with the appropriate parameters.

    -
    import {
    getRegistryChainInfo,
    getActiveRpcFromRegistryChainInfo,
    getActiveRpcFromChainName,
    getChainExplorer,
    getChainExplorerAsync,
    getKeplrChainInfoFromRegistryChainInfo,
    getKeplrChainInfo,
    } from '@ixo/cosmos-chain-resolver'; -
    -

    The Cosmos Chain Resolver SDK expose the following functions:

    - - -

    getRegistryChainInfo

    -
    -
    getRegistryChainInfo(chainName: string, chainNetwork?: ChainNetwork): Promise<RegistryChainInfo>
    -
    -

    This function fetches the chain info for the provided chainName and chainNetwork. If chainNetwork is not provided, it defaults to mainnet.

    - - -

    getActiveRpcFromRegistryChainInfo

    -
    -
    getActiveRpcFromRegistryChainInfo(chainInfo: RegistryChainInfo): Promise<string>
    -
    -

    This function filters through and fetches an active RPC endpoint from the provided chainInfo.

    - - -

    getActiveRpcFromChainName

    -
    -
    getActiveRpcFromChainName(chainName: string, chainNetwork?: ChainNetwork): Promise<string>
    -
    -

    This function fetches an active RPC endpoint for the provided chainName and chainNetwork. If chainNetwork is not provided, it defaults to mainnet.

    - - -

    getChainExplorer

    -
    -
    getChainExplorer(chainName: string, chainNetwork: ChainNetwork, chainExplorers?: ChainExplorer[]): KeplrChainExplorer | undefined
    -
    -

    This function fetches the tx explorer info for the provided chainName, chainNetwork and chainExplorers.

    - - -

    getChainExplorerAsync

    -
    -
    getChainExplorerAsync(chainName: string, chainNetwork: ChainNetwork): Promise<KeplrChainExplorer | undefined>
    -
    -

    This function fetches the tx explorer info for the provided chainName and chainNetwork via the Cosmos Chain Registry.

    - - -

    getKeplrChainInfoFromRegistryChainInfo

    -
    -
    getKeplrChainInfoFromRegistryChainInfo(chainInfo: RegistryChainInfo): Promise<KeplrChainInfo>
    -
    -

    This function fetches the keplr chain info for the provided chainInfo.

    - - -

    getKeplrChainInfo

    -
    -
    getKeplrChainInfo(chainNameOrId: string, chainNetwork: ChainNetwork = MAINNET, ): Promise<KeplrChainInfo>
    -
    -

    This function fetches the keplr chain info for the provided chain id or the chain name-and-network.

    - - -

    📱 Example

    -
    -
    import { getKeplrChainInfo } from '@ixo/cosmos-chain-resolver';

    // fetch chain info via chain id
    const ixoKeplrChainInfo = await getKeplrChainInfo('ixo-5');

    // fetch chain info via chain name and network
    const ixoTestnetKeplrChainInfo = await getKeplrChainInfo('impacthub', 'testnet'); -
    -
    import { getRegistryChainInfo, getKeplrChainInfoFromRegistryChainInfo } from '@ixo/cosmos-chain-resolver';

    // fetch chain info via chain id
    const ixoRegistryChainInfo = await getRegistryChainInfo('impacthub', 'mainnet');

    // fetch chain info via chain name and network
    const ixoKeplrChainInfo = await getKeplrChainInfoFromRegistryChainInfo(ixoRegistryChainInfo); -
    - - -

    📃 License

    -
    -

    This SDK is licensed under the Apache 2 License. See the LICENSE file for more information.

    -
    +

    Generated using TypeDoc

    diff --git a/docs/modules.html b/docs/modules.html index 0c5d179..9cb4195 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -27,10 +27,12 @@

    Variables

    SIGN_X_TRANSACT SIGN_X_TRANSACT_ERROR SIGN_X_TRANSACT_SUCCESS +VERSION

    Functions

    -
    generateSecureHash +
    diff --git a/docs/variables/SIGN_X_LOGIN.html b/docs/variables/SIGN_X_LOGIN.html index 2c0e565..8e585e7 100644 --- a/docs/variables/SIGN_X_LOGIN.html +++ b/docs/variables/SIGN_X_LOGIN.html @@ -48,7 +48,9 @@

    SIGN_X_TRANSACT
  • SIGN_X_TRANSACT_ERROR
  • SIGN_X_TRANSACT_SUCCESS
  • -
  • generateSecureHash
  • +
  • VERSION
  • +
  • convertDataToDeeplink
  • +
  • generateSecureHash
  • hashTransactData
  • Generated using TypeDoc

    diff --git a/docs/variables/SIGN_X_LOGIN_ERROR.html b/docs/variables/SIGN_X_LOGIN_ERROR.html index 079c8ff..9881e5e 100644 --- a/docs/variables/SIGN_X_LOGIN_ERROR.html +++ b/docs/variables/SIGN_X_LOGIN_ERROR.html @@ -48,7 +48,9 @@

    SIGN_X_TRANSACT
  • SIGN_X_TRANSACT_ERROR
  • SIGN_X_TRANSACT_SUCCESS
  • -
  • generateSecureHash
  • +
  • VERSION
  • +
  • convertDataToDeeplink
  • +
  • generateSecureHash
  • hashTransactData
  • Generated using TypeDoc

    diff --git a/docs/variables/SIGN_X_LOGIN_SUCCESS.html b/docs/variables/SIGN_X_LOGIN_SUCCESS.html index e5d7402..35eb221 100644 --- a/docs/variables/SIGN_X_LOGIN_SUCCESS.html +++ b/docs/variables/SIGN_X_LOGIN_SUCCESS.html @@ -48,7 +48,9 @@

    SIGN_X_TRANSACT
  • SIGN_X_TRANSACT_ERROR
  • SIGN_X_TRANSACT_SUCCESS
  • -
  • generateSecureHash
  • +
  • VERSION
  • +
  • convertDataToDeeplink
  • +
  • generateSecureHash
  • hashTransactData
  • Generated using TypeDoc

    diff --git a/docs/variables/SIGN_X_TRANSACT.html b/docs/variables/SIGN_X_TRANSACT.html index 7065744..eaaec40 100644 --- a/docs/variables/SIGN_X_TRANSACT.html +++ b/docs/variables/SIGN_X_TRANSACT.html @@ -48,7 +48,9 @@

    SIGN_X_TRANSACT
  • SIGN_X_TRANSACT_ERROR
  • SIGN_X_TRANSACT_SUCCESS
  • -
  • generateSecureHash
  • +
  • VERSION
  • +
  • convertDataToDeeplink
  • +
  • generateSecureHash
  • hashTransactData
  • Generated using TypeDoc

    diff --git a/docs/variables/SIGN_X_TRANSACT_ERROR.html b/docs/variables/SIGN_X_TRANSACT_ERROR.html index cab29a9..52fb9cb 100644 --- a/docs/variables/SIGN_X_TRANSACT_ERROR.html +++ b/docs/variables/SIGN_X_TRANSACT_ERROR.html @@ -48,7 +48,9 @@

    SIGN_X_TRANSACT
  • SIGN_X_TRANSACT_ERROR
  • SIGN_X_TRANSACT_SUCCESS
  • -
  • generateSecureHash
  • +
  • VERSION
  • +
  • convertDataToDeeplink
  • +
  • generateSecureHash
  • hashTransactData
  • Generated using TypeDoc

    diff --git a/docs/variables/SIGN_X_TRANSACT_SUCCESS.html b/docs/variables/SIGN_X_TRANSACT_SUCCESS.html index 8aed8a3..b6dad28 100644 --- a/docs/variables/SIGN_X_TRANSACT_SUCCESS.html +++ b/docs/variables/SIGN_X_TRANSACT_SUCCESS.html @@ -48,7 +48,9 @@

    SIGN_X_TRANSACT
  • SIGN_X_TRANSACT_ERROR
  • SIGN_X_TRANSACT_SUCCESS
  • -
  • generateSecureHash
  • +
  • VERSION
  • +
  • convertDataToDeeplink
  • +
  • generateSecureHash
  • hashTransactData
  • Generated using TypeDoc

    diff --git a/docs/variables/VERSION.html b/docs/variables/VERSION.html new file mode 100644 index 0000000..d85841c --- /dev/null +++ b/docs/variables/VERSION.html @@ -0,0 +1,57 @@ +VERSION | @ixo/signx
    +
    + +
    +
    +
    +
    + +

    Variable VERSIONConst

    +
    VERSION: 1 = 1
    +
    +
    +

    Generated using TypeDoc

    +
    \ No newline at end of file diff --git a/package.json b/package.json index a0a6734..d69ba5e 100644 --- a/package.json +++ b/package.json @@ -1,74 +1,74 @@ { - "name": "@ixo/signx", - "version": "0.0.1", - "description": "An SDK to manage the login and transaction signing process through Impacts X", - "author": "ixo", - "homepage": "https://github.com/ixofoundation/ixo-signx#readme", - "license": "SEE LICENSE IN LICENSE", - "main": "main/index.js", - "module": "module/index.js", - "typings": "types/index.d.ts", - "directories": { - "lib": "src" - }, - "files": [ - "types", - "main", - "module" - ], - "scripts": { - "build:local": "npm pack", - "build:main": "cross-env BABEL_ENV=production babel src --out-dir main --delete-dir-on-start --extensions \".tsx,.ts,.js\"", - "build:module": "cross-env MODULE=true babel src --out-dir module --delete-dir-on-start --extensions \".tsx,.ts,.js\"", - "build:ts": "tsc --project ./tsconfig.json", - "build:docs": "typedoc src/index.ts", - "build": "npm run build:module && npm run build:main", - "build:prepare": "npm run build && npm run build:ts && npm run build:docs", - "prepare": "npm run build", - "lint": "eslint src --fix" - }, - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/ixofoundation/ixo-signx" - }, - "keywords": [ - "cosmos", - "chain", - "ixo", - "signx" - ], - "bugs": { - "url": "https://github.com/ixofoundation/ixo-signx/issues" - }, - "devDependencies": { - "@babel/cli": "7.19.3", - "@babel/core": "7.19.3", - "@babel/eslint-parser": "7.19.1", - "@babel/node": "7.19.1", - "@babel/plugin-proposal-class-properties": "7.18.6", - "@babel/plugin-proposal-export-default-from": "7.18.10", - "@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6", - "@babel/plugin-proposal-numeric-separator": "7.18.6", - "@babel/plugin-proposal-object-rest-spread": "7.19.4", - "@babel/plugin-proposal-optional-chaining": "7.18.9", - "@babel/plugin-transform-runtime": "7.19.1", - "@babel/preset-env": "7.19.4", - "@babel/preset-typescript": "7.18.6", - "babel-core": "7.0.0-bridge.0", - "babel-jest": "29.1.2", - "babel-watch": "7.0.0", - "cross-env": "7.0.2", - "eslint": "8.25.0", - "eslint-config-prettier": "8.5.0", - "eslint-plugin-prettier": "4.2.1", - "typedoc": "0.23.28", - "typescript": "5.0.2" - }, - "dependencies": { - "@babel/runtime": "7.19.4", - "axios": "1.3.4" - } -} \ No newline at end of file + "name": "@ixo/signx", + "version": "0.0.2", + "description": "An SDK to manage the login and transaction signing process through Impacts X", + "author": "ixo", + "homepage": "https://github.com/ixofoundation/ixo-signx#readme", + "license": "SEE LICENSE IN LICENSE", + "main": "main/index.js", + "module": "module/index.js", + "typings": "types/index.d.ts", + "directories": { + "lib": "src" + }, + "files": [ + "types", + "main", + "module" + ], + "scripts": { + "build:local": "npm pack", + "build:main": "cross-env BABEL_ENV=production babel src --out-dir main --delete-dir-on-start --extensions \".tsx,.ts,.js\"", + "build:module": "cross-env MODULE=true babel src --out-dir module --delete-dir-on-start --extensions \".tsx,.ts,.js\"", + "build:ts": "tsc --project ./tsconfig.json", + "build:docs": "typedoc src/index.ts", + "build": "npm run build:module && npm run build:main", + "build:prepare": "npm run build && npm run build:ts && npm run build:docs", + "prepare": "npm run build", + "lint": "eslint src --fix" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/ixofoundation/ixo-signx" + }, + "keywords": [ + "cosmos", + "chain", + "ixo", + "signx" + ], + "bugs": { + "url": "https://github.com/ixofoundation/ixo-signx/issues" + }, + "devDependencies": { + "@babel/cli": "7.19.3", + "@babel/core": "7.19.3", + "@babel/eslint-parser": "7.19.1", + "@babel/node": "7.19.1", + "@babel/plugin-proposal-class-properties": "7.18.6", + "@babel/plugin-proposal-export-default-from": "7.18.10", + "@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6", + "@babel/plugin-proposal-numeric-separator": "7.18.6", + "@babel/plugin-proposal-object-rest-spread": "7.19.4", + "@babel/plugin-proposal-optional-chaining": "7.18.9", + "@babel/plugin-transform-runtime": "7.19.1", + "@babel/preset-env": "7.19.4", + "@babel/preset-typescript": "7.18.6", + "babel-core": "7.0.0-bridge.0", + "babel-jest": "29.1.2", + "babel-watch": "7.0.0", + "cross-env": "7.0.2", + "eslint": "8.25.0", + "eslint-config-prettier": "8.5.0", + "eslint-plugin-prettier": "4.2.1", + "typedoc": "0.23.28", + "typescript": "5.0.2" + }, + "dependencies": { + "@babel/runtime": "7.19.4", + "axios": "1.3.4" + } +} diff --git a/src/client.ts b/src/client.ts index e315391..b0866e3 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,19 +1,19 @@ import axios from 'axios'; import { EventEmitter } from 'events'; -import { Random } from './utils/random'; -import { NETWORK, TRANSACT_DTO } from './types/transact'; -import { generateSecureHash, hashTransactData } from './utils/encoding'; -import { SIGN_X_LOGIN, SIGN_X_LOGIN_ERROR, SIGN_X_LOGIN_SUCCESS, SIGN_X_TRANSACT, SIGN_X_TRANSACT_ERROR, SIGN_X_TRANSACT_SUCCESS, VERSION } from './constants/signx'; +import * as Random from './utils/random'; +import * as Types from './types/transact'; +import * as Encoding from './utils/encoding'; +import * as Constants from './constants/signx'; class SignX extends EventEmitter { public timeout: number = 2 * 60 * 1000; // 2 minutes private endpoint: string; private sitename: string; - private network: NETWORK; + private network: Types.NETWORK; private pollingTimeout: NodeJS.Timeout | null = null; - constructor(endpoint: string, sitename: string, network: NETWORK) { + constructor(endpoint: string, sitename: string, network: Types.NETWORK) { super(); this.endpoint = endpoint; this.sitename = sitename; @@ -21,22 +21,41 @@ class SignX extends EventEmitter { } private generateRandomHash(): string { - return Random.getHex(32); + return Random.Random.getHex(32); } - async login() { + async login(): Promise { const nonce = this.generateRandomHash(); const hash = this.generateRandomHash(); - const secureHash = generateSecureHash(hash, nonce); - this.startPolling('/login/fetch', { hash, nonce }, SIGN_X_LOGIN_SUCCESS, SIGN_X_LOGIN_ERROR); - return { hash, secureHash, type: SIGN_X_LOGIN, sitename: this.sitename, timeout: Date.now() + this.timeout, network: this.network, version: VERSION }; + const secureHash = Encoding.generateSecureHash(hash, nonce); + this.startPolling('/login/fetch', { hash, nonce }, Constants.SIGN_X_LOGIN_SUCCESS, Constants.SIGN_X_LOGIN_ERROR); + return { + hash, + secureHash, + type: Constants.SIGN_X_LOGIN, + sitename: this.sitename, + timeout: Date.now() + this.timeout, + network: this.network, + version: Constants.VERSION, + }; } - async transact(data: TRANSACT_DTO) { - const hash = hashTransactData(data); + async transact(data: Types.TRANSACT_DTO): Promise { + const hash = Encoding.hashTransactData(data); await axios.post(`${this.endpoint}/transaction/create`, { hash, data }); - this.startPolling('/transaction/response', { hash }, SIGN_X_TRANSACT_SUCCESS, SIGN_X_TRANSACT_ERROR); - return { hash, type: SIGN_X_TRANSACT, sitename: this.sitename, network: this.network, version: VERSION }; + this.startPolling( + '/transaction/response', + { hash }, + Constants.SIGN_X_TRANSACT_SUCCESS, + Constants.SIGN_X_TRANSACT_ERROR, + ); + return { + hash, + type: Constants.SIGN_X_TRANSACT, + sitename: this.sitename, + network: this.network, + version: Constants.VERSION, + }; } private startPolling(route: string, body: any, successEvent: string, failEvent: string): void { diff --git a/src/types/transact.ts b/src/types/transact.ts index e8cd533..60cc028 100644 --- a/src/types/transact.ts +++ b/src/types/transact.ts @@ -1,3 +1,15 @@ +export type NETWORK = 'mainnet' | 'testnet' | 'devnet'; + +export type LOGIN_DATA = { + hash: string; + secureHash: string; + type: string; + sitename: string; + timeout: number; + network: NETWORK; + version: number; +}; + export type TRANSACT_DTO = { address: string; did: string; @@ -6,4 +18,10 @@ export type TRANSACT_DTO = { timestamp: string; }; -export type NETWORK = 'mainnet' | 'testnet' | 'devnet'; +export type TRANSACT_DATA = { + hash: string; + type: string; + sitename: string; + network: NETWORK; + version: number; +}; diff --git a/src/utils/encoding.ts b/src/utils/encoding.ts index df97c5d..d38cdf4 100644 --- a/src/utils/encoding.ts +++ b/src/utils/encoding.ts @@ -1,8 +1,9 @@ import crypto from 'crypto'; -import { TRANSACT_DTO } from '../types/transact'; +import * as Types from '../types/transact'; +import * as Constants from '../constants/signx'; -export const hashTransactData = (data: TRANSACT_DTO): string => { +export const hashTransactData = (data: Types.TRANSACT_DTO): string => { const formattedData = { address: data.address, did: data.did, @@ -19,3 +20,44 @@ export const generateSecureHash = (hash: string, nonce: string): string => { .update(hash + nonce) .digest('hex'); }; + +export const convertDataToDeeplink = (data: Types.LOGIN_DATA | Types.TRANSACT_DATA, scheme = 'impactsx'): string => { + switch (data?.type) { + case Constants.SIGN_X_LOGIN: + const loginData = data as Types.LOGIN_DATA; + return ( + scheme + + '://signx?hash=' + + loginData.hash + + '&secureHash=' + + loginData.secureHash + + 'type=' + + loginData.type + + 'sitename=' + + loginData.sitename + + 'timeout=' + + loginData.timeout + + 'network=' + + loginData.network + + 'version=' + + loginData.version + ); + case Constants.SIGN_X_TRANSACT: + const transactData = data as Types.TRANSACT_DATA; + return ( + scheme + + '://signx?hash=' + + transactData.hash + + 'type=' + + transactData.type + + 'sitename=' + + transactData.sitename + + 'network=' + + transactData.network + + 'version=' + + transactData.version + ); + default: + throw new Error('Unable to convert data to deeplink - invalid data type'); + } +}; diff --git a/types/client.d.ts b/types/client.d.ts index 3dbc3a2..d63f775 100644 --- a/types/client.d.ts +++ b/types/client.d.ts @@ -1,28 +1,16 @@ /// import { EventEmitter } from 'events'; -import { NETWORK, TRANSACT_DTO } from './types/transact'; +import * as Types from './types/transact'; declare class SignX extends EventEmitter { timeout: number; private endpoint; private sitename; private network; private pollingTimeout; - constructor(endpoint: string, sitename: string, network: NETWORK); + constructor(endpoint: string, sitename: string, network: Types.NETWORK); private generateRandomHash; - login(): Promise<{ - hash: string; - secureHash: string; - type: string; - sitename: string; - timestamp: number; - network: NETWORK; - }>; - transact(data: TRANSACT_DTO): Promise<{ - hash: string; - type: string; - sitename: string; - network: NETWORK; - }>; + login(): Promise; + transact(data: Types.TRANSACT_DTO): Promise; private startPolling; private stopPolling; } diff --git a/types/constants/signx.d.ts b/types/constants/signx.d.ts index 718c1a9..99f62da 100644 --- a/types/constants/signx.d.ts +++ b/types/constants/signx.d.ts @@ -4,3 +4,4 @@ export declare const SIGN_X_LOGIN_ERROR = "SIGN_X_LOGIN_ERROR"; export declare const SIGN_X_TRANSACT = "SIGN_X_TRANSACT"; export declare const SIGN_X_TRANSACT_SUCCESS = "SIGN_X_TRANSACT_SUCCESS"; export declare const SIGN_X_TRANSACT_ERROR = "SIGN_X_TRANSACT_ERROR"; +export declare const VERSION = 1; diff --git a/types/types/transact.d.ts b/types/types/transact.d.ts index c986648..638c0d9 100644 --- a/types/types/transact.d.ts +++ b/types/types/transact.d.ts @@ -1,3 +1,13 @@ +export type NETWORK = 'mainnet' | 'testnet' | 'devnet'; +export type LOGIN_DATA = { + hash: string; + secureHash: string; + type: string; + sitename: string; + timeout: number; + network: NETWORK; + version: number; +}; export type TRANSACT_DTO = { address: string; did: string; @@ -5,4 +15,10 @@ export type TRANSACT_DTO = { txBodyHex: string; timestamp: string; }; -export type NETWORK = 'mainnet' | 'testnet' | 'devnet'; +export type TRANSACT_DATA = { + hash: string; + type: string; + sitename: string; + network: NETWORK; + version: number; +}; diff --git a/types/utils/encoding.d.ts b/types/utils/encoding.d.ts index 108b479..7e3bb63 100644 --- a/types/utils/encoding.d.ts +++ b/types/utils/encoding.d.ts @@ -1,3 +1,4 @@ -import { TRANSACT_DTO } from '../types/transact'; -export declare const hashTransactData: (data: TRANSACT_DTO) => string; +import * as Types from '../types/transact'; +export declare const hashTransactData: (data: Types.TRANSACT_DTO) => string; export declare const generateSecureHash: (hash: string, nonce: string) => string; +export declare const convertDataToDeeplink: (data: Types.LOGIN_DATA | Types.TRANSACT_DATA, scheme?: string) => string; diff --git a/yarn.lock b/yarn.lock index 2b910d2..de6942e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1470,7 +1470,7 @@ available-typed-arrays@^1.0.5: resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== -axios@^1.3.4: +axios@1.3.4: version "1.3.4" resolved "https://registry.yarnpkg.com/axios/-/axios-1.3.4.tgz#f5760cefd9cfb51fd2481acf88c05f67c4523024" integrity sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==