@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
37 lines (36 loc) • 1.62 kB
JavaScript
import { PublicJwk } from "../../../modules/kms/jwk/PublicJwk.mjs";
import "../../../modules/kms/index.mjs";
import { CredoWebCryptoKey } from "../CredoWebCryptoKey.mjs";
import * as core from "webcrypto-core";
//#region src/crypto/webcrypto/providers/CredoRsaSsaProvider.ts
var CredoRsaSsaProvider = class extends core.RsaSsaProvider {
constructor(walletWebCrypto) {
super();
this.walletWebCrypto = walletWebCrypto;
}
async onSign(algorithm, key, data) {
return new Uint8Array(await this.walletWebCrypto.sign(key, new Uint8Array(data), algorithm)).buffer;
}
async onVerify(algorithm, key, signature, data) {
return this.walletWebCrypto.verify(key, algorithm, new Uint8Array(data), new Uint8Array(signature));
}
async onGenerateKey(algorithm, extractable, keyUsages) {
const key = await this.walletWebCrypto.generate(algorithm);
const publicJwk = PublicJwk.fromPublicJwk(key.publicJwk);
return {
publicKey: new CredoWebCryptoKey(publicJwk, algorithm, extractable, "public", keyUsages),
privateKey: new CredoWebCryptoKey(publicJwk, algorithm, extractable, "private", keyUsages)
};
}
async onExportKey(format, key) {
const exported = await this.walletWebCrypto.exportKey(format, key);
if (exported instanceof Uint8Array) return new Uint8Array(exported).buffer;
return exported;
}
async onImportKey(format, keyData, algorithm, extractable, keyUsages) {
return this.walletWebCrypto.importKey(format, keyData.kty ? keyData : new Uint8Array(keyData), algorithm, extractable, keyUsages);
}
};
//#endregion
export { CredoRsaSsaProvider };
//# sourceMappingURL=CredoRsaSsaProvider.mjs.map