@yourself_id/siwys-react-native 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -354,6 +354,12 @@ var KeymasterReactNative = class _KeymasterReactNative {
354
354
  intervalSeconds: this.config.gatekeeperConfig?.intervalSeconds,
355
355
  chatty: this.config.gatekeeperConfig?.chatty
356
356
  });
357
+ if (this.config.gatekeeperConfig?.token) {
358
+ gatekeeper.addCustomHeader(
359
+ "authorization",
360
+ `Bearer ${this.config.gatekeeperConfig.token}`
361
+ );
362
+ }
357
363
  this.keymasterService = new Keymaster({
358
364
  gatekeeper,
359
365
  wallet: this.config.walletDb,
@@ -488,6 +494,22 @@ var GatekeeperReactNative = class _GatekeeperReactNative {
488
494
  _GatekeeperReactNative.getInstance().ensureInitialized();
489
495
  return _GatekeeperReactNative.getInstance().getDIDsInternal(...args);
490
496
  }
497
+ static async addCustomHeader({
498
+ header,
499
+ value
500
+ }) {
501
+ _GatekeeperReactNative.getInstance().ensureInitialized();
502
+ return _GatekeeperReactNative.getInstance().addCustomHeaderInternal({
503
+ header,
504
+ value
505
+ });
506
+ }
507
+ static async removeCustomHeader({ header }) {
508
+ _GatekeeperReactNative.getInstance().ensureInitialized();
509
+ return _GatekeeperReactNative.getInstance().removeCustomHeaderInternal({
510
+ header
511
+ });
512
+ }
491
513
  static getInstance() {
492
514
  if (!_GatekeeperReactNative.instance) {
493
515
  throw new Error(
@@ -526,6 +548,17 @@ var GatekeeperReactNative = class _GatekeeperReactNative {
526
548
  const response = await this.gatekeeperClient.getDIDs({ dids, resolve });
527
549
  return response;
528
550
  }
551
+ async addCustomHeaderInternal({
552
+ header,
553
+ value
554
+ }) {
555
+ await this.gatekeeperClient.addCustomHeader(header, value);
556
+ }
557
+ async removeCustomHeaderInternal({
558
+ header
559
+ }) {
560
+ await this.gatekeeperClient.removeCustomHeader(header);
561
+ }
529
562
  validateConfig(config) {
530
563
  if (!config) {
531
564
  throw new Error("Missing Gatekeeper config");
@@ -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\";\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 this.keymasterService = new Keymaster({\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<(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,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AAkB;AACtD,WAAO,uBAAsB,YAAY,EAAE,cAAc;AAAA,EAC3D;AAAA,EAEA,aAAoB,WACf,MACH;AACA,2BAAsB,YAAY,EAAE,kBAAkB;AACtD,WAAO,uBAAsB,YAAY,EAAE,gBAAgB,GAAG,IAAI;AAAA,EACpE;AAAA,EAEA,OAAe,cAAqC;AAClD,QAAI,CAAC,uBAAsB,UAAU;AACnC,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,WAAO,uBAAsB;AAAA,EAC/B;AAAA;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"]}
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 if (this.config.gatekeeperConfig?.token) {\n gatekeeper.addCustomHeader(\n \"authorization\",\n `Bearer ${this.config.gatekeeperConfig.token}`\n );\n }\n this.keymasterService = new Keymaster({\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<(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 public static async addCustomHeader({\n header,\n value,\n }: {\n header: string;\n value: string;\n }) {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().addCustomHeaderInternal({\n header,\n value,\n });\n }\n\n public static async removeCustomHeader({ header }: { header: string }) {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().removeCustomHeaderInternal({\n header,\n });\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 async addCustomHeaderInternal({\n header,\n value,\n }: {\n header: string;\n value: string;\n }): Promise<void> {\n await this.gatekeeperClient.addCustomHeader(header, value);\n }\n\n private async removeCustomHeaderInternal({\n header,\n }: {\n header: string;\n }): Promise<void> {\n await this.gatekeeperClient.removeCustomHeader(header);\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,SA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B;AAAA;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,EAEA,MAAc,wBAAwB;AAAA,IACpC;AAAA,IACA;AAAA,EACF,GAGkB;AAChB,UAAM,KAAK,iBAAiB,gBAAgB,QAAQ,KAAK;AAAA,EAC3D;AAAA,EAEA,MAAc,2BAA2B;AAAA,IACvC;AAAA,EACF,GAEkB;AAChB,UAAM,KAAK,iBAAiB,mBAAmB,MAAM;AAAA,EACvD;AAAA,EAEQ,eAAe,QAAyB;AAC9C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,2BAA2B;AAAA,IAC7C;AAAA,EACF;AACF;;;AF5HA,0BAAc,4BAbd;AAcA,sBAAiC;","names":["KeymasterModule","import_gatekeeper"]}
package/dist/index.d.cts CHANGED
@@ -21,6 +21,7 @@ interface SdkConfig {
21
21
  waitUntilReady?: boolean;
22
22
  intervalSeconds?: number;
23
23
  chatty?: boolean;
24
+ token?: string;
24
25
  }
25
26
  interface WalletConfig {
26
27
  id: string;
@@ -232,10 +233,19 @@ declare class GatekeeperReactNative {
232
233
  private ensureInitialized;
233
234
  static start(): Promise<boolean>;
234
235
  static getDIDs(...args: Parameters<GatekeeperReactNative["getDIDsInternal"]>): Promise<string[] | MdipDocument[]>;
236
+ static addCustomHeader({ header, value, }: {
237
+ header: string;
238
+ value: string;
239
+ }): Promise<void>;
240
+ static removeCustomHeader({ header }: {
241
+ header: string;
242
+ }): Promise<void>;
235
243
  private static getInstance;
236
244
  private startInternal;
237
245
  private startIntegratedGatekeeper;
238
246
  private getDIDsInternal;
247
+ private addCustomHeaderInternal;
248
+ private removeCustomHeaderInternal;
239
249
  private validateConfig;
240
250
  }
241
251
 
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ interface SdkConfig {
21
21
  waitUntilReady?: boolean;
22
22
  intervalSeconds?: number;
23
23
  chatty?: boolean;
24
+ token?: string;
24
25
  }
25
26
  interface WalletConfig {
26
27
  id: string;
@@ -232,10 +233,19 @@ declare class GatekeeperReactNative {
232
233
  private ensureInitialized;
233
234
  static start(): Promise<boolean>;
234
235
  static getDIDs(...args: Parameters<GatekeeperReactNative["getDIDsInternal"]>): Promise<string[] | MdipDocument[]>;
236
+ static addCustomHeader({ header, value, }: {
237
+ header: string;
238
+ value: string;
239
+ }): Promise<void>;
240
+ static removeCustomHeader({ header }: {
241
+ header: string;
242
+ }): Promise<void>;
235
243
  private static getInstance;
236
244
  private startInternal;
237
245
  private startIntegratedGatekeeper;
238
246
  private getDIDsInternal;
247
+ private addCustomHeaderInternal;
248
+ private removeCustomHeaderInternal;
239
249
  private validateConfig;
240
250
  }
241
251
 
package/dist/index.js CHANGED
@@ -317,6 +317,12 @@ var KeymasterReactNative = class _KeymasterReactNative {
317
317
  intervalSeconds: this.config.gatekeeperConfig?.intervalSeconds,
318
318
  chatty: this.config.gatekeeperConfig?.chatty
319
319
  });
320
+ if (this.config.gatekeeperConfig?.token) {
321
+ gatekeeper.addCustomHeader(
322
+ "authorization",
323
+ `Bearer ${this.config.gatekeeperConfig.token}`
324
+ );
325
+ }
320
326
  this.keymasterService = new Keymaster({
321
327
  gatekeeper,
322
328
  wallet: this.config.walletDb,
@@ -453,6 +459,22 @@ var GatekeeperReactNative = class _GatekeeperReactNative {
453
459
  _GatekeeperReactNative.getInstance().ensureInitialized();
454
460
  return _GatekeeperReactNative.getInstance().getDIDsInternal(...args);
455
461
  }
462
+ static async addCustomHeader({
463
+ header,
464
+ value
465
+ }) {
466
+ _GatekeeperReactNative.getInstance().ensureInitialized();
467
+ return _GatekeeperReactNative.getInstance().addCustomHeaderInternal({
468
+ header,
469
+ value
470
+ });
471
+ }
472
+ static async removeCustomHeader({ header }) {
473
+ _GatekeeperReactNative.getInstance().ensureInitialized();
474
+ return _GatekeeperReactNative.getInstance().removeCustomHeaderInternal({
475
+ header
476
+ });
477
+ }
456
478
  static getInstance() {
457
479
  if (!_GatekeeperReactNative.instance) {
458
480
  throw new Error(
@@ -491,6 +513,17 @@ var GatekeeperReactNative = class _GatekeeperReactNative {
491
513
  const response = await this.gatekeeperClient.getDIDs({ dids, resolve });
492
514
  return response;
493
515
  }
516
+ async addCustomHeaderInternal({
517
+ header,
518
+ value
519
+ }) {
520
+ await this.gatekeeperClient.addCustomHeader(header, value);
521
+ }
522
+ async removeCustomHeaderInternal({
523
+ header
524
+ }) {
525
+ await this.gatekeeperClient.removeCustomHeader(header);
526
+ }
494
527
  validateConfig(config) {
495
528
  if (!config) {
496
529
  throw new Error("Missing Gatekeeper config");
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\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 this.keymasterService = new Keymaster({\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<(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;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,W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AAK,QAAQ;AACf,aAAO,MAAM,KAAK,0BAA0B;AAAA,IAC9C,OAAO;AACL,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,MAAc,4BAA8C;AAC1D,QAAI;AACF,WAAK,mBAAmB,IAAIA,kBAAiB;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;;;ACrFA,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 if (this.config.gatekeeperConfig?.token) {\n gatekeeper.addCustomHeader(\n \"authorization\",\n `Bearer ${this.config.gatekeeperConfig.token}`\n );\n }\n this.keymasterService = new Keymaster({\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<(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 public static async addCustomHeader({\n header,\n value,\n }: {\n header: string;\n value: string;\n }) {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().addCustomHeaderInternal({\n header,\n value,\n });\n }\n\n public static async removeCustomHeader({ header }: { header: string }) {\n GatekeeperReactNative.getInstance().ensureInitialized();\n return GatekeeperReactNative.getInstance().removeCustomHeaderInternal({\n header,\n });\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 async addCustomHeaderInternal({\n header,\n value,\n }: {\n header: string;\n value: string;\n }): Promise<void> {\n await this.gatekeeperClient.addCustomHeader(header, value);\n }\n\n private async removeCustomHeaderInternal({\n header,\n }: {\n header: string;\n }): Promise<void> {\n await this.gatekeeperClient.removeCustomHeader(header);\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;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,Y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AM,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,EAEA,MAAc,wBAAwB;AAAA,IACpC;AAAA,IACA;AAAA,EACF,GAGkB;AAChB,UAAM,KAAK,iBAAiB,gBAAgB,QAAQ,KAAK;AAAA,EAC3D;AAAA,EAEA,MAAc,2BAA2B;AAAA,IACvC;AAAA,EACF,GAEkB;AAChB,UAAM,KAAK,iBAAiB,mBAAmB,MAAM;AAAA,EACvD;AAAA,EAEQ,eAAe,QAAyB;AAC9C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,2BAA2B;AAAA,IAC7C;AAAA,EACF;AACF;;;AC5HA,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.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "A React Native component library",
5
5
  "repository": "https://github.com/selfidhq/siwys-js",
6
6
  "type": "module",
@@ -41,5 +41,5 @@
41
41
  "tsup": "^8.3.0",
42
42
  "typescript": "4.9.4"
43
43
  },
44
- "gitHead": "ea08588a7b76b4992be3975120a27115a73d53b5"
44
+ "gitHead": "e1cef56909930339b47955fdb7839115a15f8650"
45
45
  }