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.24 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;CACxE,IAAI,IAAI,QAAQ,QAAQ,IAAI,QAAQ,OAClC,OAAO,GAAG,IAAI,IAAI,iBAAiB,IAAI,IAAI;CAG7C,IAAI,IAAI,QAAQ,OAId,OAAO,2BAFQ,kBAAkB,cAAc,IAAI,CAAC,CAAC,CAAC,SAC3B;CAG7B,IAAI,IAAI,QAAQ,OACd,OAAO;CAIT,OAAO,IAAI,IAAI,IAAI;AACrB"}