New Project

This commit is contained in:
Matthew Aaron Raymer
2023-01-04 17:05:08 +08:00
parent 6325bcbe35
commit f021fcdb1c
3 changed files with 32 additions and 9 deletions

View File

@@ -100,3 +100,14 @@ export const accessToken = async (identifier: IIdentifier) => {
});
return jwt;
};
export const sign = async (privateKeyHex: string) => {
const input = privateKeyHex.startsWith("0x")
? privateKeyHex.substring(2)
: privateKeyHex;
const privateKeyBytes = u8a.fromString(input.toLowerCase(), "base16");
const signer = didJwt.ES256KSigner(privateKeyBytes, true);
return signer;
};