create-auth-request-signature.ts 842 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env ts-node
  2. import { getAlicePair } from '../src/services/runtime/accounts'
  3. import { cryptoWaitReady } from '@polkadot/util-crypto'
  4. import { UploadTokenRequestBody, signTokenBody, UploadTokenRequest } from '../src/services/helpers/auth'
  5. import { exit } from 'process'
  6. // Wasm init
  7. cryptoWaitReady()
  8. .then(() => {
  9. const alice = getAlicePair()
  10. const tokenRequestBody: UploadTokenRequestBody = {
  11. memberId: 0,
  12. accountId: alice.address,
  13. dataObjectId: parseInt(process.env.OBJECT_ID || '0'),
  14. storageBucketId: 0,
  15. bagId: 'static:council',
  16. }
  17. const signature = signTokenBody(tokenRequestBody, alice)
  18. const tokenRequest: UploadTokenRequest = {
  19. data: tokenRequestBody,
  20. signature,
  21. }
  22. console.log(JSON.stringify(tokenRequest))
  23. exit(0)
  24. })
  25. .catch(console.error)