UNPKG

bigblocks

Version:

Complete Bitcoin UI component library - authentication, social, wallet, market, inscriptions, and blockchain interactions for React

15 lines 3.76 kB
{ "name": "bap-identity-hooks-usebapidentity", "type": "registry:hook", "dependencies": [], "devDependencies": [], "registryDependencies": [], "files": [ { "path": "components/bap-identity/hooks/useBapIdentity.ts", "type": "registry:hook", "content": "import type { UseBapEncryptionOptions } from \"../types/encryption.js\";\nimport type { UseBapKeyRotationOptions } from \"../types/identity.js\";\nimport type { UseBapSigningOptions } from \"../types/signing.js\";\n// Combined BAP Identity Hook - Combines encryption, signing, key rotation, and profile sync\nimport { useBapEncryption } from \"./useBapEncryption.js\";\nimport { useBapKeyRotation } from \"./useBapKeyRotation.js\";\nimport { useBapProfileSync } from \"./useBapProfileSync.js\";\nimport { useBapSigning } from \"./useBapSigning.js\";\n\ninterface ProfileSyncOptions {\n\tautoSync?: boolean; // Auto-sync after login\n\tmaxDiscoveryAttempts?: number; // Max sequential IDs to test\n\tsigmaApiUrl?: string; // Custom SIGMA API URL\n}\n\ninterface UseBapIdentityOptions {\n\tencryption?: UseBapEncryptionOptions;\n\tsigning?: UseBapSigningOptions;\n\tkeyRotation?: UseBapKeyRotationOptions;\n\tprofileSync?: ProfileSyncOptions;\n}\n\nexport function useBapIdentity(options: UseBapIdentityOptions = {}) {\n\tconst encryption = useBapEncryption(options.encryption);\n\tconst signing = useBapSigning(options.signing);\n\tconst keyRotation = useBapKeyRotation(options.keyRotation);\n\tconst profileSync = useBapProfileSync(options.profileSync);\n\n\treturn {\n\t\t// Encryption operations\n\t\tencrypt: encryption.encrypt,\n\t\tencryptAsync: encryption.encryptAsync,\n\t\tdecrypt: encryption.decrypt,\n\t\tdecryptAsync: encryption.decryptAsync,\n\t\tgetEncryptionKey: encryption.getEncryptionKey,\n\n\t\t// Signing operations\n\t\tsignFile: signing.signFile,\n\t\tsignFileAsync: signing.signFileAsync,\n\t\tverifyFile: signing.verifyFile,\n\t\tverifyFileAsync: signing.verifyFileAsync,\n\t\tbroadcastSignature: signing.broadcastSignature,\n\t\tbroadcastSignatureAsync: signing.broadcastSignatureAsync,\n\n\t\t// Key rotation operations\n\t\trotateKey: keyRotation.rotateKey,\n\t\trotateKeyAsync: keyRotation.rotateKeyAsync,\n\t\trotationHistory: keyRotation.rotationHistory,\n\t\tcurrentKeyInfo: keyRotation.currentKeyInfo,\n\n\t\t// Profile synchronization operations\n\t\tsyncProfiles: profileSync.syncProfiles,\n\t\tresetProfileSync: profileSync.resetSync,\n\t\tfetchProfile: profileSync.fetchProfile,\n\t\tvalidateByAddress: profileSync.validateByAddress,\n\n\t\t// Profile sync state\n\t\tisScanning: profileSync.isScanning,\n\t\tsyncProgress: profileSync.progress,\n\t\tcurrentSyncId: profileSync.currentId,\n\t\tfoundProfileCount: profileSync.foundCount,\n\t\tsyncResult: profileSync.result,\n\t\tisSyncSuccess: profileSync.isSuccess,\n\n\t\t// Combined state\n\t\tisLoading:\n\t\t\tencryption.isLoading ||\n\t\t\tsigning.isLoading ||\n\t\t\tkeyRotation.isLoading ||\n\t\t\tprofileSync.isScanning,\n\t\tisError:\n\t\t\tencryption.isError ||\n\t\t\tsigning.isError ||\n\t\t\tkeyRotation.isError ||\n\t\t\t!!profileSync.error,\n\t\tisSuccess:\n\t\t\tencryption.isSuccess ||\n\t\t\tsigning.isSuccess ||\n\t\t\tkeyRotation.isSuccess ||\n\t\t\tprofileSync.isSuccess,\n\t\thasError:\n\t\t\tencryption.isError ||\n\t\t\tsigning.isError ||\n\t\t\tkeyRotation.isError ||\n\t\t\t!!profileSync.error,\n\t\terror:\n\t\t\tencryption.error ||\n\t\t\tsigning.error ||\n\t\t\tkeyRotation.error ||\n\t\t\tprofileSync.error,\n\n\t\t// Combined reset\n\t\treset: () => {\n\t\t\tencryption.reset();\n\t\t\tsigning.reset();\n\t\t\tkeyRotation.reset();\n\t\t\tprofileSync.resetSync();\n\t\t},\n\t};\n}\n", "target": "<%- config.aliases.hooks %>/usebapidentity.ts" } ] }