@yourself_id/siwys-react-native 0.11.0 → 0.11.1-updateMDIPv113.1

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 CHANGED
@@ -38,8 +38,9 @@ __export(index_exports, {
38
38
  module.exports = __toCommonJS(index_exports);
39
39
 
40
40
  // src/keymaster-react-native.ts
41
- var GatekeeperClient = require("@mdip/gatekeeper/client").default;
42
- var KeymasterMDIP = require("@mdip/keymaster").default;
41
+ var import_gatekeeper = require("@mdip/gatekeeper");
42
+ var import_keymaster = __toESM(require("@mdip/keymaster"), 1);
43
+ var Keymaster = import_keymaster.default?.default || import_keymaster.default;
43
44
  var KeymasterReactNative = class _KeymasterReactNative {
44
45
  static instance = null;
45
46
  config;
@@ -345,18 +346,21 @@ var KeymasterReactNative = class _KeymasterReactNative {
345
346
  }
346
347
  async startIntegratedKeymaster() {
347
348
  try {
348
- if (this.config.walletDb) {
349
- const gatekeeper = await GatekeeperClient.create({
349
+ if (this.config.walletDb && this.config.cipher) {
350
+ const gatekeeper = new import_gatekeeper.GatekeeperClient();
351
+ await gatekeeper.connect({
350
352
  url: this.config.gatekeeperConfig?.url,
351
353
  waitUntilReady: this.config.gatekeeperConfig?.waitUntilReady,
352
354
  intervalSeconds: this.config.gatekeeperConfig?.intervalSeconds,
353
355
  chatty: this.config.gatekeeperConfig?.chatty
354
356
  });
355
- this.keymasterService = new KeymasterMDIP({
357
+ console.log("Gatekeeper client created:", gatekeeper);
358
+ this.keymasterService = new Keymaster({
356
359
  gatekeeper,
357
360
  wallet: this.config.walletDb,
358
361
  cipher: this.config.cipher
359
362
  });
363
+ console.log("Kyemaster client created:", this.keymasterService);
360
364
  } else {
361
365
  return false;
362
366
  }
@@ -452,7 +456,7 @@ var KeymasterReactNative = class _KeymasterReactNative {
452
456
  };
453
457
 
454
458
  // src/gatekeeper-react-native.ts
455
- var GatekeeperClient2 = require("@mdip/gatekeeper/client").default;
459
+ var import_gatekeeper2 = require("@mdip/gatekeeper");
456
460
  var GatekeeperReactNative = class _GatekeeperReactNative {
457
461
  static instance = null;
458
462
  config;
@@ -504,7 +508,8 @@ var GatekeeperReactNative = class _GatekeeperReactNative {
504
508
  }
505
509
  async startIntegratedGatekeeper() {
506
510
  try {
507
- this.gatekeeperClient = await GatekeeperClient2.create({
511
+ this.gatekeeperClient = new import_gatekeeper2.GatekeeperClient();
512
+ await this.gatekeeperClient.connect({
508
513
  url: this.config?.url,
509
514
  waitUntilReady: this.config?.waitUntilReady,
510
515
  intervalSeconds: this.config?.intervalSeconds,
@@ -521,7 +526,7 @@ var GatekeeperReactNative = class _GatekeeperReactNative {
521
526
  resolve
522
527
  }) {
523
528
  const response = await this.gatekeeperClient.getDIDs({ dids, resolve });
524
- return response.data;
529
+ return response;
525
530
  }
526
531
  validateConfig(config) {
527
532
  if (!config) {
@@ -531,13 +536,13 @@ var GatekeeperReactNative = class _GatekeeperReactNative {
531
536
  };
532
537
 
533
538
  // src/index.ts
534
- __reExport(index_exports, require("@mdip/keymaster/types"), module.exports);
535
- var GatekeeperTypes = __toESM(require("@mdip/gatekeeper/types"), 1);
539
+ __reExport(index_exports, require("@mdip/keymaster"), module.exports);
540
+ var GatekeeperTypes = __toESM(require("@mdip/gatekeeper"), 1);
536
541
  // Annotate the CommonJS export names for ESM import in node:
537
542
  0 && (module.exports = {
538
543
  GatekeeperReactNative,
539
544
  GatekeeperTypes,
540
545
  KeymasterReactNative,
541
- ...require("@mdip/keymaster/types")
546
+ ...require("@mdip/keymaster")
542
547
  });
543
548
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/keymaster-react-native.ts","../src/gatekeeper-react-native.ts"],"sourcesContent":["export {\n KeymasterReactNative,\n KeymasterConfig as KeymasterReactNativeConfig,\n} from \"./keymaster-react-native.js\";\nexport { GatekeeperReactNative } from \"./gatekeeper-react-native.js\";\n\nexport {\n SdkConfig,\n WalletConfig,\n CreateChallengeResponse,\n CreateChallengeSpec,\n} from \"./types/index.js\";\n\nexport * from \"@mdip/keymaster/types\";\nimport * as GatekeeperTypes from \"@mdip/gatekeeper/types\";\n\nexport { GatekeeperTypes };\n","// Imports\nconst GatekeeperClient = require(\"@mdip/gatekeeper/client\").default;\nconst KeymasterMDIP = require(\"@mdip/keymaster\").default;\nimport { default as KeymasterLib } from \"@mdip/keymaster\";\nimport { Cipher } from \"@mdip/cipher/types\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n CreateResponseOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n WalletBase,\n WalletFile,\n} from \"@mdip/keymaster/types\";\nimport { MdipDocument, ResolveDIDOptions } from \"@mdip/gatekeeper/types\";\n\n// Keymaster configuration interface\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n cipher?: Cipher;\n}\n\nexport class KeymasterReactNative {\n private static instance: KeymasterReactNative | null = null;\n private config: KeymasterConfig;\n private keymasterService!: KeymasterLib;\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 KeymasterReactNative instance.\n * @param config The configuration object for the Keymaster service.\n */\n public static initialize(config: KeymasterConfig): void {\n if (!KeymasterReactNative.instance) {\n KeymasterReactNative.instance = new KeymasterReactNative(config);\n } else {\n console.warn(\n \"KeymasterReactNative already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n // Ensures the instance is initialized\n private ensureInitialized(): void {\n if (!KeymasterReactNative.instance) {\n throw new Error(\n \"KeymasterReactNative not initialized. Call KeymasterReactNative.initialize() first.\"\n );\n }\n }\n\n /**\n * Starts the KeymasterReactNative service.\n * @returns A boolean indicating whether the service was started successfully.\n */\n public static async start(): Promise<boolean> {\n KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().createChallengeInternal(\n spec,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().issueCredentialInternal(\n credential,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().publishCredentialInternal(\n did,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().verifyResponseInternal(\n did,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().updateCredentialInternal(\n did,\n credential\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().createSchemaInternal(\n schema,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().newWalletInternal(\n mnemonic,\n overwrite\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().recoverWalletInternal(did);\n }\n\n // Helper method to retrieve the instance\n private static getInstance(): KeymasterReactNative {\n if (!KeymasterReactNative.instance) {\n throw new Error(\n \"KeymasterReactNative not initialized. Call KeymasterReactNative.initialize() first.\"\n );\n }\n return KeymasterReactNative.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n return await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\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 this.keymasterService = new KeymasterMDIP({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher: this.config.cipher,\n });\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting KeymasterReactNative service:\", e);\n return false;\n }\n\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\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 ...args: Parameters<KeymasterLib[\"bindCredential\"]>\n ) {\n return this.keymasterService.bindCredential(...args);\n }\n\n private async createResponseInternal(\n ...args: Parameters<KeymasterLib[\"createResponse\"]>\n ) {\n return this.keymasterService.createResponse(...args);\n }\n\n private async backupWalletInternal(registry?: string): Promise<string> {\n return this.keymasterService.backupWallet(registry);\n }\n\n private async issueCredentialInternal(\n ...args: Parameters<KeymasterLib[\"issueCredential\"]>\n ) {\n return this.keymasterService.issueCredential(...args);\n }\n\n private async publishCredentialInternal(\n ...args: Parameters<KeymasterLib[\"publishCredential\"]>\n ) {\n return this.keymasterService.publishCredential(...args);\n }\n\n private async acceptCredentialInternal(\n ...args: Parameters<KeymasterLib[\"acceptCredential\"]>\n ) {\n return this.keymasterService.acceptCredential(...args);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n ...args: Parameters<KeymasterLib[\"verifyResponse\"]>\n ) {\n return this.keymasterService.verifyResponse(...args);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<KeymasterLib[\"decryptMessage\"]>\n ) {\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal() {\n return this.keymasterService.decryptMnemonic();\n }\n\n private async getCredentialInternal(\n ...args: Parameters<KeymasterLib[\"getCredential\"]>\n ) {\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<KeymasterLib[\"removeCredential\"]>\n ) {\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<KeymasterLib[\"updateCredential\"]>\n ) {\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<KeymasterLib[\"createId\"]>\n ) {\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<KeymasterLib[\"removeId\"]>\n ) {\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<KeymasterLib[\"resolveDID\"]>\n ) {\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<KeymasterLib[\"setCurrentId\"]>\n ) {\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<KeymasterLib[\"createSchema\"]>\n ) {\n return this.keymasterService.createSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<KeymasterLib[\"newWallet\"]>\n ) {\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<KeymasterLib[\"recoverWallet\"]>\n ) {\n return this.keymasterService.recoverWallet(...args);\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.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 { SdkConfig } from \"./types/index.js\";\nconst GatekeeperClient = require(\"@mdip/gatekeeper/client\").default;\nimport { GetDIDOptions, MdipDocument } from \"@mdip/gatekeeper/types\";\n\nexport class GatekeeperReactNative {\n private static instance: GatekeeperReactNative | null = null;\n\n private config: SdkConfig;\n private gatekeeperClient!: typeof GatekeeperClient;\n\n private constructor(config: SdkConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public static initialize(config: SdkConfig) {\n if (!GatekeeperReactNative.instance) {\n GatekeeperReactNative.instance = new GatekeeperReactNative(config);\n } else {\n console.warn(\n \"GatekeeperReactNative already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n private ensureInitialized() {\n if (!GatekeeperReactNative.instance) {\n throw new Error(\n \"GatekeeperReactNative not initialized. Call GatekeeperReactNative.initialize() first.\"\n );\n }\n }\n\n // Delegated STATIC methods\n\n public static async start() {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().startInternal();\n }\n\n public static async getDIDs(\n ...args: Parameters<GatekeeperReactNative[\"getDIDsInternal\"]>\n ) {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().getDIDsInternal(...args);\n }\n\n private static getInstance(): GatekeeperReactNative {\n if (!GatekeeperReactNative.instance) {\n throw new Error(\n \"GatekeeperReactNative not initialized. Call GatekeeperReactNative.initialize() first.\"\n );\n }\n return GatekeeperReactNative.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 = await GatekeeperClient.create({\n url: this.config?.url,\n waitUntilReady: this.config?.waitUntilReady,\n intervalSeconds: this.config?.intervalSeconds,\n chatty: this.config?.chatty,\n });\n } catch (e) {\n console.error(\"Error starting GatekeeperReactNative service:\", e);\n return false;\n }\n return true;\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.data;\n }\n\n private validateConfig(config: SdkConfig): void {\n if (!config) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAM,mBAAmB,QAAQ,yBAAyB,EAAE;AAC5D,IAAM,gBAAgB,QAAQ,iBAAiB,EAAE;AA0B1C,IAAM,uBAAN,MAAM,sBAAqB;AAAA,EAChC,OAAe,WAAwC;AAAA,EAC/C;AAAA,EACA;AAAA,EAEA,YAAY,QAAyB;AAC3C,SAAK,eAAe,MAAM;AAC1B,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAc,WAAW,QAA+B;AACtD,QAAI,CAAC,sBAAqB,UAAU;AAClC,4BAAqB,WAAW,IAAI,sBAAqB,MAAM;AAAA,IACjE,OAAO;AACL,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGQ,oBAA0B;AAChC,QAAI,CAAC,sBAAqB,UAAU;AAClC,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAoB,QAA0B;AAC5C,0BAAqB,YAAY,EAAE,kBAAkB;AACrD,WAAO,sBAAqB,YAAY,EAAE,cAAc;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAoB,gBAClB,MACA,SACkC;AAClC,0BAAqB,YAAY,EAAE,kBAAkB;AACrD,WAAO,sBAAqB,YAAY,EAAE;AAAA,MACxC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU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AAA;AAAA,EAIA,MAAc,gBAAkC;AAC9C,QAAI,KAAK,QAAQ;AACf,aAAO,MAAM,KAAK,0BAA0B;AAAA,IAC9C,OAAO;AACL,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,MAAc,4BAA8C;AAC1D,QAAI;AACF,WAAK,mBAAmB,MAAMA,kBAAiB,OAAO;AAAA,QACpD,KAAK,KAAK,QAAQ;AAAA,QAClB,gBAAgB,KAAK,QAAQ;AAAA,QAC7B,iBAAiB,KAAK,QAAQ;AAAA,QAC9B,QAAQ,KAAK,QAAQ;AAAA,MACvB,CAAC;AAAA,IACH,SAAS,GAAG;AACV,cAAQ,MAAM,iDAAiD,CAAC;AAChE,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,gBAAgB;AAAA,IAC5B;AAAA,IACA;AAAA,EACF,GAAsD;AACpD,UAAM,WAAW,MAAM,KAAK,iBAAiB,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACtE,WAAO,SAAS;AAAA,EAClB;AAAA,EAEQ,eAAe,QAAyB;AAC9C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,2BAA2B;AAAA,IAC7C;AAAA,EACF;AACF;;;AFjFA,0BAAc,kCAbd;AAcA,sBAAiC;","names":["GatekeeperClient"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/keymaster-react-native.ts","../src/gatekeeper-react-native.ts"],"sourcesContent":["export {\n KeymasterReactNative,\n KeymasterConfig as KeymasterReactNativeConfig,\n} from \"./keymaster-react-native.js\";\nexport { GatekeeperReactNative } from \"./gatekeeper-react-native.js\";\n\nexport {\n SdkConfig,\n WalletConfig,\n CreateChallengeResponse,\n CreateChallengeSpec,\n} from \"./types/index.js\";\n\nexport * from \"@mdip/keymaster\";\nimport * as GatekeeperTypes from \"@mdip/gatekeeper\";\n\nexport { GatekeeperTypes };\n","// Imports\nimport CipherNode from \"@mdip/cipher\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n CreateResponseOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n WalletBase,\n WalletFile,\n} from \"@mdip/keymaster\";\n\nimport {\n GatekeeperClient,\n MdipDocument,\n ResolveDIDOptions,\n} from \"@mdip/gatekeeper\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\nimport KeymasterModule from \"@mdip/keymaster\";\n\n// @ts-ignore\nconst Keymaster = KeymasterModule?.default || KeymasterModule;\n\n// Keymaster configuration interface\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n cipher?: CipherNode;\n}\nexport class KeymasterReactNative {\n private static instance: KeymasterReactNative | null = null;\n private config: KeymasterConfig;\n private keymasterService!: typeof Keymaster;\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 KeymasterReactNative instance.\n * @param config The configuration object for the Keymaster service.\n */\n public static initialize(config: KeymasterConfig): void {\n if (!KeymasterReactNative.instance) {\n KeymasterReactNative.instance = new KeymasterReactNative(config);\n } else {\n console.warn(\n \"KeymasterReactNative already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n // Ensures the instance is initialized\n private ensureInitialized(): void {\n if (!KeymasterReactNative.instance) {\n throw new Error(\n \"KeymasterReactNative not initialized. Call KeymasterReactNative.initialize() first.\"\n );\n }\n }\n\n /**\n * Starts the KeymasterReactNative service.\n * @returns A boolean indicating whether the service was started successfully.\n */\n public static async start(): Promise<boolean> {\n KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().createChallengeInternal(\n spec,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().issueCredentialInternal(\n credential,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().publishCredentialInternal(\n did,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().verifyResponseInternal(\n did,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().updateCredentialInternal(\n did,\n credential\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().createSchemaInternal(\n schema,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().newWalletInternal(\n mnemonic,\n overwrite\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().recoverWalletInternal(did);\n }\n\n // Helper method to retrieve the instance\n private static getInstance(): KeymasterReactNative {\n if (!KeymasterReactNative.instance) {\n throw new Error(\n \"KeymasterReactNative not initialized. Call KeymasterReactNative.initialize() first.\"\n );\n }\n return KeymasterReactNative.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n return await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n }\n\n private async startIntegratedKeymaster(): Promise<boolean> {\n try {\n if (this.config.walletDb && this.config.cipher) {\n const gatekeeper = new GatekeeperClient();\n await gatekeeper.connect({\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 console.log(\"Gatekeeper client created:\", gatekeeper);\n this.keymasterService = new Keymaster({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher: this.config.cipher,\n });\n console.log(\"Kyemaster client created:\", this.keymasterService);\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting KeymasterReactNative service:\", e);\n return false;\n }\n\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\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 ...args: Parameters<(typeof Keymaster)[\"bindCredential\"]>\n ) {\n return this.keymasterService.bindCredential(...args);\n }\n\n private async createResponseInternal(\n ...args: Parameters<(typeof Keymaster)[\"createResponse\"]>\n ) {\n return this.keymasterService.createResponse(...args);\n }\n\n private async backupWalletInternal(registry?: string): Promise<string> {\n return this.keymasterService.backupWallet(registry);\n }\n\n private async issueCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"issueCredential\"]>\n ) {\n return this.keymasterService.issueCredential(...args);\n }\n\n private async publishCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"publishCredential\"]>\n ) {\n return this.keymasterService.publishCredential(...args);\n }\n\n private async acceptCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"acceptCredential\"]>\n ) {\n return this.keymasterService.acceptCredential(...args);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n ...args: Parameters<(typeof Keymaster)[\"verifyResponse\"]>\n ) {\n return this.keymasterService.verifyResponse(...args);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<(typeof Keymaster)[\"decryptMessage\"]>\n ) {\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal() {\n return this.keymasterService.decryptMnemonic();\n }\n\n private async getCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"getCredential\"]>\n ) {\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"removeCredential\"]>\n ) {\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"updateCredential\"]>\n ) {\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<(typeof Keymaster)[\"createId\"]>\n ) {\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<(typeof Keymaster)[\"removeId\"]>\n ) {\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<(typeof Keymaster)[\"resolveDID\"]>\n ) {\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<(typeof Keymaster)[\"setCurrentId\"]>\n ) {\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<(typeof Keymaster)[\"createSchema\"]>\n ) {\n return this.keymasterService.createSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<(typeof Keymaster)[\"newWallet\"]>\n ) {\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<(typeof Keymaster)[\"recoverWallet\"]>\n ) {\n return this.keymasterService.recoverWallet(...args);\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.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 { SdkConfig } from \"./types/index.js\";\nimport {\n GatekeeperClient,\n MdipDocument,\n GetDIDOptions,\n} from \"@mdip/gatekeeper\";\n\nexport class GatekeeperReactNative {\n private static instance: GatekeeperReactNative | null = null;\n\n private config: SdkConfig;\n private gatekeeperClient!: GatekeeperClient;\n\n private constructor(config: SdkConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public static initialize(config: SdkConfig) {\n if (!GatekeeperReactNative.instance) {\n GatekeeperReactNative.instance = new GatekeeperReactNative(config);\n } else {\n console.warn(\n \"GatekeeperReactNative already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n private ensureInitialized() {\n if (!GatekeeperReactNative.instance) {\n throw new Error(\n \"GatekeeperReactNative not initialized. Call GatekeeperReactNative.initialize() first.\"\n );\n }\n }\n\n // Delegated STATIC methods\n\n public static async start() {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().startInternal();\n }\n\n public static async getDIDs(\n ...args: Parameters<GatekeeperReactNative[\"getDIDsInternal\"]>\n ) {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().getDIDsInternal(...args);\n }\n\n private static getInstance(): GatekeeperReactNative {\n if (!GatekeeperReactNative.instance) {\n throw new Error(\n \"GatekeeperReactNative not initialized. Call GatekeeperReactNative.initialize() first.\"\n );\n }\n return GatekeeperReactNative.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 GatekeeperClient();\n await this.gatekeeperClient.connect({\n url: this.config?.url,\n waitUntilReady: this.config?.waitUntilReady,\n intervalSeconds: this.config?.intervalSeconds,\n chatty: this.config?.chatty,\n });\n } catch (e) {\n console.error(\"Error starting GatekeeperReactNative service:\", e);\n return false;\n }\n return true;\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 validateConfig(config: SdkConfig): void {\n if (!config) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYA,wBAIO;AAMP,uBAA4B;AAG5B,IAAM,YAAY,iBAAAA,SAAiB,WAAW,iBAAAA;AAQvC,IAAM,uBAAN,MAAM,sBAAqB;AAAA,EAChC,OAAe,WAAwC;AAAA,EAC/C;AAAA,EACA;AAAA,EAEA,YAAY,QAAyB;AAC3C,SAAK,eAAe,MAAM;AAC1B,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAc,WAAW,QAA+B;AACtD,QAAI,CAAC,sBAAqB,UAAU;AAClC,4BAAqB,WAAW,IAAI,sBAAqB,MAAM;AAAA,IACjE,OAAO;AACL,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGQ,oBAA0B;AAChC,QAAI,CAAC,sBAAqB,UAAU;AAClC,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAoB,QAA0B;AAC5C,0BAAqB,YAAY,EAAE,kBAAkB;AACrD,WAAO,sBAAqB,YAAY,EAAE,cAAc;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAoB,gBAClB,MACA,SACkC;AAClC,0BAAqB,YAAY,EAAE,kBAAkB;AACrD,WAAO,sBAAqB,YAAY,EAAE;AAAA,MACxC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,aAAoB,eAClB,UACA,WACA,SAK+B;AAC/B,0BAAqB,YAAY,EAAE,kBAAkB;AACrD,WAAO,sBAAqB,YAA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AA;AAAA,EAIA,MAAc,gBAAkC;AAC9C,QAAI,KAAK,QAAQ;AACf,aAAO,MAAM,KAAK,0BAA0B;AAAA,IAC9C,OAAO;AACL,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,MAAc,4BAA8C;AAC1D,QAAI;AACF,WAAK,mBAAmB,IAAI,oCAAiB;AAC7C,YAAM,KAAK,iBAAiB,QAAQ;AAAA,QAClC,KAAK,KAAK,QAAQ;AAAA,QAClB,gBAAgB,KAAK,QAAQ;AAAA,QAC7B,iBAAiB,KAAK,QAAQ;AAAA,QAC9B,QAAQ,KAAK,QAAQ;AAAA,MACvB,CAAC;AAAA,IACH,SAAS,GAAG;AACV,cAAQ,MAAM,iDAAiD,CAAC;AAChE,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,gBAAgB;AAAA,IAC5B;AAAA,IACA;AAAA,EACF,GAAsD;AACpD,UAAM,WAAW,MAAM,KAAK,iBAAiB,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACtE,WAAO;AAAA,EACT;AAAA,EAEQ,eAAe,QAAyB;AAC9C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,2BAA2B;AAAA,IAC7C;AAAA,EACF;AACF;;;AFrFA,0BAAc,4BAbd;AAcA,sBAAiC;","names":["KeymasterModule","import_gatekeeper"]}
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { Cipher } from '@mdip/cipher/types';
2
- import { WalletBase, CreateAssetOptions, VerifiableCredential, CreateResponseOptions, IssueCredentialsOptions, ChallengeResponse, WalletFile } from '@mdip/keymaster/types';
3
- export * from '@mdip/keymaster/types';
4
- import { ResolveDIDOptions, MdipDocument } from '@mdip/gatekeeper/types';
5
- import * as types from '@mdip/gatekeeper/types';
6
- export { types as GatekeeperTypes };
1
+ import CipherNode from '@mdip/cipher';
2
+ import { WalletBase, CreateAssetOptions, VerifiableCredential, CreateResponseOptions, IssueCredentialsOptions, ChallengeResponse, WalletFile } from '@mdip/keymaster';
3
+ export * from '@mdip/keymaster';
4
+ import { ResolveDIDOptions, MdipDocument } from '@mdip/gatekeeper';
5
+ import * as gatekeeper from '@mdip/gatekeeper';
6
+ export { gatekeeper as GatekeeperTypes };
7
7
 
8
8
  interface CreateChallengeSpec {
9
9
  callback: string;
@@ -31,7 +31,7 @@ interface WalletConfig {
31
31
  interface KeymasterConfig {
32
32
  gatekeeperConfig?: SdkConfig;
33
33
  walletDb?: WalletBase;
34
- cipher?: Cipher;
34
+ cipher?: CipherNode;
35
35
  }
36
36
  declare class KeymasterReactNative {
37
37
  private static instance;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { Cipher } from '@mdip/cipher/types';
2
- import { WalletBase, CreateAssetOptions, VerifiableCredential, CreateResponseOptions, IssueCredentialsOptions, ChallengeResponse, WalletFile } from '@mdip/keymaster/types';
3
- export * from '@mdip/keymaster/types';
4
- import { ResolveDIDOptions, MdipDocument } from '@mdip/gatekeeper/types';
5
- import * as types from '@mdip/gatekeeper/types';
6
- export { types as GatekeeperTypes };
1
+ import CipherNode from '@mdip/cipher';
2
+ import { WalletBase, CreateAssetOptions, VerifiableCredential, CreateResponseOptions, IssueCredentialsOptions, ChallengeResponse, WalletFile } from '@mdip/keymaster';
3
+ export * from '@mdip/keymaster';
4
+ import { ResolveDIDOptions, MdipDocument } from '@mdip/gatekeeper';
5
+ import * as gatekeeper from '@mdip/gatekeeper';
6
+ export { gatekeeper as GatekeeperTypes };
7
7
 
8
8
  interface CreateChallengeSpec {
9
9
  callback: string;
@@ -31,7 +31,7 @@ interface WalletConfig {
31
31
  interface KeymasterConfig {
32
32
  gatekeeperConfig?: SdkConfig;
33
33
  walletDb?: WalletBase;
34
- cipher?: Cipher;
34
+ cipher?: CipherNode;
35
35
  }
36
36
  declare class KeymasterReactNative {
37
37
  private static instance;
package/dist/index.js CHANGED
@@ -1,13 +1,9 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // src/keymaster-react-native.ts
9
- var GatekeeperClient = __require("@mdip/gatekeeper/client").default;
10
- var KeymasterMDIP = __require("@mdip/keymaster").default;
2
+ import {
3
+ GatekeeperClient
4
+ } from "@mdip/gatekeeper";
5
+ import KeymasterModule from "@mdip/keymaster";
6
+ var Keymaster = KeymasterModule?.default || KeymasterModule;
11
7
  var KeymasterReactNative = class _KeymasterReactNative {
12
8
  static instance = null;
13
9
  config;
@@ -313,18 +309,21 @@ var KeymasterReactNative = class _KeymasterReactNative {
313
309
  }
314
310
  async startIntegratedKeymaster() {
315
311
  try {
316
- if (this.config.walletDb) {
317
- const gatekeeper = await GatekeeperClient.create({
312
+ if (this.config.walletDb && this.config.cipher) {
313
+ const gatekeeper = new GatekeeperClient();
314
+ await gatekeeper.connect({
318
315
  url: this.config.gatekeeperConfig?.url,
319
316
  waitUntilReady: this.config.gatekeeperConfig?.waitUntilReady,
320
317
  intervalSeconds: this.config.gatekeeperConfig?.intervalSeconds,
321
318
  chatty: this.config.gatekeeperConfig?.chatty
322
319
  });
323
- this.keymasterService = new KeymasterMDIP({
320
+ console.log("Gatekeeper client created:", gatekeeper);
321
+ this.keymasterService = new Keymaster({
324
322
  gatekeeper,
325
323
  wallet: this.config.walletDb,
326
324
  cipher: this.config.cipher
327
325
  });
326
+ console.log("Kyemaster client created:", this.keymasterService);
328
327
  } else {
329
328
  return false;
330
329
  }
@@ -420,7 +419,9 @@ var KeymasterReactNative = class _KeymasterReactNative {
420
419
  };
421
420
 
422
421
  // src/gatekeeper-react-native.ts
423
- var GatekeeperClient2 = __require("@mdip/gatekeeper/client").default;
422
+ import {
423
+ GatekeeperClient as GatekeeperClient2
424
+ } from "@mdip/gatekeeper";
424
425
  var GatekeeperReactNative = class _GatekeeperReactNative {
425
426
  static instance = null;
426
427
  config;
@@ -472,7 +473,8 @@ var GatekeeperReactNative = class _GatekeeperReactNative {
472
473
  }
473
474
  async startIntegratedGatekeeper() {
474
475
  try {
475
- this.gatekeeperClient = await GatekeeperClient2.create({
476
+ this.gatekeeperClient = new GatekeeperClient2();
477
+ await this.gatekeeperClient.connect({
476
478
  url: this.config?.url,
477
479
  waitUntilReady: this.config?.waitUntilReady,
478
480
  intervalSeconds: this.config?.intervalSeconds,
@@ -489,7 +491,7 @@ var GatekeeperReactNative = class _GatekeeperReactNative {
489
491
  resolve
490
492
  }) {
491
493
  const response = await this.gatekeeperClient.getDIDs({ dids, resolve });
492
- return response.data;
494
+ return response;
493
495
  }
494
496
  validateConfig(config) {
495
497
  if (!config) {
@@ -499,8 +501,8 @@ var GatekeeperReactNative = class _GatekeeperReactNative {
499
501
  };
500
502
 
501
503
  // src/index.ts
502
- export * from "@mdip/keymaster/types";
503
- import * as GatekeeperTypes from "@mdip/gatekeeper/types";
504
+ export * from "@mdip/keymaster";
505
+ import * as GatekeeperTypes from "@mdip/gatekeeper";
504
506
  export {
505
507
  GatekeeperReactNative,
506
508
  GatekeeperTypes,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/keymaster-react-native.ts","../src/gatekeeper-react-native.ts","../src/index.ts"],"sourcesContent":["// Imports\nconst GatekeeperClient = require(\"@mdip/gatekeeper/client\").default;\nconst KeymasterMDIP = require(\"@mdip/keymaster\").default;\nimport { default as KeymasterLib } from \"@mdip/keymaster\";\nimport { Cipher } from \"@mdip/cipher/types\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n CreateResponseOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n WalletBase,\n WalletFile,\n} from \"@mdip/keymaster/types\";\nimport { MdipDocument, ResolveDIDOptions } from \"@mdip/gatekeeper/types\";\n\n// Keymaster configuration interface\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n cipher?: Cipher;\n}\n\nexport class KeymasterReactNative {\n private static instance: KeymasterReactNative | null = null;\n private config: KeymasterConfig;\n private keymasterService!: KeymasterLib;\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 KeymasterReactNative instance.\n * @param config The configuration object for the Keymaster service.\n */\n public static initialize(config: KeymasterConfig): void {\n if (!KeymasterReactNative.instance) {\n KeymasterReactNative.instance = new KeymasterReactNative(config);\n } else {\n console.warn(\n \"KeymasterReactNative already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n // Ensures the instance is initialized\n private ensureInitialized(): void {\n if (!KeymasterReactNative.instance) {\n throw new Error(\n \"KeymasterReactNative not initialized. Call KeymasterReactNative.initialize() first.\"\n );\n }\n }\n\n /**\n * Starts the KeymasterReactNative service.\n * @returns A boolean indicating whether the service was started successfully.\n */\n public static async start(): Promise<boolean> {\n KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().createChallengeInternal(\n spec,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().issueCredentialInternal(\n credential,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().publishCredentialInternal(\n did,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().verifyResponseInternal(\n did,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().updateCredentialInternal(\n did,\n credential\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().createSchemaInternal(\n schema,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().newWalletInternal(\n mnemonic,\n overwrite\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().recoverWalletInternal(did);\n }\n\n // Helper method to retrieve the instance\n private static getInstance(): KeymasterReactNative {\n if (!KeymasterReactNative.instance) {\n throw new Error(\n \"KeymasterReactNative not initialized. Call KeymasterReactNative.initialize() first.\"\n );\n }\n return KeymasterReactNative.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n return await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\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 this.keymasterService = new KeymasterMDIP({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher: this.config.cipher,\n });\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting KeymasterReactNative service:\", e);\n return false;\n }\n\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\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 ...args: Parameters<KeymasterLib[\"bindCredential\"]>\n ) {\n return this.keymasterService.bindCredential(...args);\n }\n\n private async createResponseInternal(\n ...args: Parameters<KeymasterLib[\"createResponse\"]>\n ) {\n return this.keymasterService.createResponse(...args);\n }\n\n private async backupWalletInternal(registry?: string): Promise<string> {\n return this.keymasterService.backupWallet(registry);\n }\n\n private async issueCredentialInternal(\n ...args: Parameters<KeymasterLib[\"issueCredential\"]>\n ) {\n return this.keymasterService.issueCredential(...args);\n }\n\n private async publishCredentialInternal(\n ...args: Parameters<KeymasterLib[\"publishCredential\"]>\n ) {\n return this.keymasterService.publishCredential(...args);\n }\n\n private async acceptCredentialInternal(\n ...args: Parameters<KeymasterLib[\"acceptCredential\"]>\n ) {\n return this.keymasterService.acceptCredential(...args);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n ...args: Parameters<KeymasterLib[\"verifyResponse\"]>\n ) {\n return this.keymasterService.verifyResponse(...args);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<KeymasterLib[\"decryptMessage\"]>\n ) {\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal() {\n return this.keymasterService.decryptMnemonic();\n }\n\n private async getCredentialInternal(\n ...args: Parameters<KeymasterLib[\"getCredential\"]>\n ) {\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<KeymasterLib[\"removeCredential\"]>\n ) {\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<KeymasterLib[\"updateCredential\"]>\n ) {\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<KeymasterLib[\"createId\"]>\n ) {\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<KeymasterLib[\"removeId\"]>\n ) {\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<KeymasterLib[\"resolveDID\"]>\n ) {\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<KeymasterLib[\"setCurrentId\"]>\n ) {\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<KeymasterLib[\"createSchema\"]>\n ) {\n return this.keymasterService.createSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<KeymasterLib[\"newWallet\"]>\n ) {\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<KeymasterLib[\"recoverWallet\"]>\n ) {\n return this.keymasterService.recoverWallet(...args);\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.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 { SdkConfig } from \"./types/index.js\";\nconst GatekeeperClient = require(\"@mdip/gatekeeper/client\").default;\nimport { GetDIDOptions, MdipDocument } from \"@mdip/gatekeeper/types\";\n\nexport class GatekeeperReactNative {\n private static instance: GatekeeperReactNative | null = null;\n\n private config: SdkConfig;\n private gatekeeperClient!: typeof GatekeeperClient;\n\n private constructor(config: SdkConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public static initialize(config: SdkConfig) {\n if (!GatekeeperReactNative.instance) {\n GatekeeperReactNative.instance = new GatekeeperReactNative(config);\n } else {\n console.warn(\n \"GatekeeperReactNative already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n private ensureInitialized() {\n if (!GatekeeperReactNative.instance) {\n throw new Error(\n \"GatekeeperReactNative not initialized. Call GatekeeperReactNative.initialize() first.\"\n );\n }\n }\n\n // Delegated STATIC methods\n\n public static async start() {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().startInternal();\n }\n\n public static async getDIDs(\n ...args: Parameters<GatekeeperReactNative[\"getDIDsInternal\"]>\n ) {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().getDIDsInternal(...args);\n }\n\n private static getInstance(): GatekeeperReactNative {\n if (!GatekeeperReactNative.instance) {\n throw new Error(\n \"GatekeeperReactNative not initialized. Call GatekeeperReactNative.initialize() first.\"\n );\n }\n return GatekeeperReactNative.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 = await GatekeeperClient.create({\n url: this.config?.url,\n waitUntilReady: this.config?.waitUntilReady,\n intervalSeconds: this.config?.intervalSeconds,\n chatty: this.config?.chatty,\n });\n } catch (e) {\n console.error(\"Error starting GatekeeperReactNative service:\", e);\n return false;\n }\n return true;\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.data;\n }\n\n private validateConfig(config: SdkConfig): void {\n if (!config) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n }\n}\n","export {\n KeymasterReactNative,\n KeymasterConfig as KeymasterReactNativeConfig,\n} from \"./keymaster-react-native.js\";\nexport { GatekeeperReactNative } from \"./gatekeeper-react-native.js\";\n\nexport {\n SdkConfig,\n WalletConfig,\n CreateChallengeResponse,\n CreateChallengeSpec,\n} from \"./types/index.js\";\n\nexport * from \"@mdip/keymaster/types\";\nimport * as GatekeeperTypes from \"@mdip/gatekeeper/types\";\n\nexport { GatekeeperTypes };\n"],"mappings":";;;;;;;;AACA,IAAM,mBAAmB,UAAQ,y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QAC7B,iBAAiB,KAAK,QAAQ;AAAA,QAC9B,QAAQ,KAAK,QAAQ;AAAA,MACvB,CAAC;AAAA,IACH,SAAS,GAAG;AACV,cAAQ,MAAM,iDAAiD,CAAC;AAChE,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,gBAAgB;AAAA,IAC5B;AAAA,IACA;AAAA,EACF,GAAsD;AACpD,UAAM,WAAW,MAAM,KAAK,iBAAiB,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACtE,WAAO,SAAS;AAAA,EAClB;AAAA,EAEQ,eAAe,QAAyB;AAC9C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,2BAA2B;AAAA,IAC7C;AAAA,EACF;AACF;;;ACjFA,cAAc;AACd,YAAY,qBAAqB;","names":["GatekeeperClient"]}
1
+ {"version":3,"sources":["../src/keymaster-react-native.ts","../src/gatekeeper-react-native.ts","../src/index.ts"],"sourcesContent":["// Imports\nimport CipherNode from \"@mdip/cipher\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n CreateResponseOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n WalletBase,\n WalletFile,\n} from \"@mdip/keymaster\";\n\nimport {\n GatekeeperClient,\n MdipDocument,\n ResolveDIDOptions,\n} from \"@mdip/gatekeeper\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\nimport KeymasterModule from \"@mdip/keymaster\";\n\n// @ts-ignore\nconst Keymaster = KeymasterModule?.default || KeymasterModule;\n\n// Keymaster configuration interface\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n cipher?: CipherNode;\n}\nexport class KeymasterReactNative {\n private static instance: KeymasterReactNative | null = null;\n private config: KeymasterConfig;\n private keymasterService!: typeof Keymaster;\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 KeymasterReactNative instance.\n * @param config The configuration object for the Keymaster service.\n */\n public static initialize(config: KeymasterConfig): void {\n if (!KeymasterReactNative.instance) {\n KeymasterReactNative.instance = new KeymasterReactNative(config);\n } else {\n console.warn(\n \"KeymasterReactNative already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n // Ensures the instance is initialized\n private ensureInitialized(): void {\n if (!KeymasterReactNative.instance) {\n throw new Error(\n \"KeymasterReactNative not initialized. Call KeymasterReactNative.initialize() first.\"\n );\n }\n }\n\n /**\n * Starts the KeymasterReactNative service.\n * @returns A boolean indicating whether the service was started successfully.\n */\n public static async start(): Promise<boolean> {\n KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().createChallengeInternal(\n spec,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().issueCredentialInternal(\n credential,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().publishCredentialInternal(\n did,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().verifyResponseInternal(\n did,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().updateCredentialInternal(\n did,\n credential\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().createSchemaInternal(\n schema,\n options\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().newWalletInternal(\n mnemonic,\n overwrite\n );\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 KeymasterReactNative.getInstance().ensureInitialized();\n return KeymasterReactNative.getInstance().recoverWalletInternal(did);\n }\n\n // Helper method to retrieve the instance\n private static getInstance(): KeymasterReactNative {\n if (!KeymasterReactNative.instance) {\n throw new Error(\n \"KeymasterReactNative not initialized. Call KeymasterReactNative.initialize() first.\"\n );\n }\n return KeymasterReactNative.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n return await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n }\n\n private async startIntegratedKeymaster(): Promise<boolean> {\n try {\n if (this.config.walletDb && this.config.cipher) {\n const gatekeeper = new GatekeeperClient();\n await gatekeeper.connect({\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 console.log(\"Gatekeeper client created:\", gatekeeper);\n this.keymasterService = new Keymaster({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher: this.config.cipher,\n });\n console.log(\"Kyemaster client created:\", this.keymasterService);\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting KeymasterReactNative service:\", e);\n return false;\n }\n\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\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 ...args: Parameters<(typeof Keymaster)[\"bindCredential\"]>\n ) {\n return this.keymasterService.bindCredential(...args);\n }\n\n private async createResponseInternal(\n ...args: Parameters<(typeof Keymaster)[\"createResponse\"]>\n ) {\n return this.keymasterService.createResponse(...args);\n }\n\n private async backupWalletInternal(registry?: string): Promise<string> {\n return this.keymasterService.backupWallet(registry);\n }\n\n private async issueCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"issueCredential\"]>\n ) {\n return this.keymasterService.issueCredential(...args);\n }\n\n private async publishCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"publishCredential\"]>\n ) {\n return this.keymasterService.publishCredential(...args);\n }\n\n private async acceptCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"acceptCredential\"]>\n ) {\n return this.keymasterService.acceptCredential(...args);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n ...args: Parameters<(typeof Keymaster)[\"verifyResponse\"]>\n ) {\n return this.keymasterService.verifyResponse(...args);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<(typeof Keymaster)[\"decryptMessage\"]>\n ) {\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal() {\n return this.keymasterService.decryptMnemonic();\n }\n\n private async getCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"getCredential\"]>\n ) {\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"removeCredential\"]>\n ) {\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<(typeof Keymaster)[\"updateCredential\"]>\n ) {\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<(typeof Keymaster)[\"createId\"]>\n ) {\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<(typeof Keymaster)[\"removeId\"]>\n ) {\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<(typeof Keymaster)[\"resolveDID\"]>\n ) {\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<(typeof Keymaster)[\"setCurrentId\"]>\n ) {\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<(typeof Keymaster)[\"createSchema\"]>\n ) {\n return this.keymasterService.createSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<(typeof Keymaster)[\"newWallet\"]>\n ) {\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<(typeof Keymaster)[\"recoverWallet\"]>\n ) {\n return this.keymasterService.recoverWallet(...args);\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.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 { SdkConfig } from \"./types/index.js\";\nimport {\n GatekeeperClient,\n MdipDocument,\n GetDIDOptions,\n} from \"@mdip/gatekeeper\";\n\nexport class GatekeeperReactNative {\n private static instance: GatekeeperReactNative | null = null;\n\n private config: SdkConfig;\n private gatekeeperClient!: GatekeeperClient;\n\n private constructor(config: SdkConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public static initialize(config: SdkConfig) {\n if (!GatekeeperReactNative.instance) {\n GatekeeperReactNative.instance = new GatekeeperReactNative(config);\n } else {\n console.warn(\n \"GatekeeperReactNative already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n private ensureInitialized() {\n if (!GatekeeperReactNative.instance) {\n throw new Error(\n \"GatekeeperReactNative not initialized. Call GatekeeperReactNative.initialize() first.\"\n );\n }\n }\n\n // Delegated STATIC methods\n\n public static async start() {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().startInternal();\n }\n\n public static async getDIDs(\n ...args: Parameters<GatekeeperReactNative[\"getDIDsInternal\"]>\n ) {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().getDIDsInternal(...args);\n }\n\n private static getInstance(): GatekeeperReactNative {\n if (!GatekeeperReactNative.instance) {\n throw new Error(\n \"GatekeeperReactNative not initialized. Call GatekeeperReactNative.initialize() first.\"\n );\n }\n return GatekeeperReactNative.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 GatekeeperClient();\n await this.gatekeeperClient.connect({\n url: this.config?.url,\n waitUntilReady: this.config?.waitUntilReady,\n intervalSeconds: this.config?.intervalSeconds,\n chatty: this.config?.chatty,\n });\n } catch (e) {\n console.error(\"Error starting GatekeeperReactNative service:\", e);\n return false;\n }\n return true;\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 validateConfig(config: SdkConfig): void {\n if (!config) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n }\n}\n","export {\n KeymasterReactNative,\n KeymasterConfig as KeymasterReactNativeConfig,\n} from \"./keymaster-react-native.js\";\nexport { GatekeeperReactNative } from \"./gatekeeper-react-native.js\";\n\nexport {\n SdkConfig,\n WalletConfig,\n CreateChallengeResponse,\n CreateChallengeSpec,\n} from \"./types/index.js\";\n\nexport * from \"@mdip/keymaster\";\nimport * as GatekeeperTypes from \"@mdip/gatekeeper\";\n\nexport { GatekeeperTypes };\n"],"mappings":";AAYA;AAAA,EACE;AAAA,OAGK;AAMP,OAAO,qBAAqB;AAG5B,IAAM,YAAY,iBAAiB,WAAW;AAQvC,IAAM,uBAAN,MAAM,sBAAqB;AAAA,EAChC,OAAe,WAAwC;AAAA,EAC/C;AAAA,EACA;AAAA,EAEA,YAAY,QAAyB;AAC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,QAC9B,QAAQ,KAAK,QAAQ;AAAA,MACvB,CAAC;AAAA,IACH,SAAS,GAAG;AACV,cAAQ,MAAM,iDAAiD,CAAC;AAChE,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,gBAAgB;AAAA,IAC5B;AAAA,IACA;AAAA,EACF,GAAsD;AACpD,UAAM,WAAW,MAAM,KAAK,iBAAiB,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACtE,WAAO;AAAA,EACT;AAAA,EAEQ,eAAe,QAAyB;AAC9C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,2BAA2B;AAAA,IAC7C;AAAA,EACF;AACF;;;ACrFA,cAAc;AACd,YAAY,qBAAqB;","names":["GatekeeperClient"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yourself_id/siwys-react-native",
3
- "version": "0.11.0",
3
+ "version": "0.11.1-updateMDIPv113.1+7092bd4",
4
4
  "description": "A React Native component library",
5
5
  "repository": "https://github.com/selfidhq/siwys-js",
6
6
  "type": "module",
@@ -25,9 +25,9 @@
25
25
  "test": "echo 'no tests yet'"
26
26
  },
27
27
  "dependencies": {
28
- "@mdip/cipher": "1.1.2",
29
- "@mdip/gatekeeper": "1.1.2",
30
- "@mdip/keymaster": "1.1.2"
28
+ "@mdip/cipher": "1.1.3",
29
+ "@mdip/gatekeeper": "1.1.3",
30
+ "@mdip/keymaster": "1.1.3"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@babel/preset-env": "^7.25.8",
@@ -41,5 +41,5 @@
41
41
  "tsup": "^8.3.0",
42
42
  "typescript": "4.9.4"
43
43
  },
44
- "gitHead": "0de2ecddf2166b78ca6c583a80eaae244ae2c0c2"
44
+ "gitHead": "7092bd4c3337b75f0ac625dd41af8f35309f68ad"
45
45
  }