@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
1 lines • 3.43 kB
Source Map (JSON)
{"version":3,"file":"CredoRsaSsaProvider.mjs","names":[],"sources":["../../../../src/crypto/webcrypto/providers/CredoRsaSsaProvider.ts"],"sourcesContent":["import * as core from 'webcrypto-core'\nimport { PublicJwk } from '../../../modules/kms'\nimport type { CredoWalletWebCrypto } from '../CredoWalletWebCrypto'\nimport { CredoWebCryptoKey } from '../CredoWebCryptoKey'\nimport type {\n CredoWebCryptoKeyPair,\n JsonWebKey,\n KeyFormat,\n KeyUsage,\n RsaHashedImportParams,\n RsaHashedKeyGenParams,\n RsaSsaParams,\n} from '../types'\n\nexport class CredoRsaSsaProvider extends core.RsaSsaProvider {\n public constructor(private walletWebCrypto: CredoWalletWebCrypto) {\n super()\n }\n\n public async onSign(\n algorithm: RsaSsaParams & { name: 'RSASSA-PKCS1-v1_5' },\n key: CredoWebCryptoKey,\n data: ArrayBuffer\n ): Promise<ArrayBuffer> {\n return new Uint8Array(await this.walletWebCrypto.sign(key, new Uint8Array(data), algorithm)).buffer\n }\n\n public async onVerify(\n algorithm: RsaSsaParams & { name: 'RSASSA-PKCS1-v1_5' },\n key: CredoWebCryptoKey,\n signature: ArrayBuffer,\n data: ArrayBuffer\n ): Promise<boolean> {\n return this.walletWebCrypto.verify(key, algorithm, new Uint8Array(data), new Uint8Array(signature))\n }\n\n public async onGenerateKey(\n algorithm: RsaHashedKeyGenParams & { name: 'RSASSA-PKCS1-v1_5' },\n extractable: boolean,\n keyUsages: KeyUsage[]\n ): Promise<CredoWebCryptoKeyPair> {\n const key = await this.walletWebCrypto.generate(algorithm)\n const publicJwk = PublicJwk.fromPublicJwk(key.publicJwk)\n\n return {\n publicKey: new CredoWebCryptoKey(publicJwk, algorithm, extractable, 'public', keyUsages),\n privateKey: new CredoWebCryptoKey(publicJwk, algorithm, extractable, 'private', keyUsages),\n }\n }\n\n public async onExportKey(format: KeyFormat, key: CredoWebCryptoKey): Promise<JsonWebKey | ArrayBuffer> {\n const exported = await this.walletWebCrypto.exportKey(format, key)\n if (exported instanceof Uint8Array) return new Uint8Array(exported).buffer\n return exported\n }\n\n public async onImportKey(\n format: KeyFormat,\n keyData: JsonWebKey | ArrayBuffer,\n algorithm: RsaHashedImportParams & { name: 'RSASSA-PKCS1-v1_5' },\n extractable: boolean,\n keyUsages: KeyUsage[]\n ): Promise<CredoWebCryptoKey> {\n return this.walletWebCrypto.importKey(\n format,\n (keyData as JsonWebKey).kty ? (keyData as JsonWebKey) : new Uint8Array(keyData as ArrayBuffer),\n algorithm,\n extractable,\n keyUsages\n )\n }\n}\n"],"mappings":";;;;;;;;AAcA,IAAa,sBAAb,cAAyC,KAAK,eAAe;CAC3D,AAAO,YAAY,AAAQ,iBAAuC;AAChE,SAAO;EADkB;;CAI3B,MAAa,OACX,WACA,KACA,MACsB;AACtB,SAAO,IAAI,WAAW,MAAM,KAAK,gBAAgB,KAAK,KAAK,IAAI,WAAW,KAAK,EAAE,UAAU,CAAC,CAAC;;CAG/F,MAAa,SACX,WACA,KACA,WACA,MACkB;AAClB,SAAO,KAAK,gBAAgB,OAAO,KAAK,WAAW,IAAI,WAAW,KAAK,EAAE,IAAI,WAAW,UAAU,CAAC;;CAGrG,MAAa,cACX,WACA,aACA,WACgC;EAChC,MAAM,MAAM,MAAM,KAAK,gBAAgB,SAAS,UAAU;EAC1D,MAAM,YAAY,UAAU,cAAc,IAAI,UAAU;AAExD,SAAO;GACL,WAAW,IAAI,kBAAkB,WAAW,WAAW,aAAa,UAAU,UAAU;GACxF,YAAY,IAAI,kBAAkB,WAAW,WAAW,aAAa,WAAW,UAAU;GAC3F;;CAGH,MAAa,YAAY,QAAmB,KAA2D;EACrG,MAAM,WAAW,MAAM,KAAK,gBAAgB,UAAU,QAAQ,IAAI;AAClE,MAAI,oBAAoB,WAAY,QAAO,IAAI,WAAW,SAAS,CAAC;AACpE,SAAO;;CAGT,MAAa,YACX,QACA,SACA,WACA,aACA,WAC4B;AAC5B,SAAO,KAAK,gBAAgB,UAC1B,QACC,QAAuB,MAAO,UAAyB,IAAI,WAAW,QAAuB,EAC9F,WACA,aACA,UACD"}