@yourself_id/siwys-api-js 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +277 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -2
- package/dist/index.d.ts +74 -2
- package/dist/index.js +278 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
|
+
GatekeeperClient: () => GatekeeperClient2,
|
|
34
35
|
Keymaster: () => Keymaster,
|
|
35
36
|
KeymasterExternalClient: () => KeymasterExternalClient
|
|
36
37
|
});
|
|
@@ -595,10 +596,286 @@ var KeymasterExternalClient = class {
|
|
|
595
596
|
}
|
|
596
597
|
};
|
|
597
598
|
|
|
599
|
+
// src/gatekepeerClient.ts
|
|
600
|
+
var import_gatekeeper = require("@mdip/gatekeeper");
|
|
601
|
+
var GatekeeperClient2 = class _GatekeeperClient {
|
|
602
|
+
static instance = null;
|
|
603
|
+
config;
|
|
604
|
+
gatekeeperClient;
|
|
605
|
+
constructor(config) {
|
|
606
|
+
this.validateConfig(config);
|
|
607
|
+
this.config = config;
|
|
608
|
+
}
|
|
609
|
+
static initialize(config) {
|
|
610
|
+
if (!_GatekeeperClient.instance) {
|
|
611
|
+
_GatekeeperClient.instance = new _GatekeeperClient(config);
|
|
612
|
+
} else {
|
|
613
|
+
console.warn(
|
|
614
|
+
"GatekeeperClient already initialized, ignoring re-initialization."
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
ensureInitialized() {
|
|
619
|
+
if (!_GatekeeperClient.instance) {
|
|
620
|
+
throw new Error(
|
|
621
|
+
"GatekeeperClient not initialized. Call GatekeeperClient.initialize() first."
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
// Delegated STATIC methods
|
|
626
|
+
static async start() {
|
|
627
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
628
|
+
return _GatekeeperClient.getInstance().startInternal();
|
|
629
|
+
}
|
|
630
|
+
static addCustomHeader(...args) {
|
|
631
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
632
|
+
return _GatekeeperClient.getInstance().addCustomHeaderInternal(...args);
|
|
633
|
+
}
|
|
634
|
+
static removeCustomHeader(...args) {
|
|
635
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
636
|
+
return _GatekeeperClient.getInstance().removeCustomHeaderInternal(...args);
|
|
637
|
+
}
|
|
638
|
+
static async listRegistries(...args) {
|
|
639
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
640
|
+
return _GatekeeperClient.getInstance().listRegistriesInternal(...args);
|
|
641
|
+
}
|
|
642
|
+
static async resetDb() {
|
|
643
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
644
|
+
return _GatekeeperClient.getInstance().resetDbInternal();
|
|
645
|
+
}
|
|
646
|
+
static async verifyDb() {
|
|
647
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
648
|
+
return _GatekeeperClient.getInstance().verifyDbInternal();
|
|
649
|
+
}
|
|
650
|
+
static async isReady() {
|
|
651
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
652
|
+
return _GatekeeperClient.getInstance().isReadyInternal();
|
|
653
|
+
}
|
|
654
|
+
static async getVersion() {
|
|
655
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
656
|
+
return _GatekeeperClient.getInstance().getVersionInternal();
|
|
657
|
+
}
|
|
658
|
+
static async getStatus() {
|
|
659
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
660
|
+
return _GatekeeperClient.getInstance().getStatusInternal();
|
|
661
|
+
}
|
|
662
|
+
static async createDID(...args) {
|
|
663
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
664
|
+
return _GatekeeperClient.getInstance().createDIDInternal(...args);
|
|
665
|
+
}
|
|
666
|
+
static async resolveDID(...args) {
|
|
667
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
668
|
+
return _GatekeeperClient.getInstance().resolveDIDInternal(...args);
|
|
669
|
+
}
|
|
670
|
+
static async updateDID(...args) {
|
|
671
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
672
|
+
return _GatekeeperClient.getInstance().updateDIDInternal(...args);
|
|
673
|
+
}
|
|
674
|
+
static async deleteDID(...args) {
|
|
675
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
676
|
+
return _GatekeeperClient.getInstance().deleteDIDInternal(...args);
|
|
677
|
+
}
|
|
678
|
+
static async getDIDs(...args) {
|
|
679
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
680
|
+
return _GatekeeperClient.getInstance().getDIDsInternal(...args);
|
|
681
|
+
}
|
|
682
|
+
static async exportDIDs(...args) {
|
|
683
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
684
|
+
return _GatekeeperClient.getInstance().exportDIDsInternal(...args);
|
|
685
|
+
}
|
|
686
|
+
static async importDIDs(...args) {
|
|
687
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
688
|
+
return _GatekeeperClient.getInstance().importDIDsInternal(...args);
|
|
689
|
+
}
|
|
690
|
+
static async exportBatch(...args) {
|
|
691
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
692
|
+
return _GatekeeperClient.getInstance().exportBatchInternal(...args);
|
|
693
|
+
}
|
|
694
|
+
static async importBatch(...args) {
|
|
695
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
696
|
+
return _GatekeeperClient.getInstance().importBatchInternal(...args);
|
|
697
|
+
}
|
|
698
|
+
static async removeDIDs(...args) {
|
|
699
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
700
|
+
return _GatekeeperClient.getInstance().removeDIDsInternal(...args);
|
|
701
|
+
}
|
|
702
|
+
static async getQueue(...args) {
|
|
703
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
704
|
+
return _GatekeeperClient.getInstance().getQueueInternal(...args);
|
|
705
|
+
}
|
|
706
|
+
static async clearQueue(...args) {
|
|
707
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
708
|
+
return _GatekeeperClient.getInstance().clearQueueInternal(...args);
|
|
709
|
+
}
|
|
710
|
+
static async processEvents(...args) {
|
|
711
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
712
|
+
return _GatekeeperClient.getInstance().processEventsInternal(...args);
|
|
713
|
+
}
|
|
714
|
+
static async addJSON(...args) {
|
|
715
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
716
|
+
return _GatekeeperClient.getInstance().addJSONInternal(...args);
|
|
717
|
+
}
|
|
718
|
+
static async getJSON(...args) {
|
|
719
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
720
|
+
return _GatekeeperClient.getInstance().getJSONInternal(...args);
|
|
721
|
+
}
|
|
722
|
+
static async addText(...args) {
|
|
723
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
724
|
+
return _GatekeeperClient.getInstance().addTextInternal(...args);
|
|
725
|
+
}
|
|
726
|
+
static async getText(...args) {
|
|
727
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
728
|
+
return _GatekeeperClient.getInstance().getTextInternal(...args);
|
|
729
|
+
}
|
|
730
|
+
static async addData(...args) {
|
|
731
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
732
|
+
return _GatekeeperClient.getInstance().addDataInternal(...args);
|
|
733
|
+
}
|
|
734
|
+
static async getData(...args) {
|
|
735
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
736
|
+
return _GatekeeperClient.getInstance().getDataInternal(...args);
|
|
737
|
+
}
|
|
738
|
+
static async getBlock(...args) {
|
|
739
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
740
|
+
return _GatekeeperClient.getInstance().getBlockInternal(...args);
|
|
741
|
+
}
|
|
742
|
+
static async addBlock(...args) {
|
|
743
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
744
|
+
return _GatekeeperClient.getInstance().addBlockInternal(...args);
|
|
745
|
+
}
|
|
746
|
+
static getInstance() {
|
|
747
|
+
if (!_GatekeeperClient.instance) {
|
|
748
|
+
throw new Error(
|
|
749
|
+
"GatekeeperClient not initialized. Call GatekeeperClient.initialize() first."
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
return _GatekeeperClient.instance;
|
|
753
|
+
}
|
|
754
|
+
// -------- Internal instance methods (originals renamed with Internal) -------
|
|
755
|
+
async startInternal() {
|
|
756
|
+
if (this.config) {
|
|
757
|
+
return await this.startIntegratedGatekeeper();
|
|
758
|
+
} else {
|
|
759
|
+
throw "Missing Gatekeeper config";
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
async startIntegratedGatekeeper() {
|
|
763
|
+
try {
|
|
764
|
+
this.gatekeeperClient = new import_gatekeeper.GatekeeperClient();
|
|
765
|
+
await this.gatekeeperClient.connect({
|
|
766
|
+
...this.config
|
|
767
|
+
});
|
|
768
|
+
} catch (e) {
|
|
769
|
+
console.error("Error starting GatekeeperClient service:", e);
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
return true;
|
|
773
|
+
}
|
|
774
|
+
addCustomHeaderInternal(header, value) {
|
|
775
|
+
this.gatekeeperClient.addCustomHeader(header, value);
|
|
776
|
+
}
|
|
777
|
+
removeCustomHeaderInternal(header) {
|
|
778
|
+
this.gatekeeperClient.removeCustomHeader(header);
|
|
779
|
+
}
|
|
780
|
+
async listRegistriesInternal() {
|
|
781
|
+
const response = await this.gatekeeperClient.listRegistries();
|
|
782
|
+
return response;
|
|
783
|
+
}
|
|
784
|
+
async resetDbInternal() {
|
|
785
|
+
return this.gatekeeperClient.resetDb();
|
|
786
|
+
}
|
|
787
|
+
async verifyDbInternal() {
|
|
788
|
+
return this.gatekeeperClient.verifyDb();
|
|
789
|
+
}
|
|
790
|
+
async isReadyInternal() {
|
|
791
|
+
return this.gatekeeperClient.isReady();
|
|
792
|
+
}
|
|
793
|
+
async getVersionInternal() {
|
|
794
|
+
return this.gatekeeperClient.getVersion();
|
|
795
|
+
}
|
|
796
|
+
async getStatusInternal() {
|
|
797
|
+
return this.gatekeeperClient.getStatus();
|
|
798
|
+
}
|
|
799
|
+
async createDIDInternal(operation) {
|
|
800
|
+
return this.gatekeeperClient.createDID(operation);
|
|
801
|
+
}
|
|
802
|
+
async resolveDIDInternal(did, options) {
|
|
803
|
+
const response = await this.gatekeeperClient.resolveDID(did, options);
|
|
804
|
+
return response;
|
|
805
|
+
}
|
|
806
|
+
async updateDIDInternal(operation) {
|
|
807
|
+
return this.gatekeeperClient.updateDID(operation);
|
|
808
|
+
}
|
|
809
|
+
async deleteDIDInternal(operation) {
|
|
810
|
+
return this.gatekeeperClient.deleteDID(operation);
|
|
811
|
+
}
|
|
812
|
+
async getDIDsInternal({
|
|
813
|
+
dids,
|
|
814
|
+
resolve
|
|
815
|
+
}) {
|
|
816
|
+
const response = await this.gatekeeperClient.getDIDs({ dids, resolve });
|
|
817
|
+
return response;
|
|
818
|
+
}
|
|
819
|
+
async exportDIDsInternal(dids) {
|
|
820
|
+
return this.gatekeeperClient.exportDIDs(dids);
|
|
821
|
+
}
|
|
822
|
+
async importDIDsInternal(dids) {
|
|
823
|
+
return this.gatekeeperClient.importDIDs(dids);
|
|
824
|
+
}
|
|
825
|
+
async exportBatchInternal(dids) {
|
|
826
|
+
return this.gatekeeperClient.exportBatch(dids);
|
|
827
|
+
}
|
|
828
|
+
async importBatchInternal(batch) {
|
|
829
|
+
return this.gatekeeperClient.importBatch(batch);
|
|
830
|
+
}
|
|
831
|
+
async removeDIDsInternal(dids) {
|
|
832
|
+
return this.gatekeeperClient.removeDIDs(dids);
|
|
833
|
+
}
|
|
834
|
+
async getQueueInternal(registry) {
|
|
835
|
+
return this.gatekeeperClient.getQueue(registry);
|
|
836
|
+
}
|
|
837
|
+
async clearQueueInternal(registry, events) {
|
|
838
|
+
return this.gatekeeperClient.clearQueue(registry, events);
|
|
839
|
+
}
|
|
840
|
+
async processEventsInternal() {
|
|
841
|
+
return this.gatekeeperClient.processEvents();
|
|
842
|
+
}
|
|
843
|
+
async addJSONInternal(data) {
|
|
844
|
+
return this.gatekeeperClient.addJSON(data);
|
|
845
|
+
}
|
|
846
|
+
async getJSONInternal(cid) {
|
|
847
|
+
return this.gatekeeperClient.getJSON(cid);
|
|
848
|
+
}
|
|
849
|
+
async addTextInternal(data) {
|
|
850
|
+
return this.gatekeeperClient.addText(data);
|
|
851
|
+
}
|
|
852
|
+
async getTextInternal(cid) {
|
|
853
|
+
return this.gatekeeperClient.getText(cid);
|
|
854
|
+
}
|
|
855
|
+
async addDataInternal(data) {
|
|
856
|
+
return this.gatekeeperClient.addData(data);
|
|
857
|
+
}
|
|
858
|
+
async getDataInternal(cid) {
|
|
859
|
+
return this.gatekeeperClient.getData(cid);
|
|
860
|
+
}
|
|
861
|
+
async getBlockInternal(registry, block) {
|
|
862
|
+
return this.gatekeeperClient.getBlock(registry, block);
|
|
863
|
+
}
|
|
864
|
+
async addBlockInternal(registry, block) {
|
|
865
|
+
return this.gatekeeperClient.addBlock(registry, block);
|
|
866
|
+
}
|
|
867
|
+
validateConfig(config) {
|
|
868
|
+
if (!config) {
|
|
869
|
+
throw new Error("Missing Gatekeeper config");
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
|
|
598
874
|
// src/index.ts
|
|
599
875
|
__reExport(src_exports, require("@mdip/keymaster"), module.exports);
|
|
600
876
|
// Annotate the CommonJS export names for ESM import in node:
|
|
601
877
|
0 && (module.exports = {
|
|
878
|
+
GatekeeperClient,
|
|
602
879
|
Keymaster,
|
|
603
880
|
KeymasterExternalClient,
|
|
604
881
|
...require("@mdip/keymaster")
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/keymaster.ts","../src/keymasterClient.ts"],"sourcesContent":["export { Keymaster, KeymasterConfig } from \"./keymaster.js\";\nexport { KeymasterExternalClient } from \"./keymasterClient.js\";\n\nexport {\n SdkConfig,\n WalletConfig,\n CreateChallengeResponse,\n CreateChallengeSpec,\n} from \"./types/index.js\";\n\nexport * from \"@mdip/keymaster\";\nimport type * as GatekeeperTypes from \"@mdip/gatekeeper\";\n\nexport { GatekeeperTypes };\n","// Imports\nimport { default as GatekeeperClient } from \"@mdip/gatekeeper/client\";\nimport { default as CipherNode } from \"@mdip/cipher/node\";\nimport { default as KeymasterLib } from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n WalletConfig,\n} from \"./types/index.js\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n CreateResponseOptions,\n IssueCredentialsOptions,\n StoredWallet,\n VerifiableCredential,\n WalletBase,\n WalletFile,\n} from \"@mdip/keymaster\";\nimport type { MdipDocument, ResolveDIDOptions } from \"@mdip/gatekeeper\";\n\n// Keymaster configuration interface\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n walletConfig?: WalletConfig;\n}\n\nexport class Keymaster {\n private static instance: Keymaster | null = null;\n\n private config: KeymasterConfig;\n private keymasterService!: KeymasterLib;\n private serviceStarted = false;\n\n private constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n // Initializes the instance if not already initialized\n /**\n * Initializes the Keymaster instance.\n * @param config The configuration object for the Keymaster service.\n */\n public static initialize(config: KeymasterConfig) {\n if (!Keymaster.instance) {\n Keymaster.instance = new Keymaster(config);\n console.log(\"✅ Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n // Ensures the instance is initialized\n private ensureInitialized() {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n\n /**\n * Starts the Keymaster service.\n * @returns A boolean indicating whether the service was started successfully.\n */\n public static async start() {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().startInternal();\n }\n\n // Method to create a challenge\n /**\n * Creates a challenge for the user to solve.\n * @param spec The challenge specifications.\n * @param options Additional options for creating the challenge (optional).\n * @returns A promise with the challenge response, including the challenge and its callback URL.\n */\n public static async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createChallengeInternal(spec, options);\n }\n\n // Method to bind a credential to a user\n /**\n * Binds a credential to a subject.\n * @param schemaId The schema ID for the credential.\n * @param subjectId The subject's DID (Decentralized Identifier).\n * @param options Optional options, such as validity period and credential data.\n * @returns A promise with the verifiable credential that was bound.\n */\n public static async bindCredential(\n schemaId: string,\n subjectId: string,\n options?: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n }\n ): Promise<VerifiableCredential> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().bindCredentialInternal(\n schemaId,\n subjectId,\n options\n );\n }\n\n // Method to create a response\n /**\n * Creates a response for the challenge.\n * @param challengeDID The DID of the challenge to respond to.\n * @param options Optional options for creating the response (optional).\n * @returns A promise with the response string.\n */\n public static async createResponse(\n challengeDID: string,\n options?: CreateResponseOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createResponseInternal(\n challengeDID,\n options\n );\n }\n\n // Backup wallet\n /**\n * Backups the wallet data.\n * @param registry Optional registry URL for the wallet backup.\n * @returns A promise with a backup string (e.g., backup URL).\n */\n public static async backupWallet(registry?: string): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().backupWalletInternal(registry);\n }\n\n // Issue credential to a user\n /**\n * Issues a credential to the subject.\n * @param credential The credential to be issued.\n * @param options Optional parameters for issuing the credential.\n * @returns A promise with the credential ID or issuance result.\n */\n public static async issueCredential(\n credential: Partial<VerifiableCredential>,\n options?: IssueCredentialsOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().issueCredentialInternal(credential, options);\n }\n\n // Publish a credential\n /**\n * Publishes a verifiable credential.\n * @param did The DID of the credential.\n * @param options Optional parameters, such as whether to reveal the credential.\n * @returns A promise with the published credential.\n */\n public static async publishCredential(\n did: string,\n options?: {\n reveal?: boolean;\n }\n ): Promise<VerifiableCredential> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().publishCredentialInternal(did, options);\n }\n\n // Accept a credential\n /**\n * Accepts a credential.\n * @param did The DID of the credential to accept.\n * @returns A promise indicating whether the credential was successfully accepted.\n */\n public static async acceptCredential(did: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().acceptCredentialInternal(did);\n }\n\n // Show mnemonic\n /**\n * Shows the mnemonic for the wallet.\n * @returns A promise with the mnemonic string.\n */\n public static async showMnemonic(): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().showMnemonicInternal();\n }\n\n // Verify a challenge response\n /**\n * Verifies a response to a challenge.\n * @param did The DID to verify the response for.\n * @param options Optional options, such as retry behavior.\n * @returns A promise with the response verification result.\n */\n public static async verifyResponse(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().verifyResponseInternal(did, options);\n }\n\n // Decrypt a message\n /**\n * Decrypts a message using the current key.\n * @param did The DID of the message to decrypt.\n * @returns A promise with the decrypted message.\n */\n public static async decryptMessage(did: string): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMessageInternal(did);\n }\n\n // Decrypt mnemonic\n /**\n * Decrypts the mnemonic for the wallet.\n * @returns A promise with the decrypted mnemonic.\n */\n public static async decryptMnemonic(): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMnemonicInternal();\n }\n\n // Get a credential\n /**\n * Retrieves a verifiable credential.\n * @param id The credential ID to retrieve.\n * @returns A promise with the credential data or null if not found.\n */\n public static async getCredential(\n id: string\n ): Promise<VerifiableCredential | null> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().getCredentialInternal(id);\n }\n\n // Remove a credential\n /**\n * Removes a verifiable credential.\n * @param id The credential ID to remove.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async removeCredential(id: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeCredentialInternal(id);\n }\n\n // Update a credential\n /**\n * Updates a verifiable credential.\n * @param did The DID of the credential to update.\n * @param credential The new credential data.\n * @returns A promise indicating success or failure of the update operation.\n */\n public static async updateCredential(\n did: string,\n credential: VerifiableCredential\n ): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().updateCredentialInternal(did, credential);\n }\n\n // Method to create an ID\n /**\n * Creates a new DID (Decentralized Identifier).\n * @param name The name for the DID.\n * @param options Optional options, such as registry URL.\n * @returns A promise with the newly created DID.\n */\n public static async createId(\n name: string,\n options?: {\n registry?: string;\n }\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createIdInternal(name, options);\n }\n\n // Remove an ID\n /**\n * Removes an existing DID.\n * @param name The name of the DID to remove.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async removeId(name: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeIdInternal(name);\n }\n\n // Resolve a DID\n /**\n * Resolves a DID to fetch associated data.\n * @param did The DID to resolve.\n * @param options Optional parameters for resolving the DID.\n * @returns A promise with the resolved DID data.\n */\n public static async resolveDID(\n did: string,\n options?: ResolveDIDOptions\n ): Promise<MdipDocument> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().resolveDIDInternal(did, options);\n }\n\n // Set the current DID\n /**\n * Sets the current DID in use.\n * @param name The DID name to set as the current one.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async setCurrentId(name: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setCurrentIdInternal(name);\n }\n\n // Create a schema\n /**\n * Creates a new schema for credentials.\n * @param schema The schema data to create.\n * @param options Optional options for creating the schema.\n * @returns A promise with the created schema data.\n */\n public static async createSchema(\n schema?: unknown,\n options?: CreateAssetOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createSchemaInternal(schema, options);\n }\n\n // Update a schema\n /**\n * Updates an schema for credentials given a schemaDID.\n * @param id The ID of the schema to update.\n * @param schema The schema data to update.\n * @returns A promise with a boolean.\n */\n public static async updateSchema(\n id: string,\n schema?: unknown\n ): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setSchemaInternal(id, schema);\n }\n\n // Create a new wallet\n /**\n * Creates a new wallet.\n * @param mnemonic Optional mnemonic to initialize the wallet.\n * @param overwrite Optional flag to overwrite the existing wallet.\n * @returns A promise with the wallet creation result.\n */\n public static async newWallet(\n mnemonic?: string,\n overwrite?: boolean\n ): Promise<WalletFile> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().newWalletInternal(mnemonic, overwrite);\n }\n\n // Recover an existing wallet\n /**\n * Recovers a wallet from a backup.\n * @param did The DID to use for recovery (optional).\n * @returns A promise with the wallet recovery result.\n */\n public static async recoverWallet(did?: string): Promise<WalletFile> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().recoverWalletInternal(did);\n }\n\n // Helper method to retrieve the instance\n private static getInstance(): Keymaster {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return Keymaster.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async ensureServiceIsRunning() {\n if (!(await this.serviceRunning())) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n\n private async startIntegratedKeymaster(): Promise<boolean> {\n try {\n if (this.config.walletDb) {\n const gatekeeper = await GatekeeperClient.create({\n url: this.config.gatekeeperConfig?.url,\n waitUntilReady: this.config.gatekeeperConfig?.waitUntilReady,\n intervalSeconds: this.config.gatekeeperConfig?.intervalSeconds,\n chatty: this.config.gatekeeperConfig?.chatty,\n });\n\n const cipher = new CipherNode();\n this.keymasterService = new KeymasterLib({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher,\n });\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n\n console.log(\"✅ Keymaster Started\");\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n await this.ensureServiceIsRunning();\n const challenge: string = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n private async bindCredentialInternal(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n private async createResponseInternal(\n challengeDID: string,\n options?: CreateResponseOptions\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createResponse(challengeDID, options);\n }\n\n private async backupWalletInternal(registry?: string): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.backupWallet(registry);\n }\n\n private async issueCredentialInternal(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n\n private async publishCredentialInternal(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n\n private async acceptCredentialInternal(did: string): Promise<boolean> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<KeymasterLib[\"decryptMessage\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal(\n ...args: Parameters<KeymasterLib[\"decryptMnemonic\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n\n private async getCredentialInternal(\n ...args: Parameters<KeymasterLib[\"getCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<KeymasterLib[\"removeCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<KeymasterLib[\"updateCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<KeymasterLib[\"createId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<KeymasterLib[\"removeId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<KeymasterLib[\"resolveDID\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<KeymasterLib[\"setCurrentId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<KeymasterLib[\"createSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n\n private async setSchemaInternal(\n ...args: Parameters<KeymasterLib[\"setSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<KeymasterLib[\"newWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<KeymasterLib[\"recoverWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n\n private async ensureWalletExists(): Promise<void> {\n const existing: StoredWallet | null =\n (await this.config?.walletDb?.loadWallet()) || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n\n const walletConfig = this.config.walletConfig;\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n\n if (walletConfig?.id) {\n await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry,\n });\n }\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.startInternal());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n}\n","import KeymasterClient from \"@mdip/keymaster/client\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n} from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\n\nexport interface KeymasterConfig {\n keymasterConfig?: SdkConfig;\n}\n\nexport class KeymasterExternalClient {\n private config: KeymasterConfig;\n private keymasterService!: KeymasterClient;\n private serviceStarted = false;\n\n constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public async start(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n public async startExternal(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n private async startExternalKeymaster(): Promise<boolean> {\n try {\n this.keymasterService = new KeymasterClient();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n\n return true;\n }\n\n async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge: string = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n async bindCredential(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n async issueCredential(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.issueCredential(credential, options);\n }\n\n async publishCredential(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.publishCredential(did, options);\n }\n\n async acceptCredential(did: string): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.acceptCredential(did);\n }\n\n async showMnemonic(): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n\n async verifyResponse(\n did: string,\n options?: {\n retries?: number;\n delay?: number;\n }\n ): Promise<ChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response: ChallengeResponse =\n await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.start());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,oBAA4C;AAC5C,kBAAsC;AACtC,uBAAwC;AA0BjC,IAAM,YAAN,MAAM,WAAU;AAAA,EACrB,OAAe,WAA6B;AAAA,EAEpC;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EAEjB,YAAY,QAAyB;AAC3C,SAAK,eAAe,MAAM;AAC1B,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAc,WAAW,QAAyB;AAChD,QAAI,CAAC,WAAU,UAAU;AACvB,iBAAU,WAAW,IAAI,WAAU,MAAM;AACzC,cAAQ,I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terLib","import_client","KeymasterClient"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/keymaster.ts","../src/keymasterClient.ts","../src/gatekepeerClient.ts"],"sourcesContent":["export { Keymaster, KeymasterConfig } from \"./keymaster.js\";\nexport { KeymasterExternalClient } from \"./keymasterClient.js\";\nexport { GatekeeperClient } from \"./gatekepeerClient.js\";\n\nexport {\n SdkConfig,\n WalletConfig,\n CreateChallengeResponse,\n CreateChallengeSpec,\n} from \"./types/index.js\";\n\nexport * from \"@mdip/keymaster\";\nimport type * as GatekeeperTypes from \"@mdip/gatekeeper\";\n\nexport { GatekeeperTypes };\n","// Imports\nimport { default as GatekeeperClient } from \"@mdip/gatekeeper/client\";\nimport { default as CipherNode } from \"@mdip/cipher/node\";\nimport { default as KeymasterLib } from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n WalletConfig,\n} from \"./types/index.js\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n CreateResponseOptions,\n IssueCredentialsOptions,\n StoredWallet,\n VerifiableCredential,\n WalletBase,\n WalletFile,\n} from \"@mdip/keymaster\";\nimport type { MdipDocument, ResolveDIDOptions } from \"@mdip/gatekeeper\";\n\n// Keymaster configuration interface\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n walletConfig?: WalletConfig;\n}\n\nexport class Keymaster {\n private static instance: Keymaster | null = null;\n\n private config: KeymasterConfig;\n private keymasterService!: KeymasterLib;\n private serviceStarted = false;\n\n private constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n // Initializes the instance if not already initialized\n /**\n * Initializes the Keymaster instance.\n * @param config The configuration object for the Keymaster service.\n */\n public static initialize(config: KeymasterConfig) {\n if (!Keymaster.instance) {\n Keymaster.instance = new Keymaster(config);\n console.log(\"✅ Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n // Ensures the instance is initialized\n private ensureInitialized() {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n\n /**\n * Starts the Keymaster service.\n * @returns A boolean indicating whether the service was started successfully.\n */\n public static async start() {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().startInternal();\n }\n\n // Method to create a challenge\n /**\n * Creates a challenge for the user to solve.\n * @param spec The challenge specifications.\n * @param options Additional options for creating the challenge (optional).\n * @returns A promise with the challenge response, including the challenge and its callback URL.\n */\n public static async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createChallengeInternal(spec, options);\n }\n\n // Method to bind a credential to a user\n /**\n * Binds a credential to a subject.\n * @param schemaId The schema ID for the credential.\n * @param subjectId The subject's DID (Decentralized Identifier).\n * @param options Optional options, such as validity period and credential data.\n * @returns A promise with the verifiable credential that was bound.\n */\n public static async bindCredential(\n schemaId: string,\n subjectId: string,\n options?: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n }\n ): Promise<VerifiableCredential> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().bindCredentialInternal(\n schemaId,\n subjectId,\n options\n );\n }\n\n // Method to create a response\n /**\n * Creates a response for the challenge.\n * @param challengeDID The DID of the challenge to respond to.\n * @param options Optional options for creating the response (optional).\n * @returns A promise with the response string.\n */\n public static async createResponse(\n challengeDID: string,\n options?: CreateResponseOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createResponseInternal(\n challengeDID,\n options\n );\n }\n\n // Backup wallet\n /**\n * Backups the wallet data.\n * @param registry Optional registry URL for the wallet backup.\n * @returns A promise with a backup string (e.g., backup URL).\n */\n public static async backupWallet(registry?: string): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().backupWalletInternal(registry);\n }\n\n // Issue credential to a user\n /**\n * Issues a credential to the subject.\n * @param credential The credential to be issued.\n * @param options Optional parameters for issuing the credential.\n * @returns A promise with the credential ID or issuance result.\n */\n public static async issueCredential(\n credential: Partial<VerifiableCredential>,\n options?: IssueCredentialsOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().issueCredentialInternal(credential, options);\n }\n\n // Publish a credential\n /**\n * Publishes a verifiable credential.\n * @param did The DID of the credential.\n * @param options Optional parameters, such as whether to reveal the credential.\n * @returns A promise with the published credential.\n */\n public static async publishCredential(\n did: string,\n options?: {\n reveal?: boolean;\n }\n ): Promise<VerifiableCredential> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().publishCredentialInternal(did, options);\n }\n\n // Accept a credential\n /**\n * Accepts a credential.\n * @param did The DID of the credential to accept.\n * @returns A promise indicating whether the credential was successfully accepted.\n */\n public static async acceptCredential(did: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().acceptCredentialInternal(did);\n }\n\n // Show mnemonic\n /**\n * Shows the mnemonic for the wallet.\n * @returns A promise with the mnemonic string.\n */\n public static async showMnemonic(): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().showMnemonicInternal();\n }\n\n // Verify a challenge response\n /**\n * Verifies a response to a challenge.\n * @param did The DID to verify the response for.\n * @param options Optional options, such as retry behavior.\n * @returns A promise with the response verification result.\n */\n public static async verifyResponse(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().verifyResponseInternal(did, options);\n }\n\n // Decrypt a message\n /**\n * Decrypts a message using the current key.\n * @param did The DID of the message to decrypt.\n * @returns A promise with the decrypted message.\n */\n public static async decryptMessage(did: string): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMessageInternal(did);\n }\n\n // Decrypt mnemonic\n /**\n * Decrypts the mnemonic for the wallet.\n * @returns A promise with the decrypted mnemonic.\n */\n public static async decryptMnemonic(): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMnemonicInternal();\n }\n\n // Get a credential\n /**\n * Retrieves a verifiable credential.\n * @param id The credential ID to retrieve.\n * @returns A promise with the credential data or null if not found.\n */\n public static async getCredential(\n id: string\n ): Promise<VerifiableCredential | null> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().getCredentialInternal(id);\n }\n\n // Remove a credential\n /**\n * Removes a verifiable credential.\n * @param id The credential ID to remove.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async removeCredential(id: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeCredentialInternal(id);\n }\n\n // Update a credential\n /**\n * Updates a verifiable credential.\n * @param did The DID of the credential to update.\n * @param credential The new credential data.\n * @returns A promise indicating success or failure of the update operation.\n */\n public static async updateCredential(\n did: string,\n credential: VerifiableCredential\n ): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().updateCredentialInternal(did, credential);\n }\n\n // Method to create an ID\n /**\n * Creates a new DID (Decentralized Identifier).\n * @param name The name for the DID.\n * @param options Optional options, such as registry URL.\n * @returns A promise with the newly created DID.\n */\n public static async createId(\n name: string,\n options?: {\n registry?: string;\n }\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createIdInternal(name, options);\n }\n\n // Remove an ID\n /**\n * Removes an existing DID.\n * @param name The name of the DID to remove.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async removeId(name: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeIdInternal(name);\n }\n\n // Resolve a DID\n /**\n * Resolves a DID to fetch associated data.\n * @param did The DID to resolve.\n * @param options Optional parameters for resolving the DID.\n * @returns A promise with the resolved DID data.\n */\n public static async resolveDID(\n did: string,\n options?: ResolveDIDOptions\n ): Promise<MdipDocument> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().resolveDIDInternal(did, options);\n }\n\n // Set the current DID\n /**\n * Sets the current DID in use.\n * @param name The DID name to set as the current one.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async setCurrentId(name: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setCurrentIdInternal(name);\n }\n\n // Create a schema\n /**\n * Creates a new schema for credentials.\n * @param schema The schema data to create.\n * @param options Optional options for creating the schema.\n * @returns A promise with the created schema data.\n */\n public static async createSchema(\n schema?: unknown,\n options?: CreateAssetOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createSchemaInternal(schema, options);\n }\n\n // Update a schema\n /**\n * Updates an schema for credentials given a schemaDID.\n * @param id The ID of the schema to update.\n * @param schema The schema data to update.\n * @returns A promise with a boolean.\n */\n public static async updateSchema(\n id: string,\n schema?: unknown\n ): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setSchemaInternal(id, schema);\n }\n\n // Create a new wallet\n /**\n * Creates a new wallet.\n * @param mnemonic Optional mnemonic to initialize the wallet.\n * @param overwrite Optional flag to overwrite the existing wallet.\n * @returns A promise with the wallet creation result.\n */\n public static async newWallet(\n mnemonic?: string,\n overwrite?: boolean\n ): Promise<WalletFile> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().newWalletInternal(mnemonic, overwrite);\n }\n\n // Recover an existing wallet\n /**\n * Recovers a wallet from a backup.\n * @param did The DID to use for recovery (optional).\n * @returns A promise with the wallet recovery result.\n */\n public static async recoverWallet(did?: string): Promise<WalletFile> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().recoverWalletInternal(did);\n }\n\n // Helper method to retrieve the instance\n private static getInstance(): Keymaster {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return Keymaster.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async ensureServiceIsRunning() {\n if (!(await this.serviceRunning())) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n\n private async startIntegratedKeymaster(): Promise<boolean> {\n try {\n if (this.config.walletDb) {\n const gatekeeper = await GatekeeperClient.create({\n url: this.config.gatekeeperConfig?.url,\n waitUntilReady: this.config.gatekeeperConfig?.waitUntilReady,\n intervalSeconds: this.config.gatekeeperConfig?.intervalSeconds,\n chatty: this.config.gatekeeperConfig?.chatty,\n });\n\n const cipher = new CipherNode();\n this.keymasterService = new KeymasterLib({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher,\n });\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n\n console.log(\"✅ Keymaster Started\");\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n await this.ensureServiceIsRunning();\n const challenge: string = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n private async bindCredentialInternal(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n private async createResponseInternal(\n challengeDID: string,\n options?: CreateResponseOptions\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createResponse(challengeDID, options);\n }\n\n private async backupWalletInternal(registry?: string): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.backupWallet(registry);\n }\n\n private async issueCredentialInternal(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n\n private async publishCredentialInternal(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n\n private async acceptCredentialInternal(did: string): Promise<boolean> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<KeymasterLib[\"decryptMessage\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal(\n ...args: Parameters<KeymasterLib[\"decryptMnemonic\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n\n private async getCredentialInternal(\n ...args: Parameters<KeymasterLib[\"getCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<KeymasterLib[\"removeCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<KeymasterLib[\"updateCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<KeymasterLib[\"createId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<KeymasterLib[\"removeId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<KeymasterLib[\"resolveDID\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<KeymasterLib[\"setCurrentId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<KeymasterLib[\"createSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n\n private async setSchemaInternal(\n ...args: Parameters<KeymasterLib[\"setSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<KeymasterLib[\"newWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<KeymasterLib[\"recoverWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n\n private async ensureWalletExists(): Promise<void> {\n const existing: StoredWallet | null =\n (await this.config?.walletDb?.loadWallet()) || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n\n const walletConfig = this.config.walletConfig;\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n\n if (walletConfig?.id) {\n await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry,\n });\n }\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.startInternal());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n}\n","import KeymasterClient from \"@mdip/keymaster/client\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n} from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\n\nexport interface KeymasterConfig {\n keymasterConfig?: SdkConfig;\n}\n\nexport class KeymasterExternalClient {\n private config: KeymasterConfig;\n private keymasterService!: KeymasterClient;\n private serviceStarted = false;\n\n constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public async start(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n public async startExternal(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n private async startExternalKeymaster(): Promise<boolean> {\n try {\n this.keymasterService = new KeymasterClient();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n\n return true;\n }\n\n async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge: string = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n async bindCredential(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n async issueCredential(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.issueCredential(credential, options);\n }\n\n async publishCredential(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.publishCredential(did, options);\n }\n\n async acceptCredential(did: string): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.acceptCredential(did);\n }\n\n async showMnemonic(): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n\n async verifyResponse(\n did: string,\n options?: {\n retries?: number;\n delay?: number;\n }\n ): Promise<ChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response: ChallengeResponse =\n await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.start());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n}\n","import {\n GatekeeperClient as GatekeeperClientMdip,\n MdipDocument,\n GetDIDOptions,\n VerifyDbResult,\n GetStatusResult,\n Operation,\n ResolveDIDOptions,\n GatekeeperEvent,\n ImportBatchResult,\n ProcessEventsResult,\n BlockId,\n BlockInfo,\n GatekeeperClientOptions,\n} from \"@mdip/gatekeeper\";\n\nexport class GatekeeperClient {\n private static instance: GatekeeperClient | null = null;\n\n private config: GatekeeperClientOptions;\n private gatekeeperClient!: GatekeeperClientMdip;\n\n private constructor(config: GatekeeperClientOptions) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public static initialize(config: GatekeeperClientOptions) {\n if (!GatekeeperClient.instance) {\n GatekeeperClient.instance = new GatekeeperClient(config);\n } else {\n console.warn(\n \"GatekeeperClient already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n private ensureInitialized() {\n if (!GatekeeperClient.instance) {\n throw new Error(\n \"GatekeeperClient not initialized. Call GatekeeperClient.initialize() first.\"\n );\n }\n }\n\n // Delegated STATIC methods\n\n public static async start() {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().startInternal();\n }\n\n public static addCustomHeader(\n ...args: Parameters<GatekeeperClient[\"addCustomHeaderInternal\"]>\n ): void {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().addCustomHeaderInternal(...args);\n }\n\n public static removeCustomHeader(\n ...args: Parameters<GatekeeperClient[\"removeCustomHeaderInternal\"]>\n ): void {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().removeCustomHeaderInternal(...args);\n }\n\n public static async listRegistries(\n ...args: Parameters<GatekeeperClient[\"listRegistriesInternal\"]>\n ) {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().listRegistriesInternal(...args);\n }\n\n public static async resetDb(): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().resetDbInternal();\n }\n\n public static async verifyDb(): Promise<VerifyDbResult> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().verifyDbInternal();\n }\n\n public static async isReady(): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().isReadyInternal();\n }\n\n public static async getVersion(): Promise<number> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getVersionInternal();\n }\n\n public static async getStatus(): Promise<GetStatusResult> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getStatusInternal();\n }\n\n public static async createDID(\n ...args: Parameters<GatekeeperClient[\"createDIDInternal\"]>\n ): Promise<string> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().createDIDInternal(...args);\n }\n\n public static async resolveDID(\n ...args: Parameters<GatekeeperClient[\"resolveDIDInternal\"]>\n ): Promise<MdipDocument> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().resolveDIDInternal(...args);\n }\n\n public static async updateDID(\n ...args: Parameters<GatekeeperClient[\"updateDIDInternal\"]>\n ): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().updateDIDInternal(...args);\n }\n\n public static async deleteDID(\n ...args: Parameters<GatekeeperClient[\"deleteDIDInternal\"]>\n ): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().deleteDIDInternal(...args);\n }\n\n public static async getDIDs(\n ...args: Parameters<GatekeeperClient[\"getDIDsInternal\"]>\n ): Promise<string[] | MdipDocument[]> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getDIDsInternal(...args);\n }\n\n public static async exportDIDs(\n ...args: Parameters<GatekeeperClient[\"exportDIDsInternal\"]>\n ): Promise<GatekeeperEvent[][]> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().exportDIDsInternal(...args);\n }\n\n public static async importDIDs(\n ...args: Parameters<GatekeeperClient[\"importDIDsInternal\"]>\n ): Promise<ImportBatchResult> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().importDIDsInternal(...args);\n }\n\n public static async exportBatch(\n ...args: Parameters<GatekeeperClient[\"exportBatchInternal\"]>\n ): Promise<GatekeeperEvent[]> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().exportBatchInternal(...args);\n }\n\n public static async importBatch(\n ...args: Parameters<GatekeeperClient[\"importBatchInternal\"]>\n ): Promise<ImportBatchResult> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().importBatchInternal(...args);\n }\n\n public static async removeDIDs(\n ...args: Parameters<GatekeeperClient[\"removeDIDsInternal\"]>\n ): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().removeDIDsInternal(...args);\n }\n\n public static async getQueue(\n ...args: Parameters<GatekeeperClient[\"getQueueInternal\"]>\n ): Promise<Operation[]> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getQueueInternal(...args);\n }\n\n public static async clearQueue(\n ...args: Parameters<GatekeeperClient[\"clearQueueInternal\"]>\n ): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().clearQueueInternal(...args);\n }\n\n public static async processEvents(\n ...args: Parameters<GatekeeperClient[\"processEventsInternal\"]>\n ): Promise<ProcessEventsResult> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().processEventsInternal(...args);\n }\n\n public static async addJSON(\n ...args: Parameters<GatekeeperClient[\"addJSONInternal\"]>\n ): Promise<string> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().addJSONInternal(...args);\n }\n\n public static async getJSON(\n ...args: Parameters<GatekeeperClient[\"getJSONInternal\"]>\n ): Promise<object> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getJSONInternal(...args);\n }\n\n public static async addText(\n ...args: Parameters<GatekeeperClient[\"addTextInternal\"]>\n ): Promise<string> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().addTextInternal(...args);\n }\n\n public static async getText(\n ...args: Parameters<GatekeeperClient[\"getTextInternal\"]>\n ): Promise<string> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getTextInternal(...args);\n }\n\n public static async addData(\n ...args: Parameters<GatekeeperClient[\"addDataInternal\"]>\n ): Promise<string> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().addDataInternal(...args);\n }\n\n public static async getData(\n ...args: Parameters<GatekeeperClient[\"getDataInternal\"]>\n ): Promise<Buffer> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getDataInternal(...args);\n }\n\n public static async getBlock(\n ...args: Parameters<GatekeeperClient[\"getBlockInternal\"]>\n ): Promise<BlockInfo | null> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getBlockInternal(...args);\n }\n\n public static async addBlock(\n ...args: Parameters<GatekeeperClient[\"addBlockInternal\"]>\n ): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().addBlockInternal(...args);\n }\n\n private static getInstance(): GatekeeperClient {\n if (!GatekeeperClient.instance) {\n throw new Error(\n \"GatekeeperClient not initialized. Call GatekeeperClient.initialize() first.\"\n );\n }\n return GatekeeperClient.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async startInternal(): Promise<boolean> {\n if (this.config) {\n return await this.startIntegratedGatekeeper();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n }\n\n private async startIntegratedGatekeeper(): Promise<boolean> {\n try {\n this.gatekeeperClient = new GatekeeperClientMdip();\n await this.gatekeeperClient.connect({\n ...this.config,\n });\n } catch (e) {\n console.error(\"Error starting GatekeeperClient service:\", e);\n return false;\n }\n return true;\n }\n\n private addCustomHeaderInternal(header: string, value: string): void {\n this.gatekeeperClient.addCustomHeader(header, value);\n }\n\n private removeCustomHeaderInternal(header: string): void {\n this.gatekeeperClient.removeCustomHeader(header);\n }\n\n private async listRegistriesInternal(): Promise<string[]> {\n const response = await this.gatekeeperClient.listRegistries();\n return response;\n }\n\n private async resetDbInternal(): Promise<boolean> {\n return this.gatekeeperClient.resetDb();\n }\n\n private async verifyDbInternal(): Promise<VerifyDbResult> {\n return this.gatekeeperClient.verifyDb();\n }\n\n private async isReadyInternal(): Promise<boolean> {\n return this.gatekeeperClient.isReady();\n }\n\n private async getVersionInternal(): Promise<number> {\n return this.gatekeeperClient.getVersion();\n }\n\n private async getStatusInternal(): Promise<GetStatusResult> {\n return this.gatekeeperClient.getStatus();\n }\n\n private async createDIDInternal(operation: Operation): Promise<string> {\n return this.gatekeeperClient.createDID(operation);\n }\n\n private async resolveDIDInternal(\n did: string,\n options?: ResolveDIDOptions\n ): Promise<MdipDocument> {\n const response = await this.gatekeeperClient.resolveDID(did, options);\n return response;\n }\n\n private async updateDIDInternal(operation: Operation): Promise<boolean> {\n return this.gatekeeperClient.updateDID(operation);\n }\n\n private async deleteDIDInternal(operation: Operation): Promise<boolean> {\n return this.gatekeeperClient.deleteDID(operation);\n }\n\n private async getDIDsInternal({\n dids,\n resolve,\n }: GetDIDOptions): Promise<string[] | MdipDocument[]> {\n const response = await this.gatekeeperClient.getDIDs({ dids, resolve });\n return response;\n }\n\n private async exportDIDsInternal(\n dids?: string[]\n ): Promise<GatekeeperEvent[][]> {\n return this.gatekeeperClient.exportDIDs(dids);\n }\n\n private async importDIDsInternal(\n dids: GatekeeperEvent[][]\n ): Promise<ImportBatchResult> {\n return this.gatekeeperClient.importDIDs(dids);\n }\n\n private async exportBatchInternal(\n dids?: string[]\n ): Promise<GatekeeperEvent[]> {\n return this.gatekeeperClient.exportBatch(dids);\n }\n\n private async importBatchInternal(\n batch: GatekeeperEvent[]\n ): Promise<ImportBatchResult> {\n return this.gatekeeperClient.importBatch(batch);\n }\n\n private async removeDIDsInternal(dids: string[]): Promise<boolean> {\n return this.gatekeeperClient.removeDIDs(dids);\n }\n\n private async getQueueInternal(registry: string): Promise<Operation[]> {\n return this.gatekeeperClient.getQueue(registry);\n }\n\n private async clearQueueInternal(\n registry: string,\n events: Operation[]\n ): Promise<boolean> {\n return this.gatekeeperClient.clearQueue(registry, events);\n }\n\n private async processEventsInternal(): Promise<ProcessEventsResult> {\n return this.gatekeeperClient.processEvents();\n }\n\n private async addJSONInternal(data: object): Promise<string> {\n return this.gatekeeperClient.addJSON(data);\n }\n\n private async getJSONInternal(cid: string): Promise<object> {\n return this.gatekeeperClient.getJSON(cid);\n }\n\n private async addTextInternal(data: string): Promise<string> {\n return this.gatekeeperClient.addText(data);\n }\n\n private async getTextInternal(cid: string): Promise<string> {\n return this.gatekeeperClient.getText(cid);\n }\n\n private async addDataInternal(data: Buffer): Promise<string> {\n return this.gatekeeperClient.addData(data);\n }\n\n private async getDataInternal(cid: string): Promise<Buffer> {\n return this.gatekeeperClient.getData(cid);\n }\n\n private async getBlockInternal(\n registry: string,\n block?: BlockId\n ): Promise<BlockInfo | null> {\n return this.gatekeeperClient.getBlock(registry, block);\n }\n\n private async addBlockInternal(\n registry: string,\n block: BlockInfo\n ): Promise<boolean> {\n return this.gatekeeperClient.addBlock(registry, block);\n }\n\n private validateConfig(config: GatekeeperClientOptions): void {\n if (!config) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;;;ACCA,oBAA4C;AAC5C,kBAAsC;AACtC,uBAAwC;AA0BjC,IAAM,YAAN,MAAM,WAAU;AAAA,EACrB,OAAe,WAA6B;AAAA,EAEpC;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EAEjB,YAAY,QAAyB;AAC3C,SAAK,eAAe,MAAM;AAC1B,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAc,WAAW,QAAyB;AAChD,QAAI,CAAC,WAAU,UAAU;AACvB,iBAAU,WAAW,IAAI,WAAU,MAAM;AACzC,cAAQ,IAAI,8BAAyB;AAAA,IACvC,OAAO;AACL,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGQ,oBAAoB;AAC1B,QAAI,CAAC,WAAU,UAAU;AACvB,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aA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O,KAAK,iBAAiB,SAAS,QAAQ;AAAA,EAChD;AAAA,EAEA,MAAc,mBACZ,UACA,QACkB;AAClB,WAAO,KAAK,iBAAiB,WAAW,UAAU,MAAM;AAAA,EAC1D;AAAA,EAEA,MAAc,wBAAsD;AAClE,WAAO,KAAK,iBAAiB,cAAc;AAAA,EAC7C;AAAA,EAEA,MAAc,gBAAgB,MAA+B;AAC3D,WAAO,KAAK,iBAAiB,QAAQ,IAAI;AAAA,EAC3C;AAAA,EAEA,MAAc,gBAAgB,KAA8B;AAC1D,WAAO,KAAK,iBAAiB,QAAQ,GAAG;AAAA,EAC1C;AAAA,EAEA,MAAc,gBAAgB,MAA+B;AAC3D,WAAO,KAAK,iBAAiB,QAAQ,IAAI;AAAA,EAC3C;AAAA,EAEA,MAAc,gBAAgB,KAA8B;AAC1D,WAAO,KAAK,iBAAiB,QAAQ,GAAG;AAAA,EAC1C;AAAA,EAEA,MAAc,gBAAgB,MAA+B;AAC3D,WAAO,KAAK,iBAAiB,QAAQ,IAAI;AAAA,EAC3C;AAAA,EAEA,MAAc,gBAAgB,KAA8B;AAC1D,WAAO,KAAK,iBAAiB,QAAQ,GAAG;AAAA,EAC1C;AAAA,EAEA,MAAc,iBACZ,UACA,OAC2B;AAC3B,WAAO,KAAK,iBAAiB,SAAS,UAAU,KAAK;AAAA,EACvD;AAAA,EAEA,MAAc,iBACZ,UACA,OACkB;AAClB,WAAO,KAAK,iBAAiB,SAAS,UAAU,KAAK;AAAA,EACvD;AAAA,EAEQ,eAAe,QAAuC;AAC5D,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,2BAA2B;AAAA,IAC7C;AAAA,EACF;AACF;;;AH7ZA,wBAAc,4BAXd;","names":["GatekeeperClient","GatekeeperClient","CipherNode","KeymasterLib","import_client","KeymasterClient","GatekeeperClient","GatekeeperClientMdip"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WalletBase, CreateAssetOptions, VerifiableCredential, CreateResponseOptions, IssueCredentialsOptions, ChallengeResponse, WalletFile } from '@mdip/keymaster';
|
|
2
2
|
export * from '@mdip/keymaster';
|
|
3
|
-
import { ResolveDIDOptions, MdipDocument } from '@mdip/gatekeeper';
|
|
3
|
+
import { ResolveDIDOptions, MdipDocument, GatekeeperClientOptions, VerifyDbResult, GetStatusResult, GatekeeperEvent, ImportBatchResult, Operation, ProcessEventsResult, BlockInfo } from '@mdip/gatekeeper';
|
|
4
4
|
import * as gatekeeper from '@mdip/gatekeeper';
|
|
5
5
|
export { gatekeeper as GatekeeperTypes };
|
|
6
6
|
|
|
@@ -265,4 +265,76 @@ declare class KeymasterExternalClient {
|
|
|
265
265
|
private validateConfig;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
declare class GatekeeperClient {
|
|
269
|
+
private static instance;
|
|
270
|
+
private config;
|
|
271
|
+
private gatekeeperClient;
|
|
272
|
+
private constructor();
|
|
273
|
+
static initialize(config: GatekeeperClientOptions): void;
|
|
274
|
+
private ensureInitialized;
|
|
275
|
+
static start(): Promise<boolean>;
|
|
276
|
+
static addCustomHeader(...args: Parameters<GatekeeperClient["addCustomHeaderInternal"]>): void;
|
|
277
|
+
static removeCustomHeader(...args: Parameters<GatekeeperClient["removeCustomHeaderInternal"]>): void;
|
|
278
|
+
static listRegistries(...args: Parameters<GatekeeperClient["listRegistriesInternal"]>): Promise<string[]>;
|
|
279
|
+
static resetDb(): Promise<boolean>;
|
|
280
|
+
static verifyDb(): Promise<VerifyDbResult>;
|
|
281
|
+
static isReady(): Promise<boolean>;
|
|
282
|
+
static getVersion(): Promise<number>;
|
|
283
|
+
static getStatus(): Promise<GetStatusResult>;
|
|
284
|
+
static createDID(...args: Parameters<GatekeeperClient["createDIDInternal"]>): Promise<string>;
|
|
285
|
+
static resolveDID(...args: Parameters<GatekeeperClient["resolveDIDInternal"]>): Promise<MdipDocument>;
|
|
286
|
+
static updateDID(...args: Parameters<GatekeeperClient["updateDIDInternal"]>): Promise<boolean>;
|
|
287
|
+
static deleteDID(...args: Parameters<GatekeeperClient["deleteDIDInternal"]>): Promise<boolean>;
|
|
288
|
+
static getDIDs(...args: Parameters<GatekeeperClient["getDIDsInternal"]>): Promise<string[] | MdipDocument[]>;
|
|
289
|
+
static exportDIDs(...args: Parameters<GatekeeperClient["exportDIDsInternal"]>): Promise<GatekeeperEvent[][]>;
|
|
290
|
+
static importDIDs(...args: Parameters<GatekeeperClient["importDIDsInternal"]>): Promise<ImportBatchResult>;
|
|
291
|
+
static exportBatch(...args: Parameters<GatekeeperClient["exportBatchInternal"]>): Promise<GatekeeperEvent[]>;
|
|
292
|
+
static importBatch(...args: Parameters<GatekeeperClient["importBatchInternal"]>): Promise<ImportBatchResult>;
|
|
293
|
+
static removeDIDs(...args: Parameters<GatekeeperClient["removeDIDsInternal"]>): Promise<boolean>;
|
|
294
|
+
static getQueue(...args: Parameters<GatekeeperClient["getQueueInternal"]>): Promise<Operation[]>;
|
|
295
|
+
static clearQueue(...args: Parameters<GatekeeperClient["clearQueueInternal"]>): Promise<boolean>;
|
|
296
|
+
static processEvents(...args: Parameters<GatekeeperClient["processEventsInternal"]>): Promise<ProcessEventsResult>;
|
|
297
|
+
static addJSON(...args: Parameters<GatekeeperClient["addJSONInternal"]>): Promise<string>;
|
|
298
|
+
static getJSON(...args: Parameters<GatekeeperClient["getJSONInternal"]>): Promise<object>;
|
|
299
|
+
static addText(...args: Parameters<GatekeeperClient["addTextInternal"]>): Promise<string>;
|
|
300
|
+
static getText(...args: Parameters<GatekeeperClient["getTextInternal"]>): Promise<string>;
|
|
301
|
+
static addData(...args: Parameters<GatekeeperClient["addDataInternal"]>): Promise<string>;
|
|
302
|
+
static getData(...args: Parameters<GatekeeperClient["getDataInternal"]>): Promise<Buffer>;
|
|
303
|
+
static getBlock(...args: Parameters<GatekeeperClient["getBlockInternal"]>): Promise<BlockInfo | null>;
|
|
304
|
+
static addBlock(...args: Parameters<GatekeeperClient["addBlockInternal"]>): Promise<boolean>;
|
|
305
|
+
private static getInstance;
|
|
306
|
+
private startInternal;
|
|
307
|
+
private startIntegratedGatekeeper;
|
|
308
|
+
private addCustomHeaderInternal;
|
|
309
|
+
private removeCustomHeaderInternal;
|
|
310
|
+
private listRegistriesInternal;
|
|
311
|
+
private resetDbInternal;
|
|
312
|
+
private verifyDbInternal;
|
|
313
|
+
private isReadyInternal;
|
|
314
|
+
private getVersionInternal;
|
|
315
|
+
private getStatusInternal;
|
|
316
|
+
private createDIDInternal;
|
|
317
|
+
private resolveDIDInternal;
|
|
318
|
+
private updateDIDInternal;
|
|
319
|
+
private deleteDIDInternal;
|
|
320
|
+
private getDIDsInternal;
|
|
321
|
+
private exportDIDsInternal;
|
|
322
|
+
private importDIDsInternal;
|
|
323
|
+
private exportBatchInternal;
|
|
324
|
+
private importBatchInternal;
|
|
325
|
+
private removeDIDsInternal;
|
|
326
|
+
private getQueueInternal;
|
|
327
|
+
private clearQueueInternal;
|
|
328
|
+
private processEventsInternal;
|
|
329
|
+
private addJSONInternal;
|
|
330
|
+
private getJSONInternal;
|
|
331
|
+
private addTextInternal;
|
|
332
|
+
private getTextInternal;
|
|
333
|
+
private addDataInternal;
|
|
334
|
+
private getDataInternal;
|
|
335
|
+
private getBlockInternal;
|
|
336
|
+
private addBlockInternal;
|
|
337
|
+
private validateConfig;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export { type CreateChallengeResponse, type CreateChallengeSpec, GatekeeperClient, Keymaster, type KeymasterConfig$1 as KeymasterConfig, KeymasterExternalClient, type SdkConfig, type WalletConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WalletBase, CreateAssetOptions, VerifiableCredential, CreateResponseOptions, IssueCredentialsOptions, ChallengeResponse, WalletFile } from '@mdip/keymaster';
|
|
2
2
|
export * from '@mdip/keymaster';
|
|
3
|
-
import { ResolveDIDOptions, MdipDocument } from '@mdip/gatekeeper';
|
|
3
|
+
import { ResolveDIDOptions, MdipDocument, GatekeeperClientOptions, VerifyDbResult, GetStatusResult, GatekeeperEvent, ImportBatchResult, Operation, ProcessEventsResult, BlockInfo } from '@mdip/gatekeeper';
|
|
4
4
|
import * as gatekeeper from '@mdip/gatekeeper';
|
|
5
5
|
export { gatekeeper as GatekeeperTypes };
|
|
6
6
|
|
|
@@ -265,4 +265,76 @@ declare class KeymasterExternalClient {
|
|
|
265
265
|
private validateConfig;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
declare class GatekeeperClient {
|
|
269
|
+
private static instance;
|
|
270
|
+
private config;
|
|
271
|
+
private gatekeeperClient;
|
|
272
|
+
private constructor();
|
|
273
|
+
static initialize(config: GatekeeperClientOptions): void;
|
|
274
|
+
private ensureInitialized;
|
|
275
|
+
static start(): Promise<boolean>;
|
|
276
|
+
static addCustomHeader(...args: Parameters<GatekeeperClient["addCustomHeaderInternal"]>): void;
|
|
277
|
+
static removeCustomHeader(...args: Parameters<GatekeeperClient["removeCustomHeaderInternal"]>): void;
|
|
278
|
+
static listRegistries(...args: Parameters<GatekeeperClient["listRegistriesInternal"]>): Promise<string[]>;
|
|
279
|
+
static resetDb(): Promise<boolean>;
|
|
280
|
+
static verifyDb(): Promise<VerifyDbResult>;
|
|
281
|
+
static isReady(): Promise<boolean>;
|
|
282
|
+
static getVersion(): Promise<number>;
|
|
283
|
+
static getStatus(): Promise<GetStatusResult>;
|
|
284
|
+
static createDID(...args: Parameters<GatekeeperClient["createDIDInternal"]>): Promise<string>;
|
|
285
|
+
static resolveDID(...args: Parameters<GatekeeperClient["resolveDIDInternal"]>): Promise<MdipDocument>;
|
|
286
|
+
static updateDID(...args: Parameters<GatekeeperClient["updateDIDInternal"]>): Promise<boolean>;
|
|
287
|
+
static deleteDID(...args: Parameters<GatekeeperClient["deleteDIDInternal"]>): Promise<boolean>;
|
|
288
|
+
static getDIDs(...args: Parameters<GatekeeperClient["getDIDsInternal"]>): Promise<string[] | MdipDocument[]>;
|
|
289
|
+
static exportDIDs(...args: Parameters<GatekeeperClient["exportDIDsInternal"]>): Promise<GatekeeperEvent[][]>;
|
|
290
|
+
static importDIDs(...args: Parameters<GatekeeperClient["importDIDsInternal"]>): Promise<ImportBatchResult>;
|
|
291
|
+
static exportBatch(...args: Parameters<GatekeeperClient["exportBatchInternal"]>): Promise<GatekeeperEvent[]>;
|
|
292
|
+
static importBatch(...args: Parameters<GatekeeperClient["importBatchInternal"]>): Promise<ImportBatchResult>;
|
|
293
|
+
static removeDIDs(...args: Parameters<GatekeeperClient["removeDIDsInternal"]>): Promise<boolean>;
|
|
294
|
+
static getQueue(...args: Parameters<GatekeeperClient["getQueueInternal"]>): Promise<Operation[]>;
|
|
295
|
+
static clearQueue(...args: Parameters<GatekeeperClient["clearQueueInternal"]>): Promise<boolean>;
|
|
296
|
+
static processEvents(...args: Parameters<GatekeeperClient["processEventsInternal"]>): Promise<ProcessEventsResult>;
|
|
297
|
+
static addJSON(...args: Parameters<GatekeeperClient["addJSONInternal"]>): Promise<string>;
|
|
298
|
+
static getJSON(...args: Parameters<GatekeeperClient["getJSONInternal"]>): Promise<object>;
|
|
299
|
+
static addText(...args: Parameters<GatekeeperClient["addTextInternal"]>): Promise<string>;
|
|
300
|
+
static getText(...args: Parameters<GatekeeperClient["getTextInternal"]>): Promise<string>;
|
|
301
|
+
static addData(...args: Parameters<GatekeeperClient["addDataInternal"]>): Promise<string>;
|
|
302
|
+
static getData(...args: Parameters<GatekeeperClient["getDataInternal"]>): Promise<Buffer>;
|
|
303
|
+
static getBlock(...args: Parameters<GatekeeperClient["getBlockInternal"]>): Promise<BlockInfo | null>;
|
|
304
|
+
static addBlock(...args: Parameters<GatekeeperClient["addBlockInternal"]>): Promise<boolean>;
|
|
305
|
+
private static getInstance;
|
|
306
|
+
private startInternal;
|
|
307
|
+
private startIntegratedGatekeeper;
|
|
308
|
+
private addCustomHeaderInternal;
|
|
309
|
+
private removeCustomHeaderInternal;
|
|
310
|
+
private listRegistriesInternal;
|
|
311
|
+
private resetDbInternal;
|
|
312
|
+
private verifyDbInternal;
|
|
313
|
+
private isReadyInternal;
|
|
314
|
+
private getVersionInternal;
|
|
315
|
+
private getStatusInternal;
|
|
316
|
+
private createDIDInternal;
|
|
317
|
+
private resolveDIDInternal;
|
|
318
|
+
private updateDIDInternal;
|
|
319
|
+
private deleteDIDInternal;
|
|
320
|
+
private getDIDsInternal;
|
|
321
|
+
private exportDIDsInternal;
|
|
322
|
+
private importDIDsInternal;
|
|
323
|
+
private exportBatchInternal;
|
|
324
|
+
private importBatchInternal;
|
|
325
|
+
private removeDIDsInternal;
|
|
326
|
+
private getQueueInternal;
|
|
327
|
+
private clearQueueInternal;
|
|
328
|
+
private processEventsInternal;
|
|
329
|
+
private addJSONInternal;
|
|
330
|
+
private getJSONInternal;
|
|
331
|
+
private addTextInternal;
|
|
332
|
+
private getTextInternal;
|
|
333
|
+
private addDataInternal;
|
|
334
|
+
private getDataInternal;
|
|
335
|
+
private getBlockInternal;
|
|
336
|
+
private addBlockInternal;
|
|
337
|
+
private validateConfig;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export { type CreateChallengeResponse, type CreateChallengeSpec, GatekeeperClient, Keymaster, type KeymasterConfig$1 as KeymasterConfig, KeymasterExternalClient, type SdkConfig, type WalletConfig };
|
package/dist/index.js
CHANGED
|
@@ -557,9 +557,287 @@ var KeymasterExternalClient = class {
|
|
|
557
557
|
}
|
|
558
558
|
};
|
|
559
559
|
|
|
560
|
+
// src/gatekepeerClient.ts
|
|
561
|
+
import {
|
|
562
|
+
GatekeeperClient as GatekeeperClientMdip
|
|
563
|
+
} from "@mdip/gatekeeper";
|
|
564
|
+
var GatekeeperClient2 = class _GatekeeperClient {
|
|
565
|
+
static instance = null;
|
|
566
|
+
config;
|
|
567
|
+
gatekeeperClient;
|
|
568
|
+
constructor(config) {
|
|
569
|
+
this.validateConfig(config);
|
|
570
|
+
this.config = config;
|
|
571
|
+
}
|
|
572
|
+
static initialize(config) {
|
|
573
|
+
if (!_GatekeeperClient.instance) {
|
|
574
|
+
_GatekeeperClient.instance = new _GatekeeperClient(config);
|
|
575
|
+
} else {
|
|
576
|
+
console.warn(
|
|
577
|
+
"GatekeeperClient already initialized, ignoring re-initialization."
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
ensureInitialized() {
|
|
582
|
+
if (!_GatekeeperClient.instance) {
|
|
583
|
+
throw new Error(
|
|
584
|
+
"GatekeeperClient not initialized. Call GatekeeperClient.initialize() first."
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
// Delegated STATIC methods
|
|
589
|
+
static async start() {
|
|
590
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
591
|
+
return _GatekeeperClient.getInstance().startInternal();
|
|
592
|
+
}
|
|
593
|
+
static addCustomHeader(...args) {
|
|
594
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
595
|
+
return _GatekeeperClient.getInstance().addCustomHeaderInternal(...args);
|
|
596
|
+
}
|
|
597
|
+
static removeCustomHeader(...args) {
|
|
598
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
599
|
+
return _GatekeeperClient.getInstance().removeCustomHeaderInternal(...args);
|
|
600
|
+
}
|
|
601
|
+
static async listRegistries(...args) {
|
|
602
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
603
|
+
return _GatekeeperClient.getInstance().listRegistriesInternal(...args);
|
|
604
|
+
}
|
|
605
|
+
static async resetDb() {
|
|
606
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
607
|
+
return _GatekeeperClient.getInstance().resetDbInternal();
|
|
608
|
+
}
|
|
609
|
+
static async verifyDb() {
|
|
610
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
611
|
+
return _GatekeeperClient.getInstance().verifyDbInternal();
|
|
612
|
+
}
|
|
613
|
+
static async isReady() {
|
|
614
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
615
|
+
return _GatekeeperClient.getInstance().isReadyInternal();
|
|
616
|
+
}
|
|
617
|
+
static async getVersion() {
|
|
618
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
619
|
+
return _GatekeeperClient.getInstance().getVersionInternal();
|
|
620
|
+
}
|
|
621
|
+
static async getStatus() {
|
|
622
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
623
|
+
return _GatekeeperClient.getInstance().getStatusInternal();
|
|
624
|
+
}
|
|
625
|
+
static async createDID(...args) {
|
|
626
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
627
|
+
return _GatekeeperClient.getInstance().createDIDInternal(...args);
|
|
628
|
+
}
|
|
629
|
+
static async resolveDID(...args) {
|
|
630
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
631
|
+
return _GatekeeperClient.getInstance().resolveDIDInternal(...args);
|
|
632
|
+
}
|
|
633
|
+
static async updateDID(...args) {
|
|
634
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
635
|
+
return _GatekeeperClient.getInstance().updateDIDInternal(...args);
|
|
636
|
+
}
|
|
637
|
+
static async deleteDID(...args) {
|
|
638
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
639
|
+
return _GatekeeperClient.getInstance().deleteDIDInternal(...args);
|
|
640
|
+
}
|
|
641
|
+
static async getDIDs(...args) {
|
|
642
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
643
|
+
return _GatekeeperClient.getInstance().getDIDsInternal(...args);
|
|
644
|
+
}
|
|
645
|
+
static async exportDIDs(...args) {
|
|
646
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
647
|
+
return _GatekeeperClient.getInstance().exportDIDsInternal(...args);
|
|
648
|
+
}
|
|
649
|
+
static async importDIDs(...args) {
|
|
650
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
651
|
+
return _GatekeeperClient.getInstance().importDIDsInternal(...args);
|
|
652
|
+
}
|
|
653
|
+
static async exportBatch(...args) {
|
|
654
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
655
|
+
return _GatekeeperClient.getInstance().exportBatchInternal(...args);
|
|
656
|
+
}
|
|
657
|
+
static async importBatch(...args) {
|
|
658
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
659
|
+
return _GatekeeperClient.getInstance().importBatchInternal(...args);
|
|
660
|
+
}
|
|
661
|
+
static async removeDIDs(...args) {
|
|
662
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
663
|
+
return _GatekeeperClient.getInstance().removeDIDsInternal(...args);
|
|
664
|
+
}
|
|
665
|
+
static async getQueue(...args) {
|
|
666
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
667
|
+
return _GatekeeperClient.getInstance().getQueueInternal(...args);
|
|
668
|
+
}
|
|
669
|
+
static async clearQueue(...args) {
|
|
670
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
671
|
+
return _GatekeeperClient.getInstance().clearQueueInternal(...args);
|
|
672
|
+
}
|
|
673
|
+
static async processEvents(...args) {
|
|
674
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
675
|
+
return _GatekeeperClient.getInstance().processEventsInternal(...args);
|
|
676
|
+
}
|
|
677
|
+
static async addJSON(...args) {
|
|
678
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
679
|
+
return _GatekeeperClient.getInstance().addJSONInternal(...args);
|
|
680
|
+
}
|
|
681
|
+
static async getJSON(...args) {
|
|
682
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
683
|
+
return _GatekeeperClient.getInstance().getJSONInternal(...args);
|
|
684
|
+
}
|
|
685
|
+
static async addText(...args) {
|
|
686
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
687
|
+
return _GatekeeperClient.getInstance().addTextInternal(...args);
|
|
688
|
+
}
|
|
689
|
+
static async getText(...args) {
|
|
690
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
691
|
+
return _GatekeeperClient.getInstance().getTextInternal(...args);
|
|
692
|
+
}
|
|
693
|
+
static async addData(...args) {
|
|
694
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
695
|
+
return _GatekeeperClient.getInstance().addDataInternal(...args);
|
|
696
|
+
}
|
|
697
|
+
static async getData(...args) {
|
|
698
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
699
|
+
return _GatekeeperClient.getInstance().getDataInternal(...args);
|
|
700
|
+
}
|
|
701
|
+
static async getBlock(...args) {
|
|
702
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
703
|
+
return _GatekeeperClient.getInstance().getBlockInternal(...args);
|
|
704
|
+
}
|
|
705
|
+
static async addBlock(...args) {
|
|
706
|
+
_GatekeeperClient.getInstance().ensureInitialized();
|
|
707
|
+
return _GatekeeperClient.getInstance().addBlockInternal(...args);
|
|
708
|
+
}
|
|
709
|
+
static getInstance() {
|
|
710
|
+
if (!_GatekeeperClient.instance) {
|
|
711
|
+
throw new Error(
|
|
712
|
+
"GatekeeperClient not initialized. Call GatekeeperClient.initialize() first."
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
return _GatekeeperClient.instance;
|
|
716
|
+
}
|
|
717
|
+
// -------- Internal instance methods (originals renamed with Internal) -------
|
|
718
|
+
async startInternal() {
|
|
719
|
+
if (this.config) {
|
|
720
|
+
return await this.startIntegratedGatekeeper();
|
|
721
|
+
} else {
|
|
722
|
+
throw "Missing Gatekeeper config";
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
async startIntegratedGatekeeper() {
|
|
726
|
+
try {
|
|
727
|
+
this.gatekeeperClient = new GatekeeperClientMdip();
|
|
728
|
+
await this.gatekeeperClient.connect({
|
|
729
|
+
...this.config
|
|
730
|
+
});
|
|
731
|
+
} catch (e) {
|
|
732
|
+
console.error("Error starting GatekeeperClient service:", e);
|
|
733
|
+
return false;
|
|
734
|
+
}
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
addCustomHeaderInternal(header, value) {
|
|
738
|
+
this.gatekeeperClient.addCustomHeader(header, value);
|
|
739
|
+
}
|
|
740
|
+
removeCustomHeaderInternal(header) {
|
|
741
|
+
this.gatekeeperClient.removeCustomHeader(header);
|
|
742
|
+
}
|
|
743
|
+
async listRegistriesInternal() {
|
|
744
|
+
const response = await this.gatekeeperClient.listRegistries();
|
|
745
|
+
return response;
|
|
746
|
+
}
|
|
747
|
+
async resetDbInternal() {
|
|
748
|
+
return this.gatekeeperClient.resetDb();
|
|
749
|
+
}
|
|
750
|
+
async verifyDbInternal() {
|
|
751
|
+
return this.gatekeeperClient.verifyDb();
|
|
752
|
+
}
|
|
753
|
+
async isReadyInternal() {
|
|
754
|
+
return this.gatekeeperClient.isReady();
|
|
755
|
+
}
|
|
756
|
+
async getVersionInternal() {
|
|
757
|
+
return this.gatekeeperClient.getVersion();
|
|
758
|
+
}
|
|
759
|
+
async getStatusInternal() {
|
|
760
|
+
return this.gatekeeperClient.getStatus();
|
|
761
|
+
}
|
|
762
|
+
async createDIDInternal(operation) {
|
|
763
|
+
return this.gatekeeperClient.createDID(operation);
|
|
764
|
+
}
|
|
765
|
+
async resolveDIDInternal(did, options) {
|
|
766
|
+
const response = await this.gatekeeperClient.resolveDID(did, options);
|
|
767
|
+
return response;
|
|
768
|
+
}
|
|
769
|
+
async updateDIDInternal(operation) {
|
|
770
|
+
return this.gatekeeperClient.updateDID(operation);
|
|
771
|
+
}
|
|
772
|
+
async deleteDIDInternal(operation) {
|
|
773
|
+
return this.gatekeeperClient.deleteDID(operation);
|
|
774
|
+
}
|
|
775
|
+
async getDIDsInternal({
|
|
776
|
+
dids,
|
|
777
|
+
resolve
|
|
778
|
+
}) {
|
|
779
|
+
const response = await this.gatekeeperClient.getDIDs({ dids, resolve });
|
|
780
|
+
return response;
|
|
781
|
+
}
|
|
782
|
+
async exportDIDsInternal(dids) {
|
|
783
|
+
return this.gatekeeperClient.exportDIDs(dids);
|
|
784
|
+
}
|
|
785
|
+
async importDIDsInternal(dids) {
|
|
786
|
+
return this.gatekeeperClient.importDIDs(dids);
|
|
787
|
+
}
|
|
788
|
+
async exportBatchInternal(dids) {
|
|
789
|
+
return this.gatekeeperClient.exportBatch(dids);
|
|
790
|
+
}
|
|
791
|
+
async importBatchInternal(batch) {
|
|
792
|
+
return this.gatekeeperClient.importBatch(batch);
|
|
793
|
+
}
|
|
794
|
+
async removeDIDsInternal(dids) {
|
|
795
|
+
return this.gatekeeperClient.removeDIDs(dids);
|
|
796
|
+
}
|
|
797
|
+
async getQueueInternal(registry) {
|
|
798
|
+
return this.gatekeeperClient.getQueue(registry);
|
|
799
|
+
}
|
|
800
|
+
async clearQueueInternal(registry, events) {
|
|
801
|
+
return this.gatekeeperClient.clearQueue(registry, events);
|
|
802
|
+
}
|
|
803
|
+
async processEventsInternal() {
|
|
804
|
+
return this.gatekeeperClient.processEvents();
|
|
805
|
+
}
|
|
806
|
+
async addJSONInternal(data) {
|
|
807
|
+
return this.gatekeeperClient.addJSON(data);
|
|
808
|
+
}
|
|
809
|
+
async getJSONInternal(cid) {
|
|
810
|
+
return this.gatekeeperClient.getJSON(cid);
|
|
811
|
+
}
|
|
812
|
+
async addTextInternal(data) {
|
|
813
|
+
return this.gatekeeperClient.addText(data);
|
|
814
|
+
}
|
|
815
|
+
async getTextInternal(cid) {
|
|
816
|
+
return this.gatekeeperClient.getText(cid);
|
|
817
|
+
}
|
|
818
|
+
async addDataInternal(data) {
|
|
819
|
+
return this.gatekeeperClient.addData(data);
|
|
820
|
+
}
|
|
821
|
+
async getDataInternal(cid) {
|
|
822
|
+
return this.gatekeeperClient.getData(cid);
|
|
823
|
+
}
|
|
824
|
+
async getBlockInternal(registry, block) {
|
|
825
|
+
return this.gatekeeperClient.getBlock(registry, block);
|
|
826
|
+
}
|
|
827
|
+
async addBlockInternal(registry, block) {
|
|
828
|
+
return this.gatekeeperClient.addBlock(registry, block);
|
|
829
|
+
}
|
|
830
|
+
validateConfig(config) {
|
|
831
|
+
if (!config) {
|
|
832
|
+
throw new Error("Missing Gatekeeper config");
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
|
|
560
837
|
// src/index.ts
|
|
561
838
|
export * from "@mdip/keymaster";
|
|
562
839
|
export {
|
|
840
|
+
GatekeeperClient2 as GatekeeperClient,
|
|
563
841
|
Keymaster,
|
|
564
842
|
KeymasterExternalClient
|
|
565
843
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/keymaster.ts","../src/keymasterClient.ts","../src/index.ts"],"sourcesContent":["// Imports\nimport { default as GatekeeperClient } from \"@mdip/gatekeeper/client\";\nimport { default as CipherNode } from \"@mdip/cipher/node\";\nimport { default as KeymasterLib } from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n WalletConfig,\n} from \"./types/index.js\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n CreateResponseOptions,\n IssueCredentialsOptions,\n StoredWallet,\n VerifiableCredential,\n WalletBase,\n WalletFile,\n} from \"@mdip/keymaster\";\nimport type { MdipDocument, ResolveDIDOptions } from \"@mdip/gatekeeper\";\n\n// Keymaster configuration interface\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n walletConfig?: WalletConfig;\n}\n\nexport class Keymaster {\n private static instance: Keymaster | null = null;\n\n private config: KeymasterConfig;\n private keymasterService!: KeymasterLib;\n private serviceStarted = false;\n\n private constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n // Initializes the instance if not already initialized\n /**\n * Initializes the Keymaster instance.\n * @param config The configuration object for the Keymaster service.\n */\n public static initialize(config: KeymasterConfig) {\n if (!Keymaster.instance) {\n Keymaster.instance = new Keymaster(config);\n console.log(\"✅ Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n // Ensures the instance is initialized\n private ensureInitialized() {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n\n /**\n * Starts the Keymaster service.\n * @returns A boolean indicating whether the service was started successfully.\n */\n public static async start() {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().startInternal();\n }\n\n // Method to create a challenge\n /**\n * Creates a challenge for the user to solve.\n * @param spec The challenge specifications.\n * @param options Additional options for creating the challenge (optional).\n * @returns A promise with the challenge response, including the challenge and its callback URL.\n */\n public static async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createChallengeInternal(spec, options);\n }\n\n // Method to bind a credential to a user\n /**\n * Binds a credential to a subject.\n * @param schemaId The schema ID for the credential.\n * @param subjectId The subject's DID (Decentralized Identifier).\n * @param options Optional options, such as validity period and credential data.\n * @returns A promise with the verifiable credential that was bound.\n */\n public static async bindCredential(\n schemaId: string,\n subjectId: string,\n options?: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n }\n ): Promise<VerifiableCredential> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().bindCredentialInternal(\n schemaId,\n subjectId,\n options\n );\n }\n\n // Method to create a response\n /**\n * Creates a response for the challenge.\n * @param challengeDID The DID of the challenge to respond to.\n * @param options Optional options for creating the response (optional).\n * @returns A promise with the response string.\n */\n public static async createResponse(\n challengeDID: string,\n options?: CreateResponseOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createResponseInternal(\n challengeDID,\n options\n );\n }\n\n // Backup wallet\n /**\n * Backups the wallet data.\n * @param registry Optional registry URL for the wallet backup.\n * @returns A promise with a backup string (e.g., backup URL).\n */\n public static async backupWallet(registry?: string): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().backupWalletInternal(registry);\n }\n\n // Issue credential to a user\n /**\n * Issues a credential to the subject.\n * @param credential The credential to be issued.\n * @param options Optional parameters for issuing the credential.\n * @returns A promise with the credential ID or issuance result.\n */\n public static async issueCredential(\n credential: Partial<VerifiableCredential>,\n options?: IssueCredentialsOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().issueCredentialInternal(credential, options);\n }\n\n // Publish a credential\n /**\n * Publishes a verifiable credential.\n * @param did The DID of the credential.\n * @param options Optional parameters, such as whether to reveal the credential.\n * @returns A promise with the published credential.\n */\n public static async publishCredential(\n did: string,\n options?: {\n reveal?: boolean;\n }\n ): Promise<VerifiableCredential> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().publishCredentialInternal(did, options);\n }\n\n // Accept a credential\n /**\n * Accepts a credential.\n * @param did The DID of the credential to accept.\n * @returns A promise indicating whether the credential was successfully accepted.\n */\n public static async acceptCredential(did: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().acceptCredentialInternal(did);\n }\n\n // Show mnemonic\n /**\n * Shows the mnemonic for the wallet.\n * @returns A promise with the mnemonic string.\n */\n public static async showMnemonic(): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().showMnemonicInternal();\n }\n\n // Verify a challenge response\n /**\n * Verifies a response to a challenge.\n * @param did The DID to verify the response for.\n * @param options Optional options, such as retry behavior.\n * @returns A promise with the response verification result.\n */\n public static async verifyResponse(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().verifyResponseInternal(did, options);\n }\n\n // Decrypt a message\n /**\n * Decrypts a message using the current key.\n * @param did The DID of the message to decrypt.\n * @returns A promise with the decrypted message.\n */\n public static async decryptMessage(did: string): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMessageInternal(did);\n }\n\n // Decrypt mnemonic\n /**\n * Decrypts the mnemonic for the wallet.\n * @returns A promise with the decrypted mnemonic.\n */\n public static async decryptMnemonic(): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMnemonicInternal();\n }\n\n // Get a credential\n /**\n * Retrieves a verifiable credential.\n * @param id The credential ID to retrieve.\n * @returns A promise with the credential data or null if not found.\n */\n public static async getCredential(\n id: string\n ): Promise<VerifiableCredential | null> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().getCredentialInternal(id);\n }\n\n // Remove a credential\n /**\n * Removes a verifiable credential.\n * @param id The credential ID to remove.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async removeCredential(id: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeCredentialInternal(id);\n }\n\n // Update a credential\n /**\n * Updates a verifiable credential.\n * @param did The DID of the credential to update.\n * @param credential The new credential data.\n * @returns A promise indicating success or failure of the update operation.\n */\n public static async updateCredential(\n did: string,\n credential: VerifiableCredential\n ): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().updateCredentialInternal(did, credential);\n }\n\n // Method to create an ID\n /**\n * Creates a new DID (Decentralized Identifier).\n * @param name The name for the DID.\n * @param options Optional options, such as registry URL.\n * @returns A promise with the newly created DID.\n */\n public static async createId(\n name: string,\n options?: {\n registry?: string;\n }\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createIdInternal(name, options);\n }\n\n // Remove an ID\n /**\n * Removes an existing DID.\n * @param name The name of the DID to remove.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async removeId(name: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeIdInternal(name);\n }\n\n // Resolve a DID\n /**\n * Resolves a DID to fetch associated data.\n * @param did The DID to resolve.\n * @param options Optional parameters for resolving the DID.\n * @returns A promise with the resolved DID data.\n */\n public static async resolveDID(\n did: string,\n options?: ResolveDIDOptions\n ): Promise<MdipDocument> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().resolveDIDInternal(did, options);\n }\n\n // Set the current DID\n /**\n * Sets the current DID in use.\n * @param name The DID name to set as the current one.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async setCurrentId(name: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setCurrentIdInternal(name);\n }\n\n // Create a schema\n /**\n * Creates a new schema for credentials.\n * @param schema The schema data to create.\n * @param options Optional options for creating the schema.\n * @returns A promise with the created schema data.\n */\n public static async createSchema(\n schema?: unknown,\n options?: CreateAssetOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createSchemaInternal(schema, options);\n }\n\n // Update a schema\n /**\n * Updates an schema for credentials given a schemaDID.\n * @param id The ID of the schema to update.\n * @param schema The schema data to update.\n * @returns A promise with a boolean.\n */\n public static async updateSchema(\n id: string,\n schema?: unknown\n ): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setSchemaInternal(id, schema);\n }\n\n // Create a new wallet\n /**\n * Creates a new wallet.\n * @param mnemonic Optional mnemonic to initialize the wallet.\n * @param overwrite Optional flag to overwrite the existing wallet.\n * @returns A promise with the wallet creation result.\n */\n public static async newWallet(\n mnemonic?: string,\n overwrite?: boolean\n ): Promise<WalletFile> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().newWalletInternal(mnemonic, overwrite);\n }\n\n // Recover an existing wallet\n /**\n * Recovers a wallet from a backup.\n * @param did The DID to use for recovery (optional).\n * @returns A promise with the wallet recovery result.\n */\n public static async recoverWallet(did?: string): Promise<WalletFile> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().recoverWalletInternal(did);\n }\n\n // Helper method to retrieve the instance\n private static getInstance(): Keymaster {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return Keymaster.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async ensureServiceIsRunning() {\n if (!(await this.serviceRunning())) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n\n private async startIntegratedKeymaster(): Promise<boolean> {\n try {\n if (this.config.walletDb) {\n const gatekeeper = await GatekeeperClient.create({\n url: this.config.gatekeeperConfig?.url,\n waitUntilReady: this.config.gatekeeperConfig?.waitUntilReady,\n intervalSeconds: this.config.gatekeeperConfig?.intervalSeconds,\n chatty: this.config.gatekeeperConfig?.chatty,\n });\n\n const cipher = new CipherNode();\n this.keymasterService = new KeymasterLib({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher,\n });\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n\n console.log(\"✅ Keymaster Started\");\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n await this.ensureServiceIsRunning();\n const challenge: string = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n private async bindCredentialInternal(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n private async createResponseInternal(\n challengeDID: string,\n options?: CreateResponseOptions\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createResponse(challengeDID, options);\n }\n\n private async backupWalletInternal(registry?: string): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.backupWallet(registry);\n }\n\n private async issueCredentialInternal(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n\n private async publishCredentialInternal(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n\n private async acceptCredentialInternal(did: string): Promise<boolean> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<KeymasterLib[\"decryptMessage\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal(\n ...args: Parameters<KeymasterLib[\"decryptMnemonic\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n\n private async getCredentialInternal(\n ...args: Parameters<KeymasterLib[\"getCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<KeymasterLib[\"removeCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<KeymasterLib[\"updateCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<KeymasterLib[\"createId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<KeymasterLib[\"removeId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<KeymasterLib[\"resolveDID\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<KeymasterLib[\"setCurrentId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<KeymasterLib[\"createSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n\n private async setSchemaInternal(\n ...args: Parameters<KeymasterLib[\"setSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<KeymasterLib[\"newWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<KeymasterLib[\"recoverWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n\n private async ensureWalletExists(): Promise<void> {\n const existing: StoredWallet | null =\n (await this.config?.walletDb?.loadWallet()) || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n\n const walletConfig = this.config.walletConfig;\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n\n if (walletConfig?.id) {\n await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry,\n });\n }\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.startInternal());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n}\n","import KeymasterClient from \"@mdip/keymaster/client\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n} from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\n\nexport interface KeymasterConfig {\n keymasterConfig?: SdkConfig;\n}\n\nexport class KeymasterExternalClient {\n private config: KeymasterConfig;\n private keymasterService!: KeymasterClient;\n private serviceStarted = false;\n\n constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public async start(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n public async startExternal(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n private async startExternalKeymaster(): Promise<boolean> {\n try {\n this.keymasterService = new KeymasterClient();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n\n return true;\n }\n\n async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge: string = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n async bindCredential(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n async issueCredential(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.issueCredential(credential, options);\n }\n\n async publishCredential(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.publishCredential(did, options);\n }\n\n async acceptCredential(did: string): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.acceptCredential(did);\n }\n\n async showMnemonic(): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n\n async verifyResponse(\n did: string,\n options?: {\n retries?: number;\n delay?: number;\n }\n ): Promise<ChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response: ChallengeResponse =\n await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.start());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n}\n","export { Keymaster, KeymasterConfig } from \"./keymaster.js\";\nexport { KeymasterExternalClient } from \"./keymasterClient.js\";\n\nexport {\n SdkConfig,\n WalletConfig,\n CreateChallengeResponse,\n CreateChallengeSpec,\n} from \"./types/index.js\";\n\nexport * from \"@mdip/keymaster\";\nimport type * as GatekeeperTypes from \"@mdip/gatekeeper\";\n\nexport { GatekeeperTypes };\n"],"mappings":";AACA,SAAS,WAAW,wBAAwB;AAC5C,SAAS,WAAW,kBAAkB;AACtC,SAAS,WAAW,oBAAoB;AA0BjC,IAAM,YAAN,MAAM,WAAU;AAAA,EACrB,OAAe,WAA6B;AAAA,EAEpC;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EA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AM;AAAA,EAClD;AAAA,EAEQ,eAAe,QAA+B;AACpD,QAAI,CAAC,OAAO,iBAAiB;AAC3B,YAAM,IAAI,MAAM,0BAA0B;AAAA,IAC5C;AAAA,EACF;AACF;;;AC7IA,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/keymaster.ts","../src/keymasterClient.ts","../src/gatekepeerClient.ts","../src/index.ts"],"sourcesContent":["// Imports\nimport { default as GatekeeperClient } from \"@mdip/gatekeeper/client\";\nimport { default as CipherNode } from \"@mdip/cipher/node\";\nimport { default as KeymasterLib } from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n WalletConfig,\n} from \"./types/index.js\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n CreateResponseOptions,\n IssueCredentialsOptions,\n StoredWallet,\n VerifiableCredential,\n WalletBase,\n WalletFile,\n} from \"@mdip/keymaster\";\nimport type { MdipDocument, ResolveDIDOptions } from \"@mdip/gatekeeper\";\n\n// Keymaster configuration interface\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n walletConfig?: WalletConfig;\n}\n\nexport class Keymaster {\n private static instance: Keymaster | null = null;\n\n private config: KeymasterConfig;\n private keymasterService!: KeymasterLib;\n private serviceStarted = false;\n\n private constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n // Initializes the instance if not already initialized\n /**\n * Initializes the Keymaster instance.\n * @param config The configuration object for the Keymaster service.\n */\n public static initialize(config: KeymasterConfig) {\n if (!Keymaster.instance) {\n Keymaster.instance = new Keymaster(config);\n console.log(\"✅ Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n // Ensures the instance is initialized\n private ensureInitialized() {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n\n /**\n * Starts the Keymaster service.\n * @returns A boolean indicating whether the service was started successfully.\n */\n public static async start() {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().startInternal();\n }\n\n // Method to create a challenge\n /**\n * Creates a challenge for the user to solve.\n * @param spec The challenge specifications.\n * @param options Additional options for creating the challenge (optional).\n * @returns A promise with the challenge response, including the challenge and its callback URL.\n */\n public static async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createChallengeInternal(spec, options);\n }\n\n // Method to bind a credential to a user\n /**\n * Binds a credential to a subject.\n * @param schemaId The schema ID for the credential.\n * @param subjectId The subject's DID (Decentralized Identifier).\n * @param options Optional options, such as validity period and credential data.\n * @returns A promise with the verifiable credential that was bound.\n */\n public static async bindCredential(\n schemaId: string,\n subjectId: string,\n options?: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n }\n ): Promise<VerifiableCredential> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().bindCredentialInternal(\n schemaId,\n subjectId,\n options\n );\n }\n\n // Method to create a response\n /**\n * Creates a response for the challenge.\n * @param challengeDID The DID of the challenge to respond to.\n * @param options Optional options for creating the response (optional).\n * @returns A promise with the response string.\n */\n public static async createResponse(\n challengeDID: string,\n options?: CreateResponseOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createResponseInternal(\n challengeDID,\n options\n );\n }\n\n // Backup wallet\n /**\n * Backups the wallet data.\n * @param registry Optional registry URL for the wallet backup.\n * @returns A promise with a backup string (e.g., backup URL).\n */\n public static async backupWallet(registry?: string): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().backupWalletInternal(registry);\n }\n\n // Issue credential to a user\n /**\n * Issues a credential to the subject.\n * @param credential The credential to be issued.\n * @param options Optional parameters for issuing the credential.\n * @returns A promise with the credential ID or issuance result.\n */\n public static async issueCredential(\n credential: Partial<VerifiableCredential>,\n options?: IssueCredentialsOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().issueCredentialInternal(credential, options);\n }\n\n // Publish a credential\n /**\n * Publishes a verifiable credential.\n * @param did The DID of the credential.\n * @param options Optional parameters, such as whether to reveal the credential.\n * @returns A promise with the published credential.\n */\n public static async publishCredential(\n did: string,\n options?: {\n reveal?: boolean;\n }\n ): Promise<VerifiableCredential> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().publishCredentialInternal(did, options);\n }\n\n // Accept a credential\n /**\n * Accepts a credential.\n * @param did The DID of the credential to accept.\n * @returns A promise indicating whether the credential was successfully accepted.\n */\n public static async acceptCredential(did: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().acceptCredentialInternal(did);\n }\n\n // Show mnemonic\n /**\n * Shows the mnemonic for the wallet.\n * @returns A promise with the mnemonic string.\n */\n public static async showMnemonic(): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().showMnemonicInternal();\n }\n\n // Verify a challenge response\n /**\n * Verifies a response to a challenge.\n * @param did The DID to verify the response for.\n * @param options Optional options, such as retry behavior.\n * @returns A promise with the response verification result.\n */\n public static async verifyResponse(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().verifyResponseInternal(did, options);\n }\n\n // Decrypt a message\n /**\n * Decrypts a message using the current key.\n * @param did The DID of the message to decrypt.\n * @returns A promise with the decrypted message.\n */\n public static async decryptMessage(did: string): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMessageInternal(did);\n }\n\n // Decrypt mnemonic\n /**\n * Decrypts the mnemonic for the wallet.\n * @returns A promise with the decrypted mnemonic.\n */\n public static async decryptMnemonic(): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMnemonicInternal();\n }\n\n // Get a credential\n /**\n * Retrieves a verifiable credential.\n * @param id The credential ID to retrieve.\n * @returns A promise with the credential data or null if not found.\n */\n public static async getCredential(\n id: string\n ): Promise<VerifiableCredential | null> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().getCredentialInternal(id);\n }\n\n // Remove a credential\n /**\n * Removes a verifiable credential.\n * @param id The credential ID to remove.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async removeCredential(id: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeCredentialInternal(id);\n }\n\n // Update a credential\n /**\n * Updates a verifiable credential.\n * @param did The DID of the credential to update.\n * @param credential The new credential data.\n * @returns A promise indicating success or failure of the update operation.\n */\n public static async updateCredential(\n did: string,\n credential: VerifiableCredential\n ): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().updateCredentialInternal(did, credential);\n }\n\n // Method to create an ID\n /**\n * Creates a new DID (Decentralized Identifier).\n * @param name The name for the DID.\n * @param options Optional options, such as registry URL.\n * @returns A promise with the newly created DID.\n */\n public static async createId(\n name: string,\n options?: {\n registry?: string;\n }\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createIdInternal(name, options);\n }\n\n // Remove an ID\n /**\n * Removes an existing DID.\n * @param name The name of the DID to remove.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async removeId(name: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeIdInternal(name);\n }\n\n // Resolve a DID\n /**\n * Resolves a DID to fetch associated data.\n * @param did The DID to resolve.\n * @param options Optional parameters for resolving the DID.\n * @returns A promise with the resolved DID data.\n */\n public static async resolveDID(\n did: string,\n options?: ResolveDIDOptions\n ): Promise<MdipDocument> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().resolveDIDInternal(did, options);\n }\n\n // Set the current DID\n /**\n * Sets the current DID in use.\n * @param name The DID name to set as the current one.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async setCurrentId(name: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setCurrentIdInternal(name);\n }\n\n // Create a schema\n /**\n * Creates a new schema for credentials.\n * @param schema The schema data to create.\n * @param options Optional options for creating the schema.\n * @returns A promise with the created schema data.\n */\n public static async createSchema(\n schema?: unknown,\n options?: CreateAssetOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createSchemaInternal(schema, options);\n }\n\n // Update a schema\n /**\n * Updates an schema for credentials given a schemaDID.\n * @param id The ID of the schema to update.\n * @param schema The schema data to update.\n * @returns A promise with a boolean.\n */\n public static async updateSchema(\n id: string,\n schema?: unknown\n ): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setSchemaInternal(id, schema);\n }\n\n // Create a new wallet\n /**\n * Creates a new wallet.\n * @param mnemonic Optional mnemonic to initialize the wallet.\n * @param overwrite Optional flag to overwrite the existing wallet.\n * @returns A promise with the wallet creation result.\n */\n public static async newWallet(\n mnemonic?: string,\n overwrite?: boolean\n ): Promise<WalletFile> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().newWalletInternal(mnemonic, overwrite);\n }\n\n // Recover an existing wallet\n /**\n * Recovers a wallet from a backup.\n * @param did The DID to use for recovery (optional).\n * @returns A promise with the wallet recovery result.\n */\n public static async recoverWallet(did?: string): Promise<WalletFile> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().recoverWalletInternal(did);\n }\n\n // Helper method to retrieve the instance\n private static getInstance(): Keymaster {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return Keymaster.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async ensureServiceIsRunning() {\n if (!(await this.serviceRunning())) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n\n private async startIntegratedKeymaster(): Promise<boolean> {\n try {\n if (this.config.walletDb) {\n const gatekeeper = await GatekeeperClient.create({\n url: this.config.gatekeeperConfig?.url,\n waitUntilReady: this.config.gatekeeperConfig?.waitUntilReady,\n intervalSeconds: this.config.gatekeeperConfig?.intervalSeconds,\n chatty: this.config.gatekeeperConfig?.chatty,\n });\n\n const cipher = new CipherNode();\n this.keymasterService = new KeymasterLib({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher,\n });\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n\n console.log(\"✅ Keymaster Started\");\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n await this.ensureServiceIsRunning();\n const challenge: string = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n private async bindCredentialInternal(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n private async createResponseInternal(\n challengeDID: string,\n options?: CreateResponseOptions\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createResponse(challengeDID, options);\n }\n\n private async backupWalletInternal(registry?: string): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.backupWallet(registry);\n }\n\n private async issueCredentialInternal(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n\n private async publishCredentialInternal(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n\n private async acceptCredentialInternal(did: string): Promise<boolean> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<KeymasterLib[\"decryptMessage\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal(\n ...args: Parameters<KeymasterLib[\"decryptMnemonic\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n\n private async getCredentialInternal(\n ...args: Parameters<KeymasterLib[\"getCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<KeymasterLib[\"removeCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<KeymasterLib[\"updateCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<KeymasterLib[\"createId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<KeymasterLib[\"removeId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<KeymasterLib[\"resolveDID\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<KeymasterLib[\"setCurrentId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<KeymasterLib[\"createSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n\n private async setSchemaInternal(\n ...args: Parameters<KeymasterLib[\"setSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<KeymasterLib[\"newWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<KeymasterLib[\"recoverWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n\n private async ensureWalletExists(): Promise<void> {\n const existing: StoredWallet | null =\n (await this.config?.walletDb?.loadWallet()) || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n\n const walletConfig = this.config.walletConfig;\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n\n if (walletConfig?.id) {\n await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry,\n });\n }\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.startInternal());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n}\n","import KeymasterClient from \"@mdip/keymaster/client\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n} from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\n\nexport interface KeymasterConfig {\n keymasterConfig?: SdkConfig;\n}\n\nexport class KeymasterExternalClient {\n private config: KeymasterConfig;\n private keymasterService!: KeymasterClient;\n private serviceStarted = false;\n\n constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public async start(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n public async startExternal(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n private async startExternalKeymaster(): Promise<boolean> {\n try {\n this.keymasterService = new KeymasterClient();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n\n return true;\n }\n\n async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge: string = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n async bindCredential(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n async issueCredential(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.issueCredential(credential, options);\n }\n\n async publishCredential(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.publishCredential(did, options);\n }\n\n async acceptCredential(did: string): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.acceptCredential(did);\n }\n\n async showMnemonic(): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n\n async verifyResponse(\n did: string,\n options?: {\n retries?: number;\n delay?: number;\n }\n ): Promise<ChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response: ChallengeResponse =\n await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.start());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n}\n","import {\n GatekeeperClient as GatekeeperClientMdip,\n MdipDocument,\n GetDIDOptions,\n VerifyDbResult,\n GetStatusResult,\n Operation,\n ResolveDIDOptions,\n GatekeeperEvent,\n ImportBatchResult,\n ProcessEventsResult,\n BlockId,\n BlockInfo,\n GatekeeperClientOptions,\n} from \"@mdip/gatekeeper\";\n\nexport class GatekeeperClient {\n private static instance: GatekeeperClient | null = null;\n\n private config: GatekeeperClientOptions;\n private gatekeeperClient!: GatekeeperClientMdip;\n\n private constructor(config: GatekeeperClientOptions) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public static initialize(config: GatekeeperClientOptions) {\n if (!GatekeeperClient.instance) {\n GatekeeperClient.instance = new GatekeeperClient(config);\n } else {\n console.warn(\n \"GatekeeperClient already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n private ensureInitialized() {\n if (!GatekeeperClient.instance) {\n throw new Error(\n \"GatekeeperClient not initialized. Call GatekeeperClient.initialize() first.\"\n );\n }\n }\n\n // Delegated STATIC methods\n\n public static async start() {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().startInternal();\n }\n\n public static addCustomHeader(\n ...args: Parameters<GatekeeperClient[\"addCustomHeaderInternal\"]>\n ): void {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().addCustomHeaderInternal(...args);\n }\n\n public static removeCustomHeader(\n ...args: Parameters<GatekeeperClient[\"removeCustomHeaderInternal\"]>\n ): void {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().removeCustomHeaderInternal(...args);\n }\n\n public static async listRegistries(\n ...args: Parameters<GatekeeperClient[\"listRegistriesInternal\"]>\n ) {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().listRegistriesInternal(...args);\n }\n\n public static async resetDb(): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().resetDbInternal();\n }\n\n public static async verifyDb(): Promise<VerifyDbResult> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().verifyDbInternal();\n }\n\n public static async isReady(): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().isReadyInternal();\n }\n\n public static async getVersion(): Promise<number> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getVersionInternal();\n }\n\n public static async getStatus(): Promise<GetStatusResult> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getStatusInternal();\n }\n\n public static async createDID(\n ...args: Parameters<GatekeeperClient[\"createDIDInternal\"]>\n ): Promise<string> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().createDIDInternal(...args);\n }\n\n public static async resolveDID(\n ...args: Parameters<GatekeeperClient[\"resolveDIDInternal\"]>\n ): Promise<MdipDocument> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().resolveDIDInternal(...args);\n }\n\n public static async updateDID(\n ...args: Parameters<GatekeeperClient[\"updateDIDInternal\"]>\n ): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().updateDIDInternal(...args);\n }\n\n public static async deleteDID(\n ...args: Parameters<GatekeeperClient[\"deleteDIDInternal\"]>\n ): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().deleteDIDInternal(...args);\n }\n\n public static async getDIDs(\n ...args: Parameters<GatekeeperClient[\"getDIDsInternal\"]>\n ): Promise<string[] | MdipDocument[]> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getDIDsInternal(...args);\n }\n\n public static async exportDIDs(\n ...args: Parameters<GatekeeperClient[\"exportDIDsInternal\"]>\n ): Promise<GatekeeperEvent[][]> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().exportDIDsInternal(...args);\n }\n\n public static async importDIDs(\n ...args: Parameters<GatekeeperClient[\"importDIDsInternal\"]>\n ): Promise<ImportBatchResult> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().importDIDsInternal(...args);\n }\n\n public static async exportBatch(\n ...args: Parameters<GatekeeperClient[\"exportBatchInternal\"]>\n ): Promise<GatekeeperEvent[]> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().exportBatchInternal(...args);\n }\n\n public static async importBatch(\n ...args: Parameters<GatekeeperClient[\"importBatchInternal\"]>\n ): Promise<ImportBatchResult> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().importBatchInternal(...args);\n }\n\n public static async removeDIDs(\n ...args: Parameters<GatekeeperClient[\"removeDIDsInternal\"]>\n ): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().removeDIDsInternal(...args);\n }\n\n public static async getQueue(\n ...args: Parameters<GatekeeperClient[\"getQueueInternal\"]>\n ): Promise<Operation[]> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getQueueInternal(...args);\n }\n\n public static async clearQueue(\n ...args: Parameters<GatekeeperClient[\"clearQueueInternal\"]>\n ): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().clearQueueInternal(...args);\n }\n\n public static async processEvents(\n ...args: Parameters<GatekeeperClient[\"processEventsInternal\"]>\n ): Promise<ProcessEventsResult> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().processEventsInternal(...args);\n }\n\n public static async addJSON(\n ...args: Parameters<GatekeeperClient[\"addJSONInternal\"]>\n ): Promise<string> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().addJSONInternal(...args);\n }\n\n public static async getJSON(\n ...args: Parameters<GatekeeperClient[\"getJSONInternal\"]>\n ): Promise<object> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getJSONInternal(...args);\n }\n\n public static async addText(\n ...args: Parameters<GatekeeperClient[\"addTextInternal\"]>\n ): Promise<string> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().addTextInternal(...args);\n }\n\n public static async getText(\n ...args: Parameters<GatekeeperClient[\"getTextInternal\"]>\n ): Promise<string> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getTextInternal(...args);\n }\n\n public static async addData(\n ...args: Parameters<GatekeeperClient[\"addDataInternal\"]>\n ): Promise<string> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().addDataInternal(...args);\n }\n\n public static async getData(\n ...args: Parameters<GatekeeperClient[\"getDataInternal\"]>\n ): Promise<Buffer> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getDataInternal(...args);\n }\n\n public static async getBlock(\n ...args: Parameters<GatekeeperClient[\"getBlockInternal\"]>\n ): Promise<BlockInfo | null> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().getBlockInternal(...args);\n }\n\n public static async addBlock(\n ...args: Parameters<GatekeeperClient[\"addBlockInternal\"]>\n ): Promise<boolean> {\n GatekeeperClient.getInstance().ensureInitialized();\n return GatekeeperClient.getInstance().addBlockInternal(...args);\n }\n\n private static getInstance(): GatekeeperClient {\n if (!GatekeeperClient.instance) {\n throw new Error(\n \"GatekeeperClient not initialized. Call GatekeeperClient.initialize() first.\"\n );\n }\n return GatekeeperClient.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async startInternal(): Promise<boolean> {\n if (this.config) {\n return await this.startIntegratedGatekeeper();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n }\n\n private async startIntegratedGatekeeper(): Promise<boolean> {\n try {\n this.gatekeeperClient = new GatekeeperClientMdip();\n await this.gatekeeperClient.connect({\n ...this.config,\n });\n } catch (e) {\n console.error(\"Error starting GatekeeperClient service:\", e);\n return false;\n }\n return true;\n }\n\n private addCustomHeaderInternal(header: string, value: string): void {\n this.gatekeeperClient.addCustomHeader(header, value);\n }\n\n private removeCustomHeaderInternal(header: string): void {\n this.gatekeeperClient.removeCustomHeader(header);\n }\n\n private async listRegistriesInternal(): Promise<string[]> {\n const response = await this.gatekeeperClient.listRegistries();\n return response;\n }\n\n private async resetDbInternal(): Promise<boolean> {\n return this.gatekeeperClient.resetDb();\n }\n\n private async verifyDbInternal(): Promise<VerifyDbResult> {\n return this.gatekeeperClient.verifyDb();\n }\n\n private async isReadyInternal(): Promise<boolean> {\n return this.gatekeeperClient.isReady();\n }\n\n private async getVersionInternal(): Promise<number> {\n return this.gatekeeperClient.getVersion();\n }\n\n private async getStatusInternal(): Promise<GetStatusResult> {\n return this.gatekeeperClient.getStatus();\n }\n\n private async createDIDInternal(operation: Operation): Promise<string> {\n return this.gatekeeperClient.createDID(operation);\n }\n\n private async resolveDIDInternal(\n did: string,\n options?: ResolveDIDOptions\n ): Promise<MdipDocument> {\n const response = await this.gatekeeperClient.resolveDID(did, options);\n return response;\n }\n\n private async updateDIDInternal(operation: Operation): Promise<boolean> {\n return this.gatekeeperClient.updateDID(operation);\n }\n\n private async deleteDIDInternal(operation: Operation): Promise<boolean> {\n return this.gatekeeperClient.deleteDID(operation);\n }\n\n private async getDIDsInternal({\n dids,\n resolve,\n }: GetDIDOptions): Promise<string[] | MdipDocument[]> {\n const response = await this.gatekeeperClient.getDIDs({ dids, resolve });\n return response;\n }\n\n private async exportDIDsInternal(\n dids?: string[]\n ): Promise<GatekeeperEvent[][]> {\n return this.gatekeeperClient.exportDIDs(dids);\n }\n\n private async importDIDsInternal(\n dids: GatekeeperEvent[][]\n ): Promise<ImportBatchResult> {\n return this.gatekeeperClient.importDIDs(dids);\n }\n\n private async exportBatchInternal(\n dids?: string[]\n ): Promise<GatekeeperEvent[]> {\n return this.gatekeeperClient.exportBatch(dids);\n }\n\n private async importBatchInternal(\n batch: GatekeeperEvent[]\n ): Promise<ImportBatchResult> {\n return this.gatekeeperClient.importBatch(batch);\n }\n\n private async removeDIDsInternal(dids: string[]): Promise<boolean> {\n return this.gatekeeperClient.removeDIDs(dids);\n }\n\n private async getQueueInternal(registry: string): Promise<Operation[]> {\n return this.gatekeeperClient.getQueue(registry);\n }\n\n private async clearQueueInternal(\n registry: string,\n events: Operation[]\n ): Promise<boolean> {\n return this.gatekeeperClient.clearQueue(registry, events);\n }\n\n private async processEventsInternal(): Promise<ProcessEventsResult> {\n return this.gatekeeperClient.processEvents();\n }\n\n private async addJSONInternal(data: object): Promise<string> {\n return this.gatekeeperClient.addJSON(data);\n }\n\n private async getJSONInternal(cid: string): Promise<object> {\n return this.gatekeeperClient.getJSON(cid);\n }\n\n private async addTextInternal(data: string): Promise<string> {\n return this.gatekeeperClient.addText(data);\n }\n\n private async getTextInternal(cid: string): Promise<string> {\n return this.gatekeeperClient.getText(cid);\n }\n\n private async addDataInternal(data: Buffer): Promise<string> {\n return this.gatekeeperClient.addData(data);\n }\n\n private async getDataInternal(cid: string): Promise<Buffer> {\n return this.gatekeeperClient.getData(cid);\n }\n\n private async getBlockInternal(\n registry: string,\n block?: BlockId\n ): Promise<BlockInfo | null> {\n return this.gatekeeperClient.getBlock(registry, block);\n }\n\n private async addBlockInternal(\n registry: string,\n block: BlockInfo\n ): Promise<boolean> {\n return this.gatekeeperClient.addBlock(registry, block);\n }\n\n private validateConfig(config: GatekeeperClientOptions): void {\n if (!config) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n }\n}\n","export { Keymaster, KeymasterConfig } from \"./keymaster.js\";\nexport { KeymasterExternalClient } from \"./keymasterClient.js\";\nexport { GatekeeperClient } from \"./gatekepeerClient.js\";\n\nexport {\n SdkConfig,\n WalletConfig,\n CreateChallengeResponse,\n CreateChallengeSpec,\n} from \"./types/index.js\";\n\nexport * from \"@mdip/keymaster\";\nimport type * as GatekeeperTypes from \"@mdip/gatekeeper\";\n\nexport { GatekeeperTypes };\n"],"mappings":";AACA,SAAS,WAAW,wBAAwB;AAC5C,SAAS,WAAW,kBAAkB;AACtC,SAAS,WAAW,oBAAoB;AA0BjC,IAAM,YAAN,MAAM,WAAU;AAAA,EACrB,OAAe,WAA6B;AAAA,EAEpC;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EAEjB,YAAY,QAAyB;AAC3C,SAAK,eAAe,MAAM;AAC1B,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAc,WAAW,QAAyB;AAChD,QAAI,CAAC,WAAU,UAAU;AACvB,iBAAU,WAAW,IAAI,WAAU,MAAM;AACzC,cAAQ,IAAI,8BAAyB;AAAA,IACvC,OAAO;AACL,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGQ,oBAAoB;AAC1B,QAAI,CAAC,WAAU,UAAU;AACvB,YAAM,IAAI;AAA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
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "A React component library",
|
|
5
5
|
"repository": "https://github.com/selfidhq/siwys-js",
|
|
6
6
|
"type": "module",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"tsup": "^8.3.0",
|
|
42
42
|
"typescript": "4.9.4"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "d375eabcb97259a6bf1e45b9a16acf56be352ded"
|
|
45
45
|
}
|