31 lines
650 B
JavaScript
31 lines
650 B
JavaScript
/**
|
|
* Server MAC key derived from SERVER_SEED for capabilities + admin proofs.
|
|
*/
|
|
import { deriveMacKey } from '../../shared/crypto-auth.js'
|
|
|
|
let macKey = null
|
|
let serverPublicKeyHex = null
|
|
let seedHex = null
|
|
|
|
/**
|
|
* @param {{ seedHex: string, publicKeyHex: string }} opts
|
|
*/
|
|
export function initAuthKeys(opts) {
|
|
seedHex = opts.seedHex
|
|
serverPublicKeyHex = opts.publicKeyHex
|
|
macKey = deriveMacKey(seedHex)
|
|
}
|
|
|
|
export function getMacKey() {
|
|
if (!macKey) throw new Error('Auth keys not initialized')
|
|
return macKey
|
|
}
|
|
|
|
export function getServerPublicKeyHex() {
|
|
return serverPublicKeyHex
|
|
}
|
|
|
|
export function getSeedHex() {
|
|
return seedHex
|
|
}
|