await promises in place

This commit is contained in:
2024-09-10 00:32:25 +02:00
parent 9de49c228d
commit 7e858b3556
9 changed files with 31 additions and 38 deletions
+7 -7
View File
@@ -12,9 +12,9 @@ export default class PrivateWrap {
private readonly pubkey: CryptoKey
) {}
public static gen(extractable: boolean = true): Promise<CryptoKeyPair> {
public static async gen(extractable: boolean = true): Promise<CryptoKeyPair> {
log.trace('generate keypair')
return crypto.subtle.generateKey(consts.ECDH, extractable, ['deriveKey']) as Promise<CryptoKeyPair>
return await crypto.subtle.generateKey(consts.ECDH, extractable, ['deriveKey']) as CryptoKeyPair
}
public static async wrap(data: CryptoKey, pubkey: CryptoKey): Promise<PrivateWrap> {
@@ -27,7 +27,7 @@ export default class PrivateWrap {
public async unwrap(privkey: CryptoKey): Promise<CryptoKey | null> {
log.trace('unwrap')
const kd = await ecdh(privkey, this.pubkey, DHusage.wrap)
return this.box.unwrap(kd)
return await this.box.unwrap(kd)
}
public async toString(): Promise<string> {
@@ -50,10 +50,10 @@ export default class PrivateWrap {
return new PrivateWrap(box, pubkey)
}
public static pubkey_toString(pubkey: CryptoKey): Promise<string> {
return misc.pubkey_toString(pubkey)
public static async pubkey_toString(pubkey: CryptoKey): Promise<string> {
return await misc.pubkey_toString(pubkey)
}
public static pubkey_fromString(pubkey: string): Promise<CryptoKey | null> {
return misc.pubkey_fromString(pubkey, misc.Usage.ecdh)
public static async pubkey_fromString(pubkey: string): Promise<CryptoKey | null> {
return await misc.pubkey_fromString(pubkey, misc.Usage.ecdh)
}
}