UNPKG

@julesl23/s5js

Version:

Enhanced TypeScript SDK for S5 decentralized storage with path-based API, media processing, and directory utilities

13 lines 654 B
const CHALLENGE_SIZE = 32; export const CHALLENGE_TYPE_REGISTER = 1; export const CHALLENGE_TYPE_LOGIN = 2; export async function signChallenge(keyPair, challenge, challengeType, portalHost, crypto) { if (challenge.length != CHALLENGE_SIZE) { throw 'Invalid challenge: wrong length'; } const portalHostHash = await crypto.hashBlake3(new TextEncoder().encode(portalHost)); const message = new Uint8Array([challengeType, ...challenge, ...portalHostHash]); const signatureBytes = await crypto.signEd25519(keyPair, message); return { response: message, signature: signatureBytes }; } //# sourceMappingURL=sign_challenge.js.map