How to use the @arcblock/did.toTypeInfo function in @arcblock/did

To help you get started, we’ve selected a few @arcblock/did examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArcBlock / forge-js / did / did-auth / lib / jwt.js View on Github external
const sign = (signer, sk, payload = {}, doSign = true) => {
  if (isValid(signer) === false) {
    throw new Error('Cannot do sign with invalid signer');
  }

  const type = toTypeInfo(signer);
  const headers = {
    [types.KeyType.SECP256K1]: {
      alg: 'ES256K',
      type: 'JWT',
    },
    [types.KeyType.ED25519]: {
      alg: 'Ed25519',
      type: 'JWT',
    },
  };

  // make header
  const header = headers[type.pk];
  const headerB64 = toBase64(stringify(header));

  // make body
github ArcBlock / forge-js / forge / forge-wallet / lib / index.js View on Github external
function fromAddress(address) {
  return Wallet({ address: toAddress(address) }, WalletType(toTypeInfo(address)));
}