├── .gitattributes ├── .github └── workflows │ └── publish.yml ├── .gitignore ├── .prettierignore ├── .prettierrc.json ├── LICENSE-APACHE ├── LICENSE-MIT ├── MIGRATION.md ├── NOTICE ├── README.md ├── assets ├── org_event.json ├── subscription_confirmation.json └── typed_data_example.json ├── eslint.config.mjs ├── examples ├── avalanchejs │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── babylon-staking-tools │ ├── README.md │ ├── eslint.config.mjs │ ├── package-lock.json │ ├── package.json │ ├── prove-inclusion-bbn │ │ ├── .gitignore │ │ ├── package.json │ │ ├── src │ │ │ ├── bbn_util.ts │ │ │ ├── cosmos_signer.ts │ │ │ ├── delegation_info.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ └── util.ts │ │ └── tsconfig.json │ ├── register-bbn │ │ ├── .gitignore │ │ ├── package.json │ │ ├── src │ │ │ ├── bbn_util.ts │ │ │ ├── cosmos_signer.ts │ │ │ ├── deposit_info.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ └── util.ts │ │ └── tsconfig.json │ ├── tsconfig.json │ ├── unbond-bbn-phase1 │ │ ├── package.json │ │ ├── src │ │ │ ├── bbn_util.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ ├── unbond_phase1_info.ts │ │ │ └── util.ts │ │ └── tsconfig.json │ ├── unbond-bbn │ │ ├── .gitignore │ │ ├── package.json │ │ ├── src │ │ │ ├── bbn_util.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ ├── unbond_info.ts │ │ │ └── util.ts │ │ └── tsconfig.json │ └── withdraw-bbn │ │ ├── .gitignore │ │ ├── package.json │ │ ├── src │ │ ├── bbn_util.ts │ │ ├── index.ts │ │ ├── types.ts │ │ ├── util.ts │ │ └── withdrawal_info.ts │ │ └── tsconfig.json ├── bitcoinjs │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── util.ts │ └── tsconfig.json ├── cardano │ ├── LICENSE-cardano-serialization-lib │ ├── README.md │ ├── jest.config.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── create_wallet.ts │ │ └── minting-nfts.ts │ ├── test │ │ ├── convert_pubkey_to_shelley.test.ts │ │ ├── helpers.ts │ │ └── minting-nfts.gamma.test.ts │ └── tsconfig.json ├── cosmos │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── esm │ ├── package.json │ └── src │ │ └── index.js ├── ethers │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── mfa │ ├── README.md │ ├── demo.sh │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── oidc-client-signing-simple-api-only │ ├── .env.template │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── public │ │ └── main.ts │ ├── src │ │ └── index.ts │ ├── tsconfig.json │ └── views │ │ └── index.handlebars ├── oidc-client-signing │ ├── .env.template │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ ├── tsconfig.json │ └── views │ │ ├── index.handlebars │ │ ├── layouts │ │ └── main.handlebars │ │ └── oauthCallback.handlebars ├── oidc │ ├── .env.template │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── rotation-lambda │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── cdk │ │ ├── .npmignore │ │ ├── bin │ │ │ └── rotation-lambda.ts │ │ ├── cdk.json │ │ ├── lib │ │ │ └── rotation-lambda-stack.ts │ │ ├── package.json │ │ └── tsconfig.json │ ├── lambdas │ │ └── rotation-lambda │ │ │ ├── package.json │ │ │ ├── src │ │ │ └── index.ts │ │ │ └── tsconfig.json │ ├── package.json │ └── scripts │ │ ├── package.json │ │ ├── src │ │ ├── gen-session.ts │ │ └── use-session.ts │ │ └── tsconfig.json ├── solana-policy │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── solana │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── stellar │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── sui │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── viem │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── waas-in-a-box │ ├── README.md │ ├── app │ │ ├── .env │ │ ├── app.tsx │ │ ├── env.ts │ │ ├── index.html │ │ ├── login_user.ts │ │ ├── oauth.ts │ │ └── register_user.ts │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── routes │ │ │ └── register_user.ts │ │ └── server.ts │ ├── tsconfig.json │ └── vite.config.js ├── walletconnect │ ├── .env.template │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json └── webpack │ ├── package-lock.json │ ├── package.json │ ├── src │ └── index.ts │ └── webpack.config.js ├── package-lock.json ├── package.json ├── packages ├── browser-storage │ ├── dist │ │ ├── index.d.ts │ │ ├── index.d.ts.map │ │ ├── index.js │ │ ├── locks.d.ts │ │ ├── locks.d.ts.map │ │ └── locks.js │ ├── package.json │ ├── playwright.config.ts │ ├── src │ │ ├── index.ts │ │ └── locks.ts │ ├── test │ │ ├── lock.spec.ts │ │ ├── manager.spec.ts │ │ └── site │ │ │ ├── .gitignore │ │ │ ├── index.html │ │ │ └── testscript.ts │ └── tsconfig.json ├── ethers-v5 │ ├── README.md │ ├── dist │ │ ├── index.d.ts │ │ ├── index.d.ts.map │ │ └── index.js │ ├── jest.config.js │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ ├── gamma.test.ts │ │ └── signer.test.ts │ └── tsconfig.json ├── ethers-v6 │ ├── README.md │ ├── dist │ │ ├── index.d.ts │ │ ├── index.d.ts.map │ │ └── index.js │ ├── jest.config.js │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ ├── gamma.test.ts │ │ └── signer.test.ts │ └── tsconfig.json ├── fs-storage │ ├── README.md │ ├── dist │ │ ├── file_storage.d.ts │ │ ├── file_storage.d.ts.map │ │ ├── file_storage.js │ │ ├── index.d.ts │ │ ├── index.d.ts.map │ │ ├── index.js │ │ ├── org_event_processor.d.ts │ │ ├── org_event_processor.d.ts.map │ │ └── org_event_processor.js │ ├── jest.config.js │ ├── package.json │ ├── src │ │ ├── file_storage.ts │ │ └── index.ts │ ├── test │ │ ├── contact.test.ts │ │ ├── fixtures │ │ │ ├── README.md │ │ │ ├── always_allow.wasm │ │ │ ├── ava_tx.ts │ │ │ ├── postman_get.wasm │ │ │ └── print_sign_request.wasm │ │ ├── helpers.ts │ │ ├── key.test.ts │ │ ├── mmi.test.ts │ │ ├── oidc_session.test.ts │ │ ├── org.test.ts │ │ ├── policy.test.ts │ │ ├── role.test.ts │ │ ├── session.test.ts │ │ ├── session_info.test.ts │ │ ├── setup.ts │ │ ├── sign.test.ts │ │ └── user_export.test.ts │ └── tsconfig.json ├── key-import │ ├── .gitignore │ ├── README.md │ ├── dist │ │ ├── import.d.ts │ │ ├── import.d.ts.map │ │ ├── import.js │ │ ├── index.d.ts │ │ ├── index.d.ts.map │ │ ├── index.js │ │ ├── mnemonic.d.ts │ │ ├── mnemonic.d.ts.map │ │ ├── mnemonic.js │ │ ├── raw.d.ts │ │ ├── raw.d.ts.map │ │ ├── raw.js │ │ ├── util.d.ts │ │ ├── util.d.ts.map │ │ └── util.js │ ├── jest.config.js │ ├── lib │ │ ├── root.pem │ │ └── test.json │ ├── package.json │ ├── src │ │ ├── import.ts │ │ ├── index.ts │ │ ├── mnemonic.ts │ │ ├── raw.ts │ │ └── util.ts │ ├── test │ │ ├── derpath.test.ts │ │ └── import.test.ts │ └── tsconfig.json ├── org-utils │ ├── README.md │ ├── dist │ │ ├── index.d.ts │ │ ├── index.d.ts.map │ │ ├── index.js │ │ ├── org_event_processor.d.ts │ │ ├── org_event_processor.d.ts.map │ │ └── org_event_processor.js │ ├── jest.config.js │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── org_event_processor.ts │ ├── test │ │ └── org_event_processor.test.ts │ └── tsconfig.json ├── sdk │ ├── README.md │ ├── dist │ │ ├── cjs │ │ │ ├── package.json │ │ │ ├── spec │ │ │ │ └── env │ │ │ │ │ ├── beta.json │ │ │ │ │ ├── gamma.json │ │ │ │ │ └── prod.json │ │ │ └── src │ │ │ │ ├── api.d.ts │ │ │ │ ├── api.js │ │ │ │ ├── client.d.ts │ │ │ │ ├── client.js │ │ │ │ ├── client │ │ │ │ ├── api_client.d.ts │ │ │ │ ├── api_client.js │ │ │ │ ├── base_client.d.ts │ │ │ │ ├── base_client.js │ │ │ │ ├── session.d.ts │ │ │ │ └── session.js │ │ │ │ ├── env.d.ts │ │ │ │ ├── env.js │ │ │ │ ├── error.d.ts │ │ │ │ ├── error.js │ │ │ │ ├── events.d.ts │ │ │ │ ├── events.js │ │ │ │ ├── evm │ │ │ │ ├── index.d.ts │ │ │ │ └── index.js │ │ │ │ ├── fetch.d.ts │ │ │ │ ├── fetch.js │ │ │ │ ├── index.d.ts │ │ │ │ ├── index.js │ │ │ │ ├── key.d.ts │ │ │ │ ├── key.js │ │ │ │ ├── mfa.d.ts │ │ │ │ ├── mfa.js │ │ │ │ ├── org.d.ts │ │ │ │ ├── org.js │ │ │ │ ├── org_event_processor.d.ts │ │ │ │ ├── org_event_processor.js │ │ │ │ ├── paginator.d.ts │ │ │ │ ├── paginator.js │ │ │ │ ├── response.d.ts │ │ │ │ ├── response.js │ │ │ │ ├── retry.d.ts │ │ │ │ ├── retry.js │ │ │ │ ├── role.d.ts │ │ │ │ ├── role.js │ │ │ │ ├── schema.d.ts │ │ │ │ ├── schema.js │ │ │ │ ├── schema_types.d.ts │ │ │ │ ├── schema_types.js │ │ │ │ ├── session │ │ │ │ ├── session_storage.d.ts │ │ │ │ ├── session_storage.js │ │ │ │ ├── signer_session_manager.d.ts │ │ │ │ └── signer_session_manager.js │ │ │ │ ├── signer_session.d.ts │ │ │ │ ├── signer_session.js │ │ │ │ ├── user_export.d.ts │ │ │ │ ├── user_export.js │ │ │ │ ├── util.d.ts │ │ │ │ └── util.js │ │ ├── esm │ │ │ ├── package.json │ │ │ ├── spec │ │ │ │ └── env │ │ │ │ │ ├── beta.json │ │ │ │ │ ├── gamma.json │ │ │ │ │ └── prod.json │ │ │ └── src │ │ │ │ ├── api.d.ts │ │ │ │ ├── api.js │ │ │ │ ├── client.d.ts │ │ │ │ ├── client.js │ │ │ │ ├── client │ │ │ │ ├── api_client.d.ts │ │ │ │ ├── api_client.js │ │ │ │ ├── base_client.d.ts │ │ │ │ ├── base_client.js │ │ │ │ ├── session.d.ts │ │ │ │ └── session.js │ │ │ │ ├── env.d.ts │ │ │ │ ├── env.js │ │ │ │ ├── error.d.ts │ │ │ │ ├── error.js │ │ │ │ ├── events.d.ts │ │ │ │ ├── events.js │ │ │ │ ├── evm │ │ │ │ ├── index.d.ts │ │ │ │ └── index.js │ │ │ │ ├── fetch.d.ts │ │ │ │ ├── fetch.js │ │ │ │ ├── index.d.ts │ │ │ │ ├── index.js │ │ │ │ ├── key.d.ts │ │ │ │ ├── key.js │ │ │ │ ├── mfa.d.ts │ │ │ │ ├── mfa.js │ │ │ │ ├── org.d.ts │ │ │ │ ├── org.js │ │ │ │ ├── org_event_processor.d.ts │ │ │ │ ├── org_event_processor.js │ │ │ │ ├── paginator.d.ts │ │ │ │ ├── paginator.js │ │ │ │ ├── response.d.ts │ │ │ │ ├── response.js │ │ │ │ ├── retry.d.ts │ │ │ │ ├── retry.js │ │ │ │ ├── role.d.ts │ │ │ │ ├── role.js │ │ │ │ ├── schema.d.ts │ │ │ │ ├── schema.js │ │ │ │ ├── schema_types.d.ts │ │ │ │ ├── schema_types.js │ │ │ │ ├── session │ │ │ │ ├── session_storage.d.ts │ │ │ │ ├── session_storage.js │ │ │ │ ├── signer_session_manager.d.ts │ │ │ │ └── signer_session_manager.js │ │ │ │ ├── signer_session.d.ts │ │ │ │ ├── signer_session.js │ │ │ │ ├── user_export.d.ts │ │ │ │ ├── user_export.js │ │ │ │ ├── util.d.ts │ │ │ │ └── util.js │ │ ├── package.json │ │ ├── spec │ │ │ └── env │ │ │ │ ├── beta.json │ │ │ │ ├── gamma.json │ │ │ │ └── prod.json │ │ └── src │ │ │ ├── api.d.ts │ │ │ ├── api.js │ │ │ ├── client.d.ts │ │ │ ├── client.d.ts.map │ │ │ ├── client.js │ │ │ ├── client │ │ │ ├── api_client.d.ts │ │ │ ├── api_client.d.ts.map │ │ │ ├── api_client.js │ │ │ ├── base_client.d.ts │ │ │ ├── base_client.d.ts.map │ │ │ ├── base_client.js │ │ │ ├── session.d.ts │ │ │ ├── session.d.ts.map │ │ │ └── session.js │ │ │ ├── contact.d.ts │ │ │ ├── contact.d.ts.map │ │ │ ├── contact.js │ │ │ ├── env.d.ts │ │ │ ├── env.d.ts.map │ │ │ ├── env.js │ │ │ ├── error.d.ts │ │ │ ├── error.d.ts.map │ │ │ ├── error.js │ │ │ ├── events.d.ts │ │ │ ├── events.d.ts.map │ │ │ ├── events.js │ │ │ ├── evm │ │ │ ├── index.d.ts │ │ │ ├── index.d.ts.map │ │ │ └── index.js │ │ │ ├── fetch.d.ts │ │ │ ├── fetch.d.ts.map │ │ │ ├── fetch.js │ │ │ ├── index.d.ts │ │ │ ├── index.d.ts.map │ │ │ ├── index.js │ │ │ ├── key.d.ts │ │ │ ├── key.d.ts.map │ │ │ ├── key.js │ │ │ ├── mfa.d.ts │ │ │ ├── mfa.d.ts.map │ │ │ ├── mfa.js │ │ │ ├── org.d.ts │ │ │ ├── org.d.ts.map │ │ │ ├── org.js │ │ │ ├── paginator.d.ts │ │ │ ├── paginator.d.ts.map │ │ │ ├── paginator.js │ │ │ ├── passkey.d.ts │ │ │ ├── passkey.d.ts.map │ │ │ ├── passkey.js │ │ │ ├── policy.d.ts │ │ │ ├── policy.d.ts.map │ │ │ ├── policy.js │ │ │ ├── response.d.ts │ │ │ ├── response.d.ts.map │ │ │ ├── response.js │ │ │ ├── retry.d.ts │ │ │ ├── retry.d.ts.map │ │ │ ├── retry.js │ │ │ ├── role.d.ts │ │ │ ├── role.d.ts.map │ │ │ ├── role.js │ │ │ ├── schema.d.ts │ │ │ ├── schema.d.ts.map │ │ │ ├── schema.js │ │ │ ├── schema_types.d.ts │ │ │ ├── schema_types.d.ts.map │ │ │ ├── schema_types.js │ │ │ ├── session │ │ │ ├── session_storage.d.ts │ │ │ ├── session_storage.js │ │ │ ├── signer_session_manager.d.ts │ │ │ └── signer_session_manager.js │ │ │ ├── signer_session.d.ts │ │ │ ├── signer_session.d.ts.map │ │ │ ├── signer_session.js │ │ │ ├── user_export.d.ts │ │ │ ├── user_export.d.ts.map │ │ │ ├── user_export.js │ │ │ ├── util.d.ts │ │ │ ├── util.d.ts.map │ │ │ └── util.js │ ├── jest.config.js │ ├── package.json │ ├── spec │ │ ├── env │ │ │ ├── beta.json │ │ │ ├── gamma.json │ │ │ └── prod.json │ │ └── openapi.json │ ├── src │ │ ├── client.ts │ │ ├── client │ │ │ ├── api_client.ts │ │ │ ├── base_client.ts │ │ │ └── session.ts │ │ ├── contact.ts │ │ ├── env.ts │ │ ├── error.ts │ │ ├── events.ts │ │ ├── evm │ │ │ └── index.ts │ │ ├── fetch.ts │ │ ├── index.ts │ │ ├── key.ts │ │ ├── mfa.ts │ │ ├── org.ts │ │ ├── paginator.ts │ │ ├── passkey.ts │ │ ├── policy.ts │ │ ├── response.ts │ │ ├── retry.ts │ │ ├── role.ts │ │ ├── schema.ts │ │ ├── schema_types.ts │ │ ├── signer_session.ts │ │ ├── user_export.ts │ │ └── util.ts │ ├── test │ │ └── util.test.ts │ └── tsconfig.json └── secretsmanager-storage │ ├── README.md │ ├── dist │ ├── index.d.ts │ ├── index.d.ts.map │ └── index.js │ ├── jest.config.js │ ├── package.json │ ├── src │ └── index.ts │ ├── test │ └── session.test.ts │ └── tsconfig.json ├── scripts ├── gen_readme_test.sh └── readme_test_template │ ├── .gitignore │ ├── package.json │ └── tsconfig.json ├── tsconfig.json └── tsconfig.local.json /.gitattributes: -------------------------------------------------------------------------------- 1 | dist/** linguist-generated=true 2 | packages/sdk/spec/openapi.json linguist-generated=true 3 | packages/sdk/src/schema.ts linguist-generated=true 4 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: ["releases/*"] 4 | 5 | name: Publish 6 | 7 | jobs: 8 | publish: 9 | # run this only in cubist-labs 10 | if: ${{ github.repository == 'cubist-labs/CubeSigner-TypeScript-SDK' }} 11 | runs-on: ubuntu-latest 12 | 13 | # needs id-token for npm provenance 14 | permissions: 15 | contents: read 16 | id-token: write 17 | 18 | # should be configured to require manual approval 19 | environment: npmjs 20 | 21 | name: Publish to npmjs 22 | steps: 23 | - name: Setup node 24 | uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4 25 | with: 26 | node-version: "20" 27 | # creates .npmrc with the following contents 28 | # //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN} 29 | # registry=https://registry.npmjs.org/ 30 | # always-auth=true 31 | registry-url: "https://registry.npmjs.org" 32 | 33 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 34 | with: 35 | fetch-depth: 0 36 | 37 | # install and lint (no need to build because 'npm publish' does it) 38 | - name: Install + Lint 39 | run: npm ci && npm run lint 40 | 41 | # publish npm package to npmjs with provenance 42 | - name: Publish to npmjs 43 | env: 44 | # this secret should only be available in the 'npmjs' environment 45 | NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} 46 | run: npm publish --workspaces --provenance --access public 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | npm-debug.log* 3 | yarn-debug.log* 4 | yarn-error.log* 5 | node_modules/ 6 | .yarn-integrity 7 | *~ 8 | dist/ 9 | docs/ 10 | .eslintcache 11 | .env -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/dist/ 2 | **/node_modules/ 3 | **/.eslintrc.js 4 | **/jest.config.js 5 | **/snap.config.js 6 | **/*.json 7 | README.md 8 | examples/** 9 | scripts/** 10 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "singleQuote": false 4 | } 5 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (C) 2022-2023 Cubist, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2024-2025 Cubist, Inc. 2 | 3 | This software is licensed under either of 4 | 5 | - Apache License, Version 2.0 6 | (see https://www.apache.org/licenses/LICENSE-2.0 or LICENSE-APACHE) 7 | 8 | - MIT license 9 | (see https://opensource.org/licenses/MIT or LICENSE-MIT) 10 | 11 | at your option. 12 | 13 | The SPDX identifier for this project is "MIT OR Apache-2.0". 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | packages/sdk/README.md -------------------------------------------------------------------------------- /assets/org_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Message": "{\"org\":\"Org#06aadcc8-1669-4cb5-a129-a293de388b70\",\"utc_timestamp\":1732616764477,\"event\":\"cubist::org_event\",\"triggered_by\":\"User#8d4ba3d1-eb35-4653-94eb-3352b42a6ead\",\"org_event\":\"KeyCreated\",\"key_type\":\"SecpEthAddr\",\"owner_id\":\"User#8d4ba3d1-eb35-4653-94eb-3352b42a6ead\",\"key_ids\":[\"Key#0xaca05602937151974754ea35c9d3e9cb20de9c07\"]}", 3 | "MessageId": "724880eb-a71f-5751-b74c-df54036250d7", 4 | "Signature": "TiP83joocQGznRjIYqpB7jtxg8PNfWTF3ZPRTqJmyDJLGr//SP6ecth9Js1klnOkq7zoIL16lg7qBhYG+DzFQtjccZmVZOq3y9LWKvzdJTkd/pIO2TzfdxXnU8zkG6R15BdmGwffgLsjRC1a4pYWZYYu8pGml1+Hjry5FEZoTiHQzItPovfnyZoPhtfNP8OmknHfbw6wh0UBb27R3S8ElKaFC9IDJasbytOvlW4P8M9541KIyPJ1/iOu9QHdk8kSDxHE94KWp5hS+6POlfBO0gnmOkr/HbqCrrL3CVMA4Iah8MUOIR5o7Fyecngtvcfljl1nisXzfRl8DNUpsDBMQA==", 5 | "SignatureVersion": "2", 6 | "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-9c6465fa7f48f5cacd23014631ec1136.pem", 7 | "Timestamp": "2024-11-26T10:26:05.673Z", 8 | "TopicArn": "arn:aws:sns:us-east-1:819335423237:Beta-CubeSignerStack-OrgEventsTopic4416298A-beobtbku2Wa8", 9 | "Type": "Notification", 10 | "UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:819335423237:Beta-CubeSignerStack-OrgEventsTopic4416298A-beobtbku2Wa8:eb0e93d7-6d91-47fb-b6b6-01ef31effe2c" 11 | } 12 | -------------------------------------------------------------------------------- /assets/subscription_confirmation.json: -------------------------------------------------------------------------------- 1 | { 2 | "Message": "You have chosen to subscribe to the topic arn:aws:sns:us-east-1:819335423237:Beta-CubeSignerStack-OrgEventsTopic4416298A-beobtbku2Wa8.\nTo confirm the subscription, visit the SubscribeURL included in this message.", 3 | "MessageId": "bc96e8bc-a228-49f7-b837-c262af36a617", 4 | "Signature": "oB7lY69BhlFLqlp+s2UA2+DirSXYPXKsbwQc/+m69CFLxishc/qqO50eecAOeYOvwpuow5PRCQs2MADlUKQdsQKKZZvXoSPB7ZSp0OrWkWTKX66oHz9yrl/Oa4SLe4tqcCNLkGRU2YL0PxbDrmrET8AjzlLInSttT9Y2bkwO5ZEznk0SgeqUlLzhMGSwDhFl3bXmzlMtFqBsFC6JaefE5lDpaRDykbTo9cYYWfVr1YONtpAVDbU7xQgsDvq0btDRRMabCd+cLu2mWWUVqhWIh2tL5f67A5LyoAjp2QrIsdckbdJWwvQmqbo7dlVhwALZB4f0OLwikk6o5R73HxagmQ==", 5 | "SignatureVersion": "2", 6 | "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-9c6465fa7f48f5cacd23014631ec1136.pem", 7 | "SubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-east-1:819335423237:Beta-CubeSignerStack-OrgEventsTopic4416298A-beobtbku2Wa8&Token=2336412f37fb687f5d51e6e2425ba1f30b1727d2d06a312f7528feafefe580ea9a151959151621ae3fdeba6e5a54bfa2047944f881ff2517278530087b27aa5ec2e0a1d54a9ca05fde406c7bd29989685aae84210dcc35c0e2e901750ebf9d1f6bdc3dea30833ff34ff3e16eb7d99b8228a3307f53cbdf632ac2622c8df0e9d3a0d857a0e9089e5e21981abb5fd01213db6f89003228d1dd4d286877eba906af", 8 | "Timestamp": "2024-11-26T10:25:03.390Z", 9 | "Token": "2336412f37fb687f5d51e6e2425ba1f30b1727d2d06a312f7528feafefe580ea9a151959151621ae3fdeba6e5a54bfa2047944f881ff2517278530087b27aa5ec2e0a1d54a9ca05fde406c7bd29989685aae84210dcc35c0e2e901750ebf9d1f6bdc3dea30833ff34ff3e16eb7d99b8228a3307f53cbdf632ac2622c8df0e9d3a0d857a0e9089e5e21981abb5fd01213db6f89003228d1dd4d286877eba906af", 10 | "TopicArn": "arn:aws:sns:us-east-1:819335423237:Beta-CubeSignerStack-OrgEventsTopic4416298A-beobtbku2Wa8", 11 | "Type": "SubscriptionConfirmation" 12 | } 13 | -------------------------------------------------------------------------------- /assets/typed_data_example.json: -------------------------------------------------------------------------------- 1 | { 2 | "domain": { 3 | "name": "Ether Mail", 4 | "version": "1", 5 | "chainId": 1, 6 | "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" 7 | }, 8 | "primaryType": "Mail", 9 | "types": { 10 | "Person": [ 11 | { 12 | "name": "name", 13 | "type": "string" 14 | }, 15 | { 16 | "name": "wallet", 17 | "type": "address" 18 | } 19 | ], 20 | "Mail": [ 21 | { 22 | "name": "from", 23 | "type": "Person" 24 | }, 25 | { 26 | "name": "to", 27 | "type": "Person" 28 | }, 29 | { 30 | "name": "contents", 31 | "type": "string" 32 | } 33 | ] 34 | }, 35 | "data": { 36 | "from": { 37 | "name": "Cow", 38 | "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" 39 | }, 40 | "to": { 41 | "name": "Bob", 42 | "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" 43 | }, 44 | "contents": "Hello, Bob!" 45 | }, 46 | "digest": "0xbe609aee343fb3c4b28e1df9e632fca64fcfaede20f02e86244efddf30957bd2" 47 | } 48 | -------------------------------------------------------------------------------- /examples/avalanchejs/README.md: -------------------------------------------------------------------------------- 1 | # CubeSigner TypeScript SDK: AvalancheJS Example 2 | 3 | This example shows how the CubeSigner TypeScript SDK can be used to sign 4 | transactions using AvalancheJS. Specifically, the example shows how to sign and 5 | send a transfer from the C-chain to the P-chain and back. It is similar to the 6 | C-chain to/from P-chain transfers using API calls outlined in the [Avalanche 7 | documentation](https://support.avax.network/en/articles/6719662-transferring-from-the-p-chain-to-c-chain-with-api-calls). 8 | 9 | ## Running the Example 10 | 11 | To run the example, you need to create a `secp` and an 12 | `secp-ava`/`secp-ava-test` key and add it to a role like we did in the 13 | [top-level README](../../README.md). After you do this, generate a session 14 | token for the role; you can either save the token (`cs token create ... 15 | --save`) or export as base64: 16 | 17 | ```bash 18 | export CUBE_SIGNER_TOKEN=$(cs token create ... --output base64) 19 | ``` 20 | 21 | Then, set the C-chain and P-chain addresses: 22 | 23 | ```bash 24 | export C_CHAIN_ADDRESS=0x... # this is your secp key material id 25 | export P_CHAIN_ADDRESS=P-... # this is your secp-ava(-test) key material id prefixed with `P-` 26 | ``` 27 | 28 | For this example to work you need to have some funds in your C-chain account. 29 | -------------------------------------------------------------------------------- /examples/avalanchejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-avalanchejs-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "start": "node ./dist/index.js" 13 | }, 14 | "dependencies": { 15 | "@avalabs/avalanchejs": "^4.0.5", 16 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 17 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 18 | "ethers": "^6.13.1" 19 | }, 20 | "devDependencies": { 21 | "@types/node": "^20.10.7", 22 | "ts-node": "^10.9.1", 23 | "typescript": "^4.8" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/avalanchejs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/babylon-staking-tools", 3 | "version": "0.1.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "workspaces": [ 8 | "prove-inclusion-bbn", 9 | "register-bbn", 10 | "unbond-bbn-phase1", 11 | "withdraw-bbn" 12 | ], 13 | "scripts": { 14 | "prebuild": "npm install", 15 | "build": "npm run build --workspaces --if-present", 16 | "lint": "eslint .", 17 | "fmt": "prettier --write .", 18 | "fmt-check": "prettier --check ." 19 | }, 20 | "engines": { 21 | "node": ">=18.0.0" 22 | }, 23 | "devDependencies": { 24 | "@eslint/eslintrc": "^3.2.0", 25 | "@eslint/js": "^9.16.0", 26 | "@types/eslint__js": "^8.42.3", 27 | "@types/node": "^22.5.2", 28 | "@types/node-fetch": "^2.6.11", 29 | "eslint": "^9.16.0", 30 | "eslint-config-google": "git://github.com/google/eslint-config-google#3ae571a", 31 | "eslint-config-prettier": "^9.1.0", 32 | "eslint-plugin-jsdoc": "^50.2.2", 33 | "prettier": "3.3.3", 34 | "ts-node": "^10.9.2", 35 | "typedoc": "^0.27.9", 36 | "typescript": "^5.5.4", 37 | "typescript-eslint": "^8.17.0" 38 | }, 39 | "dependencies": { 40 | "@babylonlabs-io/babylon-proto-ts": "^1.0.1", 41 | "@bitcoin-js/tiny-secp256k1-asmjs": "^2.2.3", 42 | "@cubist-labs/cubesigner-sdk": "^0.4.141-0", 43 | "@cubist-labs/cubesigner-sdk-fs-storage": "^0.4.141-0", 44 | "bitcoinjs-lib": "^6.1.7", 45 | "@cosmjs/amino": "^0.33.1", 46 | "@cosmjs/crypto": "^0.33.1", 47 | "@cosmjs/encoding": "^0.33.1", 48 | "@cosmjs/proto-signing": "^0.33.1", 49 | "@cosmjs/stargate": "^0.33.1", 50 | "cosmjs-types": "^0.9.0" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/prove-inclusion-bbn/.gitignore: -------------------------------------------------------------------------------- 1 | delegation.json 2 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/prove-inclusion-bbn/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prove-inclusion-bbn", 3 | "version": "1.0.0", 4 | "main": "dist/index.js", 5 | "scripts": { 6 | "prebuild": "npm i", 7 | "build": "tsc", 8 | "prestart": "npm run build", 9 | "start": "node ./dist/index.js" 10 | }, 11 | "author": "Cubist, Inc.", 12 | "license": "MIT OR Apache-2.0", 13 | "description": "Generate and post an inclusion proof for a Bitcoin staking transaction" 14 | } 15 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/prove-inclusion-bbn/src/bbn_util.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/bbn_util.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/prove-inclusion-bbn/src/cosmos_signer.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/cosmos_signer.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/prove-inclusion-bbn/src/types.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/types.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/prove-inclusion-bbn/src/util.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/util.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/prove-inclusion-bbn/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../tsconfig.json -------------------------------------------------------------------------------- /examples/babylon-staking-tools/register-bbn/.gitignore: -------------------------------------------------------------------------------- 1 | deposit.json 2 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/register-bbn/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "register-bbn", 3 | "version": "1.0.0", 4 | "main": "dist/index.js", 5 | "scripts": { 6 | "prebuild": "npm i", 7 | "build": "tsc", 8 | "prestart": "npm run build", 9 | "start": "node ./dist/index.js" 10 | }, 11 | "author": "Cubist, Inc.", 12 | "license": "MIT OR Apache-2.0", 13 | "description": "Babylon Phase2 pre-registration deposit flow" 14 | } 15 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/register-bbn/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../tsconfig.json -------------------------------------------------------------------------------- /examples/babylon-staking-tools/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn-phase1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unbond-bbn-phase1", 3 | "version": "1.0.0", 4 | "main": "dist/index.js", 5 | "scripts": { 6 | "prebuild": "npm i", 7 | "build": "tsc", 8 | "prestart": "npm run build", 9 | "start": "node ./dist/index.js" 10 | }, 11 | "author": "Cubist, Inc.", 12 | "license": "MIT OR Apache-2.0", 13 | "description": "Unbond phase1 Babylon deposit" 14 | } 15 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn-phase1/src/bbn_util.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/bbn_util.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn-phase1/src/types.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/types.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn-phase1/src/unbond_phase1_info.ts: -------------------------------------------------------------------------------- 1 | import * as cs from "@cubist-labs/cubesigner-sdk"; 2 | 3 | import type { BbnNetworkId } from "./types"; 4 | import { isBbnNetworkId, HEX_REGEX } from "./types"; 5 | 6 | /** 7 | * The information needed to create a deposit 8 | */ 9 | export type UnbondPhase1Info = { 10 | /** Transaction ID of the deposit to unbond */ 11 | txid: string; 12 | /** Babylon network */ 13 | bbnNetwork: BbnNetworkId; 14 | /** MFA approval receipt(s) */ 15 | mfaReceipts?: cs.MfaIdAndConf[]; 16 | /** 17 | * Explicit Babylon parameters to use in place of the API-provided ones. 18 | * This value is not typechecked in the client, but an invalid value will 19 | * result in a 400 error from the CubeSigner API. 20 | */ 21 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 22 | explicitParams?: any; 23 | }; 24 | 25 | /** 26 | * UnbondPhase1Info type guard 27 | * 28 | * @param val The data to check 29 | * @returns Whether the value is of the correct type 30 | */ 31 | export function isUnbondPhase1Info(val: unknown): val is UnbondPhase1Info { 32 | if (val === undefined) return false; 33 | const info = val as UnbondPhase1Info; 34 | 35 | if (typeof info.txid !== "string" || !HEX_REGEX.test(info.txid)) { 36 | return false; 37 | } 38 | if (typeof info.bbnNetwork !== "string" || !isBbnNetworkId(info.bbnNetwork)) { 39 | return false; 40 | } 41 | if (info.mfaReceipts !== undefined) { 42 | if (!Array.isArray(info.mfaReceipts) || !info.mfaReceipts.every(cs.isMfaIdAndConf)) { 43 | return false; 44 | } 45 | } 46 | 47 | return true; 48 | } 49 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn-phase1/src/util.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/util.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn-phase1/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../tsconfig.json -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn/.gitignore: -------------------------------------------------------------------------------- 1 | unbond.json 2 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unbond-bbn", 3 | "version": "1.0.0", 4 | "main": "dist/index.js", 5 | "scripts": { 6 | "prebuild": "npm i", 7 | "build": "tsc", 8 | "prestart": "npm run build", 9 | "start": "node ./dist/index.js" 10 | }, 11 | "author": "Cubist, Inc.", 12 | "license": "MIT OR Apache-2.0", 13 | "description": "Babylon phase2 unbonding flow" 14 | } 15 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn/src/bbn_util.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/bbn_util.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn/src/types.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/types.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn/src/unbond_info.ts: -------------------------------------------------------------------------------- 1 | import * as cs from "@cubist-labs/cubesigner-sdk"; 2 | 3 | import type { BbnPhase2NetworkId } from "./types"; 4 | import { isBbnPhase2NetworkId, HEX_REGEX } from "./types"; 5 | 6 | /** 7 | * The information needed to create a deposit 8 | */ 9 | export type UnbondInfo = { 10 | /** Transaction ID of the deposit to unbond */ 11 | txid: string; 12 | /** Babylon network */ 13 | bbnNetwork: BbnPhase2NetworkId; 14 | /** MFA approval receipt(s) */ 15 | mfaReceipts?: cs.MfaIdAndConf[]; 16 | /** 17 | * Explicit Babylon parameters to use in place of the API-provided ones. 18 | * This value is not typechecked in the client, but an invalid value will 19 | * result in a 400 error from the CubeSigner API. 20 | */ 21 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 22 | explicitParams?: any; 23 | }; 24 | 25 | /** 26 | * UnbondInfo type guard 27 | * 28 | * @param val The data to check 29 | * @returns Whether the value is of the correct type 30 | */ 31 | export function isUnbondInfo(val: unknown): val is UnbondInfo { 32 | if (val === undefined) return false; 33 | const info = val as UnbondInfo; 34 | 35 | if (typeof info.txid !== "string" || !HEX_REGEX.test(info.txid)) { 36 | return false; 37 | } 38 | if (typeof info.bbnNetwork !== "string" || !isBbnPhase2NetworkId(info.bbnNetwork)) { 39 | return false; 40 | } 41 | if (info.mfaReceipts !== undefined) { 42 | if (!Array.isArray(info.mfaReceipts) || !info.mfaReceipts.every(cs.isMfaIdAndConf)) { 43 | return false; 44 | } 45 | } 46 | 47 | return true; 48 | } 49 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn/src/util.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/util.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/unbond-bbn/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../tsconfig.json -------------------------------------------------------------------------------- /examples/babylon-staking-tools/withdraw-bbn/.gitignore: -------------------------------------------------------------------------------- 1 | withdrawal.json 2 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/withdraw-bbn/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "withdraw-bbn", 3 | "version": "1.0.0", 4 | "main": "dist/index.js", 5 | "scripts": { 6 | "prebuild": "npm i", 7 | "build": "tsc", 8 | "prestart": "npm run build", 9 | "start": "node ./dist/index.js" 10 | }, 11 | "author": "Cubist, Inc.", 12 | "license": "MIT OR Apache-2.0", 13 | "description": "Create Babylon withdrawal transactions" 14 | } 15 | -------------------------------------------------------------------------------- /examples/babylon-staking-tools/withdraw-bbn/src/bbn_util.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/bbn_util.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/withdraw-bbn/src/types.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/types.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/withdraw-bbn/src/util.ts: -------------------------------------------------------------------------------- 1 | ../../register-bbn/src/util.ts -------------------------------------------------------------------------------- /examples/babylon-staking-tools/withdraw-bbn/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../tsconfig.json -------------------------------------------------------------------------------- /examples/bitcoinjs/README.md: -------------------------------------------------------------------------------- 1 | # CubeSigner TypeScript SDK: bitcoinjs-lib Example 2 | 3 | This example shows how the CubeSigner TypeScript SDK can be used to sign 4 | transactions on Bitcoin chains with [bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib). Specifically, the example 5 | shows how to sign and send a simple value transaction from one account to 6 | another. 7 | 8 | ## Running the Example 9 | 10 | To run the example, you need to first create a Btc or BtcTest key and add it to a role like we 11 | did in the [top-level README](../../README.md). You must create/import your sending address 12 | in CubeSigner. You might want to do the same for the receiving address, so you can 13 | transfer your funds back if desired. After you do this, generate a session token for the role; 14 | you can either save the token (`cs token create ... --save`) or export as base64: 15 | 16 | ```bash 17 | export CUBE_SIGNER_TOKEN=$(cs token create ... --output base64) 18 | ``` 19 | 20 | Then, set the source and destination addresses: 21 | 22 | ```bash 23 | export FROM_ADDRESS=tb1... # this is your btc key material id 24 | export TO_ADDRESS=tb1... # the recipient 25 | ``` 26 | 27 | For this example to work you need to have some funds in your account. 28 | The network is established by the sending account. 29 | -------------------------------------------------------------------------------- /examples/bitcoinjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-bitcoinjs-example", 3 | "version": "0.1.0", 4 | "description": "An example of signing bitcoin transactions using CubeSigner and bitcoinjs-lib", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "start": "node ./dist/index.js" 13 | }, 14 | "dependencies": { 15 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 16 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 17 | "axios": "^1.8.1", 18 | "bitcoinjs-lib": "^6.1.3", 19 | "dotenv": "^16.3.1" 20 | }, 21 | "devDependencies": { 22 | "@types/node": "^20.10.7", 23 | "ts-node": "^10.9.1", 24 | "typescript": "^4.8" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/bitcoinjs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/cardano/LICENSE-cardano-serialization-lib: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 EMURGO 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/cardano/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: 'ts-jest', 4 | testTimeout: 15000, 5 | testEnvironment: 'node', 6 | testMatch: ["/test/*.test.[jt]s"], 7 | }; 8 | -------------------------------------------------------------------------------- /examples/cardano/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-cardano-example", 3 | "version": "0.1.0", 4 | "description": "Cardano examples using CubeSigner", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "scripts": { 8 | "prebuild": "npm ci", 9 | "build": "tsc", 10 | "create-wallet": "tsc && node ./dist/create_wallet.js", 11 | "mint-nft": "tsc && node ./dist/minting-nfts.js", 12 | "test": "jest" 13 | }, 14 | "dependencies": { 15 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 16 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 17 | "@blockfrost/blockfrost-js": "^5.4.0", 18 | "@emurgo/cardano-serialization-lib-nodejs": "^11.5.0", 19 | "bech32": "^2.0.0", 20 | "blakejs": "^1.2.1" 21 | }, 22 | "devDependencies": { 23 | "@meshsdk/core": "^1.5.11-beta.4", 24 | "@types/jest": "^29.5.2", 25 | "@types/node": "^20.10.7", 26 | "bip39": "^3.1.0", 27 | "chai": "^4.3.7", 28 | "jest": "^29.5.0", 29 | "ts-jest": "^29.1.0", 30 | "ts-node": "^10.9.1", 31 | "typescript": "^4.8" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /examples/cardano/src/create_wallet.ts: -------------------------------------------------------------------------------- 1 | import * as cs from "@cubist-labs/cubesigner-sdk"; 2 | import * as csFs from "@cubist-labs/cubesigner-sdk-fs-storage"; 3 | 4 | /** Cardano wallet details */ 5 | interface CardanoWalletDetails { 6 | role: string; 7 | paymentAddress: string; 8 | stakingAddress: string; 9 | } 10 | 11 | /** 12 | * Create a new Cardano wallet. 13 | * 14 | * @param org The org in which to create the wallet 15 | * @returns the wallet details. 16 | */ 17 | async function createCardanoWallet(org: cs.Org): Promise { 18 | // Create wallet 19 | const baseKey = await org.createKey(cs.Mnemonic); 20 | const role = await org.createRole(); 21 | 22 | // Using the derivation paths from CIP 1852 23 | // https://developers.cardano.org/docs/governance/cardano-improvement-proposals/cip-1852/ 24 | // Derive payment key 25 | const paymentKey: cs.Key = (await org.deriveKey( 26 | cs.Ed25519.Cardano, 27 | "m/1852'/1815'/0'/0/0", 28 | baseKey.materialId, 29 | ))!; 30 | // Derive staking key 31 | const stakingKey: cs.Key = (await org.deriveKey( 32 | cs.Ed25519.Cardano, 33 | "m/1852'/1815'/0'/2/0", 34 | baseKey.materialId, 35 | ))!; 36 | 37 | // Add the keys to the role with policy for signing raw blobs 38 | await role.addKeys([paymentKey, stakingKey], ["AllowRawBlobSigning"]); 39 | return { 40 | role: role.id, 41 | paymentAddress: paymentKey.materialId, 42 | stakingAddress: stakingKey.materialId, 43 | }; 44 | } 45 | 46 | /** Example main entry point */ 47 | async function main() { 48 | console.log("Loading management session..."); 49 | // Load management session from 50 | const storage = csFs.defaultManagementSessionManager(); 51 | // Get your org 52 | const client = await cs.CubeSignerClient.create(storage); 53 | 54 | // Create wallet 55 | console.log("Creating wallet..."); 56 | const wallet = await createCardanoWallet(await client.org()); 57 | console.log(wallet); 58 | } 59 | 60 | main().catch((err: Error) => { 61 | console.error(err); 62 | process.exit(1); 63 | }); 64 | -------------------------------------------------------------------------------- /examples/cardano/test/helpers.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns the value of the environment variable. 3 | * 4 | * @param name The name of the environment variable. 5 | * @param fallback The optional fallback value. 6 | * @returns The value of the environment variable, the fallback, or undefined. 7 | * @throws {Error} If the environment variable is not set and no fallback is provided. 8 | */ 9 | export function env(name: string, fallback?: string | null): string | null { 10 | const val = process.env[name] ?? fallback; 11 | if (val === undefined) { 12 | throw new Error(`Missing environment variable ${name}`); 13 | } 14 | return val; 15 | } 16 | -------------------------------------------------------------------------------- /examples/cardano/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/cosmos/README.md: -------------------------------------------------------------------------------- 1 | # CubeSigner TypeScript SDK: Cosmos token transfer example 2 | 3 | This example shows how to use `@cosmjs` and the CubeSigner TypeScript SDK to 4 | sign Cosmos transactions in secure hardware. 5 | 6 | ## Running the Example 7 | 8 | To run the example, you need to first create a key with a raw-blob signing 9 | policy. 10 | 11 | ```bash 12 | cs key create -t secp-cosmos --metadata='"cosmos-from"' --policy '"AllowRawBlobSigning" 13 | ``` 14 | 15 | Like we did in the [top-level README](../../README.md) you can use this key by 16 | adding it to a role and generating a session token for the role; you can either 17 | save the token (`cs token create ... --save`) or export as base64: 18 | 19 | ```bash 20 | export CUBE_SIGNER_TOKEN=$(cs token create ... --output base64) 21 | ``` 22 | 23 | If you're not using roles, you can instead use a user session token: `cs token 24 | create --user ...`. 25 | 26 | Once you have a session, set the source and destination addresses: 27 | 28 | ```bash 29 | export FROM_ADDRESS=... # this is your Cosmos key material id 30 | export TO_ADDRESS=... # the recipient 31 | ``` 32 | ### Sending ATOM 33 | 34 | By default the example sends 100000 uATOMS on the Theta testnet (following [the 35 | official example](https://tutorials.cosmos.network/tutorials/7-cosmjs/)), so you 36 | need to have some funds in your account to run: 37 | 38 | 39 | ```bash 40 | npm -C examples/cosmos start 41 | ``` 42 | You can get testnet funds from the one of the [testnet faucets](https://github.com/cosmos/testnets/tree/master/release#faucet) -------------------------------------------------------------------------------- /examples/cosmos/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-cosmos-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "start": "node ./dist/index.js" 13 | }, 14 | "dependencies": { 15 | "@cosmjs/amino": "^0.32.4", 16 | "@cosmjs/proto-signing": "^0.32.4", 17 | "@cosmjs/stargate": "^0.32.4", 18 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 19 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage" 20 | }, 21 | "devDependencies": { 22 | "@types/node": "^20.10.7", 23 | "ts-node": "^10.9.1", 24 | "typescript": "^5.5.3" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/cosmos/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": false, 11 | "noUnusedParameters": false, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/esm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "esm", 3 | "type": "module", 4 | "version": "1.0.0", 5 | "description": "Example of how to use the Cubesigner SDK with Webpack", 6 | "license": "MIT OR Apache-2.0", 7 | "author": "Cubist, Inc.", 8 | "main": "src/index.js", 9 | "scripts": { 10 | "build": "", 11 | "test": "node ." 12 | }, 13 | "dependencies": { 14 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/esm/src/index.js: -------------------------------------------------------------------------------- 1 | import { CubeSignerClient } from "@cubist-labs/cubesigner-sdk"; 2 | 3 | console.log(CubeSignerClient); -------------------------------------------------------------------------------- /examples/ethers/README.md: -------------------------------------------------------------------------------- 1 | # CubeSigner TypeScript SDK: ethers.js Example 2 | 3 | This example shows how the CubeSigner TypeScript SDK can be used to sign 4 | transactions on EVM-based chains with ethers.js. Specifically, the example 5 | shows how to sign and send a simple value transaction from one account to 6 | another. 7 | 8 | ## Running the Example 9 | 10 | To run the example, you need to first create a key and add it to a role like we 11 | did in the [top-level README](../../README.md). After you do this, generate a 12 | session token for the role; you can either save the token (`cs token create ... --save`) 13 | or export as base64: 14 | 15 | ```bash 16 | export CUBE_SIGNER_TOKEN=$(cs token create ... --output base64) 17 | ``` 18 | 19 | Then, set the source and destination addresses, and [a JSON-RPC provider for your desired chain](https://ethereum-json-rpc.com/providers): 20 | 21 | ```bash 22 | export FROM_ADDRESS=0x... # this is your secp key material id 23 | export TO_ADDRESS=0x... # the recipient 24 | export RPC_PROVIDER=https://... # A JSON-RPC provider for the desired chain 25 | ``` 26 | 27 | For this example to work you need to have some funds in your account. 28 | -------------------------------------------------------------------------------- /examples/ethers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-ethers-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "start": "node ./dist/index.js" 13 | }, 14 | "dependencies": { 15 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 16 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 17 | "@cubist-labs/cubesigner-sdk-ethers-v6": "../../packages/ethers-v6" 18 | }, 19 | "devDependencies": { 20 | "@types/node": "^22.5.2", 21 | "ts-node": "^10.9.2", 22 | "typescript": "^5.5.4" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/ethers/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/mfa/README.md: -------------------------------------------------------------------------------- 1 | # MFA Example 2 | 3 | In this example we are first going to use the CubeSigner CLI tool (`cs`) 4 | to create a role and add a key to it s.t., multi-factor authentication (MFA) 5 | is required before that key may be used for signing. 6 | 7 | Next, we are going to use the CubeSigner TypeScript SDK to implement a 8 | simple Node app that allows different users to: 9 | 10 | - initiate signing an EVM transaction with key from the role (which initially requires MFA) 11 | - list pending MFA requests assigned to them 12 | - approve a pending MFA request 13 | - obtain the signed EVM transaction once the MFA request is approved 14 | 15 | ## Prerequisites 16 | 17 | - `cs` (version `v.0.27.0` or later) is installed and in `PATH` 18 | - a user is logged into CubeSigner (i.e., `cs user me` works) 19 | 20 | ## Demo 21 | 22 | Follow the instructions in [demo.sh](./demo.sh). 23 | -------------------------------------------------------------------------------- /examples/mfa/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-mfa-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "start": "node ./dist/index.js" 13 | }, 14 | "dependencies": { 15 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 16 | "cli-color": "^2.0.3", 17 | "commander": "^11.0.0", 18 | "dotenv": "^16.3.1" 19 | }, 20 | "devDependencies": { 21 | "@types/cli-color": "^2.0.3", 22 | "@types/node": "^20.10.7", 23 | "ts-node": "^10.9.1", 24 | "typescript": "^4.8" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/mfa/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/oidc-client-signing-simple-api-only/.env.template: -------------------------------------------------------------------------------- 1 | GOOGLE_CLIENT_ID= 2 | ORG_ID= 3 | CS_API_ROOT=https://gamma.signer.cubist.dev 4 | -------------------------------------------------------------------------------- /examples/oidc-client-signing-simple-api-only/.gitignore: -------------------------------------------------------------------------------- 1 | public/*.d.ts 2 | public/*.js 3 | src/*.js 4 | .env 5 | .vscode 6 | -------------------------------------------------------------------------------- /examples/oidc-client-signing-simple-api-only/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-oidc-client-signing-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "./src/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "start": "node ./src/index.js" 13 | }, 14 | "dependencies": { 15 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 16 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 17 | "@types/express": "^4.17.21", 18 | "dotenv": "^16.3.1", 19 | "express": "^4.19.2", 20 | "express-handlebars": "^7.1.2" 21 | }, 22 | "devDependencies": { 23 | "@types/node": "^20.10.7", 24 | "ts-node": "^10.9.1", 25 | "typescript": "^4.8" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/oidc-client-signing-simple-api-only/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true 21 | }, 22 | "exclude": ["node_modules", "dist"], 23 | "include": ["src/**/*.ts", "public/**/*.ts"] 24 | } 25 | -------------------------------------------------------------------------------- /examples/oidc-client-signing-simple-api-only/views/index.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sign-In with Google and Sign EVM transaction 4 | 8 | 9 | 10 |

