@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
20 lines (19 loc) • 814 B
JavaScript
import { TypedArrayEncoder } from "./TypedArrayEncoder.mjs";
//#region src/utils/did.ts
function indyDidFromPublicKeyBase58(publicKeyBase58) {
const buffer = TypedArrayEncoder.fromBase58(publicKeyBase58);
return TypedArrayEncoder.toBase58(buffer.slice(0, 16));
}
/**
* Checks whether `potentialDid` is a valid DID. You can optionally provide a `method` to
* check whether the did is for that specific method.
*
* Note: the check in this method is very simple and just check whether the did starts with
* `did:` or `did:<method>:`. It does not do an advanced regex check on the did.
*/
function isDid(potentialDid, method) {
return method ? potentialDid.startsWith(`did:${method}:`) : potentialDid.startsWith("did:");
}
//#endregion
export { indyDidFromPublicKeyBase58, isDid };
//# sourceMappingURL=did.mjs.map