Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
function fromAddress(address) {
return Wallet({ address: toAddress(address) }, WalletType(toTypeInfo(address)));
}