@ledgerhq/context-module 1.14.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/DefaultContextModule.js +1 -1
- package/lib/cjs/src/DefaultContextModule.js.map +3 -3
- package/lib/cjs/src/di.js +1 -1
- package/lib/cjs/src/di.js.map +3 -3
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
- package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
- package/lib/cjs/src/gated-signing/data/GatedDescriptorDataSource.js +2 -0
- package/lib/cjs/src/gated-signing/data/GatedDescriptorDataSource.js.map +7 -0
- package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.js +2 -0
- package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.js.map +7 -0
- package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js +2 -0
- package/lib/cjs/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js.map +7 -0
- package/lib/cjs/src/gated-signing/data/dto/GatedDappsDto.js +2 -0
- package/lib/cjs/src/gated-signing/data/dto/GatedDappsDto.js.map +7 -0
- package/lib/cjs/src/gated-signing/di/gatedSigningModuleFactory.js +2 -0
- package/lib/cjs/src/gated-signing/di/gatedSigningModuleFactory.js.map +7 -0
- package/lib/cjs/src/gated-signing/di/gatedSigningTypes.js +2 -0
- package/lib/cjs/src/gated-signing/di/gatedSigningTypes.js.map +7 -0
- package/lib/cjs/src/gated-signing/domain/GatedSigningContextLoader.js +2 -0
- package/lib/cjs/src/gated-signing/domain/GatedSigningContextLoader.js.map +7 -0
- package/lib/cjs/src/gated-signing/domain/GatedSigningContextLoader.test.js +2 -0
- package/lib/cjs/src/gated-signing/domain/GatedSigningContextLoader.test.js.map +7 -0
- package/lib/cjs/src/gated-signing/domain/GatedSigningTypedDataContextLoader.js +2 -0
- package/lib/cjs/src/gated-signing/domain/GatedSigningTypedDataContextLoader.js.map +7 -0
- package/lib/cjs/src/gated-signing/domain/GatedSigningTypedDataContextLoader.test.js +2 -0
- package/lib/cjs/src/gated-signing/domain/GatedSigningTypedDataContextLoader.test.js.map +7 -0
- package/lib/cjs/src/index.js +1 -1
- package/lib/cjs/src/index.js.map +2 -2
- package/lib/cjs/src/pki/model/KeyId.js +1 -1
- package/lib/cjs/src/pki/model/KeyId.js.map +2 -2
- package/lib/cjs/src/pki/model/KeyUsage.js +1 -1
- package/lib/cjs/src/pki/model/KeyUsage.js.map +2 -2
- package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
- package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
- package/lib/cjs/src/shared/model/SolanaContextTypes.js +1 -1
- package/lib/cjs/src/shared/model/SolanaContextTypes.js.map +1 -1
- package/lib/cjs/src/shared/utils/KeyUsageMapper.js +1 -1
- package/lib/cjs/src/shared/utils/KeyUsageMapper.js.map +2 -2
- package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js +1 -1
- package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js.map +2 -2
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js +1 -1
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js.map +3 -3
- package/lib/cjs/src/solana/domain/solanaContextTypes.js.map +1 -1
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.js +1 -1
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.js.map +3 -3
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js +1 -1
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js.map +3 -3
- package/lib/cjs/src/solanaLifi/data/SolanaLifiDataSource.js +1 -1
- package/lib/cjs/src/solanaLifi/data/SolanaLifiDataSource.js.map +1 -1
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.js +1 -1
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.js.map +3 -3
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.test.js +1 -1
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.test.js.map +3 -3
- package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.js +1 -1
- package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.js.map +2 -2
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
- package/lib/cjs/src/typed-data/utils/getSchemaHash.js +2 -0
- package/lib/cjs/src/typed-data/utils/getSchemaHash.js.map +7 -0
- package/lib/cjs/src/typed-data/utils/getSchemaHash.test.js +2 -0
- package/lib/cjs/src/typed-data/utils/getSchemaHash.test.js.map +7 -0
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/DefaultContextModule.js +1 -1
- package/lib/esm/src/DefaultContextModule.js.map +3 -3
- package/lib/esm/src/di.js +1 -1
- package/lib/esm/src/di.js.map +3 -3
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
- package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
- package/lib/esm/src/gated-signing/data/GatedDescriptorDataSource.js +1 -0
- package/lib/esm/src/gated-signing/data/GatedDescriptorDataSource.js.map +7 -0
- package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.js +2 -0
- package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.js.map +7 -0
- package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js +2 -0
- package/lib/esm/src/gated-signing/data/HttpGatedDescriptorDataSource.test.js.map +7 -0
- package/lib/esm/src/gated-signing/data/dto/GatedDappsDto.js +1 -0
- package/lib/esm/src/gated-signing/data/dto/GatedDappsDto.js.map +7 -0
- package/lib/esm/src/gated-signing/di/gatedSigningModuleFactory.js +2 -0
- package/lib/esm/src/gated-signing/di/gatedSigningModuleFactory.js.map +7 -0
- package/lib/esm/src/gated-signing/di/gatedSigningTypes.js +2 -0
- package/lib/esm/src/gated-signing/di/gatedSigningTypes.js.map +7 -0
- package/lib/esm/src/gated-signing/domain/GatedSigningContextLoader.js +2 -0
- package/lib/esm/src/gated-signing/domain/GatedSigningContextLoader.js.map +7 -0
- package/lib/esm/src/gated-signing/domain/GatedSigningContextLoader.test.js +2 -0
- package/lib/esm/src/gated-signing/domain/GatedSigningContextLoader.test.js.map +7 -0
- package/lib/esm/src/gated-signing/domain/GatedSigningTypedDataContextLoader.js +2 -0
- package/lib/esm/src/gated-signing/domain/GatedSigningTypedDataContextLoader.js.map +7 -0
- package/lib/esm/src/gated-signing/domain/GatedSigningTypedDataContextLoader.test.js +2 -0
- package/lib/esm/src/gated-signing/domain/GatedSigningTypedDataContextLoader.test.js.map +7 -0
- package/lib/esm/src/index.js +1 -1
- package/lib/esm/src/index.js.map +2 -2
- package/lib/esm/src/pki/model/KeyId.js +1 -1
- package/lib/esm/src/pki/model/KeyId.js.map +2 -2
- package/lib/esm/src/pki/model/KeyUsage.js +1 -1
- package/lib/esm/src/pki/model/KeyUsage.js.map +2 -2
- package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
- package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
- package/lib/esm/src/shared/model/SolanaContextTypes.js.map +1 -1
- package/lib/esm/src/shared/utils/KeyUsageMapper.js +1 -1
- package/lib/esm/src/shared/utils/KeyUsageMapper.js.map +2 -2
- package/lib/esm/src/shared/utils/KeyUsageMapper.test.js +1 -1
- package/lib/esm/src/shared/utils/KeyUsageMapper.test.js.map +2 -2
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js +1 -1
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js.map +3 -3
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.js +1 -1
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.js.map +3 -3
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js +1 -1
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js.map +3 -3
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.js +1 -1
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.js.map +3 -3
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.test.js +1 -1
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.test.js.map +3 -3
- package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.js +1 -1
- package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.js.map +2 -2
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
- package/lib/esm/src/typed-data/utils/getSchemaHash.js +2 -0
- package/lib/esm/src/typed-data/utils/getSchemaHash.js.map +7 -0
- package/lib/esm/src/typed-data/utils/getSchemaHash.test.js +2 -0
- package/lib/esm/src/typed-data/utils/getSchemaHash.test.js.map +7 -0
- package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +2 -0
- package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -1
- package/lib/types/src/gated-signing/data/GatedDescriptorDataSource.d.ts +20 -0
- package/lib/types/src/gated-signing/data/GatedDescriptorDataSource.d.ts.map +1 -0
- package/lib/types/src/gated-signing/data/HttpGatedDescriptorDataSource.d.ts +13 -0
- package/lib/types/src/gated-signing/data/HttpGatedDescriptorDataSource.d.ts.map +1 -0
- package/lib/types/src/gated-signing/data/HttpGatedDescriptorDataSource.test.d.ts +2 -0
- package/lib/types/src/gated-signing/data/HttpGatedDescriptorDataSource.test.d.ts.map +1 -0
- package/lib/types/src/gated-signing/data/dto/GatedDappsDto.d.ts +15 -0
- package/lib/types/src/gated-signing/data/dto/GatedDappsDto.d.ts.map +1 -0
- package/lib/types/src/gated-signing/di/gatedSigningModuleFactory.d.ts +3 -0
- package/lib/types/src/gated-signing/di/gatedSigningModuleFactory.d.ts.map +1 -0
- package/lib/types/src/gated-signing/di/gatedSigningTypes.d.ts +6 -0
- package/lib/types/src/gated-signing/di/gatedSigningTypes.d.ts.map +1 -0
- package/lib/types/src/gated-signing/domain/GatedSigningContextLoader.d.ts +22 -0
- package/lib/types/src/gated-signing/domain/GatedSigningContextLoader.d.ts.map +1 -0
- package/lib/types/src/gated-signing/domain/GatedSigningContextLoader.test.d.ts +2 -0
- package/lib/types/src/gated-signing/domain/GatedSigningContextLoader.test.d.ts.map +1 -0
- package/lib/types/src/gated-signing/domain/GatedSigningTypedDataContextLoader.d.ts +27 -0
- package/lib/types/src/gated-signing/domain/GatedSigningTypedDataContextLoader.d.ts.map +1 -0
- package/lib/types/src/gated-signing/domain/GatedSigningTypedDataContextLoader.test.d.ts +2 -0
- package/lib/types/src/gated-signing/domain/GatedSigningTypedDataContextLoader.test.d.ts.map +1 -0
- package/lib/types/src/index.d.ts +5 -0
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/pki/model/KeyId.d.ts +3 -1
- package/lib/types/src/pki/model/KeyId.d.ts.map +1 -1
- package/lib/types/src/pki/model/KeyUsage.d.ts +3 -1
- package/lib/types/src/pki/model/KeyUsage.d.ts.map +1 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts +2 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
- package/lib/types/src/shared/model/SolanaContextTypes.d.ts +33 -3
- package/lib/types/src/shared/model/SolanaContextTypes.d.ts.map +1 -1
- package/lib/types/src/shared/utils/KeyUsageMapper.d.ts.map +1 -1
- package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts +4 -1
- package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts.map +1 -1
- package/lib/types/src/solana/domain/solanaContextTypes.d.ts +2 -2
- package/lib/types/src/solana/domain/solanaContextTypes.d.ts.map +1 -1
- package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.d.ts +3 -1
- package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.d.ts.map +1 -1
- package/lib/types/src/solanaLifi/data/SolanaLifiDataSource.d.ts +2 -5
- package/lib/types/src/solanaLifi/data/SolanaLifiDataSource.d.ts.map +1 -1
- package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.d.ts +10 -8
- package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.d.ts.map +1 -1
- package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.d.ts +4 -9
- package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +0 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
- package/lib/types/src/typed-data/utils/getSchemaHash.d.ts +12 -0
- package/lib/types/src/typed-data/utils/getSchemaHash.d.ts.map +1 -0
- package/lib/types/src/typed-data/utils/getSchemaHash.test.d.ts +2 -0
- package/lib/types/src/typed-data/utils/getSchemaHash.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/gated-signing/data/HttpGatedDescriptorDataSource.test.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { HttpGatedDescriptorDataSource } from \"@/gated-signing/data/HttpGatedDescriptorDataSource\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpGatedDescriptorDataSource\", () => {\n const config: ContextModuleConfig = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n branch: \"next\",\n mode: \"prod\",\n },\n originToken: \"test-origin-token\",\n } as ContextModuleConfig;\n\n const contractAddress = \"0x1111111254fb6c44bac0bed2854e76f90643097d\";\n const selector = \"0xa1251d75\";\n const chainId = 1;\n\n const descriptorPayload =\n \"010122020101222a30783131313131313235346662366334346261633062656432383534653736663930363433303937642308000000000000000140086131323531643735\";\n const validGatedDappsResponse = [\n {\n gated_descriptors: {\n \"0x1111111254fb6c44bac0bed2854e76f90643097d\": {\n a1251d75: {\n network: \"ethereum\",\n chain_id: 1,\n address: \"0x1111111254fb6c44bac0bed2854e76f90643097d\",\n selector: \"a1251d75\",\n version: \"v1\",\n descriptor: descriptorPayload,\n signatures: { prod: \"00\", test: \"00\" },\n },\n },\n },\n },\n ];\n // signedDescriptor = payload + SIGNATURE_TAG(\"15\") + length(01) + signature(\"00\")\n const expectedSignedDescriptor = `${descriptorPayload}150100`;\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"getGatedDescriptor\", () => {\n it(\"should return descriptor on successful request with correct URL and params\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: validGatedDappsResponse,\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(axios.request).toHaveBeenCalledWith({\n method: \"GET\",\n url: \"https://crypto-assets-service.api.ledger.com/v1/gated_dapps\",\n params: {\n ref: \"branch:next\",\n output: \"gated_descriptors,app,category\",\n contracts: contractAddress,\n chain_id: chainId,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: \"test-origin-token\",\n },\n });\n expect(result).toEqual(\n Right({\n signedDescriptor: expectedSignedDescriptor,\n }),\n );\n });\n\n it(\"should find descriptor when API response has selector key without 0x prefix\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: validGatedDappsResponse,\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector: \"0xa1251d75\",\n chainId,\n });\n\n expect(result).toEqual(\n Right({\n signedDescriptor: expectedSignedDescriptor,\n }),\n );\n });\n\n it(\"should return Left when response is not an array\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: { gated_descriptors: {} },\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpGatedDescriptorDataSource: Invalid gated descriptors response\",\n ),\n ),\n );\n });\n\n it(\"should return Left when response is empty array\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [],\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpGatedDescriptorDataSource: Invalid gated descriptors response\",\n ),\n ),\n );\n });\n\n it(\"should return Left when no descriptor matches contract and selector\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [\n {\n gated_descriptors: {\n \"0xothercontract\": {\n a1251d75: {\n descriptor: \"some-descriptor\",\n network: \"ethereum\",\n chain_id: 1,\n address: \"0xother\",\n selector: \"a1251d75\",\n version: \"v1\",\n },\n },\n },\n },\n ],\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpGatedDescriptorDataSource: No gated descriptor for contract 0x1111111254fb6c44bac0bed2854e76f90643097d and selector 0xa1251d75\",\n ),\n ),\n );\n });\n\n it(\"should return Left when axios request fails\", async () => {\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"Network error\"));\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpGatedDescriptorDataSource: Failed to fetch gated descriptors: Error: Network error\",\n ),\n ),\n );\n });\n\n it(\"should use config.cal.branch in ref param\", async () => {\n const configMain: ContextModuleConfig = {\n ...config,\n cal: { ...config.cal!, branch: \"main\" },\n } as ContextModuleConfig;\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: validGatedDappsResponse,\n });\n\n await new HttpGatedDescriptorDataSource(configMain).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n params: expect.objectContaining({\n ref: \"branch:main\",\n }),\n }),\n );\n });\n\n describe(\"when response fails DTO validation\", () => {\n const invalidResponseError = new Error(\n \"[ContextModule] HttpGatedDescriptorDataSource: Invalid gated descriptors response\",\n );\n\n it(\"should return Left when array item has no gated_descriptors\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [{}],\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(result).toEqual(Left(invalidResponseError));\n });\n\n it(\"should return Left when gated_descriptors is not an object\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [{ gated_descriptors: \"not-an-object\" }],\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(result).toEqual(Left(invalidResponseError));\n });\n\n it(\"should return Left when entry is missing required field (descriptor)\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [\n {\n gated_descriptors: {\n [contractAddress]: {\n a1251d75: {\n network: \"ethereum\",\n chain_id: 1,\n address: contractAddress,\n selector: \"a1251d75\",\n version: \"v1\",\n // descriptor missing\n },\n },\n },\n },\n ],\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(result).toEqual(Left(invalidResponseError));\n });\n\n it(\"should return Left when entry has wrong type for chain_id\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [\n {\n gated_descriptors: {\n [contractAddress]: {\n a1251d75: {\n network: \"ethereum\",\n chain_id: \"1\", // string instead of number\n address: contractAddress,\n selector: \"a1251d75\",\n version: \"v1\",\n descriptor: descriptorPayload,\n signatures: { prod: \"00\", test: \"00\" },\n },\n },\n },\n },\n ],\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(result).toEqual(Left(invalidResponseError));\n });\n\n it(\"should return Left when entry signatures contains non-string value\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [\n {\n gated_descriptors: {\n [contractAddress]: {\n a1251d75: {\n network: \"ethereum\",\n chain_id: 1,\n address: contractAddress,\n selector: \"a1251d75\",\n version: \"v1\",\n descriptor: descriptorPayload,\n signatures: { prod: 123 }, // number instead of string\n },\n },\n },\n },\n ],\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(result).toEqual(Left(invalidResponseError));\n });\n\n it(\"should return Left when array item is null\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [null],\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(result).toEqual(Left(invalidResponseError));\n });\n\n it(\"should return Left when selectors map value is not an object\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [\n {\n gated_descriptors: {\n [contractAddress]: \"not-a-selectors-map\",\n },\n },\n ],\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptor({\n contractAddress,\n selector,\n chainId,\n });\n\n expect(result).toEqual(Left(invalidResponseError));\n });\n });\n });\n\n describe(\"getGatedDescriptorForTypedData\", () => {\n const schemaHash =\n \"4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3\";\n const descriptorPayloadTypedData =\n \"010122020101222a30783131313131313235346662366334346261633062656432383534653736663930363433303937642308000000000000000140086131323531643735\";\n const validTypedDataResponse = [\n {\n gated_descriptors: {\n [contractAddress]: {\n [schemaHash]: {\n network: \"ethereum\",\n chain_id: 1,\n address: contractAddress,\n selector: \"eip712\",\n version: \"v1\",\n descriptor: descriptorPayloadTypedData,\n signatures: { prod: \"00\", test: \"00\" },\n },\n },\n },\n },\n ];\n const expectedSignedDescriptorTypedData = `${descriptorPayloadTypedData}150100`;\n\n it(\"should return descriptor on successful request when keyed by schema hash\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: validTypedDataResponse,\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptorForTypedData({\n contractAddress,\n schemaHash,\n chainId,\n });\n\n expect(axios.request).toHaveBeenCalledWith({\n method: \"GET\",\n url: \"https://crypto-assets-service.api.ledger.com/v1/gated_dapps\",\n params: {\n ref: \"branch:next\",\n output: \"gated_descriptors\",\n contracts: contractAddress,\n chain_id: chainId,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: \"test-origin-token\",\n },\n });\n expect(result).toEqual(\n Right({\n signedDescriptor: expectedSignedDescriptorTypedData,\n }),\n );\n });\n\n it(\"should return Left when no descriptor matches contract and schema hash\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValue({\n status: 200,\n data: [\n {\n gated_descriptors: {\n [contractAddress]: {\n other_schema_hash: {\n descriptor: \"some-descriptor\",\n network: \"ethereum\",\n chain_id: 1,\n address: contractAddress,\n selector: \"eip712\",\n version: \"v1\",\n },\n },\n },\n },\n ],\n });\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptorForTypedData({\n contractAddress,\n schemaHash,\n chainId,\n });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpGatedDescriptorDataSource: No gated descriptor for contract ${contractAddress} and schema hash ${schemaHash}`,\n ),\n ),\n );\n });\n\n it(\"should return Left when axios request fails\", async () => {\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"Network error\"));\n\n const result = await new HttpGatedDescriptorDataSource(\n config,\n ).getGatedDescriptorForTypedData({\n contractAddress,\n schemaHash,\n chainId,\n });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpGatedDescriptorDataSource: Failed to fetch gated descriptors: Error: Network error\",\n ),\n ),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OAAS,iCAAAC,MAAqC,qDAC9C,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAOC,MAAa,qBAEpB,GAAG,KAAK,OAAO,EAEf,SAAS,gCAAiC,IAAM,CAC9C,MAAMC,EAA8B,CAClC,IAAK,CACH,IAAK,kDACL,OAAQ,OACR,KAAM,MACR,EACA,YAAa,mBACf,EAEMC,EAAkB,6CAClBC,EAAW,aACXC,EAAU,EAEVC,EACJ,6IACIC,EAA0B,CAC9B,CACE,kBAAmB,CACjB,6CAA8C,CAC5C,S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EAAG,kBAAkBE,EAAQ,OAAO,GACjE,CAACD,CAA0B,EAAG,mBAChC,CACF,CAAC,EACD,OAAOS,CAAM,EAAE,QACbZ,EAAM,CACJ,iBAAkBkB,CACpB,CAAC,CACH,CACF,CAAC,EAED,GAAG,yEAA0E,SAAY,CACvF,GAAG,MAAMpB,EAAO,SAAS,EAAE,kBAAkB,CAC3C,OAAQ,IACR,KAAM,CACJ,CACE,kBAAmB,CACjB,CAACQ,CAAe,EAAG,CACjB,kBAAmB,CACjB,WAAY,kBACZ,QAAS,WACT,SAAU,EACV,QAASA,EACT,SAAU,SACV,QAAS,IACX,CACF,CACF,CACF,CACF,CACF,CAAC,EAED,MAAMM,EAAS,MAAM,IAAIX,EACvBI,CACF,EAAE,+BAA+B,CAC/B,gBAAAC,EACA,WAAAS,EACA,QAAAP,CACF,CAAC,EAED,OAAOI,CAAM,EAAE,QACbb,EACE,IAAI,MACF,mFAAmFO,CAAe,oBAAoBS,CAAU,EAClI,CACF,CACF,CACF,CAAC,EAED,GAAG,8CAA+C,SAAY,CAC5D,GAAG,MAAMjB,EAAO,SAAS,EAAE,kBAAkB,IAAI,MAAM,eAAe,CAAC,EAEvE,MAAMc,EAAS,MAAM,IAAIX,EACvBI,CACF,EAAE,+BAA+B,CAC/B,gBAAAC,EACA,WAAAS,EACA,QAAAP,CACF,CAAC,EAED,OAAOI,CAAM,EAAE,QACbb,EACE,IAAI,MACF,wGACF,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["axios", "Left", "Right", "HttpGatedDescriptorDataSource", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "config", "contractAddress", "selector", "chainId", "descriptorPayload", "validGatedDappsResponse", "expectedSignedDescriptor", "result", "configMain", "invalidResponseError", "schemaHash", "descriptorPayloadTypedData", "validTypedDataResponse", "expectedSignedDescriptorTypedData"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=GatedDappsDto.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ContainerModule as e}from"inversify";import{HttpGatedDescriptorDataSource as r}from"../../gated-signing/data/HttpGatedDescriptorDataSource";import{GatedSigningContextLoader as a}from"../../gated-signing/domain/GatedSigningContextLoader";import{GatedSigningTypedDataContextLoader as i}from"../../gated-signing/domain/GatedSigningTypedDataContextLoader";import{gatedSigningTypes as o}from"./gatedSigningTypes";const S=()=>new e(({bind:t})=>{t(o.GatedDescriptorDataSource).to(r),t(o.GatedSigningContextLoader).to(a),t(o.GatedSigningTypedDataContextLoader).to(i)});export{S as gatedSigningModuleFactory};
|
|
2
|
+
//# sourceMappingURL=gatedSigningModuleFactory.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/gated-signing/di/gatedSigningModuleFactory.ts"],
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpGatedDescriptorDataSource } from \"@/gated-signing/data/HttpGatedDescriptorDataSource\";\nimport { GatedSigningContextLoader } from \"@/gated-signing/domain/GatedSigningContextLoader\";\nimport { GatedSigningTypedDataContextLoader } from \"@/gated-signing/domain/GatedSigningTypedDataContextLoader\";\n\nimport { gatedSigningTypes } from \"./gatedSigningTypes\";\n\nexport const gatedSigningModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(gatedSigningTypes.GatedDescriptorDataSource).to(\n HttpGatedDescriptorDataSource,\n );\n bind(gatedSigningTypes.GatedSigningContextLoader).to(\n GatedSigningContextLoader,\n );\n bind(gatedSigningTypes.GatedSigningTypedDataContextLoader).to(\n GatedSigningTypedDataContextLoader,\n );\n });\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,iCAAAC,MAAqC,qDAC9C,OAAS,6BAAAC,MAAiC,mDAC1C,OAAS,sCAAAC,MAA0C,4DAEnD,OAAS,qBAAAC,MAAyB,sBAE3B,MAAMC,EAA4B,IACvC,IAAIL,EAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAKF,EAAkB,yBAAyB,EAAE,GAChDH,CACF,EACAK,EAAKF,EAAkB,yBAAyB,EAAE,GAChDF,CACF,EACAI,EAAKF,EAAkB,kCAAkC,EAAE,GACzDD,CACF,CACF,CAAC",
|
|
6
|
+
"names": ["ContainerModule", "HttpGatedDescriptorDataSource", "GatedSigningContextLoader", "GatedSigningTypedDataContextLoader", "gatedSigningTypes", "gatedSigningModuleFactory", "bind"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e={GatedDescriptorDataSource:Symbol.for("GatedDescriptorDataSource"),GatedSigningContextLoader:Symbol.for("GatedSigningContextLoader"),GatedSigningTypedDataContextLoader:Symbol.for("GatedSigningTypedDataContextLoader")};export{e as gatedSigningTypes};
|
|
2
|
+
//# sourceMappingURL=gatedSigningTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/gated-signing/di/gatedSigningTypes.ts"],
|
|
4
|
+
"sourcesContent": ["export const gatedSigningTypes = {\n GatedDescriptorDataSource: Symbol.for(\"GatedDescriptorDataSource\"),\n GatedSigningContextLoader: Symbol.for(\"GatedSigningContextLoader\"),\n GatedSigningTypedDataContextLoader: Symbol.for(\n \"GatedSigningTypedDataContextLoader\",\n ),\n};\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAAoB,CAC/B,0BAA2B,OAAO,IAAI,2BAA2B,EACjE,0BAA2B,OAAO,IAAI,2BAA2B,EACjE,mCAAoC,OAAO,IACzC,oCACF,CACF",
|
|
6
|
+
"names": ["gatedSigningTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var I=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var m=(o,e,r,t)=>{for(var a=t>1?void 0:t?_(e,r):e,i=o.length-1,n;i>=0;i--)(n=o[i])&&(a=(t?n(e,r,a):n(a))||a);return t&&a&&I(e,r,a),a},d=(o,e)=>(r,t)=>e(r,t,o);import{isHexaString as g}from"@ledgerhq/device-management-kit";import{inject as l,injectable as P}from"inversify";import{gatedSigningTypes as h}from"../../gated-signing/di/gatedSigningTypes";import{pkiTypes as k}from"../../pki/di/pkiTypes";import{KeyId as v}from"../../pki/model/KeyId";import{KeyUsage as T}from"../../pki/model/KeyUsage";import{proxyTypes as A}from"../../proxy/di/proxyTypes";import{ClearSignContextType as c}from"../../shared/model/ClearSignContext";const R=[c.GATED_SIGNING];function w(o){const e=o.toLowerCase();return e.startsWith("0x")?e:`0x${e}`}let p=class{constructor(e,r,t){this._dataSource=e;this._certificateLoader=r;this._proxyDataSource=t}canHandle(e,r){return R.every(t=>r.includes(t))&&typeof e=="object"&&e!==null&&"to"in e&&g(e.to)&&e.to!=="0x"&&"selector"in e&&g(e.selector)&&"chainId"in e&&typeof e.chainId=="number"&&"deviceModelId"in e&&e.deviceModelId!==void 0}async load({to:e,selector:r,chainId:t,deviceModelId:a}){const i=await this._dataSource.getGatedDescriptor({contractAddress:e,selector:r,chainId:t});if(i.isRight()){const{signedDescriptor:D}=i.unsafeCoerce(),G=await this._loadGatedCertificate(a);return[{type:c.GATED_SIGNING,payload:D,certificate:G}]}const n={type:c.ERROR,error:i.extract()},y=await this._proxyDataSource.getProxyImplementationAddress({proxyAddress:e,chainId:t,challenge:"",calldata:"0x"});if(y.isLeft())return[n];const s=y.unsafeCoerce(),x=w(s.implementationAddress),f=await this._dataSource.getGatedDescriptor({contractAddress:x,selector:r,chainId:t});if(f.isLeft())return[n];const{signedDescriptor:S}=f.unsafeCoerce(),[C,u]=await Promise.all([this._certificateLoader.loadCertificate({keyId:s.keyId,keyUsage:s.keyUsage,targetDevice:a}),this._loadGatedCertificate(a)]);return[{type:c.PROXY_INFO,payload:s.signedDescriptor,certificate:C},{type:c.GATED_SIGNING,payload:S,certificate:u}]}_loadGatedCertificate(e){return this._certificateLoader.loadCertificate({keyId:v.CalGatedSigning,keyUsage:T.GatedSigning,targetDevice:e})}};p=m([P(),d(0,l(h.GatedDescriptorDataSource)),d(1,l(k.PkiCertificateLoader)),d(2,l(A.ProxyDataSource))],p);export{p as GatedSigningContextLoader};
|
|
2
|
+
//# sourceMappingURL=GatedSigningContextLoader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/gated-signing/domain/GatedSigningContextLoader.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n DeviceModelId,\n HexaString,\n isHexaString,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { type GatedDescriptorDataSource } from \"@/gated-signing/data/GatedDescriptorDataSource\";\nimport { gatedSigningTypes } from \"@/gated-signing/di/gatedSigningTypes\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { proxyTypes } from \"@/proxy/di/proxyTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport type GatedSigningContextInput = {\n to: HexaString;\n selector: HexaString;\n chainId: number;\n deviceModelId: DeviceModelId;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.GATED_SIGNING,\n];\n\nfunction normalizeAddress(address: string): HexaString {\n const lower = address.toLowerCase();\n return (lower.startsWith(\"0x\") ? lower : `0x${lower}`) as HexaString;\n}\n\n@injectable()\nexport class GatedSigningContextLoader\n implements ContextLoader<GatedSigningContextInput>\n{\n constructor(\n @inject(gatedSigningTypes.GatedDescriptorDataSource)\n private readonly _dataSource: GatedDescriptorDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n @inject(proxyTypes.ProxyDataSource)\n private readonly _proxyDataSource: ProxyDataSource,\n ) {}\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is GatedSigningContextInput {\n return (\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type)) &&\n typeof input === \"object\" &&\n input !== null &&\n \"to\" in input &&\n isHexaString(input.to) &&\n input.to !== \"0x\" &&\n \"selector\" in input &&\n isHexaString(input.selector) &&\n \"chainId\" in input &&\n typeof input.chainId === \"number\" &&\n \"deviceModelId\" in input &&\n input.deviceModelId !== undefined\n );\n }\n\n async load({\n to,\n selector,\n chainId,\n deviceModelId,\n }: GatedSigningContextInput): Promise<ClearSignContext[]> {\n const directResult = await this._dataSource.getGatedDescriptor({\n contractAddress: to,\n selector,\n chainId,\n });\n\n if (directResult.isRight()) {\n const { signedDescriptor } = directResult.unsafeCoerce();\n const certificate = await this._loadGatedCertificate(deviceModelId);\n return [\n {\n type: ClearSignContextType.GATED_SIGNING,\n payload: signedDescriptor,\n certificate,\n },\n ];\n }\n\n const errorContext: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: directResult.extract() as Error,\n };\n\n const proxyResult =\n await this._proxyDataSource.getProxyImplementationAddress({\n proxyAddress: to,\n chainId,\n challenge: \"\",\n calldata: \"0x\",\n });\n\n if (proxyResult.isLeft()) {\n return [errorContext];\n }\n\n const proxyData = proxyResult.unsafeCoerce();\n const implementationAddress = normalizeAddress(\n proxyData.implementationAddress,\n );\n\n const implGatedResult = await this._dataSource.getGatedDescriptor({\n contractAddress: implementationAddress,\n selector,\n chainId,\n });\n\n if (implGatedResult.isLeft()) {\n return [errorContext];\n }\n\n const { signedDescriptor } = implGatedResult.unsafeCoerce();\n const [proxyCertificate, gatedCertificate] = await Promise.all([\n this._certificateLoader.loadCertificate({\n keyId: proxyData.keyId,\n keyUsage: proxyData.keyUsage,\n targetDevice: deviceModelId,\n }),\n this._loadGatedCertificate(deviceModelId),\n ]);\n\n return [\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: proxyData.signedDescriptor,\n certificate: proxyCertificate,\n },\n {\n type: ClearSignContextType.GATED_SIGNING,\n payload: signedDescriptor,\n certificate: gatedCertificate,\n },\n ];\n }\n\n private _loadGatedCertificate(deviceModelId: DeviceModelId) {\n return this._certificateLoader.loadCertificate({\n keyId: KeyId.CalGatedSigning,\n keyUsage: KeyUsage.GatedSigning,\n targetDevice: deviceModelId,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAGE,gBAAAA,MACK,kCACP,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAGnC,OAAS,qBAAAC,MAAyB,uCAClC,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAEzB,OAAS,cAAAC,MAAkB,wBAE3B,OAEE,wBAAAC,MACK,kCASP,MAAMC,EAA0C,CAC9CC,EAAqB,aACvB,EAEA,SAASC,EAAiBC,EAA6B,CACrD,MAAMC,EAAQD,EAAQ,YAAY,EAClC,OAAQC,EAAM,WAAW,IAAI,EAAIA,EAAQ,KAAKA,CAAK,EACrD,CAGO,IAAMC,EAAN,KAEP,CACE,YAEmBC,EAEAC,EAEAC,EACjB,CALiB,iBAAAF,EAEA,wBAAAC,EAEA,sBAAAC,CAChB,CAEH,UACEC,EACAC,EACmC,CACnC,OACEV,EAAgB,MAAOW,GAASD,EAAc,SAASC,CAAI,CAAC,GAC5D,OAAOF,GAAU,UACjBA,IAAU,MACV,OAAQA,GACRG,EAAaH,EAAM,EAAE,GACrBA,EAAM,KAAO,MACb,aAAcA,GACdG,EAAaH,EAAM,QAAQ,GAC3B,YAAaA,GACb,OAAOA,EAAM,SAAY,UACzB,kBAAmBA,GACnBA,EAAM,gBAAkB,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EAA8B,CAC1D,OAAO,KAAK,mBAAmB,gBAAgB,CAC7C,MAAOW,EAAM,gBACb,SAAUC,EAAS,aACnB,aAAcZ,CAChB,CAAC,CACH,CACF,EAvHaX,EAANwB,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAkB,yBAAyB,GAElDF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,GAEpCH,EAAA,EAAAC,EAAOG,EAAW,eAAe,IARzB9B",
|
|
6
|
+
"names": ["isHexaString", "inject", "injectable", "gatedSigningTypes", "pkiTypes", "KeyId", "KeyUsage", "proxyTypes", "ClearSignContextType", "SUPPORTED_TYPES", "ClearSignContextType", "normalizeAddress", "address", "lower", "GatedSigningContextLoader", "_dataSource", "_certificateLoader", "_proxyDataSource", "input", "expectedTypes", "type", "isHexaString", "to", "selector", "chainId", "deviceModelId", "directResult", "signedDescriptor", "certificate", "errorContext", "proxyResult", "proxyData", "implementationAddress", "implGatedResult", "proxyCertificate", "gatedCertificate", "KeyId", "KeyUsage", "__decorateClass", "injectable", "__decorateParam", "inject", "gatedSigningTypes", "pkiTypes", "proxyTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DeviceModelId as p}from"@ledgerhq/device-management-kit";import{Left as f,Right as n}from"purify-ts";import{GatedSigningContextLoader as h}from"../../gated-signing/domain/GatedSigningContextLoader";import{KeyId as x}from"../../pki/model/KeyId";import{KeyUsage as m}from"../../pki/model/KeyUsage";import{ClearSignContextType as i}from"../../shared/model/ClearSignContext";describe("GatedSigningContextLoader",()=>{const o={getGatedDescriptor:vi.fn(),getGatedDescriptorForTypedData:vi.fn()},c={loadCertificate:vi.fn()},d={getProxyImplementationAddress:vi.fn()},r=new h(o,c,d),g={keyUsageNumber:1,payload:new Uint8Array([1,2,3])},s=[i.GATED_SIGNING];beforeEach(()=>{vi.resetAllMocks(),vi.spyOn(c,"loadCertificate").mockResolvedValue(g)}),describe("canHandle function",()=>{const e={to:"0x1111111254fb6c44bac0bed2854e76f90643097d",selector:"0xa1251d75",chainId:1,deviceModelId:p.STAX};it("should return true for valid input",()=>{expect(r.canHandle(e,s)).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(r.canHandle(e,[i.TOKEN])).toBe(!1),expect(r.canHandle(e,[i.DYNAMIC_NETWORK])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"]])("should return false for %s",(a,t)=>{expect(r.canHandle(a,s)).toBe(!1)}),it.each([[{...e,to:void 0},"missing to"],[{...e,selector:void 0},"missing selector"],[{...e,chainId:void 0},"missing chainId"],[{...e,deviceModelId:void 0},"missing deviceModelId"]])("should return false for %s",(a,t)=>{expect(r.canHandle(a,s)).toBe(!1)}),it.each([[{...e,to:"0x"},"empty to (0x)"],[{...e,to:"not-hex"},"non-hex to"],[{...e,selector:"not-hex"},"non-hex selector"],[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"]])("should return false for %s",(a,t)=>{expect(r.canHandle(a,s)).toBe(!1)})}),describe("load function",()=>{const e={to:"0x1111111254fb6c44bac0bed2854e76f90643097d",selector:"0xa1251d75",chainId:1,deviceModelId:p.STAX},a="010122020101222a30783131313131313235346662366334346261633062656432383534653736663930363433303937642308000000000000000140086131323531643735150100";it("should return error context when getGatedDescriptor returns Left and proxy resolution fails",async()=>{const t=new Error("Failed to fetch gated descriptors");vi.spyOn(o,"getGatedDescriptor").mockResolvedValue(f(t)),vi.spyOn(d,"getProxyImplementationAddress").mockResolvedValue(f(new Error("Not a proxy")));const l=await r.load(e);expect(l).toEqual([{type:i.ERROR,error:t}]),expect(o.getGatedDescriptor).toHaveBeenCalledWith({contractAddress:e.to,selector:e.selector,chainId:e.chainId}),expect(d.getProxyImplementationAddress).toHaveBeenCalledWith({proxyAddress:e.to,chainId:e.chainId,challenge:"",calldata:"0x"}),expect(c.loadCertificate).not.toHaveBeenCalled()}),it("should return gated signing context when getGatedDescriptor succeeds",async()=>{vi.spyOn(o,"getGatedDescriptor").mockResolvedValue(n({signedDescriptor:a}));const t=await r.load(e);expect(t).toHaveLength(1),expect(t[0]).toMatchObject({type:i.GATED_SIGNING,payload:a,certificate:g}),expect(o.getGatedDescriptor).toHaveBeenCalledWith({contractAddress:e.to,selector:e.selector,chainId:e.chainId}),expect(c.loadCertificate).toHaveBeenCalledWith({keyId:x.CalGatedSigning,keyUsage:m.GatedSigning,targetDevice:e.deviceModelId})}),it("should pass to as contractAddress to getGatedDescriptor",async()=>{const t="0xabcdef1234567890abcdef1234567890abcdef12";vi.spyOn(o,"getGatedDescriptor").mockResolvedValue(n({signedDescriptor:a})),await r.load({...e,to:t}),expect(o.getGatedDescriptor).toHaveBeenCalledWith(expect.objectContaining({contractAddress:t}))}),it("should request certificate for correct device model",async()=>{vi.spyOn(o,"getGatedDescriptor").mockResolvedValue(n({signedDescriptor:a})),await r.load({...e,deviceModelId:p.FLEX}),expect(c.loadCertificate).toHaveBeenCalledWith({keyId:x.CalGatedSigning,keyUsage:m.GatedSigning,targetDevice:p.FLEX})}),it("should reject when certificate loading fails",async()=>{const t=new Error("Certificate loading failed");vi.spyOn(o,"getGatedDescriptor").mockResolvedValue(n({signedDescriptor:a})),vi.spyOn(c,"loadCertificate").mockRejectedValue(t),await expect(r.load(e)).rejects.toThrow(t)}),it("should return PROXY_INFO and GATED_SIGNING when to is proxy and gated descriptor exists for implementation",async()=>{const t="0xabcdef1234567890abcdef1234567890abcdef12",l="0xproxy-descriptor";vi.spyOn(o,"getGatedDescriptor").mockResolvedValueOnce(f(new Error("No gated descriptor"))).mockResolvedValueOnce(n({signedDescriptor:a})),vi.spyOn(d,"getProxyImplementationAddress").mockResolvedValue(n({implementationAddress:t,signedDescriptor:l,keyId:"domain-metadata",keyUsage:"trusted-name"}));const u=await r.load(e);expect(u).toHaveLength(2),expect(u[0]).toMatchObject({type:i.PROXY_INFO,payload:l}),expect(u[1]).toMatchObject({type:i.GATED_SIGNING,payload:a}),expect(o.getGatedDescriptor).toHaveBeenCalledTimes(2),expect(o.getGatedDescriptor).toHaveBeenNthCalledWith(1,{contractAddress:e.to,selector:e.selector,chainId:e.chainId}),expect(o.getGatedDescriptor).toHaveBeenNthCalledWith(2,{contractAddress:t.toLowerCase(),selector:e.selector,chainId:e.chainId})})})});
|
|
2
|
+
//# sourceMappingURL=GatedSigningContextLoader.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/gated-signing/domain/GatedSigningContextLoader.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type GatedDescriptorDataSource } from \"@/gated-signing/data/GatedDescriptorDataSource\";\nimport {\n type GatedSigningContextInput,\n GatedSigningContextLoader,\n} from \"@/gated-signing/domain/GatedSigningContextLoader\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\ndescribe(\"GatedSigningContextLoader\", () => {\n const mockGatedDescriptorDataSource: GatedDescriptorDataSource = {\n getGatedDescriptor: vi.fn(),\n getGatedDescriptorForTypedData: vi.fn(),\n };\n\n const mockCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n\n const mockProxyDataSource: ProxyDataSource = {\n getProxyImplementationAddress: vi.fn(),\n };\n\n const loader = new GatedSigningContextLoader(\n mockGatedDescriptorDataSource,\n mockCertificateLoader,\n mockProxyDataSource,\n );\n\n const mockCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n const SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.GATED_SIGNING,\n ];\n\n beforeEach(() => {\n vi.resetAllMocks();\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n mockCertificate,\n );\n });\n\n describe(\"canHandle function\", () => {\n const validInput: GatedSigningContextInput = {\n to: \"0x1111111254fb6c44bac0bed2854e76f90643097d\",\n selector: \"0xa1251d75\",\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n };\n\n it(\"should return true for valid input\", () => {\n expect(loader.canHandle(validInput, SUPPORTED_TYPES)).toBe(true);\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.DYNAMIC_NETWORK]),\n ).toBe(false);\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n [123, \"number input\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: undefined }, \"missing to\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, deviceModelId: undefined }, \"missing deviceModelId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: \"0x\" }, \"empty to (0x)\"],\n [{ ...validInput, to: \"not-hex\" }, \"non-hex to\"],\n [{ ...validInput, selector: \"not-hex\" }, \"non-hex selector\"],\n [{ ...validInput, chainId: \"1\" as unknown as number }, \"string chainId\"],\n [{ ...validInput, chainId: null as unknown as number }, \"null chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n });\n\n describe(\"load function\", () => {\n const validInput: GatedSigningContextInput = {\n to: \"0x1111111254fb6c44bac0bed2854e76f90643097d\",\n selector: \"0xa1251d75\",\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n };\n\n const signedDescriptor =\n \"010122020101222a30783131313131313235346662366334346261633062656432383534653736663930363433303937642308000000000000000140086131323531643735150100\";\n\n it(\"should return error context when getGatedDescriptor returns Left and proxy resolution fails\", async () => {\n const error = new Error(\"Failed to fetch gated descriptors\");\n vi.spyOn(\n mockGatedDescriptorDataSource,\n \"getGatedDescriptor\",\n ).mockResolvedValue(Left(error));\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(Left(new Error(\"Not a proxy\")));\n\n const result = await loader.load(validInput);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error,\n },\n ]);\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptor,\n ).toHaveBeenCalledWith({\n contractAddress: validInput.to,\n selector: validInput.selector,\n chainId: validInput.chainId,\n });\n expect(\n mockProxyDataSource.getProxyImplementationAddress,\n ).toHaveBeenCalledWith({\n proxyAddress: validInput.to,\n chainId: validInput.chainId,\n challenge: \"\",\n calldata: \"0x\",\n });\n expect(mockCertificateLoader.loadCertificate).not.toHaveBeenCalled();\n });\n\n it(\"should return gated signing context when getGatedDescriptor succeeds\", async () => {\n vi.spyOn(\n mockGatedDescriptorDataSource,\n \"getGatedDescriptor\",\n ).mockResolvedValue(Right({ signedDescriptor }));\n\n const result = await loader.load(validInput);\n\n expect(result).toHaveLength(1);\n expect(result[0]).toMatchObject({\n type: ClearSignContextType.GATED_SIGNING,\n payload: signedDescriptor,\n certificate: mockCertificate,\n });\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptor,\n ).toHaveBeenCalledWith({\n contractAddress: validInput.to,\n selector: validInput.selector,\n chainId: validInput.chainId,\n });\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: KeyId.CalGatedSigning,\n keyUsage: KeyUsage.GatedSigning,\n targetDevice: validInput.deviceModelId,\n });\n });\n\n it(\"should pass to as contractAddress to getGatedDescriptor\", async () => {\n const customTo = \"0xabcdef1234567890abcdef1234567890abcdef12\";\n vi.spyOn(\n mockGatedDescriptorDataSource,\n \"getGatedDescriptor\",\n ).mockResolvedValue(Right({ signedDescriptor }));\n\n await loader.load({\n ...validInput,\n to: customTo,\n });\n\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptor,\n ).toHaveBeenCalledWith(\n expect.objectContaining({\n contractAddress: customTo,\n }),\n );\n });\n\n it(\"should request certificate for correct device model\", async () => {\n vi.spyOn(\n mockGatedDescriptorDataSource,\n \"getGatedDescriptor\",\n ).mockResolvedValue(Right({ signedDescriptor }));\n\n await loader.load({\n ...validInput,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: KeyId.CalGatedSigning,\n keyUsage: KeyUsage.GatedSigning,\n targetDevice: DeviceModelId.FLEX,\n });\n });\n\n it(\"should reject when certificate loading fails\", async () => {\n const certificateError = new Error(\"Certificate loading failed\");\n vi.spyOn(\n mockGatedDescriptorDataSource,\n \"getGatedDescriptor\",\n ).mockResolvedValue(Right({ signedDescriptor }));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockRejectedValue(\n certificateError,\n );\n\n await expect(loader.load(validInput)).rejects.toThrow(certificateError);\n });\n\n it(\"should return PROXY_INFO and GATED_SIGNING when to is proxy and gated descriptor exists for implementation\", async () => {\n const implementationAddress =\n \"0xabcdef1234567890abcdef1234567890abcdef12\";\n const proxySignedDescriptor = \"0xproxy-descriptor\";\n vi.spyOn(mockGatedDescriptorDataSource, \"getGatedDescriptor\")\n .mockResolvedValueOnce(Left(new Error(\"No gated descriptor\")))\n .mockResolvedValueOnce(Right({ signedDescriptor }));\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(\n Right({\n implementationAddress,\n signedDescriptor: proxySignedDescriptor,\n keyId: \"domain-metadata\",\n keyUsage: \"trusted-name\",\n }),\n );\n\n const result = await loader.load(validInput);\n\n expect(result).toHaveLength(2);\n expect(result[0]).toMatchObject({\n type: ClearSignContextType.PROXY_INFO,\n payload: proxySignedDescriptor,\n });\n expect(result[1]).toMatchObject({\n type: ClearSignContextType.GATED_SIGNING,\n payload: signedDescriptor,\n });\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptor,\n ).toHaveBeenCalledTimes(2);\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptor,\n ).toHaveBeenNthCalledWith(1, {\n contractAddress: validInput.to,\n selector: validInput.selector,\n chainId: validInput.chainId,\n });\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptor,\n ).toHaveBeenNthCalledWith(2, {\n contractAddress: implementationAddress.toLowerCase(),\n selector: validInput.selector,\n chainId: validInput.chainId,\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OAEE,6BAAAC,MACK,mDAEP,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAGzB,OAAS,wBAAAC,MAA4B,kCAErC,SAAS,4BAA6B,IAAM,CAC1C,MAAMC,EAA2D,CAC/D,mBAAoB,GAAG,GAAG,EAC1B,+BAAgC,GAAG,GAAG,CACxC,EAEMC,EAA8C,CAClD,gBAAiB,GAAG,GAAG,CACzB,EAEMC,EAAuC,CAC3C,8BAA+B,GAAG,GAAG,CACvC,EAEMC,EAAS,IAAIP,EACjBI,EACAC,EACAC,CACF,EAEME,EAAkC,CACtC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAC5C,EAEMC,EAA0C,CAC9CN,EAAqB,aACvB,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjB,GAAG,MAAME,EAAuB,iBAAiB,EAAE,kBACjDG,CACF,CACF,CAAC,EAED,SAAS,qB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,EACJ,6CACIC,EAAwB,qBAC9B,GAAG,MAAMf,EAA+B,oBAAoB,EACzD,sBAAsBN,EAAK,IAAI,MAAM,qBAAqB,CAAC,CAAC,EAC5D,sBAAsBC,EAAM,CAAE,iBAAAc,CAAiB,CAAC,CAAC,EACpD,GAAG,MACDP,EACA,+BACF,EAAE,kBACAP,EAAM,CACJ,sBAAAmB,EACA,iBAAkBC,EAClB,MAAO,kBACP,SAAU,cACZ,CAAC,CACH,EAEA,MAAMJ,EAAS,MAAMR,EAAO,KAAKG,CAAU,EAE3C,OAAOK,CAAM,EAAE,aAAa,CAAC,EAC7B,OAAOA,EAAO,CAAC,CAAC,EAAE,cAAc,CAC9B,KAAMZ,EAAqB,WAC3B,QAASgB,CACX,CAAC,EACD,OAAOJ,EAAO,CAAC,CAAC,EAAE,cAAc,CAC9B,KAAMZ,EAAqB,cAC3B,QAASU,CACX,CAAC,EACD,OACET,EAA8B,kBAChC,EAAE,sBAAsB,CAAC,EACzB,OACEA,EAA8B,kBAChC,EAAE,wBAAwB,EAAG,CAC3B,gBAAiBM,EAAW,GAC5B,SAAUA,EAAW,SACrB,QAASA,EAAW,OACtB,CAAC,EACD,OACEN,EAA8B,kBAChC,EAAE,wBAAwB,EAAG,CAC3B,gBAAiBc,EAAsB,YAAY,EACnD,SAAUR,EAAW,SACrB,QAASA,EAAW,OACtB,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["DeviceModelId", "Left", "Right", "GatedSigningContextLoader", "KeyId", "KeyUsage", "ClearSignContextType", "mockGatedDescriptorDataSource", "mockCertificateLoader", "mockProxyDataSource", "loader", "mockCertificate", "SUPPORTED_TYPES", "validInput", "input", "_description", "signedDescriptor", "error", "result", "customTo", "certificateError", "implementationAddress", "proxySignedDescriptor"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var w=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var D=(i,e,r,t)=>{for(var a=t>1?void 0:t?v(e,r):e,o=i.length-1,n;o>=0;o--)(n=i[o])&&(a=(t?n(e,r,a):n(a))||a);return t&&a&&w(e,r,a),a},p=(i,e)=>(r,t)=>e(r,t,i);import{inject as l,injectable as _}from"inversify";import{gatedSigningTypes as A}from"../../gated-signing/di/gatedSigningTypes";import{pkiTypes as P}from"../../pki/di/pkiTypes";import{KeyId as C}from"../../pki/model/KeyId";import{KeyUsage as h}from"../../pki/model/KeyUsage";import{proxyTypes as E}from"../../proxy/di/proxyTypes";import{ClearSignContextType as s}from"../../shared/model/ClearSignContext";import{getSchemaHash as L}from"../../typed-data/utils/getSchemaHash";const H="0x0000000000000000000000000000000000000000",b=[s.GATED_SIGNING];function j(i){if(!i||typeof i!="object")return!1;const e=i;if(!e.types||typeof e.types!="object"||Array.isArray(e.types))return!1;const r=e.types;for(const t of Object.keys(r)){if(typeof t!="string")return!1;const a=r[t];if(!Array.isArray(a))return!1;for(const o of a)if(!o||typeof o!="object"||typeof o.name!="string"||typeof o.type!="string")return!1}return!0}let d=class{constructor(e,r,t){this._dataSource=e;this._certificateLoader=r;this._proxyDataSource=t}canHandle(e,r){return b.every(t=>r.includes(t))&&typeof e=="object"&&e!==null&&"data"in e&&j(e.data)&&"chainId"in e&&"deviceModelId"in e&&e.deviceModelId!==void 0&&"challenge"in e&&typeof e.challenge=="string"}async load({data:e,chainId:r,deviceModelId:t,challenge:a}){const o=e.domain?.verifyingContract?.toLowerCase()??H,n=o.startsWith("0x")?o:`0x${o}`,m=L(e.types),y=await this._dataSource.getGatedDescriptorForTypedData({contractAddress:n,schemaHash:m,chainId:r});if(y.isRight()){const{signedDescriptor:g}=y.unsafeCoerce(),R=await this._certificateLoader.loadCertificate({keyId:C.CalGatedSigning,keyUsage:h.GatedSigning,targetDevice:t});return[{type:s.GATED_SIGNING,payload:g,certificate:R}]}const S=y.caseOf({Left:g=>g,Right:()=>new Error("unreachable")}),u=await this._proxyDataSource.getProxyImplementationAddress({proxyAddress:n,chainId:r,challenge:a,calldata:"0x"});if(u.isLeft())return[{type:s.ERROR,error:S}];const c=u.unsafeCoerce(),f=c.implementationAddress.toLowerCase(),G=f.startsWith("0x")?f:`0x${f}`,x=await this._dataSource.getGatedDescriptorForTypedData({contractAddress:G,schemaHash:m,chainId:r});if(x.isLeft())return[{type:s.ERROR,error:S}];const{signedDescriptor:I}=x.unsafeCoerce(),[T,k]=await Promise.all([this._certificateLoader.loadCertificate({keyId:c.keyId,keyUsage:c.keyUsage,targetDevice:t}),this._certificateLoader.loadCertificate({keyId:C.CalGatedSigning,keyUsage:h.GatedSigning,targetDevice:t})]);return[{type:s.PROXY_INFO,payload:c.signedDescriptor,certificate:T},{type:s.GATED_SIGNING,payload:I,certificate:k}]}};d=D([_(),p(0,l(A.GatedDescriptorDataSource)),p(1,l(P.PkiCertificateLoader)),p(2,l(E.ProxyDataSource))],d);export{d as GatedSigningTypedDataContextLoader};
|
|
2
|
+
//# sourceMappingURL=GatedSigningTypedDataContextLoader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/gated-signing/domain/GatedSigningTypedDataContextLoader.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n DeviceModelId,\n type HexaString,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { type GatedDescriptorDataSource } from \"@/gated-signing/data/GatedDescriptorDataSource\";\nimport { gatedSigningTypes } from \"@/gated-signing/di/gatedSigningTypes\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { proxyTypes } from \"@/proxy/di/proxyTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport type { TypedDataSchema } from \"@/shared/model/TypedDataContext\";\nimport { getSchemaHash } from \"@/typed-data/utils/getSchemaHash\";\n\nconst ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\";\n\nexport type GatedSigningTypedDataContextInput = {\n data: {\n types: TypedDataSchema;\n domain?: { verifyingContract?: string };\n };\n chainId: number;\n deviceModelId: DeviceModelId;\n challenge: string;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.GATED_SIGNING,\n];\n\nfunction hasTypedDataShape(\n data: unknown,\n): data is { types: TypedDataSchema; domain?: { verifyingContract?: string } } {\n if (!data || typeof data !== \"object\") return false;\n const obj = data as Record<string, unknown>;\n if (\n !obj[\"types\"] ||\n typeof obj[\"types\"] !== \"object\" ||\n Array.isArray(obj[\"types\"])\n ) {\n return false;\n }\n const types = obj[\"types\"] as Record<string, unknown>;\n for (const key of Object.keys(types)) {\n if (typeof key !== \"string\") return false;\n const value = types[key];\n if (!Array.isArray(value)) return false;\n for (const item of value) {\n if (\n !item ||\n typeof item !== \"object\" ||\n typeof (item as { name?: unknown }).name !== \"string\" ||\n typeof (item as { type?: unknown }).type !== \"string\"\n ) {\n return false;\n }\n }\n }\n return true;\n}\n\n@injectable()\nexport class GatedSigningTypedDataContextLoader\n implements ContextLoader<GatedSigningTypedDataContextInput>\n{\n constructor(\n @inject(gatedSigningTypes.GatedDescriptorDataSource)\n private readonly _dataSource: GatedDescriptorDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n @inject(proxyTypes.ProxyDataSource)\n private readonly _proxyDataSource: ProxyDataSource,\n ) {}\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is GatedSigningTypedDataContextInput {\n return (\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type)) &&\n typeof input === \"object\" &&\n input !== null &&\n \"data\" in input &&\n hasTypedDataShape((input as GatedSigningTypedDataContextInput).data) &&\n \"chainId\" in input &&\n \"deviceModelId\" in input &&\n (input as GatedSigningTypedDataContextInput).deviceModelId !==\n undefined &&\n \"challenge\" in input &&\n typeof (input as GatedSigningTypedDataContextInput).challenge === \"string\"\n );\n }\n\n async load({\n data,\n chainId,\n deviceModelId,\n challenge,\n }: GatedSigningTypedDataContextInput): Promise<ClearSignContext[]> {\n const raw = data.domain?.verifyingContract?.toLowerCase() ?? ZERO_ADDRESS;\n const verifyingContract: HexaString = raw.startsWith(\"0x\")\n ? (raw as HexaString)\n : (`0x${raw}` as HexaString);\n const schemaHash = getSchemaHash(data.types);\n\n const directResult = await this._dataSource.getGatedDescriptorForTypedData({\n contractAddress: verifyingContract,\n schemaHash,\n chainId,\n });\n\n if (directResult.isRight()) {\n const { signedDescriptor } = directResult.unsafeCoerce();\n const certificate = await this._certificateLoader.loadCertificate({\n keyId: KeyId.CalGatedSigning,\n keyUsage: KeyUsage.GatedSigning,\n targetDevice: deviceModelId,\n });\n return [\n {\n type: ClearSignContextType.GATED_SIGNING,\n payload: signedDescriptor,\n certificate,\n },\n ];\n }\n\n const firstError: Error = directResult.caseOf({\n Left: (error) => error,\n Right: () => new Error(\"unreachable\"),\n });\n\n const proxyResult =\n await this._proxyDataSource.getProxyImplementationAddress({\n proxyAddress: verifyingContract,\n chainId,\n challenge,\n calldata: \"0x\",\n });\n\n if (proxyResult.isLeft()) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: firstError,\n },\n ];\n }\n\n const proxyData = proxyResult.unsafeCoerce();\n const implRaw = proxyData.implementationAddress.toLowerCase();\n const implementationAddress: HexaString = implRaw.startsWith(\"0x\")\n ? (implRaw as HexaString)\n : (`0x${implRaw}` as HexaString);\n\n const implGatedResult =\n await this._dataSource.getGatedDescriptorForTypedData({\n contractAddress: implementationAddress,\n schemaHash,\n chainId,\n });\n\n if (implGatedResult.isLeft()) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: firstError,\n },\n ];\n }\n\n const { signedDescriptor } = implGatedResult.unsafeCoerce();\n const [proxyCertificate, gatedCertificate] = await Promise.all([\n this._certificateLoader.loadCertificate({\n keyId: proxyData.keyId,\n keyUsage: proxyData.keyUsage,\n targetDevice: deviceModelId,\n }),\n this._certificateLoader.loadCertificate({\n keyId: KeyId.CalGatedSigning,\n keyUsage: KeyUsage.GatedSigning,\n targetDevice: deviceModelId,\n }),\n ]);\n\n return [\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: proxyData.signedDescriptor,\n certificate: proxyCertificate,\n },\n {\n type: ClearSignContextType.GATED_SIGNING,\n payload: signedDescriptor,\n certificate: gatedCertificate,\n },\n ];\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAIA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAGnC,OAAS,qBAAAC,MAAyB,uCAClC,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAEzB,OAAS,cAAAC,MAAkB,wBAE3B,OAEE,wBAAAC,MACK,kCAEP,OAAS,iBAAAC,MAAqB,mCAE9B,MAAMC,EAAe,6CAYfC,EAA0C,CAC9CC,EAAqB,aACvB,EAEA,SAASC,EACPC,EAC6E,CAC7E,GAAI,CAACA,GAAQ,OAAOA,GAAS,SAAU,MAAO,GAC9C,MAAMC,EAAMD,EACZ,GACE,CAACC,EAAI,OACL,OAAOA,EAAI,OAAa,UACxB,MAAM,QAAQA,EAAI,KAAQ,EAE1B,MAAO,GAET,MAAMC,EAAQD,EAAI,MAClB,UAAWE,KAAO,OAAO,KAAKD,CAAK,EAAG,CACpC,GAAI,OAAOC,GAAQ,SAAU,MAAO,GACpC,MAAMC,EAAQF,EAAMC,CAAG,EACvB,GAAI,CAAC,MAAM,QAAQC,CAAK,EAAG,MAAO,GAClC,UAAWC,KAAQD,EACjB,GACE,CAACC,GACD,OAAOA,GAAS,UAChB,OAAQA,EAA4B,MAAS,UAC7C,OAAQA,EAA4B,MAAS,S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CACE,KAAM7B,EAAqB,MAC3B,MAAO2B,CACT,CACF,EAGF,MAAMG,EAAYD,EAAY,aAAa,EACrCE,EAAUD,EAAU,sBAAsB,YAAY,EACtDE,EAAoCD,EAAQ,WAAW,IAAI,EAC5DA,EACA,KAAKA,CAAO,GAEXE,EACJ,MAAM,KAAK,YAAY,+BAA+B,CACpD,gBAAiBD,EACjB,WAAAZ,EACA,QAAAL,CACF,CAAC,EAEH,GAAIkB,EAAgB,OAAO,EACzB,MAAO,CACL,CACE,KAAMjC,EAAqB,MAC3B,MAAO2B,CACT,CACF,EAGF,KAAM,CAAE,iBAAAJ,CAAiB,EAAIU,EAAgB,aAAa,EACpD,CAACC,EAAkBC,CAAgB,EAAI,MAAM,QAAQ,IAAI,CAC7D,KAAK,mBAAmB,gBAAgB,CACtC,MAAOL,EAAU,MACjB,SAAUA,EAAU,SACpB,aAAcd,CAChB,CAAC,EACD,KAAK,mBAAmB,gBAAgB,CACtC,MAAOS,EAAM,gBACb,SAAUC,EAAS,aACnB,aAAcV,CAChB,CAAC,CACH,CAAC,EAED,MAAO,CACL,CACE,KAAMhB,EAAqB,WAC3B,QAAS8B,EAAU,iBACnB,YAAaI,CACf,EACA,CACE,KAAMlC,EAAqB,cAC3B,QAASuB,EACT,YAAaY,CACf,CACF,CACF,CACF,EAxIa3B,EAAN4B,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAkB,yBAAyB,GAElDF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,GAEpCH,EAAA,EAAAC,EAAOG,EAAW,eAAe,IARzBlC",
|
|
6
|
+
"names": ["inject", "injectable", "gatedSigningTypes", "pkiTypes", "KeyId", "KeyUsage", "proxyTypes", "ClearSignContextType", "getSchemaHash", "ZERO_ADDRESS", "SUPPORTED_TYPES", "ClearSignContextType", "hasTypedDataShape", "data", "obj", "types", "key", "value", "item", "GatedSigningTypedDataContextLoader", "_dataSource", "_certificateLoader", "_proxyDataSource", "input", "expectedTypes", "type", "chainId", "deviceModelId", "challenge", "raw", "verifyingContract", "schemaHash", "getSchemaHash", "directResult", "signedDescriptor", "certificate", "KeyId", "KeyUsage", "firstError", "error", "proxyResult", "proxyData", "implRaw", "implementationAddress", "implGatedResult", "proxyCertificate", "gatedCertificate", "__decorateClass", "injectable", "__decorateParam", "inject", "gatedSigningTypes", "pkiTypes", "proxyTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DeviceModelId as i}from"@ledgerhq/device-management-kit";import{Left as g,Right as s}from"purify-ts";import{GatedSigningTypedDataContextLoader as u}from"../../gated-signing/domain/GatedSigningTypedDataContextLoader";import{KeyId as f}from"../../pki/model/KeyId";import{KeyUsage as m}from"../../pki/model/KeyUsage";import{ClearSignContextType as r}from"../../shared/model/ClearSignContext";describe("GatedSigningTypedDataContextLoader",()=>{const a={getGatedDescriptor:vi.fn(),getGatedDescriptorForTypedData:vi.fn()},c={loadCertificate:vi.fn()},l={getProxyImplementationAddress:vi.fn()},t=new u(a,c,l),h={keyUsageNumber:1,payload:new Uint8Array([1,2,3])},n=[r.GATED_SIGNING],e={data:{types:{EIP712Domain:[{name:"name",type:"string"},{name:"chainId",type:"uint256"}],Mail:[{name:"subject",type:"string"}]},domain:{verifyingContract:"0x1111111254fb6c44bac0bed2854e76f90643097d"}},chainId:1,deviceModelId:i.STAX,challenge:"test-challenge"};beforeEach(()=>{vi.resetAllMocks(),vi.spyOn(c,"loadCertificate").mockResolvedValue(h)}),describe("canHandle",()=>{it("should return true for valid typed data input",()=>{expect(t.canHandle(e,n)).toBe(!0)}),it("should return false when expected types do not include GATED_SIGNING",()=>{expect(t.canHandle(e,[r.TOKEN])).toBe(!1),expect(t.canHandle(e,[r.DYNAMIC_NETWORK])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"]])("should return false for %s",(d,o)=>{expect(t.canHandle(d,n)).toBe(!1)}),it("should return false for transaction-style input (selector, to)",()=>{const d={to:"0x1111111254fb6c44bac0bed2854e76f90643097d",selector:"0xa1251d75",chainId:1,deviceModelId:i.STAX};expect(t.canHandle(d,n)).toBe(!1)}),it("should return false when data is missing",()=>{expect(t.canHandle({chainId:1,deviceModelId:i.STAX},n)).toBe(!1)}),it("should return false when data.types is not a valid schema",()=>{expect(t.canHandle({data:{types:"not-an-object"},chainId:1,deviceModelId:i.STAX,challenge:e.challenge},n)).toBe(!1),expect(t.canHandle({data:{types:{}},chainId:1,deviceModelId:i.STAX,challenge:e.challenge},n)).toBe(!0)}),it("should return false when chainId or deviceModelId is missing",()=>{expect(t.canHandle({data:e.data,deviceModelId:i.STAX,challenge:e.challenge},n)).toBe(!1),expect(t.canHandle({data:e.data,chainId:1,challenge:e.challenge},n)).toBe(!1)}),it("should return false when challenge is missing",()=>{expect(t.canHandle({data:e.data,chainId:1,deviceModelId:i.STAX},n)).toBe(!1)})}),describe("load",()=>{const d="010122020101222a30783131313131313235346662366334346261633062656432383534653736663930363433303937642308000000000000000140086131323531643735150100";it("should return error context when getGatedDescriptorForTypedData returns Left and proxy resolution fails",async()=>{const o=new Error("No gated descriptor for schema hash");vi.spyOn(a,"getGatedDescriptorForTypedData").mockResolvedValue(g(o)),vi.spyOn(l,"getProxyImplementationAddress").mockResolvedValue(g(new Error("Not a proxy")));const p=await t.load(e);expect(p).toEqual([{type:r.ERROR,error:o}]),expect(a.getGatedDescriptorForTypedData).toHaveBeenCalledWith({contractAddress:e.data.domain.verifyingContract.toLowerCase(),schemaHash:expect.any(String),chainId:e.chainId}),expect(l.getProxyImplementationAddress).toHaveBeenCalledWith({proxyAddress:e.data.domain.verifyingContract.toLowerCase(),chainId:e.chainId,challenge:e.challenge,calldata:"0x"}),expect(c.loadCertificate).not.toHaveBeenCalled()}),it("should return gated signing context when getGatedDescriptorForTypedData succeeds",async()=>{vi.spyOn(a,"getGatedDescriptorForTypedData").mockResolvedValue(s({signedDescriptor:d}));const o=await t.load(e);expect(o).toHaveLength(1),expect(o[0]).toMatchObject({type:r.GATED_SIGNING,payload:d,certificate:h}),expect(a.getGatedDescriptorForTypedData).toHaveBeenCalledWith({contractAddress:e.data.domain.verifyingContract.toLowerCase(),schemaHash:expect.any(String),chainId:e.chainId}),expect(c.loadCertificate).toHaveBeenCalledWith({keyId:f.CalGatedSigning,keyUsage:m.GatedSigning,targetDevice:e.deviceModelId})}),it("should use zero address when domain.verifyingContract is missing",async()=>{vi.spyOn(a,"getGatedDescriptorForTypedData").mockResolvedValue(s({signedDescriptor:d})),await t.load({data:{types:e.data.types},chainId:e.chainId,deviceModelId:e.deviceModelId,challenge:e.challenge}),expect(a.getGatedDescriptorForTypedData).toHaveBeenCalledWith(expect.objectContaining({contractAddress:"0x0000000000000000000000000000000000000000"}))}),it("should request certificate for correct device model",async()=>{vi.spyOn(a,"getGatedDescriptorForTypedData").mockResolvedValue(s({signedDescriptor:d})),await t.load({...e,deviceModelId:i.FLEX}),expect(c.loadCertificate).toHaveBeenCalledWith({keyId:f.CalGatedSigning,keyUsage:m.GatedSigning,targetDevice:i.FLEX})}),it("should reject when certificate loading fails",async()=>{const o=new Error("Certificate loading failed");vi.spyOn(a,"getGatedDescriptorForTypedData").mockResolvedValue(s({signedDescriptor:d})),vi.spyOn(c,"loadCertificate").mockRejectedValue(o),await expect(t.load(e)).rejects.toThrow(o)}),it("should return PROXY_INFO and GATED_SIGNING when verifying contract is proxy and gated descriptor exists for implementation",async()=>{const o="0xabcdef1234567890abcdef1234567890abcdef12",p="0xproxy-descriptor";vi.spyOn(a,"getGatedDescriptorForTypedData").mockResolvedValueOnce(g(new Error("No gated descriptor"))).mockResolvedValueOnce(s({signedDescriptor:d})),vi.spyOn(l,"getProxyImplementationAddress").mockResolvedValue(s({implementationAddress:o,signedDescriptor:p,keyId:"domain-metadata",keyUsage:"trusted-name"}));const y=await t.load(e);expect(y).toHaveLength(2),expect(y[0]).toMatchObject({type:r.PROXY_INFO,payload:p}),expect(y[1]).toMatchObject({type:r.GATED_SIGNING,payload:d}),expect(a.getGatedDescriptorForTypedData).toHaveBeenCalledTimes(2),expect(a.getGatedDescriptorForTypedData).toHaveBeenNthCalledWith(1,{contractAddress:e.data.domain.verifyingContract.toLowerCase(),schemaHash:expect.any(String),chainId:e.chainId}),expect(a.getGatedDescriptorForTypedData).toHaveBeenNthCalledWith(2,{contractAddress:o.toLowerCase(),schemaHash:expect.any(String),chainId:e.chainId})})})});
|
|
2
|
+
//# sourceMappingURL=GatedSigningTypedDataContextLoader.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/gated-signing/domain/GatedSigningTypedDataContextLoader.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type GatedDescriptorDataSource } from \"@/gated-signing/data/GatedDescriptorDataSource\";\nimport {\n type GatedSigningTypedDataContextInput,\n GatedSigningTypedDataContextLoader,\n} from \"@/gated-signing/domain/GatedSigningTypedDataContextLoader\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\ndescribe(\"GatedSigningTypedDataContextLoader\", () => {\n const mockGatedDescriptorDataSource: GatedDescriptorDataSource = {\n getGatedDescriptor: vi.fn(),\n getGatedDescriptorForTypedData: vi.fn(),\n };\n\n const mockCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n\n const mockProxyDataSource: ProxyDataSource = {\n getProxyImplementationAddress: vi.fn(),\n };\n\n const loader = new GatedSigningTypedDataContextLoader(\n mockGatedDescriptorDataSource,\n mockCertificateLoader,\n mockProxyDataSource,\n );\n\n const mockCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n const SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.GATED_SIGNING,\n ];\n\n const validInput: GatedSigningTypedDataContextInput = {\n data: {\n types: {\n EIP712Domain: [\n { name: \"name\", type: \"string\" },\n { name: \"chainId\", type: \"uint256\" },\n ],\n Mail: [{ name: \"subject\", type: \"string\" }],\n },\n domain: {\n verifyingContract: \"0x1111111254fb6c44bac0bed2854e76f90643097d\",\n },\n },\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n challenge: \"test-challenge\",\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n mockCertificate,\n );\n });\n\n describe(\"canHandle\", () => {\n it(\"should return true for valid typed data input\", () => {\n expect(loader.canHandle(validInput, SUPPORTED_TYPES)).toBe(true);\n });\n\n it(\"should return false when expected types do not include GATED_SIGNING\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.DYNAMIC_NETWORK]),\n ).toBe(false);\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it(\"should return false for transaction-style input (selector, to)\", () => {\n const transactionInput = {\n to: \"0x1111111254fb6c44bac0bed2854e76f90643097d\",\n selector: \"0xa1251d75\",\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n };\n expect(loader.canHandle(transactionInput, SUPPORTED_TYPES)).toBe(false);\n });\n\n it(\"should return false when data is missing\", () => {\n expect(\n loader.canHandle(\n { chainId: 1, deviceModelId: DeviceModelId.STAX },\n SUPPORTED_TYPES,\n ),\n ).toBe(false);\n });\n\n it(\"should return false when data.types is not a valid schema\", () => {\n expect(\n loader.canHandle(\n {\n data: { types: \"not-an-object\" },\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n challenge: validInput.challenge,\n },\n SUPPORTED_TYPES,\n ),\n ).toBe(false);\n expect(\n loader.canHandle(\n {\n data: { types: {} },\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n challenge: validInput.challenge,\n },\n SUPPORTED_TYPES,\n ),\n ).toBe(true);\n });\n\n it(\"should return false when chainId or deviceModelId is missing\", () => {\n expect(\n loader.canHandle(\n {\n data: validInput.data,\n deviceModelId: DeviceModelId.STAX,\n challenge: validInput.challenge,\n },\n SUPPORTED_TYPES,\n ),\n ).toBe(false);\n expect(\n loader.canHandle(\n {\n data: validInput.data,\n chainId: 1,\n challenge: validInput.challenge,\n },\n SUPPORTED_TYPES,\n ),\n ).toBe(false);\n });\n\n it(\"should return false when challenge is missing\", () => {\n expect(\n loader.canHandle(\n {\n data: validInput.data,\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n },\n SUPPORTED_TYPES,\n ),\n ).toBe(false);\n });\n });\n\n describe(\"load\", () => {\n const signedDescriptor =\n \"010122020101222a30783131313131313235346662366334346261633062656432383534653736663930363433303937642308000000000000000140086131323531643735150100\";\n\n it(\"should return error context when getGatedDescriptorForTypedData returns Left and proxy resolution fails\", async () => {\n const error = new Error(\"No gated descriptor for schema hash\");\n vi.spyOn(\n mockGatedDescriptorDataSource,\n \"getGatedDescriptorForTypedData\",\n ).mockResolvedValue(Left(error));\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(Left(new Error(\"Not a proxy\")));\n\n const result = await loader.load(validInput);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error,\n },\n ]);\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptorForTypedData,\n ).toHaveBeenCalledWith({\n contractAddress:\n validInput.data.domain!.verifyingContract!.toLowerCase(),\n schemaHash: expect.any(String),\n chainId: validInput.chainId,\n });\n expect(\n mockProxyDataSource.getProxyImplementationAddress,\n ).toHaveBeenCalledWith({\n proxyAddress: validInput.data.domain!.verifyingContract!.toLowerCase(),\n chainId: validInput.chainId,\n challenge: validInput.challenge,\n calldata: \"0x\",\n });\n expect(mockCertificateLoader.loadCertificate).not.toHaveBeenCalled();\n });\n\n it(\"should return gated signing context when getGatedDescriptorForTypedData succeeds\", async () => {\n vi.spyOn(\n mockGatedDescriptorDataSource,\n \"getGatedDescriptorForTypedData\",\n ).mockResolvedValue(Right({ signedDescriptor }));\n\n const result = await loader.load(validInput);\n\n expect(result).toHaveLength(1);\n expect(result[0]).toMatchObject({\n type: ClearSignContextType.GATED_SIGNING,\n payload: signedDescriptor,\n certificate: mockCertificate,\n });\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptorForTypedData,\n ).toHaveBeenCalledWith({\n contractAddress:\n validInput.data.domain!.verifyingContract!.toLowerCase(),\n schemaHash: expect.any(String),\n chainId: validInput.chainId,\n });\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: KeyId.CalGatedSigning,\n keyUsage: KeyUsage.GatedSigning,\n targetDevice: validInput.deviceModelId,\n });\n });\n\n it(\"should use zero address when domain.verifyingContract is missing\", async () => {\n vi.spyOn(\n mockGatedDescriptorDataSource,\n \"getGatedDescriptorForTypedData\",\n ).mockResolvedValue(Right({ signedDescriptor }));\n\n await loader.load({\n data: { types: validInput.data.types },\n chainId: validInput.chainId,\n deviceModelId: validInput.deviceModelId,\n challenge: validInput.challenge,\n });\n\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptorForTypedData,\n ).toHaveBeenCalledWith(\n expect.objectContaining({\n contractAddress: \"0x0000000000000000000000000000000000000000\",\n }),\n );\n });\n\n it(\"should request certificate for correct device model\", async () => {\n vi.spyOn(\n mockGatedDescriptorDataSource,\n \"getGatedDescriptorForTypedData\",\n ).mockResolvedValue(Right({ signedDescriptor }));\n\n await loader.load({\n ...validInput,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: KeyId.CalGatedSigning,\n keyUsage: KeyUsage.GatedSigning,\n targetDevice: DeviceModelId.FLEX,\n });\n });\n\n it(\"should reject when certificate loading fails\", async () => {\n const certificateError = new Error(\"Certificate loading failed\");\n vi.spyOn(\n mockGatedDescriptorDataSource,\n \"getGatedDescriptorForTypedData\",\n ).mockResolvedValue(Right({ signedDescriptor }));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockRejectedValue(\n certificateError,\n );\n\n await expect(loader.load(validInput)).rejects.toThrow(certificateError);\n });\n\n it(\"should return PROXY_INFO and GATED_SIGNING when verifying contract is proxy and gated descriptor exists for implementation\", async () => {\n const implementationAddress =\n \"0xabcdef1234567890abcdef1234567890abcdef12\";\n const proxySignedDescriptor = \"0xproxy-descriptor\";\n vi.spyOn(mockGatedDescriptorDataSource, \"getGatedDescriptorForTypedData\")\n .mockResolvedValueOnce(Left(new Error(\"No gated descriptor\")))\n .mockResolvedValueOnce(Right({ signedDescriptor }));\n vi.spyOn(\n mockProxyDataSource,\n \"getProxyImplementationAddress\",\n ).mockResolvedValue(\n Right({\n implementationAddress,\n signedDescriptor: proxySignedDescriptor,\n keyId: \"domain-metadata\",\n keyUsage: \"trusted-name\",\n }),\n );\n\n const result = await loader.load(validInput);\n\n expect(result).toHaveLength(2);\n expect(result[0]).toMatchObject({\n type: ClearSignContextType.PROXY_INFO,\n payload: proxySignedDescriptor,\n });\n expect(result[1]).toMatchObject({\n type: ClearSignContextType.GATED_SIGNING,\n payload: signedDescriptor,\n });\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptorForTypedData,\n ).toHaveBeenCalledTimes(2);\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptorForTypedData,\n ).toHaveBeenNthCalledWith(1, {\n contractAddress:\n validInput.data.domain!.verifyingContract!.toLowerCase(),\n schemaHash: expect.any(String),\n chainId: validInput.chainId,\n });\n expect(\n mockGatedDescriptorDataSource.getGatedDescriptorForTypedData,\n ).toHaveBeenNthCalledWith(2, {\n contractAddress: implementationAddress.toLowerCase(),\n schemaHash: expect.any(String),\n chainId: validInput.chainId,\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OAEE,sCAAAC,MACK,4DAEP,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAGzB,OAAS,wBAAAC,MAA4B,kCAErC,SAAS,qCAAsC,IAAM,CACnD,MAAMC,EAA2D,CAC/D,mBAAoB,GAAG,GAAG,EAC1B,+BAAgC,GAAG,GAAG,CACxC,EAEMC,EAA8C,CAClD,gBAAiB,GAAG,GAAG,CACzB,EAEMC,EAAuC,CAC3C,8BAA+B,GAAG,GAAG,CACvC,EAEMC,EAAS,IAAIP,EACjBI,EACAC,EACAC,CACF,EAEME,EAAkC,CACtC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAC5C,EAEMC,EAA0C,CAC9CN,EAAqB,aACvB,EAEMO,EAAgD,CACpD,KAAM,CACJ,MAAO,CACL,aAAc,CACZ,CAAE,KAAM,OAAQ,KAAM,QAAS,EAC/B,CAAE,KAAM,UAAW,KAAM,SAAU,CACrC,EACA,KAAM,CAAC,CAAE,KAAM,UAAW,KAAM,QAAS,CAAC,CAC5C,EACA,OAAQ,CACN,kBAAmB,4CACrB,CACF,EACA,QAAS,EACT,cAAeb,EAAc,KAC7B,UAAW,gBACb,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjB,GAAG,MAAMQ,EAAuB,iBAAiB,EAAE,kBACjDG,CACF,CACF,CAAC,EAED,SAAS,YAAa,IAAM,CAC1B,GAAG,gDAAiD,IAAM,CACxD,OAAOD,EAAO,UAAUG,EAAYD,CAAe,CAAC,EAAE,KAAK,EAAI,CACjE,CAAC,EA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MAAM,OAAOV,EAAO,KAAKG,CAAU,CAAC,EAAE,QAAQ,QAAQO,CAAgB,CACxE,CAAC,EAED,GAAG,6HAA8H,SAAY,CAC3I,MAAMC,EACJ,6CACIC,EAAwB,qBAC9B,GAAG,MAAMf,EAA+B,gCAAgC,EACrE,sBAAsBN,EAAK,IAAI,MAAM,qBAAqB,CAAC,CAAC,EAC5D,sBAAsBC,EAAM,CAAE,iBAAAe,CAAiB,CAAC,CAAC,EACpD,GAAG,MACDR,EACA,+BACF,EAAE,kBACAP,EAAM,CACJ,sBAAAmB,EACA,iBAAkBC,EAClB,MAAO,kBACP,SAAU,cACZ,CAAC,CACH,EAEA,MAAMH,EAAS,MAAMT,EAAO,KAAKG,CAAU,EAE3C,OAAOM,CAAM,EAAE,aAAa,CAAC,EAC7B,OAAOA,EAAO,CAAC,CAAC,EAAE,cAAc,CAC9B,KAAMb,EAAqB,WAC3B,QAASgB,CACX,CAAC,EACD,OAAOH,EAAO,CAAC,CAAC,EAAE,cAAc,CAC9B,KAAMb,EAAqB,cAC3B,QAASW,CACX,CAAC,EACD,OACEV,EAA8B,8BAChC,EAAE,sBAAsB,CAAC,EACzB,OACEA,EAA8B,8BAChC,EAAE,wBAAwB,EAAG,CAC3B,gBACEM,EAAW,KAAK,OAAQ,kBAAmB,YAAY,EACzD,WAAY,OAAO,IAAI,MAAM,EAC7B,QAASA,EAAW,OACtB,CAAC,EACD,OACEN,EAA8B,8BAChC,EAAE,wBAAwB,EAAG,CAC3B,gBAAiBc,EAAsB,YAAY,EACnD,WAAY,OAAO,IAAI,MAAM,EAC7B,QAASR,EAAW,OACtB,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["DeviceModelId", "Left", "Right", "GatedSigningTypedDataContextLoader", "KeyId", "KeyUsage", "ClearSignContextType", "mockGatedDescriptorDataSource", "mockCertificateLoader", "mockProxyDataSource", "loader", "mockCertificate", "SUPPORTED_TYPES", "validInput", "input", "_description", "transactionInput", "signedDescriptor", "error", "result", "certificateError", "implementationAddress", "proxySignedDescriptor"]
|
|
7
|
+
}
|
package/lib/esm/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./calldata/data/CalldataDescriptorDataSource";export*from"./calldata/data/HttpCalldataDescriptorDataSource";export*from"./calldata/domain/CalldataContextLoader";export*from"./config/model/ContextModuleConfig";export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./dynamic-network/data/DynamicNetworkDataSource";export*from"./dynamic-network/data/HttpDynamicNetworkDataSource";export*from"./dynamic-network/domain/DynamicNetworkContextLoader";export*from"./dynamic-network/model/DynamicNetworkConfiguration";export*from"./external-plugin/data/ExternalPluginDataSource";export*from"./external-plugin/data/HttpExternalPluginDataSource";export*from"./external-plugin/domain/ExternalPluginContextLoader";export*from"./nft/data/HttpNftDataSource";export*from"./nft/data/NftDataSource";export*from"./nft/domain/NftContextFieldLoader";export*from"./nft/domain/NftContextLoader";export*from"./pki/data/HttpPkiCertificateDataSource";export*from"./pki/data/PkiCertificateDataSource";export*from"./pki/domain/DefaultPkiCertificateLoader";export*from"./pki/domain/PkiCertificateLoader";export*from"./pki/model/KeyId";export*from"./pki/model/KeyUsage";export*from"./pki/model/PkiCertificate";export*from"./pki/model/PkiCertificateInfo";export*from"./proxy/data/HttpProxyDataSource";export*from"./proxy/data/HttpSafeProxyDataSource";export*from"./proxy/data/ProxyDataSource";export*from"./proxy/domain/ProxyContextFieldLoader";export*from"./shared/domain/ContextFieldLoader";export*from"./shared/domain/ContextLoader";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/SolanaContextTypes";export*from"./shared/model/TransactionSubset";export*from"./shared/model/TypedDataClearSignContext";export*from"./shared/model/TypedDataContext";export*from"./solana/data/HttpSolanaOwnerInfoDataSource";export*from"./solana/data/SolanaDataSource";export*from"./solana/domain/DefaultSolanaContextLoader";export*from"./solana/domain/SolanaContextLoader";export*from"./solana/domain/solanaContextTypes";export*from"./token/data/HttpTokenDataSource";export*from"./token/data/TokenDataSource";export*from"./token/domain/TokenContextFieldLoader";export*from"./token/domain/TokenContextLoader";export*from"./trusted-name/data/HttpTrustedNameDataSource";export*from"./trusted-name/data/TrustedNameDataSource";export*from"./trusted-name/domain/TrustedNameContextFieldLoader";export*from"./trusted-name/domain/TrustedNameContextLoader";export*from"./typed-data/data/HttpTypedDataDataSource";export*from"./typed-data/data/TypedDataDataSource";export*from"./typed-data/domain/DefaultTypedDataContextLoader";export*from"./typed-data/domain/TypedDataContextLoader";export*from"./uniswap/data/AbiDecoderDataSource";export*from"./uniswap/data/CommandDecoderDataSource";export*from"./uniswap/data/DefaultCommandDecoderDataSource";export*from"./uniswap/data/EthersAbiDecoderDataSource";export*from"./uniswap/domain/UniswapContextLoader";
|
|
1
|
+
export*from"./calldata/data/CalldataDescriptorDataSource";export*from"./calldata/data/HttpCalldataDescriptorDataSource";export*from"./calldata/domain/CalldataContextLoader";export*from"./config/model/ContextModuleConfig";export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./dynamic-network/data/DynamicNetworkDataSource";export*from"./dynamic-network/data/HttpDynamicNetworkDataSource";export*from"./dynamic-network/domain/DynamicNetworkContextLoader";export*from"./dynamic-network/model/DynamicNetworkConfiguration";export*from"./external-plugin/data/ExternalPluginDataSource";export*from"./external-plugin/data/HttpExternalPluginDataSource";export*from"./external-plugin/domain/ExternalPluginContextLoader";export*from"./gated-signing/data/GatedDescriptorDataSource";export*from"./gated-signing/data/HttpGatedDescriptorDataSource";export*from"./gated-signing/domain/GatedSigningContextLoader";export*from"./gated-signing/domain/GatedSigningTypedDataContextLoader";export*from"./nft/data/HttpNftDataSource";export*from"./nft/data/NftDataSource";export*from"./nft/domain/NftContextFieldLoader";export*from"./nft/domain/NftContextLoader";export*from"./pki/data/HttpPkiCertificateDataSource";export*from"./pki/data/PkiCertificateDataSource";export*from"./pki/domain/DefaultPkiCertificateLoader";export*from"./pki/domain/PkiCertificateLoader";export*from"./pki/model/KeyId";export*from"./pki/model/KeyUsage";export*from"./pki/model/PkiCertificate";export*from"./pki/model/PkiCertificateInfo";export*from"./proxy/data/HttpProxyDataSource";export*from"./proxy/data/HttpSafeProxyDataSource";export*from"./proxy/data/ProxyDataSource";export*from"./proxy/domain/ProxyContextFieldLoader";export*from"./shared/domain/ContextFieldLoader";export*from"./shared/domain/ContextLoader";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/SolanaContextTypes";export*from"./shared/model/TransactionSubset";export*from"./shared/model/TypedDataClearSignContext";export*from"./shared/model/TypedDataContext";export*from"./solana/data/HttpSolanaOwnerInfoDataSource";export*from"./solana/data/SolanaDataSource";export*from"./solana/domain/DefaultSolanaContextLoader";export*from"./solana/domain/SolanaContextLoader";export*from"./solana/domain/solanaContextTypes";export*from"./token/data/HttpTokenDataSource";export*from"./token/data/TokenDataSource";export*from"./token/domain/TokenContextFieldLoader";export*from"./token/domain/TokenContextLoader";export*from"./trusted-name/data/HttpTrustedNameDataSource";export*from"./trusted-name/data/TrustedNameDataSource";export*from"./trusted-name/domain/TrustedNameContextFieldLoader";export*from"./trusted-name/domain/TrustedNameContextLoader";export*from"./typed-data/data/HttpTypedDataDataSource";export*from"./typed-data/data/TypedDataDataSource";export*from"./typed-data/domain/DefaultTypedDataContextLoader";export*from"./typed-data/domain/TypedDataContextLoader";export*from"./typed-data/utils/getSchemaHash";export*from"./uniswap/data/AbiDecoderDataSource";export*from"./uniswap/data/CommandDecoderDataSource";export*from"./uniswap/data/DefaultCommandDecoderDataSource";export*from"./uniswap/data/EthersAbiDecoderDataSource";export*from"./uniswap/domain/UniswapContextLoader";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/src/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./calldata/data/CalldataDescriptorDataSource\";\nexport * from \"./calldata/data/HttpCalldataDescriptorDataSource\";\nexport * from \"./calldata/domain/CalldataContextLoader\";\nexport * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./dynamic-network/data/DynamicNetworkDataSource\";\nexport * from \"./dynamic-network/data/HttpDynamicNetworkDataSource\";\nexport * from \"./dynamic-network/domain/DynamicNetworkContextLoader\";\nexport * from \"./dynamic-network/model/DynamicNetworkConfiguration\";\nexport * from \"./external-plugin/data/ExternalPluginDataSource\";\nexport * from \"./external-plugin/data/HttpExternalPluginDataSource\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/data/HttpNftDataSource\";\nexport * from \"./nft/data/NftDataSource\";\nexport * from \"./nft/domain/NftContextFieldLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/data/HttpPkiCertificateDataSource\";\nexport * from \"./pki/data/PkiCertificateDataSource\";\nexport * from \"./pki/domain/DefaultPkiCertificateLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./proxy/data/HttpProxyDataSource\";\nexport * from \"./proxy/data/HttpSafeProxyDataSource\";\nexport * from \"./proxy/data/ProxyDataSource\";\nexport * from \"./proxy/domain/ProxyContextFieldLoader\";\nexport * from \"./shared/domain/ContextFieldLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/SolanaContextTypes\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./solana/data/HttpSolanaOwnerInfoDataSource\";\nexport * from \"./solana/data/SolanaDataSource\";\nexport * from \"./solana/domain/DefaultSolanaContextLoader\";\nexport * from \"./solana/domain/SolanaContextLoader\";\nexport * from \"./solana/domain/solanaContextTypes\";\nexport * from \"./token/data/HttpTokenDataSource\";\nexport * from \"./token/data/TokenDataSource\";\nexport * from \"./token/domain/TokenContextFieldLoader\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./trusted-name/data/TrustedNameDataSource\";\nexport * from \"./trusted-name/domain/TrustedNameContextFieldLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./typed-data/data/HttpTypedDataDataSource\";\nexport * from \"./typed-data/data/TypedDataDataSource\";\nexport * from \"./typed-data/domain/DefaultTypedDataContextLoader\";\nexport * from \"./typed-data/domain/TypedDataContextLoader\";\nexport * from \"./uniswap/data/AbiDecoderDataSource\";\nexport * from \"./uniswap/data/CommandDecoderDataSource\";\nexport * from \"./uniswap/data/DefaultCommandDecoderDataSource\";\nexport * from \"./uniswap/data/EthersAbiDecoderDataSource\";\nexport * from \"./uniswap/domain/UniswapContextLoader\";\n"],
|
|
5
|
-
"mappings": "AAAA,WAAc,+CACd,WAAc,mDACd,WAAc,0CACd,WAAc,qCACd,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,sDACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,+BACd,WAAc,2BACd,WAAc,qCACd,WAAc,gCACd,WAAc,0CACd,WAAc,sCACd,WAAc,2CACd,WAAc,oCACd,WAAc,oBACd,WAAc,uBACd,WAAc,6BACd,WAAc,iCACd,WAAc,mCACd,WAAc,uCACd,WAAc,+BACd,WAAc,yCACd,WAAc,qCACd,WAAc,gCACd,WAAc,kCACd,WAAc,6BACd,WAAc,oCACd,WAAc,mCACd,WAAc,2CACd,WAAc,kCACd,WAAc,8CACd,WAAc,iCACd,WAAc,6CACd,WAAc,sCACd,WAAc,qCACd,WAAc,mCACd,WAAc,+BACd,WAAc,yCACd,WAAc,oCACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,iDACd,WAAc,4CACd,WAAc,wCACd,WAAc,oDACd,WAAc,6CACd,WAAc,sCACd,WAAc,0CACd,WAAc,iDACd,WAAc,4CACd,WAAc",
|
|
4
|
+
"sourcesContent": ["export * from \"./calldata/data/CalldataDescriptorDataSource\";\nexport * from \"./calldata/data/HttpCalldataDescriptorDataSource\";\nexport * from \"./calldata/domain/CalldataContextLoader\";\nexport * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./dynamic-network/data/DynamicNetworkDataSource\";\nexport * from \"./dynamic-network/data/HttpDynamicNetworkDataSource\";\nexport * from \"./dynamic-network/domain/DynamicNetworkContextLoader\";\nexport * from \"./dynamic-network/model/DynamicNetworkConfiguration\";\nexport * from \"./external-plugin/data/ExternalPluginDataSource\";\nexport * from \"./external-plugin/data/HttpExternalPluginDataSource\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./gated-signing/data/GatedDescriptorDataSource\";\nexport * from \"./gated-signing/data/HttpGatedDescriptorDataSource\";\nexport * from \"./gated-signing/domain/GatedSigningContextLoader\";\nexport * from \"./gated-signing/domain/GatedSigningTypedDataContextLoader\";\nexport * from \"./nft/data/HttpNftDataSource\";\nexport * from \"./nft/data/NftDataSource\";\nexport * from \"./nft/domain/NftContextFieldLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/data/HttpPkiCertificateDataSource\";\nexport * from \"./pki/data/PkiCertificateDataSource\";\nexport * from \"./pki/domain/DefaultPkiCertificateLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./proxy/data/HttpProxyDataSource\";\nexport * from \"./proxy/data/HttpSafeProxyDataSource\";\nexport * from \"./proxy/data/ProxyDataSource\";\nexport * from \"./proxy/domain/ProxyContextFieldLoader\";\nexport * from \"./shared/domain/ContextFieldLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/SolanaContextTypes\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./solana/data/HttpSolanaOwnerInfoDataSource\";\nexport * from \"./solana/data/SolanaDataSource\";\nexport * from \"./solana/domain/DefaultSolanaContextLoader\";\nexport * from \"./solana/domain/SolanaContextLoader\";\nexport * from \"./solana/domain/solanaContextTypes\";\nexport * from \"./token/data/HttpTokenDataSource\";\nexport * from \"./token/data/TokenDataSource\";\nexport * from \"./token/domain/TokenContextFieldLoader\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./trusted-name/data/TrustedNameDataSource\";\nexport * from \"./trusted-name/domain/TrustedNameContextFieldLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./typed-data/data/HttpTypedDataDataSource\";\nexport * from \"./typed-data/data/TypedDataDataSource\";\nexport * from \"./typed-data/domain/DefaultTypedDataContextLoader\";\nexport * from \"./typed-data/domain/TypedDataContextLoader\";\nexport * from \"./typed-data/utils/getSchemaHash\";\nexport * from \"./uniswap/data/AbiDecoderDataSource\";\nexport * from \"./uniswap/data/CommandDecoderDataSource\";\nexport * from \"./uniswap/data/DefaultCommandDecoderDataSource\";\nexport * from \"./uniswap/data/EthersAbiDecoderDataSource\";\nexport * from \"./uniswap/domain/UniswapContextLoader\";\n"],
|
|
5
|
+
"mappings": "AAAA,WAAc,+CACd,WAAc,mDACd,WAAc,0CACd,WAAc,qCACd,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,sDACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,iDACd,WAAc,qDACd,WAAc,mDACd,WAAc,4DACd,WAAc,+BACd,WAAc,2BACd,WAAc,qCACd,WAAc,gCACd,WAAc,0CACd,WAAc,sCACd,WAAc,2CACd,WAAc,oCACd,WAAc,oBACd,WAAc,uBACd,WAAc,6BACd,WAAc,iCACd,WAAc,mCACd,WAAc,uCACd,WAAc,+BACd,WAAc,yCACd,WAAc,qCACd,WAAc,gCACd,WAAc,kCACd,WAAc,6BACd,WAAc,oCACd,WAAc,mCACd,WAAc,2CACd,WAAc,kCACd,WAAc,8CACd,WAAc,iCACd,WAAc,6CACd,WAAc,sCACd,WAAc,qCACd,WAAc,mCACd,WAAc,+BACd,WAAc,yCACd,WAAc,oCACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,iDACd,WAAc,4CACd,WAAc,wCACd,WAAc,oDACd,WAAc,6CACd,WAAc,mCACd,WAAc,sCACd,WAAc,0CACd,WAAc,iDACd,WAAc,4CACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var e=(a=>(a.Test="test",a.PersoV2="persov2",a.LedgerRootV3="ledger_root_v3",a.PluginSelectorKey="plugin_selector_key",a.NftMetadataKey="nft_metadata_key",a.PartnerMetadataKey="partner_metadata_key",a.Erc20MetadataKey="erc20_metadata_key",a.DomainMetadataKey="domain_metadata_key",a.CalCalldataKey="cal_calldata_key",a.CalTrustedNameKey="cal_trusted_name_key",a.CalNetwork="cal_network",a.CalGatedSigning="cal_gated_signing",a.SwapTemplateKey="swap_template_key",a))(e||{});export{e as KeyId};
|
|
2
2
|
//# sourceMappingURL=KeyId.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/pki/model/KeyId.ts"],
|
|
4
|
-
"sourcesContent": ["export enum KeyId {\n Test = \"test\",\n PersoV2 = \"persov2\",\n LedgerRootV3 = \"ledger_root_v3\",\n PluginSelectorKey = \"plugin_selector_key\",\n NftMetadataKey = \"nft_metadata_key\",\n PartnerMetadataKey = \"partner_metadata_key\",\n Erc20MetadataKey = \"erc20_metadata_key\",\n DomainMetadataKey = \"domain_metadata_key\",\n CalCalldataKey = \"cal_calldata_key\",\n CalTrustedNameKey = \"cal_trusted_name_key\",\n CalNetwork = \"cal_network\",\n}\n"],
|
|
5
|
-
"mappings": "AAAO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,aAAe,iBACfA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,mBACjBA,EAAA,mBAAqB,uBACrBA,EAAA,iBAAmB,qBACnBA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,mBACjBA,EAAA,kBAAoB,uBACpBA,EAAA,WAAa,
|
|
4
|
+
"sourcesContent": ["export enum KeyId {\n Test = \"test\",\n PersoV2 = \"persov2\",\n LedgerRootV3 = \"ledger_root_v3\",\n PluginSelectorKey = \"plugin_selector_key\",\n NftMetadataKey = \"nft_metadata_key\",\n PartnerMetadataKey = \"partner_metadata_key\",\n Erc20MetadataKey = \"erc20_metadata_key\",\n DomainMetadataKey = \"domain_metadata_key\",\n CalCalldataKey = \"cal_calldata_key\",\n CalTrustedNameKey = \"cal_trusted_name_key\",\n CalNetwork = \"cal_network\",\n CalGatedSigning = \"cal_gated_signing\",\n SwapTemplateKey = \"swap_template_key\",\n}\n"],
|
|
5
|
+
"mappings": "AAAO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,aAAe,iBACfA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,mBACjBA,EAAA,mBAAqB,uBACrBA,EAAA,iBAAmB,qBACnBA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,mBACjBA,EAAA,kBAAoB,uBACpBA,EAAA,WAAa,cACbA,EAAA,gBAAkB,oBAClBA,EAAA,gBAAkB,oBAbRA,OAAA",
|
|
6
6
|
"names": ["KeyId"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=(t=>(t.GenuineCheck="genuine_check",t.ExchangePayload="exchange_payload",t.NftMeta="nft_meta",t.TrustedName="trusted_name",t.BackupProvider="backup_provider",t.ProtectOrchestrator="protect_orchestrator",t.PluginMeta="plugin_meta",t.CoinMeta="coin_meta",t.SeedIdAuth="seed_id_auth",t.TxSimulationSigner="tx_simu_signer",t.Calldata="calldata",t.Network="network",t.LESMultisig="les_multisig",t.GatedSigning="gated_signing",t.SwapTemplate="swap_template",t))(i||{});export{i as KeyUsage};
|
|
2
2
|
//# sourceMappingURL=KeyUsage.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/pki/model/KeyUsage.ts"],
|
|
4
|
-
"sourcesContent": ["export enum KeyUsage {\n GenuineCheck = \"genuine_check\",\n ExchangePayload = \"exchange_payload\",\n NftMeta = \"nft_meta\",\n TrustedName = \"trusted_name\",\n BackupProvider = \"backup_provider\",\n ProtectOrchestrator = \"protect_orchestrator\",\n PluginMeta = \"plugin_meta\",\n CoinMeta = \"coin_meta\",\n SeedIdAuth = \"seed_id_auth\",\n TxSimulationSigner = \"tx_simu_signer\",\n Calldata = \"calldata\",\n Network = \"network\",\n LESMultisig = \"les_multisig\",\n}\n"],
|
|
5
|
-
"mappings": "AAAO,IAAKA,OACVA,EAAA,aAAe,gBACfA,EAAA,gBAAkB,mBAClBA,EAAA,QAAU,WACVA,EAAA,YAAc,eACdA,EAAA,eAAiB,kBACjBA,EAAA,oBAAsB,uBACtBA,EAAA,WAAa,cACbA,EAAA,SAAW,YACXA,EAAA,WAAa,eACbA,EAAA,mBAAqB,iBACrBA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,YAAc,
|
|
4
|
+
"sourcesContent": ["export enum KeyUsage {\n GenuineCheck = \"genuine_check\",\n ExchangePayload = \"exchange_payload\",\n NftMeta = \"nft_meta\",\n TrustedName = \"trusted_name\",\n BackupProvider = \"backup_provider\",\n ProtectOrchestrator = \"protect_orchestrator\",\n PluginMeta = \"plugin_meta\",\n CoinMeta = \"coin_meta\",\n SeedIdAuth = \"seed_id_auth\",\n TxSimulationSigner = \"tx_simu_signer\",\n Calldata = \"calldata\",\n Network = \"network\",\n LESMultisig = \"les_multisig\",\n GatedSigning = \"gated_signing\",\n SwapTemplate = \"swap_template\",\n}\n"],
|
|
5
|
+
"mappings": "AAAO,IAAKA,OACVA,EAAA,aAAe,gBACfA,EAAA,gBAAkB,mBAClBA,EAAA,QAAU,WACVA,EAAA,YAAc,eACdA,EAAA,eAAiB,kBACjBA,EAAA,oBAAsB,uBACtBA,EAAA,WAAa,cACbA,EAAA,SAAW,YACXA,EAAA,WAAa,eACbA,EAAA,mBAAqB,iBACrBA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,YAAc,eACdA,EAAA,aAAe,gBACfA,EAAA,aAAe,gBAfLA,OAAA",
|
|
6
6
|
"names": ["KeyUsage"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var n=(e=>(e.TOKEN="token",e.NFT="nft",e.TRUSTED_NAME="trustedName",e.PLUGIN="plugin",e.EXTERNAL_PLUGIN="externalPlugin",e.TRANSACTION_INFO="transactionInfo",e.PROXY_INFO="proxyInfo",e.ENUM="enum",e.TRANSACTION_FIELD_DESCRIPTION="transactionFieldDescription",e.TRANSACTION_CHECK="transactionCheck",e.DYNAMIC_NETWORK="dynamicNetwork",e.DYNAMIC_NETWORK_ICON="dynamicNetworkIcon",e.ERROR="error",e.SAFE="safe",e.SIGNER="signer",e))(n||{}),r=(t=>(t.TOKEN="token",t.NFT="nft",t.TRUSTED_NAME="trustedName",t.ENUM="enum",t.CALLDATA="calldata",t))(r||{});export{r as ClearSignContextReferenceType,n as ClearSignContextType};
|
|
1
|
+
var n=(e=>(e.TOKEN="token",e.NFT="nft",e.TRUSTED_NAME="trustedName",e.PLUGIN="plugin",e.EXTERNAL_PLUGIN="externalPlugin",e.TRANSACTION_INFO="transactionInfo",e.PROXY_INFO="proxyInfo",e.ENUM="enum",e.TRANSACTION_FIELD_DESCRIPTION="transactionFieldDescription",e.TRANSACTION_CHECK="transactionCheck",e.DYNAMIC_NETWORK="dynamicNetwork",e.DYNAMIC_NETWORK_ICON="dynamicNetworkIcon",e.ERROR="error",e.SAFE="safe",e.SIGNER="signer",e.GATED_SIGNING="gatedSigning",e))(n||{}),r=(t=>(t.TOKEN="token",t.NFT="nft",t.TRUSTED_NAME="trustedName",t.ENUM="enum",t.CALLDATA="calldata",t))(r||{});export{r as ClearSignContextReferenceType,n as ClearSignContextType};
|
|
2
2
|
//# sourceMappingURL=ClearSignContext.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/model/ClearSignContext.ts"],
|
|
4
|
-
"sourcesContent": ["import { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nimport { type GenericPath } from \"./GenericPath\";\n\nexport enum ClearSignContextType {\n TOKEN = \"token\",\n NFT = \"nft\",\n TRUSTED_NAME = \"trustedName\",\n PLUGIN = \"plugin\",\n EXTERNAL_PLUGIN = \"externalPlugin\",\n TRANSACTION_INFO = \"transactionInfo\",\n PROXY_INFO = \"proxyInfo\",\n ENUM = \"enum\",\n TRANSACTION_FIELD_DESCRIPTION = \"transactionFieldDescription\",\n TRANSACTION_CHECK = \"transactionCheck\",\n DYNAMIC_NETWORK = \"dynamicNetwork\",\n DYNAMIC_NETWORK_ICON = \"dynamicNetworkIcon\",\n ERROR = \"error\",\n SAFE = \"safe\",\n SIGNER = \"signer\",\n}\n\nexport enum ClearSignContextReferenceType {\n TOKEN = ClearSignContextType.TOKEN,\n NFT = ClearSignContextType.NFT,\n TRUSTED_NAME = ClearSignContextType.TRUSTED_NAME,\n ENUM = ClearSignContextType.ENUM,\n CALLDATA = \"calldata\",\n}\n\ntype PathOnly = {\n valuePath: GenericPath;\n value?: never;\n callee?: GenericPath;\n selector?: GenericPath;\n amount?: GenericPath;\n spender?: GenericPath;\n chainId?: GenericPath;\n};\n\ntype ValueOnly = {\n value: string;\n valuePath?: never;\n};\n\ntype PathOrValue = PathOnly | ValueOnly;\n\n// per-type payloads for references\ntype ClearSignContextReferencePayloads = {\n [ClearSignContextReferenceType.ENUM]: {\n valuePath: GenericPath;\n id: number; // enum id to reference\n };\n [ClearSignContextReferenceType.TRUSTED_NAME]: {\n valuePath: GenericPath;\n types: string[];\n sources: string[];\n };\n [ClearSignContextReferenceType.CALLDATA]: {\n callee: GenericPath;\n valuePath: GenericPath;\n selector?: GenericPath;\n amount?: GenericPath;\n spender?: GenericPath;\n chainId?: GenericPath;\n };\n [ClearSignContextReferenceType.TOKEN]: PathOrValue;\n [ClearSignContextReferenceType.NFT]: PathOrValue;\n};\n\n// discriminated union of all reference shapes, built from the payload map\ntype ClearSignContextReferenceUnion = {\n [T in ClearSignContextReferenceType]: {\n type: T;\n } & ClearSignContextReferencePayloads[T];\n}[ClearSignContextReferenceType];\n\nexport type ClearSignContextReference<\n T extends ClearSignContextReferenceType = ClearSignContextReferenceType,\n> = Extract<ClearSignContextReferenceUnion, { type: T }>;\n\nexport type ClearSignContextSuccessType = Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n>;\n\n// base payload shared by most success contexts\ntype ClearSignContextSuccessBase = {\n payload: string;\n certificate?: PkiCertificate;\n};\n\n// map from ClearSign success type to payload\ntype ClearSignContextSuccessPayloadsBase = {\n [K in ClearSignContextSuccessType]: ClearSignContextSuccessBase;\n};\n\n// special cases overrides for certain context types\ntype ClearSignContextSuccessPayloadOverrides = {\n [ClearSignContextType.ENUM]: ClearSignContextSuccessBase & {\n id: number;\n value: number;\n };\n [ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION]: ClearSignContextSuccessBase & {\n reference?: ClearSignContextReference;\n };\n};\n\ntype ClearSignContextSuccessPayloads = Omit<\n ClearSignContextSuccessPayloadsBase,\n ClearSignContextType.ENUM | ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION\n> &\n ClearSignContextSuccessPayloadOverrides;\n\n// union of all success contexts, built from the payload map.\ntype ClearSignContextSuccessUnion = {\n [T in ClearSignContextSuccessType]: {\n type: T;\n } & ClearSignContextSuccessPayloads[T];\n}[ClearSignContextSuccessType];\n\nexport type ClearSignContextSuccess<\n T extends ClearSignContextSuccessType = ClearSignContextSuccessType,\n> = Extract<ClearSignContextSuccessUnion, { type: T }>;\n\nexport type ClearSignContextError = {\n type: ClearSignContextType.ERROR;\n error: Error;\n};\n\nexport type ClearSignContext = ClearSignContextSuccess | ClearSignContextError;\n"],
|
|
5
|
-
"mappings": "AAIO,IAAKA,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,OAAS,SACTA,EAAA,gBAAkB,iBAClBA,EAAA,iBAAmB,kBACnBA,EAAA,WAAa,YACbA,EAAA,KAAO,OACPA,EAAA,8BAAgC,8BAChCA,EAAA,kBAAoB,mBACpBA,EAAA,gBAAkB,iBAClBA,EAAA,qBAAuB,qBACvBA,EAAA,MAAQ,QACRA,EAAA,KAAO,OACPA,EAAA,OAAS,
|
|
4
|
+
"sourcesContent": ["import { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nimport { type GenericPath } from \"./GenericPath\";\n\nexport enum ClearSignContextType {\n TOKEN = \"token\",\n NFT = \"nft\",\n TRUSTED_NAME = \"trustedName\",\n PLUGIN = \"plugin\",\n EXTERNAL_PLUGIN = \"externalPlugin\",\n TRANSACTION_INFO = \"transactionInfo\",\n PROXY_INFO = \"proxyInfo\",\n ENUM = \"enum\",\n TRANSACTION_FIELD_DESCRIPTION = \"transactionFieldDescription\",\n TRANSACTION_CHECK = \"transactionCheck\",\n DYNAMIC_NETWORK = \"dynamicNetwork\",\n DYNAMIC_NETWORK_ICON = \"dynamicNetworkIcon\",\n ERROR = \"error\",\n SAFE = \"safe\",\n SIGNER = \"signer\",\n GATED_SIGNING = \"gatedSigning\",\n}\n\nexport enum ClearSignContextReferenceType {\n TOKEN = ClearSignContextType.TOKEN,\n NFT = ClearSignContextType.NFT,\n TRUSTED_NAME = ClearSignContextType.TRUSTED_NAME,\n ENUM = ClearSignContextType.ENUM,\n CALLDATA = \"calldata\",\n}\n\ntype PathOnly = {\n valuePath: GenericPath;\n value?: never;\n callee?: GenericPath;\n selector?: GenericPath;\n amount?: GenericPath;\n spender?: GenericPath;\n chainId?: GenericPath;\n};\n\ntype ValueOnly = {\n value: string;\n valuePath?: never;\n};\n\ntype PathOrValue = PathOnly | ValueOnly;\n\n// per-type payloads for references\ntype ClearSignContextReferencePayloads = {\n [ClearSignContextReferenceType.ENUM]: {\n valuePath: GenericPath;\n id: number; // enum id to reference\n };\n [ClearSignContextReferenceType.TRUSTED_NAME]: {\n valuePath: GenericPath;\n types: string[];\n sources: string[];\n };\n [ClearSignContextReferenceType.CALLDATA]: {\n callee: GenericPath;\n valuePath: GenericPath;\n selector?: GenericPath;\n amount?: GenericPath;\n spender?: GenericPath;\n chainId?: GenericPath;\n };\n [ClearSignContextReferenceType.TOKEN]: PathOrValue;\n [ClearSignContextReferenceType.NFT]: PathOrValue;\n};\n\n// discriminated union of all reference shapes, built from the payload map\ntype ClearSignContextReferenceUnion = {\n [T in ClearSignContextReferenceType]: {\n type: T;\n } & ClearSignContextReferencePayloads[T];\n}[ClearSignContextReferenceType];\n\nexport type ClearSignContextReference<\n T extends ClearSignContextReferenceType = ClearSignContextReferenceType,\n> = Extract<ClearSignContextReferenceUnion, { type: T }>;\n\nexport type ClearSignContextSuccessType = Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n>;\n\n// base payload shared by most success contexts\ntype ClearSignContextSuccessBase = {\n payload: string;\n certificate?: PkiCertificate;\n};\n\n// map from ClearSign success type to payload\ntype ClearSignContextSuccessPayloadsBase = {\n [K in ClearSignContextSuccessType]: ClearSignContextSuccessBase;\n};\n\n// special cases overrides for certain context types\ntype ClearSignContextSuccessPayloadOverrides = {\n [ClearSignContextType.ENUM]: ClearSignContextSuccessBase & {\n id: number;\n value: number;\n };\n [ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION]: ClearSignContextSuccessBase & {\n reference?: ClearSignContextReference;\n };\n};\n\ntype ClearSignContextSuccessPayloads = Omit<\n ClearSignContextSuccessPayloadsBase,\n ClearSignContextType.ENUM | ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION\n> &\n ClearSignContextSuccessPayloadOverrides;\n\n// union of all success contexts, built from the payload map.\ntype ClearSignContextSuccessUnion = {\n [T in ClearSignContextSuccessType]: {\n type: T;\n } & ClearSignContextSuccessPayloads[T];\n}[ClearSignContextSuccessType];\n\nexport type ClearSignContextSuccess<\n T extends ClearSignContextSuccessType = ClearSignContextSuccessType,\n> = Extract<ClearSignContextSuccessUnion, { type: T }>;\n\nexport type ClearSignContextError = {\n type: ClearSignContextType.ERROR;\n error: Error;\n};\n\nexport type ClearSignContext = ClearSignContextSuccess | ClearSignContextError;\n"],
|
|
5
|
+
"mappings": "AAIO,IAAKA,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,OAAS,SACTA,EAAA,gBAAkB,iBAClBA,EAAA,iBAAmB,kBACnBA,EAAA,WAAa,YACbA,EAAA,KAAO,OACPA,EAAA,8BAAgC,8BAChCA,EAAA,kBAAoB,mBACpBA,EAAA,gBAAkB,iBAClBA,EAAA,qBAAuB,qBACvBA,EAAA,MAAQ,QACRA,EAAA,KAAO,OACPA,EAAA,OAAS,SACTA,EAAA,cAAgB,eAhBNA,OAAA,IAmBAC,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,KAAO,OACPA,EAAA,SAAW,WALDA,OAAA",
|
|
6
6
|
"names": ["ClearSignContextType", "ClearSignContextReferenceType"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/model/SolanaContextTypes.ts"],
|
|
4
|
-
"sourcesContent": ["import type { PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nexport enum SolanaContextTypes {\n SOLANA_TOKEN = \"solanaToken\",\n SOLANA_LIFI = \"solanaLifi\",\n ERROR = \"error\",\n}\n\nexport type
|
|
4
|
+
"sourcesContent": ["import type { PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nexport enum SolanaContextTypes {\n SOLANA_TOKEN = \"solanaToken\",\n SOLANA_LIFI = \"solanaLifi\",\n ERROR = \"error\",\n}\n\nexport type SolanaTransactionDescriptorRaw = {\n data: string;\n descriptorType: string;\n descriptorVersion: string;\n signatures: {\n prod?: string;\n test?: string;\n };\n};\n\nexport type SolanaTransactionDescriptor = {\n data: string;\n descriptorType: string;\n descriptorVersion: string;\n signature: string;\n};\n\nexport type SolanaLifiDescriptorEntry = {\n program_id: string;\n discriminator_hex?: string;\n descriptor: SolanaTransactionDescriptorRaw;\n};\n\nexport type GetTransactionDescriptorsResponse = {\n id: string;\n chain_id: number;\n instructions: Array<{\n program_id: string;\n discriminator?: number;\n discriminator_hex?: string;\n }>;\n descriptors: SolanaLifiDescriptorEntry[];\n};\n\nexport type SolanaTransactionDescriptorList = Record<\n string,\n SolanaTransactionDescriptor\n>;\n\nexport type SolanaLifiInstructionMeta = {\n program_id: string;\n discriminator_hex?: string;\n};\n\nexport type SolanaLifiPayload = {\n descriptors: SolanaTransactionDescriptorList;\n instructions: SolanaLifiInstructionMeta[];\n};\n\nexport type SolanaTokenData = {\n solanaTokenDescriptor: {\n data: string;\n signature: string;\n };\n};\n\nexport type SolanaContextSuccessType = Exclude<\n SolanaContextTypes,\n SolanaContextTypes.ERROR\n>;\n\n// map from Solana success type to payload\ntype SolanaContextSuccessPayloads = {\n [SolanaContextTypes.SOLANA_TOKEN]: {\n payload: SolanaTokenData;\n certificate?: PkiCertificate;\n };\n [SolanaContextTypes.SOLANA_LIFI]: {\n payload: SolanaLifiPayload;\n certificate?: PkiCertificate;\n };\n};\n\nexport type SolanaContextSuccess<\n T extends SolanaContextSuccessType = SolanaContextSuccessType,\n> = {\n type: T;\n} & SolanaContextSuccessPayloads[T];\n\nexport type SolanaContextError = {\n type: SolanaContextTypes.ERROR;\n error: Error;\n};\n\nexport type SolanaContext = SolanaContextSuccess | SolanaContextError;\n\nexport type SolanaTokenContextSuccess =\n SolanaContextSuccess<SolanaContextTypes.SOLANA_TOKEN>;\n\nexport type SolanaLifiContextSuccess =\n SolanaContextSuccess<SolanaContextTypes.SOLANA_LIFI>;\n\nexport type SolanaTokenContextResult =\n | SolanaTokenContextSuccess\n | SolanaContextError;\n\nexport type SolanaLifiContextResult =\n | SolanaLifiContextSuccess\n | SolanaContextError;\n\nexport type LoaderResult = SolanaTokenContextResult | SolanaLifiContextResult;\n"],
|
|
5
5
|
"mappings": "AAEO,IAAKA,OACVA,EAAA,aAAe,cACfA,EAAA,YAAc,aACdA,EAAA,MAAQ,QAHEA,OAAA",
|
|
6
6
|
"names": ["SolanaContextTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{KeyUsage as e}from"../../pki/model/KeyUsage";class
|
|
1
|
+
import{KeyUsage as e}from"../../pki/model/KeyUsage";class i{static keyUsageMap=new Map([[e.GenuineCheck,1],[e.ExchangePayload,2],[e.NftMeta,3],[e.TrustedName,4],[e.BackupProvider,5],[e.ProtectOrchestrator,6],[e.PluginMeta,7],[e.CoinMeta,8],[e.SeedIdAuth,9],[e.TxSimulationSigner,10],[e.Calldata,11],[e.Network,12],[e.SwapTemplate,13],[e.LESMultisig,14],[e.GatedSigning,15]]);static mapKeyUsageForFirmware(a){return Object.values(e).includes(a)?this.keyUsageMap.get(a)??-1:-1}}export{i as KeyUsageMapper};
|
|
2
2
|
//# sourceMappingURL=KeyUsageMapper.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/utils/KeyUsageMapper.ts"],
|
|
4
|
-
"sourcesContent": ["import { KeyUsage } from \"@/pki/model/KeyUsage\";\n\nexport class KeyUsageMapper {\n private static keyUsageMap = new Map<KeyUsage, number>([\n [KeyUsage.GenuineCheck, 1],\n [KeyUsage.ExchangePayload, 2],\n [KeyUsage.NftMeta, 3],\n [KeyUsage.TrustedName, 4],\n [KeyUsage.BackupProvider, 5],\n [KeyUsage.ProtectOrchestrator, 6],\n [KeyUsage.PluginMeta, 7],\n [KeyUsage.CoinMeta, 8],\n [KeyUsage.SeedIdAuth, 9],\n [KeyUsage.TxSimulationSigner, 10],\n [KeyUsage.Calldata, 11],\n [KeyUsage.Network, 12],\n [KeyUsage.LESMultisig, 14],\n ]);\n\n static mapKeyUsageForFirmware(keyUsage: string): number {\n if (Object.values(KeyUsage).includes(keyUsage as KeyUsage)) {\n return this.keyUsageMap.get(keyUsage as KeyUsage) ?? -1;\n }\n return -1;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,YAAAA,MAAgB,uBAElB,MAAMC,CAAe,CAC1B,OAAe,YAAc,IAAI,IAAsB,CACrD,CAACD,EAAS,aAAc,CAAC,EACzB,CAACA,EAAS,gBAAiB,CAAC,EAC5B,CAACA,EAAS,QAAS,CAAC,EACpB,CAACA,EAAS,YAAa,CAAC,EACxB,CAACA,EAAS,eAAgB,CAAC,EAC3B,CAACA,EAAS,oBAAqB,CAAC,EAChC,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,SAAU,CAAC,EACrB,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,mBAAoB,EAAE,EAChC,CAACA,EAAS,SAAU,EAAE,EACtB,CAACA,EAAS,QAAS,EAAE,EACrB,CAACA,EAAS,YAAa,EAAE,
|
|
4
|
+
"sourcesContent": ["import { KeyUsage } from \"@/pki/model/KeyUsage\";\n\nexport class KeyUsageMapper {\n private static keyUsageMap = new Map<KeyUsage, number>([\n [KeyUsage.GenuineCheck, 1],\n [KeyUsage.ExchangePayload, 2],\n [KeyUsage.NftMeta, 3],\n [KeyUsage.TrustedName, 4],\n [KeyUsage.BackupProvider, 5],\n [KeyUsage.ProtectOrchestrator, 6],\n [KeyUsage.PluginMeta, 7],\n [KeyUsage.CoinMeta, 8],\n [KeyUsage.SeedIdAuth, 9],\n [KeyUsage.TxSimulationSigner, 10],\n [KeyUsage.Calldata, 11],\n [KeyUsage.Network, 12],\n [KeyUsage.SwapTemplate, 13],\n [KeyUsage.LESMultisig, 14],\n [KeyUsage.GatedSigning, 15],\n ]);\n\n static mapKeyUsageForFirmware(keyUsage: string): number {\n if (Object.values(KeyUsage).includes(keyUsage as KeyUsage)) {\n return this.keyUsageMap.get(keyUsage as KeyUsage) ?? -1;\n }\n return -1;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,YAAAA,MAAgB,uBAElB,MAAMC,CAAe,CAC1B,OAAe,YAAc,IAAI,IAAsB,CACrD,CAACD,EAAS,aAAc,CAAC,EACzB,CAACA,EAAS,gBAAiB,CAAC,EAC5B,CAACA,EAAS,QAAS,CAAC,EACpB,CAACA,EAAS,YAAa,CAAC,EACxB,CAACA,EAAS,eAAgB,CAAC,EAC3B,CAACA,EAAS,oBAAqB,CAAC,EAChC,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,SAAU,CAAC,EACrB,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,mBAAoB,EAAE,EAChC,CAACA,EAAS,SAAU,EAAE,EACtB,CAACA,EAAS,QAAS,EAAE,EACrB,CAACA,EAAS,aAAc,EAAE,EAC1B,CAACA,EAAS,YAAa,EAAE,EACzB,CAACA,EAAS,aAAc,EAAE,CAC5B,CAAC,EAED,OAAO,uBAAuBE,EAA0B,CACtD,OAAI,OAAO,OAAOF,CAAQ,EAAE,SAASE,CAAoB,EAChD,KAAK,YAAY,IAAIA,CAAoB,GAAK,GAEhD,EACT,CACF",
|
|
6
6
|
"names": ["KeyUsage", "KeyUsageMapper", "keyUsage"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{KeyUsage as e}from"../../pki/model/KeyUsage";import{KeyUsageMapper as r}from"../../shared/utils/KeyUsageMapper";describe("KeyUsageMapper",()=>{describe("mapKeyUsageForFirmware",()=>{it.each([[e.GenuineCheck,1],[e.ExchangePayload,2],[e.NftMeta,3],[e.TrustedName,4],[e.BackupProvider,5],[e.ProtectOrchestrator,6],[e.PluginMeta,7],[e.CoinMeta,8],[e.SeedIdAuth,9],[e.TxSimulationSigner,10],[e.Calldata,11],[e.Network,12],[e.LESMultisig,14]])("should map key usage %s to %i",(a,t)=>{const o=r.mapKeyUsageForFirmware(a);expect(o).toEqual(t)}),it("should return -1 when key usage is not found",()=>{const a=r.mapKeyUsageForFirmware("unknown");expect(a).toEqual(-1)})})});
|
|
1
|
+
import{KeyUsage as e}from"../../pki/model/KeyUsage";import{KeyUsageMapper as r}from"../../shared/utils/KeyUsageMapper";describe("KeyUsageMapper",()=>{describe("mapKeyUsageForFirmware",()=>{it.each([[e.GenuineCheck,1],[e.ExchangePayload,2],[e.NftMeta,3],[e.TrustedName,4],[e.BackupProvider,5],[e.ProtectOrchestrator,6],[e.PluginMeta,7],[e.CoinMeta,8],[e.SeedIdAuth,9],[e.TxSimulationSigner,10],[e.Calldata,11],[e.Network,12],[e.LESMultisig,14],[e.SwapTemplate,13]])("should map key usage %s to %i",(a,t)=>{const o=r.mapKeyUsageForFirmware(a);expect(o).toEqual(t)}),it("should return -1 when key usage is not found",()=>{const a=r.mapKeyUsageForFirmware("unknown");expect(a).toEqual(-1)})})});
|
|
2
2
|
//# sourceMappingURL=KeyUsageMapper.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/utils/KeyUsageMapper.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { KeyUsageMapper } from \"@/shared/utils/KeyUsageMapper\";\n\ndescribe(\"KeyUsageMapper\", () => {\n describe(\"mapKeyUsageForFirmware\", () => {\n it.each([\n [KeyUsage.GenuineCheck, 1],\n [KeyUsage.ExchangePayload, 2],\n [KeyUsage.NftMeta, 3],\n [KeyUsage.TrustedName, 4],\n [KeyUsage.BackupProvider, 5],\n [KeyUsage.ProtectOrchestrator, 6],\n [KeyUsage.PluginMeta, 7],\n [KeyUsage.CoinMeta, 8],\n [KeyUsage.SeedIdAuth, 9],\n [KeyUsage.TxSimulationSigner, 10],\n [KeyUsage.Calldata, 11],\n [KeyUsage.Network, 12],\n [KeyUsage.LESMultisig, 14],\n ])(`should map key usage %s to %i`, (keyUsage, expected) => {\n // WHEN\n const result = KeyUsageMapper.mapKeyUsageForFirmware(keyUsage);\n\n // THEN\n expect(result).toEqual(expected);\n });\n\n it(\"should return -1 when key usage is not found\", () => {\n // WHEN\n const result = KeyUsageMapper.mapKeyUsageForFirmware(\n \"unknown\" as KeyUsage,\n );\n\n // THEN\n expect(result).toEqual(-1);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,YAAAA,MAAgB,uBACzB,OAAS,kBAAAC,MAAsB,gCAE/B,SAAS,iBAAkB,IAAM,CAC/B,SAAS,yBAA0B,IAAM,CACvC,GAAG,KAAK,CACN,CAACD,EAAS,aAAc,CAAC,EACzB,CAACA,EAAS,gBAAiB,CAAC,EAC5B,CAACA,EAAS,QAAS,CAAC,EACpB,CAACA,EAAS,YAAa,CAAC,EACxB,CAACA,EAAS,eAAgB,CAAC,EAC3B,CAACA,EAAS,oBAAqB,CAAC,EAChC,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,SAAU,CAAC,EACrB,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,mBAAoB,EAAE,EAChC,CAACA,EAAS,SAAU,EAAE,EACtB,CAACA,EAAS,QAAS,EAAE,EACrB,CAACA,EAAS,YAAa,EAAE,
|
|
4
|
+
"sourcesContent": ["import { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { KeyUsageMapper } from \"@/shared/utils/KeyUsageMapper\";\n\ndescribe(\"KeyUsageMapper\", () => {\n describe(\"mapKeyUsageForFirmware\", () => {\n it.each([\n [KeyUsage.GenuineCheck, 1],\n [KeyUsage.ExchangePayload, 2],\n [KeyUsage.NftMeta, 3],\n [KeyUsage.TrustedName, 4],\n [KeyUsage.BackupProvider, 5],\n [KeyUsage.ProtectOrchestrator, 6],\n [KeyUsage.PluginMeta, 7],\n [KeyUsage.CoinMeta, 8],\n [KeyUsage.SeedIdAuth, 9],\n [KeyUsage.TxSimulationSigner, 10],\n [KeyUsage.Calldata, 11],\n [KeyUsage.Network, 12],\n [KeyUsage.LESMultisig, 14],\n [KeyUsage.SwapTemplate, 13],\n ])(`should map key usage %s to %i`, (keyUsage, expected) => {\n // WHEN\n const result = KeyUsageMapper.mapKeyUsageForFirmware(keyUsage);\n\n // THEN\n expect(result).toEqual(expected);\n });\n\n it(\"should return -1 when key usage is not found\", () => {\n // WHEN\n const result = KeyUsageMapper.mapKeyUsageForFirmware(\n \"unknown\" as KeyUsage,\n );\n\n // THEN\n expect(result).toEqual(-1);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,YAAAA,MAAgB,uBACzB,OAAS,kBAAAC,MAAsB,gCAE/B,SAAS,iBAAkB,IAAM,CAC/B,SAAS,yBAA0B,IAAM,CACvC,GAAG,KAAK,CACN,CAACD,EAAS,aAAc,CAAC,EACzB,CAACA,EAAS,gBAAiB,CAAC,EAC5B,CAACA,EAAS,QAAS,CAAC,EACpB,CAACA,EAAS,YAAa,CAAC,EACxB,CAACA,EAAS,eAAgB,CAAC,EAC3B,CAACA,EAAS,oBAAqB,CAAC,EAChC,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,SAAU,CAAC,EACrB,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,mBAAoB,EAAE,EAChC,CAACA,EAAS,SAAU,EAAE,EACtB,CAACA,EAAS,QAAS,EAAE,EACrB,CAACA,EAAS,YAAa,EAAE,EACzB,CAACA,EAAS,aAAc,EAAE,CAC5B,CAAC,EAAE,gCAAiC,CAACE,EAAUC,IAAa,CAE1D,MAAMC,EAASH,EAAe,uBAAuBC,CAAQ,EAG7D,OAAOE,CAAM,EAAE,QAAQD,CAAQ,CACjC,CAAC,EAED,GAAG,+CAAgD,IAAM,CAEvD,MAAMC,EAASH,EAAe,uBAC5B,SACF,EAGA,OAAOG,CAAM,EAAE,QAAQ,EAAE,CAC3B,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["KeyUsage", "KeyUsageMapper", "keyUsage", "expected", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var g=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var u=(s,e,r,a)=>{for(var t=a>1?void 0:a?T(e,r):e,d=s.length-1,i;d>=0;d--)(i=s[d])&&(t=(a?i(e,r,t):i(t))||t);return a&&t&&g(e,r,t),t},n=(s,e)=>(r,a)=>e(r,a,s);import{inject as l,injectable as y}from"inversify";import{Left as C,Right as k}from"purify-ts";import{configTypes as x}from"../../config/di/configTypes";import{pkiTypes as v}from"../../pki/di/pkiTypes";import{KeyUsage as A}from"../../pki/model/KeyUsage";import{SolanaContextTypes as c}from"../../shared/model/SolanaContextTypes";import{solanaContextTypes as P}from"../../solana/di/solanaContextTypes";import{lifiTypes as h}from"../../solanaLifi/di/solanaLifiTypes";import{solanaTokenTypes as _}from"../../solanaToken/di/solanaTokenTypes";let p=class{constructor(e,r,a,t,d){this._dataSource=e;this._certificateLoader=r;this._solanaTokenLoader=a;this._solanaLifiLoader=d;this.logger=t("DefaultSolanaContextLoader")}logger;needsOwnerInfo(e){return!!(e.tokenAddress||e.createATA)}async load(e){this.logger.debug("[load] Loading solana context",{data:{input:e}});const{deviceModelId:r}=e,t=[{loader:this._solanaTokenLoader,expectedType:c.SOLANA_TOKEN},{loader:this._solanaLifiLoader,expectedType:c.SOLANA_LIFI}].map(({loader:o,expectedType:f})=>o.canHandle(e,f)?o.loadField(e):void 0).filter(o=>o!==void 0),i=(await Promise.allSettled(t)).map(o=>o.status==="fulfilled"?o.value:void 0).filter(o=>o!==void 0).sort((o,f)=>{const L=o.type===c.SOLANA_TOKEN?0:1,S=f.type===c.SOLANA_TOKEN?0:1;return L-S});if(!this.needsOwnerInfo(e))return this.logger.debug("[load] No tokenAddress or createATA, skipping owner info lookup"),k({loadersResults:i});const m=await this._certificateLoader.loadCertificate({keyId:"domain_metadata_key",keyUsage:A.TrustedName,targetDevice:r});return m?(await this._dataSource.getOwnerInfo(e)).map(({tlvDescriptor:o})=>({trustedNamePKICertificate:m,tlvDescriptor:o,loadersResults:i})):C(new Error("[ContextModule] DefaultSolanaContextLoader: trustedNamePKICertificate is missing"))}};p=u([y(),n(0,l(P.SolanaDataSource)),n(1,l(v.PkiCertificateLoader)),n(2,l(_.SolanaTokenContextLoader)),n(3,l(x.ContextModuleLoggerFactory)),n(4,l(h.SolanaLifiContextLoader))],p);export{p as DefaultSolanaContextLoader};
|
|
2
2
|
//# sourceMappingURL=DefaultSolanaContextLoader.js.map
|