UNPKG

bigblocks

Version:

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

15 lines 5.38 kB
{ "name": "bap-identity-types-identity", "type": "registry:component", "dependencies": [], "devDependencies": [], "registryDependencies": [], "files": [ { "path": "components/bap-identity/types/identity.ts", "type": "registry:component", "content": "// Schema.org types for identity (matching profile-creator)\nexport enum SchemaType {\n\tPerson = \"Person\",\n\tOrganization = \"Organization\",\n}\n\n// Extended User type with BAP capabilities to avoid any type usage\nexport interface AuthUserWithBAP {\n\tid: string;\n\taddress: string;\n\tidKey: string;\n\tprofiles: unknown[];\n\tactiveProfileId: string;\n\tbapInstance?: ExtendedBAP;\n\tmasterKey?: string;\n\txprv?: string;\n}\n\n// BAP Address type (blockchain context, not postal)\nexport type BapAddress = {\n\taddress: string;\n\ttxId: string;\n\tblock: number;\n};\n\n// Enhanced Identity interface for Schema.org compliance\nexport interface BapIdentitySchema {\n\t\"@context\"?: string;\n\t\"@type\": SchemaType;\n\talternateName?: string;\n\tdescription?: string;\n\timage?: string;\n\tlogo?: string;\n\taddress?: string;\n\turl?: string;\n\temail?: string;\n\tgivenName?: string;\n\tfamilyName?: string;\n\tlegalName?: string;\n\tpaymail?: string;\n\tbitcoinAddress?: string;\n\tbanner?: string;\n}\n\n// Identity Data (matching profile-creator structure exactly)\nexport type IdentityData = {\n\taddresses?: BapAddress[];\n\tblock: number;\n\tcurrentAddress: string;\n\tfirstSeen: number;\n\tidKey: string; // BAP ID format - consistent with profile-creator\n\tidentity: BapIdentitySchema;\n\trootAddress: string;\n\ttimestamp: number;\n\tvalid: boolean;\n};\n\n// Hook parameter types\nexport interface KeyRotationOptions {\n\tautoBackup?: boolean;\n\tcustomBroadcast?: (tx: string) => Promise<string>;\n}\n\nexport interface KeyRotationResult {\n\tsuccess: boolean;\n\tdata?: {\n\t\tnewPath: string;\n\t\tnewAddress: string;\n\t\ttxid: string;\n\t};\n\terror?: Error;\n}\n\nexport interface UseBapKeyRotationOptions {\n\tautoRotate?: boolean;\n\trotationInterval?: number;\n}\n\n// Enhanced BAP interface to work around type issues\nexport interface BapIdentity {\n\tidKey: string; // Use consistent naming only\n\trootPath: string;\n\tcurrentPath: string;\n}\n\n// Type 42 specific identity interface\nexport interface BapIdentityType42 {\n\tidKey: string;\n\tcounter: number; // Type 42 uses counters instead of paths\n\taddress: string;\n}\n\n// BAP Identity instance interface (matches MasterID from bsv-bap)\nexport interface BapIdentityInstance {\n\texportMemberBackup(): {\n\t\tderivedPrivateKey?: string;\n\t\tderivedPublicKey?: string;\n\t\tidKey?: string;\n\t};\n\tgetCurrentAddress(): string;\n\tgetIdTransaction(path: string): string[];\n\tsignMessage(\n\t\tmessage: number[],\n\t\tsigningPath?: string,\n\t): { address: string; signature: string };\n\tgetEncryptionKey(): {\n\t\tprivKey: import(\"@bsv/sdk\").PrivateKey;\n\t\tpubKey: import(\"@bsv/sdk\").PublicKey;\n\t};\n\tgetEncryptionKeyType42(): {\n\t\tprivKey: import(\"@bsv/sdk\").PrivateKey;\n\t\tpubKey: import(\"@bsv/sdk\").PublicKey;\n\t};\n\tgetEncryptionPublicKey(): string;\n\tencrypt(stringData: string, counterPartyPublicKey?: string): string;\n\tdecrypt(ciphertext: string, counterPartyPublicKey?: string): string;\n}\n\n// TODO: Replace ExtendedBAP mock interface with actual BSV-BAP library class\n// The current approach of mocking the interface is not ideal when the real\n// BSV-BAP library already provides proper classes. This was done to avoid\n// circular dependencies and immediate integration complexity, but should be\n// revisited to use the actual library types and instances.\nexport interface ExtendedBAP {\n\tlistIds(): BapIdentity[];\n\tgetAddress(rootPath: string, currentPath: string): string;\n\tnewId(idKey: string): boolean;\n\tgetId(idKey: string): BapIdentityInstance | null;\n\tgetCurrentPublicKey(): string | undefined;\n}\n\nexport interface BapKeyRotationManagerProps {\n\t/**\n\t * The BAP instance for the current identity\n\t */\n\tbapInstance: ExtendedBAP;\n\n\t/**\n\t * Callback when rotation is complete\n\t */\n\tonRotationComplete?: (newPath: string, txid: string) => void;\n\n\t/**\n\t * Whether to show rotation history\n\t */\n\tshowRotationHistory?: boolean;\n\n\t/**\n\t * Whether to auto-backup after rotation\n\t */\n\tautoBackupAfterRotation?: boolean;\n\n\t/**\n\t * Custom broadcast function (defaults to using built-in broadcaster)\n\t */\n\tonBroadcast?: (tx: string) => Promise<string>;\n\n\t/**\n\t * Theme variant for the component\n\t */\n\tvariant?: \"surface\" | \"ghost\" | \"classic\";\n\n\t/**\n\t * Size of the component\n\t */\n\tsize?: \"1\" | \"2\" | \"3\";\n}\n\nexport interface BapKeyRotationEvent {\n\tid: string;\n\ttimestamp: Date;\n\tfromPath: string;\n\ttoPath: string;\n\tfromAddress: string;\n\ttoAddress: string;\n\ttxid: string;\n\tblockHeight?: number;\n\tstatus: \"pending\" | \"confirmed\" | \"failed\";\n}\n\nexport interface KeyRotationHistory {\n\tevents: BapKeyRotationEvent[];\n\tcurrentPath: string;\n\tcurrentAddress: string;\n\trootPath: string;\n\trootAddress: string;\n}\n\nexport interface RotationConfirmationData {\n\tcurrentAddress: string;\n\tnewAddress: string;\n\testimatedFee: number;\n\twarningMessage?: string;\n}\n", "target": "<%- config.aliases.components %>/identity.tsx" } ] }