@ledgerhq/context-module 0.0.0-multisig-20250925175241 → 0.0.0-multisig-20250926152730
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/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
- package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js +1 -1
- package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js.map +1 -1
- package/lib/cjs/src/trusted-name/data/TrustedNameDto.js +1 -1
- package/lib/cjs/src/trusted-name/data/TrustedNameDto.js.map +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +3 -3
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +3 -3
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +3 -3
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +3 -3
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +7 -3
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
- package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts +7 -2
- package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -1
- package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts +4 -5
- package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts.map +1 -1
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts +5 -1
- package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +5 -1
- package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n chainId,\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error,
|
|
5
|
-
"mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OACE,gCAAAC,EACA,8BAAAC,MACK,
|
|
6
|
-
"names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpTrustedNameDataSource", "config", "chainId", "domain", "challenge", "
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n TrustedNamePayload,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n chainId,\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error, TrustedNamePayload>> {\n let dto: TrustedNameDto | undefined;\n try {\n const type = \"eoa\"; // Externally owned account\n const source = \"ens\"; // Ethereum name service\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/names/ethereum/${chainId}/forward/${domain}?types=${type}&sources=${source}&challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n dto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: No data received for domain ${domain} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isTrustedNameDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: Invalid trusted name response format for domain ${domain} on chain ${chainId}`,\n ),\n );\n }\n\n return Right({\n data: dto.signedDescriptor.data,\n keyId: dto.keyId,\n keyUsage: dto.keyUsage,\n });\n }\n\n public async getTrustedNamePayload({\n chainId,\n address,\n challenge,\n sources,\n types,\n }: GetTrustedNameInfosParams): Promise<Either<Error, TrustedNamePayload>> {\n let dto: TrustedNameDto | undefined;\n try {\n // TODO remove that filtering once https://ledgerhq.atlassian.net/browse/BACK-8075 is done\n // For now we have to filter or trusted names won't work with the generic parser, because transaction\n // fields descriptors can contain unsupported sources.\n sources = sources.filter(\n (source) => source === \"ens\" || source === \"crypto_asset_list\",\n );\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/names/ethereum/${chainId}/reverse/${address}?types=${types.join(\",\")}&sources=${sources.join(\",\")}&challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n dto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: No data received for address ${address} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isTrustedNameDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: Invalid trusted name response format for address ${address} on chain ${chainId}`,\n ),\n );\n }\n\n if (\n typeof dto.signedDescriptor.signatures[this.config.cal.mode] !== \"string\"\n ) {\n // If we have no separated signature but a valid descriptor, it may mean the descriptor was\n // signed on-the-fly for dynamic sources such as ens\n return Right({\n data: dto.signedDescriptor.data,\n keyId: dto.keyId,\n keyUsage: dto.keyUsage,\n });\n }\n\n const signature = dto.signedDescriptor.signatures[this.config.cal.mode]!;\n return Right({\n data: this.formatTrustedName(dto.signedDescriptor.data, signature),\n keyId: dto.keyId,\n keyUsage: dto.keyUsage,\n });\n }\n\n private formatTrustedName(payload: string, signature: string): string {\n // Ensure correct padding\n if (signature.length % 2 !== 0) {\n signature = \"0\" + signature;\n }\n // TLV encoding as according to trusted name documentation\n const signatureTag = \"15\";\n const signatureLength = (signature.length / 2).toString(16);\n return `${payload}${signatureTag}${signatureLength}${signature}`;\n }\n /**\n * Type guard to validate ProxyDelegateCallDto\n */\n private isTrustedNameDto(value: unknown): value is TrustedNameDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"signedDescriptor\" in value &&\n \"keyId\" in value &&\n \"keyUsage\" in value &&\n typeof value.keyId === \"string\" &&\n typeof value.keyUsage === \"string\" &&\n typeof value.signedDescriptor === \"object\" &&\n value.signedDescriptor !== null &&\n \"data\" in value.signedDescriptor &&\n \"signatures\" in value.signedDescriptor &&\n typeof value.signedDescriptor.data === \"string\" &&\n typeof value.signedDescriptor.signatures ===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AOA,EAAM,kBAAqB,UAClCA,EAAM,mBAAqB,MAC3B,SAAUA,EAAM,kBAChB,eAAgBA,EAAM,kBACtB,OAAOA,EAAM,iBAAiB,MAAS,UACvC,OAAOA,EAAM,iBAAiB,YAAe,QAEjD,CACF,EAxJapB,EAANqB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBzB",
|
|
6
|
+
"names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpTrustedNameDataSource", "config", "chainId", "domain", "challenge", "dto", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "Left", "Right", "address", "sources", "types", "source", "signature", "payload", "signatureTag", "signatureLength", "value", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import o from"axios";import{Left as
|
|
1
|
+
import o from"axios";import{Left as s,Right as r}from"purify-ts";import{LEDGER_CLIENT_VERSION_HEADER as d,LEDGER_ORIGIN_TOKEN_HEADER as l}from"../../shared/constant/HttpHeaders";import{HttpTrustedNameDataSource as c}from"../../trusted-name/data/HttpTrustedNameDataSource";import i from"../../../package.json";vi.mock("axios");const n={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"},metadataServiceDomain:{url:"https://nft.api.live.ledger.com"},originToken:"originToken"};describe("HttpTrustedNameDataSource",()=>{let t;beforeAll(()=>{t=new c(n),vi.clearAllMocks()}),describe("getDomainNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${i.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),await t.getDomainNamePayload({chainId:137,challenge:"9876",domain:"hello.eth"}),expect(a).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876",headers:{[d]:e,[l]:n.originToken}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error);const e=await t.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(e).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(a).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: Invalid trusted name response format for domain hello.eth on chain 137")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{}},keyId:"testKeyId",keyUsage:"testKeyUsage"}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({chainId:137,challenge:"challenge",domain:"hello.eth"});expect(a).toEqual(r({data:"payload",keyId:"testKeyId",keyUsage:"testKeyUsage"}))})}),describe("getTrustedNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${i.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"5678",sources:["ens","crypto_asset_list"],types:["eoa"]}),expect(a).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678",headers:{[d]:e,[l]:n.originToken}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error);const e=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(e).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: Invalid trusted name response format for address 0x1234 on chain 137")))}),it("should return an error when no keys are returned",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{prod:"12345"}}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: Invalid trusted name response format for address 0x1234 on chain 137")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{}},keyId:"testKeyId",keyUsage:"testKeyUsage"}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(r({data:"payload",keyId:"testKeyId",keyUsage:"testKeyUsage"}))}),it("should return a payload with a signature",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{prod:"12345"}},keyId:"testKeyId",keyUsage:"testKeyUsage"}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(r({data:"payload153012345",keyId:"testKeyId",keyUsage:"testKeyUsage"}))})})});
|
|
2
2
|
//# sourceMappingURL=HttpTrustedNameDataSource.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.test.ts"],
|
|
4
|
-
"sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\nconst config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n metadataServiceDomain: {\n url: \"https://nft.api.live.ledger.com\",\n },\n originToken: \"originToken\",\n} as ContextModuleConfig;\ndescribe(\"HttpTrustedNameDataSource\", () => {\n let datasource: TrustedNameDataSource;\n\n beforeAll(() => {\n datasource = new HttpTrustedNameDataSource(config);\n vi.clearAllMocks();\n });\n\n describe(\"getDomainNamePayload\", () => {\n it(\"should call axios with the correct url and ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"9876\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource:
|
|
5
|
-
"mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAS,6BAAAC,MAAiC,gDAE1C,OAAOC,MAAa,qBAEpB,GAAG,KAAK,OAAO,EAEf,MAAMC,EAAS,CACb,IAAK,CACH,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,EACA,sBAAuB,CACrB,IAAK,iCACP,EACA,YAAa,aACf,EACA,SAAS,4BAA6B,IAAM,CAC1C,IAAIC,EAEJ,UAAU,IAAM,CACdA,EAAa,IAAIH,EAA0BE,CAAM,EACjD,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,uBAAwB,IAAM,CACrC,GAAG,0EAA2E,SAAY,CAExF,MAAME,EAAU,kBAAkBH,EAAQ,OAAO,GAC3CI,EAAa,GAAG,GAAG,IAAM,QAAQ,QAAQ,CAAE,KAAM,CAAC,CAAE,CAAC,CAAC,EAC5D,GAAG,MAAMV,EAAO,SAAS,EAAE,mBAAmBU,CAAU,EAGxD,MAAMF,EAAW,qBAAqB,CACpC,QAAS,IACT,UAAW,OACX,OAAQ,WACV,CAAC,EAGD,OAAOE,CAAU,EAAE,qBACjB,OAAO,iBAAiB,CACtB,IAAK,+GACL,QAAS,CACP,CAACP,CAA4B,EAAGM,EAChC,CAACL,CAA0B,EAAGG,EAAO,WACvC,CACF,CAAC,CACH,CACF,CAAC,EAED,GAAG,mDAAoD,SAAY,CAEjE,GAAG,MAAMP,EAAO,SAAS,EAAE,kBAAkB,IAAI,KAAO,EAGxD,MAAMW,EAAS,MAAMH,EAAW,qBAAqB,CACnD,QAAS,IACT,UAAW,GACX,OAAQ,WACV,CAAC,EAGD,OAAOG,CAAM,EAAE,QACbV,EACE,IAAI,MACF,wEACF,CACF,CACF,CACF,CAAC,EAED,GAAG,qDAAsD,SAAY,CAEnE,MAAMW,EAAW,CAAE,KAAM,CAAE,KAAM,EAAG,CAAE,EACtC,GAAG,MAAMZ,EAAO,SAAS,EAAE,kBAAkBY,CAAQ,EAGrD,MAAMD,EAAS,MAAMH,EAAW,qBAAqB,CACnD,QAAS,IACT,UAAW,GACX,OAAQ,WACV,CAAC,EAGD,OAAOG,CAAM,EAAE,QACbV,EACE,IAAI,MACF,
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\nconst config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n metadataServiceDomain: {\n url: \"https://nft.api.live.ledger.com\",\n },\n originToken: \"originToken\",\n} as ContextModuleConfig;\ndescribe(\"HttpTrustedNameDataSource\", () => {\n let datasource: TrustedNameDataSource;\n\n beforeAll(() => {\n datasource = new HttpTrustedNameDataSource(config);\n vi.clearAllMocks();\n });\n\n describe(\"getDomainNamePayload\", () => {\n it(\"should call axios with the correct url and ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"9876\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Invalid trusted name response format for domain hello.eth on chain 137\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: {} },\n keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"challenge\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Right({\n data: \"payload\",\n keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n }),\n );\n });\n });\n\n describe(\"getTrustedNamePayload\", () => {\n it(\"should call axios with the correct url and ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"5678\",\n sources: [\"ens\", \"crypto_asset_list\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Invalid trusted name response format for address 0x1234 on chain 137\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no keys are returned\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: { prod: \"12345\" } },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Invalid trusted name response format for address 0x1234 on chain 137\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: {} },\n keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Right({\n data: \"payload\",\n keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n }),\n );\n });\n\n it(\"should return a payload with a signature\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: { prod: \"12345\" } },\n keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Right({\n data: \"payload153012345\",\n keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n }),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAS,6BAAAC,MAAiC,gDAE1C,OAAOC,MAAa,qBAEpB,GAAG,KAAK,OAAO,EAEf,MAAMC,EAAS,CACb,IAAK,CACH,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,EACA,sBAAuB,CACrB,IAAK,iCACP,EACA,YAAa,aACf,EAC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,EAGrD,MAAMD,EAAS,MAAMH,EAAW,sBAAsB,CACpD,QAAS,IACT,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOG,CAAM,EAAE,QACbT,EAAM,CACJ,KAAM,mBACN,MAAO,YACP,SAAU,cACZ,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["axios", "Left", "Right", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "HttpTrustedNameDataSource", "PACKAGE", "config", "datasource", "version", "requestSpy", "result", "response"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=(i,e,a,r)=>{for(var t=r>1?void 0:r?f(e,a):e,o=i.length-1,d;o>=0;o--)(d=i[o])&&(t=(r?d(e,a,t):d(t))||t);return r&&t&&p(e,a,t),t},c=(i,e)=>(a,r)=>e(a,r,i);import{inject as m,injectable as y}from"inversify";import{pkiTypes as g}from"../../pki/di/pkiTypes";import{ClearSignContextType as n}from"../../shared/model/ClearSignContext";import{trustedNameTypes as u}from"../../trusted-name/di/trustedNameTypes";let s=class{constructor(e,a){this._dataSource=e;this._certificateLoader=a}canHandle(e,a){return a===n.TRUSTED_NAME&&typeof e=="object"&&e!==null&&"chainId"in e&&"address"in e&&"challenge"in e&&"types"in e&&"sources"in e&&"deviceModelId"in e&&e.deviceModelId!==void 0}async loadField(e){return await(await this._dataSource.getTrustedNamePayload({chainId:e.chainId,address:e.address,challenge:e.challenge,types:e.types,sources:e.sources})).caseOf({Left:r=>Promise.resolve({type:n.ERROR,error:r}),Right:async({data:r,keyId:t,keyUsage:o})=>{const d=await this._certificateLoader.loadCertificate({keyId:t,keyUsage:o,targetDevice:e.deviceModelId});return{type:n.TRUSTED_NAME,payload:r,certificate:d}}})}};s=l([y(),c(0,m(u.TrustedNameDataSource)),c(1,m(g.PkiCertificateLoader))],s);export{s as TrustedNameContextFieldLoader};
|
|
2
2
|
//# sourceMappingURL=TrustedNameContextFieldLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/trusted-name/domain/TrustedNameContextFieldLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { ContextFieldLoader } from \"@/shared/domain/ContextFieldLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport * as TrustedNameDataSource from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\ntype TrustedNameFieldInput = {\n chainId: number;\n address: string;\n challenge: string;\n types: string[];\n sources: string[];\n};\n\n@injectable()\nexport class TrustedNameContextFieldLoader\n implements ContextFieldLoader<TrustedNameFieldInput>\n{\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n private _dataSource: TrustedNameDataSource.TrustedNameDataSource,\n ) {}\n\n canHandle(\n input: unknown,\n expectedType: ClearSignContextType,\n ): input is TrustedNameFieldInput {\n return (\n expectedType === ClearSignContextType.TRUSTED_NAME &&\n typeof input === \"object\" &&\n input !== null &&\n \"chainId\" in input &&\n \"address\" in input &&\n \"challenge\" in input &&\n \"types\" in input &&\n \"sources\" in input\n );\n }\n\n async loadField(input: TrustedNameFieldInput): Promise<ClearSignContext> {\n const payload = await this._dataSource.getTrustedNamePayload({\n chainId: input.chainId,\n address: input.address,\n challenge: input.challenge,\n types: input.types,\n sources: input.sources,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["inject", "injectable", "ClearSignContextType", "trustedNameTypes", "TrustedNameContextFieldLoader", "_dataSource", "input", "expectedType", "ClearSignContextType", "error", "
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { ContextFieldLoader } from \"@/shared/domain/ContextFieldLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport * as TrustedNameDataSource from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\ntype TrustedNameFieldInput = {\n chainId: number;\n address: string;\n challenge: string;\n types: string[];\n sources: string[];\n deviceModelId: DeviceModelId;\n};\n\n@injectable()\nexport class TrustedNameContextFieldLoader\n implements ContextFieldLoader<TrustedNameFieldInput>\n{\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n private _dataSource: TrustedNameDataSource.TrustedNameDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private _certificateLoader: PkiCertificateLoader,\n ) {}\n\n canHandle(\n input: unknown,\n expectedType: ClearSignContextType,\n ): input is TrustedNameFieldInput {\n return (\n expectedType === ClearSignContextType.TRUSTED_NAME &&\n typeof input === \"object\" &&\n input !== null &&\n \"chainId\" in input &&\n \"address\" in input &&\n \"challenge\" in input &&\n \"types\" in input &&\n \"sources\" in input &&\n \"deviceModelId\" in input &&\n input.deviceModelId !== undefined\n );\n }\n\n async loadField(input: TrustedNameFieldInput): Promise<ClearSignContext> {\n const payload = await this._dataSource.getTrustedNamePayload({\n chainId: input.chainId,\n address: input.address,\n challenge: input.challenge,\n types: input.types,\n sources: input.sources,\n });\n return await payload.caseOf({\n Left: (error): Promise<ClearSignContext> =>\n Promise.resolve({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: async ({ data, keyId, keyUsage }): Promise<ClearSignContext> => {\n const certificate = await this._certificateLoader.loadCertificate({\n keyId,\n keyUsage,\n targetDevice: input.deviceModelId,\n });\n return {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: data,\n certificate,\n };\n },\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAEnC,OAAS,YAAAC,MAAgB,oBAGzB,OAEE,wBAAAC,MACK,kCAEP,OAAS,oBAAAC,MAAwB,qCAY1B,IAAMC,EAAN,KAEP,CACE,YAEUC,EAEAC,EACR,CAHQ,iBAAAD,EAEA,wBAAAC,CACP,CAEH,UACEC,EACAC,EACgC,CAChC,OACEA,IAAiBC,EAAqB,cACtC,OAAOF,GAAU,UACjBA,IAAU,MACV,YAAaA,GACb,YAAaA,GACb,cAAeA,GACf,UAAWA,GACX,YAAaA,GACb,kBAAmBA,GACnBA,EAAM,gBAAkB,MAE5B,CAEA,MAAM,UAAUA,EAAyD,CAQvE,OAAO,MAPS,MAAM,KAAK,YAAY,sBAAsB,CAC3D,QAASA,EAAM,QACf,QAASA,EAAM,QACf,UAAWA,EAAM,UACjB,MAAOA,EAAM,MACb,QAASA,EAAM,OACjB,CAAC,GACoB,OAAO,CAC1B,KAAOG,GACL,QAAQ,QAAQ,CACd,KAAMD,EAAqB,MAC3B,MAAAC,CACF,CAAC,EACH,MAAO,MAAO,CAAE,KAAAC,EAAM,MAAAC,EAAO,SAAAC,CAAS,IAAiC,CACrE,MAAMC,EAAc,MAAM,KAAK,mBAAmB,gBAAgB,CAChE,MAAAF,EACA,SAAAC,EACA,aAAcN,EAAM,aACtB,CAAC,EACD,MAAO,CACL,KAAME,EAAqB,aAC3B,QAASE,EACT,YAAAG,CACF,CACF,CACF,CAAC,CACH,CACF,EAxDaV,EAANW,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAiB,qBAAqB,GAE7CF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAN5BhB",
|
|
6
|
+
"names": ["inject", "injectable", "pkiTypes", "ClearSignContextType", "trustedNameTypes", "TrustedNameContextFieldLoader", "_dataSource", "_certificateLoader", "input", "expectedType", "ClearSignContextType", "error", "data", "keyId", "keyUsage", "certificate", "__decorateClass", "injectable", "__decorateParam", "inject", "trustedNameTypes", "pkiTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as
|
|
1
|
+
import{DeviceModelId as i}from"@ledgerhq/device-management-kit";import{Left as u,Right as n}from"purify-ts";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";import{TrustedNameContextFieldLoader as y}from"../../trusted-name/domain/TrustedNameContextFieldLoader";describe("TrustedNameContextFieldLoader",()=>{const t={getTrustedNamePayload:vi.fn(),getDomainNamePayload:vi.fn()},c={loadCertificate:vi.fn()},d=new y(t,c),e={chainId:1,address:"0x1234567890abcdef",challenge:"test-challenge",types:["contract","token"],sources:["ledger","ens"],deviceModelId:i.STAX},l={data:"0x123456789abcdef0",keyId:"testKeyId",keyUsage:"testKeyUsage"},r={keyUsageNumber:1,payload:new Uint8Array([1,2,3,4])};beforeEach(()=>{vi.resetAllMocks()}),describe("canHandle",()=>{it("should return true for valid trusted name field",()=>{const a={chainId:1,address:"0x1234567890abcdef",challenge:"test-challenge",types:["contract","token"],sources:["ledger","ens"],deviceModelId:i.STAX};expect(d.canHandle(a,o.TRUSTED_NAME)).toBe(!0)}),describe("should return false for invalid inputs",()=>{const a=[{name:"null",value:null},{name:"undefined",value:void 0},{name:"string",value:"invalid"},{name:"number",value:123},{name:"boolean",value:!0},{name:"array",value:[]},{name:"empty object",value:{}},{name:"object missing chainId",value:{address:"0x123",challenge:"test",types:["contract"],sources:["ledger"]}},{name:"object missing address",value:{chainId:1,challenge:"test",types:["contract"],sources:["ledger"]}},{name:"object missing challenge",value:{chainId:1,address:"0x123",types:["contract"],sources:["ledger"]}},{name:"object missing types",value:{chainId:1,address:"0x123",challenge:"test",sources:["ledger"]}},{name:"object missing sources",value:{chainId:1,address:"0x123",challenge:"test",types:["contract"]}},{name:"object missing device model",value:{chainId:1,address:"0x1234567890abcdef",challenge:"test-challenge",types:["contract","token"],sources:["ledger","ens"]}}];test.each(a)("$name",({value:s})=>{expect(d.canHandle(s,o.TRUSTED_NAME)).toBe(!1)})}),it("should return false for invalid expected type",()=>{expect(d.canHandle(e,o.TOKEN)).toBe(!1)})}),describe("loadField",()=>{it("should return error context when trusted name data source fails",async()=>{const a=new Error("Trusted name data source error");vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(u(a));const s=await d.loadField(e);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:e.types,sources:e.sources}),expect(c.loadCertificate).not.toHaveBeenCalled(),expect(s).toEqual({type:o.ERROR,error:a})}),it("should return trusted name context when successful",async()=>{vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(n(l)),vi.spyOn(c,"loadCertificate").mockResolvedValue(r);const a=await d.loadField(e);expect(c.loadCertificate).toHaveBeenCalledWith({keyId:"testKeyId",keyUsage:"testKeyUsage",targetDevice:e.deviceModelId}),expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:e.types,sources:e.sources}),expect(a).toEqual({type:o.TRUSTED_NAME,payload:l.data,certificate:r})}),it("should handle different chain IDs and addresses correctly",async()=>{const a={...e,chainId:137,address:"0xdeadbeef",challenge:"custom-challenge"};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(n(l)),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:137,address:"0xdeadbeef",challenge:"custom-challenge",types:e.types,sources:e.sources}),expect(s).toEqual({type:o.TRUSTED_NAME,payload:l.data})}),it("should handle different types and sources correctly",async()=>{const a={...e,types:["wallet","exchange"],sources:["coingecko","1inch"]};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(n(l)),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:["wallet","exchange"],sources:["coingecko","1inch"]}),expect(s).toEqual({type:o.TRUSTED_NAME,payload:l.data})}),it("should preserve error message from trusted name data source",async()=>{const a=new Error("Network timeout error");vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(u(a));const s=await d.loadField(e);expect(s).toEqual({type:o.ERROR,error:a})}),it("should handle empty trusted name payload",async()=>{const a={...l,data:""};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(n(a)),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const s=await d.loadField(e);expect(s).toEqual({type:o.TRUSTED_NAME,payload:a.data})}),it("should handle empty types and sources arrays",async()=>{const a={...e,types:[],sources:[]};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(n(l)),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:[],sources:[]}),expect(s).toEqual({type:o.TRUSTED_NAME,payload:l.data})}),it("should handle single type and source",async()=>{const a={...e,types:["contract"],sources:["ens"]};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(n(l)),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:["contract"],sources:["ens"]}),expect(s).toEqual({type:o.TRUSTED_NAME,payload:l.data})})})});
|
|
2
2
|
//# sourceMappingURL=TrustedNameContextFieldLoader.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/trusted-name/domain/TrustedNameContextFieldLoader.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextFieldLoader } from \"@/trusted-name/domain/TrustedNameContextFieldLoader\";\n\ndescribe(\"TrustedNameContextFieldLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getTrustedNamePayload: vi.fn(),\n getDomainNamePayload: vi.fn(),\n };\n const trustedNameContextFieldLoader = new TrustedNameContextFieldLoader(\n mockTrustedNameDataSource,\n );\n\n const mockTransactionField = {\n chainId: 1,\n address: \"0x1234567890abcdef\",\n challenge: \"test-challenge\",\n types: [\"contract\", \"token\"],\n sources: [\"ledger\", \"ens\"],\n };\n\n const mockTrustedNamePayload = \"0x123456789abcdef0\";\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"canHandle\", () => {\n it(\"should return true for valid trusted name field\", () => {\n // GIVEN\n const validField = {\n chainId: 1,\n address: \"0x1234567890abcdef\",\n challenge: \"test-challenge\",\n types: [\"contract\", \"token\"],\n sources: [\"ledger\", \"ens\"],\n };\n\n // THEN\n expect(\n trustedNameContextFieldLoader.canHandle(\n validField,\n ClearSignContextType.TRUSTED_NAME,\n ),\n ).toBe(true);\n });\n\n describe(\"should return false for invalid inputs\", () => {\n const invalidInputs = [\n { name: \"null\", value: null },\n { name: \"undefined\", value: undefined },\n { name: \"string\", value: \"invalid\" },\n { name: \"number\", value: 123 },\n { name: \"boolean\", value: true },\n { name: \"array\", value: [] },\n { name: \"empty object\", value: {} },\n {\n name: \"object missing chainId\",\n value: {\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing address\",\n value: {\n chainId: 1,\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing challenge\",\n value: {\n chainId: 1,\n address: \"0x123\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing types\",\n value: {\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing sources\",\n value: {\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n },\n },\n ];\n\n test.each(invalidInputs)(\"$name\", ({ value }) => {\n expect(\n trustedNameContextFieldLoader.canHandle(\n value,\n ClearSignContextType.TRUSTED_NAME,\n ),\n ).toBe(false);\n });\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(\n trustedNameContextFieldLoader.canHandle(\n mockTransactionField,\n ClearSignContextType.TOKEN,\n ),\n ).toBe(false);\n });\n });\n\n describe(\"loadField\", () => {\n it(\"should return error context when trusted name data source fails\", async () => {\n // GIVEN\n const error = new Error(\"Trusted name data source error\");\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(error));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: error,\n });\n });\n\n it(\"should return trusted name context when successful\", async () => {\n // GIVEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle different chain IDs and addresses correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n chainId: 137,\n address: \"0xdeadbeef\",\n challenge: \"custom-challenge\",\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(customField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: 137,\n address: \"0xdeadbeef\",\n challenge: \"custom-challenge\",\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle different types and sources correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n types: [\"wallet\", \"exchange\"],\n sources: [\"coingecko\", \"1inch\"],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(customField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [\"wallet\", \"exchange\"],\n sources: [\"coingecko\", \"1inch\"],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should preserve error message from trusted name data source\", async () => {\n // GIVEN\n const specificError = new Error(\"Network timeout error\");\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(specificError));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: specificError,\n });\n });\n\n it(\"should handle empty trusted name payload\", async () => {\n // GIVEN\n const emptyPayload = \"\";\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(emptyPayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: emptyPayload,\n });\n });\n\n it(\"should handle empty types and sources arrays\", async () => {\n // GIVEN\n const fieldWithEmptyArrays = {\n ...mockTransactionField,\n types: [],\n sources: [],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(fieldWithEmptyArrays);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [],\n sources: [],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle single type and source\", async () => {\n // GIVEN\n const fieldWithSingleElements = {\n ...mockTransactionField,\n types: [\"contract\"],\n sources: [\"ens\"],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(\n fieldWithSingleElements,\n );\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [\"contract\"],\n sources: [\"ens\"],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,
|
|
6
|
-
"names": ["Left", "Right", "ClearSignContextType", "TrustedNameContextFieldLoader", "mockTrustedNameDataSource", "trustedNameContextFieldLoader", "mockTransactionField", "mockTrustedNamePayload", "validField", "invalidInputs", "value", "error", "result", "customField", "specificError", "emptyPayload", "fieldWithEmptyArrays", "fieldWithSingleElements"]
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextFieldLoader } from \"@/trusted-name/domain/TrustedNameContextFieldLoader\";\n\ndescribe(\"TrustedNameContextFieldLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getTrustedNamePayload: vi.fn(),\n getDomainNamePayload: vi.fn(),\n };\n const mockCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n const trustedNameContextFieldLoader = new TrustedNameContextFieldLoader(\n mockTrustedNameDataSource,\n mockCertificateLoader,\n );\n\n const mockTransactionField = {\n chainId: 1,\n address: \"0x1234567890abcdef\",\n challenge: \"test-challenge\",\n types: [\"contract\", \"token\"],\n sources: [\"ledger\", \"ens\"],\n deviceModelId: DeviceModelId.STAX,\n };\n\n const mockTrustedNamePayload = {\n data: \"0x123456789abcdef0\",\n keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n };\n\n const mockCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3, 4]),\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"canHandle\", () => {\n it(\"should return true for valid trusted name field\", () => {\n // GIVEN\n const validField = {\n chainId: 1,\n address: \"0x1234567890abcdef\",\n challenge: \"test-challenge\",\n types: [\"contract\", \"token\"],\n sources: [\"ledger\", \"ens\"],\n deviceModelId: DeviceModelId.STAX,\n };\n\n // THEN\n expect(\n trustedNameContextFieldLoader.canHandle(\n validField,\n ClearSignContextType.TRUSTED_NAME,\n ),\n ).toBe(true);\n });\n\n describe(\"should return false for invalid inputs\", () => {\n const invalidInputs = [\n { name: \"null\", value: null },\n { name: \"undefined\", value: undefined },\n { name: \"string\", value: \"invalid\" },\n { name: \"number\", value: 123 },\n { name: \"boolean\", value: true },\n { name: \"array\", value: [] },\n { name: \"empty object\", value: {} },\n {\n name: \"object missing chainId\",\n value: {\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing address\",\n value: {\n chainId: 1,\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing challenge\",\n value: {\n chainId: 1,\n address: \"0x123\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing types\",\n value: {\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing sources\",\n value: {\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n },\n },\n {\n name: \"object missing device model\",\n value: {\n chainId: 1,\n address: \"0x1234567890abcdef\",\n challenge: \"test-challenge\",\n types: [\"contract\", \"token\"],\n sources: [\"ledger\", \"ens\"],\n },\n },\n ];\n\n test.each(invalidInputs)(\"$name\", ({ value }) => {\n expect(\n trustedNameContextFieldLoader.canHandle(\n value,\n ClearSignContextType.TRUSTED_NAME,\n ),\n ).toBe(false);\n });\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(\n trustedNameContextFieldLoader.canHandle(\n mockTransactionField,\n ClearSignContextType.TOKEN,\n ),\n ).toBe(false);\n });\n });\n\n describe(\"loadField\", () => {\n it(\"should return error context when trusted name data source fails\", async () => {\n // GIVEN\n const error = new Error(\"Trusted name data source error\");\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(error));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(mockCertificateLoader.loadCertificate).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: error,\n });\n });\n\n it(\"should return trusted name context when successful\", async () => {\n // GIVEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n mockCertificate,\n );\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n targetDevice: mockTransactionField.deviceModelId,\n });\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload.data,\n certificate: mockCertificate,\n });\n });\n\n it(\"should handle different chain IDs and addresses correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n chainId: 137,\n address: \"0xdeadbeef\",\n challenge: \"custom-challenge\",\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n undefined,\n );\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(customField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: 137,\n address: \"0xdeadbeef\",\n challenge: \"custom-challenge\",\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload.data,\n });\n });\n\n it(\"should handle different types and sources correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n types: [\"wallet\", \"exchange\"],\n sources: [\"coingecko\", \"1inch\"],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n undefined,\n );\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(customField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [\"wallet\", \"exchange\"],\n sources: [\"coingecko\", \"1inch\"],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload.data,\n });\n });\n\n it(\"should preserve error message from trusted name data source\", async () => {\n // GIVEN\n const specificError = new Error(\"Network timeout error\");\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(specificError));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: specificError,\n });\n });\n\n it(\"should handle empty trusted name payload\", async () => {\n // GIVEN\n const emptyPayload = {\n ...mockTrustedNamePayload,\n data: \"\",\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(emptyPayload));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n undefined,\n );\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: emptyPayload.data,\n });\n });\n\n it(\"should handle empty types and sources arrays\", async () => {\n // GIVEN\n const fieldWithEmptyArrays = {\n ...mockTransactionField,\n types: [],\n sources: [],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n undefined,\n );\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(fieldWithEmptyArrays);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [],\n sources: [],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload.data,\n });\n });\n\n it(\"should handle single type and source\", async () => {\n // GIVEN\n const fieldWithSingleElements = {\n ...mockTransactionField,\n types: [\"contract\"],\n sources: [\"ens\"],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n undefined,\n );\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(\n fieldWithSingleElements,\n );\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [\"contract\"],\n sources: [\"ens\"],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload.data,\n });\n });\n });\n});\n"],
|
|
5
|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gD,SAAY,CAE7D,MAAMC,EAAuB,CAC3B,GAAGX,EACH,MAAO,CAAC,EACR,QAAS,CAAC,CACZ,EACA,GAAG,MACDH,EACA,uBACF,EAAE,kBAAkBH,EAAMO,CAAsB,CAAC,EACjD,GAAG,MAAMH,EAAuB,iBAAiB,EAAE,kBACjD,MACF,EAGA,MAAMS,EACJ,MAAMR,EAA8B,UAAUY,CAAoB,EAGpE,OACEd,EAA0B,qBAC5B,EAAE,qBAAqB,CACrB,QAASG,EAAqB,QAC9B,QAASA,EAAqB,QAC9B,UAAWA,EAAqB,UAChC,MAAO,CAAC,EACR,QAAS,CAAC,CACZ,CAAC,EACD,OAAOO,CAAM,EAAE,QAAQ,CACrB,KAAMZ,EAAqB,aAC3B,QAASM,EAAuB,IAClC,CAAC,CACH,CAAC,EAED,GAAG,uCAAwC,SAAY,CAErD,MAAMW,EAA0B,CAC9B,GAAGZ,EACH,MAAO,CAAC,UAAU,EAClB,QAAS,CAAC,KAAK,CACjB,EACA,GAAG,MACDH,EACA,uBACF,EAAE,kBAAkBH,EAAMO,CAAsB,CAAC,EACjD,GAAG,MAAMH,EAAuB,iBAAiB,EAAE,kBACjD,MACF,EAGA,MAAMS,EAAS,MAAMR,EAA8B,UACjDa,CACF,EAGA,OACEf,EAA0B,qBAC5B,EAAE,qBAAqB,CACrB,QAASG,EAAqB,QAC9B,QAASA,EAAqB,QAC9B,UAAWA,EAAqB,UAChC,MAAO,CAAC,UAAU,EAClB,QAAS,CAAC,KAAK,CACjB,CAAC,EACD,OAAOO,CAAM,EAAE,QAAQ,CACrB,KAAMZ,EAAqB,aAC3B,QAASM,EAAuB,IAClC,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["DeviceModelId", "Left", "Right", "ClearSignContextType", "TrustedNameContextFieldLoader", "mockTrustedNameDataSource", "mockCertificateLoader", "trustedNameContextFieldLoader", "mockTransactionField", "mockTrustedNamePayload", "mockCertificate", "validField", "invalidInputs", "value", "error", "result", "customField", "specificError", "emptyPayload", "fieldWithEmptyArrays", "fieldWithSingleElements"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var y=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var m=(o,e,a,t)=>{for(var r=t>1?void 0:t?C(e,a):e,i=o.length-1,n;i>=0;i--)(n=o[i])&&(r=(t?n(e,a,r):n(r))||r);return t&&r&&y(e,a,r),r},l=(o,e)=>(a,t)=>e(a,t,o);import{inject as p,injectable as h}from"inversify";import{pkiTypes as S}from"../../pki/di/pkiTypes";import{ClearSignContextType as c}from"../../shared/model/ClearSignContext";import{trustedNameTypes as T}from"../../trusted-name/di/trustedNameTypes";const I=[c.TRUSTED_NAME];let d=class{constructor(e,a){this.certificateLoader=a;this._dataSource=e}_dataSource;canHandle(e,a){return typeof e=="object"&&e!==null&&"chainId"in e&&"domain"in e&&"challenge"in e&&"deviceModelId"in e&&e.deviceModelId!==void 0&&typeof e.chainId=="number"&&typeof e.domain=="string"&&e.domain.length>0&&typeof e.challenge=="string"&&e.challenge.length>0&&I.every(t=>a.includes(t))}async load(e){const{chainId:a,domain:t,challenge:r,deviceModelId:i}=e;return this.isDomainValid(t)?[await(await this._dataSource.getDomainNamePayload({chainId:a,domain:t,challenge:r})).caseOf({Left:s=>Promise.resolve({type:c.ERROR,error:s}),Right:async({data:s,keyId:g,keyUsage:u})=>{const f=await this.certificateLoader.loadCertificate({keyId:g,keyUsage:u,targetDevice:i});return{type:c.TRUSTED_NAME,payload:s,certificate:f}}})]:[{type:c.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}]}isDomainValid(e){const a=e.length>0&&Number(e.length)<30,t=new RegExp("^[a-zA-Z0-9\\-\\_\\.]+$").test(e);return a&&t}};d=m([h(),l(0,p(T.TrustedNameDataSource)),l(1,p(S.PkiCertificateLoader))],d);export{d as TrustedNameContextLoader};
|
|
2
2
|
//# sourceMappingURL=TrustedNameContextLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/trusted-name/domain/TrustedNameContextLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport type { TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nexport type TrustedNameContextInput = {\n chainId: number;\n domain: string;\n challenge: string;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.TRUSTED_NAME,\n];\n\n@injectable()\nexport class TrustedNameContextLoader\n implements ContextLoader<TrustedNameContextInput>\n{\n private _dataSource: TrustedNameDataSource;\n\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n dataSource: TrustedNameDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is TrustedNameContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"chainId\" in input &&\n \"domain\" in input &&\n \"challenge\" in input &&\n typeof input.chainId === \"number\" &&\n typeof input.domain === \"string\" &&\n input.domain.length > 0 &&\n typeof input.challenge === \"string\" &&\n input.challenge.length > 0 &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: TrustedNameContextInput): Promise<ClearSignContext[]> {\n const { chainId, domain, challenge } = input;\n\n if (!this.isDomainValid(domain)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ];\n }\n\n const payload = await this._dataSource.getDomainNamePayload({\n chainId,\n domain,\n challenge,\n });\n
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["inject", "injectable", "ClearSignContextType", "trustedNameTypes", "SUPPORTED_TYPES", "ClearSignContextType", "TrustedNameContextLoader", "dataSource", "input", "expectedTypes", "type", "chainId", "domain", "challenge", "error", "
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport type { TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nexport type TrustedNameContextInput = {\n chainId: number;\n domain: string;\n challenge: string;\n deviceModelId: DeviceModelId;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.TRUSTED_NAME,\n];\n\n@injectable()\nexport class TrustedNameContextLoader\n implements ContextLoader<TrustedNameContextInput>\n{\n private _dataSource: TrustedNameDataSource;\n\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n dataSource: TrustedNameDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private certificateLoader: PkiCertificateLoader,\n ) {\n this._dataSource = dataSource;\n }\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is TrustedNameContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"chainId\" in input &&\n \"domain\" in input &&\n \"challenge\" in input &&\n \"deviceModelId\" in input &&\n input.deviceModelId !== undefined &&\n typeof input.chainId === \"number\" &&\n typeof input.domain === \"string\" &&\n input.domain.length > 0 &&\n typeof input.challenge === \"string\" &&\n input.challenge.length > 0 &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: TrustedNameContextInput): Promise<ClearSignContext[]> {\n const { chainId, domain, challenge, deviceModelId } = input;\n\n if (!this.isDomainValid(domain)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ];\n }\n\n const payload = await this._dataSource.getDomainNamePayload({\n chainId,\n domain,\n challenge,\n });\n const response = await payload.caseOf({\n Left: (error): Promise<ClearSignContext> =>\n Promise.resolve({\n type: ClearSignContextType.ERROR,\n error: error,\n }),\n Right: async ({ data, keyId, keyUsage }): Promise<ClearSignContext> => {\n const certificate = await this.certificateLoader.loadCertificate({\n keyId,\n keyUsage,\n targetDevice: deviceModelId,\n });\n return {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: data,\n certificate,\n };\n },\n });\n\n return [response];\n }\n\n private isDomainValid(domain: string) {\n const lengthIsValid = domain.length > 0 && Number(domain.length) < 30;\n const containsOnlyValidChars = new RegExp(\"^[a-zA-Z0-9\\\\-\\\\_\\\\.]+$\").test(\n domain,\n );\n\n return lengthIsValid && containsOnlyValidChars;\n }\n}\n"],
|
|
5
|
+
"mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAEnC,OAAS,YAAAC,MAAgB,oBAGzB,OAEE,wBAAAC,MACK,kCAEP,OAAS,oBAAAC,MAAwB,qCASjC,MAAMC,EAA0C,CAC9CC,EAAqB,YACvB,EAGO,IAAMC,EAAN,KAEP,CAGE,YAEEC,EAEQC,EACR,CADQ,uBAAAA,EAER,KAAK,YAAcD,CACrB,CATQ,YAWR,UACEE,EACAC,EACkC,CAClC,OACE,OAAOD,GAAU,UACjBA,IAAU,MACV,YAAaA,GACb,WAAYA,GACZ,cAAeA,GACf,kBAAmBA,GACnBA,EAAM,gBAAkB,QACxB,OAAOA,EAAM,SAAY,UACzB,OAAOA,EAAM,QAAW,UACxBA,EAAM,OAAO,OAAS,GACtB,OAAOA,EAAM,WAAc,UAC3BA,EAAM,UAAU,OAAS,GACzBL,EAAgB,MAAOO,GAASD,EAAc,SAASC,CAAI,CAAC,CAEhE,CAEA,MAAM,KAAKF,EAA6D,CACtE,KAAM,CAAE,QAAAG,EAAS,OAAAC,EAAQ,UAAAC,EAAW,cAAAC,CAAc,EAAIN,EAEtD,OAAK,KAAK,cAAcI,CAAM,EAkCvB,CApBU,MALD,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAAAD,EACA,OAAAC,EACA,UAAAC,CACF,CAAC,GAC8B,OAAO,CACpC,KAAOE,GACL,QAAQ,QAAQ,CACd,KAAMX,EAAqB,MAC3B,MAAOW,CACT,CAAC,EACH,MAAO,MAAO,CAAE,KAAAC,EAAM,MAAAC,EAAO,SAAAC,CAAS,IAAiC,CACrE,MAAMC,EAAc,MAAM,KAAK,kBAAkB,gBAAgB,CAC/D,MAAAF,EACA,SAAAC,EACA,aAAcJ,CAChB,CAAC,EACD,MAAO,CACL,KAAMV,EAAqB,aAC3B,QAASY,EACT,YAAAG,CACF,CACF,CACF,CAAC,CAEe,EAjCP,CACL,CACE,KAAMf,EAAqB,MAC3B,MAAO,IAAI,MAAM,mDAAmD,CACtE,CACF,CA6BJ,CAEQ,cAAcQ,EAAgB,CACpC,MAAMQ,EAAgBR,EAAO,OAAS,GAAK,OAAOA,EAAO,MAAM,EAAI,GAC7DS,EAAyB,IAAI,OAAO,yBAAyB,EAAE,KACnET,CACF,EAEA,OAAOQ,GAAiBC,CAC1B,CACF,EAnFahB,EAANiB,EAAA,CADNC,EAAW,EAOPC,EAAA,EAAAC,EAAOC,EAAiB,qBAAqB,GAE7CF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAR5BtB",
|
|
6
|
+
"names": ["inject", "injectable", "pkiTypes", "ClearSignContextType", "trustedNameTypes", "SUPPORTED_TYPES", "ClearSignContextType", "TrustedNameContextLoader", "dataSource", "certificateLoader", "input", "expectedTypes", "type", "chainId", "domain", "challenge", "deviceModelId", "error", "data", "keyId", "keyUsage", "certificate", "lengthIsValid", "containsOnlyValidChars", "__decorateClass", "injectable", "__decorateParam", "inject", "trustedNameTypes", "pkiTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as
|
|
1
|
+
import{DeviceModelId as o}from"@ledgerhq/device-management-kit";import{Left as c,Right as s}from"purify-ts";import{ClearSignContextType as n}from"../../shared/model/ClearSignContext";import{TrustedNameContextLoader as u}from"../../trusted-name/domain/TrustedNameContextLoader";describe("TrustedNameContextLoader",()=>{const d={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()},i={loadCertificate:vi.fn()},a=new u(d,i),l={keyUsageNumber:1,payload:new Uint8Array([1,2,3,4])};beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(d,"getDomainNamePayload").mockResolvedValue(s({data:"payload",keyId:"testKeyId",keyUsage:"testKeyUsage"}))}),describe("canHandle function",()=>{const e={chainId:1,domain:"hello.eth",challenge:"challenge",deviceModelId:o.STAX};it("should return true for valid input",()=>{expect(a.canHandle(e,[n.TRUSTED_NAME])).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(a.canHandle(e,[n.TOKEN])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"]])("should return false for %s",(t,r)=>{expect(a.canHandle(t,[n.TRUSTED_NAME])).toBe(!1)}),it.each([[{...e,chainId:void 0},"missing chainId"],[{...e,domain:void 0},"missing domain"],[{...e,challenge:void 0},"missing challenge"],[{...e,deviceModelId:void 0},"missing device model"]])("should return false for %s",(t,r)=>{expect(a.canHandle(t,[n.TRUSTED_NAME])).toBe(!1)}),it.each([[{...e,domain:""},"empty domain"],[{...e,challenge:""},"empty challenge"],[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"],[{...e,domain:123},"numeric domain"],[{...e,challenge:123},"numeric challenge"]])("should return false for %s",(t,r)=>{expect(a.canHandle(t,[n.TRUSTED_NAME])).toBe(!1)})}),describe("load function",()=>{it("should return an error when domain > max length",async()=>{const e={chainId:1,domain:"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength",challenge:"challenge",deviceModelId:o.STAX},t=await a.load(e);expect(i.loadCertificate).not.toHaveBeenCalled(),expect(t).toEqual([{type:n.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return an error when domain is not valid",async()=>{const e={chainId:1,domain:"hello\u{1F44B}",challenge:"challenge",deviceModelId:o.STAX},t=await a.load(e);expect(i.loadCertificate).not.toHaveBeenCalled(),expect(t).toEqual([{type:n.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return a payload",async()=>{vi.spyOn(i,"loadCertificate").mockResolvedValue(l);const e={chainId:1,domain:"hello.eth",challenge:"challenge",deviceModelId:o.STAX},t=await a.load(e);expect(i.loadCertificate).toHaveBeenCalledWith({keyId:"testKeyId",keyUsage:"testKeyUsage",targetDevice:o.STAX}),expect(t).toEqual([{type:n.TRUSTED_NAME,payload:"payload",certificate:l}])}),it("should return an error when unable to fetch the datasource",async()=>{const e={chainId:1,domain:"hello.eth",challenge:"challenge",deviceModelId:o.STAX};vi.spyOn(d,"getDomainNamePayload").mockResolvedValue(c(new Error("error")));const t=await a.load(e);expect(t).toEqual([{type:n.ERROR,error:new Error("error")}])})})});
|
|
2
2
|
//# sourceMappingURL=TrustedNameContextLoader.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/trusted-name/domain/TrustedNameContextLoader.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport {\n type TrustedNameContextInput,\n TrustedNameContextLoader,\n} from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\ndescribe(\"TrustedNameContextLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Right(\"payload\"));\n });\n\n describe(\"canHandle function\", () => {\n const validInput: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello.eth\",\n challenge: \"challenge\",\n };\n\n it(\"should return true for valid input\", () => {\n expect(\n loader.canHandle(validInput, [ClearSignContextType.TRUSTED_NAME]),\n ).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 });\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, [ClearSignContextType.TRUSTED_NAME])).toBe(\n false,\n );\n });\n\n it.each([\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, domain: undefined }, \"missing domain\"],\n [{ ...validInput, challenge: undefined }, \"missing challenge\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, [ClearSignContextType.TRUSTED_NAME])).toBe(\n false,\n );\n });\n\n it.each([\n [{ ...validInput, domain: \"\" }, \"empty domain\"],\n [{ ...validInput, challenge: \"\" }, \"empty challenge\"],\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [{ ...validInput, domain: 123 }, \"numeric domain\"],\n [{ ...validInput, challenge: 123 }, \"numeric challenge\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, [ClearSignContextType.TRUSTED_NAME])).toBe(\n false,\n );\n });\n });\n\n describe(\"load function\", () => {\n it(\"should return an error when domain > max length\", async () => {\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength\",\n challenge: \"challenge\",\n };\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return an error when domain is not valid\", async () => {\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello\uD83D\uDC4B\",\n challenge: \"challenge\",\n };\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return a payload\", async () => {\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello.eth\",\n challenge: \"challenge\",\n };\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n },\n ]);\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello.eth\",\n challenge: \"challenge\",\n };\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,
|
|
6
|
-
"names": ["Left", "Right", "ClearSignContextType", "TrustedNameContextLoader", "mockTrustedNameDataSource", "loader", "validInput", "input", "_description", "result"]
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport {\n type TrustedNameContextInput,\n TrustedNameContextLoader,\n} from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\ndescribe(\"TrustedNameContextLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n const mockCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n const loader = new TrustedNameContextLoader(\n mockTrustedNameDataSource,\n mockCertificateLoader,\n );\n\n const mockCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3, 4]),\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(\n Right({\n data: \"payload\",\n keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n }),\n );\n });\n\n describe(\"canHandle function\", () => {\n const validInput: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello.eth\",\n challenge: \"challenge\",\n deviceModelId: DeviceModelId.STAX,\n };\n\n it(\"should return true for valid input\", () => {\n expect(\n loader.canHandle(validInput, [ClearSignContextType.TRUSTED_NAME]),\n ).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 });\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, [ClearSignContextType.TRUSTED_NAME])).toBe(\n false,\n );\n });\n\n it.each([\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, domain: undefined }, \"missing domain\"],\n [{ ...validInput, challenge: undefined }, \"missing challenge\"],\n [{ ...validInput, deviceModelId: undefined }, \"missing device model\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, [ClearSignContextType.TRUSTED_NAME])).toBe(\n false,\n );\n });\n\n it.each([\n [{ ...validInput, domain: \"\" }, \"empty domain\"],\n [{ ...validInput, challenge: \"\" }, \"empty challenge\"],\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [{ ...validInput, domain: 123 }, \"numeric domain\"],\n [{ ...validInput, challenge: 123 }, \"numeric challenge\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, [ClearSignContextType.TRUSTED_NAME])).toBe(\n false,\n );\n });\n });\n\n describe(\"load function\", () => {\n it(\"should return an error when domain > max length\", async () => {\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength\",\n challenge: \"challenge\",\n deviceModelId: DeviceModelId.STAX,\n };\n\n const result = await loader.load(input);\n\n expect(mockCertificateLoader.loadCertificate).not.toHaveBeenCalled();\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return an error when domain is not valid\", async () => {\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello\uD83D\uDC4B\",\n challenge: \"challenge\",\n deviceModelId: DeviceModelId.STAX,\n };\n\n const result = await loader.load(input);\n\n expect(mockCertificateLoader.loadCertificate).not.toHaveBeenCalled();\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return a payload\", async () => {\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n mockCertificate,\n );\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello.eth\",\n challenge: \"challenge\",\n deviceModelId: DeviceModelId.STAX,\n };\n\n const result = await loader.load(input);\n\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: \"testKeyId\",\n keyUsage: \"testKeyUsage\",\n targetDevice: DeviceModelId.STAX,\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n certificate: mockCertificate,\n },\n ]);\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const input: TrustedNameContextInput = {\n chainId: 1,\n domain: \"hello.eth\",\n challenge: \"challenge\",\n deviceModelId: DeviceModelId.STAX,\n };\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAI5B,OAAS,wBAAAC,MAA4B,kCAErC,OAEE,4BAAAC,MACK,iDAEP,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAmD,CACvD,qBAAsB,GAAG,GAAG,EAC5B,sBAAuB,GAAG,GAAG,CAC/B,EACMC,EAA8C,CAClD,gBAAiB,GAAG,GAAG,CACzB,EACMC,EAAS,IAAIH,EACjBC,EACAC,CACF,EAEME,EAAkC,CACtC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAG,EAAG,EAAG,CAAC,CAAC,CACtC,EAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MACDH,EACA,sBACF,EAAE,kBACAH,EAAM,CACJ,KAAM,UACN,MAAO,YACP,SAAU,cACZ,CAAC,CACH,CACF,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,MAAMO,EAAsC,CAC1C,QAAS,EACT,OAAQ,YACR,UAAW,YACX,cAAeT,EAAc,IAC/B,EAEA,GAAG,qCAAsC,IAAM,CAC7C,OACEO,EAAO,UAAUE,EAAY,CAACN,EAAqB,YAAY,CAAC,CACl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,UAAW,YACX,cAAeV,EAAc,IAC/B,EAGA,GAAG,MACDK,EACA,sBACF,EAAE,kBAAkBJ,EAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EAC5C,MAAMW,EAAS,MAAML,EAAO,KAAKG,CAAK,EAGtC,OAAOE,CAAM,EAAE,QAAQ,CACrB,CAAE,KAAMT,EAAqB,MAAO,MAAO,IAAI,MAAM,OAAO,CAAE,CAChE,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["DeviceModelId", "Left", "Right", "ClearSignContextType", "TrustedNameContextLoader", "mockTrustedNameDataSource", "mockCertificateLoader", "loader", "mockCertificate", "validInput", "input", "_description", "result"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Either } from "purify-ts";
|
|
2
2
|
import type { ContextModuleConfig } from "../../config/model/ContextModuleConfig";
|
|
3
|
-
import { GetDomainNameInfosParams, GetTrustedNameInfosParams, TrustedNameDataSource } from "../../trusted-name/data/TrustedNameDataSource";
|
|
3
|
+
import { GetDomainNameInfosParams, GetTrustedNameInfosParams, TrustedNameDataSource, TrustedNamePayload } from "../../trusted-name/data/TrustedNameDataSource";
|
|
4
4
|
export declare class HttpTrustedNameDataSource implements TrustedNameDataSource {
|
|
5
5
|
private readonly config;
|
|
6
6
|
constructor(config: ContextModuleConfig);
|
|
7
|
-
getDomainNamePayload({ chainId, domain, challenge, }: GetDomainNameInfosParams): Promise<Either<Error,
|
|
8
|
-
getTrustedNamePayload({ chainId, address, challenge, sources, types, }: GetTrustedNameInfosParams): Promise<Either<Error,
|
|
7
|
+
getDomainNamePayload({ chainId, domain, challenge, }: GetDomainNameInfosParams): Promise<Either<Error, TrustedNamePayload>>;
|
|
8
|
+
getTrustedNamePayload({ chainId, address, challenge, sources, types, }: GetTrustedNameInfosParams): Promise<Either<Error, TrustedNamePayload>>;
|
|
9
9
|
private formatTrustedName;
|
|
10
|
+
/**
|
|
11
|
+
* Type guard to validate ProxyDelegateCallDto
|
|
12
|
+
*/
|
|
13
|
+
private isTrustedNameDto;
|
|
10
14
|
}
|
|
11
15
|
//# sourceMappingURL=HttpTrustedNameDataSource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpTrustedNameDataSource.d.ts","sourceRoot":"","sources":["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAe,MAAM,WAAW,CAAC;AAGhD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAK9E,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"HttpTrustedNameDataSource.d.ts","sourceRoot":"","sources":["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAe,MAAM,WAAW,CAAC;AAGhD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAK9E,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,2CAA2C,CAAC;AAKnD,qBACa,yBAA0B,YAAW,qBAAqB;IAEvC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,mBAAmB;IAG7D,oBAAoB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,SAAS,GACV,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IA6C3D,qBAAqB,CAAC,EACjC,OAAO,EACP,OAAO,EACP,SAAS,EACT,OAAO,EACP,KAAK,GACN,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IA8DzE,OAAO,CAAC,iBAAiB;IAUzB;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAiBzB"}
|
|
@@ -11,8 +11,13 @@ export type GetTrustedNameInfosParams = {
|
|
|
11
11
|
types: string[];
|
|
12
12
|
sources: string[];
|
|
13
13
|
};
|
|
14
|
+
export type TrustedNamePayload = {
|
|
15
|
+
data: string;
|
|
16
|
+
keyId: string;
|
|
17
|
+
keyUsage: string;
|
|
18
|
+
};
|
|
14
19
|
export interface TrustedNameDataSource {
|
|
15
|
-
getDomainNamePayload(params: GetDomainNameInfosParams): Promise<Either<Error,
|
|
16
|
-
getTrustedNamePayload(params: GetTrustedNameInfosParams): Promise<Either<Error,
|
|
20
|
+
getDomainNamePayload(params: GetDomainNameInfosParams): Promise<Either<Error, TrustedNamePayload>>;
|
|
21
|
+
getTrustedNamePayload(params: GetTrustedNameInfosParams): Promise<Either<Error, TrustedNamePayload>>;
|
|
17
22
|
}
|
|
18
23
|
//# sourceMappingURL=TrustedNameDataSource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrustedNameDataSource.d.ts","sourceRoot":"","sources":["../../../../../src/trusted-name/data/TrustedNameDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,oBAAoB,CAClB,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"TrustedNameDataSource.d.ts","sourceRoot":"","sources":["../../../../../src/trusted-name/data/TrustedNameDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,oBAAoB,CAClB,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAE9C,qBAAqB,CACnB,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC;CAC/C"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
export type TrustedNameSignatures = {
|
|
2
|
-
prod: string;
|
|
3
|
-
test?: string;
|
|
4
|
-
} | {
|
|
5
2
|
prod?: string;
|
|
6
|
-
test
|
|
3
|
+
test?: string;
|
|
7
4
|
};
|
|
8
5
|
export type TrustedNameDescriptor = {
|
|
9
6
|
data: string;
|
|
10
|
-
signatures
|
|
7
|
+
signatures: TrustedNameSignatures;
|
|
11
8
|
};
|
|
12
9
|
export type TrustedNameDto = {
|
|
13
10
|
signedDescriptor: TrustedNameDescriptor;
|
|
11
|
+
keyId: string;
|
|
12
|
+
keyUsage: string;
|
|
14
13
|
};
|
|
15
14
|
//# sourceMappingURL=TrustedNameDto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrustedNameDto.d.ts","sourceRoot":"","sources":["../../../../../src/trusted-name/data/TrustedNameDto.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"TrustedNameDto.d.ts","sourceRoot":"","sources":["../../../../../src/trusted-name/data/TrustedNameDto.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,qBAAqB,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,gBAAgB,EAAE,qBAAqB,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DeviceModelId } from "@ledgerhq/device-management-kit";
|
|
2
|
+
import { type PkiCertificateLoader } from "../../pki/domain/PkiCertificateLoader";
|
|
1
3
|
import { ContextFieldLoader } from "../../shared/domain/ContextFieldLoader";
|
|
2
4
|
import { ClearSignContext, ClearSignContextType } from "../../shared/model/ClearSignContext";
|
|
3
5
|
import * as TrustedNameDataSource from "../../trusted-name/data/TrustedNameDataSource";
|
|
@@ -7,10 +9,12 @@ type TrustedNameFieldInput = {
|
|
|
7
9
|
challenge: string;
|
|
8
10
|
types: string[];
|
|
9
11
|
sources: string[];
|
|
12
|
+
deviceModelId: DeviceModelId;
|
|
10
13
|
};
|
|
11
14
|
export declare class TrustedNameContextFieldLoader implements ContextFieldLoader<TrustedNameFieldInput> {
|
|
12
15
|
private _dataSource;
|
|
13
|
-
|
|
16
|
+
private _certificateLoader;
|
|
17
|
+
constructor(_dataSource: TrustedNameDataSource.TrustedNameDataSource, _certificateLoader: PkiCertificateLoader);
|
|
14
18
|
canHandle(input: unknown, expectedType: ClearSignContextType): input is TrustedNameFieldInput;
|
|
15
19
|
loadField(input: TrustedNameFieldInput): Promise<ClearSignContext>;
|
|
16
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrustedNameContextFieldLoader.d.ts","sourceRoot":"","sources":["../../../../../src/trusted-name/domain/TrustedNameContextFieldLoader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TrustedNameContextFieldLoader.d.ts","sourceRoot":"","sources":["../../../../../src/trusted-name/domain/TrustedNameContextFieldLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAIhE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,qBAAqB,MAAM,2CAA2C,CAAC;AAGnF,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,qBACa,6BACX,YAAW,kBAAkB,CAAC,qBAAqB,CAAC;IAIlD,OAAO,CAAC,WAAW;IAEnB,OAAO,CAAC,kBAAkB;gBAFlB,WAAW,EAAE,qBAAqB,CAAC,qBAAqB,EAExD,kBAAkB,EAAE,oBAAoB;IAGlD,SAAS,CACP,KAAK,EAAE,OAAO,EACd,YAAY,EAAE,oBAAoB,GACjC,KAAK,IAAI,qBAAqB;IAe3B,SAAS,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA4BzE"}
|