Sign-In with Google and Sign EVM transaction transparently

11 | 12 | 18 | 19 |
20 |
21 |
23 |
24 | 27 |
28 |
29 | 30 | -------------------------------------------------------------------------------- /examples/oidc-client-signing/.env.template: -------------------------------------------------------------------------------- 1 | GOOGLE_CLIENT_ID= 2 | TWITTER_CLIENT_ID= 3 | FACEBOOK_CLIENT_ID= 4 | ORG_ID= 5 | CS_API_ROOT=https://gamma.signer.cubist.dev 6 | -------------------------------------------------------------------------------- /examples/oidc-client-signing/.gitignore: -------------------------------------------------------------------------------- 1 | public/ 2 | .env 3 | -------------------------------------------------------------------------------- /examples/oidc-client-signing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-oidc-client-signing-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "bundle": "esbuild node_modules/@cubist-labs/cubesigner-sdk/dist/src/index.js --bundle --minify --sourcemap --format=iife --global-name=cs --outfile=public/cs/index.js", 12 | "prestart": "npm run build && npm run bundle", 13 | "start": "node ./dist/index.js" 14 | }, 15 | "dependencies": { 16 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 17 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 18 | "@types/body-parser": "^1.19.2", 19 | "@types/express": "^4.17.17", 20 | "body-parser": "^1.20.2", 21 | "dotenv": "^16.3.1", 22 | "express": "^4.19.2", 23 | "express-handlebars": "^7.1.2" 24 | }, 25 | "devDependencies": { 26 | "@types/node": "^20.10.7", 27 | "buffer": "^6.0.3", 28 | "esbuild": "^0.19.11", 29 | "path-browserify": "^1.0.1", 30 | "ts-node": "^10.9.1", 31 | "typescript": "^4.8" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /examples/oidc-client-signing/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/oidc-client-signing/views/layouts/main.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{{body}}} 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/oidc-client-signing/views/oauthCallback.handlebars: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/oidc/.env.template: -------------------------------------------------------------------------------- 1 | GOOGLE_CLIENT_ID= 2 | APPLE_CLIENT_ID= 3 | BASE_URL= 4 | -------------------------------------------------------------------------------- /examples/oidc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-oidc-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "start": "node ./dist/index.js" 13 | }, 14 | "dependencies": { 15 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 16 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 17 | "@types/body-parser": "^1.19.2", 18 | "@types/express": "^4.17.17", 19 | "body-parser": "^1.20.2", 20 | "dotenv": "^16.3.1", 21 | "express": "^4.19.2" 22 | }, 23 | "devDependencies": { 24 | "@types/node": "^20.10.7", 25 | "ts-node": "^10.9.1", 26 | "typescript": "^4.8" 27 | }, 28 | "engines": { 29 | "node": ">=18.0.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/oidc/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/rotation-lambda/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | build 6 | outputs.json 7 | package-lock.json 8 | 9 | # CDK asset staging directory 10 | cdk/.cdk.staging 11 | cdk/cdk.out 12 | -------------------------------------------------------------------------------- /examples/rotation-lambda/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: install-deps 2 | install-deps: 3 | npm install 4 | 5 | .PHONY: deploy 6 | deploy: install-deps 7 | # Rebuild lambda 8 | npm -w lambdas/rotation-lambda run build 9 | mkdir -p build 10 | cd lambdas/rotation-lambda && zip -r ../../build/rotation-lambda.zip index.js 11 | npm -w cdk run cdk -- deploy --outputs-file outputs.json 12 | -------------------------------------------------------------------------------- /examples/rotation-lambda/cdk/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /examples/rotation-lambda/cdk/bin/rotation-lambda.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import 'source-map-support/register'; 3 | import * as cdk from 'aws-cdk-lib'; 4 | import { RotationLambdaStack } from '../lib/rotation-lambda-stack'; 5 | 6 | const app = new cdk.App(); 7 | new RotationLambdaStack(app, 'RotationLambdaStack', {}); 8 | -------------------------------------------------------------------------------- /examples/rotation-lambda/cdk/lib/rotation-lambda-stack.ts: -------------------------------------------------------------------------------- 1 | import * as cdk from 'aws-cdk-lib'; 2 | import * as lambda from 'aws-cdk-lib/aws-lambda'; 3 | import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager"; 4 | import type { Construct } from 'constructs'; 5 | 6 | /** Stack that deploys a secret for storing a CubeSigner session and a lambda for refreshing it */ 7 | export class RotationLambdaStack extends cdk.Stack { 8 | /** 9 | * Constructor. 10 | * 11 | * @param scope Parent of this stack 12 | * @param id The construct ID of this stack 13 | * @param props Stack properties 14 | */ 15 | constructor(scope: Construct, id: string, props?: cdk.StackProps) { 16 | super(scope, id, props); 17 | 18 | const cubeSignerSession = new secretsmanager.Secret(this, "CubeSignerSession", { 19 | description: "CubeSigner session data", 20 | }); 21 | 22 | const rotationLambda = new lambda.Function(this, "RotationLambda", { 23 | runtime: lambda.Runtime.NODEJS_20_X, 24 | handler: "index.handler", 25 | description: "Lambda for refreshing a CubeSigner session", 26 | code: lambda.Code.fromAsset(`${__dirname}/../../build/rotation-lambda.zip`) 27 | }); 28 | 29 | cubeSignerSession.grantWrite(rotationLambda); 30 | cubeSignerSession.addRotationSchedule("Rotation", { 31 | rotationLambda: rotationLambda, 32 | // NOTE: Make sure that this is smaller than the session's auth and refresh lifetimes to 33 | // make sure that there is always a valid auth token available 34 | automaticallyAfter: cdk.Duration.hours(4), 35 | }); 36 | 37 | new cdk.CfnOutput(this, 'CubeSignerSessionArn', { value: cubeSignerSession.secretArn }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/rotation-lambda/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-rotation-lambda-cdk", 3 | "version": "0.1.0", 4 | "license": "MIT OR Apache-2.0", 5 | "author": "Cubist, Inc.", 6 | "bin": { 7 | "rotation-lambda": "bin/rotation-lambda.js" 8 | }, 9 | "files": [ 10 | "tsconfig.json", 11 | "src/**", 12 | "dist/**", 13 | "../../../LICENSE-APACHE", 14 | "../../../LICENSE-MIT" 15 | ], 16 | "scripts": { 17 | "build": "npx tsc", 18 | "watch": "npx tsc -w", 19 | "test": "npx jest", 20 | "cdk": "npx cdk" 21 | }, 22 | "devDependencies": { 23 | "@types/jest": "^29.5.14", 24 | "@types/node": "22.7.9", 25 | "jest": "^29.7.0", 26 | "ts-jest": "^29.2.5", 27 | "aws-cdk": "2.166.0", 28 | "cdk": "2.1001.0", 29 | "ts-node": "^10.9.2", 30 | "typescript": "~5.6.3" 31 | }, 32 | "dependencies": { 33 | "aws-cdk-lib": "2.166.0", 34 | "constructs": "^10.0.0", 35 | "source-map-support": "^0.5.21" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /examples/rotation-lambda/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2020", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": false, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | }, 23 | "exclude": [ 24 | "node_modules", 25 | "cdk.out" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /examples/rotation-lambda/lambdas/rotation-lambda/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-rotation-lambda", 3 | "version": "0.1.0", 4 | "license": "MIT OR Apache-2.0", 5 | "author": "Cubist, Inc.", 6 | "files": [ 7 | "tsconfig.json", 8 | "src/**", 9 | "dist/**", 10 | "../../../../LICENSE-APACHE", 11 | "../../../../LICENSE-MIT" 12 | ], 13 | "scripts": { 14 | "build": "npx tsc -noEmit && npx esbuild ./src/index.ts --conditions=cubist:esbuild --bundle --minify --preserve-symlinks --platform=node --target=node20 --outdir=." 15 | }, 16 | "devDependencies": { 17 | "@types/node": "^22.9.0", 18 | "esbuild": "0.24.0", 19 | "typescript": "^5.5.4" 20 | }, 21 | "dependencies": { 22 | "@cubist-labs/cubesigner-sdk": "../../../../packages/sdk", 23 | "@cubist-labs/cubesigner-sdk-secretsmanager-storage": "../../../../packages/secretsmanager-storage" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/rotation-lambda/lambdas/rotation-lambda/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as csSm from "@cubist-labs/cubesigner-sdk-secretsmanager-storage"; 2 | 3 | /** The type of the event that a rotation lambda receives */ 4 | type RotationEvent = { 5 | Step: string; 6 | SecretId: string; 7 | ClientRequestToken: string; 8 | }; 9 | 10 | /** The type of a lambda handler */ 11 | type Handler = (event: RotationEvent, _context: unknown) => Promise; 12 | 13 | /** 14 | * The lambda handler 15 | * 16 | * @param event The event being processed 17 | * @param _context Ignored 18 | */ 19 | export const handler: Handler = async (event: RotationEvent, _context) => { 20 | // On each rotation, the lambda is called four times. Rotate only on the first call (createSecret). 21 | if (event.Step != "createSecret") { 22 | return; 23 | } 24 | 25 | console.log(`Refreshing for request-token ${event.ClientRequestToken}`); 26 | await new csSm.AwsSecretManager(event.SecretId).refresh(); 27 | console.log("done"); 28 | }; 29 | -------------------------------------------------------------------------------- /examples/rotation-lambda/lambdas/rotation-lambda/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/rotation-lambda/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-rotation-lambda-workspace", 3 | "version": "0.1.0", 4 | "license": "(MIT-0 OR Apache-2.0)", 5 | "author": "Cubist, Inc.", 6 | "workspaces": [ 7 | "cdk", 8 | "lambdas/rotation-lambda", 9 | "scripts" 10 | ], 11 | "scripts": { 12 | "build": "true", 13 | "gen-session": "npm -C scripts run gen-session", 14 | "use-session": "npm -C scripts run use-session" 15 | }, 16 | "engines": { 17 | "node": ">=18.0.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/rotation-lambda/scripts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rotation-lambda-scripts", 3 | "version": "0.1.0", 4 | "license": "MIT OR Apache-2.0", 5 | "scripts": { 6 | "prebuild": "npm ci", 7 | "build": "tsc", 8 | "gen-session": "npm run build && node ./dist/scripts/src/gen-session.js", 9 | "use-session": "npm run build && node ./dist/scripts/src/use-session.js" 10 | }, 11 | "devDependencies": { 12 | "@types/node": "^22.9.0", 13 | "typescript": "^5.5.4" 14 | }, 15 | "dependencies": { 16 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 17 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 18 | "@cubist-labs/cubesigner-sdk-secretsmanager-storage": "../../packages/secretsmanager-storage" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/rotation-lambda/scripts/src/gen-session.ts: -------------------------------------------------------------------------------- 1 | import * as cs from "@cubist-labs/cubesigner-sdk"; 2 | import * as csFs from "@cubist-labs/cubesigner-sdk-fs-storage"; 3 | import * as csSm from "@cubist-labs/cubesigner-sdk-secretsmanager-storage"; 4 | import outputs from '../../cdk/outputs.json'; 5 | 6 | /** 7 | * Creates a new session and stores it in the secret created by CDK 8 | */ 9 | async function main() { 10 | const secretId = outputs.RotationLambdaStack.CubeSignerSessionArn; 11 | const client = await cs.CubeSignerClient.create(csFs.defaultManagementSessionManager()); 12 | // NOTE: When adapting this example to your code base, create a session with only the strictly 13 | // necessary scopes 14 | const session = await client.org().createSession( 15 | "Secrets Manager example", 16 | ["manage:*"], 17 | { 18 | auth: 8 * 60 * 60, // 8 hours 19 | } 20 | ); 21 | 22 | // Write session to AWS Secret Manager 23 | await new csSm.AwsSecretManager(secretId).update(session); 24 | } 25 | 26 | main().catch((err: Error) => { 27 | console.error(err); 28 | process.exit(1); 29 | }); 30 | -------------------------------------------------------------------------------- /examples/rotation-lambda/scripts/src/use-session.ts: -------------------------------------------------------------------------------- 1 | import * as cs from "@cubist-labs/cubesigner-sdk"; 2 | import * as csSm from "@cubist-labs/cubesigner-sdk-secretsmanager-storage"; 3 | import outputs from '../../cdk/outputs.json'; 4 | 5 | /** 6 | * Uses the session stored in the secret created by CDK 7 | */ 8 | async function main() { 9 | const secretId = outputs.RotationLambdaStack.CubeSignerSessionArn; 10 | const client = await cs.CubeSignerClient.create(new csSm.AwsSecretSessionManager(secretId)); 11 | const user = await client.user(); 12 | console.log(user.orgs); 13 | } 14 | 15 | main().catch((err: Error) => { 16 | console.error(err); 17 | process.exit(1); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/rotation-lambda/scripts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/solana-policy/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-solana-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "start": "node ./dist/index.js" 13 | }, 14 | "dependencies": { 15 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 16 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 17 | "@solana/web3.js": "^1.91.7" 18 | }, 19 | "devDependencies": { 20 | "@types/node": "^20.10.7", 21 | "ts-node": "^10.9.1", 22 | "typescript": "^4.8" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/solana-policy/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/solana/README.md: -------------------------------------------------------------------------------- 1 | # CubeSigner TypeScript SDK: @solana/web3.js Example 2 | 3 | This example shows how to use 4 | [@solana/web3.js](https://www.npmjs.com/package/@solana/web3.js) and the 5 | CubeSigner TypeScript SDK to sign Solana transactions in secure hardware. 6 | Specifically, the example shows how to sign and send a simple value transaction 7 | from one account to another. 8 | 9 | ## Running the Example 10 | 11 | To run the example, you need to first create a key and add it to a role like we 12 | did in the [top-level README](../../README.md). After you do this, generate a 13 | session token for the role; you can either save the token (`cs token create ... --save`) 14 | or export as base64: 15 | 16 | ```bash 17 | export CUBE_SIGNER_TOKEN=$(cs token create ... --output base64) 18 | ``` 19 | 20 | Then, set the source and destination addresses: 21 | 22 | ```bash 23 | export FROM_ADDRESS=... # this is your Solana base58 key material id 24 | export TO_ADDRESS=... # the recipient 25 | ``` 26 | 27 | For this example to work you need to have some funds in your account. 28 | 29 | By default, the example runs on the Solana devnet. You can, of course, change 30 | this on the Solana testnet or mainnet. 31 | 32 | ## Raw Ed25519 signing 33 | 34 | Though we strongly suggest using the well-typed Solana end point (which expects 35 | a base64-encoded serialized message), this example also shows how to to use raw 36 | Ed25519 signing to sign messages. To exercise this path, you need to make sure 37 | the source key has `AllowRawBlobSigning` enabled: 38 | 39 | ```bash 40 | cs key set-policy --key-id="Key#Solana_..." --policy='"AllowRawBlobSigning"' 41 | ``` 42 | -------------------------------------------------------------------------------- /examples/solana/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-solana-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "start": "node ./dist/index.js" 13 | }, 14 | "dependencies": { 15 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 16 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 17 | "@solana/web3.js": "^1.91.7", 18 | "borsh": "^1.0.0", 19 | "bs58": "^5.0.0" 20 | }, 21 | "devDependencies": { 22 | "@types/node": "^20.10.7", 23 | "ts-node": "^10.9.1", 24 | "typescript": "^4.8" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/solana/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/stellar/README.md: -------------------------------------------------------------------------------- 1 | # CubeSigner TypeScript SDK: Stellar-SDK Example 2 | 3 | This example shows how the CubeSigner TypeScript SDK can be used to sign 4 | Stellar transactions using the js-stellar-sdk. Specifically, the example shows 5 | how to sign and send a simple value transaction from one account to another, 6 | extending the [js-stellar-sdk 7 | example](https://github.com/stellar/js-stellar-sdk/blob/62eab36822cd7a3e16d201bcbae7e9ed28589310/docs/reference/examples.md). 8 | 9 | ## Running the Example 10 | 11 | To run the example, you need to first create a key and add it to a role like we 12 | did in the [top-level README](../../README.md). Be sure to attach allow raw 13 | blob signing when you add the key to the role: `cs role add-keys ... --policy 14 | '"AllowRawBlobSigning"'`. After you do this, generate a session token for the 15 | role; you can either save the token (`cs token create ... --save`) or export as 16 | base64: 17 | 18 | ```bash 19 | export CUBE_SIGNER_TOKEN=$(cs token create ... --output base64) 20 | ``` 21 | 22 | Then, set the source and destination addresses: 23 | 24 | ```bash 25 | export FROM_ADDRESS=G... # this is your stellar key material id 26 | export TO_ADDRESS=G... # the recipient 27 | ``` 28 | 29 | For this example to work you need to have some funds in your account. 30 | 31 | By default, the example runs on the Horizon testnet. 32 | -------------------------------------------------------------------------------- /examples/stellar/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-stellar-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "start": "node ./dist/index.js" 13 | }, 14 | "dependencies": { 15 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 16 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 17 | "stellar-sdk": "^11.0.1" 18 | }, 19 | "devDependencies": { 20 | "@types/node": "^20.10.7", 21 | "typescript": "^4.8" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/stellar/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/sui/README.md: -------------------------------------------------------------------------------- 1 | # CubeSigner TypeScript SDK: Sui token transfer example 2 | 3 | This example shows how to use `@mysten/sui` and the CubeSigner TypeScript SDK to 4 | sign Sui transactions in secure hardware. 5 | 6 | ## Running the Example 7 | 8 | To run the example, you need to first create a key and add it to a role like we 9 | did in the [top-level README](../../README.md). After you do this, generate a 10 | session token for the role; you can either save the token (`cs token create ... 11 | --save`) or export as base64: 12 | 13 | ```bash 14 | export CUBE_SIGNER_TOKEN=$(cs token create ... --output base64) 15 | ``` 16 | 17 | If you're not using roles, you could instead use a user session token: `cs token 18 | create --user ...`. 19 | 20 | Once you have a session, set the source and destination addresses: 21 | 22 | ```bash 23 | export FROM_ADDRESS=... # this is your Sui key material id 24 | export TO_ADDRESS=... # the recipient 25 | ``` 26 | ### Sending SUI 27 | 28 | By default the example send 2000 mists, so you need to have some SUI in your 29 | account to run: 30 | 31 | 32 | ```bash 33 | npm -C examples/sui start 34 | ``` 35 | 36 | ### Sending other tokens 37 | 38 | To send other token, like 39 | [NAVX](https://suiscan.xyz/mainnet/coin/0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX), 40 | you just need to additionally set the coin type (and network): 41 | 42 | ``` 43 | ... 44 | export SUI_NETWORK=mainnet 45 | export COIN_TYPE="0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX" 46 | export AMOUNT=99999 47 | npm -C examples/sui start 48 | ``` -------------------------------------------------------------------------------- /examples/sui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-sui-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "start": "node ./dist/index.js" 13 | }, 14 | "dependencies": { 15 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 16 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 17 | "@mysten/sui": "^1.29.0", 18 | "readline-sync": "^1.4.10" 19 | }, 20 | "devDependencies": { 21 | "@types/node": "^20.10.7", 22 | "ts-node": "^10.9.1", 23 | "typescript": "^5.5.3" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/sui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": false, 11 | "noUnusedParameters": false, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/viem/README.md: -------------------------------------------------------------------------------- 1 | # CubeSigner TypeScript SDK: viem Example 2 | 3 | This example shows how the CubeSigner TypeScript SDK can be used to sign 4 | transactions on EVM-based chains with viem. Specifically, the example shows how 5 | to sign and send a simple value transaction from one account to another. 6 | 7 | ## Running the Example 8 | 9 | To run the example, you need to first create a key and add it to a role like we 10 | did in the [top-level README](../../README.md). After you do this, generate a 11 | session token for the role; you can either save the token (`cs token create ... --save`) 12 | or export as base64: 13 | 14 | ```bash 15 | export CUBE_SIGNER_TOKEN=$(cs token create ... --output base64) 16 | ``` 17 | 18 | Then, set the source and destination addresses, and a [JSON-RPC provider for your desired chain](https://ethereum-json-rpc.com/providers): 19 | 20 | ```bash 21 | export FROM_ADDRESS=0x... # this is your secp key material id 22 | export TO_ADDRESS=0x... # the recipient 23 | export RPC_PROVIDER=https://... # A JSON-RPC provider 24 | ``` 25 | 26 | For this example to work you need to have some funds in your account. 27 | -------------------------------------------------------------------------------- /examples/viem/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-viem-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc", 11 | "prestart": "npm run build", 12 | "fmt": "prettier --write .", 13 | "start": "node ./dist/index.js" 14 | }, 15 | "dependencies": { 16 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 17 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 18 | "viem": "^2.21.54" 19 | }, 20 | "devDependencies": { 21 | "@types/node": "^22.5.2", 22 | "ts-node": "^10.9.2", 23 | "typescript": "^5.5.4" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/viem/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "strict": true, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "alwaysStrict": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": false, 14 | "inlineSourceMap": true, 15 | "inlineSources": true, 16 | "experimentalDecorators": true, 17 | "strictPropertyInitialization": true, 18 | "resolveJsonModule": true, 19 | "esModuleInterop": true, 20 | "skipLibCheck": true, 21 | "outDir": "./dist" 22 | }, 23 | "exclude": ["node_modules", "dist"], 24 | "include": ["src/**/*.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/waas-in-a-box/README.md: -------------------------------------------------------------------------------- 1 | # WaaS in a box 2 | 3 | This example implements a Wallet-as-a-Service provider (server and client web app) using CubeSigner. 4 | 5 | This includes: 6 | - OIDC logins 7 | - User registration 8 | - End-user signing 9 | 10 | Comments throughout the code correspond to the [End-User Wallets] section 11 | of the [CubeSigner docs]. 12 | 13 | ## Setup 14 | 15 | 1. Edit the `.env` file to include: 16 | 17 | - Your Org ID, 18 | - Your OAuth Client information (optional) 19 | 20 | By default, this example uses a testing-only Google OAuth client provided by 21 | Cubist. It will only ever work on `localhost`. If you wish use your own client, 22 | you can put the relevant information in the `.env` file. You will need to register 23 | `http://localhost:3000` as a redirect URI. 24 | 25 | 2. Configure your org 26 | Follow the [setup instructions], to enable the OAuth Client (`issuer` and `client_id`) 27 | defined in the `.env` file. You must also add `http://localhost:3000` to your 28 | `OriginAllowlist`. 29 | 30 | ## Running the example 31 | 32 | Simply invoke: 33 | 34 | ```bash 35 | npm start 36 | ``` 37 | 38 | and navigate to `http://localhost:3000` 39 | 40 | [setup instructions]: https://signer-docs.cubist.dev/end-user-wallets/setup 41 | [End-User Wallets]: https://signer-docs.cubist.dev/end-user-wallets 42 | [CubeSigner docs]: https://signer-docs.cubist.dev/ 43 | -------------------------------------------------------------------------------- /examples/waas-in-a-box/app/.env: -------------------------------------------------------------------------------- 1 | # Populate this file with your own values 2 | # The values in this file are used by the backend and frontend 3 | # Only VITE_ prefixed values are accessible by the frontend 4 | VITE_ORG_ID= 5 | VITE_ISSUER_URL=https://accounts.google.com 6 | VITE_CLIENT_ID=991377673731-7vcard03e7gf08dhkd1ntgc8m43i3g7e.apps.googleusercontent.com 7 | VITE_CUBESIGNER_ENV=gamma 8 | BACKEND_SESSION= -------------------------------------------------------------------------------- /examples/waas-in-a-box/app/env.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This module simply exports the project's env vars. 3 | * This is specific to your bundler (in this case, vite), 4 | * so we've isolated it to this module 5 | */ 6 | 7 | import { envs, type EnvInterface } from "@cubist-labs/cubesigner-sdk"; 8 | 9 | export const ORG_ID: string = import.meta.env.VITE_ORG_ID; 10 | export const ISSUER_URL: string = import.meta.env.VITE_ISSUER_URL; 11 | export const CLIENT_ID: string = import.meta.env.VITE_CLIENT_ID; 12 | export const CUBESIGNER_ENV: EnvInterface = ((e) => envs[e] ?? Object.values(JSON.parse(e))[0])( 13 | import.meta.env.VITE_CUBESIGNER_ENV, 14 | ); 15 | -------------------------------------------------------------------------------- /examples/waas-in-a-box/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | WaaS in a Box 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/waas-in-a-box/app/login_user.ts: -------------------------------------------------------------------------------- 1 | import { CUBESIGNER_ENV, ORG_ID } from "./env.js"; 2 | import { CubeSignerClient, type SessionData } from "@cubist-labs/cubesigner-sdk"; 3 | import type { OidcToken } from "./oauth.js"; 4 | 5 | /** 6 | * Implements the LoginFlow steps 3-4 7 | * 8 | * @param idToken The ID token from the OIDC provider 9 | * @returns A session for the logged-in user 10 | */ 11 | export async function loginUser(idToken: OidcToken): Promise { 12 | // Create a session, requesting only the scopes we need for this application 13 | const response = await CubeSignerClient.createOidcSession(CUBESIGNER_ENV, ORG_ID, idToken, [ 14 | "manage:readonly", // for listing keys 15 | "sign:evm:tx", // for signing the test transaction 16 | ]); 17 | 18 | if (response.requiresMfa()) { 19 | throw new Error("This example does not include MFA"); 20 | } 21 | 22 | return response.data(); 23 | } 24 | -------------------------------------------------------------------------------- /examples/waas-in-a-box/app/register_user.ts: -------------------------------------------------------------------------------- 1 | import { CubeSignerClient } from "@cubist-labs/cubesigner-sdk"; 2 | import type { OidcToken } from "./oauth.js"; 3 | import { CUBESIGNER_ENV, ORG_ID } from "./env.js"; 4 | 5 | /** 6 | * Registers a user in the organization by making a request to the backend. 7 | * 8 | * @param id_token The ID token from the OIDC provider 9 | */ 10 | export async function registerUser(id_token: OidcToken): Promise { 11 | // Step 3 12 | // Step 4 13 | // Generate an identity proof 14 | const identity_proof = await CubeSignerClient.proveOidcIdentity(CUBESIGNER_ENV, ORG_ID, id_token); 15 | 16 | // Step 5 17 | // Pass the proof to the backend 18 | await fetch("/register", { 19 | method: "POST", 20 | headers: { 21 | "Content-Type": "application/json", 22 | }, 23 | body: JSON.stringify({ identity_proof }), 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /examples/waas-in-a-box/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "waas-in-a-box", 3 | "version": "1.0.0", 4 | "description": "A server and client example for a Wallet-as-a-Service backed by CubeSigner", 5 | "type": "module", 6 | "scripts": { 7 | "start": "tsx src/server.ts", 8 | "prebuild": "npm ci", 9 | "build": "vite build && tsc -p . --noEmit" 10 | }, 11 | "author": "", 12 | "license": "MIT OR Apache-2.0", 13 | "devDependencies": { 14 | "@rollup/plugin-commonjs": "^28.0.1", 15 | "@types/react": "^18.3.12", 16 | "express": "^4.21.1", 17 | "openid-client": "^6.1.3", 18 | "react": "^18.3.1", 19 | "react-dom": "^18.3.1", 20 | "tsx": "^4.19.2", 21 | "vite": "^5.4.11", 22 | "vite-express": "^0.19.0" 23 | }, 24 | "dependencies": { 25 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 26 | "@cubist-labs/cubesigner-sdk-browser-storage": "../../packages/browser-storage", 27 | "@types/express": "^5.0.0", 28 | "body-parser": "^1.20.3", 29 | "dotenv": "^16.4.5" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/waas-in-a-box/src/routes/register_user.ts: -------------------------------------------------------------------------------- 1 | import { 2 | CubeSignerClient, 3 | parseSessionLike, 4 | Secp256k1, 5 | type IdentityProof, 6 | } from "@cubist-labs/cubesigner-sdk"; 7 | import type { RequestHandler } from "express"; 8 | import { config } from "dotenv"; 9 | 10 | // Load the environment variables 11 | config(); 12 | 13 | /** 14 | * A route handler implementing steps 5-7 of the registration flow. 15 | * Accepts a POST request with an identity proof, and creates a user in the organization. 16 | * 17 | * @param req The request object 18 | * @param res The response object 19 | */ 20 | export default (async (req, res) => { 21 | const session = parseSessionLike(process.env.BACKEND_SESSION!); 22 | const client = await CubeSignerClient.create(session); 23 | 24 | // Step 5: Receive the identity proof from the frontend 25 | const proof: IdentityProof = req.body.identity_proof; 26 | 27 | // Inspect the proof and decide whether to accept it 28 | // TODO: Implement your own validation logic here 29 | if (proof.email?.startsWith("spam")) { 30 | res.status(403).send("No spam allowed"); 31 | return; 32 | } 33 | 34 | // Step 6 & Step 7 35 | // Create a user in the organization 36 | // If the proof is invalid, this will throw an error 37 | const userId = await client.org().createOidcUser(proof, proof.email); 38 | 39 | console.debug("Created user", userId); 40 | 41 | // Give the user a key 42 | const key = await client.org().createKey(Secp256k1.Evm, userId); 43 | 44 | console.debug(`Created key ${key.materialId} for user ${userId}`); 45 | 46 | res.status(200).send(); 47 | }) satisfies RequestHandler; 48 | -------------------------------------------------------------------------------- /examples/waas-in-a-box/src/server.ts: -------------------------------------------------------------------------------- 1 | import express from "express"; 2 | import register from "./routes/register_user.js"; 3 | import bodyParser from "body-parser"; 4 | import { join } from "path"; 5 | 6 | const app = express(); 7 | app.use(bodyParser.json()); 8 | app.post("/register", register); 9 | 10 | const PORT = 3000; 11 | const listening = () => console.log(`Listening on port ${PORT}`); 12 | 13 | if (process.env.NODE_ENV === "production") { 14 | // In production, serve the client/dist folder 15 | app.use(express.static(join(import.meta.dirname, "../app/dist"))); 16 | app.listen(PORT, listening); 17 | } else { 18 | // In development, use Vite to serve the client 19 | const { default: ViteExpress } = await import("vite-express"); 20 | ViteExpress.listen(app, PORT, listening); 21 | } 22 | -------------------------------------------------------------------------------- /examples/waas-in-a-box/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2022", 4 | "module": "Node16", 5 | "moduleResolution": "node16", 6 | "jsx": "react", 7 | "skipLibCheck": true, 8 | "types": ["vite/client"] 9 | }, 10 | "exclude": ["node_modules"] 11 | } 12 | -------------------------------------------------------------------------------- /examples/waas-in-a-box/vite.config.js: -------------------------------------------------------------------------------- 1 | import commonjs from "@rollup/plugin-commonjs"; 2 | 3 | export default { 4 | root: "app", 5 | plugins: [commonjs()], 6 | optimizeDeps: { 7 | include: ["@cubist-labs/cubesigner-sdk", "@cubist-labs/cubesigner-sdk-browser-storage"], 8 | }, 9 | build: { 10 | commonjsOptions: { 11 | include: ["@cubist-labs/cubesigner-sdk", "@cubist-labs/cubesigner-sdk-browser-storage"], 12 | }, 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /examples/walletconnect/.env.template: -------------------------------------------------------------------------------- 1 | WALLETCONNECT_PROJECT_ID= 2 | CUBESIGNER_KEY_ID= 3 | -------------------------------------------------------------------------------- /examples/walletconnect/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cubesigner-walletconnect-example", 3 | "version": "1.0.0", 4 | "type": "module", 5 | "description": "Example of how to use CubeSigner with WalletConnect's WalletKit", 6 | "license": "MIT OR Apache-2.0", 7 | "author": "Cubist, Inc.", 8 | "scripts": { 9 | "prebuild": "npm ci", 10 | "build": "tsc" 11 | }, 12 | "dependencies": { 13 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 14 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 15 | "@cubist-labs/cubesigner-sdk-ethers-v6": "../../packages/ethers-v6", 16 | "@walletconnect/utils": "^2.13.3", 17 | "@walletconnect/web3wallet": "^1.12.3", 18 | "dotenv": "^16.4.5", 19 | "typescript": "^5.5.2" 20 | }, 21 | "devDependencies": { 22 | "@types/node": "^20.14.8", 23 | "@walletconnect/types": "^2.13.3" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/walletconnect/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/webpack/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webpack", 3 | "version": "1.0.0", 4 | "description": "Example of how to use the Cubesigner SDK with Webpack", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "build": "webpack --mode=production", 10 | "test": "npm run build" 11 | }, 12 | "dependencies": { 13 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk" 14 | }, 15 | "devDependencies": { 16 | "webpack": "^5.91.0", 17 | "webpack-cli": "^5.1.4" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/webpack/src/index.ts: -------------------------------------------------------------------------------- 1 | import { CubeSignerClient } from "@cubist-labs/cubesigner-sdk"; 2 | 3 | console.log(CubeSignerClient); -------------------------------------------------------------------------------- /examples/webpack/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | entry: './src/index.ts', 5 | output: { 6 | path: path.resolve(__dirname, 'dist'), 7 | filename: 'bundle.js', 8 | }, 9 | resolve: { 10 | fallback: { 11 | "crypto": false 12 | } 13 | }, 14 | }; -------------------------------------------------------------------------------- /packages/browser-storage/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { SessionData, SessionManager, SessionMetadata } from "@cubist-labs/cubesigner-sdk"; 2 | import { EventEmitter } from "@cubist-labs/cubesigner-sdk"; 3 | type BrowserStorageEvents = { 4 | logout(): void; 5 | login(): void; 6 | }; 7 | /** 8 | * A manager that persists into browser storage and uses weblocks to safely perform refreshes 9 | */ 10 | export declare class BrowserStorageManager extends EventEmitter implements SessionManager { 11 | #private; 12 | /** 13 | * 14 | * @param key The storage key to use 15 | * @param storage The storage object to use (defaults to localStorage) 16 | */ 17 | constructor(key: string, storage?: Storage); 18 | /** 19 | * Loads the metadata for a session from storage 20 | * 21 | * @returns The session metadata 22 | */ 23 | metadata(): Promise; 24 | /** 25 | * Loads the current access token from storage 26 | * 27 | * @returns The access token 28 | */ 29 | token(): Promise; 30 | /** 31 | * Directly set the session (updating all consumers of the session storage) 32 | * 33 | * @param session The new session 34 | */ 35 | setSession(session?: SessionData): Promise; 36 | } 37 | export {}; 38 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/browser-storage/dist/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,EACL,YAAY,EAOb,MAAM,4BAA4B,CAAC;AAGpC,KAAK,oBAAoB,GAAG;IAC1B,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,qBAAa,qBACX,SAAQ,YAAY,CAAC,oBAAoB,CACzC,YAAW,cAAc;;IAOzB;;;;OAIG;gBACS,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,OAAiC;IA4CnE;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,eAAe,CAAC;IAQ1C;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IA8B9B;;;;OAIG;IACG,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW;CAwBvC"} -------------------------------------------------------------------------------- /packages/browser-storage/dist/locks.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Used as an argument to {@link readTestAndSet}. 3 | * Defines the behavior to perform during the locking strategy 4 | */ 5 | export type ReadTestAndSet = { 6 | /** How to read the data */ 7 | read(): T; 8 | /** If true, perform set, if false, return v */ 9 | test(v: T): boolean; 10 | /** Persist the value */ 11 | set(prev: T): Promise; 12 | }; 13 | /** 14 | * A locking primitive for contentious reads and writes. 15 | * 16 | * Guarantees: 17 | * 1. Set is only called when test(read()) returns true 18 | * 2. Only 1 set() call is active at a time 19 | * 3. read() never occurs while set() is running 20 | * 21 | * @param lock The name of the lock to use 22 | * @param spec The set of read, test, and set functions to use 23 | * @returns The current value 24 | */ 25 | export declare function readTestAndSet(lock: string, spec: ReadTestAndSet): Promise; 26 | //# sourceMappingURL=locks.d.ts.map -------------------------------------------------------------------------------- /packages/browser-storage/dist/locks.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"locks.d.ts","sourceRoot":"","sources":["../src/locks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,2BAA2B;IAC3B,IAAI,IAAI,CAAC,CAAC;IACV,+CAA+C;IAC/C,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;IACpB,wBAAwB;IACxB,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAczF"} -------------------------------------------------------------------------------- /packages/browser-storage/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/cubesigner-sdk-browser-storage", 3 | "repository": { 4 | "type": "git", 5 | "url": "git+https://github.com/cubist-labs/CubeSigner-TypeScript-SDK.git", 6 | "directory": "packages/browser-storage" 7 | }, 8 | "version": "0.4.156-0", 9 | "description": "Browser-based storage for CubeSigner SDK sessions", 10 | "license": "MIT OR Apache-2.0", 11 | "author": "Cubist, Inc.", 12 | "main": "dist/index.js", 13 | "types": "dist/index.d.ts", 14 | "files": [ 15 | "tsconfig.json", 16 | "src/**", 17 | "dist/**", 18 | "../../NOTICE", 19 | "../../LICENSE-APACHE", 20 | "../../LICENSE-MIT" 21 | ], 22 | "scripts": { 23 | "build": "tsc", 24 | "prepack": "tsc", 25 | "test:playwright": "playwright test", 26 | "test:build": "esbuild test/site/testscript.ts --bundle --format=esm --outfile='test/site/testscript.js' --external:crypto", 27 | "test:server": "http-server ./test/site -c-1" 28 | }, 29 | "peerDependencies": { 30 | "@cubist-labs/cubesigner-sdk": "^0.4.156-0" 31 | }, 32 | "directories": { 33 | "test": "test" 34 | }, 35 | "devDependencies": { 36 | "@cubist-labs/cubesigner-sdk": "^0.4.156-0", 37 | "@cubist-labs/cubesigner-sdk-fs-storage": "^0.4.156-0", 38 | "@playwright/test": "^1.44.1", 39 | "esbuild": "^0.23.0", 40 | "http-server": "^14.1.1" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /packages/browser-storage/playwright.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "@playwright/test"; 2 | 3 | export default defineConfig({ 4 | testDir: "test", 5 | webServer: { 6 | command: "npm run test:build && npm run test:server -- -p 3000 -c-1", 7 | url: "http://localhost:3000/", 8 | }, 9 | use: { 10 | baseURL: "http://localhost:3000/", 11 | }, 12 | fullyParallel: true, 13 | }); 14 | -------------------------------------------------------------------------------- /packages/browser-storage/src/locks.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Used as an argument to {@link readTestAndSet}. 3 | * Defines the behavior to perform during the locking strategy 4 | */ 5 | export type ReadTestAndSet = { 6 | /** How to read the data */ 7 | read(): T; 8 | /** If true, perform set, if false, return v */ 9 | test(v: T): boolean; 10 | /** Persist the value */ 11 | set(prev: T): Promise; 12 | }; 13 | 14 | /** 15 | * A locking primitive for contentious reads and writes. 16 | * 17 | * Guarantees: 18 | * 1. Set is only called when test(read()) returns true 19 | * 2. Only 1 set() call is active at a time 20 | * 3. read() never occurs while set() is running 21 | * 22 | * @param lock The name of the lock to use 23 | * @param spec The set of read, test, and set functions to use 24 | * @returns The current value 25 | */ 26 | export async function readTestAndSet(lock: string, spec: ReadTestAndSet): Promise { 27 | const { read, test, set } = spec; 28 | const value = await navigator.locks.request(lock, { mode: "shared" }, async () => read()); 29 | if (test(value)) { 30 | return navigator.locks.request(lock, { mode: "exclusive" }, async () => { 31 | const prev = read(); 32 | if (test(prev)) { 33 | await set(prev); 34 | return read(); 35 | } 36 | return prev; 37 | }); 38 | } 39 | return value; 40 | } 41 | -------------------------------------------------------------------------------- /packages/browser-storage/test/site/.gitignore: -------------------------------------------------------------------------------- 1 | testscript.js -------------------------------------------------------------------------------- /packages/browser-storage/test/site/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Browser Storage Test Page 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/browser-storage/test/site/testscript.ts: -------------------------------------------------------------------------------- 1 | import { delay } from "@cubist-labs/cubesigner-sdk"; 2 | import { readTestAndSet } from "../../src/locks"; 3 | import { BrowserStorageManager } from "../../"; 4 | 5 | declare global { 6 | interface Window { 7 | readTestAndSet: typeof readTestAndSet; 8 | delay: typeof delay; 9 | BrowserStorageManager: typeof BrowserStorageManager; 10 | } 11 | } 12 | window.delay = delay; 13 | window.readTestAndSet = readTestAndSet; 14 | window.BrowserStorageManager = BrowserStorageManager; 15 | -------------------------------------------------------------------------------- /packages/browser-storage/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../../tsconfig.local.json -------------------------------------------------------------------------------- /packages/ethers-v5/README.md: -------------------------------------------------------------------------------- 1 | # ethers.js v5 Signer implementation for CubeSigner TypeScript SDK 2 | 3 | This package exposes a single `Signer` class which implements the ethers.js v5 4 | `Signer` abstract interface, offloading all signing tasks to a remote CubeSigner service. 5 | 6 | ## Simple example usage 7 | 8 | ```typescript 9 | import * as cs from "@cubist-labs/cubesigner-sdk"; 10 | import { Signer } from "@cubist-labs/cubesigner-sdk-ethers-v5"; 11 | import { ethers } from "ethers"; 12 | 13 | ... 14 | // Create new Signer given a key/account address and CubeSigner session object 15 | // (with permissions to sign with this key): 16 | const signer = new Signer(keyAddress, cubeSignerSession); 17 | 18 | // Sign transaction as usual: 19 | await signer.signTransaction({ 20 | to: "0xff50ed3d0ec03ac01d4c79aad74928bff48a7b2b", 21 | value: ethers.utils.parseEther("0.0000001"), 22 | }); 23 | ... 24 | ``` 25 | 26 | Check out the [@cubist-labs/cubesigner-sdk](https://www.npmjs.com/package/@cubist-labs/cubesigner-sdk) NPM package for more details on how to create signer sessions. -------------------------------------------------------------------------------- /packages/ethers-v5/dist/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAGV,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,GAAG,EACH,UAAU,EACX,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAQ1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,6BAA6B;AAC7B,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;CAC7C;AAED;;GAEG;AACH,qBAAa,MAAO,SAAQ,MAAM,CAAC,MAAO,YAAW,eAAe;;IAIlE;;;;;;OAMG;gBACS,OAAO,EAAE,GAAG,GAAG,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,aAAa;IAQpF,4CAA4C;IACtC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,GAAG,MAAM;IAOpD;;;;;;OAMG;IACG,oBAAoB,CAAC,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAuB3E;;;;;OAKG;IACG,eAAe,CAAC,EAAE,EAAE,UAAU,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAK1E;;;;;;;;OAQG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAM3D;;;;;;;;;OASG;IACG,cAAc,CAClB,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,EAC5C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACzB,OAAO,CAAC,MAAM,CAAC;IAiBlB;;;;;;OAMG;IACG,sBAAsB,CAAC,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAOjF;;;;;;;OAOG;IACG,0BAA0B,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAIvF"} -------------------------------------------------------------------------------- /packages/ethers-v5/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: "ts-jest", 4 | testTimeout: 15000, 5 | testEnvironment: "node", 6 | testMatch: ["/test/*.test.[jt]s"], 7 | reporters: [ 8 | "default", 9 | ["jest-summary-reporter", {"failuresOnly": false}] 10 | ] 11 | }; 12 | -------------------------------------------------------------------------------- /packages/ethers-v5/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/cubesigner-sdk-ethers-v5", 3 | "repository": { 4 | "type": "git", 5 | "url": "git+https://github.com/cubist-labs/CubeSigner-TypeScript-SDK.git", 6 | "directory": "packages/ethers-v5" 7 | }, 8 | "version": "0.4.156-0", 9 | "description": "Ethers.js v5 Signer implementation", 10 | "license": "MIT OR Apache-2.0", 11 | "author": "Cubist, Inc.", 12 | "main": "dist/index.js", 13 | "types": "dist/index.d.ts", 14 | "files": [ 15 | "tsconfig.json", 16 | "src/**", 17 | "dist/**", 18 | "../../NOTICE", 19 | "../../LICENSE-APACHE", 20 | "../../LICENSE-MIT" 21 | ], 22 | "scripts": { 23 | "build": "tsc", 24 | "prepack": "tsc", 25 | "test": "jest --maxWorkers=1" 26 | }, 27 | "peerDependencies": { 28 | "@cubist-labs/cubesigner-sdk": "^0.4.156-0", 29 | "ethers": "5.7.2" 30 | }, 31 | "directories": { 32 | "test": "test" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/ethers-v5/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../../tsconfig.local.json -------------------------------------------------------------------------------- /packages/ethers-v6/README.md: -------------------------------------------------------------------------------- 1 | # ethers.js v6 Signer implementation for CubeSigner TypeScript SDK 2 | 3 | This package exposes a single `Signer` class which implements the ethers.js v6 4 | `AbstractSigner` interface, offloading all signing tasks to a remote CubeSigner 5 | service. 6 | 7 | ## Simple example usage 8 | 9 | ```typescript 10 | import * as cs from "@cubist-labs/cubesigner-sdk"; 11 | import { Signer } from "@cubist-labs/cubesigner-sdk-ethers-v6"; 12 | import { ethers } from "ethers"; 13 | 14 | ... 15 | // Create new Signer given a key/account address and CubeSigner session object 16 | // (with permissions to sign with this key): 17 | const signer = new Signer(keyAddress, cubeSignerSession); 18 | 19 | // Sign transaction as usual: 20 | await signer.signTransaction({ 21 | to: "0xff50ed3d0ec03ac01d4c79aad74928bff48a7b2b", 22 | value: ethers.parseEther("0.0000001"), 23 | }); 24 | ... 25 | ``` 26 | 27 | Check out the [@cubist-labs/cubesigner-sdk](https://www.npmjs.com/package/@cubist-labs/cubesigner-sdk) NPM package for more details on how to create signer sessions. -------------------------------------------------------------------------------- /packages/ethers-v6/dist/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAwC,MAAM,EAAW,MAAM,QAAQ,CAAC;AAC/E,OAAO,KAAK,EACV,gBAAgB,EAGhB,cAAc,EACd,gBAAgB,EAChB,GAAG,EACH,UAAU,EACX,MAAM,4BAA4B,CAAC;AAGpC,6BAA6B;AAC7B,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC;CACnC;AAED;;GAEG;AACH,qBAAa,MAAO,SAAQ,MAAM,CAAC,cAAc;;IAI/C;;;;;;OAMG;gBACS,OAAO,EAAE,GAAG,GAAG,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,aAAa;IAKpF,+CAA+C;IACzC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAC,QAAQ,GAAG,MAAM;IAOjD;;;;;;OAMG;IACG,oBAAoB,CAAC,EAAE,EAAE,MAAM,CAAC,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAgClF;;;;;OAKG;IACG,eAAe,CAAC,EAAE,EAAE,MAAM,CAAC,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAKrE;;;;;;;OAOG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAMhE;;;;;;;;;OASG;IACG,aAAa,CACjB,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,EAC5C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACzB,OAAO,CAAC,MAAM,CAAC;IAiBlB;;;;;;OAMG;IACG,sBAAsB,CAAC,EAAE,EAAE,MAAM,CAAC,kBAAkB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAOxF;;;;;;;OAOG;IACG,0BAA0B,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC;CAI9F"} -------------------------------------------------------------------------------- /packages/ethers-v6/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: "ts-jest", 4 | testTimeout: 15000, 5 | testEnvironment: "node", 6 | testMatch: ["/test/*.test.[jt]s"], 7 | reporters: [ 8 | "default", 9 | ["jest-summary-reporter", {"failuresOnly": false}] 10 | ] 11 | }; 12 | -------------------------------------------------------------------------------- /packages/ethers-v6/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/cubesigner-sdk-ethers-v6", 3 | "repository": { 4 | "type": "git", 5 | "url": "git+https://github.com/cubist-labs/CubeSigner-TypeScript-SDK.git", 6 | "directory": "packages/ethers-v6" 7 | }, 8 | "version": "0.4.156-0", 9 | "description": "Ethers.js v6 Signer implementation", 10 | "license": "MIT OR Apache-2.0", 11 | "author": "Cubist, Inc.", 12 | "main": "dist/index.js", 13 | "types": "dist/index.d.ts", 14 | "files": [ 15 | "tsconfig.json", 16 | "src/**", 17 | "dist/**", 18 | "../../NOTICE", 19 | "../../LICENSE-APACHE", 20 | "../../LICENSE-MIT" 21 | ], 22 | "scripts": { 23 | "build": "tsc", 24 | "prepack": "tsc", 25 | "test": "jest --maxWorkers=1" 26 | }, 27 | "peerDependencies": { 28 | "@cubist-labs/cubesigner-sdk": "^0.4.156-0", 29 | "ethers": "6.13.4" 30 | }, 31 | "directories": { 32 | "test": "test" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/ethers-v6/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../../tsconfig.local.json -------------------------------------------------------------------------------- /packages/fs-storage/README.md: -------------------------------------------------------------------------------- 1 | # Filesystem storage implementation for CubeSigner SDK 2 | 3 | This package provides a filesystem-backed implementation 4 | of the `ExclusiveSessionManager` interface from the CubeSigner SDK. 5 | 6 | For more information, check out the 7 | [@cubist-labs/cubesigner-sdk](https://www.npmjs.com/package/@cubist-labs/cubesigner-sdk) 8 | NPM package. -------------------------------------------------------------------------------- /packages/fs-storage/dist/file_storage.d.ts: -------------------------------------------------------------------------------- 1 | import type { SessionData } from "@cubist-labs/cubesigner-sdk"; 2 | import { ExclusiveSessionManager } from "@cubist-labs/cubesigner-sdk"; 3 | /** 4 | * A session manager that refreshes and stores data in a JSON file 5 | */ 6 | export declare class JsonFileSessionManager extends ExclusiveSessionManager { 7 | #private; 8 | /** 9 | * Store session information. 10 | * 11 | * @param data The session information to store 12 | */ 13 | store(data: SessionData): Promise; 14 | /** 15 | * Retrieve session information. 16 | * 17 | * @returns The session information 18 | */ 19 | retrieve(): Promise; 20 | /** 21 | * Constructor. 22 | * 23 | * @param filePath The file path to use for storage 24 | */ 25 | constructor(filePath: string); 26 | } 27 | //# sourceMappingURL=file_storage.d.ts.map -------------------------------------------------------------------------------- /packages/fs-storage/dist/file_storage.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"file_storage.d.ts","sourceRoot":"","sources":["../src/file_storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAGrE;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,uBAAuB;;IAEjE;;;;OAIG;IACG,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAItC;;;;OAIG;gBACS,QAAQ,EAAE,MAAM;CAI7B"} -------------------------------------------------------------------------------- /packages/fs-storage/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | import { JsonFileSessionManager } from "."; 2 | /** Session storage */ 3 | export { JsonFileSessionManager as JsonFileSessionManager } from "./file_storage"; 4 | /** Directory where CubeSigner stores config files. */ 5 | export declare const CONFIG_DIR: string; 6 | /** Default file path where the management session token is stored. */ 7 | export declare const MANAGEMENT_SESSION_PATH: string; 8 | /** Default file path where the signer session token is stored. */ 9 | export declare const SIGNER_SESSION_PATH: string; 10 | /** 11 | * @returns Manager pointing to the default management session file on disk. 12 | */ 13 | export declare function defaultManagementSessionManager(): JsonFileSessionManager; 14 | /** 15 | * @returns Manager pointing to the default signer session file on disk. 16 | */ 17 | export declare function defaultSignerSessionManager(): JsonFileSessionManager; 18 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/fs-storage/dist/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,GAAG,CAAC;AAE3C,sBAAsB;AACtB,OAAO,EAAE,sBAAsB,IAAI,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAelF,sDAAsD;AACtD,eAAO,MAAM,UAAU,QAAc,CAAC;AAEtC,sEAAsE;AACtE,eAAO,MAAM,uBAAuB,QAAmD,CAAC;AAExF,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,QAA+C,CAAC;AAEhF;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,sBAAsB,CAExE;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,sBAAsB,CAEpE"} -------------------------------------------------------------------------------- /packages/fs-storage/dist/org_event_processor.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"org_event_processor.d.ts","sourceRoot":"","sources":["../src/org_event_processor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQ9D,wCAAwC;AACxC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,4DAA4D;AAC5D,MAAM,WAAW,+BAAgC,SAAQ,UAAU;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,iDAAiD;AACjD,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,gCAAgC;AAChC,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,WAAW,CAAC;CAClB;AAED,kDAAkD;AAClD,qBAAa,iBAAiB;;IAK5B;;;;OAIG;gBACS,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAM7D;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,UAAU;IAqCtC;;;;;;OAMG;IACG,KAAK,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;CA6D7D"} -------------------------------------------------------------------------------- /packages/fs-storage/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: "ts-jest", 4 | testTimeout: 30000, 5 | testEnvironment: "node", 6 | testMatch: ["/test/*.test.[jt]s"], 7 | verbose: true, 8 | reporters: [ 9 | 'default', 10 | ['github-actions', {silent: false}], 11 | ["jest-summary-reporter", {"failuresOnly": false}] 12 | ] 13 | }; 14 | -------------------------------------------------------------------------------- /packages/fs-storage/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/cubesigner-sdk-fs-storage", 3 | "repository": { 4 | "type": "git", 5 | "url": "git+https://github.com/cubist-labs/CubeSigner-TypeScript-SDK.git", 6 | "directory": "packages/fs-storage" 7 | }, 8 | "version": "0.4.156-0", 9 | "description": "Filesystem storage implementation for CubeSigner SDK", 10 | "license": "MIT OR Apache-2.0", 11 | "author": "Cubist, Inc.", 12 | "main": "dist/index.js", 13 | "types": "dist/index.d.ts", 14 | "files": [ 15 | "tsconfig.json", 16 | "src/**", 17 | "dist/**", 18 | "../../NOTICE", 19 | "../../LICENSE-APACHE", 20 | "../../LICENSE-MIT" 21 | ], 22 | "scripts": { 23 | "build": "tsc", 24 | "prepack": "tsc", 25 | "test": "npx --node-options='--experimental-vm-modules' jest --maxWorkers=1" 26 | }, 27 | "peerDependencies": { 28 | "@cubist-labs/cubesigner-sdk": "^0.4.156-0" 29 | }, 30 | "devDependencies": { 31 | "@solana/web3.js": "^1.95.3", 32 | "@mysten/sui": "^1.21.1" 33 | }, 34 | "directories": { 35 | "test": "test" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/fs-storage/src/file_storage.ts: -------------------------------------------------------------------------------- 1 | import type { SessionData } from "@cubist-labs/cubesigner-sdk"; 2 | import { ExclusiveSessionManager } from "@cubist-labs/cubesigner-sdk"; 3 | import { promises as fs } from "fs"; 4 | 5 | /** 6 | * A session manager that refreshes and stores data in a JSON file 7 | */ 8 | export class JsonFileSessionManager extends ExclusiveSessionManager { 9 | readonly #filePath: string; 10 | /** 11 | * Store session information. 12 | * 13 | * @param data The session information to store 14 | */ 15 | async store(data: SessionData): Promise { 16 | await fs.writeFile(this.#filePath, JSON.stringify(data ?? null), "utf-8"); 17 | } 18 | 19 | /** 20 | * Retrieve session information. 21 | * 22 | * @returns The session information 23 | */ 24 | async retrieve(): Promise { 25 | return JSON.parse(await fs.readFile(this.#filePath, "utf-8")) ?? undefined; 26 | } 27 | 28 | /** 29 | * Constructor. 30 | * 31 | * @param filePath The file path to use for storage 32 | */ 33 | constructor(filePath: string) { 34 | super(); 35 | this.#filePath = filePath; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/fs-storage/src/index.ts: -------------------------------------------------------------------------------- 1 | import path from "path"; 2 | import { JsonFileSessionManager } from "."; 3 | 4 | /** Session storage */ 5 | export { JsonFileSessionManager as JsonFileSessionManager } from "./file_storage"; 6 | 7 | /** 8 | * Directory where CubeSigner stores config files. 9 | * 10 | * @returns Config dir 11 | */ 12 | function configDir(): string { 13 | const configDir = 14 | process.platform === "darwin" 15 | ? `${process.env.HOME}/Library/Application Support` 16 | : `${process.env.HOME}/.config`; 17 | return path.join(configDir, "cubesigner"); 18 | } 19 | 20 | /** Directory where CubeSigner stores config files. */ 21 | export const CONFIG_DIR = configDir(); 22 | 23 | /** Default file path where the management session token is stored. */ 24 | export const MANAGEMENT_SESSION_PATH = path.join(CONFIG_DIR, "management-session.json"); 25 | 26 | /** Default file path where the signer session token is stored. */ 27 | export const SIGNER_SESSION_PATH = path.join(CONFIG_DIR, "signer-session.json"); 28 | 29 | /** 30 | * @returns Manager pointing to the default management session file on disk. 31 | */ 32 | export function defaultManagementSessionManager(): JsonFileSessionManager { 33 | return new JsonFileSessionManager(MANAGEMENT_SESSION_PATH); 34 | } 35 | 36 | /** 37 | * @returns Manager pointing to the default signer session file on disk. 38 | */ 39 | export function defaultSignerSessionManager(): JsonFileSessionManager { 40 | return new JsonFileSessionManager(SIGNER_SESSION_PATH); 41 | } 42 | -------------------------------------------------------------------------------- /packages/fs-storage/test/fixtures/README.md: -------------------------------------------------------------------------------- 1 | # Ava Test Fixtures 2 | 3 | The transactions in [ava_tx.ts](./ava_tx.ts) were obtained by running the following unit tests 4 | from the [avalanche-types](https://github.com/ava-labs/avalanche-rs/tree/avalanche-types-v0.1.3/crates/avalanche-types) crate: 5 | 6 | ```bash 7 | cargo test --package avalanche-types --lib -- --exact --show-output \ 8 | platformvm::txs::add_permissionless_validator::test_add_permissionless_validator_tx_serialization_with_one_signer \ 9 | platformvm::txs::add_subnet_validator::test_add_subnet_validator_tx_serialization_with_one_signer \ 10 | platformvm::txs::add_validator::test_add_validator_tx_serialization_with_one_signer \ 11 | platformvm::txs::create_chain::test_create_chain_tx_serialization_with_one_signer \ 12 | platformvm::txs::create_subnet::test_create_subnet_tx_serialization_with_one_signer \ 13 | platformvm::txs::export::test_export_tx_serialization_with_one_signer \ 14 | platformvm::txs::import::test_import_tx_serialization_with_one_signer \ 15 | avm::txs::test_tx_serialization_with_two_signers \ 16 | avm::txs::export::test_export_tx_serialization_with_two_signers \ 17 | avm::txs::import::test_import_tx_serialization_with_two_signers 18 | ``` 19 | 20 | after updating each to serialize to Json and print out the transaction before signing it. 21 | 22 | # Wasm Policy Fixtures 23 | 24 | The `.wasm` policies were built from the [cubist-policy-sdk](https://github.com/cubist-labs/cubist-policy-sdk/tree/a045fac71093a1ae2b39609788a5279cf9a66919) examples, using the `--release` flag for the `wasm32-wasip2` target. 25 | 26 | ```bash 27 | cargo build --all --target wasm32-wasip2 --release 28 | ``` 29 | -------------------------------------------------------------------------------- /packages/fs-storage/test/fixtures/always_allow.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubist-labs/CubeSigner-TypeScript-SDK/5dd06d6e5ff461ba6ea27c783505370e8e471c59/packages/fs-storage/test/fixtures/always_allow.wasm -------------------------------------------------------------------------------- /packages/fs-storage/test/fixtures/postman_get.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubist-labs/CubeSigner-TypeScript-SDK/5dd06d6e5ff461ba6ea27c783505370e8e471c59/packages/fs-storage/test/fixtures/postman_get.wasm -------------------------------------------------------------------------------- /packages/fs-storage/test/fixtures/print_sign_request.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubist-labs/CubeSigner-TypeScript-SDK/5dd06d6e5ff461ba6ea27c783505370e8e471c59/packages/fs-storage/test/fixtures/print_sign_request.wasm -------------------------------------------------------------------------------- /packages/fs-storage/test/session_info.test.ts: -------------------------------------------------------------------------------- 1 | import type { CubeSignerClient, Org, Role } from "@cubist-labs/cubesigner-sdk"; 2 | import { refresh } from "@cubist-labs/cubesigner-sdk"; 3 | import { newCubeSigner } from "./setup"; 4 | import { expect, should } from "chai"; 5 | import { assertForbidden } from "./helpers"; 6 | 7 | describe("SignerSessionInfo", () => { 8 | let client: CubeSignerClient; 9 | let org: Org; 10 | let role: Role; 11 | let me: string; 12 | 13 | beforeAll(async () => { 14 | client = await newCubeSigner(); 15 | org = client.org(); 16 | me = (await client.user()).user_id; 17 | }); 18 | 19 | beforeEach(async () => { 20 | role = await org.createRole(); 21 | }); 22 | 23 | afterEach(async () => { 24 | // delete role 25 | await role.delete(); 26 | }); 27 | 28 | it("list, revoke", async () => { 29 | expect(await role.enabled()).to.equal(true); 30 | expect(role.name).to.equal(undefined); 31 | expect(await role.users()).to.deep.equal([me]); 32 | 33 | console.log("Creating sessions"); 34 | const s1 = await role.createSession("s1"); 35 | const s2 = await role.createSession("s2"); 36 | 37 | console.log("Listing role sessions"); 38 | const sessions = await role.sessions(); 39 | expect(sessions.length).to.equal(2); 40 | const si1 = sessions.find((t) => t.purpose === "s1"); 41 | const si2 = sessions.find((t) => t.purpose === "s2"); 42 | should().exist(si1, "Session 's1' not found"); 43 | should().exist(si2, "Session 's2' not found"); 44 | 45 | console.log("Revoking s1"); 46 | await si1?.revoke(); 47 | await assertForbidden(refresh(s1)); 48 | 49 | // revoking should continue work after refreshing 50 | console.log("Revoking s2"); 51 | await refresh(s2); 52 | await si2?.revoke(); 53 | await assertForbidden(refresh(s2)); 54 | 55 | // list should now return no sessions 56 | console.log("Listing role sessions again"); 57 | const sessions2 = await role.sessions(); 58 | expect(sessions2.length).to.equal(0); 59 | }); 60 | }); 61 | -------------------------------------------------------------------------------- /packages/fs-storage/test/setup.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from "fs"; 2 | import { CubeSignerClient } from "@cubist-labs/cubesigner-sdk"; 3 | import { expect } from "chai"; 4 | import * as path from "path"; 5 | import { CONFIG_DIR, defaultManagementSessionManager } from "../src"; 6 | 7 | /** 8 | * Create a new CubeSignerClient instance. 9 | * 10 | * @returns A new CubeSignerClient instance. 11 | */ 12 | export async function newCubeSigner(): Promise { 13 | return await CubeSignerClient.create(defaultManagementSessionManager()); 14 | } 15 | 16 | /** 17 | * Load the Cognito session's OIDC token from the default file on disk. 18 | * 19 | * @returns Cognito OIDC token. 20 | */ 21 | export async function loadCognitoOidcToken(): Promise { 22 | const defaultFilePath = path.join(CONFIG_DIR, "cognito-session.json"); 23 | const json = JSON.parse(await fs.readFile(defaultFilePath, "utf-8")); 24 | expect(json.id_token).to.exist; 25 | return json.id_token; 26 | } 27 | -------------------------------------------------------------------------------- /packages/fs-storage/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../../tsconfig.local.json -------------------------------------------------------------------------------- /packages/key-import/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /*.zip 3 | /dist 4 | *.d.ts 5 | *.js 6 | -------------------------------------------------------------------------------- /packages/key-import/dist/import.d.ts: -------------------------------------------------------------------------------- 1 | import type { Key, KeyType, Org, ImportDeriveKeyProperties } from "@cubist-labs/cubesigner-sdk"; 2 | import type { MnemonicToImport } from "./mnemonic"; 3 | /** 4 | * An import encryption key and the corresponding attestation document 5 | */ 6 | export declare class KeyImporter { 7 | #private; 8 | /** 9 | * Construct from a CubeSigner `Org` instance 10 | * 11 | * @param cs A CubeSigner `Org` instance 12 | */ 13 | constructor(cs: Org); 14 | /** 15 | * Encrypts a set of mnemonics and imports them. 16 | * 17 | * @param keyType The type of key to import 18 | * @param mnes The mnemonics to import, with optional derivation paths and passwords 19 | * @param props Additional options for import 20 | * @returns `Key` objects for each imported key. 21 | */ 22 | importMnemonics(keyType: KeyType, mnes: MnemonicToImport[], props?: ImportDeriveKeyProperties): Promise; 23 | /** 24 | * Encrypts a set of raw keys and imports them. 25 | * 26 | * @param keyType The type of key to import 27 | * @param secrets The secret keys to import. 28 | * @param props Additional options for import 29 | * @returns `Key` objects for each imported key. 30 | */ 31 | importRawSecretKeys(keyType: KeyType, secrets: Uint8Array[], props?: ImportDeriveKeyProperties): Promise; 32 | } 33 | //# sourceMappingURL=import.d.ts.map -------------------------------------------------------------------------------- /packages/key-import/dist/import.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../src/import.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,GAAG,EACH,OAAO,EACP,GAAG,EACH,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AAWpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA0LnD;;GAEG;AACH,qBAAa,WAAW;;IAOtB;;;;OAIG;gBACS,EAAE,EAAE,GAAG;IAoDnB;;;;;;;OAOG;IACU,eAAe,CAC1B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,gBAAgB,EAAE,EACxB,KAAK,CAAC,EAAE,yBAAyB,GAChC,OAAO,CAAC,GAAG,EAAE,CAAC;IAQjB;;;;;;;OAOG;IACU,mBAAmB,CAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,UAAU,EAAE,EACrB,KAAK,CAAC,EAAE,yBAAyB,GAChC,OAAO,CAAC,GAAG,EAAE,CAAC;CA+FlB"} -------------------------------------------------------------------------------- /packages/key-import/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export { KeyImporter } from "./import"; 2 | export { MnemonicToImport } from "./mnemonic"; 3 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/key-import/dist/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"} -------------------------------------------------------------------------------- /packages/key-import/dist/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.KeyImporter = void 0; 4 | var import_1 = require("./import"); 5 | Object.defineProperty(exports, "KeyImporter", { enumerable: true, get: function () { return import_1.KeyImporter; } }); 6 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsbUNBQXVDO0FBQTlCLHFHQUFBLFdBQVcsT0FBQSIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCB7IEtleUltcG9ydGVyIH0gZnJvbSBcIi4vaW1wb3J0XCI7XG5leHBvcnQgeyBNbmVtb25pY1RvSW1wb3J0IH0gZnJvbSBcIi4vbW5lbW9uaWNcIjtcbiJdfQ== -------------------------------------------------------------------------------- /packages/key-import/dist/mnemonic.d.ts: -------------------------------------------------------------------------------- 1 | export type MnemonicKeyPackage = { 2 | EnglishMnemonic: { 3 | mnemonic: { 4 | entropy: Uint8Array; 5 | }; 6 | der_path: { 7 | path: number[]; 8 | }; 9 | password: string; 10 | }; 11 | }; 12 | /** 13 | * A BIP39 mnemonic to be imported, plus optional BIP39 password 14 | * and BIP32 derivation path. 15 | */ 16 | export type MnemonicToImport = { 17 | mnemonic: string; 18 | derivationPath?: string; 19 | password?: string; 20 | }; 21 | /** 22 | * Create a new MnemonicKeyPackage value 23 | * 24 | * @param mne A BIP39 mnemonic and optional BIP39 password and BIP32 derivation path 25 | * @returns A serialized key package for import to CubeSigner 26 | */ 27 | export declare function newMnemonicKeyPackage(mne: MnemonicToImport): Uint8Array; 28 | /** 29 | * Parse a derivation path into a sequence of 32-bit integers 30 | * 31 | * @param derp The derivation path to parse; must start with 'm/' 32 | * @returns The parsed path 33 | */ 34 | export declare function parseDerivationPath(derp: string): number[]; 35 | //# sourceMappingURL=mnemonic.d.ts.map -------------------------------------------------------------------------------- /packages/key-import/dist/mnemonic.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"mnemonic.d.ts","sourceRoot":"","sources":["../src/mnemonic.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,EAAE;QACf,QAAQ,EAAE;YACR,OAAO,EAAE,UAAU,CAAC;SACrB,CAAC;QACF,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM,EAAE,CAAC;SAChB,CAAC;QACF,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU,CAgBvE;AAMD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CA6B1D"} -------------------------------------------------------------------------------- /packages/key-import/dist/raw.d.ts: -------------------------------------------------------------------------------- 1 | export type RawKeyPackage = { 2 | Secret: Uint8Array; 3 | }; 4 | /** 5 | * Create a new RawKeyPackage value 6 | * 7 | * @param secret The raw secret key to import 8 | * @returns A serialized key package for import to CubeSigner 9 | */ 10 | export declare function newRawKeyPackage(secret: Uint8Array): Uint8Array; 11 | //# sourceMappingURL=raw.d.ts.map -------------------------------------------------------------------------------- /packages/key-import/dist/raw.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"raw.d.ts","sourceRoot":"","sources":["../src/raw.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAK/D"} -------------------------------------------------------------------------------- /packages/key-import/dist/raw.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.newRawKeyPackage = newRawKeyPackage; 4 | const msgpackr_1 = require("msgpackr"); 5 | /** 6 | * Create a new RawKeyPackage value 7 | * 8 | * @param secret The raw secret key to import 9 | * @returns A serialized key package for import to CubeSigner 10 | */ 11 | function newRawKeyPackage(secret) { 12 | const rawPkg = { 13 | Secret: secret, 14 | }; 15 | return (0, msgpackr_1.encode)(rawPkg); 16 | } 17 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmF3LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3Jhdy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQWFBLDRDQUtDO0FBbEJELHVDQUE4QztBQU85Qzs7Ozs7R0FLRztBQUNILFNBQWdCLGdCQUFnQixDQUFDLE1BQWtCO0lBQ2pELE1BQU0sTUFBTSxHQUFrQjtRQUM1QixNQUFNLEVBQUUsTUFBTTtLQUNmLENBQUM7SUFDRixPQUFPLElBQUEsaUJBQVEsRUFBQyxNQUFNLENBQUMsQ0FBQztBQUMxQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgZW5jb2RlIGFzIG1wRW5jb2RlIH0gZnJvbSBcIm1zZ3BhY2tyXCI7XG5cbi8vIFRoZSBLZXlQYWNrYWdlIHR5cGUgZnJvbSBDdWJlU2lnbmVyIChyYXcgc2VjcmV0IHZhcmlhbnQpXG5leHBvcnQgdHlwZSBSYXdLZXlQYWNrYWdlID0ge1xuICBTZWNyZXQ6IFVpbnQ4QXJyYXk7XG59O1xuXG4vKipcbiAqIENyZWF0ZSBhIG5ldyBSYXdLZXlQYWNrYWdlIHZhbHVlXG4gKlxuICogQHBhcmFtIHNlY3JldCBUaGUgcmF3IHNlY3JldCBrZXkgdG8gaW1wb3J0XG4gKiBAcmV0dXJucyBBIHNlcmlhbGl6ZWQga2V5IHBhY2thZ2UgZm9yIGltcG9ydCB0byBDdWJlU2lnbmVyXG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBuZXdSYXdLZXlQYWNrYWdlKHNlY3JldDogVWludDhBcnJheSk6IFVpbnQ4QXJyYXkge1xuICBjb25zdCByYXdQa2c6IFJhd0tleVBhY2thZ2UgPSB7XG4gICAgU2VjcmV0OiBzZWNyZXQsXG4gIH07XG4gIHJldHVybiBtcEVuY29kZShyYXdQa2cpO1xufVxuIl19 -------------------------------------------------------------------------------- /packages/key-import/dist/util.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Converts a bigint to a big-endian Uint8Array of a specified length 3 | * 4 | * @param n The value to convert 5 | * @param l The length in bytes 6 | * @returns The big-endian bytes 7 | */ 8 | export declare function toBigEndian(n: bigint, l: number): Uint8Array; 9 | /** 10 | * Concatenates an array of Uint8Arrays into a single array 11 | * 12 | * @param parts The parts to be concatenated 13 | * @returns The concatenated array 14 | */ 15 | export declare function concatArrays(parts: Uint8Array[]): Uint8Array; 16 | /** 17 | * Get the current time in seconds since UNIX epoch 18 | * 19 | * @returns Seconds since UNIX epoch 20 | */ 21 | export declare function nowEpochMillis(): bigint; 22 | //# sourceMappingURL=util.d.ts.map -------------------------------------------------------------------------------- /packages/key-import/dist/util.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,CAW5D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,UAAU,CAW5D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC"} -------------------------------------------------------------------------------- /packages/key-import/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: "ts-jest", 4 | testTimeout: 90000, 5 | testEnvironment: "node", 6 | testMatch: ["/test/*.test.[jt]s"], 7 | reporters: [ 8 | "default", 9 | ["jest-summary-reporter", {"failuresOnly": false}] 10 | ] 11 | }; 12 | -------------------------------------------------------------------------------- /packages/key-import/lib/root.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICETCCAZagAwIBAgIRAPkxdWgbkK/hHUbMtOTn+FYwCgYIKoZIzj0EAwMwSTEL 3 | MAkGA1UEBhMCVVMxDzANBgNVBAoMBkFtYXpvbjEMMAoGA1UECwwDQVdTMRswGQYD 4 | VQQDDBJhd3Mubml0cm8tZW5jbGF2ZXMwHhcNMTkxMDI4MTMyODA1WhcNNDkxMDI4 5 | MTQyODA1WjBJMQswCQYDVQQGEwJVUzEPMA0GA1UECgwGQW1hem9uMQwwCgYDVQQL 6 | DANBV1MxGzAZBgNVBAMMEmF3cy5uaXRyby1lbmNsYXZlczB2MBAGByqGSM49AgEG 7 | BSuBBAAiA2IABPwCVOumCMHzaHDimtqQvkY4MpJzbolL//Zy2YlES1BR5TSksfbb 8 | 48C8WBoyt7F2Bw7eEtaaP+ohG2bnUs990d0JX28TcPQXCEPZ3BABIeTPYwEoCWZE 9 | h8l5YoQwTcU/9KNCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUkCW1DdkF 10 | R+eWw5b6cp3PmanfS5YwDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2kAMGYC 11 | MQCjfy+Rocm9Xue4YnwWmNJVA44fA0P5W2OpYow9OYCVRaEevL8uO1XYru5xtMPW 12 | rfMCMQCi85sWBbJwKKXdS6BptQFuZbT73o/gBh1qUxl/nNr12UO8Yfwr6wPLb+6N 13 | IwLz3/Y= 14 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /packages/key-import/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/cubesigner-sdk-key-import", 3 | "repository": { 4 | "type": "git", 5 | "url": "git+https://github.com/cubist-labs/CubeSigner-TypeScript-SDK.git", 6 | "directory": "packages/key-import" 7 | }, 8 | "version": "0.4.156-0", 9 | "description": "Client-side key-import machinery for CubeSigner", 10 | "license": "MIT OR Apache-2.0", 11 | "author": "Cubist, Inc.", 12 | "main": "dist/index.js", 13 | "types": "dist/index.d.ts", 14 | "files": [ 15 | "tsconfig.json", 16 | "src/**", 17 | "dist/**", 18 | "../../NOTICE", 19 | "../../LICENSE-APACHE", 20 | "../../LICENSE_MIT" 21 | ], 22 | "scripts": { 23 | "build": "tsc", 24 | "prepack": "tsc", 25 | "repl": "npx node --import tsx", 26 | "test": "npx --node-options='--experimental-vm-modules' jest --maxWorkers=1" 27 | }, 28 | "peerDependencies": { 29 | "@cubist-labs/cubesigner-sdk": "^0.4.156-0" 30 | }, 31 | "devDependencies": { 32 | "tsx": "^4.19.0" 33 | }, 34 | "dependencies": { 35 | "@auth0/cose": "^1.0.2", 36 | "@hpke/core": "^1.3.1", 37 | "@peculiar/asn1-ecc": "^2.3.13", 38 | "@peculiar/asn1-schema": "^2.3.13", 39 | "@peculiar/x509": "^1.12.1", 40 | "@scure/bip39": "^1.4.0", 41 | "cbor-x": "^1.6.0", 42 | "msgpackr": "^1.11.0" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/key-import/src/index.ts: -------------------------------------------------------------------------------- 1 | export { KeyImporter } from "./import"; 2 | export { MnemonicToImport } from "./mnemonic"; 3 | -------------------------------------------------------------------------------- /packages/key-import/src/raw.ts: -------------------------------------------------------------------------------- 1 | import { encode as mpEncode } from "msgpackr"; 2 | 3 | // The KeyPackage type from CubeSigner (raw secret variant) 4 | export type RawKeyPackage = { 5 | Secret: Uint8Array; 6 | }; 7 | 8 | /** 9 | * Create a new RawKeyPackage value 10 | * 11 | * @param secret The raw secret key to import 12 | * @returns A serialized key package for import to CubeSigner 13 | */ 14 | export function newRawKeyPackage(secret: Uint8Array): Uint8Array { 15 | const rawPkg: RawKeyPackage = { 16 | Secret: secret, 17 | }; 18 | return mpEncode(rawPkg); 19 | } 20 | -------------------------------------------------------------------------------- /packages/key-import/src/util.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Converts a bigint to a big-endian Uint8Array of a specified length 3 | * 4 | * @param n The value to convert 5 | * @param l The length in bytes 6 | * @returns The big-endian bytes 7 | */ 8 | export function toBigEndian(n: bigint, l: number): Uint8Array { 9 | if (n >= 1n << (8n * BigInt(l))) { 10 | throw new Error(`Cannot convert ${n} to ${l} big-endian bytes (overflow)`); 11 | } 12 | let nn = n; 13 | const ret = new Uint8Array(l); 14 | for (let i = l - 1; i >= 0; --i) { 15 | ret[i] = Number(nn % 256n); 16 | nn = nn >> 8n; 17 | } 18 | return ret; 19 | } 20 | 21 | /** 22 | * Concatenates an array of Uint8Arrays into a single array 23 | * 24 | * @param parts The parts to be concatenated 25 | * @returns The concatenated array 26 | */ 27 | export function concatArrays(parts: Uint8Array[]): Uint8Array { 28 | const totalLen = parts.reduce((len, part) => len + part.length, 0); 29 | 30 | let lenSoFar = 0; 31 | const ret = new Uint8Array(totalLen); 32 | parts.forEach((part) => { 33 | ret.set(part, lenSoFar); 34 | lenSoFar += part.length; 35 | }); 36 | 37 | return ret; 38 | } 39 | 40 | /** 41 | * Get the current time in seconds since UNIX epoch 42 | * 43 | * @returns Seconds since UNIX epoch 44 | */ 45 | export function nowEpochMillis(): bigint { 46 | return BigInt(Date.now()); 47 | } 48 | -------------------------------------------------------------------------------- /packages/key-import/test/derpath.test.ts: -------------------------------------------------------------------------------- 1 | import { parseDerivationPath } from "../src/mnemonic"; 2 | 3 | const BIP32_HARDEN = Number(BigInt(1) << BigInt(31)); 4 | 5 | describe("derpath", () => { 6 | it("errors on bad paths", async () => { 7 | const badPaths = ["//", "m/", "-", "h", "toast", "憂鬱", "0/1/2"]; 8 | for (const path of badPaths) { 9 | expect(() => { 10 | parseDerivationPath(path); 11 | }).toThrowError(); 12 | } 13 | }); 14 | 15 | it("parses derivation strings correctly", async () => { 16 | const goodPaths = [ 17 | ["m/32", [32]], 18 | ["m/32'", [32 + BIP32_HARDEN]], 19 | ["m/0'/32/5/5/5", [BIP32_HARDEN, 32, 5, 5, 5]], 20 | ["m/0/2147483647H/1/2147483646H/2", [0, 2 * BIP32_HARDEN - 1, 1, 2 * BIP32_HARDEN - 2, 2]], 21 | ["M/0H/1/2H/2/1000000000", [BIP32_HARDEN, 1, 2 + BIP32_HARDEN, 2, 1000000000]], 22 | ]; 23 | for (const kat of goodPaths) { 24 | const [path, expected] = kat; 25 | expect(parseDerivationPath(path as string)).toEqual(expected as number[]); 26 | } 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/key-import/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../../tsconfig.local.json -------------------------------------------------------------------------------- /packages/org-utils/README.md: -------------------------------------------------------------------------------- 1 | # Organization utilities for CubeSigner SDK 2 | 3 | This package provides org utilities for the CubeSigner SDK. 4 | 5 | Concretely, this package includes the following 6 | - utilities for verifying the authenticity of org events sent by the CubeSigner SNS 7 | 8 | For more information, check out the [@cubist-labs/cubesigner-sdk] NPM package. 9 | 10 | [@cubist-labs/cubesigner-sdk]: https://www.npmjs.com/package/@cubist-labs/cubesigner-sdk -------------------------------------------------------------------------------- /packages/org-utils/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | /** Utils for processing org events */ 2 | export * from "./org_event_processor"; 3 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/org-utils/dist/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,cAAc,uBAAuB,CAAC"} -------------------------------------------------------------------------------- /packages/org-utils/dist/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | /** Utils for processing org events */ 18 | __exportStar(require("./org_event_processor"), exports); 19 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLHNDQUFzQztBQUN0Qyx3REFBc0MiLCJzb3VyY2VzQ29udGVudCI6WyIvKiogVXRpbHMgZm9yIHByb2Nlc3Npbmcgb3JnIGV2ZW50cyAqL1xuZXhwb3J0ICogZnJvbSBcIi4vb3JnX2V2ZW50X3Byb2Nlc3NvclwiO1xuIl19 -------------------------------------------------------------------------------- /packages/org-utils/dist/org_event_processor.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"org_event_processor.d.ts","sourceRoot":"","sources":["../src/org_event_processor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQ5E,wCAAwC;AACxC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,4DAA4D;AAC5D,MAAM,WAAW,+BAAgC,SAAQ,UAAU;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,iDAAiD;AACjD,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,gCAAgC;AAChC,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,WAAW,GAAG,YAAY,CAAC;CACjC;AAED,kDAAkD;AAClD,qBAAa,iBAAiB;;IAK5B;;;;;OAKG;gBACS,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAW7D;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,UAAU;IAqCtC;;;;;;OAMG;IACG,KAAK,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;CA6D7D"} -------------------------------------------------------------------------------- /packages/org-utils/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: "ts-jest", 4 | testTimeout: 15000, 5 | testEnvironment: "node", 6 | testMatch: ["/test/*.test.[jt]s"], 7 | reporters: [ 8 | "default", 9 | ["jest-summary-reporter", {"failuresOnly": false}] 10 | ] 11 | }; 12 | -------------------------------------------------------------------------------- /packages/org-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/cubesigner-sdk-org-utils", 3 | "repository": { 4 | "type": "git", 5 | "url": "git+https://github.com/cubist-labs/CubeSigner-TypeScript-SDK.git", 6 | "directory": "packages/org-utils" 7 | }, 8 | "version": "0.4.156-0", 9 | "description": "Optional utilities for CubeSigner SDK", 10 | "license": "MIT OR Apache-2.0", 11 | "author": "Cubist, Inc.", 12 | "main": "dist/index.js", 13 | "types": "dist/index.d.ts", 14 | "files": [ 15 | "tsconfig.json", 16 | "src/**", 17 | "dist/**", 18 | "../../NOTICE", 19 | "../../LICENSE-APACHE", 20 | "../../LICENSE-MIT" 21 | ], 22 | "scripts": { 23 | "build": "tsc", 24 | "prepack": "tsc", 25 | "test": "jest --maxWorkers=1" 26 | }, 27 | "peerDependencies": { 28 | "@cubist-labs/cubesigner-sdk": "^0.4.156-0" 29 | }, 30 | "directories": { 31 | "test": "test" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/org-utils/src/index.ts: -------------------------------------------------------------------------------- 1 | /** Utils for processing org events */ 2 | export * from "./org_event_processor"; 3 | -------------------------------------------------------------------------------- /packages/org-utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../../tsconfig.local.json -------------------------------------------------------------------------------- /packages/sdk/dist/cjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/cubesigner-sdk", 3 | "version": "0.4.29-0", 4 | "description": "CubeSigner TypeScript SDK", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/cjs/src/index.js", 8 | "files": [ 9 | "tsconfig.json", 10 | "src/**", 11 | "dist/**", 12 | "../..NOTICE", 13 | "../..LICENSE-APACHE", 14 | "../..LICENSE-MIT" 15 | ], 16 | "exports": { 17 | "require": "./dist/cjs/src/index.js", 18 | "import": "./dist/esm/src/index.js" 19 | }, 20 | "scripts": { 21 | "build": "npm run build:cjs && npm run build:mjs", 22 | "prepack": "npm run build", 23 | "build:cjs": "tsc -p . --outDir dist/cjs --module commonjs --moduleResolution node", 24 | "build:mjs": "tsc -p . --outDir dist/esm --module es2022", 25 | "gen-schema": "openapi-typescript ./spec/openapi.json --output ./src/schema.ts", 26 | "test": "jest --maxWorkers=1", 27 | "typedoc": "typedoc" 28 | }, 29 | "dependencies": { 30 | "openapi-fetch": "0.8.2" 31 | }, 32 | "optionalDependencies": { 33 | "@hpke/core": "^1.2.7" 34 | }, 35 | "engines": { 36 | "node": ">=18.0.0" 37 | }, 38 | "directories": { 39 | "test": "test" 40 | }, 41 | "devDependencies": { 42 | "openapi-typescript-helpers": "^0.0.7" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/sdk/dist/cjs/spec/env/beta.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "ClientId": "405mhvv13llufju1ruvnq42rdc", 4 | "LongLivedClientId": "6he1bnm17s0dv8bb4hjim6fs6i", 5 | "Region": "us-east-1", 6 | "UserPoolId": "us-east-1_79ljlRRfX", 7 | "SignerApiRoot": "https://beta.signer.cubist.dev", 8 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:819335423237:Beta-CubeSignerStack-OrgEventsTopic4416298A-beobtbku2Wa8" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/sdk/dist/cjs/spec/env/gamma.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "ClientId": "1tiou9ecj058khiidmhj4ds4rj", 4 | "LongLivedClientId": "4jiuai7mtl5164of3drmvej234", 5 | "Region": "us-east-1", 6 | "UserPoolId": "us-east-1_RU7HEslOW", 7 | "SignerApiRoot": "https://gamma.signer.cubist.dev", 8 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:453904756570:Gamma-CubeSignerStack-OrgEventsTopic4416298A-MpV66OYPFQV0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/sdk/dist/cjs/spec/env/prod.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "ClientId": "2saesgbmeu8p981sk33sr6nq1j", 4 | "LongLivedClientId": "79qoe43lbiphd7jv0emqadtoia", 5 | "Region": "us-east-1", 6 | "UserPoolId": "us-east-1_lLLal8vGd", 7 | "SignerApiRoot": "https://prod.signer.cubist.dev", 8 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:120601948649:Production-0-us-east-1-CubeSignerStack-OrgEventsTopic4416298A-Zf6LzKIIDrvV" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/sdk/dist/cjs/src/env.d.ts: -------------------------------------------------------------------------------- 1 | export type Environment = 2 | /** Production environment */ 3 | "prod" 4 | /** Gamma, staging environment */ 5 | | "gamma" 6 | /** Beta, development environment */ 7 | | "beta"; 8 | export interface EnvInterface { 9 | ClientId: string; 10 | LongLivedClientId: string; 11 | Region: string; 12 | UserPoolId: string; 13 | SignerApiRoot: string; 14 | OrgEventsTopicArn: string; 15 | } 16 | export declare const envs: Record; 17 | -------------------------------------------------------------------------------- /packages/sdk/dist/cjs/src/events.d.ts: -------------------------------------------------------------------------------- 1 | /** Used to declare the type of an event emitter. See {@link EventEmitter} */ 2 | type EventMap = { 3 | [key: string]: (...args: never[]) => void; 4 | }; 5 | /** 6 | * Type-safe event emitter. 7 | * 8 | * Use it like this: 9 | * 10 | * ```typescript 11 | * type MyEvents = { 12 | * error: (error: Error) => void; 13 | * message: (from: string, content: string) => void; 14 | * } 15 | * 16 | * const myEmitter = new EventEmitter(); 17 | * 18 | * myEmitter.emit("error", "x") // <- Will catch this type error; 19 | * ``` 20 | */ 21 | export declare class EventEmitter { 22 | #private; 23 | /** 24 | * Add a listener for an event (the same listener cannot be registered twice) 25 | * 26 | * @param {string} event The event to listen to 27 | * @param {Function} listener The function to be invoked on that event 28 | * @return {EventEmitter} 29 | */ 30 | addEventListener(event: E, listener: Events[E]): this; 31 | /** 32 | * Remove a listener for an event 33 | * 34 | * @param {string} event The event to remove the listener from 35 | * @param {Function} listener The listener to be removed 36 | * @return {EventEmitter} 37 | */ 38 | removeEventListener(event: E, listener: Events[E]): this; 39 | /** 40 | * Emit an event, invoking all the listeners 41 | * 42 | * @param {string} event The event to invoke 43 | * @param {Function} listener The associated event data 44 | */ 45 | emit(event: E, ...args: Parameters): void; 46 | } 47 | export {}; 48 | -------------------------------------------------------------------------------- /packages/sdk/dist/cjs/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /** Errors */ 2 | export * from "./error"; 3 | /** API */ 4 | export * from "./client/api_client"; 5 | /** Client */ 6 | export * from "./client"; 7 | /** Callbacks */ 8 | export { ErrorEvent, SessionExpiredEvent } from "./client/base_client"; 9 | /** Organizations */ 10 | export * from "./org"; 11 | /** Keys */ 12 | export * from "./key"; 13 | /** Events */ 14 | export * from "./events"; 15 | /** Roles */ 16 | export * from "./role"; 17 | /** Env */ 18 | export * from "./env"; 19 | /** Fido */ 20 | export * from "./mfa"; 21 | /** Pagination */ 22 | export * from "./paginator"; 23 | /** Response */ 24 | export * from "./response"; 25 | /** Types */ 26 | export * from "./schema_types"; 27 | /** Sessions */ 28 | export * from "./signer_session"; 29 | /** Session storage */ 30 | export * from "./client/session"; 31 | /** Utils */ 32 | export * from "./util"; 33 | /** User-export decryption helper */ 34 | export { userExportDecrypt, userExportKeygen } from "./user_export"; 35 | /** Ethers.js helpers */ 36 | export * from "./evm"; 37 | /** CubeSigner SDK package name */ 38 | export declare const NAME: string; 39 | /** CubeSigner SDK version */ 40 | export declare const VERSION: string; 41 | -------------------------------------------------------------------------------- /packages/sdk/dist/cjs/src/org_event_processor.d.ts: -------------------------------------------------------------------------------- 1 | import { Environment } from "."; 2 | /** The common fields of SNS messages */ 3 | export interface SnsMessage { 4 | Type: string; 5 | MessageId: string; 6 | TopicArn: string; 7 | Message: string; 8 | Timestamp: string; 9 | SignatureVersion: string; 10 | Signature: string; 11 | SigningCertURL: string; 12 | } 13 | /** The format of a subscription confirmation sent by SNS */ 14 | export interface SubscriptionConfirmationMessage extends SnsMessage { 15 | Token: string; 16 | SubscribeURL: string; 17 | } 18 | /** Common fields for an org event */ 19 | export interface OrgEventBase { 20 | org: string; 21 | utc_timestamp: number; 22 | org_event: string; 23 | } 24 | /** The format of an event message sent by SNS */ 25 | export interface OrgEventMessage extends SnsMessage { 26 | Subject?: string; 27 | UnsubscribeURL: string; 28 | } 29 | /** Options for the processor */ 30 | export interface OrgEventProcessorOptions { 31 | env: Environment; 32 | } 33 | /** A utility for processing org event messages */ 34 | export declare class OrgEventProcessor { 35 | #private; 36 | /** 37 | * Constructor. 38 | * @param {string} orgId The org id 39 | * @param {OrgEventProcessorOptions} options Additional options for the processor 40 | */ 41 | constructor(orgId: string, options?: OrgEventProcessorOptions); 42 | /** 43 | * Checks an SNS message and its signature. Throws an error if the message 44 | * invalid or the signature is invalid. 45 | * 46 | * @param {SnsMessage} message The SNS message to check 47 | */ 48 | checkMessage(message: SnsMessage): Promise; 49 | /** 50 | * Parse an org event and check its signature. Throws an error if the 51 | * message is not a valid org event or the signature is invalid. 52 | * 53 | * @param {OrgEventMessage} message The org event message to check 54 | * @return {OrgEventBase} The org event 55 | */ 56 | parse(message: OrgEventMessage): Promise; 57 | } 58 | -------------------------------------------------------------------------------- /packages/sdk/dist/cjs/src/retry.d.ts: -------------------------------------------------------------------------------- 1 | /** Options to configure the behavior of the retry function */ 2 | export type RetryOptions = { 3 | /** Accepts the result of the fallible operation and returns whether or not to retry (true = retry) */ 4 | pred?: (val: T) => boolean; 5 | /** A sequence of millisecond delays to perform */ 6 | delays?: number[]; 7 | }; 8 | /** 9 | * Retry an async function 10 | * 11 | * @param {Function} f The function that may or namy not fail 12 | * @param {RetryOptions} opts specifying when, how long, and how many times to retry 13 | */ 14 | export declare function retry(f: () => Promise, { pred, delays }: RetryOptions): Promise; 15 | /** 16 | * A specialization of retry that retries on 5XX errors 17 | * 18 | * @param {Function} f The function that may return a failing response 19 | * @param {number[]} delays The sequence of delays (in milliseconds) between retries 20 | * @return {T} The result of the function 21 | */ 22 | export declare function retryOn5XX(f: () => Promise, delays?: number[]): Promise; 27 | /** 28 | * Generates a predicate that matches response status codes 29 | * @param {number[]} codes The response codes on which we want to retry 30 | * @return {Function} To be used as a predicate on retry 31 | **/ 32 | export declare const onErrorCodes: (codes?: number[]) => (r: { 33 | response: { 34 | status: number; 35 | }; 36 | }) => boolean; 37 | -------------------------------------------------------------------------------- /packages/sdk/dist/cjs/src/session/session_storage.d.ts: -------------------------------------------------------------------------------- 1 | /** Interface for storing sessions. */ 2 | export interface SessionStorage { 3 | /** Store session information */ 4 | save(data: U): Promise; 5 | /** Retrieve session information */ 6 | retrieve(): Promise; 7 | } 8 | /** Stores session information in memory */ 9 | export declare class MemorySessionStorage implements SessionStorage { 10 | #private; 11 | /** 12 | * Store session information. 13 | * @param {U} data The session information to store 14 | * @return {Promise} 15 | */ 16 | save(data: U): Promise; 17 | /** 18 | * Retrieve session information. 19 | * @return {Promise} The session information 20 | */ 21 | retrieve(): Promise; 22 | /** 23 | * Constructor. 24 | * @param {U?} data The initial data 25 | */ 26 | constructor(data?: U); 27 | } 28 | -------------------------------------------------------------------------------- /packages/sdk/dist/cjs/src/signer_session.d.ts: -------------------------------------------------------------------------------- 1 | import type { ApiClient } from "."; 2 | /** Signer session info. Can only be used to revoke a token, but not for authentication. */ 3 | export declare class SignerSessionInfo { 4 | #private; 5 | readonly purpose: string; 6 | /** Revoke this session */ 7 | revoke(): Promise; 8 | /** 9 | * Internal constructor. 10 | * @param {ApiClient} apiClient The API client to use. 11 | * @param {string} sessionId The ID of the session; can be used for revocation but not for auth 12 | * @param {string} purpose Session purpose 13 | * @internal 14 | */ 15 | constructor(apiClient: ApiClient, sessionId: string, purpose: string); 16 | } 17 | -------------------------------------------------------------------------------- /packages/sdk/dist/esm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/cubesigner-sdk", 3 | "version": "0.4.29-0", 4 | "description": "CubeSigner TypeScript SDK", 5 | "license": "MIT OR Apache-2.0", 6 | "author": "Cubist, Inc.", 7 | "main": "dist/cjs/src/index.js", 8 | "files": [ 9 | "tsconfig.json", 10 | "src/**", 11 | "dist/**", 12 | "../..NOTICE", 13 | "../..LICENSE-APACHE", 14 | "../..LICENSE-MIT" 15 | ], 16 | "exports": { 17 | "require": "./dist/cjs/src/index.js", 18 | "import": "./dist/esm/src/index.js" 19 | }, 20 | "scripts": { 21 | "build": "npm run build:cjs && npm run build:mjs", 22 | "prepack": "npm run build", 23 | "build:cjs": "tsc -p . --outDir dist/cjs --module commonjs --moduleResolution node", 24 | "build:mjs": "tsc -p . --outDir dist/esm --module es2022", 25 | "gen-schema": "openapi-typescript ./spec/openapi.json --output ./src/schema.ts", 26 | "test": "jest --maxWorkers=1", 27 | "typedoc": "typedoc" 28 | }, 29 | "dependencies": { 30 | "openapi-fetch": "0.8.2" 31 | }, 32 | "optionalDependencies": { 33 | "@hpke/core": "^1.2.7" 34 | }, 35 | "engines": { 36 | "node": ">=18.0.0" 37 | }, 38 | "directories": { 39 | "test": "test" 40 | }, 41 | "devDependencies": { 42 | "openapi-typescript-helpers": "^0.0.7" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/sdk/dist/esm/spec/env/beta.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "ClientId": "405mhvv13llufju1ruvnq42rdc", 4 | "LongLivedClientId": "6he1bnm17s0dv8bb4hjim6fs6i", 5 | "Region": "us-east-1", 6 | "UserPoolId": "us-east-1_79ljlRRfX", 7 | "SignerApiRoot": "https://beta.signer.cubist.dev", 8 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:819335423237:Beta-CubeSignerStack-OrgEventsTopic4416298A-beobtbku2Wa8" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/sdk/dist/esm/spec/env/gamma.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "ClientId": "1tiou9ecj058khiidmhj4ds4rj", 4 | "LongLivedClientId": "4jiuai7mtl5164of3drmvej234", 5 | "Region": "us-east-1", 6 | "UserPoolId": "us-east-1_RU7HEslOW", 7 | "SignerApiRoot": "https://gamma.signer.cubist.dev", 8 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:453904756570:Gamma-CubeSignerStack-OrgEventsTopic4416298A-MpV66OYPFQV0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/sdk/dist/esm/spec/env/prod.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "ClientId": "2saesgbmeu8p981sk33sr6nq1j", 4 | "LongLivedClientId": "79qoe43lbiphd7jv0emqadtoia", 5 | "Region": "us-east-1", 6 | "UserPoolId": "us-east-1_lLLal8vGd", 7 | "SignerApiRoot": "https://prod.signer.cubist.dev", 8 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:120601948649:Production-0-us-east-1-CubeSignerStack-OrgEventsTopic4416298A-Zf6LzKIIDrvV" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/sdk/dist/esm/src/env.d.ts: -------------------------------------------------------------------------------- 1 | export type Environment = 2 | /** Production environment */ 3 | "prod" 4 | /** Gamma, staging environment */ 5 | | "gamma" 6 | /** Beta, development environment */ 7 | | "beta"; 8 | export interface EnvInterface { 9 | ClientId: string; 10 | LongLivedClientId: string; 11 | Region: string; 12 | UserPoolId: string; 13 | SignerApiRoot: string; 14 | OrgEventsTopicArn: string; 15 | } 16 | export declare const envs: Record; 17 | -------------------------------------------------------------------------------- /packages/sdk/dist/esm/src/env.js: -------------------------------------------------------------------------------- 1 | import prodSpec from "../spec/env/prod.json"; 2 | import gammaSpec from "../spec/env/gamma.json"; 3 | import betaSpec from "../spec/env/beta.json"; 4 | export const envs = { 5 | prod: prodSpec["Dev-CubeSignerStack"], 6 | gamma: gammaSpec["Dev-CubeSignerStack"], 7 | beta: betaSpec["Dev-CubeSignerStack"], 8 | }; 9 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW52LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2Vudi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLFFBQVEsTUFBTSx1QkFBdUIsQ0FBQztBQUM3QyxPQUFPLFNBQVMsTUFBTSx3QkFBd0IsQ0FBQztBQUMvQyxPQUFPLFFBQVEsTUFBTSx1QkFBdUIsQ0FBQztBQW1CN0MsTUFBTSxDQUFDLE1BQU0sSUFBSSxHQUFzQztJQUNyRCxJQUFJLEVBQUUsUUFBUSxDQUFDLHFCQUFxQixDQUFDO0lBQ3JDLEtBQUssRUFBRSxTQUFTLENBQUMscUJBQXFCLENBQUM7SUFDdkMsSUFBSSxFQUFFLFFBQVEsQ0FBQyxxQkFBcUIsQ0FBQztDQUN0QyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHByb2RTcGVjIGZyb20gXCIuLi9zcGVjL2Vudi9wcm9kLmpzb25cIjtcbmltcG9ydCBnYW1tYVNwZWMgZnJvbSBcIi4uL3NwZWMvZW52L2dhbW1hLmpzb25cIjtcbmltcG9ydCBiZXRhU3BlYyBmcm9tIFwiLi4vc3BlYy9lbnYvYmV0YS5qc29uXCI7XG5cbmV4cG9ydCB0eXBlIEVudmlyb25tZW50ID1cbiAgLyoqIFByb2R1Y3Rpb24gZW52aXJvbm1lbnQgKi9cbiAgfCBcInByb2RcIlxuICAvKiogR2FtbWEsIHN0YWdpbmcgZW52aXJvbm1lbnQgKi9cbiAgfCBcImdhbW1hXCJcbiAgLyoqIEJldGEsIGRldmVsb3BtZW50IGVudmlyb25tZW50ICovXG4gIHwgXCJiZXRhXCI7XG5cbmV4cG9ydCBpbnRlcmZhY2UgRW52SW50ZXJmYWNlIHtcbiAgQ2xpZW50SWQ6IHN0cmluZztcbiAgTG9uZ0xpdmVkQ2xpZW50SWQ6IHN0cmluZztcbiAgUmVnaW9uOiBzdHJpbmc7XG4gIFVzZXJQb29sSWQ6IHN0cmluZztcbiAgU2lnbmVyQXBpUm9vdDogc3RyaW5nO1xuICBPcmdFdmVudHNUb3BpY0Fybjogc3RyaW5nO1xufVxuXG5leHBvcnQgY29uc3QgZW52czogUmVjb3JkPEVudmlyb25tZW50LCBFbnZJbnRlcmZhY2U+ID0ge1xuICBwcm9kOiBwcm9kU3BlY1tcIkRldi1DdWJlU2lnbmVyU3RhY2tcIl0sXG4gIGdhbW1hOiBnYW1tYVNwZWNbXCJEZXYtQ3ViZVNpZ25lclN0YWNrXCJdLFxuICBiZXRhOiBiZXRhU3BlY1tcIkRldi1DdWJlU2lnbmVyU3RhY2tcIl0sXG59O1xuIl19 -------------------------------------------------------------------------------- /packages/sdk/dist/esm/src/events.d.ts: -------------------------------------------------------------------------------- 1 | /** Used to declare the type of an event emitter. See {@link EventEmitter} */ 2 | type EventMap = { 3 | [key: string]: (...args: never[]) => void; 4 | }; 5 | /** 6 | * Type-safe event emitter. 7 | * 8 | * Use it like this: 9 | * 10 | * ```typescript 11 | * type MyEvents = { 12 | * error: (error: Error) => void; 13 | * message: (from: string, content: string) => void; 14 | * } 15 | * 16 | * const myEmitter = new EventEmitter(); 17 | * 18 | * myEmitter.emit("error", "x") // <- Will catch this type error; 19 | * ``` 20 | */ 21 | export declare class EventEmitter { 22 | #private; 23 | /** 24 | * Add a listener for an event (the same listener cannot be registered twice) 25 | * 26 | * @param {string} event The event to listen to 27 | * @param {Function} listener The function to be invoked on that event 28 | * @return {EventEmitter} 29 | */ 30 | addEventListener(event: E, listener: Events[E]): this; 31 | /** 32 | * Remove a listener for an event 33 | * 34 | * @param {string} event The event to remove the listener from 35 | * @param {Function} listener The listener to be removed 36 | * @return {EventEmitter} 37 | */ 38 | removeEventListener(event: E, listener: Events[E]): this; 39 | /** 40 | * Emit an event, invoking all the listeners 41 | * 42 | * @param {string} event The event to invoke 43 | * @param {Function} listener The associated event data 44 | */ 45 | emit(event: E, ...args: Parameters): void; 46 | } 47 | export {}; 48 | -------------------------------------------------------------------------------- /packages/sdk/dist/esm/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /** Errors */ 2 | export * from "./error"; 3 | /** API */ 4 | export * from "./client/api_client"; 5 | /** Client */ 6 | export * from "./client"; 7 | /** Callbacks */ 8 | export { ErrorEvent, SessionExpiredEvent } from "./client/base_client"; 9 | /** Organizations */ 10 | export * from "./org"; 11 | /** Keys */ 12 | export * from "./key"; 13 | /** Events */ 14 | export * from "./events"; 15 | /** Roles */ 16 | export * from "./role"; 17 | /** Env */ 18 | export * from "./env"; 19 | /** Fido */ 20 | export * from "./mfa"; 21 | /** Pagination */ 22 | export * from "./paginator"; 23 | /** Response */ 24 | export * from "./response"; 25 | /** Types */ 26 | export * from "./schema_types"; 27 | /** Sessions */ 28 | export * from "./signer_session"; 29 | /** Session storage */ 30 | export * from "./client/session"; 31 | /** Utils */ 32 | export * from "./util"; 33 | /** User-export decryption helper */ 34 | export { userExportDecrypt, userExportKeygen } from "./user_export"; 35 | /** Ethers.js helpers */ 36 | export * from "./evm"; 37 | /** CubeSigner SDK package name */ 38 | export declare const NAME: string; 39 | /** CubeSigner SDK version */ 40 | export declare const VERSION: string; 41 | -------------------------------------------------------------------------------- /packages/sdk/dist/esm/src/org_event_processor.d.ts: -------------------------------------------------------------------------------- 1 | import { Environment } from "."; 2 | /** The common fields of SNS messages */ 3 | export interface SnsMessage { 4 | Type: string; 5 | MessageId: string; 6 | TopicArn: string; 7 | Message: string; 8 | Timestamp: string; 9 | SignatureVersion: string; 10 | Signature: string; 11 | SigningCertURL: string; 12 | } 13 | /** The format of a subscription confirmation sent by SNS */ 14 | export interface SubscriptionConfirmationMessage extends SnsMessage { 15 | Token: string; 16 | SubscribeURL: string; 17 | } 18 | /** Common fields for an org event */ 19 | export interface OrgEventBase { 20 | org: string; 21 | utc_timestamp: number; 22 | org_event: string; 23 | } 24 | /** The format of an event message sent by SNS */ 25 | export interface OrgEventMessage extends SnsMessage { 26 | Subject?: string; 27 | UnsubscribeURL: string; 28 | } 29 | /** Options for the processor */ 30 | export interface OrgEventProcessorOptions { 31 | env: Environment; 32 | } 33 | /** A utility for processing org event messages */ 34 | export declare class OrgEventProcessor { 35 | #private; 36 | /** 37 | * Constructor. 38 | * @param {string} orgId The org id 39 | * @param {OrgEventProcessorOptions} options Additional options for the processor 40 | */ 41 | constructor(orgId: string, options?: OrgEventProcessorOptions); 42 | /** 43 | * Checks an SNS message and its signature. Throws an error if the message 44 | * invalid or the signature is invalid. 45 | * 46 | * @param {SnsMessage} message The SNS message to check 47 | */ 48 | checkMessage(message: SnsMessage): Promise; 49 | /** 50 | * Parse an org event and check its signature. Throws an error if the 51 | * message is not a valid org event or the signature is invalid. 52 | * 53 | * @param {OrgEventMessage} message The org event message to check 54 | * @return {OrgEventBase} The org event 55 | */ 56 | parse(message: OrgEventMessage): Promise; 57 | } 58 | -------------------------------------------------------------------------------- /packages/sdk/dist/esm/src/retry.d.ts: -------------------------------------------------------------------------------- 1 | /** Options to configure the behavior of the retry function */ 2 | export type RetryOptions = { 3 | /** Accepts the result of the fallible operation and returns whether or not to retry (true = retry) */ 4 | pred?: (val: T) => boolean; 5 | /** A sequence of millisecond delays to perform */ 6 | delays?: number[]; 7 | }; 8 | /** 9 | * Retry an async function 10 | * 11 | * @param {Function} f The function that may or namy not fail 12 | * @param {RetryOptions} opts specifying when, how long, and how many times to retry 13 | */ 14 | export declare function retry(f: () => Promise, { pred, delays }: RetryOptions): Promise; 15 | /** 16 | * A specialization of retry that retries on 5XX errors 17 | * 18 | * @param {Function} f The function that may return a failing response 19 | * @param {number[]} delays The sequence of delays (in milliseconds) between retries 20 | * @return {T} The result of the function 21 | */ 22 | export declare function retryOn5XX(f: () => Promise, delays?: number[]): Promise; 27 | /** 28 | * Generates a predicate that matches response status codes 29 | * @param {number[]} codes The response codes on which we want to retry 30 | * @return {Function} To be used as a predicate on retry 31 | **/ 32 | export declare const onErrorCodes: (codes?: number[]) => (r: { 33 | response: { 34 | status: number; 35 | }; 36 | }) => boolean; 37 | -------------------------------------------------------------------------------- /packages/sdk/dist/esm/src/session/session_storage.d.ts: -------------------------------------------------------------------------------- 1 | /** Interface for storing sessions. */ 2 | export interface SessionStorage { 3 | /** Store session information */ 4 | save(data: U): Promise; 5 | /** Retrieve session information */ 6 | retrieve(): Promise; 7 | } 8 | /** Stores session information in memory */ 9 | export declare class MemorySessionStorage implements SessionStorage { 10 | #private; 11 | /** 12 | * Store session information. 13 | * @param {U} data The session information to store 14 | * @return {Promise} 15 | */ 16 | save(data: U): Promise; 17 | /** 18 | * Retrieve session information. 19 | * @return {Promise} The session information 20 | */ 21 | retrieve(): Promise; 22 | /** 23 | * Constructor. 24 | * @param {U?} data The initial data 25 | */ 26 | constructor(data?: U); 27 | } 28 | -------------------------------------------------------------------------------- /packages/sdk/dist/esm/src/signer_session.d.ts: -------------------------------------------------------------------------------- 1 | import type { ApiClient } from "."; 2 | /** Signer session info. Can only be used to revoke a token, but not for authentication. */ 3 | export declare class SignerSessionInfo { 4 | #private; 5 | readonly purpose: string; 6 | /** Revoke this session */ 7 | revoke(): Promise; 8 | /** 9 | * Internal constructor. 10 | * @param {ApiClient} apiClient The API client to use. 11 | * @param {string} sessionId The ID of the session; can be used for revocation but not for auth 12 | * @param {string} purpose Session purpose 13 | * @internal 14 | */ 15 | constructor(apiClient: ApiClient, sessionId: string, purpose: string); 16 | } 17 | -------------------------------------------------------------------------------- /packages/sdk/dist/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/cubesigner-sdk", 3 | "repository": { 4 | "type": "git", 5 | "url": "git+https://github.com/cubist-labs/CubeSigner-TypeScript-SDK.git", 6 | "directory": "packages/sdk" 7 | }, 8 | "version": "0.4.156-0", 9 | "description": "CubeSigner TypeScript SDK", 10 | "license": "MIT OR Apache-2.0", 11 | "author": "Cubist, Inc.", 12 | "main": "dist/src/index.js", 13 | "files": [ 14 | "tsconfig.json", 15 | "src/**", 16 | "dist/**", 17 | "../../NOTICE", 18 | "../../LICENSE-APACHE", 19 | "../../LICENSE-MIT" 20 | ], 21 | "scripts": { 22 | "build": "tsc", 23 | "prepack": "npm run build", 24 | "gen-schema": "openapi-typescript ./spec/openapi.json --output ./src/schema.ts", 25 | "test": "jest --maxWorkers=1", 26 | "typedoc": "typedoc" 27 | }, 28 | "dependencies": { 29 | "openapi-fetch": "0.8.2" 30 | }, 31 | "optionalDependencies": { 32 | "@hpke/core": "^1.2.7" 33 | }, 34 | "engines": { 35 | "node": ">=18.0.0" 36 | }, 37 | "directories": { 38 | "test": "test" 39 | }, 40 | "devDependencies": { 41 | "openapi-typescript-helpers": "^0.0.7", 42 | "typescript": "^5.5" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/sdk/dist/spec/env/beta.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "SignerApiRoot": "https://beta.signer.cubist.dev", 4 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:819335423237:Beta-CubeSignerStack-OrgEventsTopic4416298A-beobtbku2Wa8" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/sdk/dist/spec/env/gamma.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "SignerApiRoot": "https://gamma.signer.cubist.dev", 4 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:453904756570:Gamma-CubeSignerStack-OrgEventsTopic4416298A-MpV66OYPFQV0" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/sdk/dist/spec/env/prod.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "SignerApiRoot": "https://prod.signer.cubist.dev", 4 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:120601948649:Production-0-us-east-1-CubeSignerStack-OrgEventsTopic4416298A-Zf6LzKIIDrvV" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/sdk/dist/src/client.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIrF,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,KAAK,EACL,WAAW,EACX,cAAc,EACf,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;AAExB,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,+BAA+B;IAC/B,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,8BAA8B;IAC9B,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,gBAAgB;;IAG3B;;OAEG;IACH,IAAI,SAAS,cAEZ;IAED;;OAEG;IACH,IAAI,GAAG,iBAEN;IAED;;OAEG;IACH,IAAI,KAAK,WAER;IAED;;;;OAIG;gBACS,SAAS,EAAE,SAAS;IAIhC;;;;;;;;;OASG;WACU,MAAM,CACjB,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,WAAW,EAC9C,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,gBAAgB,CAAC;IAI5B;;;;OAIG;IACH,GAAG,IAAI,GAAG;IAIV;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG;IAI1B;;;;;;OAMG;IACH,IAAI,IAAI,qDAEP;IAED;;;;;;OAMG;IACG,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAMnC;;;;;;;;;;;OAWG;WACU,iBAAiB,CAC5B,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,EACpB,SAAS,CAAC,EAAE,aAAa,EACzB,UAAU,CAAC,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAY3C;;;;;;;OAOG;WACU,iBAAiB,CAC5B,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,CAAC;IAIzB;;;;;;;;;;;OAWG;WACU,gBAAgB,CAC3B,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,CAAC;IAI5B;;;;;;;;;;OAUG;IACH,IAAI,OAAO,sJAEV;IAED;;;;;;;;OAQG;IACH,IAAI,UAAU,8GAEb;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAI/C;;;;;;;OAOG;IACH,IAAI,SAAS,8FAEZ;IAED;;;;;;;OAOG;IACH,IAAI,UAAU,oCAEb;IAED;;;;;;;;OAQG;IACH,IAAI,UAAU,8FAEb;IAED;;;;;;OAMG;IACH,IAAI,gBAAgB;;;;uBAEnB;IAED;;;;;;OAMG;IACH,IAAI,mBAAmB;;;;uBAEtB;IAED;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrC"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/contact.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"contact.d.ts","sourceRoot":"","sources":["../../src/contact.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAwB,MAAM,GAAG,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,GAAG,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,qBAAa,OAAO;;IAIlB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,MAAM,EAAE,WAAW,CAAC;IAEpB,qDAAqD;IACrD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAK7B;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM;IAI1B;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC;IAKtC;;;;OAIG;IACG,YAAY,CAAC,SAAS,EAAE,UAAU;IAIxC;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAK9B;;;;OAIG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM;IAI5B;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,SAAS,CAAC;IAKpC;;;;OAIG;IACG,WAAW,CAAC,QAAQ,EAAE,SAAS;IAIrC;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAKnD;;;;;OAKG;IACG,aAAa,CAAC,UAAU,EAAE,UAAU;IAI1C;;OAEG;IACG,MAAM;IAQZ;;;;;OAKG;gBACS,MAAM,EAAE,SAAS,GAAG,gBAAgB,EAAE,IAAI,EAAE,WAAW;IAMnE;;;;;OAKG;YACW,KAAK;IAKnB;;;;;;OAMG;YACW,MAAM;CAIrB"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/env.d.ts: -------------------------------------------------------------------------------- 1 | export type Environment = 2 | /** Production environment */ 3 | "prod" 4 | /** Gamma, staging environment */ 5 | | "gamma" 6 | /** Beta, development environment */ 7 | | "beta"; 8 | export interface EnvInterface { 9 | SignerApiRoot: string; 10 | OrgEventsTopicArn: string; 11 | } 12 | export declare const envs: Record; 13 | //# sourceMappingURL=env.d.ts.map -------------------------------------------------------------------------------- /packages/sdk/dist/src/env.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW;AACrB,6BAA6B;AAC3B,MAAM;AACR,iCAAiC;GAC/B,OAAO;AACT,oCAAoC;GAClC,MAAM,CAAC;AAEX,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,YAAY,CAIlD,CAAC"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/env.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.envs = void 0; 7 | const prod_json_1 = __importDefault(require("../spec/env/prod.json")); 8 | const gamma_json_1 = __importDefault(require("../spec/env/gamma.json")); 9 | const beta_json_1 = __importDefault(require("../spec/env/beta.json")); 10 | exports.envs = { 11 | prod: prod_json_1.default["Dev-CubeSignerStack"], 12 | gamma: gamma_json_1.default["Dev-CubeSignerStack"], 13 | beta: beta_json_1.default["Dev-CubeSignerStack"], 14 | }; 15 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW52LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2Vudi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSxzRUFBNkM7QUFDN0Msd0VBQStDO0FBQy9DLHNFQUE2QztBQWVoQyxRQUFBLElBQUksR0FBc0M7SUFDckQsSUFBSSxFQUFFLG1CQUFRLENBQUMscUJBQXFCLENBQUM7SUFDckMsS0FBSyxFQUFFLG9CQUFTLENBQUMscUJBQXFCLENBQUM7SUFDdkMsSUFBSSxFQUFFLG1CQUFRLENBQUMscUJBQXFCLENBQUM7Q0FDdEMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBwcm9kU3BlYyBmcm9tIFwiLi4vc3BlYy9lbnYvcHJvZC5qc29uXCI7XG5pbXBvcnQgZ2FtbWFTcGVjIGZyb20gXCIuLi9zcGVjL2Vudi9nYW1tYS5qc29uXCI7XG5pbXBvcnQgYmV0YVNwZWMgZnJvbSBcIi4uL3NwZWMvZW52L2JldGEuanNvblwiO1xuXG5leHBvcnQgdHlwZSBFbnZpcm9ubWVudCA9XG4gIC8qKiBQcm9kdWN0aW9uIGVudmlyb25tZW50ICovXG4gIHwgXCJwcm9kXCJcbiAgLyoqIEdhbW1hLCBzdGFnaW5nIGVudmlyb25tZW50ICovXG4gIHwgXCJnYW1tYVwiXG4gIC8qKiBCZXRhLCBkZXZlbG9wbWVudCBlbnZpcm9ubWVudCAqL1xuICB8IFwiYmV0YVwiO1xuXG5leHBvcnQgaW50ZXJmYWNlIEVudkludGVyZmFjZSB7XG4gIFNpZ25lckFwaVJvb3Q6IHN0cmluZztcbiAgT3JnRXZlbnRzVG9waWNBcm46IHN0cmluZztcbn1cblxuZXhwb3J0IGNvbnN0IGVudnM6IFJlY29yZDxFbnZpcm9ubWVudCwgRW52SW50ZXJmYWNlPiA9IHtcbiAgcHJvZDogcHJvZFNwZWNbXCJEZXYtQ3ViZVNpZ25lclN0YWNrXCJdLFxuICBnYW1tYTogZ2FtbWFTcGVjW1wiRGV2LUN1YmVTaWduZXJTdGFja1wiXSxcbiAgYmV0YTogYmV0YVNwZWNbXCJEZXYtQ3ViZVNpZ25lclN0YWNrXCJdLFxufTtcbiJdfQ== -------------------------------------------------------------------------------- /packages/sdk/dist/src/error.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AA4B3C;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,yCAAyC;IACzC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,UAAU,CAAC;IACtC,yDAAyD;IACzD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,uBAAuB;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,wBAAwB;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,4BAA4B;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,iBAAiB;IACjB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;gBACS,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC;IAKtC;;;;;;;;;OASG;IACH,qBAAqB,IAAI,OAAO;IAMhC;;;;;;;;;;OAUG;IACH,cAAc,IAAI,OAAO;CAO1B;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD;;;;OAIG;gBACS,SAAS,CAAC,EAAE,MAAM,UAAU;CASzC"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/events.d.ts: -------------------------------------------------------------------------------- 1 | /** Used to declare the type of an event emitter. See {@link EventEmitter} */ 2 | export type EventMap = { 3 | [key: string]: (...args: never[]) => void; 4 | }; 5 | /** 6 | * Type-safe event emitter. 7 | * 8 | * Use it like this: 9 | * 10 | * ```typescript 11 | * type MyEvents = { 12 | * error: (error: Error) => void; 13 | * message: (from: string, content: string) => void; 14 | * } 15 | * 16 | * const myEmitter = new EventEmitter(); 17 | * 18 | * myEmitter.emit("error", "x") // <- Will catch this type error; 19 | * ``` 20 | */ 21 | export declare class EventEmitter { 22 | #private; 23 | /** 24 | * Add a listener for an event (the same listener cannot be registered twice) 25 | * 26 | * @param event The event to listen to 27 | * @param listener The function to be invoked on that event 28 | * @returns This EventEmitter with the new event listener 29 | */ 30 | addEventListener(event: E, listener: Events[E]): this; 31 | /** 32 | * Remove a listener for an event 33 | * 34 | * @param event The event to remove the listener from 35 | * @param listener The listener to be removed 36 | * @returns This EventEmitter with the event listener removed 37 | */ 38 | removeEventListener(event: E, listener: Events[E]): this; 39 | /** 40 | * Emit an event, invoking all the listeners 41 | * 42 | * @param event The event to invoke 43 | * @param args The associated event data 44 | */ 45 | emit(event: E, ...args: Parameters): void; 46 | } 47 | //# sourceMappingURL=events.d.ts.map -------------------------------------------------------------------------------- /packages/sdk/dist/src/events.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,MAAM,QAAQ,GAAG;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;CAC3C,CAAC;AAOF;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY,CAAC,MAAM,SAAS,QAAQ;;IAc/C;;;;;;OAMG;IACH,gBAAgB,CAAC,CAAC,SAAS,MAAM,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;IAKtF;;;;;;OAMG;IACH,mBAAmB,CAAC,CAAC,SAAS,MAAM,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;IAKzF;;;;;OAKG;IACH,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;CAKtF"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/evm/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/evm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,GAAG,EACH,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EAEhB,MAAM,UAAU,CAAC;AAElB,6BAA6B;AAC7B,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,qBAAa,SAAS;;IAapB,iDAAiD;IACjD,IAAI,OAAO,WAEV;IAED,qCAAqC;IACrC,IAAI,MAAM,qBAET;IAED,mDAAmD;IACnD,IAAI,OAAO,qBAEV;IAED;;;;;;OAMG;gBACS,OAAO,EAAE,GAAG,GAAG,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,gBAAgB;IAcvF;;;;;OAKG;IACG,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAM3D;;;;;;;OAOG;IACG,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IAKhF;;;;;;;OAOG;IACG,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAOzD;;;;;;;OAOG;IACG,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAOzD,qDAAqD;IAC/C,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IAWzB;;;;;;OAMG;IACG,0BAA0B,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;CAyC1E"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/fetch.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,aAAa,EAKnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,UAAU,CAAC;AAI/D,KAAK,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAClF,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,UAAU,CAAC,CAAC;AAGrD,KAAK,KAAK,GAAG;KACV,CAAC,IAAI,MAAM,SAAS,GAAG;SACrB,CAAC,IAAI,UAAU,IAAI,CAAC,SAAS,MAAM,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,SAAS,MAAM,SAAS,CAAC,CAAC,CAAC,GACvF,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,GAC/B,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACf,KAAK,GACP,KAAK;KACV;CACF,CAAC;AAGF,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAOrE;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAAC,CAAC,SAAS,MAAM,KAAK,EAAE,CAAC,SAAS,MAAM,KAAK,CAAC,CAAC,CAAC,EAC5E,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACvC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CA6FrC;AAED,+FAA+F;AAC/F,MAAM,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAEzE;;;;;;;GAOG;AACH,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,KAAK,EAAE,CAAC,SAAS,MAAM,KAAK,CAAC,CAAC,CAAC,EAChE,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,CAAC,GACR,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAEjB;AAED;;;GAGG;AACH,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAc/E"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /** Errors */ 2 | export * from "./error"; 3 | /** API */ 4 | export * from "./client/api_client"; 5 | /** Client */ 6 | export * from "./client"; 7 | /** Callbacks */ 8 | export { ErrorEvent, SessionExpiredEvent } from "./client/base_client"; 9 | /** Organizations */ 10 | export * from "./org"; 11 | /** Keys */ 12 | export * from "./key"; 13 | /** Events */ 14 | export * from "./events"; 15 | /** Roles */ 16 | export * from "./role"; 17 | /** Env */ 18 | export * from "./env"; 19 | /** Fido */ 20 | export * from "./mfa"; 21 | /** Pagination */ 22 | export * from "./paginator"; 23 | /** Response */ 24 | export * from "./response"; 25 | /** Types */ 26 | export * from "./schema_types"; 27 | /** Sessions */ 28 | export * from "./signer_session"; 29 | /** Session storage */ 30 | export * from "./client/session"; 31 | /** Contacts */ 32 | export * from "./contact"; 33 | /** Policies */ 34 | export * from "./policy"; 35 | /** Utils */ 36 | export * from "./util"; 37 | /** User-export decryption helper */ 38 | export { loadCrypto, loadSubtleCrypto, userExportDecrypt, userExportKeygen } from "./user_export"; 39 | /** Ethers.js helpers */ 40 | export * from "./evm"; 41 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/sdk/dist/src/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,SAAS,CAAC;AACxB,UAAU;AACV,cAAc,qBAAqB,CAAC;AACpC,aAAa;AACb,cAAc,UAAU,CAAC;AACzB,gBAAgB;AAChB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACvE,oBAAoB;AACpB,cAAc,OAAO,CAAC;AACtB,WAAW;AACX,cAAc,OAAO,CAAC;AACtB,aAAa;AACb,cAAc,UAAU,CAAC;AACzB,YAAY;AACZ,cAAc,QAAQ,CAAC;AACvB,UAAU;AACV,cAAc,OAAO,CAAC;AACtB,WAAW;AACX,cAAc,OAAO,CAAC;AACtB,iBAAiB;AACjB,cAAc,aAAa,CAAC;AAC5B,eAAe;AACf,cAAc,YAAY,CAAC;AAC3B,YAAY;AACZ,cAAc,gBAAgB,CAAC;AAC/B,eAAe;AACf,cAAc,kBAAkB,CAAC;AACjC,sBAAsB;AACtB,cAAc,kBAAkB,CAAC;AACjC,eAAe;AACf,cAAc,WAAW,CAAC;AAC1B,eAAe;AACf,cAAc,UAAU,CAAC;AACzB,YAAY;AACZ,cAAc,QAAQ,CAAC;AACvB,oCAAoC;AACpC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAClG,wBAAwB;AACxB,cAAc,OAAO,CAAC"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/paginator.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"paginator.d.ts","sourceRoot":"","sources":["../../src/paginator.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,MAAM,WAAW,QAAQ;IACvB,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,GAAG,EAAE,OAAO,CAAC;CACd;AAED,sCAAsC;AACtC,qBAAa,IAAI;IACf;;;;;OAKG;IACH,MAAM,CAAC,OAAO,IAAI,QAAQ;CAK3B;AAED,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AACrE,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAC/D,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,SAAS,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AAEjE;;;;;GAKG;AACH,qBAAa,SAAS,CAAC,CAAC,EAAE,CAAC;;IAQzB;;;;;OAKG;gBAED,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IAU5B;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EACf,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,EACzB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAChB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAQpB;;;OAGG;IACH,MAAM,IAAI,OAAO;IAIjB;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC;IAIzB;;;;;OAKG;IACG,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC;IAK7B;;;;;;OAMG;IACG,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC;IAa7B;;;;;OAKG;IACG,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC;CAS7B"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/passkey.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"passkey.d.ts","sourceRoot":"","sources":["../../src/passkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,OAAO,EACZ,KAAK,WAAW,EACjB,MAAM,GAAG,CAAC;AAwBX;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,CAAC,mCAAmC,CAAC,GACpD,iCAAiC,CASnC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,CAAC,oCAAoC,CAAC,GACrD,kCAAkC,CAWpC;AA2BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAyB1F;AAED;;GAEG;AACH,qBAAa,qBAAqB;;IAe9B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAb7C,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC;IAC5D,QAAQ,CAAC,OAAO,EAAE,iCAAiC,CAAC;IAEpD;;;;;;OAMG;gBAED,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,sBAAsB,EACxB,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAO7C;;;;;OAKG;IACG,sBAAsB,IAAI,OAAO,CAAC,WAAW,CAAC;IAMpD;;;;;;;;;;;OAWG;IACG,MAAM,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;CAM9D"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/response.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,YAAY,EAAE,WAAW,EAAe,MAAM,GAAG,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAqB,MAAM,GAAG,CAAC;AAExD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAEtC;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAMpF;AAED;;GAEG;AACH,qBAAa,kBAAkB,CAAC,CAAC;;IAS/B,sEAAsE;IACtE,KAAK,IAAI,MAAM,GAAG,SAAS;IAI3B,iEAAiE;IACjE,MAAM,IAAI,MAAM,EAAE;IAIlB,6DAA6D;IAC7D,WAAW,IAAI,OAAO;IAItB;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAkBxD,wDAAwD;IACxD,IAAI,IAAI,CAAC;IAOT;;;;;;OAMG;IACG,WAAW,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAIzF;;;;;OAKG;IACG,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM;IAiCvD;;;;;OAKG;IACG,OAAO,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAIvE;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,gBAAgB;IA6BrC;;;;;OAKG;IACG,mBAAmB,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IASlF;;;;;;;;;OASG;IACH,SAAS,aAAa,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,gBAAgB;IAO5F;;;;;;;;;;OAUG;WACU,MAAM,CAAC,CAAC,EACnB,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EACvB,UAAU,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAKjC;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS;CA2BxE"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/retry.d.ts: -------------------------------------------------------------------------------- 1 | /** Options to configure the behavior of the retry function */ 2 | export type RetryOptions = { 3 | /** Accepts the result of the fallible operation and returns whether or not to retry (true = retry) */ 4 | pred?: (val: T) => Promise; 5 | /** A sequence of millisecond delays to perform */ 6 | delays?: number[]; 7 | }; 8 | /** 9 | * Retry an async function 10 | * 11 | * @param f The function that may or may not fail 12 | * @param opts specifying when, how long, and how many times to retry 13 | * @param opts.pred Takes result of fallible operation and returns whether or not to retry, defaults to always retrying 14 | * @param opts.delays Sequence of millisecond delays to perform, defaulting to 100, 200, 400 15 | * @returns A resolved async function 16 | */ 17 | export declare function retry(f: () => Promise, { pred, delays }: RetryOptions): Promise; 18 | /** 19 | * A specialization of retry that retries on 5XX errors 20 | * 21 | * @param f The function that may return a failing response 22 | * @param delays The sequence of delays (in milliseconds) between retries 23 | * @returns The result of the function 24 | */ 25 | export declare function retryOn5XX(f: () => Promise, delays?: number[]): Promise; 30 | /** 31 | * Generates a predicate that matches response status codes 32 | * 33 | * @param codes The response codes on which we want to retry 34 | * @returns To be used as a predicate on retry 35 | */ 36 | export declare const onErrorCodes: (codes?: number[]) => (r: { 37 | response: { 38 | status: number; 39 | }; 40 | }) => Promise; 41 | //# sourceMappingURL=retry.d.ts.map -------------------------------------------------------------------------------- /packages/sdk/dist/src/retry.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/retry.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,sGAAsG;IACtG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAOF;;;;;;;;GAQG;AACH,wBAAsB,KAAK,CAAC,CAAC,EAC3B,CAAC,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACnB,EAAE,IAAa,EAAE,MAAwB,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC,GAC3D,OAAO,CAAC,CAAC,CAAC,CAUZ;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,CAAC,SAAS;IAAE,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACzE,CAAC,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACnB,MAAM,CAAC,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,WACf,MAAM,EAAE,SACN;IAAE,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,qBACP,CAAC"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/session/session_storage.d.ts: -------------------------------------------------------------------------------- 1 | /** Interface for storing sessions. */ 2 | export interface SessionStorage { 3 | /** Store session information */ 4 | save(data: U): Promise; 5 | /** Retrieve session information */ 6 | retrieve(): Promise; 7 | } 8 | /** Stores session information in memory */ 9 | export declare class MemorySessionStorage implements SessionStorage { 10 | #private; 11 | /** 12 | * Store session information. 13 | * @param {U} data The session information to store 14 | * @return {Promise} 15 | */ 16 | save(data: U): Promise; 17 | /** 18 | * Retrieve session information. 19 | * @return {Promise} The session information 20 | */ 21 | retrieve(): Promise; 22 | /** 23 | * Constructor. 24 | * @param {U?} data The initial data 25 | */ 26 | constructor(data?: U); 27 | } 28 | /** Stores session information in a JSON file */ 29 | export declare class JsonFileSessionStorage implements SessionStorage { 30 | #private; 31 | /** 32 | * Store session information. 33 | * @param {U} data The session information to store 34 | * @return {Promise} 35 | */ 36 | save(data: U): Promise; 37 | /** 38 | * Retrieve session information. 39 | * @return {Promise} The session information 40 | */ 41 | retrieve(): Promise; 42 | /** 43 | * Constructor. 44 | * @param {string} filePath The file path to use for storage 45 | */ 46 | constructor(filePath: string); 47 | } 48 | -------------------------------------------------------------------------------- /packages/sdk/dist/src/signer_session.d.ts: -------------------------------------------------------------------------------- 1 | import type { ApiClient } from "."; 2 | /** Signer session info. Can only be used to revoke a token, but not for authentication. */ 3 | export declare class SignerSessionInfo { 4 | #private; 5 | readonly purpose: string; 6 | /** Revoke this session */ 7 | revoke(): Promise; 8 | /** 9 | * Internal constructor. 10 | * 11 | * @param apiClient The API client to use. 12 | * @param sessionId The ID of the session; can be used for revocation but not for auth 13 | * @param purpose Session purpose 14 | * @internal 15 | */ 16 | constructor(apiClient: ApiClient, sessionId: string, purpose: string); 17 | } 18 | //# sourceMappingURL=signer_session.d.ts.map -------------------------------------------------------------------------------- /packages/sdk/dist/src/signer_session.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"signer_session.d.ts","sourceRoot":"","sources":["../../src/signer_session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;AAEnC,2FAA2F;AAC3F,qBAAa,iBAAiB;;IAG5B,SAAgB,OAAO,EAAE,MAAM,CAAC;IAEhC,0BAA0B;IACpB,MAAM;IAQZ;;;;;;;OAOG;gBACS,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAKrE"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/user_export.d.ts: -------------------------------------------------------------------------------- 1 | import type { UserExportCompleteResponse, UserExportKeyMaterial } from "./schema_types"; 2 | import type { CipherSuite } from "@hpke/core"; 3 | /** 4 | * Get the HPKE ciphersuite for user-export decryption. 5 | * 6 | * @returns The HPKE ciphersuite for user export. 7 | */ 8 | export declare function userExportCipherSuite(): Promise; 9 | /** 10 | * Generate a key pair for user export. 11 | * 12 | * @returns The newly generated key pair. 13 | */ 14 | export declare function userExportKeygen(): Promise; 15 | /** 16 | * Decrypt a user export. 17 | * 18 | * @param recipientKey The NIST P-256 secret key corresponding to the `publicKey` argument to the `userExportComplete` invocation that returned `response`. 19 | * @param response The response from a successful `userExportComplete` request. 20 | * @returns The decrypted key material. 21 | */ 22 | export declare function userExportDecrypt(recipientKey: CryptoKey, response: UserExportCompleteResponse): Promise; 23 | /** 24 | * Figure out how to load SubtleCrypto in the current environment. 25 | * 26 | * @returns A SubtleCrypto instance 27 | */ 28 | export declare function loadSubtleCrypto(): Promise; 29 | /** 30 | * Figure out how to load Crypto in the current environment. 31 | * 32 | * @returns A Crypto instance 33 | */ 34 | export declare function loadCrypto(): Promise; 35 | //# sourceMappingURL=user_export.d.ts.map -------------------------------------------------------------------------------- /packages/sdk/dist/src/user_export.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user_export.d.ts","sourceRoot":"","sources":["../../src/user_export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAExF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,WAAW,CAAC,CAQlE;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,CAE/D;AAYD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,SAAS,EACvB,QAAQ,EAAE,0BAA0B,GACnC,OAAO,CAAC,qBAAqB,CAAC,CAwBhC;AA+BD;;;;GAIG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC,CAO9D;AAED;;;;GAIG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAYlD"} -------------------------------------------------------------------------------- /packages/sdk/dist/src/util.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,MAAM,WAAW,OAAO;IACtB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC;CAC1E;AAED,sBAAsB;AACtB,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;AAEtF,qBAAqB;AACrB,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC;AAE/E,iCAAiC;AACjC,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAIpD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAI1D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,WAAW,GAAG,MAAM,CAO7E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,WAAW,GAAG,MAAM,CAIhF;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAGhE"} -------------------------------------------------------------------------------- /packages/sdk/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: 'ts-jest', 4 | testTimeout: 15000, 5 | testEnvironment: 'node', 6 | testMatch: ["/test/*.test.[jt]s"], 7 | reporters: [ 8 | "default", 9 | ["jest-summary-reporter", {"failuresOnly": false}] 10 | ] 11 | }; 12 | -------------------------------------------------------------------------------- /packages/sdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/cubesigner-sdk", 3 | "repository": { 4 | "type": "git", 5 | "url": "git+https://github.com/cubist-labs/CubeSigner-TypeScript-SDK.git", 6 | "directory": "packages/sdk" 7 | }, 8 | "version": "0.4.156-0", 9 | "description": "CubeSigner TypeScript SDK", 10 | "license": "MIT OR Apache-2.0", 11 | "author": "Cubist, Inc.", 12 | "main": "dist/src/index.js", 13 | "files": [ 14 | "tsconfig.json", 15 | "src/**", 16 | "dist/**", 17 | "../../NOTICE", 18 | "../../LICENSE-APACHE", 19 | "../../LICENSE-MIT" 20 | ], 21 | "scripts": { 22 | "build": "tsc", 23 | "prepack": "npm run build", 24 | "gen-schema": "openapi-typescript ./spec/openapi.json --output ./src/schema.ts", 25 | "test": "jest --maxWorkers=1", 26 | "typedoc": "typedoc" 27 | }, 28 | "dependencies": { 29 | "openapi-fetch": "0.8.2" 30 | }, 31 | "optionalDependencies": { 32 | "@hpke/core": "^1.2.7" 33 | }, 34 | "engines": { 35 | "node": ">=18.0.0" 36 | }, 37 | "directories": { 38 | "test": "test" 39 | }, 40 | "devDependencies": { 41 | "openapi-typescript-helpers": "^0.0.7", 42 | "typescript": "^5.5" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/sdk/spec/env/beta.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "SignerApiRoot": "https://beta.signer.cubist.dev", 4 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:819335423237:Beta-CubeSignerStack-OrgEventsTopic4416298A-beobtbku2Wa8" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/sdk/spec/env/gamma.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "SignerApiRoot": "https://gamma.signer.cubist.dev", 4 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:453904756570:Gamma-CubeSignerStack-OrgEventsTopic4416298A-MpV66OYPFQV0" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/sdk/spec/env/prod.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dev-CubeSignerStack": { 3 | "SignerApiRoot": "https://prod.signer.cubist.dev", 4 | "OrgEventsTopicArn": "arn:aws:sns:us-east-1:120601948649:Production-0-us-east-1-CubeSignerStack-OrgEventsTopic4416298A-Zf6LzKIIDrvV" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/sdk/src/env.ts: -------------------------------------------------------------------------------- 1 | import prodSpec from "../spec/env/prod.json"; 2 | import gammaSpec from "../spec/env/gamma.json"; 3 | import betaSpec from "../spec/env/beta.json"; 4 | 5 | export type Environment = 6 | /** Production environment */ 7 | | "prod" 8 | /** Gamma, staging environment */ 9 | | "gamma" 10 | /** Beta, development environment */ 11 | | "beta"; 12 | 13 | export interface EnvInterface { 14 | SignerApiRoot: string; 15 | OrgEventsTopicArn: string; 16 | } 17 | 18 | export const envs: Record = { 19 | prod: prodSpec["Dev-CubeSignerStack"], 20 | gamma: gammaSpec["Dev-CubeSignerStack"], 21 | beta: betaSpec["Dev-CubeSignerStack"], 22 | }; 23 | -------------------------------------------------------------------------------- /packages/sdk/src/index.ts: -------------------------------------------------------------------------------- 1 | /** Errors */ 2 | export * from "./error"; 3 | /** API */ 4 | export * from "./client/api_client"; 5 | /** Client */ 6 | export * from "./client"; 7 | /** Callbacks */ 8 | export { ErrorEvent, SessionExpiredEvent } from "./client/base_client"; 9 | /** Organizations */ 10 | export * from "./org"; 11 | /** Keys */ 12 | export * from "./key"; 13 | /** Events */ 14 | export * from "./events"; 15 | /** Roles */ 16 | export * from "./role"; 17 | /** Env */ 18 | export * from "./env"; 19 | /** Fido */ 20 | export * from "./mfa"; 21 | /** Pagination */ 22 | export * from "./paginator"; 23 | /** Response */ 24 | export * from "./response"; 25 | /** Types */ 26 | export * from "./schema_types"; 27 | /** Sessions */ 28 | export * from "./signer_session"; 29 | /** Session storage */ 30 | export * from "./client/session"; 31 | /** Contacts */ 32 | export * from "./contact"; 33 | /** Policies */ 34 | export * from "./policy"; 35 | /** Utils */ 36 | export * from "./util"; 37 | /** User-export decryption helper */ 38 | export { loadCrypto, loadSubtleCrypto, userExportDecrypt, userExportKeygen } from "./user_export"; 39 | /** Ethers.js helpers */ 40 | export * from "./evm"; 41 | -------------------------------------------------------------------------------- /packages/sdk/src/signer_session.ts: -------------------------------------------------------------------------------- 1 | import type { ApiClient } from "."; 2 | 3 | /** Signer session info. Can only be used to revoke a token, but not for authentication. */ 4 | export class SignerSessionInfo { 5 | readonly #apiClient: ApiClient; 6 | readonly #sessionId: string; 7 | public readonly purpose: string; 8 | 9 | /** Revoke this session */ 10 | async revoke() { 11 | await this.#apiClient.sessionRevoke(this.#sessionId); 12 | } 13 | 14 | // -------------------------------------------------------------------------- 15 | // -- INTERNAL -------------------------------------------------------------- 16 | // -------------------------------------------------------------------------- 17 | 18 | /** 19 | * Internal constructor. 20 | * 21 | * @param apiClient The API client to use. 22 | * @param sessionId The ID of the session; can be used for revocation but not for auth 23 | * @param purpose Session purpose 24 | * @internal 25 | */ 26 | constructor(apiClient: ApiClient, sessionId: string, purpose: string) { 27 | this.#apiClient = apiClient; 28 | this.#sessionId = sessionId; 29 | this.purpose = purpose; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/sdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | ../../tsconfig.local.json -------------------------------------------------------------------------------- /packages/secretsmanager-storage/README.md: -------------------------------------------------------------------------------- 1 | # CubeSigner SDK session manager backed by AWS Secrets Manager 2 | 3 | This package provides an AWS Secrets Manager-backed implementation of the 4 | `SessionManager` interface from the CubeSigner SDK. 5 | 6 | For more information, check out the 7 | [@cubist-labs/cubesigner-sdk](https://www.npmjs.com/package/@cubist-labs/cubesigner-sdk) 8 | NPM package. 9 | -------------------------------------------------------------------------------- /packages/secretsmanager-storage/dist/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAClG,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,cAAc,EAEnB,KAAK,eAAe,EAIrB,MAAM,4BAA4B,CAAC;AAEpC,6DAA6D;AAC7D,UAAU,2BAA4B,SAAQ,0BAA0B;IACtE;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,uBAAwB,YAAW,cAAc;;IAkB5D;;;;;OAKG;gBACS,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAOhE,kBAAkB;IACZ,cAAc;IAIpB,kBAAkB;IACZ,QAAQ,IAAI,OAAO,CAAC,eAAe,CAAC;IAK1C,kBAAkB;IACZ,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;CAsC/B;AAED,qEAAqE;AACrE,qBAAa,gBAAgB;;IAM3B;;;;OAIG;IACG,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjD;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B;;;;OAIG;gBACS,QAAQ,EAAE,MAAM;CAI7B"} -------------------------------------------------------------------------------- /packages/secretsmanager-storage/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: "ts-jest", 4 | testTimeout: 30000, 5 | testEnvironment: "node", 6 | testMatch: ["/test/*.test.[jt]s"], 7 | verbose: true, 8 | reporters: [ 9 | 'default', 10 | ['github-actions', {silent: false}], 11 | ["jest-summary-reporter", {"failuresOnly": false}] 12 | ] 13 | }; 14 | -------------------------------------------------------------------------------- /packages/secretsmanager-storage/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cubist-labs/cubesigner-sdk-secretsmanager-storage", 3 | "repository": { 4 | "type": "git", 5 | "url": "git+https://github.com/cubist-labs/CubeSigner-TypeScript-SDK.git", 6 | "directory": "packages/secretsmanager-storage" 7 | }, 8 | "version": "0.4.156-0", 9 | "description": "CubeSigner SDK session manager backed by AWS Secrets Manager", 10 | "license": "MIT OR Apache-2.0", 11 | "author": "Cubist, Inc.", 12 | "main": "dist/index.js", 13 | "types": "dist/index.d.ts", 14 | "files": [ 15 | "tsconfig.json", 16 | "src/**", 17 | "dist/**", 18 | "../../NOTICE", 19 | "../../LICENSE-APACHE", 20 | "../../LICENSE-MIT" 21 | ], 22 | "scripts": { 23 | "build": "tsc", 24 | "prepack": "tsc", 25 | "test": "npx --node-options='--experimental-vm-modules' jest --maxWorkers=1" 26 | }, 27 | "peerDependencies": { 28 | "@cubist-labs/cubesigner-sdk": "^0.4.156-0" 29 | }, 30 | "directories": { 31 | "test": "test" 32 | }, 33 | "dependencies": { 34 | "@aws-sdk/client-secrets-manager": "^3.682.0" 35 | }, 36 | "devDependencies": { 37 | "aws-sdk-client-mock": "^4.1.0" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/secretsmanager-storage/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "typedocOptions": { 7 | "out": "./docs", 8 | "entryPoints": ["src/index.ts"] 9 | }, 10 | "exclude": ["spec", "node_modules", "dist"], 11 | "include": ["src/**/*.ts"] 12 | } 13 | -------------------------------------------------------------------------------- /scripts/gen_readme_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -EeuoT pipefail 4 | 5 | SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 6 | 7 | README_FILE="${SCRIPT_DIR}/../README.md" 8 | INDEX_TS="${SCRIPT_DIR}/readme_test_template/src/index.ts" 9 | 10 | mkdir -p "$( dirname "${INDEX_TS}" )" 11 | cat "${README_FILE}" | sed 's/^```typescript$/```typescript\n/g' | sed -n '/```typescript$/,/```/{//!p}' > "${INDEX_TS}".tmp 12 | 13 | # add imports first, then the rest between 'export const run = async () => {}' and '};' 14 | 15 | ( 16 | cat "${INDEX_TS}".tmp | grep "^import " 17 | echo 18 | echo "export const run = async () => {" 19 | cat "${INDEX_TS}".tmp | grep -v "^import " 20 | echo 21 | echo "};" 22 | ) > "${INDEX_TS}" 23 | 24 | rm "${INDEX_TS}".tmp 25 | -------------------------------------------------------------------------------- /scripts/readme_test_template/.gitignore: -------------------------------------------------------------------------------- 1 | package-lock.json 2 | dist 3 | node_modules 4 | src/index.ts -------------------------------------------------------------------------------- /scripts/readme_test_template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "readme-test", 3 | "version": "0.0.1", 4 | "description": "", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "prebuild": "npm install", 8 | "build": "tsc", 9 | "prestart": "npm run build", 10 | "start": "ts-node -e 'require(\"./src/index\").run()'" 11 | }, 12 | "dependencies": { 13 | "@cubist-labs/cubesigner-sdk": "../../packages/sdk", 14 | "@cubist-labs/cubesigner-sdk-fs-storage": "../../packages/fs-storage", 15 | "@cubist-labs/cubesigner-sdk-ethers-v6": "../../packages/ethers-v6", 16 | "dotenv": "^16.3.1", 17 | "otplib": "^12.0.1" 18 | }, 19 | "devDependencies": { 20 | "@types/node": "^20.5.1", 21 | "ts-node": "^10.9.1", 22 | "typescript": "^4.8" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /scripts/readme_test_template/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "outDir": "dist", 5 | "module": "commonjs", 6 | "declaration": true, 7 | "esModuleInterop": true, 8 | "sourceMap": true, 9 | "strictPropertyInitialization": true, 10 | "strict": true, 11 | "noImplicitAny": true, 12 | "strictNullChecks": true, 13 | "noImplicitThis": true, 14 | "alwaysStrict": true, 15 | "noUnusedParameters": true, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": false, 18 | "forceConsistentCasingInFileNames": true 19 | }, 20 | "include": ["src/**/*"], 21 | "exclude": ["node_modules", "dist"] 22 | } 23 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2021", 4 | "moduleResolution": "Node16", 5 | "module": "Node16", 6 | "declaration": true, 7 | "declarationMap": true, 8 | "strict": true, 9 | "noImplicitAny": true, 10 | "noImplicitThis": true, 11 | "alwaysStrict": true, 12 | "noUnusedLocals": true, 13 | "noUnusedParameters": true, 14 | "noImplicitReturns": true, 15 | "noFallthroughCasesInSwitch": false, 16 | "inlineSourceMap": true, 17 | "inlineSources": true, 18 | "experimentalDecorators": true, 19 | "strictPropertyInitialization": true, 20 | "resolveJsonModule": true, 21 | "esModuleInterop": true, 22 | "skipLibCheck": true 23 | }, 24 | "typedocOptions": { 25 | "excludeInternal": true, 26 | "excludePrivate": true, 27 | "excludeProtected": true 28 | }, 29 | "exclude": ["**/*.d.ts"] 30 | } 31 | -------------------------------------------------------------------------------- /tsconfig.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist" 5 | }, 6 | "typedocOptions": { 7 | "out": "./docs", 8 | "entryPoints": ["src/index.ts"] 9 | }, 10 | "exclude": ["spec", "node_modules", "dist"], 11 | "include": ["src/**/*.ts"] 12 | } 13 | --------------------------------------------------------------------------------