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.55 kB
{"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;CACnE,MAAM,MAAM,aAAa,UAAU;CAEnC,OAAO,2BAA2B,KAAK,SAAS;AAClD;AAEA,SAAgB,yBAAyB,KAAa;CACpD,MAAM,SAAS,SAAS,GAAG;CAC3B,MAAM,UAAU,sBAAsB,GAAG;CAEzC,IAAI,CAAC,eAAe,GAAG,GACrB,MAAM,IAAI,WAAW,qBAAqB,IAAI,EAAE;CAGlD,IAAI,YAAA,GACF,MAAM,IAAI,WAAW,mBAAmB,QAAQ,aAAoD;CAGtG,MAAM,YAAY,UAAU,gBAAgB,OAAO,GAAG,UAAU,CAAC,CAAC;CAElE,OAAO,2BAA2B,KAAK,SAAS;AAClD"}