@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.53 kB
Source Map (JSON)
{"version":3,"file":"peerDidNumAlgo0.mjs","names":[],"sources":["../../../../../src/modules/dids/methods/peer/peerDidNumAlgo0.ts"],"sourcesContent":["import { CredoError } from '../../../../error'\nimport { PublicJwk } from '../../../kms'\nimport { getDidDocumentForPublicJwk } from '../../domain/keyDidDocument'\nimport { parseDid } from '../../domain/parse'\n\nimport { getNumAlgoFromPeerDid, isValidPeerDid, PeerDidNumAlgo } from './didPeer'\n\nexport function publicJwkToNumAlgo0DidDocument(publicJwk: PublicJwk) {\n const did = `did:peer:0${publicJwk.fingerprint}`\n\n return getDidDocumentForPublicJwk(did, publicJwk)\n}\n\nexport function didToNumAlgo0DidDocument(did: string) {\n const parsed = parseDid(did)\n const numAlgo = getNumAlgoFromPeerDid(did)\n\n if (!isValidPeerDid(did)) {\n throw new CredoError(`Invalid peer did '${did}'`)\n }\n\n if (numAlgo !== PeerDidNumAlgo.InceptionKeyWithoutDoc) {\n throw new CredoError(`Invalid numAlgo ${numAlgo}, expected ${PeerDidNumAlgo.InceptionKeyWithoutDoc}`)\n }\n\n const publicJwk = PublicJwk.fromFingerprint(parsed.id.substring(1))\n\n return getDidDocumentForPublicJwk(did, publicJwk)\n}\n"],"mappings":";;;;;;;;;;;AAOA,SAAgB,+BAA+B,WAAsB;AAGnE,QAAO,2BAFK,aAAa,UAAU,eAEI,UAAU;;AAGnD,SAAgB,yBAAyB,KAAa;CACpD,MAAM,SAAS,SAAS,IAAI;CAC5B,MAAM,UAAU,sBAAsB,IAAI;AAE1C,KAAI,CAAC,eAAe,IAAI,CACtB,OAAM,IAAI,WAAW,qBAAqB,IAAI,GAAG;AAGnD,KAAI,YAAY,eAAe,uBAC7B,OAAM,IAAI,WAAW,mBAAmB,QAAQ,aAAa,eAAe,yBAAyB;AAKvG,QAAO,2BAA2B,KAFhB,UAAU,gBAAgB,OAAO,GAAG,UAAU,EAAE,CAAC,CAElB"}