

const require_CredoError = require('../../../../error/CredoError.js');
require('../../../../error/index.js');
const require_PublicJwk = require('../../../kms/jwk/PublicJwk.js');
require('../../../kms/index.js');
const require_parse = require('../../domain/parse.js');
const require_keyDidDocument = require('../../domain/keyDidDocument.js');
const require_didPeer = require('./didPeer.js');

//#region src/modules/dids/methods/peer/peerDidNumAlgo0.ts
function publicJwkToNumAlgo0DidDocument(publicJwk) {
	return require_keyDidDocument.getDidDocumentForPublicJwk(`did:peer:0${publicJwk.fingerprint}`, publicJwk);
}
function didToNumAlgo0DidDocument(did) {
	const parsed = require_parse.parseDid(did);
	const numAlgo = require_didPeer.getNumAlgoFromPeerDid(did);
	if (!require_didPeer.isValidPeerDid(did)) throw new require_CredoError.CredoError(`Invalid peer did '${did}'`);
	if (numAlgo !== require_didPeer.PeerDidNumAlgo.InceptionKeyWithoutDoc) throw new require_CredoError.CredoError(`Invalid numAlgo ${numAlgo}, expected ${require_didPeer.PeerDidNumAlgo.InceptionKeyWithoutDoc}`);
	return require_keyDidDocument.getDidDocumentForPublicJwk(did, require_PublicJwk.PublicJwk.fromFingerprint(parsed.id.substring(1)));
}

//#endregion
exports.didToNumAlgo0DidDocument = didToNumAlgo0DidDocument;
exports.publicJwkToNumAlgo0DidDocument = publicJwkToNumAlgo0DidDocument;