UNPKG

@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 • 1.23 kB
{"version":3,"file":"humanDescription.mjs","names":[],"sources":["../../../../src/modules/kms/jwk/humanDescription.ts"],"sourcesContent":["import { TypedArrayEncoder } from '../../../utils'\nimport type { KmsJwkPrivate, KmsJwkPublic } from './knownJwk'\n\n/**\n * Gets text description of a key.\n *\n * - `EC key with crv '<crv>'`\n * - `RSA key with bith length <bitLength>\n * - `oct key`\n * - `'<kty>' key`\n */\nexport function getJwkHumanDescription(jwk: KmsJwkPrivate | KmsJwkPublic) {\n if (jwk.kty === 'EC' || jwk.kty === 'OKP') {\n return `${jwk.kty} key with crv '${jwk.crv}'`\n }\n\n if (jwk.kty === 'RSA') {\n // n is the modulus, base64url encoded. Decode to get bit length\n const nBytes = TypedArrayEncoder.fromBase64Url(jwk.n).length\n const bitLength = nBytes * 8\n return `RSA key with bit length ${bitLength}`\n }\n if (jwk.kty === 'oct') {\n return 'oct key'\n }\n\n // @ts-expect-error\n return `'${jwk.kty}' key'`\n}\n"],"mappings":";;;;;;;;;;;;;;AAWA,SAAgB,uBAAuB,KAAmC;AACxE,KAAI,IAAI,QAAQ,QAAQ,IAAI,QAAQ,MAClC,QAAO,GAAG,IAAI,IAAI,iBAAiB,IAAI,IAAI;AAG7C,KAAI,IAAI,QAAQ,MAId,QAAO,2BAFQ,kBAAkB,cAAc,IAAI,EAAE,CAAC,SAC3B;AAG7B,KAAI,IAAI,QAAQ,MACd,QAAO;AAIT,QAAO,IAAI,IAAI,IAAI"}