@hashgraphonline/standards-sdk 0.1.143-feat-solana-register.canary.16fb796.75 → 0.1.143-feat-solana-register.canary.8527a8c.77
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/cjs/hcs-10/base-client.d.ts.map +1 -1
- package/dist/cjs/hcs-12/rendering/resource-manager.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client/base-client.d.ts +14 -1
- package/dist/cjs/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client/feedback.d.ts +6 -6
- package/dist/cjs/services/registry-broker/client/feedback.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client.d.ts +1 -0
- package/dist/cjs/services/registry-broker/client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/schemas.d.ts +542 -294
- package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/types.d.ts +3 -2
- package/dist/cjs/services/registry-broker/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/cjs/utils/crypto-abstraction.d.ts.map +1 -1
- package/dist/cjs/utils/crypto-env.d.ts.map +1 -1
- package/dist/cjs/utils/hash-adapter.d.ts.map +1 -1
- package/dist/es/hcs-10/base-client.d.ts.map +1 -1
- package/dist/es/hcs-12/rendering/resource-manager.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client/base-client.d.ts +14 -1
- package/dist/es/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client/feedback.d.ts +6 -6
- package/dist/es/services/registry-broker/client/feedback.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client.d.ts +1 -0
- package/dist/es/services/registry-broker/client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +542 -294
- package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/es/services/registry-broker/types.d.ts +3 -2
- package/dist/es/services/registry-broker/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +2 -1
- package/dist/es/standards-sdk.es110.js +1 -2
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +5 -5
- package/dist/es/standards-sdk.es117.js +5 -1
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +6 -5
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es120.js +12 -4
- package/dist/es/standards-sdk.es120.js.map +1 -1
- package/dist/es/standards-sdk.es121.js +1 -1
- package/dist/es/standards-sdk.es122.js +1 -1
- package/dist/es/standards-sdk.es123.js +5 -5
- package/dist/es/standards-sdk.es125.js +1 -1
- package/dist/es/standards-sdk.es126.js +1 -1
- package/dist/es/standards-sdk.es128.js +2 -2
- package/dist/es/standards-sdk.es129.js +1 -1
- package/dist/es/standards-sdk.es130.js +1 -1
- package/dist/es/standards-sdk.es131.js +2 -2
- package/dist/es/standards-sdk.es132.js +1 -1
- package/dist/es/standards-sdk.es133.js +1 -1
- package/dist/es/standards-sdk.es134.js +1 -1
- package/dist/es/standards-sdk.es135.js +1 -1
- package/dist/es/standards-sdk.es136.js +8 -54
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +44 -1
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +1 -1
- package/dist/es/standards-sdk.es150.js +958 -17
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +12269 -903
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +54 -12287
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +71 -161
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +139 -289
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +274 -298
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +262 -369
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +316 -194
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +319 -64
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +69 -49
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es160.js +15 -80
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es17.js +1 -2
- package/dist/es/standards-sdk.es17.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +2 -3
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +2 -3
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +2 -3
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +1 -1
- package/dist/es/standards-sdk.es32.js +1 -1
- package/dist/es/standards-sdk.es36.js +2 -3
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +1 -1
- package/dist/es/standards-sdk.es38.js +1 -1
- package/dist/es/standards-sdk.es47.js +3 -2
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +1 -1
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es60.js +1 -1
- package/dist/es/standards-sdk.es61.js +1 -2
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es66.js +1 -1
- package/dist/es/standards-sdk.es78.js +1 -2
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/utils/crypto-abstraction.d.ts.map +1 -1
- package/dist/es/utils/crypto-env.d.ts.map +1 -1
- package/dist/es/utils/hash-adapter.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es28.js","sources":["../../src/hcs-11/client.ts"],"sourcesContent":["import {\n AccountId,\n AccountUpdateTransaction,\n Client,\n PrivateKey,\n Status,\n Transaction,\n} from '@hashgraph/sdk';\nimport {\n inscribe,\n inscribeWithSigner,\n InscriptionInput,\n InscriptionOptions,\n InscriptionResult,\n} from '../inscribe';\nimport { Logger, ILogger, getTopicId } from '../utils';\nimport * as mime from 'mime-types';\nimport { z, ZodIssue } from 'zod';\nimport type { DAppSigner } from '@hashgraph/hedera-wallet-connect';\nimport { ProgressReporter } from '../utils/progress-reporter';\nimport { HederaMirrorNode } from '../services';\nimport { isHederaNetwork, toHederaCaip10 } from '../hcs-14/caip';\nimport { TopicInfo } from '../services/types';\nimport {\n createNodeOperatorContext,\n type NodeOperatorContext,\n} from '../common/node-operator-resolver';\nimport { NetworkType } from '../utils/types';\nimport {\n ProfileType,\n AIAgentType,\n AIAgentCapability,\n SocialLink,\n PersonalProfile,\n AIAgentProfile,\n HCS11Profile,\n HCS11Auth,\n HCS11ClientConfig,\n TransactionResult,\n InscribeProfileResponse,\n InscribeImageResponse,\n AgentMetadata,\n InscribeImageOptions,\n InscribeProfileOptions,\n capabilityNameToCapabilityMap,\n MCPServerDetails,\n MCPServerProfile,\n MCPServerCapability,\n VerificationType,\n} from './types';\n\nexport const SocialLinkSchema = z.object({\n platform: z.string().min(1),\n handle: z.string().min(1),\n});\n\nexport const AIAgentDetailsSchema = z.object({\n type: z.nativeEnum(AIAgentType),\n capabilities: z.array(z.nativeEnum(AIAgentCapability)).min(1),\n model: z.string().min(1),\n creator: z.string().optional(),\n});\n\nexport const MCPServerConnectionInfoSchema = z.object({\n url: z.string().min(1),\n transport: z.enum(['stdio', 'sse']),\n});\n\nexport const MCPServerVerificationSchema = z.object({\n type: z.nativeEnum(VerificationType),\n value: z.string(),\n dns_field: z.string().optional(),\n challenge_path: z.string().optional(),\n});\n\nexport const MCPServerHostSchema = z.object({\n minVersion: z.string().optional(),\n});\n\nexport const MCPServerResourceSchema = z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n});\n\nexport const MCPServerToolSchema = z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n});\n\nexport const MCPServerDetailsSchema = z.object({\n version: z.string().min(1),\n connectionInfo: MCPServerConnectionInfoSchema,\n services: z.array(z.nativeEnum(MCPServerCapability)).min(1),\n description: z.string().min(1),\n verification: MCPServerVerificationSchema.optional(),\n host: MCPServerHostSchema.optional(),\n capabilities: z.array(z.string()).optional(),\n resources: z.array(MCPServerResourceSchema).optional(),\n tools: z.array(MCPServerToolSchema).optional(),\n maintainer: z.string().optional(),\n repository: z.string().optional(),\n docs: z.string().optional(),\n});\n\nexport const BaseProfileSchema = z.object({\n version: z.string().min(1),\n type: z.nativeEnum(ProfileType),\n display_name: z.string().min(1),\n alias: z.string().optional(),\n bio: z.string().optional(),\n socials: z.array(SocialLinkSchema).optional(),\n profileImage: z.string().optional(),\n uaid: z.string().optional(),\n properties: z.record(z.any()).optional(),\n inboundTopicId: z.string().optional(),\n outboundTopicId: z.string().optional(),\n base_account: z.string().optional(),\n});\n\nexport const PersonalProfileSchema = BaseProfileSchema.extend({\n type: z.literal(ProfileType.PERSONAL),\n language: z.string().optional(),\n timezone: z.string().optional(),\n});\n\nexport const AIAgentProfileSchema = BaseProfileSchema.extend({\n type: z.literal(ProfileType.AI_AGENT),\n aiAgent: AIAgentDetailsSchema,\n});\n\nexport const MCPServerProfileSchema = BaseProfileSchema.extend({\n type: z.literal(ProfileType.MCP_SERVER),\n mcpServer: MCPServerDetailsSchema,\n});\n\nconst FloraProfileSchema = z.object({\n version: z.string(),\n type: z.literal(ProfileType.FLORA),\n display_name: z.string().min(1),\n members: z.array(\n z.object({\n accountId: z.string(),\n publicKey: z.string().optional(),\n weight: z.number().optional(),\n }),\n ),\n threshold: z.number().min(1),\n topics: z.object({\n communication: z.string(),\n transaction: z.string(),\n state: z.string(),\n }),\n inboundTopicId: z.string(),\n outboundTopicId: z.string(),\n bio: z.string().optional(),\n metadata: z.record(z.any()).optional(),\n policies: z.record(z.any()).optional(),\n});\n\nexport const HCS11ProfileSchema = z.union([\n PersonalProfileSchema,\n AIAgentProfileSchema,\n MCPServerProfileSchema,\n FloraProfileSchema,\n]);\n\nexport class HCS11Client {\n private client: Client;\n private auth: HCS11Auth;\n private network: string;\n private logger: ILogger;\n private mirrorNode: HederaMirrorNode;\n private keyType: 'ed25519' | 'ecdsa';\n private operatorId: string;\n private operatorCtx?: NodeOperatorContext;\n\n constructor(config: HCS11ClientConfig) {\n this.client =\n config.network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.auth = config.auth;\n this.network = config.network;\n this.operatorId = config.auth.operatorId;\n\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS-11',\n silent: config.silent,\n });\n\n this.mirrorNode = new HederaMirrorNode(\n this.network as 'mainnet' | 'testnet',\n this.logger,\n );\n\n if (this.auth.privateKey) {\n this.operatorCtx = createNodeOperatorContext({\n network: this.network as NetworkType,\n operatorId: this.operatorId,\n operatorKey: this.auth.privateKey,\n keyType: config.keyType,\n mirrorNode: this.mirrorNode,\n logger: this.logger,\n client: this.client,\n });\n this.client = this.operatorCtx.client;\n this.keyType = this.operatorCtx.keyType;\n void this.operatorCtx.ensureInitialized();\n this.client.setOperator(\n this.operatorId.toString(),\n this.operatorCtx.operatorKey,\n );\n } else {\n this.keyType = config.keyType || 'ed25519';\n }\n }\n\n public getClient(): Client {\n return this.client;\n }\n\n public getOperatorId(): string {\n return this.auth.operatorId;\n }\n\n public async initializeOperator() {\n if (!this.operatorCtx) {\n return;\n }\n\n try {\n await this.operatorCtx.ensureInitialized();\n this.keyType = this.operatorCtx.keyType;\n this.client.setOperator(this.operatorId, this.operatorCtx.operatorKey);\n } catch (error) {\n this.logger.warn(\n `Failed to verify operator key with mirror node: ${\n (error as Error).message\n }`,\n );\n }\n }\n\n public createPersonalProfile(\n displayName: string,\n options?: {\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n language?: string;\n timezone?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n baseAccount?: string;\n },\n ): PersonalProfile {\n return {\n version: '1.0',\n type: ProfileType.PERSONAL,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n base_account: options?.baseAccount,\n };\n }\n\n public createAIAgentProfile(\n displayName: string,\n agentType: AIAgentType,\n capabilities: AIAgentCapability[],\n model: string,\n options?: {\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n creator?: string;\n baseAccount?: string;\n },\n ): AIAgentProfile {\n const validation = this.validateProfile({\n version: '1.0',\n type: ProfileType.AI_AGENT,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n base_account: options?.baseAccount,\n aiAgent: {\n type: agentType,\n capabilities,\n model,\n creator: options?.creator,\n },\n });\n\n if (!validation.valid) {\n throw new Error(\n `Invalid AI Agent Profile: ${validation.errors.join(', ')}`,\n );\n }\n\n return {\n version: '1.0',\n type: ProfileType.AI_AGENT,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n base_account: options?.baseAccount,\n aiAgent: {\n type: agentType,\n capabilities,\n model,\n creator: options?.creator,\n },\n };\n }\n\n /**\n * Creates an MCP server profile.\n *\n * @param displayName - The display name for the MCP server\n * @param serverDetails - The MCP server details\n * @param options - Additional profile options\n * @returns An MCPServerProfile object\n */\n public createMCPServerProfile(\n displayName: string,\n serverDetails: MCPServerDetails,\n options?: {\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n },\n ): MCPServerProfile {\n const validation = this.validateProfile({\n version: '1.0',\n type: ProfileType.MCP_SERVER,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n mcpServer: serverDetails,\n });\n\n if (!validation.valid) {\n throw new Error(\n `Invalid MCP Server Profile: ${validation.errors.join(', ')}`,\n );\n }\n\n return {\n version: '1.0',\n type: ProfileType.MCP_SERVER,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n mcpServer: serverDetails,\n };\n }\n\n public validateProfile(profile: unknown): {\n valid: boolean;\n errors: string[];\n } {\n const result = HCS11ProfileSchema.safeParse(profile);\n\n if (result.success) {\n return { valid: true, errors: [] };\n }\n\n const formattedErrors = result.error.errors.map((err: ZodIssue) => {\n const path = err.path.join('.');\n let message = err.message;\n\n if (err.code === 'invalid_type') {\n message = `Expected ${err.expected}, got ${err.received}`;\n } else if (err.code === 'invalid_enum_value') {\n const validOptions = err.options?.join(', ');\n message = `Invalid value. Valid options are: ${validOptions}`;\n } else if (err.code === 'too_small' && err.type === 'string') {\n message = 'Cannot be empty';\n }\n\n return `${path}: ${message}`;\n });\n\n return { valid: false, errors: formattedErrors };\n }\n\n public profileToJSONString(profile: HCS11Profile): string {\n return JSON.stringify(profile);\n }\n\n public parseProfileFromString(profileStr: string): HCS11Profile | null {\n try {\n const parsedProfile = JSON.parse(profileStr);\n const validation = this.validateProfile(parsedProfile);\n if (!validation.valid) {\n this.logger.error('Invalid profile format:', validation.errors);\n return null;\n }\n return parsedProfile as HCS11Profile;\n } catch (error) {\n this.logger.error('Error parsing profile:');\n return null;\n }\n }\n\n public setProfileForAccountMemo(\n topicId: string,\n topicStandard: 1 | 2 | 7 = 1,\n ): string {\n return `hcs-11:hcs://${topicStandard}/${topicId}`;\n }\n\n private async executeTransaction<T>(\n transaction: Transaction,\n ): Promise<TransactionResult<T>> {\n try {\n if (this.auth.privateKey) {\n const signedTx = await transaction.signWithOperator(this.client);\n const response = await signedTx.execute(this.client);\n const receipt = await response.getReceipt(this.client);\n\n if (receipt.status.toString() !== Status.Success.toString()) {\n return {\n success: false,\n error: `Transaction failed: ${receipt.status.toString()}`,\n };\n }\n\n return {\n success: true,\n result: receipt as T,\n };\n }\n\n if (!this.auth.signer) {\n throw new Error('No valid authentication method provided');\n }\n\n const signer = this.auth.signer;\n const frozenTransaction = await transaction.freezeWithSigner(signer);\n const response = await frozenTransaction.executeWithSigner(signer);\n const receipt = await response.getReceiptWithSigner(signer);\n\n if (receipt.status.toString() !== Status.Success.toString()) {\n return {\n success: false,\n error: `Transaction failed: ${receipt.status.toString()}: ${Status.Success.toString()}`,\n };\n }\n\n return {\n success: true,\n result: receipt as T,\n };\n } catch (error) {\n return {\n success: false,\n error:\n error instanceof Error\n ? error.message\n : 'Unknown error during transaction execution',\n };\n }\n }\n\n public async inscribeImage(\n buffer: Buffer,\n fileName: string,\n options?: InscribeImageOptions,\n ): Promise<InscribeImageResponse> {\n try {\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-Image',\n logger: this.logger,\n callback: progressCallback as any,\n });\n\n progressReporter.preparing('Preparing to inscribe image', 0);\n\n const mimeType = mime.lookup(fileName) || 'application/octet-stream';\n\n const waitForConfirmation = options?.waitForConfirmation ?? true;\n\n let inscriptionResponse;\n if (this.auth.signer) {\n if ('accountId' in this.auth.signer) {\n progressReporter.preparing('Using signer for inscription', 10);\n\n inscriptionResponse = await inscribeWithSigner(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n this.auth.signer as DAppSigner,\n {\n network: this.network as 'mainnet' | 'testnet',\n waitForConfirmation,\n waitMaxAttempts: 150,\n waitIntervalMs: 4000,\n logging: {\n level: 'debug',\n },\n progressCallback: data => {\n const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;\n progressReporter.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n },\n );\n } else {\n progressReporter.failed(\n 'Signer must be a DAppSigner for inscription',\n );\n throw new Error('Signer must be a DAppSigner for inscription');\n }\n } else {\n if (!this.auth.privateKey) {\n progressReporter.failed('Private key is required for inscription');\n this.logger.error('Private key is required for inscription');\n throw new Error('Private key is required for inscription');\n }\n\n progressReporter.preparing('Using private key for inscription', 10);\n\n const PK =\n this.keyType === 'ecdsa'\n ? PrivateKey.fromStringECDSA(this.auth.privateKey)\n : PrivateKey.fromStringED25519(this.auth.privateKey);\n\n inscriptionResponse = await inscribe(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n {\n accountId: this.auth.operatorId,\n privateKey: PK,\n network: this.network as 'mainnet' | 'testnet',\n },\n {\n waitForConfirmation,\n waitMaxAttempts: 150,\n waitIntervalMs: 2000,\n logging: {\n level: 'debug',\n },\n progressCallback: data => {\n const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;\n progressReporter.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n },\n );\n }\n\n if (inscriptionResponse.confirmed) {\n progressReporter.completed('Image inscription completed', {\n topicId: getTopicId(inscriptionResponse.inscription),\n });\n return {\n imageTopicId: getTopicId(inscriptionResponse.inscription) || '',\n transactionId: (inscriptionResponse.result as InscriptionResult)\n .jobId,\n success: true,\n };\n } else {\n const jobId = inscriptionResponse.quote\n ? 'quote-only'\n : (inscriptionResponse.result as InscriptionResult).jobId;\n progressReporter.verifying('Waiting for inscription confirmation', 50, {\n jobId,\n });\n return {\n imageTopicId: '',\n transactionId: jobId,\n success: false,\n error: 'Inscription not confirmed',\n };\n }\n } catch (error) {\n this.logger.error('Error inscribing image:', error);\n return {\n imageTopicId: '',\n transactionId: '',\n success: false,\n error:\n error instanceof Error ? error.message : 'Error inscribing image',\n };\n }\n }\n\n public async inscribeProfile(\n profile: HCS11Profile,\n options?: InscribeProfileOptions,\n ): Promise<InscribeProfileResponse> {\n this.logger.info('Inscribing HCS-11 profile');\n\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-Profile',\n logger: this.logger,\n callback: progressCallback,\n });\n\n await this.attachUaidIfMissing(profile);\n\n progressReporter.preparing('Validating profile data', 5);\n\n const validation = this.validateProfile(profile);\n if (!validation.valid) {\n progressReporter.failed(\n `Invalid profile: ${validation.errors.join(', ')}`,\n );\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: `Invalid profile: ${validation.errors.join(', ')}`,\n };\n }\n\n progressReporter.preparing('Formatting profile for inscription', 15);\n\n const profileJson = this.profileToJSONString(profile);\n const fileName = `profile-${profile.display_name\n .toLowerCase()\n .replace(/\\s+/g, '-')}.json`;\n\n try {\n const contentBuffer = Buffer.from(profileJson, 'utf-8');\n const contentType = 'application/json';\n\n progressReporter.preparing('Preparing profile for inscription', 20);\n\n const input: InscriptionInput = {\n type: 'buffer',\n buffer: contentBuffer,\n fileName,\n mimeType: contentType,\n };\n\n const inscriptionOptions: InscriptionOptions = {\n waitForConfirmation: true,\n mode: 'file',\n network: this.network as 'mainnet' | 'testnet',\n waitMaxAttempts: 100,\n waitIntervalMs: 2000,\n progressCallback: data => {\n const adjustedPercent =\n 20 + Number(data?.progressPercent || 0) * 0.75;\n progressReporter?.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n };\n\n progressReporter.submitting('Submitting profile to Hedera network', 30);\n\n let inscriptionResponse;\n\n if (this.auth.privateKey) {\n const PK =\n this.keyType === 'ecdsa'\n ? PrivateKey.fromStringECDSA(this.auth.privateKey)\n : PrivateKey.fromStringED25519(this.auth.privateKey);\n\n inscriptionResponse = await inscribe(\n input,\n {\n accountId: this.auth.operatorId,\n privateKey: PK,\n network: this.network as 'mainnet' | 'testnet',\n },\n inscriptionOptions,\n );\n } else if (this.auth.signer) {\n inscriptionResponse = await inscribeWithSigner(\n input,\n this.auth.signer as DAppSigner,\n inscriptionOptions,\n );\n } else {\n throw new Error(\n 'No authentication method available - neither private key nor signer',\n );\n }\n\n if (\n !inscriptionResponse.confirmed ||\n !getTopicId(inscriptionResponse.inscription)\n ) {\n progressReporter.failed('Failed to inscribe profile content');\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: 'Failed to inscribe profile content',\n };\n }\n const topicId = getTopicId(inscriptionResponse.inscription);\n\n progressReporter.completed('Profile inscription completed', {\n topicId,\n transactionId: (inscriptionResponse.result as InscriptionResult)\n .transactionId,\n });\n\n return {\n profileTopicId: topicId,\n transactionId: (inscriptionResponse.result as InscriptionResult)\n .transactionId,\n success: true,\n totalCostHbar: inscriptionResponse.costSummary?.totalCostHbar,\n };\n } catch (error) {\n progressReporter.failed(\n `Error inscribing profile: ${error.message || 'Unknown error'}`,\n );\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: error.message || 'Unknown error during inscription',\n };\n }\n }\n\n private async attachUaidIfMissing(profile: HCS11Profile): Promise<void> {\n if (profile.uaid) {\n return;\n }\n if (!isHederaNetwork(this.network)) {\n return;\n }\n try {\n const { HCS14Client } = await import('../hcs-14');\n const hcs14 = new HCS14Client({ client: this.client });\n const did = await hcs14.createDid({\n method: 'hedera',\n client: this.client,\n });\n const nativeId = toHederaCaip10(this.network, this.auth.operatorId);\n let uid = this.auth.operatorId;\n const inboundFromProfile = profile.inboundTopicId;\n if (inboundFromProfile && inboundFromProfile.trim().length > 0) {\n uid = `${inboundFromProfile}@${this.auth.operatorId}`;\n } else {\n try {\n const fetched = await this.fetchProfileByAccountId(\n this.auth.operatorId,\n this.network as 'mainnet' | 'testnet',\n );\n const inbound = fetched?.topicInfo?.inboundTopic;\n if (inbound && inbound.trim().length > 0) {\n uid = `${inbound}@${this.auth.operatorId}`;\n }\n } catch {}\n }\n\n const uaid = hcs14.createUaid(did, { proto: 'hcs-10', nativeId, uid });\n profile.uaid = uaid;\n } catch (e) {\n this.logger.warn(\n 'Hiero registrar not available; skipping UAID generation for profile',\n e,\n );\n }\n }\n\n public async updateAccountMemoWithProfile(\n accountId: string | AccountId,\n profileTopicId: string,\n signerKeys?: PrivateKey[],\n ): Promise<TransactionResult> {\n try {\n this.logger.info(\n `Updating account memo for ${accountId} with profile ${profileTopicId}`,\n );\n const memo = this.setProfileForAccountMemo(profileTopicId);\n\n const transaction = new AccountUpdateTransaction()\n .setAccountMemo(memo)\n .setAccountId(accountId);\n\n if (signerKeys && signerKeys.length > 0) {\n const frozen = await transaction.freezeWith(this.client);\n let signed = frozen;\n for (const key of signerKeys) {\n signed = await signed.sign(key);\n }\n const response = await signed.execute(this.client);\n const receipt = await response.getReceipt(this.client);\n if (receipt.status.toString() !== Status.Success.toString()) {\n return {\n success: false,\n error: `Transaction failed: ${receipt.status.toString()}`,\n };\n }\n return {\n success: true,\n result: receipt,\n };\n }\n\n return this.executeTransaction(transaction);\n } catch (error) {\n this.logger.error(\n `Error updating account memo: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n );\n return {\n success: false,\n error:\n error instanceof Error\n ? error.message\n : 'Unknown error updating account memo',\n };\n }\n }\n\n /**\n * Creates and inscribes a profile.\n *\n * @param profile - The profile to create and inscribe.\n * @param updateAccountMemo - Whether to update the account memo with the profile.\n * @param options - Optional configuration options.\n * @returns A promise that resolves to the inscription result.\n */\n public async createAndInscribeProfile(\n profile: HCS11Profile,\n updateAccountMemo = true,\n options?: InscribeProfileOptions,\n ): Promise<InscribeProfileResponse> {\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-ProfileCreation',\n logger: this.logger,\n callback: progressCallback,\n });\n\n progressReporter.preparing('Starting profile creation process', 0);\n\n const inscriptionProgress = progressReporter.createSubProgress({\n minPercent: 0,\n maxPercent: 80,\n logPrefix: 'Inscription',\n });\n\n const inscriptionResult = await this.inscribeProfile(profile, {\n ...options,\n progressCallback: data => {\n inscriptionProgress.report({\n stage: data.stage,\n message: data.message,\n progressPercent: data.progressPercent,\n details: data.details,\n });\n },\n });\n\n if (!inscriptionResult?.success) {\n progressReporter.failed('Profile inscription failed', {\n error: inscriptionResult?.error,\n });\n return inscriptionResult;\n }\n\n progressReporter.confirming('Profile inscribed, updating account memo', 85);\n\n if (updateAccountMemo) {\n const memoResult = await this.updateAccountMemoWithProfile(\n this.auth.operatorId,\n inscriptionResult.profileTopicId,\n );\n\n if (!memoResult.success) {\n progressReporter.failed('Failed to update account memo', {\n error: memoResult?.error,\n });\n return {\n ...inscriptionResult,\n success: false,\n error: memoResult?.error,\n };\n }\n }\n\n progressReporter.completed('Profile creation completed successfully', {\n profileTopicId: inscriptionResult.profileTopicId,\n transactionId: inscriptionResult.transactionId,\n totalCostHbar: inscriptionResult.totalCostHbar,\n });\n\n return inscriptionResult;\n }\n\n /**\n * Gets the capabilities from the capability names.\n *\n * @param capabilityNames - The capability names to get the capabilities for.\n * @returns The capabilities.\n */\n public async getCapabilitiesFromTags(\n capabilityNames: string[],\n ): Promise<number[]> {\n const capabilities: number[] = [];\n\n if (capabilityNames.length === 0) {\n return [AIAgentCapability.TEXT_GENERATION];\n }\n\n for (const capabilityName of capabilityNames) {\n const capability =\n capabilityNameToCapabilityMap[capabilityName.toLowerCase()];\n if (capability !== undefined && !capabilities.includes(capability)) {\n capabilities.push(capability);\n }\n }\n\n if (capabilities.length === 0) {\n capabilities.push(AIAgentCapability.TEXT_GENERATION);\n }\n\n return capabilities;\n }\n\n /**\n * Gets the agent type from the metadata.\n *\n * @param metadata - The metadata of the agent.\n * @returns The agent type.\n */\n public getAgentTypeFromMetadata(metadata: AgentMetadata): AIAgentType {\n if (metadata.type === 'autonomous') {\n return AIAgentType.AUTONOMOUS;\n } else {\n return AIAgentType.MANUAL;\n }\n }\n\n /**\n * Fetches a profile from the account memo.\n *\n * @param accountId - The account ID of the agent to fetch the profile for.\n * @param network - The network to use for the fetch.\n * @returns A promise that resolves to the profile.\n */\n public async fetchProfileByAccountId(\n accountId: string | AccountId,\n network?: string,\n ): Promise<{\n success: boolean;\n profile?: HCS11Profile;\n error?: string;\n topicInfo?: TopicInfo;\n }> {\n try {\n this.logger.debug(\n `Fetching profile for account ${accountId.toString()} on ${this.network}`,\n );\n\n const memo = await this.mirrorNode.getAccountMemo(accountId.toString());\n\n this.logger.debug(`Got account memo: ${memo}`);\n\n if (!memo?.startsWith('hcs-11:')) {\n return {\n success: false,\n error: `Account ${accountId.toString()} does not have a valid HCS-11 memo. Current memo: ${memo || 'empty'}`,\n };\n }\n\n this.logger.debug(`Found HCS-11 memo: ${memo}`);\n\n const protocolReference = memo.substring(7);\n\n if (protocolReference?.startsWith('hcs://')) {\n const hcsFormat = protocolReference.match(/hcs:\\/\\/(\\d+)\\/(.+)/);\n\n if (!hcsFormat) {\n return {\n success: false,\n error: `Invalid HCS protocol reference format: ${protocolReference}`,\n };\n }\n\n const [_, protocolId, profileTopicId] = hcsFormat;\n const networkParam = network || this.network || 'mainnet';\n\n this.logger.debug(\n `Retrieving profile from Kiloscribe CDN: ${profileTopicId}`,\n );\n const cdnUrl = `https://kiloscribe.com/api/inscription-cdn/${profileTopicId}?network=${networkParam}`;\n\n try {\n const response = await fetch(cdnUrl);\n\n if (!response.ok) {\n return {\n success: false,\n error: `Failed to fetch profile from Kiloscribe CDN: ${response.statusText}`,\n };\n }\n\n const profileData = await response.json();\n\n if (!profileData) {\n return {\n success: false,\n error: `No profile data found for topic ${profileTopicId}`,\n };\n }\n\n const parsed = HCS11ProfileSchema.safeParse(profileData);\n if (!parsed.success) {\n return {\n success: false,\n error: `Invalid HCS-11 profile data for topic ${profileTopicId}`,\n };\n }\n\n return {\n success: true,\n profile: parsed.data as HCS11Profile,\n topicInfo: {\n inboundTopic: parsed.data.inboundTopicId || '',\n outboundTopic: parsed.data.outboundTopicId || '',\n profileTopicId,\n },\n };\n } catch (cdnError) {\n this.logger.error(\n `Error retrieving from Kiloscribe CDN: ${cdnError.message}`,\n );\n return {\n success: false,\n error: `Error retrieving from Kiloscribe CDN: ${cdnError.message}`,\n };\n }\n } else if (protocolReference.startsWith('ipfs://')) {\n this.logger.warn('IPFS protocol references are not fully supported');\n const response = await fetch(\n `https://ipfs.io/ipfs/${protocolReference.replace('ipfs://', '')}`,\n );\n const profileData = await response.json();\n const parsed = HCS11ProfileSchema.safeParse(profileData);\n if (!parsed.success) {\n return {\n success: false,\n error: `Invalid HCS-11 profile data from IPFS reference ${protocolReference}`,\n };\n }\n return {\n success: true,\n profile: parsed.data as HCS11Profile,\n topicInfo: {\n inboundTopic: parsed.data.inboundTopicId || '',\n outboundTopic: parsed.data.outboundTopicId || '',\n profileTopicId: '',\n },\n };\n } else if (protocolReference.startsWith('ar://')) {\n const arTxId = protocolReference.replace('ar://', '');\n const response = await fetch(`https://arweave.net/${arTxId}`);\n\n if (!response.ok) {\n return {\n success: false,\n error: `Failed to fetch profile from Arweave ${arTxId}: ${response.statusText}`,\n };\n }\n\n const profileData = await response.json();\n const parsed = HCS11ProfileSchema.safeParse(profileData);\n if (!parsed.success) {\n return {\n success: false,\n error: `Invalid HCS-11 profile data from Arweave reference ${arTxId}`,\n };\n }\n return {\n success: true,\n profile: parsed.data as HCS11Profile,\n topicInfo: {\n inboundTopic: parsed.data.inboundTopicId || '',\n outboundTopic: parsed.data.outboundTopicId || '',\n profileTopicId: '',\n },\n };\n } else {\n return {\n success: false,\n error: `Invalid protocol reference format: ${protocolReference}`,\n };\n }\n } catch (error) {\n this.logger.error(`Error fetching profile: ${error.message}`);\n return {\n success: false,\n error: `Error fetching profile: ${error.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OAAO,KAAK,kBAAkB;AAAA,YAC5C,eAAe,OAAO,KAAK,mBAAmB;AAAA,YAC9C,gBAAgB;AAAA,UAAA;AAAA,QAClB;AAAA,MAEJ,OAAO;AACL,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,sCAAsC,iBAAiB;AAAA,QAAA;AAAA,MAElE;AAAA,IACF,SAAS,OAAO;AACd,WAAK,OAAO,MAAM,2BAA2B,MAAM,OAAO,EAAE;AAC5D,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,2BAA2B,MAAM,OAAO;AAAA,MAAA;AAAA,IAEnD;AAAA,EACF;AACF;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es28.js","sources":["../../src/hcs-11/client.ts"],"sourcesContent":["import {\n AccountId,\n AccountUpdateTransaction,\n Client,\n PrivateKey,\n Status,\n Transaction,\n} from '@hashgraph/sdk';\nimport {\n inscribe,\n inscribeWithSigner,\n InscriptionInput,\n InscriptionOptions,\n InscriptionResult,\n} from '../inscribe';\nimport { Logger, ILogger, getTopicId } from '../utils';\nimport * as mime from 'mime-types';\nimport { z, ZodIssue } from 'zod';\nimport type { DAppSigner } from '@hashgraph/hedera-wallet-connect';\nimport { ProgressReporter } from '../utils/progress-reporter';\nimport { HederaMirrorNode } from '../services';\nimport { isHederaNetwork, toHederaCaip10 } from '../hcs-14/caip';\nimport { TopicInfo } from '../services/types';\nimport {\n createNodeOperatorContext,\n type NodeOperatorContext,\n} from '../common/node-operator-resolver';\nimport { NetworkType } from '../utils/types';\nimport {\n ProfileType,\n AIAgentType,\n AIAgentCapability,\n SocialLink,\n PersonalProfile,\n AIAgentProfile,\n HCS11Profile,\n HCS11Auth,\n HCS11ClientConfig,\n TransactionResult,\n InscribeProfileResponse,\n InscribeImageResponse,\n AgentMetadata,\n InscribeImageOptions,\n InscribeProfileOptions,\n capabilityNameToCapabilityMap,\n MCPServerDetails,\n MCPServerProfile,\n MCPServerCapability,\n VerificationType,\n} from './types';\n\nexport const SocialLinkSchema = z.object({\n platform: z.string().min(1),\n handle: z.string().min(1),\n});\n\nexport const AIAgentDetailsSchema = z.object({\n type: z.nativeEnum(AIAgentType),\n capabilities: z.array(z.nativeEnum(AIAgentCapability)).min(1),\n model: z.string().min(1),\n creator: z.string().optional(),\n});\n\nexport const MCPServerConnectionInfoSchema = z.object({\n url: z.string().min(1),\n transport: z.enum(['stdio', 'sse']),\n});\n\nexport const MCPServerVerificationSchema = z.object({\n type: z.nativeEnum(VerificationType),\n value: z.string(),\n dns_field: z.string().optional(),\n challenge_path: z.string().optional(),\n});\n\nexport const MCPServerHostSchema = z.object({\n minVersion: z.string().optional(),\n});\n\nexport const MCPServerResourceSchema = z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n});\n\nexport const MCPServerToolSchema = z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n});\n\nexport const MCPServerDetailsSchema = z.object({\n version: z.string().min(1),\n connectionInfo: MCPServerConnectionInfoSchema,\n services: z.array(z.nativeEnum(MCPServerCapability)).min(1),\n description: z.string().min(1),\n verification: MCPServerVerificationSchema.optional(),\n host: MCPServerHostSchema.optional(),\n capabilities: z.array(z.string()).optional(),\n resources: z.array(MCPServerResourceSchema).optional(),\n tools: z.array(MCPServerToolSchema).optional(),\n maintainer: z.string().optional(),\n repository: z.string().optional(),\n docs: z.string().optional(),\n});\n\nexport const BaseProfileSchema = z.object({\n version: z.string().min(1),\n type: z.nativeEnum(ProfileType),\n display_name: z.string().min(1),\n alias: z.string().optional(),\n bio: z.string().optional(),\n socials: z.array(SocialLinkSchema).optional(),\n profileImage: z.string().optional(),\n uaid: z.string().optional(),\n properties: z.record(z.any()).optional(),\n inboundTopicId: z.string().optional(),\n outboundTopicId: z.string().optional(),\n base_account: z.string().optional(),\n});\n\nexport const PersonalProfileSchema = BaseProfileSchema.extend({\n type: z.literal(ProfileType.PERSONAL),\n language: z.string().optional(),\n timezone: z.string().optional(),\n});\n\nexport const AIAgentProfileSchema = BaseProfileSchema.extend({\n type: z.literal(ProfileType.AI_AGENT),\n aiAgent: AIAgentDetailsSchema,\n});\n\nexport const MCPServerProfileSchema = BaseProfileSchema.extend({\n type: z.literal(ProfileType.MCP_SERVER),\n mcpServer: MCPServerDetailsSchema,\n});\n\nconst FloraProfileSchema = z.object({\n version: z.string(),\n type: z.literal(ProfileType.FLORA),\n display_name: z.string().min(1),\n members: z.array(\n z.object({\n accountId: z.string(),\n publicKey: z.string().optional(),\n weight: z.number().optional(),\n }),\n ),\n threshold: z.number().min(1),\n topics: z.object({\n communication: z.string(),\n transaction: z.string(),\n state: z.string(),\n }),\n inboundTopicId: z.string(),\n outboundTopicId: z.string(),\n bio: z.string().optional(),\n metadata: z.record(z.any()).optional(),\n policies: z.record(z.any()).optional(),\n});\n\nexport const HCS11ProfileSchema = z.union([\n PersonalProfileSchema,\n AIAgentProfileSchema,\n MCPServerProfileSchema,\n FloraProfileSchema,\n]);\n\nexport class HCS11Client {\n private client: Client;\n private auth: HCS11Auth;\n private network: string;\n private logger: ILogger;\n private mirrorNode: HederaMirrorNode;\n private keyType: 'ed25519' | 'ecdsa';\n private operatorId: string;\n private operatorCtx?: NodeOperatorContext;\n\n constructor(config: HCS11ClientConfig) {\n this.client =\n config.network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.auth = config.auth;\n this.network = config.network;\n this.operatorId = config.auth.operatorId;\n\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS-11',\n silent: config.silent,\n });\n\n this.mirrorNode = new HederaMirrorNode(\n this.network as 'mainnet' | 'testnet',\n this.logger,\n );\n\n if (this.auth.privateKey) {\n this.operatorCtx = createNodeOperatorContext({\n network: this.network as NetworkType,\n operatorId: this.operatorId,\n operatorKey: this.auth.privateKey,\n keyType: config.keyType,\n mirrorNode: this.mirrorNode,\n logger: this.logger,\n client: this.client,\n });\n this.client = this.operatorCtx.client;\n this.keyType = this.operatorCtx.keyType;\n void this.operatorCtx.ensureInitialized();\n this.client.setOperator(\n this.operatorId.toString(),\n this.operatorCtx.operatorKey,\n );\n } else {\n this.keyType = config.keyType || 'ed25519';\n }\n }\n\n public getClient(): Client {\n return this.client;\n }\n\n public getOperatorId(): string {\n return this.auth.operatorId;\n }\n\n public async initializeOperator() {\n if (!this.operatorCtx) {\n return;\n }\n\n try {\n await this.operatorCtx.ensureInitialized();\n this.keyType = this.operatorCtx.keyType;\n this.client.setOperator(this.operatorId, this.operatorCtx.operatorKey);\n } catch (error) {\n this.logger.warn(\n `Failed to verify operator key with mirror node: ${\n (error as Error).message\n }`,\n );\n }\n }\n\n public createPersonalProfile(\n displayName: string,\n options?: {\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n language?: string;\n timezone?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n baseAccount?: string;\n },\n ): PersonalProfile {\n return {\n version: '1.0',\n type: ProfileType.PERSONAL,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n base_account: options?.baseAccount,\n };\n }\n\n public createAIAgentProfile(\n displayName: string,\n agentType: AIAgentType,\n capabilities: AIAgentCapability[],\n model: string,\n options?: {\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n creator?: string;\n baseAccount?: string;\n },\n ): AIAgentProfile {\n const validation = this.validateProfile({\n version: '1.0',\n type: ProfileType.AI_AGENT,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n base_account: options?.baseAccount,\n aiAgent: {\n type: agentType,\n capabilities,\n model,\n creator: options?.creator,\n },\n });\n\n if (!validation.valid) {\n throw new Error(\n `Invalid AI Agent Profile: ${validation.errors.join(', ')}`,\n );\n }\n\n return {\n version: '1.0',\n type: ProfileType.AI_AGENT,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n base_account: options?.baseAccount,\n aiAgent: {\n type: agentType,\n capabilities,\n model,\n creator: options?.creator,\n },\n };\n }\n\n /**\n * Creates an MCP server profile.\n *\n * @param displayName - The display name for the MCP server\n * @param serverDetails - The MCP server details\n * @param options - Additional profile options\n * @returns An MCPServerProfile object\n */\n public createMCPServerProfile(\n displayName: string,\n serverDetails: MCPServerDetails,\n options?: {\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n },\n ): MCPServerProfile {\n const validation = this.validateProfile({\n version: '1.0',\n type: ProfileType.MCP_SERVER,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n mcpServer: serverDetails,\n });\n\n if (!validation.valid) {\n throw new Error(\n `Invalid MCP Server Profile: ${validation.errors.join(', ')}`,\n );\n }\n\n return {\n version: '1.0',\n type: ProfileType.MCP_SERVER,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n mcpServer: serverDetails,\n };\n }\n\n public validateProfile(profile: unknown): {\n valid: boolean;\n errors: string[];\n } {\n const result = HCS11ProfileSchema.safeParse(profile);\n\n if (result.success) {\n return { valid: true, errors: [] };\n }\n\n const formattedErrors = result.error.errors.map((err: ZodIssue) => {\n const path = err.path.join('.');\n let message = err.message;\n\n if (err.code === 'invalid_type') {\n message = `Expected ${err.expected}, got ${err.received}`;\n } else if (err.code === 'invalid_enum_value') {\n const validOptions = err.options?.join(', ');\n message = `Invalid value. Valid options are: ${validOptions}`;\n } else if (err.code === 'too_small' && err.type === 'string') {\n message = 'Cannot be empty';\n }\n\n return `${path}: ${message}`;\n });\n\n return { valid: false, errors: formattedErrors };\n }\n\n public profileToJSONString(profile: HCS11Profile): string {\n return JSON.stringify(profile);\n }\n\n public parseProfileFromString(profileStr: string): HCS11Profile | null {\n try {\n const parsedProfile = JSON.parse(profileStr);\n const validation = this.validateProfile(parsedProfile);\n if (!validation.valid) {\n this.logger.error('Invalid profile format:', validation.errors);\n return null;\n }\n return parsedProfile as HCS11Profile;\n } catch (error) {\n this.logger.error('Error parsing profile:');\n return null;\n }\n }\n\n public setProfileForAccountMemo(\n topicId: string,\n topicStandard: 1 | 2 | 7 = 1,\n ): string {\n return `hcs-11:hcs://${topicStandard}/${topicId}`;\n }\n\n private async executeTransaction<T>(\n transaction: Transaction,\n ): Promise<TransactionResult<T>> {\n try {\n if (this.auth.privateKey) {\n const signedTx = await transaction.signWithOperator(this.client);\n const response = await signedTx.execute(this.client);\n const receipt = await response.getReceipt(this.client);\n\n if (receipt.status.toString() !== Status.Success.toString()) {\n return {\n success: false,\n error: `Transaction failed: ${receipt.status.toString()}`,\n };\n }\n\n return {\n success: true,\n result: receipt as T,\n };\n }\n\n if (!this.auth.signer) {\n throw new Error('No valid authentication method provided');\n }\n\n const signer = this.auth.signer;\n const frozenTransaction = await transaction.freezeWithSigner(signer);\n const response = await frozenTransaction.executeWithSigner(signer);\n const receipt = await response.getReceiptWithSigner(signer);\n\n if (receipt.status.toString() !== Status.Success.toString()) {\n return {\n success: false,\n error: `Transaction failed: ${receipt.status.toString()}: ${Status.Success.toString()}`,\n };\n }\n\n return {\n success: true,\n result: receipt as T,\n };\n } catch (error) {\n return {\n success: false,\n error:\n error instanceof Error\n ? error.message\n : 'Unknown error during transaction execution',\n };\n }\n }\n\n public async inscribeImage(\n buffer: Buffer,\n fileName: string,\n options?: InscribeImageOptions,\n ): Promise<InscribeImageResponse> {\n try {\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-Image',\n logger: this.logger,\n callback: progressCallback as any,\n });\n\n progressReporter.preparing('Preparing to inscribe image', 0);\n\n const mimeType = mime.lookup(fileName) || 'application/octet-stream';\n\n const waitForConfirmation = options?.waitForConfirmation ?? true;\n\n let inscriptionResponse;\n if (this.auth.signer) {\n if ('accountId' in this.auth.signer) {\n progressReporter.preparing('Using signer for inscription', 10);\n\n inscriptionResponse = await inscribeWithSigner(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n this.auth.signer as DAppSigner,\n {\n network: this.network as 'mainnet' | 'testnet',\n waitForConfirmation,\n waitMaxAttempts: 150,\n waitIntervalMs: 4000,\n logging: {\n level: 'debug',\n },\n progressCallback: data => {\n const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;\n progressReporter.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n },\n );\n } else {\n progressReporter.failed(\n 'Signer must be a DAppSigner for inscription',\n );\n throw new Error('Signer must be a DAppSigner for inscription');\n }\n } else {\n if (!this.auth.privateKey) {\n progressReporter.failed('Private key is required for inscription');\n this.logger.error('Private key is required for inscription');\n throw new Error('Private key is required for inscription');\n }\n\n progressReporter.preparing('Using private key for inscription', 10);\n\n const PK =\n this.keyType === 'ecdsa'\n ? PrivateKey.fromStringECDSA(this.auth.privateKey)\n : PrivateKey.fromStringED25519(this.auth.privateKey);\n\n inscriptionResponse = await inscribe(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n {\n accountId: this.auth.operatorId,\n privateKey: PK,\n network: this.network as 'mainnet' | 'testnet',\n },\n {\n waitForConfirmation,\n waitMaxAttempts: 150,\n waitIntervalMs: 2000,\n logging: {\n level: 'debug',\n },\n progressCallback: data => {\n const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;\n progressReporter.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n },\n );\n }\n\n if (inscriptionResponse.confirmed) {\n progressReporter.completed('Image inscription completed', {\n topicId: getTopicId(inscriptionResponse.inscription),\n });\n return {\n imageTopicId: getTopicId(inscriptionResponse.inscription) || '',\n transactionId: (inscriptionResponse.result as InscriptionResult)\n .jobId,\n success: true,\n };\n } else {\n const jobId = inscriptionResponse.quote\n ? 'quote-only'\n : (inscriptionResponse.result as InscriptionResult).jobId;\n progressReporter.verifying('Waiting for inscription confirmation', 50, {\n jobId,\n });\n return {\n imageTopicId: '',\n transactionId: jobId,\n success: false,\n error: 'Inscription not confirmed',\n };\n }\n } catch (error) {\n this.logger.error('Error inscribing image:', error);\n return {\n imageTopicId: '',\n transactionId: '',\n success: false,\n error:\n error instanceof Error ? error.message : 'Error inscribing image',\n };\n }\n }\n\n public async inscribeProfile(\n profile: HCS11Profile,\n options?: InscribeProfileOptions,\n ): Promise<InscribeProfileResponse> {\n this.logger.info('Inscribing HCS-11 profile');\n\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-Profile',\n logger: this.logger,\n callback: progressCallback,\n });\n\n await this.attachUaidIfMissing(profile);\n\n progressReporter.preparing('Validating profile data', 5);\n\n const validation = this.validateProfile(profile);\n if (!validation.valid) {\n progressReporter.failed(\n `Invalid profile: ${validation.errors.join(', ')}`,\n );\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: `Invalid profile: ${validation.errors.join(', ')}`,\n };\n }\n\n progressReporter.preparing('Formatting profile for inscription', 15);\n\n const profileJson = this.profileToJSONString(profile);\n const fileName = `profile-${profile.display_name\n .toLowerCase()\n .replace(/\\s+/g, '-')}.json`;\n\n try {\n const contentBuffer = Buffer.from(profileJson, 'utf-8');\n const contentType = 'application/json';\n\n progressReporter.preparing('Preparing profile for inscription', 20);\n\n const input: InscriptionInput = {\n type: 'buffer',\n buffer: contentBuffer,\n fileName,\n mimeType: contentType,\n };\n\n const inscriptionOptions: InscriptionOptions = {\n waitForConfirmation: true,\n mode: 'file',\n network: this.network as 'mainnet' | 'testnet',\n waitMaxAttempts: 100,\n waitIntervalMs: 2000,\n progressCallback: data => {\n const adjustedPercent =\n 20 + Number(data?.progressPercent || 0) * 0.75;\n progressReporter?.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n };\n\n progressReporter.submitting('Submitting profile to Hedera network', 30);\n\n let inscriptionResponse;\n\n if (this.auth.privateKey) {\n const PK =\n this.keyType === 'ecdsa'\n ? PrivateKey.fromStringECDSA(this.auth.privateKey)\n : PrivateKey.fromStringED25519(this.auth.privateKey);\n\n inscriptionResponse = await inscribe(\n input,\n {\n accountId: this.auth.operatorId,\n privateKey: PK,\n network: this.network as 'mainnet' | 'testnet',\n },\n inscriptionOptions,\n );\n } else if (this.auth.signer) {\n inscriptionResponse = await inscribeWithSigner(\n input,\n this.auth.signer as DAppSigner,\n inscriptionOptions,\n );\n } else {\n throw new Error(\n 'No authentication method available - neither private key nor signer',\n );\n }\n\n if (\n !inscriptionResponse.confirmed ||\n !getTopicId(inscriptionResponse.inscription)\n ) {\n progressReporter.failed('Failed to inscribe profile content');\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: 'Failed to inscribe profile content',\n };\n }\n const topicId = getTopicId(inscriptionResponse.inscription);\n\n progressReporter.completed('Profile inscription completed', {\n topicId,\n transactionId: (inscriptionResponse.result as InscriptionResult)\n .transactionId,\n });\n\n return {\n profileTopicId: topicId,\n transactionId: (inscriptionResponse.result as InscriptionResult)\n .transactionId,\n success: true,\n totalCostHbar: inscriptionResponse.costSummary?.totalCostHbar,\n };\n } catch (error) {\n progressReporter.failed(\n `Error inscribing profile: ${error.message || 'Unknown error'}`,\n );\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: error.message || 'Unknown error during inscription',\n };\n }\n }\n\n private async attachUaidIfMissing(profile: HCS11Profile): Promise<void> {\n if (profile.uaid) {\n return;\n }\n if (!isHederaNetwork(this.network)) {\n return;\n }\n try {\n const { HCS14Client } = await import('../hcs-14');\n const hcs14 = new HCS14Client({ client: this.client });\n const did = await hcs14.createDid({\n method: 'hedera',\n client: this.client,\n });\n const nativeId = toHederaCaip10(this.network, this.auth.operatorId);\n let uid = this.auth.operatorId;\n const inboundFromProfile = profile.inboundTopicId;\n if (inboundFromProfile && inboundFromProfile.trim().length > 0) {\n uid = `${inboundFromProfile}@${this.auth.operatorId}`;\n } else {\n try {\n const fetched = await this.fetchProfileByAccountId(\n this.auth.operatorId,\n this.network as 'mainnet' | 'testnet',\n );\n const inbound = fetched?.topicInfo?.inboundTopic;\n if (inbound && inbound.trim().length > 0) {\n uid = `${inbound}@${this.auth.operatorId}`;\n }\n } catch {}\n }\n\n const uaid = hcs14.createUaid(did, { proto: 'hcs-10', nativeId, uid });\n profile.uaid = uaid;\n } catch (e) {\n this.logger.warn(\n 'Hiero registrar not available; skipping UAID generation for profile',\n e,\n );\n }\n }\n\n public async updateAccountMemoWithProfile(\n accountId: string | AccountId,\n profileTopicId: string,\n signerKeys?: PrivateKey[],\n ): Promise<TransactionResult> {\n try {\n this.logger.info(\n `Updating account memo for ${accountId} with profile ${profileTopicId}`,\n );\n const memo = this.setProfileForAccountMemo(profileTopicId);\n\n const transaction = new AccountUpdateTransaction()\n .setAccountMemo(memo)\n .setAccountId(accountId);\n\n if (signerKeys && signerKeys.length > 0) {\n const frozen = await transaction.freezeWith(this.client);\n let signed = frozen;\n for (const key of signerKeys) {\n signed = await signed.sign(key);\n }\n const response = await signed.execute(this.client);\n const receipt = await response.getReceipt(this.client);\n if (receipt.status.toString() !== Status.Success.toString()) {\n return {\n success: false,\n error: `Transaction failed: ${receipt.status.toString()}`,\n };\n }\n return {\n success: true,\n result: receipt,\n };\n }\n\n return this.executeTransaction(transaction);\n } catch (error) {\n this.logger.error(\n `Error updating account memo: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n );\n return {\n success: false,\n error:\n error instanceof Error\n ? error.message\n : 'Unknown error updating account memo',\n };\n }\n }\n\n /**\n * Creates and inscribes a profile.\n *\n * @param profile - The profile to create and inscribe.\n * @param updateAccountMemo - Whether to update the account memo with the profile.\n * @param options - Optional configuration options.\n * @returns A promise that resolves to the inscription result.\n */\n public async createAndInscribeProfile(\n profile: HCS11Profile,\n updateAccountMemo = true,\n options?: InscribeProfileOptions,\n ): Promise<InscribeProfileResponse> {\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-ProfileCreation',\n logger: this.logger,\n callback: progressCallback,\n });\n\n progressReporter.preparing('Starting profile creation process', 0);\n\n const inscriptionProgress = progressReporter.createSubProgress({\n minPercent: 0,\n maxPercent: 80,\n logPrefix: 'Inscription',\n });\n\n const inscriptionResult = await this.inscribeProfile(profile, {\n ...options,\n progressCallback: data => {\n inscriptionProgress.report({\n stage: data.stage,\n message: data.message,\n progressPercent: data.progressPercent,\n details: data.details,\n });\n },\n });\n\n if (!inscriptionResult?.success) {\n progressReporter.failed('Profile inscription failed', {\n error: inscriptionResult?.error,\n });\n return inscriptionResult;\n }\n\n progressReporter.confirming('Profile inscribed, updating account memo', 85);\n\n if (updateAccountMemo) {\n const memoResult = await this.updateAccountMemoWithProfile(\n this.auth.operatorId,\n inscriptionResult.profileTopicId,\n );\n\n if (!memoResult.success) {\n progressReporter.failed('Failed to update account memo', {\n error: memoResult?.error,\n });\n return {\n ...inscriptionResult,\n success: false,\n error: memoResult?.error,\n };\n }\n }\n\n progressReporter.completed('Profile creation completed successfully', {\n profileTopicId: inscriptionResult.profileTopicId,\n transactionId: inscriptionResult.transactionId,\n totalCostHbar: inscriptionResult.totalCostHbar,\n });\n\n return inscriptionResult;\n }\n\n /**\n * Gets the capabilities from the capability names.\n *\n * @param capabilityNames - The capability names to get the capabilities for.\n * @returns The capabilities.\n */\n public async getCapabilitiesFromTags(\n capabilityNames: string[],\n ): Promise<number[]> {\n const capabilities: number[] = [];\n\n if (capabilityNames.length === 0) {\n return [AIAgentCapability.TEXT_GENERATION];\n }\n\n for (const capabilityName of capabilityNames) {\n const capability =\n capabilityNameToCapabilityMap[capabilityName.toLowerCase()];\n if (capability !== undefined && !capabilities.includes(capability)) {\n capabilities.push(capability);\n }\n }\n\n if (capabilities.length === 0) {\n capabilities.push(AIAgentCapability.TEXT_GENERATION);\n }\n\n return capabilities;\n }\n\n /**\n * Gets the agent type from the metadata.\n *\n * @param metadata - The metadata of the agent.\n * @returns The agent type.\n */\n public getAgentTypeFromMetadata(metadata: AgentMetadata): AIAgentType {\n if (metadata.type === 'autonomous') {\n return AIAgentType.AUTONOMOUS;\n } else {\n return AIAgentType.MANUAL;\n }\n }\n\n /**\n * Fetches a profile from the account memo.\n *\n * @param accountId - The account ID of the agent to fetch the profile for.\n * @param network - The network to use for the fetch.\n * @returns A promise that resolves to the profile.\n */\n public async fetchProfileByAccountId(\n accountId: string | AccountId,\n network?: string,\n ): Promise<{\n success: boolean;\n profile?: HCS11Profile;\n error?: string;\n topicInfo?: TopicInfo;\n }> {\n try {\n this.logger.debug(\n `Fetching profile for account ${accountId.toString()} on ${this.network}`,\n );\n\n const memo = await this.mirrorNode.getAccountMemo(accountId.toString());\n\n this.logger.debug(`Got account memo: ${memo}`);\n\n if (!memo?.startsWith('hcs-11:')) {\n return {\n success: false,\n error: `Account ${accountId.toString()} does not have a valid HCS-11 memo. Current memo: ${memo || 'empty'}`,\n };\n }\n\n this.logger.debug(`Found HCS-11 memo: ${memo}`);\n\n const protocolReference = memo.substring(7);\n\n if (protocolReference?.startsWith('hcs://')) {\n const hcsFormat = protocolReference.match(/hcs:\\/\\/(\\d+)\\/(.+)/);\n\n if (!hcsFormat) {\n return {\n success: false,\n error: `Invalid HCS protocol reference format: ${protocolReference}`,\n };\n }\n\n const [_, protocolId, profileTopicId] = hcsFormat;\n const networkParam = network || this.network || 'mainnet';\n\n this.logger.debug(\n `Retrieving profile from Kiloscribe CDN: ${profileTopicId}`,\n );\n const cdnUrl = `https://kiloscribe.com/api/inscription-cdn/${profileTopicId}?network=${networkParam}`;\n\n try {\n const response = await fetch(cdnUrl);\n\n if (!response.ok) {\n return {\n success: false,\n error: `Failed to fetch profile from Kiloscribe CDN: ${response.statusText}`,\n };\n }\n\n const profileData = await response.json();\n\n if (!profileData) {\n return {\n success: false,\n error: `No profile data found for topic ${profileTopicId}`,\n };\n }\n\n const parsed = HCS11ProfileSchema.safeParse(profileData);\n if (!parsed.success) {\n return {\n success: false,\n error: `Invalid HCS-11 profile data for topic ${profileTopicId}`,\n };\n }\n\n return {\n success: true,\n profile: parsed.data as HCS11Profile,\n topicInfo: {\n inboundTopic: parsed.data.inboundTopicId || '',\n outboundTopic: parsed.data.outboundTopicId || '',\n profileTopicId,\n },\n };\n } catch (cdnError) {\n this.logger.error(\n `Error retrieving from Kiloscribe CDN: ${cdnError.message}`,\n );\n return {\n success: false,\n error: `Error retrieving from Kiloscribe CDN: ${cdnError.message}`,\n };\n }\n } else if (protocolReference.startsWith('ipfs://')) {\n this.logger.warn('IPFS protocol references are not fully supported');\n const response = await fetch(\n `https://ipfs.io/ipfs/${protocolReference.replace('ipfs://', '')}`,\n );\n const profileData = await response.json();\n const parsed = HCS11ProfileSchema.safeParse(profileData);\n if (!parsed.success) {\n return {\n success: false,\n error: `Invalid HCS-11 profile data from IPFS reference ${protocolReference}`,\n };\n }\n return {\n success: true,\n profile: parsed.data as HCS11Profile,\n topicInfo: {\n inboundTopic: parsed.data.inboundTopicId || '',\n outboundTopic: parsed.data.outboundTopicId || '',\n profileTopicId: '',\n },\n };\n } else if (protocolReference.startsWith('ar://')) {\n const arTxId = protocolReference.replace('ar://', '');\n const response = await fetch(`https://arweave.net/${arTxId}`);\n\n if (!response.ok) {\n return {\n success: false,\n error: `Failed to fetch profile from Arweave ${arTxId}: ${response.statusText}`,\n };\n }\n\n const profileData = await response.json();\n const parsed = HCS11ProfileSchema.safeParse(profileData);\n if (!parsed.success) {\n return {\n success: false,\n error: `Invalid HCS-11 profile data from Arweave reference ${arTxId}`,\n };\n }\n return {\n success: true,\n profile: parsed.data as HCS11Profile,\n topicInfo: {\n inboundTopic: parsed.data.inboundTopicId || '',\n outboundTopic: parsed.data.outboundTopicId || '',\n profileTopicId: '',\n },\n };\n } else {\n return {\n success: false,\n error: `Invalid protocol reference format: ${protocolReference}`,\n };\n }\n } catch (error) {\n this.logger.error(`Error fetching profile: ${error.message}`);\n return {\n success: false,\n error: `Error fetching profile: ${error.message}`,\n };\n }\n }\n}\n"],"names":["response","receipt"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDO,MAAM,mBAAmB,EAAE,OAAO;AAAA,EACvC,UAAU,EAAE,SAAS,IAAI,CAAC;AAAA,EAC1B,QAAQ,EAAE,OAAA,EAAS,IAAI,CAAC;AAC1B,CAAC;AAEM,MAAM,uBAAuB,EAAE,OAAO;AAAA,EAC3C,MAAM,EAAE,WAAW,WAAW;AAAA,EAC9B,cAAc,EAAE,MAAM,EAAE,WAAW,iBAAiB,CAAC,EAAE,IAAI,CAAC;AAAA,EAC5D,OAAO,EAAE,SAAS,IAAI,CAAC;AAAA,EACvB,SAAS,EAAE,OAAA,EAAS,SAAA;AACtB,CAAC;AAEM,MAAM,gCAAgC,EAAE,OAAO;AAAA,EACpD,KAAK,EAAE,SAAS,IAAI,CAAC;AAAA,EACrB,WAAW,EAAE,KAAK,CAAC,SAAS,KAAK,CAAC;AACpC,CAAC;AAEM,MAAM,8BAA8B,EAAE,OAAO;AAAA,EAClD,MAAM,EAAE,WAAW,gBAAgB;AAAA,EACnC,OAAO,EAAE,OAAA;AAAA,EACT,WAAW,EAAE,OAAA,EAAS,SAAA;AAAA,EACtB,gBAAgB,EAAE,OAAA,EAAS,SAAA;AAC7B,CAAC;AAEM,MAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,YAAY,EAAE,OAAA,EAAS,SAAA;AACzB,CAAC;AAEM,MAAM,0BAA0B,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KAAK,SAAS,UAAU;AAAA,UAAA;AAAA,QAEjF;AAEA,cAAM,cAAc,MAAM,SAAS,KAAA;AACnC,cAAM,SAAS,mBAAmB,UAAU,WAAW;AACvD,YAAI,CAAC,OAAO,SAAS;AACnB,iBAAO;AAAA,YACL,SAAS;AAAA,YACT,OAAO,sDAAsD,MAAM;AAAA,UAAA;AAAA,QAEvE;AACA,eAAO;AAAA,UACL,SAAS;AAAA,UACT,SAAS,OAAO;AAAA,UAChB,WAAW;AAAA,YACT,cAAc,OAAO,KAAK,kBAAkB;AAAA,YAC5C,eAAe,OAAO,KAAK,mBAAmB;AAAA,YAC9C,gBAAgB;AAAA,UAAA;AAAA,QAClB;AAAA,MAEJ,OAAO;AACL,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,sCAAsC,iBAAiB;AAAA,QAAA;AAAA,MAElE;AAAA,IACF,SAAS,OAAO;AACd,WAAK,OAAO,MAAM,2BAA2B,MAAM,OAAO,EAAE;AAC5D,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO,2BAA2B,MAAM,OAAO;AAAA,MAAA;AAAA,IAEnD;AAAA,EACF;AACF;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RegistryType } from "./standards-sdk.es30.js";
|
|
2
2
|
import { inscribe, inscribeWithSigner } from "./standards-sdk.es125.js";
|
|
3
|
-
import "./standards-sdk.
|
|
3
|
+
import "./standards-sdk.es151.js";
|
|
4
4
|
class BaseRegistry {
|
|
5
5
|
constructor(networkType, logger, registryType, topicId, client) {
|
|
6
6
|
this.entries = /* @__PURE__ */ new Map();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RegistryType } from "./standards-sdk.es30.js";
|
|
2
2
|
import { BaseRegistry } from "./standards-sdk.es31.js";
|
|
3
3
|
import { retrieveInscription } from "./standards-sdk.es125.js";
|
|
4
|
-
import "./standards-sdk.
|
|
4
|
+
import "./standards-sdk.es151.js";
|
|
5
5
|
import { getCryptoAdapter } from "./standards-sdk.es120.js";
|
|
6
6
|
import { isSSREnvironment } from "./standards-sdk.es118.js";
|
|
7
7
|
import { validateActionRegistration } from "./standards-sdk.es43.js";
|
|
@@ -8,14 +8,13 @@ import "./standards-sdk.es132.js";
|
|
|
8
8
|
import "./standards-sdk.es133.js";
|
|
9
9
|
import "./standards-sdk.es134.js";
|
|
10
10
|
import "./standards-sdk.es135.js";
|
|
11
|
-
import "./standards-sdk.es136.js";
|
|
12
11
|
import "buffer";
|
|
13
12
|
import "crypto";
|
|
14
13
|
import "@noble/curves/secp256k1.js";
|
|
15
14
|
import "zod";
|
|
16
|
-
import "./standards-sdk.
|
|
15
|
+
import "./standards-sdk.es150.js";
|
|
17
16
|
import "./standards-sdk.es140.js";
|
|
18
|
-
import "./standards-sdk.
|
|
17
|
+
import "./standards-sdk.es151.js";
|
|
19
18
|
import "@hashgraph/proto";
|
|
20
19
|
import "@hashgraph/sdk";
|
|
21
20
|
import "ethers";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es36.js","sources":["../../src/hcs-12/base-client.ts"],"sourcesContent":["import { ILogger, Logger, LogLevel } from '../utils/logger';\nimport { NetworkType } from '../utils/types';\nimport { HederaMirrorNode, MirrorNodeConfig } from '../services';\nimport { PrivateKey, PublicKey } from '@hashgraph/sdk';\nimport {\n ActionRegistry,\n BlockLoader,\n AssemblyRegistry,\n HashLinksRegistry,\n} from './registries';\nimport {\n ActionRegistration,\n BlockDefinition,\n AssemblyRegistration,\n HashLinksRegistration,\n RegistryType,\n AssemblyState,\n} from './types';\nimport { AssemblyEngine, Assembly } from './assembly';\n\n/**\n * Configuration for HCS-12 client\n */\nexport interface HCS12Config {\n /** The Hedera network to connect to */\n network: NetworkType;\n /** Custom logger instance (if not provided, one will be created) */\n logger?: ILogger;\n /** Log level for the client (ignored if logger is provided) */\n logLevel?: LogLevel;\n /** Whether to pretty print logs (ignored if logger is provided) */\n prettyPrint?: boolean;\n /** Custom mirror node configuration */\n mirrorNode?: MirrorNodeConfig;\n /** Whether to run logger in silent mode (ignored if logger is provided) */\n silent?: boolean;\n /** The key type to use for the operator */\n keyType?: 'ed25519' | 'ecdsa';\n}\n\n/**\n * Abstract base class for HCS-12 HashLinks clients\n */\nexport abstract class HCS12BaseClient {\n protected network: NetworkType;\n protected logger: ILogger;\n public mirrorNode: HederaMirrorNode;\n\n protected _actionRegistry?: ActionRegistry;\n protected _blockLoader?: BlockLoader;\n protected _assemblyRegistry?: AssemblyRegistry;\n protected _hashLinksRegistry?: HashLinksRegistry;\n protected _assemblyEngine?: AssemblyEngine;\n\n protected actionRegistryTopicId?: string;\n protected _assemblyRegistryTopicId?: string;\n protected _hashLinksRegistryTopicId?: string;\n\n constructor(config: HCS12Config) {\n this.network = config.network;\n\n this.logger =\n config.logger ||\n Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS12-BaseClient',\n prettyPrint: config.prettyPrint,\n silent: config.silent,\n });\n\n this.mirrorNode = new HederaMirrorNode(\n config.network,\n this.logger,\n config.mirrorNode,\n );\n }\n\n /**\n * Initialize registries with optional existing topic IDs\n */\n protected initializeRegistries(topicIds?: {\n action?: string;\n assembly?: string;\n hashlinks?: string;\n }): void {\n this.actionRegistryTopicId = topicIds?.action;\n this._assemblyRegistryTopicId = topicIds?.assembly;\n this._hashLinksRegistryTopicId = topicIds?.hashlinks;\n }\n\n /**\n * Create a new HCS topic for a registry\n */\n abstract createRegistryTopic(\n registryType: RegistryType,\n adminKey?: boolean | PublicKey,\n submitKey?: boolean | PublicKey,\n ): Promise<string>;\n\n /**\n * Submit a message to an HCS topic\n */\n abstract submitMessage(\n topicId: string,\n message: string,\n submitKey?: PrivateKey,\n ): Promise<{ transactionId: string; sequenceNumber?: number }>;\n\n /**\n * Register a new assembly in the assembly registry\n */\n async registerAssembly(\n registration: AssemblyRegistration,\n ): Promise<{ id: string; transactionId?: string }> {\n if (!this._assemblyRegistry) {\n throw new Error('Assembly registry not initialized');\n }\n\n const id = await this._assemblyRegistry.register(registration);\n return { id };\n }\n\n /**\n * Get action by hash\n */\n async getAction(hash: string): Promise<ActionRegistration | null> {\n if (!this._actionRegistry) {\n throw new Error('Action registry not initialized');\n }\n\n return this._actionRegistry.getAction(hash);\n }\n\n /**\n * Load block from HCS-1\n */\n async loadBlock(blockTopicId: string): Promise<{\n definition: BlockDefinition;\n template: string;\n }> {\n if (!this._blockLoader) {\n this._blockLoader = new BlockLoader(\n this.network,\n this.logger,\n this as any,\n );\n }\n\n return this._blockLoader.loadBlock(blockTopicId);\n }\n\n /**\n * Get assembly by name and version\n */\n async getAssembly(\n name: string,\n version: string,\n ): Promise<AssemblyState | null> {\n if (!this._assemblyRegistry) {\n throw new Error('Assembly registry not initialized');\n }\n\n const entries = await this._assemblyRegistry.listEntries();\n for (const entry of entries) {\n const state = await this._assemblyRegistry.getAssemblyState(entry.id);\n if (state && state.name === name && state.version === version) {\n return state;\n }\n }\n return null;\n }\n\n /**\n * Load and resolve a complete assembly by topic ID\n */\n async loadAssembly(topicId: string): Promise<Assembly> {\n if (this._actionRegistry) {\n this.logger.info('Syncing action registry before loading assembly');\n await this._actionRegistry.sync();\n }\n\n const assemblyRegistry = new AssemblyRegistry(\n this.network,\n this.logger,\n topicId,\n this as any,\n );\n\n await assemblyRegistry.sync();\n\n const assemblyEngine = new AssemblyEngine(\n this.logger,\n assemblyRegistry,\n this._actionRegistry!,\n this._blockLoader!,\n );\n\n return assemblyEngine.loadAndResolveAssembly(topicId);\n }\n\n /**\n * Get assembly state by topic ID (without resolving references)\n */\n async getAssemblyState(topicId: string): Promise<AssemblyState | null> {\n if (!this._assemblyRegistry) {\n throw new Error('Assembly registry not initialized');\n }\n return this._assemblyRegistry.getAssemblyState(topicId);\n }\n\n /**\n * Ensure assembly engine is initialized\n */\n protected ensureAssemblyEngine(): void {\n if (!this._assemblyEngine) {\n if (\n !this._actionRegistry ||\n !this._blockLoader ||\n !this._assemblyRegistry\n ) {\n throw new Error(\n 'Registries must be initialized before assembly engine',\n );\n }\n this._assemblyEngine = new AssemblyEngine(\n this.logger,\n this._assemblyRegistry,\n this._actionRegistry,\n this._blockLoader,\n );\n }\n }\n\n /**\n * Register a new HashLink in the global directory\n */\n async registerHashLink(\n registration: HashLinksRegistration,\n ): Promise<{ id: string; transactionId?: string }> {\n if (!this._hashLinksRegistry) {\n throw new Error('HashLinks registry not initialized');\n }\n\n const id = await this._hashLinksRegistry.register(registration);\n return { id };\n }\n\n /**\n * Search HashLinks by tags\n */\n async searchHashLinksByTags(\n tags: string[],\n ): Promise<HashLinksRegistration[]> {\n if (!this._hashLinksRegistry) {\n throw new Error('HashLinks registry not initialized');\n }\n\n return this._hashLinksRegistry.searchByTags(tags);\n }\n\n /**\n * Search HashLinks by name\n */\n async searchHashLinksByName(\n searchTerm: string,\n ): Promise<HashLinksRegistration[]> {\n if (!this._hashLinksRegistry) {\n throw new Error('HashLinks registry not initialized');\n }\n\n return this._hashLinksRegistry.searchByName(searchTerm);\n }\n\n /**\n * Get featured HashLinks\n */\n async getFeaturedHashLinks(): Promise<HashLinksRegistration[]> {\n if (!this._hashLinksRegistry) {\n throw new Error('HashLinks registry not initialized');\n }\n\n return this._hashLinksRegistry.getFeatured();\n }\n\n /**\n * Get HashLinks by category\n */\n async getHashLinksByCategory(\n category: string,\n ): Promise<HashLinksRegistration[]> {\n if (!this._hashLinksRegistry) {\n throw new Error('HashLinks registry not initialized');\n }\n\n return this._hashLinksRegistry.getByCategory(category);\n }\n\n /**\n * Sync all registries with the network\n */\n async syncRegistries(): Promise<void> {\n const promises: Promise<void>[] = [];\n\n if (this._actionRegistry) {\n promises.push(this._actionRegistry.sync());\n }\n if (this._assemblyRegistry) {\n promises.push(this._assemblyRegistry.sync());\n }\n if (this._hashLinksRegistry) {\n promises.push(this._hashLinksRegistry.sync());\n }\n\n await Promise.all(promises);\n }\n\n /**\n * Get registry topic IDs\n */\n getRegistryTopicIds(): {\n action?: string;\n assembly?: string;\n hashlinks?: string;\n } {\n return {\n action: this.actionRegistryTopicId,\n assembly: this._assemblyRegistryTopicId,\n hashlinks: this._hashLinksRegistryTopicId,\n };\n }\n\n /**\n * Clear all registry caches\n */\n clearCaches(): void {\n this._actionRegistry?.clearCache();\n this._blockLoader?.clearCache();\n this._assemblyRegistry?.clearCache();\n this._hashLinksRegistry?.clearCache();\n }\n\n /**\n * Get the action registry instance\n */\n get actionRegistry(): ActionRegistry | undefined {\n return this._actionRegistry;\n }\n\n /**\n * Get the block loader instance\n */\n get blockLoader(): BlockLoader | undefined {\n return this._blockLoader;\n }\n\n /**\n * Get the assembly registry instance\n */\n get assemblyRegistry(): AssemblyRegistry | undefined {\n return this._assemblyRegistry;\n }\n\n /**\n * Get the HashLinks registry instance\n */\n get hashLinksRegistry(): HashLinksRegistry | undefined {\n return this._hashLinksRegistry;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CO,MAAe,gBAAgB;AAAA,EAepC,YAAY,QAAqB;AAC/B,SAAK,UAAU,OAAO;AAEtB,SAAK,SACH,OAAO,UACP,OAAO,YAAY;AAAA,MACjB,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,MACR,aAAa,OAAO;AAAA,MACpB,QAAQ,OAAO;AAAA,IAAA,CAChB;AAEH,SAAK,aAAa,IAAI;AAAA,MACpB,OAAO;AAAA,MACP,KAAK;AAAA,MACL,OAAO;AAAA,IAAA;AAAA,EAEX;AAAA;AAAA;AAAA;AAAA,EAKU,qBAAqB,UAItB;AACP,SAAK,wBAAwB,UAAU;AACvC,SAAK,2BAA2B,UAAU;AAC1C,SAAK,4BAA4B,UAAU;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA,EAuBA,MAAM,iBACJ,cACiD;AACjD,QAAI,CAAC,KAAK,mBAAmB;AAC3B,YAAM,IAAI,MAAM,mCAAmC;AAAA,IACrD;AAEA,UAAM,KAAK,MAAM,KAAK,kBAAkB,SAAS,YAAY;AAC7D,WAAO,EAAE,GAAA;AAAA,EACX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A,MAAM,uBACJ,UACkC;AAClC,QAAI,CAAC,KAAK,oBAAoB;AAC5B,YAAM,IAAI,MAAM,oCAAoC;AAAA,IACtD;AAEA,WAAO,KAAK,mBAAmB,cAAc,QAAQ;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,iBAAgC;AACpC,UAAM,WAA4B,CAAA;AAElC,QAAI,KAAK,iBAAiB;AACxB,eAAS,KAAK,KAAK,gBAAgB,KAAA,CAAM;AAAA,IAC3C;AACA,QAAI,KAAK,mBAAmB;AAC1B,eAAS,KAAK,KAAK,kBAAkB,KAAA,CAAM;AAAA,IAC7C;AACA,QAAI,KAAK,oBAAoB;AAC3B,eAAS,KAAK,KAAK,mBAAmB,KAAA,CAAM;AAAA,IAC9C;AAEA,UAAM,QAAQ,IAAI,QAAQ;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKA,sBAIE;AACA,WAAO;AAAA,MACL,QAAQ,KAAK;AAAA,MACb,UAAU,KAAK;AAAA,MACf,WAAW,KAAK;AAAA,IAAA;AAAA,EAEpB;AAAA;AAAA;AAAA;AAAA,EAKA,cAAoB;AAClB,SAAK,iBAAiB,WAAA;AACtB,SAAK,cAAc,WAAA;AACnB,SAAK,mBAAmB,WAAA;AACxB,SAAK,oBAAoB,WAAA;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,iBAA6C;AAC/C,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,cAAuC;AACzC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,mBAAiD;AACnD,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,oBAAmD;AACrD,WAAO,KAAK;AAAA,EACd;AACF;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es36.js","sources":["../../src/hcs-12/base-client.ts"],"sourcesContent":["import { ILogger, Logger, LogLevel } from '../utils/logger';\nimport { NetworkType } from '../utils/types';\nimport { HederaMirrorNode, MirrorNodeConfig } from '../services';\nimport { PrivateKey, PublicKey } from '@hashgraph/sdk';\nimport {\n ActionRegistry,\n BlockLoader,\n AssemblyRegistry,\n HashLinksRegistry,\n} from './registries';\nimport {\n ActionRegistration,\n BlockDefinition,\n AssemblyRegistration,\n HashLinksRegistration,\n RegistryType,\n AssemblyState,\n} from './types';\nimport { AssemblyEngine, Assembly } from './assembly';\n\n/**\n * Configuration for HCS-12 client\n */\nexport interface HCS12Config {\n /** The Hedera network to connect to */\n network: NetworkType;\n /** Custom logger instance (if not provided, one will be created) */\n logger?: ILogger;\n /** Log level for the client (ignored if logger is provided) */\n logLevel?: LogLevel;\n /** Whether to pretty print logs (ignored if logger is provided) */\n prettyPrint?: boolean;\n /** Custom mirror node configuration */\n mirrorNode?: MirrorNodeConfig;\n /** Whether to run logger in silent mode (ignored if logger is provided) */\n silent?: boolean;\n /** The key type to use for the operator */\n keyType?: 'ed25519' | 'ecdsa';\n}\n\n/**\n * Abstract base class for HCS-12 HashLinks clients\n */\nexport abstract class HCS12BaseClient {\n protected network: NetworkType;\n protected logger: ILogger;\n public mirrorNode: HederaMirrorNode;\n\n protected _actionRegistry?: ActionRegistry;\n protected _blockLoader?: BlockLoader;\n protected _assemblyRegistry?: AssemblyRegistry;\n protected _hashLinksRegistry?: HashLinksRegistry;\n protected _assemblyEngine?: AssemblyEngine;\n\n protected actionRegistryTopicId?: string;\n protected _assemblyRegistryTopicId?: string;\n protected _hashLinksRegistryTopicId?: string;\n\n constructor(config: HCS12Config) {\n this.network = config.network;\n\n this.logger =\n config.logger ||\n Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS12-BaseClient',\n prettyPrint: config.prettyPrint,\n silent: config.silent,\n });\n\n this.mirrorNode = new HederaMirrorNode(\n config.network,\n this.logger,\n config.mirrorNode,\n );\n }\n\n /**\n * Initialize registries with optional existing topic IDs\n */\n protected initializeRegistries(topicIds?: {\n action?: string;\n assembly?: string;\n hashlinks?: string;\n }): void {\n this.actionRegistryTopicId = topicIds?.action;\n this._assemblyRegistryTopicId = topicIds?.assembly;\n this._hashLinksRegistryTopicId = topicIds?.hashlinks;\n }\n\n /**\n * Create a new HCS topic for a registry\n */\n abstract createRegistryTopic(\n registryType: RegistryType,\n adminKey?: boolean | PublicKey,\n submitKey?: boolean | PublicKey,\n ): Promise<string>;\n\n /**\n * Submit a message to an HCS topic\n */\n abstract submitMessage(\n topicId: string,\n message: string,\n submitKey?: PrivateKey,\n ): Promise<{ transactionId: string; sequenceNumber?: number }>;\n\n /**\n * Register a new assembly in the assembly registry\n */\n async registerAssembly(\n registration: AssemblyRegistration,\n ): Promise<{ id: string; transactionId?: string }> {\n if (!this._assemblyRegistry) {\n throw new Error('Assembly registry not initialized');\n }\n\n const id = await this._assemblyRegistry.register(registration);\n return { id };\n }\n\n /**\n * Get action by hash\n */\n async getAction(hash: string): Promise<ActionRegistration | null> {\n if (!this._actionRegistry) {\n throw new Error('Action registry not initialized');\n }\n\n return this._actionRegistry.getAction(hash);\n }\n\n /**\n * Load block from HCS-1\n */\n async loadBlock(blockTopicId: string): Promise<{\n definition: BlockDefinition;\n template: string;\n }> {\n if (!this._blockLoader) {\n this._blockLoader = new BlockLoader(\n this.network,\n this.logger,\n this as any,\n );\n }\n\n return this._blockLoader.loadBlock(blockTopicId);\n }\n\n /**\n * Get assembly by name and version\n */\n async getAssembly(\n name: string,\n version: string,\n ): Promise<AssemblyState | null> {\n if (!this._assemblyRegistry) {\n throw new Error('Assembly registry not initialized');\n }\n\n const entries = await this._assemblyRegistry.listEntries();\n for (const entry of entries) {\n const state = await this._assemblyRegistry.getAssemblyState(entry.id);\n if (state && state.name === name && state.version === version) {\n return state;\n }\n }\n return null;\n }\n\n /**\n * Load and resolve a complete assembly by topic ID\n */\n async loadAssembly(topicId: string): Promise<Assembly> {\n if (this._actionRegistry) {\n this.logger.info('Syncing action registry before loading assembly');\n await this._actionRegistry.sync();\n }\n\n const assemblyRegistry = new AssemblyRegistry(\n this.network,\n this.logger,\n topicId,\n this as any,\n );\n\n await assemblyRegistry.sync();\n\n const assemblyEngine = new AssemblyEngine(\n this.logger,\n assemblyRegistry,\n this._actionRegistry!,\n this._blockLoader!,\n );\n\n return assemblyEngine.loadAndResolveAssembly(topicId);\n }\n\n /**\n * Get assembly state by topic ID (without resolving references)\n */\n async getAssemblyState(topicId: string): Promise<AssemblyState | null> {\n if (!this._assemblyRegistry) {\n throw new Error('Assembly registry not initialized');\n }\n return this._assemblyRegistry.getAssemblyState(topicId);\n }\n\n /**\n * Ensure assembly engine is initialized\n */\n protected ensureAssemblyEngine(): void {\n if (!this._assemblyEngine) {\n if (\n !this._actionRegistry ||\n !this._blockLoader ||\n !this._assemblyRegistry\n ) {\n throw new Error(\n 'Registries must be initialized before assembly engine',\n );\n }\n this._assemblyEngine = new AssemblyEngine(\n this.logger,\n this._assemblyRegistry,\n this._actionRegistry,\n this._blockLoader,\n );\n }\n }\n\n /**\n * Register a new HashLink in the global directory\n */\n async registerHashLink(\n registration: HashLinksRegistration,\n ): Promise<{ id: string; transactionId?: string }> {\n if (!this._hashLinksRegistry) {\n throw new Error('HashLinks registry not initialized');\n }\n\n const id = await this._hashLinksRegistry.register(registration);\n return { id };\n }\n\n /**\n * Search HashLinks by tags\n */\n async searchHashLinksByTags(\n tags: string[],\n ): Promise<HashLinksRegistration[]> {\n if (!this._hashLinksRegistry) {\n throw new Error('HashLinks registry not initialized');\n }\n\n return this._hashLinksRegistry.searchByTags(tags);\n }\n\n /**\n * Search HashLinks by name\n */\n async searchHashLinksByName(\n searchTerm: string,\n ): Promise<HashLinksRegistration[]> {\n if (!this._hashLinksRegistry) {\n throw new Error('HashLinks registry not initialized');\n }\n\n return this._hashLinksRegistry.searchByName(searchTerm);\n }\n\n /**\n * Get featured HashLinks\n */\n async getFeaturedHashLinks(): Promise<HashLinksRegistration[]> {\n if (!this._hashLinksRegistry) {\n throw new Error('HashLinks registry not initialized');\n }\n\n return this._hashLinksRegistry.getFeatured();\n }\n\n /**\n * Get HashLinks by category\n */\n async getHashLinksByCategory(\n category: string,\n ): Promise<HashLinksRegistration[]> {\n if (!this._hashLinksRegistry) {\n throw new Error('HashLinks registry not initialized');\n }\n\n return this._hashLinksRegistry.getByCategory(category);\n }\n\n /**\n * Sync all registries with the network\n */\n async syncRegistries(): Promise<void> {\n const promises: Promise<void>[] = [];\n\n if (this._actionRegistry) {\n promises.push(this._actionRegistry.sync());\n }\n if (this._assemblyRegistry) {\n promises.push(this._assemblyRegistry.sync());\n }\n if (this._hashLinksRegistry) {\n promises.push(this._hashLinksRegistry.sync());\n }\n\n await Promise.all(promises);\n }\n\n /**\n * Get registry topic IDs\n */\n getRegistryTopicIds(): {\n action?: string;\n assembly?: string;\n hashlinks?: string;\n } {\n return {\n action: this.actionRegistryTopicId,\n assembly: this._assemblyRegistryTopicId,\n hashlinks: this._hashLinksRegistryTopicId,\n };\n }\n\n /**\n * Clear all registry caches\n */\n clearCaches(): void {\n this._actionRegistry?.clearCache();\n this._blockLoader?.clearCache();\n this._assemblyRegistry?.clearCache();\n this._hashLinksRegistry?.clearCache();\n }\n\n /**\n * Get the action registry instance\n */\n get actionRegistry(): ActionRegistry | undefined {\n return this._actionRegistry;\n }\n\n /**\n * Get the block loader instance\n */\n get blockLoader(): BlockLoader | undefined {\n return this._blockLoader;\n }\n\n /**\n * Get the assembly registry instance\n */\n get assemblyRegistry(): AssemblyRegistry | undefined {\n return this._assemblyRegistry;\n }\n\n /**\n * Get the HashLinks registry instance\n */\n get hashLinksRegistry(): HashLinksRegistry | undefined {\n return this._hashLinksRegistry;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CO,MAAe,gBAAgB;AAAA,EAepC,YAAY,QAAqB;AAC/B,SAAK,UAAU,OAAO;AAEtB,SAAK,SACH,OAAO,UACP,OAAO,YAAY;AAAA,MACjB,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,MACR,a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AACtB,SAAK,cAAc,WAAA;AACnB,SAAK,mBAAmB,WAAA;AACxB,SAAK,oBAAoB,WAAA;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,iBAA6C;AAC/C,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,cAAuC;AACzC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,mBAAiD;AACnD,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,oBAAmD;AACrD,WAAO,KAAK;AAAA,EACd;AACF;"}
|
|
@@ -3,7 +3,7 @@ import { HCS12BaseClient } from "./standards-sdk.es36.js";
|
|
|
3
3
|
import { createNodeOperatorContext } from "./standards-sdk.es148.js";
|
|
4
4
|
import { RegistryType } from "./standards-sdk.es30.js";
|
|
5
5
|
import { inscribe } from "./standards-sdk.es125.js";
|
|
6
|
-
import { InscriptionSDK } from "./standards-sdk.
|
|
6
|
+
import { InscriptionSDK } from "./standards-sdk.es151.js";
|
|
7
7
|
import { ActionRegistry } from "./standards-sdk.es32.js";
|
|
8
8
|
import { BlockLoader } from "./standards-sdk.es33.js";
|
|
9
9
|
import { AssemblyRegistry } from "./standards-sdk.es34.js";
|
|
@@ -2,7 +2,7 @@ import { TopicCreateTransaction, TransactionId, AccountId, PublicKey, KeyList, T
|
|
|
2
2
|
import { HCS12BaseClient } from "./standards-sdk.es36.js";
|
|
3
3
|
import { RegistryType } from "./standards-sdk.es30.js";
|
|
4
4
|
import { inscribeWithSigner } from "./standards-sdk.es125.js";
|
|
5
|
-
import { InscriptionSDK } from "./standards-sdk.
|
|
5
|
+
import { InscriptionSDK } from "./standards-sdk.es151.js";
|
|
6
6
|
import { ActionRegistry } from "./standards-sdk.es32.js";
|
|
7
7
|
import { BlockLoader } from "./standards-sdk.es33.js";
|
|
8
8
|
import { AssemblyRegistry } from "./standards-sdk.es34.js";
|
|
@@ -178,7 +178,8 @@ class ResourceManager {
|
|
|
178
178
|
this.logger.warn("Integrity verification skipped in SSR environment");
|
|
179
179
|
return true;
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
const webCrypto = globalThis.crypto;
|
|
182
|
+
if (typeof webCrypto === "undefined" || !webCrypto.subtle) {
|
|
182
183
|
this.logger.warn(
|
|
183
184
|
"WebCrypto not available, skipping integrity verification"
|
|
184
185
|
);
|
|
@@ -187,7 +188,7 @@ class ResourceManager {
|
|
|
187
188
|
const buffer = typeof content === "string" ? new TextEncoder().encode(content) : content;
|
|
188
189
|
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
189
190
|
const copy = new Uint8Array(bytes);
|
|
190
|
-
const hashBuffer = await
|
|
191
|
+
const hashBuffer = await webCrypto.subtle.digest("SHA-256", copy.buffer);
|
|
191
192
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
192
193
|
const actualHash = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
193
194
|
return actualHash === expectedHash.toLowerCase();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es47.js","sources":["../../src/hcs-12/rendering/resource-manager.ts"],"sourcesContent":["/**\n * Resource Manager for HCS-12 HashLinks\n *\n * Manages loading and caching of resources (CSS, JS, images, templates)\n * from HCS-3 storage with integrity verification and security validation.\n */\n\nimport { Logger } from '../../utils/logger';\nimport { NetworkType } from '../../utils/types';\nimport { HCS } from '../../hcs-3/src';\nimport { isSSREnvironment } from '../../utils/crypto-env';\n\nexport interface ResourceData {\n content: string | Uint8Array;\n contentType: string;\n size: number;\n hash?: string;\n}\n\nexport interface VerifiedResource {\n content: string | Uint8Array;\n verified: boolean;\n contentType: string;\n}\n\nexport interface ResourceDependency {\n topicId: string;\n type: 'css' | 'js' | 'template' | 'image';\n depends?: string[];\n}\n\nexport interface LoadedResource {\n topicId: string;\n content: string | Uint8Array;\n contentType: string;\n type: string;\n}\n\nexport interface CacheEntry {\n data: ResourceData;\n timestamp: number;\n size: number;\n}\n\nexport interface ResourceManagerOptions {\n cacheTTL?: number;\n maxCacheSize?: number;\n maxResourceSize?: number;\n}\n\n/**\n * Resource manager for efficient loading and caching of HCS-3 resources\n */\nexport class ResourceManager {\n private logger: Logger;\n private hcs: HCS;\n private cache: Map<string, CacheEntry> = new Map();\n private options: Required<ResourceManagerOptions>;\n private currentCacheSize: number = 0;\n\n private readonly supportedImageTypes = new Set([\n 'image/png',\n 'image/jpeg',\n 'image/jpg',\n 'image/gif',\n 'image/svg+xml',\n 'image/webp',\n ]);\n\n private readonly dangerousJSPatterns = [\n /eval\\s*\\(/g,\n /Function\\s*\\(/g,\n /setTimeout\\s*\\(\\s*[\"'].*[\"']/g,\n /setInterval\\s*\\(\\s*[\"'].*[\"']/g,\n /document\\.write/g,\n /innerHTML\\s*=/g,\n /outerHTML\\s*=/g,\n ];\n\n private readonly dangerousCSSPatterns = [\n /javascript\\s*:/gi,\n /@import.*url\\s*\\(\\s*[\"']?javascript:/gi,\n /expression\\s*\\(/gi,\n /behavior\\s*:/gi,\n ];\n\n constructor(\n networkType: NetworkType,\n logger: Logger,\n hcs?: HCS,\n options: ResourceManagerOptions = {},\n ) {\n this.logger = logger;\n this.hcs = hcs || new HCS();\n this.options = {\n cacheTTL: options.cacheTTL || 300000,\n maxCacheSize: options.maxCacheSize || 50 * 1024 * 1024,\n maxResourceSize: options.maxResourceSize || 5 * 1024 * 1024,\n };\n }\n\n /**\n * Load CSS resource from HCS-3\n */\n async loadCSS(topicId: string): Promise<string> {\n this.logger.debug('Loading CSS resource', { topicId });\n\n try {\n const resource = await this.loadResource(topicId);\n\n if (resource.contentType !== 'text/css') {\n throw new Error(`Expected CSS resource, got ${resource.contentType}`);\n }\n\n const content = resource.content as string;\n const sanitized = this.sanitizeCSS(content);\n\n this.logger.debug('CSS resource loaded successfully', {\n topicId,\n size: content.length,\n sanitized: sanitized.length !== content.length,\n });\n\n return sanitized;\n } catch (error) {\n this.logger.error('Failed to load CSS resource', { topicId, error });\n throw new Error(\n `Failed to load CSS resource: ${error instanceof Error ? error.message : 'Unknown error'}`,\n );\n }\n }\n\n /**\n * Load JavaScript resource from HCS-3\n */\n async loadJS(topicId: string): Promise<string> {\n this.logger.debug('Loading JavaScript resource', { topicId });\n\n try {\n const resource = await this.loadResource(topicId);\n\n if (\n !resource.contentType.includes('javascript') &&\n !resource.contentType.includes('ecmascript')\n ) {\n throw new Error(\n `Expected JavaScript resource, got ${resource.contentType}`,\n );\n }\n\n const content = resource.content as string;\n\n if (content.length > this.options.maxResourceSize) {\n throw new Error('JavaScript resource too large');\n }\n\n const sanitized = this.sanitizeJavaScript(content);\n\n this.logger.debug('JavaScript resource loaded successfully', {\n topicId,\n size: content.length,\n sanitized: sanitized.length !== content.length,\n });\n\n return sanitized;\n } catch (error) {\n this.logger.error('Failed to load JavaScript resource', {\n topicId,\n error,\n });\n throw new Error(\n `Failed to load JavaScript resource: ${error instanceof Error ? error.message : 'Unknown error'}`,\n );\n }\n }\n\n /**\n * Load image resource from HCS-3 as Blob\n */\n async loadImage(topicId: string): Promise<Blob> {\n this.logger.debug('Loading image resource', { topicId });\n\n try {\n const resource = await this.loadResource(topicId);\n\n if (!this.supportedImageTypes.has(resource.contentType)) {\n throw new Error(`Unsupported image format: ${resource.contentType}`);\n }\n\n const content = resource.content as Uint8Array;\n const view = new Uint8Array(content); // ensures ArrayBuffer, not SharedArrayBuffer\n const blob = new Blob([view.buffer], { type: resource.contentType });\n\n this.logger.debug('Image resource loaded successfully', {\n topicId,\n size: content.length,\n type: resource.contentType,\n });\n\n return blob;\n } catch (error) {\n this.logger.error('Failed to load image resource', { topicId, error });\n throw new Error(\n `Failed to load image resource: ${error instanceof Error ? error.message : 'Unknown error'}`,\n );\n }\n }\n\n /**\n * Load template resource from HCS-3\n */\n async loadTemplate(topicId: string): Promise<string> {\n this.logger.debug('Loading template resource', { topicId });\n\n try {\n const resource = await this.loadResource(topicId);\n\n const content = resource.content as string;\n\n this.validateTemplateSyntax(content);\n\n const sanitized = this.sanitizeTemplate(content);\n\n this.logger.debug('Template resource loaded successfully', {\n topicId,\n size: content.length,\n });\n\n return sanitized;\n } catch (error) {\n this.logger.error('Failed to load template resource', { topicId, error });\n throw new Error(\n `Failed to load template resource: ${error instanceof Error ? error.message : 'Unknown error'}`,\n );\n }\n }\n\n /**\n * Load resource with integrity verification\n */\n async loadWithIntegrityCheck(\n topicId: string,\n expectedHash: string,\n ): Promise<VerifiedResource> {\n this.logger.debug('Loading resource with integrity check', {\n topicId,\n expectedHash,\n });\n\n try {\n const resource = await this.loadResource(topicId);\n\n const verified = await this.verifyIntegrity(\n resource.content,\n expectedHash,\n );\n\n if (!verified) {\n throw new Error('Resource integrity verification failed');\n }\n\n this.logger.debug('Resource integrity verified', { topicId });\n\n return {\n content: resource.content,\n verified,\n contentType: resource.contentType,\n };\n } catch (error) {\n this.logger.error('Resource integrity check failed', { topicId, error });\n throw error;\n }\n }\n\n /**\n * Verify content integrity using SHA-256 hash\n */\n private async verifyIntegrity(\n content: string | Uint8Array,\n expectedHash: string,\n ): Promise<boolean> {\n try {\n if (isSSREnvironment()) {\n this.logger.warn('Integrity verification skipped in SSR environment');\n return true;\n }\n\n if (typeof crypto === 'undefined' || !crypto.subtle) {\n this.logger.warn(\n 'WebCrypto not available, skipping integrity verification',\n );\n return true;\n }\n\n const buffer =\n typeof content === 'string'\n ? new TextEncoder().encode(content)\n : content;\n\n const bytes =\n buffer instanceof Uint8Array\n ? buffer\n : new Uint8Array(buffer as ArrayBufferLike);\n const copy = new Uint8Array(bytes);\n const hashBuffer = await crypto.subtle.digest('SHA-256', copy.buffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const actualHash = hashArray\n .map(b => b.toString(16).padStart(2, '0'))\n .join('');\n\n return actualHash === expectedHash.toLowerCase();\n } catch (error) {\n this.logger.error('Error verifying integrity', { error });\n return false;\n }\n }\n\n /**\n * Load multiple dependencies in correct order\n */\n async loadDependencies(\n dependencies: ResourceDependency[],\n ): Promise<LoadedResource[]> {\n this.logger.debug('Loading dependencies', { count: dependencies.length });\n\n try {\n this.detectCircularDependencies(dependencies);\n\n const sorted = this.topologicalSort(dependencies);\n\n const results: LoadedResource[] = [];\n\n for (const dep of sorted) {\n let content: string | Uint8Array;\n\n switch (dep.type) {\n case 'css':\n content = await this.loadCSS(dep.topicId);\n break;\n case 'js':\n content = await this.loadJS(dep.topicId);\n break;\n case 'template':\n content = await this.loadTemplate(dep.topicId);\n break;\n case 'image':\n const blob = await this.loadImage(dep.topicId);\n content = new Uint8Array(await blob.arrayBuffer());\n break;\n default:\n throw new Error(`Unsupported dependency type: ${dep.type}`);\n }\n\n results.push({\n topicId: dep.topicId,\n content,\n contentType: this.getContentTypeForType(dep.type),\n type: dep.type,\n });\n }\n\n this.logger.debug('Dependencies loaded successfully', {\n count: results.length,\n });\n return results;\n } catch (error) {\n this.logger.error('Failed to load dependencies', { error });\n throw error;\n }\n }\n\n /**\n * Clear resource cache\n */\n clearCache(): void {\n this.cache.clear();\n this.currentCacheSize = 0;\n this.logger.debug('Resource cache cleared');\n }\n\n /**\n * Get current cache size for testing\n */\n getCacheSize(): number {\n return this.currentCacheSize;\n }\n\n /**\n * Load resource with caching\n */\n private async loadResource(topicId: string): Promise<ResourceData> {\n const cached = this.getFromCache(topicId);\n if (cached) {\n this.logger.debug('Resource loaded from cache', { topicId });\n return cached;\n }\n\n const blob = await this.hcs.retrieveHCS1Data(topicId);\n\n const contentType = blob.type || 'application/octet-stream';\n\n let content: string | Uint8Array;\n if (\n contentType.startsWith('text/') ||\n contentType.includes('javascript') ||\n contentType.includes('json')\n ) {\n content = await blob.text();\n } else {\n content = new Uint8Array(await blob.arrayBuffer());\n }\n\n const resource: ResourceData = {\n content,\n contentType,\n size: blob.size,\n };\n\n this.addToCache(topicId, resource);\n\n return resource;\n }\n\n /**\n * Get resource from cache if valid\n */\n private getFromCache(topicId: string): ResourceData | null {\n const entry = this.cache.get(topicId);\n if (!entry) return null;\n\n if (Date.now() - entry.timestamp > this.options.cacheTTL) {\n this.removeFromCache(topicId);\n return null;\n }\n\n return entry.data;\n }\n\n /**\n * Add resource to cache with size management\n */\n private addToCache(topicId: string, resource: ResourceData): void {\n const size =\n typeof resource.content === 'string'\n ? resource.content.length\n : resource.content.byteLength;\n\n if (size > this.options.maxCacheSize / 2) {\n this.logger.warn('Resource too large for cache', { topicId, size });\n return;\n }\n\n while (\n this.currentCacheSize + size > this.options.maxCacheSize &&\n this.cache.size > 0\n ) {\n this.evictOldestEntry();\n }\n\n const entry: CacheEntry = {\n data: resource,\n timestamp: Date.now(),\n size,\n };\n\n this.cache.set(topicId, entry);\n this.currentCacheSize += size;\n\n this.logger.debug('Resource added to cache', {\n topicId,\n size,\n totalCacheSize: this.currentCacheSize,\n });\n }\n\n /**\n * Remove resource from cache\n */\n private removeFromCache(topicId: string): void {\n const entry = this.cache.get(topicId);\n if (entry) {\n this.cache.delete(topicId);\n this.currentCacheSize -= entry.size;\n }\n }\n\n /**\n * Evict oldest cache entry\n */\n private evictOldestEntry(): void {\n let oldest: string | null = null;\n let oldestTime = Date.now();\n\n for (const [topicId, entry] of this.cache) {\n if (entry.timestamp < oldestTime) {\n oldestTime = entry.timestamp;\n oldest = topicId;\n }\n }\n\n if (oldest) {\n this.removeFromCache(oldest);\n this.logger.debug('Evicted oldest cache entry', { topicId: oldest });\n }\n }\n\n /**\n * Sanitize CSS content\n */\n private sanitizeCSS(css: string): string {\n let sanitized = css;\n\n for (const pattern of this.dangerousCSSPatterns) {\n sanitized = sanitized.replace(pattern, '');\n }\n\n return sanitized;\n }\n\n /**\n * Sanitize JavaScript content\n */\n private sanitizeJavaScript(js: string): string {\n let sanitized = js;\n\n for (const pattern of this.dangerousJSPatterns) {\n sanitized = sanitized.replace(pattern, '');\n }\n\n return sanitized;\n }\n\n /**\n * Sanitize template content\n */\n private sanitizeTemplate(template: string): string {\n return template\n .replace(/<script\\b[^<]*(?:(?!<\\/script>)<[^<]*)*<\\/script>/gi, '')\n .replace(/on\\w+\\s*=\\s*[\"'][^\"']*[\"']/gi, '')\n .replace(/javascript\\s*:/gi, '');\n }\n\n /**\n * Validate template syntax\n */\n private validateTemplateSyntax(template: string): void {\n const openBraces = (template.match(/\\{\\{/g) || []).length;\n const closeBraces = (template.match(/\\}\\}/g) || []).length;\n\n if (openBraces !== closeBraces) {\n throw new Error('Invalid template syntax: unmatched braces');\n }\n\n const openBlocks = (template.match(/\\{\\{#\\w+/g) || []).length;\n const closeBlocks = (template.match(/\\{\\{\\/\\w+/g) || []).length;\n\n if (openBlocks !== closeBlocks) {\n throw new Error('Invalid template syntax: unclosed block helpers');\n }\n }\n\n /**\n * Detect circular dependencies\n */\n private detectCircularDependencies(dependencies: ResourceDependency[]): void {\n const dependencyMap = new Map<string, string[]>();\n\n for (const dep of dependencies) {\n dependencyMap.set(dep.topicId, dep.depends || []);\n }\n\n const visited = new Set<string>();\n const visiting = new Set<string>();\n\n const visit = (topicId: string): void => {\n if (visiting.has(topicId)) {\n throw new Error('Circular dependency detected');\n }\n\n if (visited.has(topicId)) return;\n\n visiting.add(topicId);\n\n const deps = dependencyMap.get(topicId) || [];\n for (const dep of deps) {\n visit(dep);\n }\n\n visiting.delete(topicId);\n visited.add(topicId);\n };\n\n for (const dep of dependencies) {\n visit(dep.topicId);\n }\n }\n\n /**\n * Topological sort of dependencies\n */\n private topologicalSort(\n dependencies: ResourceDependency[],\n ): ResourceDependency[] {\n const dependencyMap = new Map<string, ResourceDependency>();\n const dependsMap = new Map<string, string[]>();\n\n for (const dep of dependencies) {\n dependencyMap.set(dep.topicId, dep);\n dependsMap.set(dep.topicId, dep.depends || []);\n }\n\n const sorted: ResourceDependency[] = [];\n const visited = new Set<string>();\n\n const visit = (topicId: string): void => {\n if (visited.has(topicId)) return;\n\n const deps = dependsMap.get(topicId) || [];\n for (const dep of deps) {\n visit(dep);\n }\n\n visited.add(topicId);\n const depObj = dependencyMap.get(topicId);\n if (depObj) {\n sorted.push(depObj);\n }\n };\n\n for (const dep of dependencies) {\n visit(dep.topicId);\n }\n\n return sorted;\n }\n\n /**\n * Get content type for dependency type\n */\n private getContentTypeForType(type: string): string {\n switch (type) {\n case 'css':\n return 'text/css';\n case 'js':\n return 'application/javascript';\n case 'template':\n return 'text/html';\n case 'image':\n return 'image/*';\n default:\n return 'application/octet-stream';\n }\n }\n}\n"],"names":[],"mappings":";;AAqDO,MAAM,gBAAgB;AAAA,EAiC3B,YACE,aACA,QACA,KACA,UAAkC,CAAA,GAClC;AAnCF,SAAQ,4BAAqC,IAAA;AAE7C,SAAQ,mBAA2B;AAEnC,SAAiB,0CAA0B,IAAI;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAED,SAAiB,sBAAsB;AAAA,MACrC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAGF,SAAiB,uBAAuB;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AASA,SAAK,SAAS;AACd,SAAK,MAAM,OAAO,IAAI,IAAA;AACtB,SAAK,UAAU;AAAA,MACb,UAAU,QAAQ,YAAY;AAAA,MAC9B,cAAc,QAAQ,gBAAgB,KAAK,OAAO;AAAA,MAClD,iBAAiB,QAAQ,mBAAmB,IAAI,OAAO;AAAA,IAAA;AAAA,EAE3D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,QAAQ,SAAkC;AAC9C,SAAK,OAAO,MAAM,wBAAwB,EAAE,SAAS;AAErD,QAAI;AACF,YAAM,WAAW,MAAM,KAAK,aAAa,OAAO;AAEhD,UAAI,SAAS,gBAAgB,YAAY;AACvC,cAAM,IAAI,MAAM,8BAA8B,SAAS,WAAW,EAAE;AAAA,MACtE;AAEA,YAAM,UAAU,SAAS;AACzB,YAAM,YAAY,KAAK,YAAY,OAAO;AAE1C,WAAK,OAAO,MAAM,oCAAoC;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AAA;AAEpB,UAAM,QAAQ,CAAC,YAA0B;AACvC,UAAI,QAAQ,IAAI,OAAO,EAAG;AAE1B,YAAM,OAAO,WAAW,IAAI,OAAO,KAAK,CAAA;AACxC,iBAAW,OAAO,MAAM;AACtB,cAAM,GAAG;AAAA,MACX;AAEA,cAAQ,IAAI,OAAO;AACnB,YAAM,SAAS,cAAc,IAAI,OAAO;AACxC,UAAI,QAAQ;AACV,eAAO,KAAK,MAAM;AAAA,MACpB;AAAA,IACF;AAEA,eAAW,OAAO,cAAc;AAC9B,YAAM,IAAI,OAAO;AAAA,IACnB;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKQ,sBAAsB,MAAsB;AAClD,YAAQ,MAAA;AAAA,MACN,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IAAA;AAAA,EAEb;AACF;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es47.js","sources":["../../src/hcs-12/rendering/resource-manager.ts"],"sourcesContent":["/**\n * Resource Manager for HCS-12 HashLinks\n *\n * Manages loading and caching of resources (CSS, JS, images, templates)\n * from HCS-3 storage with integrity verification and security validation.\n */\n\nimport { Logger } from '../../utils/logger';\nimport { NetworkType } from '../../utils/types';\nimport { HCS } from '../../hcs-3/src';\nimport { isSSREnvironment } from '../../utils/crypto-env';\n\nexport interface ResourceData {\n content: string | Uint8Array;\n contentType: string;\n size: number;\n hash?: string;\n}\n\nexport interface VerifiedResource {\n content: string | Uint8Array;\n verified: boolean;\n contentType: string;\n}\n\nexport interface ResourceDependency {\n topicId: string;\n type: 'css' | 'js' | 'template' | 'image';\n depends?: string[];\n}\n\nexport interface LoadedResource {\n topicId: string;\n content: string | Uint8Array;\n contentType: string;\n type: string;\n}\n\nexport interface CacheEntry {\n data: ResourceData;\n timestamp: number;\n size: number;\n}\n\nexport interface ResourceManagerOptions {\n cacheTTL?: number;\n maxCacheSize?: number;\n maxResourceSize?: number;\n}\n\n/**\n * Resource manager for efficient loading and caching of HCS-3 resources\n */\nexport class ResourceManager {\n private logger: Logger;\n private hcs: HCS;\n private cache: Map<string, CacheEntry> = new Map();\n private options: Required<ResourceManagerOptions>;\n private currentCacheSize: number = 0;\n\n private readonly supportedImageTypes = new Set([\n 'image/png',\n 'image/jpeg',\n 'image/jpg',\n 'image/gif',\n 'image/svg+xml',\n 'image/webp',\n ]);\n\n private readonly dangerousJSPatterns = [\n /eval\\s*\\(/g,\n /Function\\s*\\(/g,\n /setTimeout\\s*\\(\\s*[\"'].*[\"']/g,\n /setInterval\\s*\\(\\s*[\"'].*[\"']/g,\n /document\\.write/g,\n /innerHTML\\s*=/g,\n /outerHTML\\s*=/g,\n ];\n\n private readonly dangerousCSSPatterns = [\n /javascript\\s*:/gi,\n /@import.*url\\s*\\(\\s*[\"']?javascript:/gi,\n /expression\\s*\\(/gi,\n /behavior\\s*:/gi,\n ];\n\n constructor(\n networkType: NetworkType,\n logger: Logger,\n hcs?: HCS,\n options: ResourceManagerOptions = {},\n ) {\n this.logger = logger;\n this.hcs = hcs || new HCS();\n this.options = {\n cacheTTL: options.cacheTTL || 300000,\n maxCacheSize: options.maxCacheSize || 50 * 1024 * 1024,\n maxResourceSize: options.maxResourceSize || 5 * 1024 * 1024,\n };\n }\n\n /**\n * Load CSS resource from HCS-3\n */\n async loadCSS(topicId: string): Promise<string> {\n this.logger.debug('Loading CSS resource', { topicId });\n\n try {\n const resource = await this.loadResource(topicId);\n\n if (resource.contentType !== 'text/css') {\n throw new Error(`Expected CSS resource, got ${resource.contentType}`);\n }\n\n const content = resource.content as string;\n const sanitized = this.sanitizeCSS(content);\n\n this.logger.debug('CSS resource loaded successfully', {\n topicId,\n size: content.length,\n sanitized: sanitized.length !== content.length,\n });\n\n return sanitized;\n } catch (error) {\n this.logger.error('Failed to load CSS resource', { topicId, error });\n throw new Error(\n `Failed to load CSS resource: ${error instanceof Error ? error.message : 'Unknown error'}`,\n );\n }\n }\n\n /**\n * Load JavaScript resource from HCS-3\n */\n async loadJS(topicId: string): Promise<string> {\n this.logger.debug('Loading JavaScript resource', { topicId });\n\n try {\n const resource = await this.loadResource(topicId);\n\n if (\n !resource.contentType.includes('javascript') &&\n !resource.contentType.includes('ecmascript')\n ) {\n throw new Error(\n `Expected JavaScript resource, got ${resource.contentType}`,\n );\n }\n\n const content = resource.content as string;\n\n if (content.length > this.options.maxResourceSize) {\n throw new Error('JavaScript resource too large');\n }\n\n const sanitized = this.sanitizeJavaScript(content);\n\n this.logger.debug('JavaScript resource loaded successfully', {\n topicId,\n size: content.length,\n sanitized: sanitized.length !== content.length,\n });\n\n return sanitized;\n } catch (error) {\n this.logger.error('Failed to load JavaScript resource', {\n topicId,\n error,\n });\n throw new Error(\n `Failed to load JavaScript resource: ${error instanceof Error ? error.message : 'Unknown error'}`,\n );\n }\n }\n\n /**\n * Load image resource from HCS-3 as Blob\n */\n async loadImage(topicId: string): Promise<Blob> {\n this.logger.debug('Loading image resource', { topicId });\n\n try {\n const resource = await this.loadResource(topicId);\n\n if (!this.supportedImageTypes.has(resource.contentType)) {\n throw new Error(`Unsupported image format: ${resource.contentType}`);\n }\n\n const content = resource.content as Uint8Array;\n const view = new Uint8Array(content); // ensures ArrayBuffer, not SharedArrayBuffer\n const blob = new Blob([view.buffer], { type: resource.contentType });\n\n this.logger.debug('Image resource loaded successfully', {\n topicId,\n size: content.length,\n type: resource.contentType,\n });\n\n return blob;\n } catch (error) {\n this.logger.error('Failed to load image resource', { topicId, error });\n throw new Error(\n `Failed to load image resource: ${error instanceof Error ? error.message : 'Unknown error'}`,\n );\n }\n }\n\n /**\n * Load template resource from HCS-3\n */\n async loadTemplate(topicId: string): Promise<string> {\n this.logger.debug('Loading template resource', { topicId });\n\n try {\n const resource = await this.loadResource(topicId);\n\n const content = resource.content as string;\n\n this.validateTemplateSyntax(content);\n\n const sanitized = this.sanitizeTemplate(content);\n\n this.logger.debug('Template resource loaded successfully', {\n topicId,\n size: content.length,\n });\n\n return sanitized;\n } catch (error) {\n this.logger.error('Failed to load template resource', { topicId, error });\n throw new Error(\n `Failed to load template resource: ${error instanceof Error ? error.message : 'Unknown error'}`,\n );\n }\n }\n\n /**\n * Load resource with integrity verification\n */\n async loadWithIntegrityCheck(\n topicId: string,\n expectedHash: string,\n ): Promise<VerifiedResource> {\n this.logger.debug('Loading resource with integrity check', {\n topicId,\n expectedHash,\n });\n\n try {\n const resource = await this.loadResource(topicId);\n\n const verified = await this.verifyIntegrity(\n resource.content,\n expectedHash,\n );\n\n if (!verified) {\n throw new Error('Resource integrity verification failed');\n }\n\n this.logger.debug('Resource integrity verified', { topicId });\n\n return {\n content: resource.content,\n verified,\n contentType: resource.contentType,\n };\n } catch (error) {\n this.logger.error('Resource integrity check failed', { topicId, error });\n throw error;\n }\n }\n\n /**\n * Verify content integrity using SHA-256 hash\n */\n private async verifyIntegrity(\n content: string | Uint8Array,\n expectedHash: string,\n ): Promise<boolean> {\n try {\n if (isSSREnvironment()) {\n this.logger.warn('Integrity verification skipped in SSR environment');\n return true;\n }\n\n const webCrypto = globalThis.crypto;\n if (typeof webCrypto === 'undefined' || !webCrypto.subtle) {\n this.logger.warn(\n 'WebCrypto not available, skipping integrity verification',\n );\n return true;\n }\n\n const buffer =\n typeof content === 'string'\n ? new TextEncoder().encode(content)\n : content;\n\n const bytes =\n buffer instanceof Uint8Array\n ? buffer\n : new Uint8Array(buffer as ArrayBufferLike);\n const copy = new Uint8Array(bytes);\n const hashBuffer = await webCrypto.subtle.digest('SHA-256', copy.buffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const actualHash = hashArray\n .map(b => b.toString(16).padStart(2, '0'))\n .join('');\n\n return actualHash === expectedHash.toLowerCase();\n } catch (error) {\n this.logger.error('Error verifying integrity', { error });\n return false;\n }\n }\n\n /**\n * Load multiple dependencies in correct order\n */\n async loadDependencies(\n dependencies: ResourceDependency[],\n ): Promise<LoadedResource[]> {\n this.logger.debug('Loading dependencies', { count: dependencies.length });\n\n try {\n this.detectCircularDependencies(dependencies);\n\n const sorted = this.topologicalSort(dependencies);\n\n const results: LoadedResource[] = [];\n\n for (const dep of sorted) {\n let content: string | Uint8Array;\n\n switch (dep.type) {\n case 'css':\n content = await this.loadCSS(dep.topicId);\n break;\n case 'js':\n content = await this.loadJS(dep.topicId);\n break;\n case 'template':\n content = await this.loadTemplate(dep.topicId);\n break;\n case 'image':\n const blob = await this.loadImage(dep.topicId);\n content = new Uint8Array(await blob.arrayBuffer());\n break;\n default:\n throw new Error(`Unsupported dependency type: ${dep.type}`);\n }\n\n results.push({\n topicId: dep.topicId,\n content,\n contentType: this.getContentTypeForType(dep.type),\n type: dep.type,\n });\n }\n\n this.logger.debug('Dependencies loaded successfully', {\n count: results.length,\n });\n return results;\n } catch (error) {\n this.logger.error('Failed to load dependencies', { error });\n throw error;\n }\n }\n\n /**\n * Clear resource cache\n */\n clearCache(): void {\n this.cache.clear();\n this.currentCacheSize = 0;\n this.logger.debug('Resource cache cleared');\n }\n\n /**\n * Get current cache size for testing\n */\n getCacheSize(): number {\n return this.currentCacheSize;\n }\n\n /**\n * Load resource with caching\n */\n private async loadResource(topicId: string): Promise<ResourceData> {\n const cached = this.getFromCache(topicId);\n if (cached) {\n this.logger.debug('Resource loaded from cache', { topicId });\n return cached;\n }\n\n const blob = await this.hcs.retrieveHCS1Data(topicId);\n\n const contentType = blob.type || 'application/octet-stream';\n\n let content: string | Uint8Array;\n if (\n contentType.startsWith('text/') ||\n contentType.includes('javascript') ||\n contentType.includes('json')\n ) {\n content = await blob.text();\n } else {\n content = new Uint8Array(await blob.arrayBuffer());\n }\n\n const resource: ResourceData = {\n content,\n contentType,\n size: blob.size,\n };\n\n this.addToCache(topicId, resource);\n\n return resource;\n }\n\n /**\n * Get resource from cache if valid\n */\n private getFromCache(topicId: string): ResourceData | null {\n const entry = this.cache.get(topicId);\n if (!entry) return null;\n\n if (Date.now() - entry.timestamp > this.options.cacheTTL) {\n this.removeFromCache(topicId);\n return null;\n }\n\n return entry.data;\n }\n\n /**\n * Add resource to cache with size management\n */\n private addToCache(topicId: string, resource: ResourceData): void {\n const size =\n typeof resource.content === 'string'\n ? resource.content.length\n : resource.content.byteLength;\n\n if (size > this.options.maxCacheSize / 2) {\n this.logger.warn('Resource too large for cache', { topicId, size });\n return;\n }\n\n while (\n this.currentCacheSize + size > this.options.maxCacheSize &&\n this.cache.size > 0\n ) {\n this.evictOldestEntry();\n }\n\n const entry: CacheEntry = {\n data: resource,\n timestamp: Date.now(),\n size,\n };\n\n this.cache.set(topicId, entry);\n this.currentCacheSize += size;\n\n this.logger.debug('Resource added to cache', {\n topicId,\n size,\n totalCacheSize: this.currentCacheSize,\n });\n }\n\n /**\n * Remove resource from cache\n */\n private removeFromCache(topicId: string): void {\n const entry = this.cache.get(topicId);\n if (entry) {\n this.cache.delete(topicId);\n this.currentCacheSize -= entry.size;\n }\n }\n\n /**\n * Evict oldest cache entry\n */\n private evictOldestEntry(): void {\n let oldest: string | null = null;\n let oldestTime = Date.now();\n\n for (const [topicId, entry] of this.cache) {\n if (entry.timestamp < oldestTime) {\n oldestTime = entry.timestamp;\n oldest = topicId;\n }\n }\n\n if (oldest) {\n this.removeFromCache(oldest);\n this.logger.debug('Evicted oldest cache entry', { topicId: oldest });\n }\n }\n\n /**\n * Sanitize CSS content\n */\n private sanitizeCSS(css: string): string {\n let sanitized = css;\n\n for (const pattern of this.dangerousCSSPatterns) {\n sanitized = sanitized.replace(pattern, '');\n }\n\n return sanitized;\n }\n\n /**\n * Sanitize JavaScript content\n */\n private sanitizeJavaScript(js: string): string {\n let sanitized = js;\n\n for (const pattern of this.dangerousJSPatterns) {\n sanitized = sanitized.replace(pattern, '');\n }\n\n return sanitized;\n }\n\n /**\n * Sanitize template content\n */\n private sanitizeTemplate(template: string): string {\n return template\n .replace(/<script\\b[^<]*(?:(?!<\\/script>)<[^<]*)*<\\/script>/gi, '')\n .replace(/on\\w+\\s*=\\s*[\"'][^\"']*[\"']/gi, '')\n .replace(/javascript\\s*:/gi, '');\n }\n\n /**\n * Validate template syntax\n */\n private validateTemplateSyntax(template: string): void {\n const openBraces = (template.match(/\\{\\{/g) || []).length;\n const closeBraces = (template.match(/\\}\\}/g) || []).length;\n\n if (openBraces !== closeBraces) {\n throw new Error('Invalid template syntax: unmatched braces');\n }\n\n const openBlocks = (template.match(/\\{\\{#\\w+/g) || []).length;\n const closeBlocks = (template.match(/\\{\\{\\/\\w+/g) || []).length;\n\n if (openBlocks !== closeBlocks) {\n throw new Error('Invalid template syntax: unclosed block helpers');\n }\n }\n\n /**\n * Detect circular dependencies\n */\n private detectCircularDependencies(dependencies: ResourceDependency[]): void {\n const dependencyMap = new Map<string, string[]>();\n\n for (const dep of dependencies) {\n dependencyMap.set(dep.topicId, dep.depends || []);\n }\n\n const visited = new Set<string>();\n const visiting = new Set<string>();\n\n const visit = (topicId: string): void => {\n if (visiting.has(topicId)) {\n throw new Error('Circular dependency detected');\n }\n\n if (visited.has(topicId)) return;\n\n visiting.add(topicId);\n\n const deps = dependencyMap.get(topicId) || [];\n for (const dep of deps) {\n visit(dep);\n }\n\n visiting.delete(topicId);\n visited.add(topicId);\n };\n\n for (const dep of dependencies) {\n visit(dep.topicId);\n }\n }\n\n /**\n * Topological sort of dependencies\n */\n private topologicalSort(\n dependencies: ResourceDependency[],\n ): ResourceDependency[] {\n const dependencyMap = new Map<string, ResourceDependency>();\n const dependsMap = new Map<string, string[]>();\n\n for (const dep of dependencies) {\n dependencyMap.set(dep.topicId, dep);\n dependsMap.set(dep.topicId, dep.depends || []);\n }\n\n const sorted: ResourceDependency[] = [];\n const visited = new Set<string>();\n\n const visit = (topicId: string): void => {\n if (visited.has(topicId)) return;\n\n const deps = dependsMap.get(topicId) || [];\n for (const dep of deps) {\n visit(dep);\n }\n\n visited.add(topicId);\n const depObj = dependencyMap.get(topicId);\n if (depObj) {\n sorted.push(depObj);\n }\n };\n\n for (const dep of dependencies) {\n visit(dep.topicId);\n }\n\n return sorted;\n }\n\n /**\n * Get content type for dependency type\n */\n private getContentTypeForType(type: string): string {\n switch (type) {\n case 'css':\n return 'text/css';\n case 'js':\n return 'application/javascript';\n case 'template':\n return 'text/html';\n case 'image':\n return 'image/*';\n default:\n return 'application/octet-stream';\n }\n }\n}\n"],"names":[],"mappings":";;AAqDO,MAAM,gBAAgB;AAAA,EAiC3B,YACE,aACA,QACA,KACA,UAAkC,CAAA,GAClC;AAnCF,SAAQ,4BAAqC,IAAA;AAE7C,SAAQ,mBAA2B;AAEnC,SAAiB,0CAA0B,IAAI;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAED,SAAiB,sBAAsB;AAAA,MACrC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAGF,SAAiB,uBAAuB;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AASA,SAAK,SAAS;AACd,SAAK,MAAM,OAAO,IAAI,IAAA;AACtB,SAAK,UAAU;AAAA,MACb,UAAU,QAAQ,YAAY;AAAA,MAC9B,cAAc,QAAQ,gBAAgB,KAAK,OAAO;AAAA,MAClD,iBAAiB,QAAQ,mBAAmB,IAAI,OAAO;AAAA,IAAA;AAAA,EAE3D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,QAAQ,SAAkC;AAC9C,SAAK,OAAO,MAAM,wBAAwB,EAAE,SAAS;AAErD,QAAI;AACF,YAAM,WAAW,MAAM,KAAK,aAAa,OAAO;AAEhD,UAAI,SAAS,gBAAgB,YAAY;AACvC,cAAM,IAAI,MAAM,8BAA8B,SAAS,WAAW,EAAE;AAAA,MACtE;AAEA,YAAM,UAAU,SAAS;AACzB,YAAM,YAAY,KAAK,YAAY,OAAO;AAE1C,WAAK,OAAO,MAAM,oCAAoC;AAAA,QACpD;AAAA,QACA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c,IAAA;AAEpB,UAAM,QAAQ,CAAC,YAA0B;AACvC,UAAI,QAAQ,IAAI,OAAO,EAAG;AAE1B,YAAM,OAAO,WAAW,IAAI,OAAO,KAAK,CAAA;AACxC,iBAAW,OAAO,MAAM;AACtB,cAAM,GAAG;AAAA,MACX;AAEA,cAAQ,IAAI,OAAO;AACnB,YAAM,SAAS,cAAc,IAAI,OAAO;AACxC,UAAI,QAAQ;AACV,eAAO,KAAK,MAAM;AAAA,MACpB;AAAA,IACF;AAEA,eAAW,OAAO,cAAc;AAC9B,YAAM,IAAI,OAAO;AAAA,IACnB;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKQ,sBAAsB,MAAsB;AAClD,YAAQ,MAAA;AAAA,MACN,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IAAA;AAAA,EAEb;AACF;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getCryptoAdapter } from "./standards-sdk.es120.js";
|
|
2
|
-
import { base58Encode } from "./standards-sdk.
|
|
2
|
+
import { base58Encode } from "./standards-sdk.es152.js";
|
|
3
3
|
import { canonicalizeAgentData } from "./standards-sdk.es56.js";
|
|
4
4
|
function encodeMultibaseB58btc(input) {
|
|
5
5
|
const bytes = Buffer.from(input, "utf8");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HieroDidResolver } from "./standards-sdk.es60.js";
|
|
2
2
|
import { parseHcs14Did } from "./standards-sdk.es57.js";
|
|
3
|
-
import { multibaseB58btcDecode } from "./standards-sdk.
|
|
3
|
+
import { multibaseB58btcDecode } from "./standards-sdk.es152.js";
|
|
4
4
|
class ResolverRegistry {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.resolvers = [];
|
|
@@ -18,12 +18,11 @@ import "./standards-sdk.es132.js";
|
|
|
18
18
|
import "./standards-sdk.es133.js";
|
|
19
19
|
import "./standards-sdk.es134.js";
|
|
20
20
|
import "./standards-sdk.es135.js";
|
|
21
|
-
import "./standards-sdk.es136.js";
|
|
22
21
|
import "buffer";
|
|
23
22
|
import "crypto";
|
|
24
23
|
import "@noble/curves/secp256k1.js";
|
|
25
24
|
import "zod";
|
|
26
|
-
import "./standards-sdk.
|
|
25
|
+
import "./standards-sdk.es150.js";
|
|
27
26
|
import "./standards-sdk.es140.js";
|
|
28
27
|
import "@hashgraph/proto";
|
|
29
28
|
import "ethers";
|