@ledgerhq/context-module 1.11.1 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
- package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
- package/lib/cjs/src/DefaultContextModule.test.js +1 -1
- package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
- package/lib/cjs/src/config/di/configTypes.js +1 -1
- package/lib/cjs/src/config/di/configTypes.js.map +2 -2
- package/lib/cjs/src/config/model/ContextModuleBuildArgs.js +1 -1
- package/lib/cjs/src/config/model/ContextModuleBuildArgs.js.map +1 -1
- package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
- package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
- package/lib/cjs/src/di.js +1 -1
- package/lib/cjs/src/di.js.map +3 -3
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +1 -1
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +2 -2
- package/lib/cjs/src/shared/utils/NullLoggerPublisherService.js +2 -0
- package/lib/cjs/src/shared/utils/NullLoggerPublisherService.js.map +7 -0
- package/lib/cjs/src/shared/utils/NullLoggerPublisherService.test.js +2 -0
- package/lib/cjs/src/shared/utils/NullLoggerPublisherService.test.js.map +7 -0
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js +1 -1
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js.map +3 -3
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js +1 -1
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js.map +3 -3
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.js +1 -1
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.js.map +3 -3
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.test.js +1 -1
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.test.js.map +3 -3
- package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.js +1 -1
- package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.js.map +3 -3
- package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.test.js +1 -1
- package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.test.js.map +3 -3
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.js +1 -1
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.js.map +3 -3
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js +1 -1
- package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js.map +3 -3
- package/lib/cjs/src/typed-data/data/FiltersDto.js.map +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +2 -2
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +2 -2
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/ContextModuleBuilder.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
- package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
- package/lib/esm/src/DefaultContextModule.test.js +1 -1
- package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
- package/lib/esm/src/config/di/configTypes.js +1 -1
- package/lib/esm/src/config/di/configTypes.js.map +2 -2
- package/lib/esm/src/di.js +1 -1
- package/lib/esm/src/di.js.map +3 -3
- package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +2 -2
- package/lib/esm/src/shared/utils/NullLoggerPublisherService.js +2 -0
- package/lib/esm/src/shared/utils/NullLoggerPublisherService.js.map +7 -0
- package/lib/esm/src/shared/utils/NullLoggerPublisherService.test.js +2 -0
- package/lib/esm/src/shared/utils/NullLoggerPublisherService.test.js.map +7 -0
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js +1 -1
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js.map +3 -3
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js +1 -1
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js.map +3 -3
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.js +1 -1
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.js.map +3 -3
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.test.js +1 -1
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.test.js.map +3 -3
- package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.js +1 -1
- package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.js.map +3 -3
- package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.test.js +1 -1
- package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.test.js.map +3 -3
- package/lib/esm/src/token/domain/TokenContextFieldLoader.js +1 -1
- package/lib/esm/src/token/domain/TokenContextFieldLoader.js.map +3 -3
- package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js +1 -1
- package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js.map +3 -3
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +2 -2
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +2 -2
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
- package/lib/types/src/ContextModuleBuilder.d.ts +9 -1
- package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
- package/lib/types/src/config/di/configTypes.d.ts +1 -0
- package/lib/types/src/config/di/configTypes.d.ts.map +1 -1
- package/lib/types/src/config/model/ContextModuleBuildArgs.d.ts +2 -0
- package/lib/types/src/config/model/ContextModuleBuildArgs.d.ts.map +1 -1
- package/lib/types/src/config/model/ContextModuleConfig.d.ts +2 -0
- package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +2 -0
- package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -1
- package/lib/types/src/shared/utils/NullLoggerPublisherService.d.ts +3 -0
- package/lib/types/src/shared/utils/NullLoggerPublisherService.d.ts.map +1 -0
- package/lib/types/src/shared/utils/NullLoggerPublisherService.test.d.ts +2 -0
- package/lib/types/src/shared/utils/NullLoggerPublisherService.test.d.ts.map +1 -0
- package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts +3 -1
- package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts.map +1 -1
- package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.d.ts +3 -1
- package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.d.ts.map +1 -1
- package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.d.ts +3 -2
- package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.d.ts.map +1 -1
- package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts +5 -1
- package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/FiltersDto.d.ts +0 -4
- package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
- package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -5
package/lib/cjs/package.json
CHANGED
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
59
59
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
60
60
|
},
|
|
61
|
-
"version": "1.
|
|
61
|
+
"version": "1.12.0"
|
|
62
62
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var l=(t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})},C=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of u(e))!g.call(t,r)&&r!==o&&i(t,r,{get:()=>e[r],enumerable:!(n=c(e,r))||n.enumerable});return t};var f=t=>C(i({},"__esModule",{value:!0}),t);var x={};l(x,{ContextModuleBuilder:()=>L,DEFAULT_CONFIG:()=>d});module.exports=f(x);var a=require("./shared/utils/NullLoggerPublisherService"),s=require("./DefaultContextModule");const p="https://crypto-assets-service.api.ledger.com/v1",h="https://web3checks-backend.api.ledger.com/v3",m="https://nft.api.live.ledger.com",d={cal:{url:p,mode:"prod",branch:"main"},web3checks:{url:h},metadataServiceDomain:{url:m},defaultLoaders:!0,customLoaders:[],defaultFieldLoaders:!0,customFieldLoaders:[],customTypedDataLoader:void 0,customSolanaLoader:void 0,loggerFactory:a.NullLoggerPublisherService};class L{config=d;originToken;constructor({originToken:e,loggerFactory:o}={}){this.originToken=e,o&&(this.config.loggerFactory=o)}removeDefaultLoaders(){return this.config.defaultLoaders=!1,this}addLoader(e){return this.config.customLoaders.push(e),this}addTypedDataLoader(e){return this.config.customTypedDataLoader=e,this}addSolanaLoader(e){return this.config.customSolanaLoader=e,this}setCalConfig(e){return this.config.cal=e,this}setMetadataServiceConfig(e){return this.config.metadataServiceDomain=e,this}setWeb3ChecksConfig(e){return this.config.web3checks=e,this}setDatasourceConfig(e){return this.config.datasource=e,this}setLoggerFactory(e){return this.config.loggerFactory=e,this}build(){const e={...this.config,originToken:this.originToken};return new s.DefaultContextModule(e)}}0&&(module.exports={ContextModuleBuilder,DEFAULT_CONFIG});
|
|
2
2
|
//# sourceMappingURL=ContextModuleBuilder.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ContextModuleBuilder.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n type ContextModuleWeb3ChecksConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { type SolanaContextLoader } from \"./solana/domain/SolanaContextLoader\";\nimport { type TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst DEFAULT_CAL_URL = \"https://crypto-assets-service.api.ledger.com/v1\";\nconst DEFAULT_WEB3_CHECKS_URL = \"https://web3checks-backend.api.ledger.com/v3\";\nconst DEFAULT_METADATA_SERVICE_DOMAIN = \"https://nft.api.live.ledger.com\";\n\nexport const DEFAULT_CONFIG: ContextModuleConfig = {\n cal: {\n url: DEFAULT_CAL_URL,\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: DEFAULT_WEB3_CHECKS_URL,\n },\n metadataServiceDomain: {\n url: DEFAULT_METADATA_SERVICE_DOMAIN,\n },\n defaultLoaders: true,\n customLoaders: [],\n defaultFieldLoaders: true,\n customFieldLoaders: [],\n customTypedDataLoader: undefined,\n customSolanaLoader: undefined,\n};\n\nexport class ContextModuleBuilder {\n private config: ContextModuleConfig = DEFAULT_CONFIG;\n private originToken?: string;\n\n constructor({
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,mBAAAC,IAAA,eAAAC,EAAAJ,
|
|
6
|
-
"names": ["ContextModuleBuilder_exports", "__export", "ContextModuleBuilder", "DEFAULT_CONFIG", "__toCommonJS", "import_DefaultContextModule", "DEFAULT_CAL_URL", "DEFAULT_WEB3_CHECKS_URL", "DEFAULT_METADATA_SERVICE_DOMAIN", "originToken", "loader", "calConfig", "metadataServiceConfig", "web3ChecksConfig", "datasourceConfig", "config"]
|
|
4
|
+
"sourcesContent": ["import { type LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\n\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n type ContextModuleWeb3ChecksConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { NullLoggerPublisherService } from \"./shared/utils/NullLoggerPublisherService\";\nimport { type SolanaContextLoader } from \"./solana/domain/SolanaContextLoader\";\nimport { type TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst DEFAULT_CAL_URL = \"https://crypto-assets-service.api.ledger.com/v1\";\nconst DEFAULT_WEB3_CHECKS_URL = \"https://web3checks-backend.api.ledger.com/v3\";\nconst DEFAULT_METADATA_SERVICE_DOMAIN = \"https://nft.api.live.ledger.com\";\n\nexport const DEFAULT_CONFIG: ContextModuleConfig = {\n cal: {\n url: DEFAULT_CAL_URL,\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: DEFAULT_WEB3_CHECKS_URL,\n },\n metadataServiceDomain: {\n url: DEFAULT_METADATA_SERVICE_DOMAIN,\n },\n defaultLoaders: true,\n customLoaders: [],\n defaultFieldLoaders: true,\n customFieldLoaders: [],\n customTypedDataLoader: undefined,\n customSolanaLoader: undefined,\n loggerFactory: NullLoggerPublisherService,\n};\n\nexport class ContextModuleBuilder {\n private config: ContextModuleConfig = DEFAULT_CONFIG;\n private originToken?: string;\n\n constructor({\n originToken,\n loggerFactory,\n }: ContextModuleConstructorArgs = {}) {\n this.originToken = originToken;\n\n if (loggerFactory) {\n this.config.loggerFactory = loggerFactory;\n }\n }\n\n /**\n * Remove default loaders from the list of loaders\n *\n * @returns this\n */\n removeDefaultLoaders() {\n this.config.defaultLoaders = false;\n return this;\n }\n\n /**\n * Add a custom loader to the list of loaders\n *\n * @param loader loader to add to the list of loaders\n * @returns this\n */\n addLoader(loader: ContextLoader) {\n this.config.customLoaders.push(loader);\n return this;\n }\n\n /**\n * Replace the default loader for typed data clear signing contexts\n *\n * @param loader loader to use for typed data clear signing contexts\n * @returns this\n */\n addTypedDataLoader(loader: TypedDataContextLoader) {\n this.config.customTypedDataLoader = loader;\n return this;\n }\n\n /**\n * Replace the default loader for Solana context\n *\n * @param loader loader to use for Solana context\n * @returns this\n */\n addSolanaLoader(loader: SolanaContextLoader) {\n this.config.customSolanaLoader = loader;\n return this;\n }\n\n /**\n * Add a custom CAL configuration\n *\n * @param calConfig\n * @returns this\n */\n setCalConfig(calConfig: ContextModuleCalConfig) {\n this.config.cal = calConfig;\n return this;\n }\n\n /**\n * Add a custom metadata service configuration\n *\n * @param metadataServiceConfig\n * @returns this\n */\n setMetadataServiceConfig(\n metadataServiceConfig: ContextModuleMetadataServiceConfig,\n ) {\n this.config.metadataServiceDomain = metadataServiceConfig;\n return this;\n }\n\n /**\n * Add a custom web3 checks configuration\n *\n * @param web3ChecksConfig\n * @returns this\n */\n setWeb3ChecksConfig(web3ChecksConfig: ContextModuleWeb3ChecksConfig) {\n this.config.web3checks = web3ChecksConfig;\n return this;\n }\n\n /**\n * Add datasource configuration\n *\n * @param datasourceConfig\n * @returns this\n */\n setDatasourceConfig(datasourceConfig: ContextModuleDatasourceConfig) {\n this.config.datasource = datasourceConfig;\n return this;\n }\n\n /**\n * Set a custom logger factory\n *\n * @param loggerFactory\n * @returns this\n */\n setLoggerFactory(loggerFactory: (tag: string) => LoggerPublisherService) {\n this.config.loggerFactory = loggerFactory;\n return this;\n }\n\n /**\n * Build the context module\n *\n * @returns the context module\n */\n build(): ContextModule {\n const config = { ...this.config, originToken: this.originToken };\n return new DefaultContextModule(config);\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,mBAAAC,IAAA,eAAAC,EAAAJ,GAWA,IAAAK,EAA2C,qDAI3CC,EAAqC,kCAErC,MAAMC,EAAkB,kDAClBC,EAA0B,+CAC1BC,EAAkC,kCAE3BN,EAAsC,CACjD,IAAK,CACH,IAAKI,EACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAKC,CACP,EACA,sBAAuB,CACrB,IAAKC,CACP,EACA,eAAgB,GAChB,cAAe,CAAC,EAChB,oBAAqB,GACrB,mBAAoB,CAAC,EACrB,sBAAuB,OACvB,mBAAoB,OACpB,cAAe,4BACjB,EAEO,MAAMP,CAAqB,CACxB,OAA8BC,EAC9B,YAER,YAAY,CACV,YAAAO,EACA,cAAAC,CACF,EAAkC,CAAC,EAAG,CACpC,KAAK,YAAcD,EAEfC,IACF,KAAK,OAAO,cAAgBA,EAEhC,CAOA,sBAAuB,CACrB,YAAK,OAAO,eAAiB,GACtB,IACT,CAQA,UAAUC,EAAuB,CAC/B,YAAK,OAAO,cAAc,KAAKA,CAAM,EAC9B,IACT,CAQA,mBAAmBA,EAAgC,CACjD,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,gBAAgBA,EAA6B,CAC3C,YAAK,OAAO,mBAAqBA,EAC1B,IACT,CAQA,aAAaC,EAAmC,CAC9C,YAAK,OAAO,IAAMA,EACX,IACT,CAQA,yBACEC,EACA,CACA,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,oBAAoBC,EAAiD,CACnE,YAAK,OAAO,WAAaA,EAClB,IACT,CAQA,oBAAoBC,EAAiD,CACnE,YAAK,OAAO,WAAaA,EAClB,IACT,CAQA,iBAAiBL,EAAwD,CACvE,YAAK,OAAO,cAAgBA,EACrB,IACT,CAOA,OAAuB,CACrB,MAAMM,EAAS,CAAE,GAAG,KAAK,OAAQ,YAAa,KAAK,WAAY,EAC/D,OAAO,IAAI,uBAAqBA,CAAM,CACxC,CACF",
|
|
6
|
+
"names": ["ContextModuleBuilder_exports", "__export", "ContextModuleBuilder", "DEFAULT_CONFIG", "__toCommonJS", "import_NullLoggerPublisherService", "import_DefaultContextModule", "DEFAULT_CAL_URL", "DEFAULT_WEB3_CHECKS_URL", "DEFAULT_METADATA_SERVICE_DOMAIN", "originToken", "loggerFactory", "loader", "calConfig", "metadataServiceConfig", "web3ChecksConfig", "datasourceConfig", "config"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var s=require("./config/di/configTypes"),c=require("./ContextModuleBuilder"),
|
|
1
|
+
"use strict";var s=require("./config/di/configTypes"),c=require("./ContextModuleBuilder"),a=require("./DefaultContextModule");describe("ContextModuleBuilder",()=>{const i={url:"https://cal/v1",mode:"prod",branch:"main"},u={url:"https://web3checks/v1"},r={originToken:"test"};beforeEach(()=>{vi.resetAllMocks()}),it("should return a default context module",()=>{const e=new c.ContextModuleBuilder(r).build();expect(e).toBeInstanceOf(a.DefaultContextModule)}),it("should return a custom context module",()=>{const t=new c.ContextModuleBuilder(r),e={load:vi.fn(),canHandle:vi.fn()},o=t.removeDefaultLoaders().addLoader(e).build();expect(o).toBeInstanceOf(a.DefaultContextModule)}),it("should return a custom context module with a custom typed data loader",()=>{const t=new c.ContextModuleBuilder(r),e={load:vi.fn()},o=t.removeDefaultLoaders().addTypedDataLoader(e).build();expect(o).toBeInstanceOf(a.DefaultContextModule),expect(o._typedDataLoader).toBe(e)}),it("should return a custom context module with a custom config",()=>{const e=new c.ContextModuleBuilder(r).setCalConfig(i).setWeb3ChecksConfig(u).build(),o=e._container.get(s.configTypes.Config);expect(e).toBeInstanceOf(a.DefaultContextModule),expect(o.cal).toEqual(i),expect(o.web3checks).toEqual(u)}),it("should not throw an error if origin token is provided",()=>{const t=new c.ContextModuleBuilder(r);expect(()=>t.build()).not.toThrow()}),describe("setMetadataServiceConfig",()=>{it("should set the metadata service configuration",()=>{const t=new c.ContextModuleBuilder(r),e={url:"https://custom-metadata-service.com/v3"},o=t.setMetadataServiceConfig(e).build(),n=o._container.get(s.configTypes.Config);expect(o).toBeInstanceOf(a.DefaultContextModule),expect(n.metadataServiceDomain).toEqual(e)}),it("should override the default metadata service configuration",()=>{const t=new c.ContextModuleBuilder(r),e={url:"https://override-metadata-service.com/v1"},n=t.setMetadataServiceConfig(e).build()._container.get(s.configTypes.Config);expect(n.metadataServiceDomain.url).toBe(e.url),expect(n.metadataServiceDomain.url).not.toBe("https://nft.api.live.ledger.com/v2")})}),describe("setCalConfig",()=>{it("should set the CAL configuration",()=>{const t=new c.ContextModuleBuilder(r),e={url:"https://custom-cal-service.com/v2",mode:"test",branch:"next"},o=t.setCalConfig(e).build(),n=o._container.get(s.configTypes.Config);expect(o).toBeInstanceOf(a.DefaultContextModule),expect(n.cal).toEqual(e)}),it("should override the default CAL configuration",()=>{const t=new c.ContextModuleBuilder(r),e={url:"https://override-cal-service.com/v1",mode:"prod",branch:"demo"},n=t.setCalConfig(e).build()._container.get(s.configTypes.Config);expect(n.cal.url).toBe(e.url),expect(n.cal.mode).toBe(e.mode),expect(n.cal.branch).toBe(e.branch),expect(n.cal.url).not.toBe("https://crypto-assets-service.api.ledger.com/v1")})}),describe("setWeb3ChecksConfig",()=>{it("should set the web3 checks configuration",()=>{const t=new c.ContextModuleBuilder(r),e={url:"https://custom-web3checks-service.com/v4"},o=t.setWeb3ChecksConfig(e).build(),n=o._container.get(s.configTypes.Config);expect(o).toBeInstanceOf(a.DefaultContextModule),expect(n.web3checks).toEqual(e)}),it("should override the default web3 checks configuration",()=>{const t=new c.ContextModuleBuilder(r),e={url:"https://override-web3checks-service.com/v2"},n=t.setWeb3ChecksConfig(e).build()._container.get(s.configTypes.Config);expect(n.web3checks.url).toBe(e.url),expect(n.web3checks.url).not.toBe("https://web3checks-backend.api.ledger.com/v3")})}),describe("setDatasourceConfig",()=>{it("should set the datasource configuration with safe proxy",()=>{const t=new c.ContextModuleBuilder(r),e={proxy:"safe"},o=t.setDatasourceConfig(e).build(),n=o._container.get(s.configTypes.Config);expect(o).toBeInstanceOf(a.DefaultContextModule),expect(n.datasource).toEqual(e),expect(n.datasource?.proxy).toBe("safe")}),it("should set the datasource configuration with default proxy",()=>{const t=new c.ContextModuleBuilder(r),e={proxy:"default"},o=t.setDatasourceConfig(e).build(),n=o._container.get(s.configTypes.Config);expect(o).toBeInstanceOf(a.DefaultContextModule),expect(n.datasource).toEqual(e),expect(n.datasource?.proxy).toBe("default")}),it("should override the default datasource configuration",()=>{const t=new c.ContextModuleBuilder(r),e={proxy:"safe"},n=t.setDatasourceConfig(e).build()._container.get(s.configTypes.Config);expect(n.datasource?.proxy).toBe("safe"),expect(n.datasource).not.toBeUndefined()}),it("should set an empty datasource configuration",()=>{const t=new c.ContextModuleBuilder(r),e={},o=t.setDatasourceConfig(e).build(),n=o._container.get(s.configTypes.Config);expect(o).toBeInstanceOf(a.DefaultContextModule),expect(n.datasource).toEqual(e),expect(n.datasource?.proxy).toBeUndefined()})}),describe("loggerFactory",()=>{it("should set the loggerFactory when provided in the constructor",()=>{const t=vi.fn(),o=new c.ContextModuleBuilder({...r,loggerFactory:t}).build(),n=o._container.get(s.configTypes.Config);expect(o).toBeInstanceOf(a.DefaultContextModule),expect(n.loggerFactory).toBe(t)}),it("should set the loggerFactory via setLoggerFactory",()=>{const t=vi.fn(),o=new c.ContextModuleBuilder(r).setLoggerFactory(t).build(),n=o._container.get(s.configTypes.Config);expect(o).toBeInstanceOf(a.DefaultContextModule),expect(n.loggerFactory).toBe(t)}),it("should override constructor loggerFactory with setLoggerFactory",()=>{const t=vi.fn(),e=vi.fn(),l=new c.ContextModuleBuilder({...r,loggerFactory:t}).setLoggerFactory(e).build()._container.get(s.configTypes.Config);expect(l.loggerFactory).toBe(e),expect(l.loggerFactory).not.toBe(t)})})});
|
|
2
2
|
//# sourceMappingURL=ContextModuleBuilder.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ContextModuleBuilder.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Container } from \"inversify\";\n\nimport { configTypes } from \"./config/di/configTypes\";\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n const defaultWeb3ChecksConfig = {\n url: \"https://web3checks/v1\",\n };\n const defaultBuilderArgs: ContextModuleConstructorArgs = {\n originToken: \"test\",\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader: ContextLoader = {\n load: vi.fn(),\n canHandle: vi.fn() as unknown as ContextLoader[\"canHandle\"],\n };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom typed data loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addTypedDataLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _typedDataLoader is private\n expect(res[\"_typedDataLoader\"]).toBe(customLoader);\n });\n\n it(\"should return a custom context module with a custom config\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder\n .setCalConfig(defaultCalConfig)\n .setWeb3ChecksConfig(defaultWeb3ChecksConfig)\n .build();\n // @ts-expect-error _container is private\n const config = (res[\"_container\"] as Container).get<ContextModuleConfig>(\n configTypes.Config,\n );\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(defaultCalConfig);\n expect(config.web3checks).toEqual(defaultWeb3ChecksConfig);\n });\n\n it(\"should not throw an error if origin token is provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n expect(() => contextModuleBuilder.build()).not.toThrow();\n });\n\n describe(\"setMetadataServiceConfig\", () => {\n it(\"should set the metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://custom-metadata-service.com/v3\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.metadataServiceDomain).toEqual(customMetadataConfig);\n });\n\n it(\"should override the default metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://override-metadata-service.com/v1\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.metadataServiceDomain.url).toBe(customMetadataConfig.url);\n expect(config.metadataServiceDomain.url).not.toBe(\n \"https://nft.api.live.ledger.com/v2\",\n );\n });\n });\n\n describe(\"setCalConfig\", () => {\n it(\"should set the CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://custom-cal-service.com/v2\",\n mode: \"test\",\n branch: \"next\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(customCalConfig);\n });\n\n it(\"should override the default CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://override-cal-service.com/v1\",\n mode: \"prod\",\n branch: \"demo\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.cal.url).toBe(customCalConfig.url);\n expect(config.cal.mode).toBe(customCalConfig.mode);\n expect(config.cal.branch).toBe(customCalConfig.branch);\n expect(config.cal.url).not.toBe(\n \"https://crypto-assets-service.api.ledger.com/v1\",\n );\n });\n });\n\n describe(\"setWeb3ChecksConfig\", () => {\n it(\"should set the web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://custom-web3checks-service.com/v4\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.web3checks).toEqual(customWeb3ChecksConfig);\n });\n\n it(\"should override the default web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://override-web3checks-service.com/v2\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.web3checks.url).toBe(customWeb3ChecksConfig.url);\n expect(config.web3checks.url).not.toBe(\n \"https://web3checks-backend.api.ledger.com/v3\",\n );\n });\n });\n\n describe(\"setDatasourceConfig\", () => {\n it(\"should set the datasource configuration with safe proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"safe\");\n });\n\n it(\"should set the datasource configuration with default proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"default\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"default\");\n });\n\n it(\"should override the default datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.datasource?.proxy).toBe(\"safe\");\n expect(config.datasource).not.toBeUndefined();\n });\n\n it(\"should set an empty datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {};\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBeUndefined();\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["import_configTypes", "import_ContextModuleBuilder", "import_DefaultContextModule", "defaultCalConfig", "defaultWeb3ChecksConfig", "defaultBuilderArgs", "res", "contextModuleBuilder", "customLoader", "config", "customMetadataConfig", "customCalConfig", "customWeb3ChecksConfig", "customDatasourceConfig"]
|
|
4
|
+
"sourcesContent": ["import { type LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\nimport { type Container } from \"inversify\";\n\nimport { configTypes } from \"./config/di/configTypes\";\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n const defaultWeb3ChecksConfig = {\n url: \"https://web3checks/v1\",\n };\n const defaultBuilderArgs: ContextModuleConstructorArgs = {\n originToken: \"test\",\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader: ContextLoader = {\n load: vi.fn(),\n canHandle: vi.fn() as unknown as ContextLoader[\"canHandle\"],\n };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom typed data loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addTypedDataLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _typedDataLoader is private\n expect(res[\"_typedDataLoader\"]).toBe(customLoader);\n });\n\n it(\"should return a custom context module with a custom config\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder\n .setCalConfig(defaultCalConfig)\n .setWeb3ChecksConfig(defaultWeb3ChecksConfig)\n .build();\n // @ts-expect-error _container is private\n const config = (res[\"_container\"] as Container).get<ContextModuleConfig>(\n configTypes.Config,\n );\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(defaultCalConfig);\n expect(config.web3checks).toEqual(defaultWeb3ChecksConfig);\n });\n\n it(\"should not throw an error if origin token is provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n expect(() => contextModuleBuilder.build()).not.toThrow();\n });\n\n describe(\"setMetadataServiceConfig\", () => {\n it(\"should set the metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://custom-metadata-service.com/v3\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.metadataServiceDomain).toEqual(customMetadataConfig);\n });\n\n it(\"should override the default metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://override-metadata-service.com/v1\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.metadataServiceDomain.url).toBe(customMetadataConfig.url);\n expect(config.metadataServiceDomain.url).not.toBe(\n \"https://nft.api.live.ledger.com/v2\",\n );\n });\n });\n\n describe(\"setCalConfig\", () => {\n it(\"should set the CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://custom-cal-service.com/v2\",\n mode: \"test\",\n branch: \"next\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(customCalConfig);\n });\n\n it(\"should override the default CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://override-cal-service.com/v1\",\n mode: \"prod\",\n branch: \"demo\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.cal.url).toBe(customCalConfig.url);\n expect(config.cal.mode).toBe(customCalConfig.mode);\n expect(config.cal.branch).toBe(customCalConfig.branch);\n expect(config.cal.url).not.toBe(\n \"https://crypto-assets-service.api.ledger.com/v1\",\n );\n });\n });\n\n describe(\"setWeb3ChecksConfig\", () => {\n it(\"should set the web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://custom-web3checks-service.com/v4\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.web3checks).toEqual(customWeb3ChecksConfig);\n });\n\n it(\"should override the default web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://override-web3checks-service.com/v2\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.web3checks.url).toBe(customWeb3ChecksConfig.url);\n expect(config.web3checks.url).not.toBe(\n \"https://web3checks-backend.api.ledger.com/v3\",\n );\n });\n });\n\n describe(\"setDatasourceConfig\", () => {\n it(\"should set the datasource configuration with safe proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"safe\");\n });\n\n it(\"should set the datasource configuration with default proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"default\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"default\");\n });\n\n it(\"should override the default datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.datasource?.proxy).toBe(\"safe\");\n expect(config.datasource).not.toBeUndefined();\n });\n\n it(\"should set an empty datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {};\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBeUndefined();\n });\n });\n\n describe(\"loggerFactory\", () => {\n it(\"should set the loggerFactory when provided in the constructor\", () => {\n const loggerFactory: (tag: string) => LoggerPublisherService = vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder({\n ...defaultBuilderArgs,\n loggerFactory,\n });\n\n const res = contextModuleBuilder.build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.loggerFactory).toBe(loggerFactory);\n });\n\n it(\"should set the loggerFactory via setLoggerFactory\", () => {\n const loggerFactory: (tag: string) => LoggerPublisherService = vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.setLoggerFactory(loggerFactory).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.loggerFactory).toBe(loggerFactory);\n });\n\n it(\"should override constructor loggerFactory with setLoggerFactory\", () => {\n const constructorLoggerFactory: (tag: string) => LoggerPublisherService =\n vi.fn();\n const overrideLoggerFactory: (tag: string) => LoggerPublisherService =\n vi.fn();\n\n const contextModuleBuilder = new ContextModuleBuilder({\n ...defaultBuilderArgs,\n loggerFactory: constructorLoggerFactory,\n });\n\n const res = contextModuleBuilder\n .setLoggerFactory(overrideLoggerFactory)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.loggerFactory).toBe(overrideLoggerFactory);\n expect(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E,MAAMK,EAAyD,GAAG,GAAG,EAO/DR,EALuB,IAAI,uBAAqB,CACpD,GAAGD,EACH,cAAAS,CACF,CAAC,EAEgC,MAAM,EACjCL,EAAUH,EACd,WACA,IAAyB,cAAY,MAAM,EAE7C,OAAOA,CAAG,EAAE,eAAe,sBAAoB,EAC/C,OAAOG,EAAO,aAAa,EAAE,KAAKK,CAAa,CACjD,CAAC,EAED,GAAG,oDAAqD,IAAM,CAC5D,MAAMA,EAAyD,GAAG,GAAG,EAI/DR,EAFuB,IAAI,uBAAqBD,CAAkB,EAEvC,iBAAiBS,CAAa,EAAE,MAAM,EACjEL,EAAUH,EACd,WACA,IAAyB,cAAY,MAAM,EAE7C,OAAOA,CAAG,EAAE,eAAe,sBAAoB,EAC/C,OAAOG,EAAO,aAAa,EAAE,KAAKK,CAAa,CACjD,CAAC,EAED,GAAG,kEAAmE,IAAM,CAC1E,MAAMC,EACJ,GAAG,GAAG,EACFC,EACJ,GAAG,GAAG,EAUFP,EARuB,IAAI,uBAAqB,CACpD,GAAGJ,EACH,cAAeU,CACjB,CAAC,EAGE,iBAAiBC,CAAqB,EACtC,MAAM,EAEP,WACA,IAAyB,cAAY,MAAM,EAE7C,OAAOP,EAAO,aAAa,EAAE,KAAKO,CAAqB,EACvD,OAAOP,EAAO,aAAa,EAAE,IAAI,KAAKM,CAAwB,CAChE,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_configTypes", "import_ContextModuleBuilder", "import_DefaultContextModule", "defaultCalConfig", "defaultWeb3ChecksConfig", "defaultBuilderArgs", "res", "contextModuleBuilder", "customLoader", "config", "customMetadataConfig", "customCalConfig", "customWeb3ChecksConfig", "customDatasourceConfig", "loggerFactory", "constructorLoggerFactory", "overrideLoggerFactory"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=require("./shared/model/ClearSignContext"),l=require("./DefaultContextModule");const u=i=>({load:vi.fn(),canHandle:vi.fn().mockReturnValue(i)}),r=()=>({canHandle:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const i={load:vi.fn()},d={customLoaders:[],defaultLoaders:!1,defaultFieldLoaders:!1,customFieldLoaders:[],customTypedDataLoader:i,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},metadataServiceDomain:{url:"https://metadata.com"},originToken:"originToken"};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new l.DefaultContextModule(d).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new l.DefaultContextModule(d).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=u(!0);await new l.DefaultContextModule({...d,customLoaders:[e,e]}).getContexts({}),expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=u(!0),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const a=await new l.DefaultContextModule({...d,customLoaders:[e,e]}).getContexts({});expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2),expect(a).toEqual(t.flat())}),it("should only call loaders that can handle the input",async()=>{const e=u(!0),t=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!1),vi.spyOn(e,"load").mockResolvedValue([{type:o.ClearSignContextType.TOKEN,payload:"payload1"}]),vi.spyOn(t,"load").mockResolvedValue([{type:o.ClearSignContextType.NFT,payload:"payload2"}]);const n=new l.DefaultContextModule({...d,customLoaders:[e,t]}),a={to:"0x123",selector:"0xabc"},s=await n.getContexts(a);expect(e.canHandle).toHaveBeenCalledWith(a,Object.values(o.ClearSignContextType)),expect(t.canHandle).toHaveBeenCalledWith(a,Object.values(o.ClearSignContextType)),expect(e.load).toHaveBeenCalledWith(a),expect(t.load).not.toHaveBeenCalled(),expect(s).toEqual([{type:"token",payload:"payload1"}])}),it("should use expected types if provided",async()=>{const e=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"load").mockResolvedValue([{type:o.ClearSignContextType.TOKEN,payload:"payload1"}]);const t=new l.DefaultContextModule({...d,customLoaders:[e]}),n={to:"0x123",selector:"0xabc"};await t.getContexts(n,[o.ClearSignContextType.TOKEN]),expect(e.canHandle).toHaveBeenCalledWith(n,[o.ClearSignContextType.TOKEN])}),it("should call the typed data loader",async()=>{await new l.DefaultContextModule({...d,customTypedDataLoader:i}).getTypedDataFilters({}),expect(i.load).toHaveBeenCalledTimes(1)}),describe("getFieldContext",()=>{it("should return error when no loader can handle the field",async()=>{const e=r();vi.spyOn(e,"canHandle").mockReturnValue(!1);const t=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),n={type:"unknown"},a=await t.getFieldContext(n,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(n,o.ClearSignContextType.TOKEN),expect(e.loadField).not.toHaveBeenCalled(),expect(a).toEqual({type:o.ClearSignContextType.ERROR,error:new Error(`Loader not found for field: ${n} and expected type: ${o.ClearSignContextType.TOKEN}`)})}),it("should return context when a loader can handle the field",async()=>{const e=r(),t={type:o.ClearSignContextType.TOKEN,payload:"test-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(t);const n=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),a={type:"token",address:"0x123"},s=await n.getFieldContext(a,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(a,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a),expect(s).toEqual(t)}),it("should return first context when multiple loaders can handle the field",async()=>{const e=r(),t=r(),n={type:o.ClearSignContextType.TOKEN,payload:"first-payload"},a={type:o.ClearSignContextType.NFT,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new l.DefaultContextModule({...d,customFieldLoaders:[e,t]}),c={type:"multi",address:"0x123"},p=await s.getFieldContext(c,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).not.toHaveBeenCalled(),expect(p).toEqual(n)}),it("should return second context when first context is an error",async()=>{const e=r(),t=r(),n={type:o.ClearSignContextType.ERROR,error:new Error("first-error")},a={type:o.ClearSignContextType.TOKEN,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new l.DefaultContextModule({...d,customFieldLoaders:[e,t]}),c={type:"error",address:"0x123"},p=await s.getFieldContext(c,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).toHaveBeenCalledWith(c),expect(p).toEqual(a)}),it("should handle loader rejection gracefully",async()=>{const e=r(),t=new Error("Load field failed");vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockRejectedValue(t);const n=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),a={type:"error",address:"0x123"};await expect(n.getFieldContext(a,o.ClearSignContextType.TOKEN)).rejects.toThrow("Load field failed"),expect(e.canHandle).toHaveBeenCalledWith(a,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a)})})});
|
|
1
|
+
"use strict";var o=require("./shared/model/ClearSignContext"),x=require("./shared/utils/NullLoggerPublisherService"),l=require("./DefaultContextModule");const u=i=>({load:vi.fn(),canHandle:vi.fn().mockReturnValue(i)}),r=()=>({canHandle:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const i={load:vi.fn()},d={customLoaders:[],defaultLoaders:!1,defaultFieldLoaders:!1,customFieldLoaders:[],customTypedDataLoader:i,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},metadataServiceDomain:{url:"https://metadata.com"},originToken:"originToken",loggerFactory:x.NullLoggerPublisherService};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new l.DefaultContextModule(d).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new l.DefaultContextModule(d).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=u(!0);await new l.DefaultContextModule({...d,customLoaders:[e,e]}).getContexts({}),expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=u(!0),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const a=await new l.DefaultContextModule({...d,customLoaders:[e,e]}).getContexts({});expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2),expect(a).toEqual(t.flat())}),it("should only call loaders that can handle the input",async()=>{const e=u(!0),t=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!1),vi.spyOn(e,"load").mockResolvedValue([{type:o.ClearSignContextType.TOKEN,payload:"payload1"}]),vi.spyOn(t,"load").mockResolvedValue([{type:o.ClearSignContextType.NFT,payload:"payload2"}]);const n=new l.DefaultContextModule({...d,customLoaders:[e,t]}),a={to:"0x123",selector:"0xabc"},s=await n.getContexts(a);expect(e.canHandle).toHaveBeenCalledWith(a,Object.values(o.ClearSignContextType)),expect(t.canHandle).toHaveBeenCalledWith(a,Object.values(o.ClearSignContextType)),expect(e.load).toHaveBeenCalledWith(a),expect(t.load).not.toHaveBeenCalled(),expect(s).toEqual([{type:"token",payload:"payload1"}])}),it("should use expected types if provided",async()=>{const e=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"load").mockResolvedValue([{type:o.ClearSignContextType.TOKEN,payload:"payload1"}]);const t=new l.DefaultContextModule({...d,customLoaders:[e]}),n={to:"0x123",selector:"0xabc"};await t.getContexts(n,[o.ClearSignContextType.TOKEN]),expect(e.canHandle).toHaveBeenCalledWith(n,[o.ClearSignContextType.TOKEN])}),it("should call the typed data loader",async()=>{await new l.DefaultContextModule({...d,customTypedDataLoader:i}).getTypedDataFilters({}),expect(i.load).toHaveBeenCalledTimes(1)}),describe("getFieldContext",()=>{it("should return error when no loader can handle the field",async()=>{const e=r();vi.spyOn(e,"canHandle").mockReturnValue(!1);const t=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),n={type:"unknown"},a=await t.getFieldContext(n,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(n,o.ClearSignContextType.TOKEN),expect(e.loadField).not.toHaveBeenCalled(),expect(a).toEqual({type:o.ClearSignContextType.ERROR,error:new Error(`Loader not found for field: ${n} and expected type: ${o.ClearSignContextType.TOKEN}`)})}),it("should return context when a loader can handle the field",async()=>{const e=r(),t={type:o.ClearSignContextType.TOKEN,payload:"test-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(t);const n=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),a={type:"token",address:"0x123"},s=await n.getFieldContext(a,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(a,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a),expect(s).toEqual(t)}),it("should return first context when multiple loaders can handle the field",async()=>{const e=r(),t=r(),n={type:o.ClearSignContextType.TOKEN,payload:"first-payload"},a={type:o.ClearSignContextType.NFT,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new l.DefaultContextModule({...d,customFieldLoaders:[e,t]}),c={type:"multi",address:"0x123"},p=await s.getFieldContext(c,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).not.toHaveBeenCalled(),expect(p).toEqual(n)}),it("should return second context when first context is an error",async()=>{const e=r(),t=r(),n={type:o.ClearSignContextType.ERROR,error:new Error("first-error")},a={type:o.ClearSignContextType.TOKEN,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new l.DefaultContextModule({...d,customFieldLoaders:[e,t]}),c={type:"error",address:"0x123"},p=await s.getFieldContext(c,o.ClearSignContextType.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).toHaveBeenCalledWith(c),expect(p).toEqual(a)}),it("should handle loader rejection gracefully",async()=>{const e=r(),t=new Error("Load field failed");vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockRejectedValue(t);const n=new l.DefaultContextModule({...d,customFieldLoaders:[e]}),a={type:"error",address:"0x123"};await expect(n.getFieldContext(a,o.ClearSignContextType.TOKEN)).rejects.toThrow("Load field failed"),expect(e.canHandle).toHaveBeenCalledWith(a,o.ClearSignContextType.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a)})})});
|
|
2
2
|
//# sourceMappingURL=DefaultContextModule.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/DefaultContextModule.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn() as unknown as ContextFieldLoader[\"canHandle\"],\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.com\",\n },\n originToken: \"originToken\",\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0]!)\n .mockResolvedValueOnce(responses[1]!);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"token\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [ClearSignContextType.TOKEN]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.TOKEN,\n ]);\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(testField, ClearSignContextType.TOKEN),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAGA,IAAAA,EAGO,
|
|
6
|
-
"names": ["import_ClearSignContext", "import_DefaultContextModule", "contextLoaderStubBuilder", "canHandle", "fieldLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses", "loader1", "loader2", "contextModule", "testInput", "fieldLoader", "testField", "result", "mockContext", "fieldLoader1", "fieldLoader2", "mockContext1", "mockContext2", "loadError"]
|
|
4
|
+
"sourcesContent": ["import { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport { NullLoggerPublisherService } from \"./shared/utils/NullLoggerPublisherService\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn() as unknown as ContextFieldLoader[\"canHandle\"],\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.com\",\n },\n originToken: \"originToken\",\n loggerFactory: NullLoggerPublisherService,\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0]!)\n .mockResolvedValueOnce(responses[1]!);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"token\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [ClearSignContextType.TOKEN]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.TOKEN,\n ]);\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(testField, ClearSignContextType.TOKEN),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAGA,IAAAA,EAGO,2CAEPC,EAA2C,qDAE3CC,EAAqC,kCAErC,MAAMC,EAA4BC,IACzB,CACL,KAAM,GAAG,GAAG,EACZ,UAAW,GACR,GAAG,EACH,gBAAgBA,CAAS,CAC9B,GAGIC,EAAyB,KACtB,CACL,UAAW,GAAG,GAAG,EACjB,UAAW,GAAG,GAAG,CACnB,GAGF,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,EAC1DC,EAAkD,CACtD,cAAe,CAAC,EAChB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,OAAQ,EAGpD,MAAM,OACJH,EAAc,gBAAgBG,EAAW,uBAAqB,KAAK,CACrE,EAAE,QAAQ,QAAQ,mBAAmB,EAErC,OAAOD,EAAY,SAAS,EAAE,qBAC5BC,EACA,uBAAqB,KACvB,EACA,OAAOD,EAAY,SAAS,EAAE,qBAAqBC,CAAS,CAC9D,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_ClearSignContext", "import_NullLoggerPublisherService", "import_DefaultContextModule", "contextLoaderStubBuilder", "canHandle", "fieldLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses", "loader1", "loader2", "contextModule", "testInput", "fieldLoader", "testField", "result", "mockContext", "fieldLoader1", "fieldLoader2", "mockContext1", "mockContext2", "loadError"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var g=Object.defineProperty;var
|
|
1
|
+
"use strict";var g=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var y=(e,o)=>{for(var r in o)g(e,r,{get:o[r],enumerable:!0})},l=(e,o,r,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of c(o))!f.call(e,n)&&n!==r&&g(e,n,{get:()=>o[n],enumerable:!(t=i(o,n))||t.enumerable});return e};var b=e=>l(g({},"__esModule",{value:!0}),e);var x={};y(x,{configTypes:()=>m});module.exports=b(x);const m={Config:Symbol.for("config"),OriginToken:Symbol.for("originToken"),ContextModuleLoggerFactory:Symbol.for("contextModuleLoggerFactory")};0&&(module.exports={configTypes});
|
|
2
2
|
//# sourceMappingURL=configTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/config/di/configTypes.ts"],
|
|
4
|
-
"sourcesContent": ["export const configTypes = {\n Config: Symbol.for(\"config\"),\n OriginToken: Symbol.for(\"originToken\"),\n};\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAc,CACzB,OAAQ,OAAO,IAAI,QAAQ,EAC3B,YAAa,OAAO,IAAI,aAAa,
|
|
4
|
+
"sourcesContent": ["export const configTypes = {\n Config: Symbol.for(\"config\"),\n OriginToken: Symbol.for(\"originToken\"),\n ContextModuleLoggerFactory: Symbol.for(\"contextModuleLoggerFactory\"),\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAc,CACzB,OAAQ,OAAO,IAAI,QAAQ,EAC3B,YAAa,OAAO,IAAI,aAAa,EACrC,2BAA4B,OAAO,IAAI,4BAA4B,CACrE",
|
|
6
6
|
"names": ["configTypes_exports", "__export", "configTypes", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var g=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(e,r,i,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of s(r))!c.call(e,o)&&o!==i&&g(e,o,{get:()=>r[o],enumerable:!(t=n(r,o))||t.enumerable});return e};var p=e=>l(g({},"__esModule",{value:!0}),e);var u={};module.exports=p(u);
|
|
2
2
|
//# sourceMappingURL=ContextModuleBuildArgs.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/config/model/ContextModuleBuildArgs.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["import { type LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\n\nexport type ContextModuleConstructorArgs = {\n originToken?: string;\n loggerFactory?: (tag: string) => LoggerPublisherService;\n};\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["ContextModuleBuildArgs_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var r=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var r=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var i=(o,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of l(e))!C.call(o,t)&&t!==n&&r(o,t,{get:()=>e[t],enumerable:!(a=d(e,t))||a.enumerable});return o};var x=o=>i(r({},"__esModule",{value:!0}),o);var p={};module.exports=x(p);
|
|
2
2
|
//# sourceMappingURL=ContextModuleConfig.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/config/model/ContextModuleConfig.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextFieldLoader } from \"@/shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport { type SolanaContextLoader } from \"@/solana/domain/SolanaContextLoader\";\nimport { type TypedDataContextLoader } from \"@/typed-data/domain/TypedDataContextLoader\";\n\nexport type ContextModuleCalMode = \"prod\" | \"test\";\nexport type ContextModuleCalBranch = \"next\" | \"main\" | \"demo\";\n\nexport type ContextModuleCalConfig = {\n url: string;\n mode: ContextModuleCalMode;\n branch: ContextModuleCalBranch;\n};\n\nexport type ContextModuleWeb3ChecksConfig = {\n url: string;\n};\n\nexport type ContextModuleMetadataServiceConfig = {\n url: string;\n};\n\nexport type ContextModuleDatasourceConfig = {\n proxy?: \"safe\" | \"default\";\n};\n\nexport type ContextModuleConfig = {\n cal: ContextModuleCalConfig;\n web3checks: ContextModuleWeb3ChecksConfig;\n metadataServiceDomain: ContextModuleMetadataServiceConfig;\n defaultLoaders: boolean;\n defaultFieldLoaders: boolean;\n customFieldLoaders: ContextFieldLoader[];\n customLoaders: ContextLoader[];\n customTypedDataLoader?: TypedDataContextLoader;\n customSolanaLoader?: SolanaContextLoader;\n originToken?: string;\n datasource?: ContextModuleDatasourceConfig;\n};\n"],
|
|
4
|
+
"sourcesContent": ["import { type LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\n\nimport { type ContextFieldLoader } from \"@/shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport { type SolanaContextLoader } from \"@/solana/domain/SolanaContextLoader\";\nimport { type TypedDataContextLoader } from \"@/typed-data/domain/TypedDataContextLoader\";\n\nexport type ContextModuleCalMode = \"prod\" | \"test\";\nexport type ContextModuleCalBranch = \"next\" | \"main\" | \"demo\";\n\nexport type ContextModuleCalConfig = {\n url: string;\n mode: ContextModuleCalMode;\n branch: ContextModuleCalBranch;\n};\n\nexport type ContextModuleWeb3ChecksConfig = {\n url: string;\n};\n\nexport type ContextModuleMetadataServiceConfig = {\n url: string;\n};\n\nexport type ContextModuleDatasourceConfig = {\n proxy?: \"safe\" | \"default\";\n};\n\nexport type ContextModuleConfig = {\n cal: ContextModuleCalConfig;\n web3checks: ContextModuleWeb3ChecksConfig;\n metadataServiceDomain: ContextModuleMetadataServiceConfig;\n defaultLoaders: boolean;\n defaultFieldLoaders: boolean;\n customFieldLoaders: ContextFieldLoader[];\n customLoaders: ContextLoader[];\n loggerFactory: (tag: string) => LoggerPublisherService;\n customTypedDataLoader?: TypedDataContextLoader;\n customSolanaLoader?: SolanaContextLoader;\n originToken?: string;\n datasource?: ContextModuleDatasourceConfig;\n};\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["ContextModuleConfig_exports", "__toCommonJS"]
|
|
7
7
|
}
|
package/lib/cjs/src/di.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var S=(r,o)=>{for(var e in o)a(r,e,{get:o[e],enumerable:!0})},v=(r,o,e,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of h(o))!w.call(r,t)&&t!==e&&a(r,t,{get:()=>o[t],enumerable:!(m=b(o,t))||m.enumerable});return r};var A=r=>v(a({},"__esModule",{value:!0}),r);var T={};S(T,{makeContainer:()=>N});module.exports=A(T);var i=require("inversify"),n=require("./calldata/di/calldataModuleFactory"),l=require("./config/di/configModuleFactory"),c=require("./config/di/configTypes"),p=require("./dynamic-network/di/dynamicNetworkModuleFactory"),y=require("./external-plugin/di/externalPluginModuleFactory"),f=require("./nft/di/nftModuleFactory"),u=require("./pki/di/pkiModuleFactory"),d=require("./proxy/di/proxyModuleFactory"),M=require("./safe/di/safeModuleFactory"),F=require("./solana/di/SolanaContextModuleFactory"),g=require("./solanaLifi/di/lifiModuleFactory"),s=require("./solanaToken/di/tokenModuleFactory"),C=require("./token/di/tokenModuleFactory"),k=require("./transaction-check/di/transactionCheckModuleFactory"),x=require("./trusted-name/di/trustedNameModuleFactory"),L=require("./typed-data/di/typedDataModuleFactory"),P=require("./uniswap/di/uniswapModuleFactory");const N=({config:r})=>{const o=new i.Container;return r.loggerFactory&&o.bind(c.configTypes.ContextModuleLoggerFactory).toConstantValue(r.loggerFactory),o.loadSync((0,l.configModuleFactory)(r),(0,y.externalPluginModuleFactory)(),(0,p.dynamicNetworkModuleFactory)(),(0,f.nftModuleFactory)(),(0,d.proxyModuleFactory)(r),(0,M.safeModuleFactory)(),(0,C.tokenModuleFactory)(),(0,n.calldataModuleFactory)(),(0,x.trustedNameModuleFactory)(),(0,L.typedDataModuleFactory)(),(0,u.nanoPkiModuleFactory)(),(0,P.uniswapModuleFactory)(),(0,k.transactionCheckModuleFactory)(),(0,F.solanaContextModuleFactory)(),(0,s.solanaTokenModuleFactory)(),(0,g.solanaLifiModuleFactory)()),o};0&&(module.exports={makeContainer});
|
|
2
2
|
//# sourceMappingURL=di.js.map
|
package/lib/cjs/src/di.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/di.ts"],
|
|
4
|
-
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { calldataModuleFactory } from \"@/calldata/di/calldataModuleFactory\";\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { dynamicNetworkModuleFactory } from \"@/dynamic-network/di/dynamicNetworkModuleFactory\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { proxyModuleFactory } from \"@/proxy/di/proxyModuleFactory\";\nimport { safeModuleFactory } from \"@/safe/di/safeModuleFactory\";\nimport { solanaContextModuleFactory } from \"@/solana/di/SolanaContextModuleFactory\";\nimport { solanaLifiModuleFactory } from \"@/solanaLifi/di/lifiModuleFactory\";\nimport { solanaTokenModuleFactory } from \"@/solanaToken/di/tokenModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionCheckModuleFactory } from \"@/transaction-check/di/transactionCheckModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n dynamicNetworkModuleFactory(),\n nftModuleFactory(),\n proxyModuleFactory(config),\n safeModuleFactory(),\n tokenModuleFactory(),\n calldataModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n transactionCheckModuleFactory(),\n solanaContextModuleFactory(),\n solanaTokenModuleFactory(),\n solanaLifiModuleFactory(),\n );\n\n return container;\n};\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_calldataModuleFactory", "import_configModuleFactory", "import_dynamicNetworkModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_pkiModuleFactory", "import_proxyModuleFactory", "import_safeModuleFactory", "import_SolanaContextModuleFactory", "import_lifiModuleFactory", "import_tokenModuleFactory", "import_transactionCheckModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "import_uniswapModuleFactory", "config", "container"]
|
|
4
|
+
"sourcesContent": ["import { type LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\nimport { Container } from \"inversify\";\n\nimport { calldataModuleFactory } from \"@/calldata/di/calldataModuleFactory\";\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { dynamicNetworkModuleFactory } from \"@/dynamic-network/di/dynamicNetworkModuleFactory\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { proxyModuleFactory } from \"@/proxy/di/proxyModuleFactory\";\nimport { safeModuleFactory } from \"@/safe/di/safeModuleFactory\";\nimport { solanaContextModuleFactory } from \"@/solana/di/SolanaContextModuleFactory\";\nimport { solanaLifiModuleFactory } from \"@/solanaLifi/di/lifiModuleFactory\";\nimport { solanaTokenModuleFactory } from \"@/solanaToken/di/tokenModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionCheckModuleFactory } from \"@/transaction-check/di/transactionCheckModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n if (config.loggerFactory) {\n container\n .bind<\n (tag: string) => LoggerPublisherService\n >(configTypes.ContextModuleLoggerFactory)\n .toConstantValue(config.loggerFactory);\n }\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n dynamicNetworkModuleFactory(),\n nftModuleFactory(),\n proxyModuleFactory(config),\n safeModuleFactory(),\n tokenModuleFactory(),\n calldataModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n transactionCheckModuleFactory(),\n solanaContextModuleFactory(),\n solanaTokenModuleFactory(),\n solanaLifiModuleFactory(),\n );\n\n return container;\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAA0B,qBAE1BC,EAAsC,+CACtCC,EAAoC,2CACpCC,EAA4B,mCAE5BC,EAA4C,4DAC5CC,EAA4C,4DAC5CC,EAAiC,qCACjCC,EAAqC,qCACrCC,EAAmC,yCACnCC,EAAkC,uCAClCC,EAA2C,kDAC3CC,EAAwC,6CACxCC,EAAyC,+CACzCA,EAAmC,yCACnCC,EAA8C,gEAC9CC,EAAyC,sDACzCC,EAAuC,kDACvCC,EAAqC,6CAM9B,MAAMlB,EAAgB,CAAC,CAAE,OAAAmB,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAI,YAEtB,OAAID,EAAO,eACTC,EACG,KAEC,cAAY,0BAA0B,EACvC,gBAAgBD,EAAO,aAAa,EAGzCC,EAAU,YACR,uBAAoBD,CAAM,KAC1B,+BAA4B,KAC5B,+BAA4B,KAC5B,oBAAiB,KACjB,sBAAmBA,CAAM,KACzB,qBAAkB,KAClB,sBAAmB,KACnB,yBAAsB,KACtB,4BAAyB,KACzB,0BAAuB,KACvB,wBAAqB,KACrB,wBAAqB,KACrB,iCAA8B,KAC9B,8BAA2B,KAC3B,4BAAyB,KACzB,2BAAwB,CAC1B,EAEOC,CACT",
|
|
6
|
+
"names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_calldataModuleFactory", "import_configModuleFactory", "import_configTypes", "import_dynamicNetworkModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_pkiModuleFactory", "import_proxyModuleFactory", "import_safeModuleFactory", "import_SolanaContextModuleFactory", "import_lifiModuleFactory", "import_tokenModuleFactory", "import_transactionCheckModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "import_uniswapModuleFactory", "config", "container"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var s=(t,e)=>{for(var n in e)p(t,n,{get:e[n],enumerable:!0})},y=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of d(e))!o.call(t,r)&&r!==n&&p(t,r,{get:()=>e[r],enumerable:!(a=i(e,r))||a.enumerable});return t};var T=t=>y(p({},"__esModule",{value:!0}),t);var c={};s(c,{TypedDataCalldataParamPresence:()=>l,VERIFYING_CONTRACT_TOKEN_INDEX:()=>g});module.exports=T(c);const g=255;var l=(a=>(a.None="none",a.Present="present",a.VerifyingContract="verifying_contract",a))(l||{});0&&(module.exports={TypedDataCalldataParamPresence,VERIFYING_CONTRACT_TOKEN_INDEX});
|
|
2
2
|
//# sourceMappingURL=TypedDataClearSignContext.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/model/TypedDataClearSignContext.ts"],
|
|
4
|
-
"sourcesContent": ["import type { HexaString } from \"@ledgerhq/device-management-kit\";\n\nimport {\n type ClearSignContextSuccess,\n type ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { type TransactionSubset } from \"@/shared/model/TransactionSubset\";\n\n// The general informations for a typed message\nexport type TypedDataMessageInfo = {\n displayName: string;\n filtersCount: number;\n signature: string;\n};\n\n// Token index and descriptor. Needed for tokens that are referenced by a typed message\nexport type TypedDataTokenIndex = number;\nexport type TypedDataToken = string;\n// Calldata index. Needed for calldatas that are referenced by a typed message\nexport type TypedDataCalldataIndex = number;\n// Special token index value when the referenced token is the verifying contract\nexport const VERIFYING_CONTRACT_TOKEN_INDEX = 255;\n\n// Typed message filters, to select fields to display, and provide formatting informations\nexport type TypedDataFilterPath = string;\nexport type TypedDataFilterWithToken = {\n type: \"amount\" | \"token\";\n displayName: string;\n tokenIndex: TypedDataTokenIndex;\n path: TypedDataFilterPath;\n signature: string;\n};\nexport type TypedDataFilterWithTrustedName = {\n type: \"trusted-name\";\n displayName: string;\n types: string[];\n sources: string[];\n typesAndSourcesPayload: string;\n path: TypedDataFilterPath;\n signature: string;\n};\nexport type TypedDataFilterCalldata = {\n type:\n | \"calldata-value\"\n | \"calldata-callee\"\n | \"calldata-chain-id\"\n | \"calldata-selector\"\n | \"calldata-amount\"\n | \"calldata-spender\";\n displayName: string;\n calldataIndex: TypedDataCalldataIndex;\n path: TypedDataFilterPath;\n signature: string;\n};\nexport type TypedDataFilter =\n | {\n type: \"datetime\" | \"raw\";\n displayName: string;\n path: TypedDataFilterPath;\n signature: string;\n }\n | TypedDataFilterWithToken\n | TypedDataFilterWithTrustedName\n | TypedDataFilterCalldata;\n\n// Calldata info when referenced by a typed message\nexport enum TypedDataCalldataParamPresence {\n None = \"none\",\n Present = \"present\",\n VerifyingContract = \"verifying_contract\",\n}\nexport type TypedDataFilterCalldataInfo = {\n displayName: string;\n calldataIndex: TypedDataCalldataIndex;\n valueFlag: boolean;\n calleeFlag: TypedDataCalldataParamPresence;\n chainIdFlag: boolean;\n selectorFlag: boolean;\n amountFlag: boolean;\n spenderFlag: TypedDataCalldataParamPresence;\n signature: string;\n};\nexport type TypedDataCalldataInfo = {\n filter: TypedDataFilterCalldataInfo;\n subset: TransactionSubset;\n};\n\n// Clear signing context for a typed message\nexport type TypedDataClearSignContextSuccess = {\n type: \"success\";\n messageInfo: TypedDataMessageInfo;\n filters: Record<TypedDataFilterPath, TypedDataFilter>;\n trustedNamesAddresses: Record<TypedDataFilterPath, HexaString>;\n tokens: Record<TypedDataTokenIndex, TypedDataToken>;\n calldatas: Record<TypedDataCalldataIndex, TypedDataCalldataInfo>;\n proxy?: ClearSignContextSuccess<ClearSignContextType.PROXY_INFO>;\n};\nexport type TypedDataClearSignContextError = {\n type: \"error\";\n error: Error;\n};\nexport type TypedDataClearSignContext =\n | TypedDataClearSignContextSuccess\n | TypedDataClearSignContextError;\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oCAAAE,EAAA,mCAAAC,IAAA,eAAAC,EAAAJ,
|
|
4
|
+
"sourcesContent": ["import type { HexaString } from \"@ledgerhq/device-management-kit\";\n\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport {\n type ClearSignContextSuccess,\n type ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { type TransactionSubset } from \"@/shared/model/TransactionSubset\";\n\n// The general informations for a typed message\nexport type TypedDataMessageInfo = {\n displayName: string;\n filtersCount: number;\n signature: string;\n};\n\n// Token index and descriptor. Needed for tokens that are referenced by a typed message\nexport type TypedDataTokenIndex = number;\nexport type TypedDataToken = string;\n// Calldata index. Needed for calldatas that are referenced by a typed message\nexport type TypedDataCalldataIndex = number;\n// Special token index value when the referenced token is the verifying contract\nexport const VERIFYING_CONTRACT_TOKEN_INDEX = 255;\n\n// Typed message filters, to select fields to display, and provide formatting informations\nexport type TypedDataFilterPath = string;\nexport type TypedDataFilterWithToken = {\n type: \"amount\" | \"token\";\n displayName: string;\n tokenIndex: TypedDataTokenIndex;\n path: TypedDataFilterPath;\n signature: string;\n};\nexport type TypedDataFilterWithTrustedName = {\n type: \"trusted-name\";\n displayName: string;\n types: string[];\n sources: string[];\n typesAndSourcesPayload: string;\n path: TypedDataFilterPath;\n signature: string;\n};\nexport type TypedDataFilterCalldata = {\n type:\n | \"calldata-value\"\n | \"calldata-callee\"\n | \"calldata-chain-id\"\n | \"calldata-selector\"\n | \"calldata-amount\"\n | \"calldata-spender\";\n displayName: string;\n calldataIndex: TypedDataCalldataIndex;\n path: TypedDataFilterPath;\n signature: string;\n};\nexport type TypedDataFilter =\n | {\n type: \"datetime\" | \"raw\";\n displayName: string;\n path: TypedDataFilterPath;\n signature: string;\n }\n | TypedDataFilterWithToken\n | TypedDataFilterWithTrustedName\n | TypedDataFilterCalldata;\n\n// Calldata info when referenced by a typed message\nexport enum TypedDataCalldataParamPresence {\n None = \"none\",\n Present = \"present\",\n VerifyingContract = \"verifying_contract\",\n}\nexport type TypedDataFilterCalldataInfo = {\n displayName: string;\n calldataIndex: TypedDataCalldataIndex;\n valueFlag: boolean;\n calleeFlag: TypedDataCalldataParamPresence;\n chainIdFlag: boolean;\n selectorFlag: boolean;\n amountFlag: boolean;\n spenderFlag: TypedDataCalldataParamPresence;\n signature: string;\n};\nexport type TypedDataCalldataInfo = {\n filter: TypedDataFilterCalldataInfo;\n subset: TransactionSubset;\n};\n\n// Clear signing context for a typed message\nexport type TypedDataClearSignContextSuccess = {\n type: \"success\";\n messageInfo: TypedDataMessageInfo;\n filters: Record<TypedDataFilterPath, TypedDataFilter>;\n trustedNamesAddresses: Record<TypedDataFilterPath, HexaString>;\n tokens: Record<TypedDataTokenIndex, TypedDataToken>;\n calldatas: Record<TypedDataCalldataIndex, TypedDataCalldataInfo>;\n certificate?: PkiCertificate;\n proxy?: ClearSignContextSuccess<ClearSignContextType.PROXY_INFO>;\n};\nexport type TypedDataClearSignContextError = {\n type: \"error\";\n error: Error;\n};\nexport type TypedDataClearSignContext =\n | TypedDataClearSignContextSuccess\n | TypedDataClearSignContextError;\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oCAAAE,EAAA,mCAAAC,IAAA,eAAAC,EAAAJ,GAsBO,MAAMG,EAAiC,IA6CvC,IAAKD,OACVA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,kBAAoB,qBAHVA,OAAA",
|
|
6
6
|
"names": ["TypedDataClearSignContext_exports", "__export", "TypedDataCalldataParamPresence", "VERIFYING_CONTRACT_TOKEN_INDEX", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var c=(r,e)=>{for(var i in e)t(r,i,{get:e[i],enumerable:!0})},l=(r,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let g of n(e))!b.call(r,g)&&g!==i&&t(r,g,{get:()=>e[g],enumerable:!(o=s(e,g))||o.enumerable});return r};var u=r=>l(t({},"__esModule",{value:!0}),r);var h={};c(h,{NullLoggerPublisherService:()=>a});module.exports=u(h);const a=r=>({debug:()=>{},info:()=>{},warn:()=>{},error:()=>{},subscribers:[]});0&&(module.exports={NullLoggerPublisherService});
|
|
2
|
+
//# sourceMappingURL=NullLoggerPublisherService.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/shared/utils/NullLoggerPublisherService.ts"],
|
|
4
|
+
"sourcesContent": ["import type { LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\n\nexport const NullLoggerPublisherService: (\n tag: string,\n) => LoggerPublisherService = (_tag: string) => ({\n debug: () => {\n // no-op\n },\n info: () => {\n // no-op\n },\n warn: () => {\n // no-op\n },\n error: () => {\n // no-op\n },\n subscribers: [],\n});\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,GAEO,MAAME,EAEkBE,IAAkB,CAC/C,MAAO,IAAM,CAEb,EACA,KAAM,IAAM,CAEZ,EACA,KAAM,IAAM,CAEZ,EACA,MAAO,IAAM,CAEb,EACA,YAAa,CAAC,CAChB",
|
|
6
|
+
"names": ["NullLoggerPublisherService_exports", "__export", "NullLoggerPublisherService", "__toCommonJS", "_tag"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("vitest"),r=require("./NullLoggerPublisherService");(0,e.describe)("NullLoggerPublisherService",()=>{(0,e.it)("returns a LoggerPublisherService-like obj",()=>{const o=(0,r.NullLoggerPublisherService)("any-tag");(0,e.expect)(o).toBeDefined(),(0,e.expect)(typeof o.debug).toBe("function"),(0,e.expect)(typeof o.info).toBe("function"),(0,e.expect)(typeof o.warn).toBe("function"),(0,e.expect)(typeof o.error).toBe("function"),(0,e.expect)(Array.isArray(o.subscribers)).toBe(!0),(0,e.expect)(o.subscribers).toHaveLength(0)}),(0,e.it)("methods are no-ops (do not throw)",()=>{const o=(0,r.NullLoggerPublisherService)("test");(0,e.expect)(()=>o.debug("hello")).not.toThrow(),(0,e.expect)(()=>o.info("hello")).not.toThrow(),(0,e.expect)(()=>o.warn("hello")).not.toThrow(),(0,e.expect)(()=>o.error("hello")).not.toThrow(),(0,e.expect)(()=>o.debug("hello",{data:{a:1}})).not.toThrow()}),(0,e.it)("returns a new object per call (current implementation)",()=>{const o=(0,r.NullLoggerPublisherService)("x"),t=(0,r.NullLoggerPublisherService)("x");(0,e.expect)(o).not.toBe(t)})});
|
|
2
|
+
//# sourceMappingURL=NullLoggerPublisherService.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/shared/utils/NullLoggerPublisherService.test.ts"],
|
|
4
|
+
"sourcesContent": ["import type { LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\nimport { describe, expect, it } from \"vitest\";\n\nimport { NullLoggerPublisherService } from \"./NullLoggerPublisherService\";\n\ndescribe(\"NullLoggerPublisherService\", () => {\n it(\"returns a LoggerPublisherService-like obj\", () => {\n const logger = NullLoggerPublisherService(\n \"any-tag\",\n ) as LoggerPublisherService;\n\n expect(logger).toBeDefined();\n expect(typeof logger.debug).toBe(\"function\");\n expect(typeof logger.info).toBe(\"function\");\n expect(typeof logger.warn).toBe(\"function\");\n expect(typeof logger.error).toBe(\"function\");\n expect(Array.isArray(logger.subscribers)).toBe(true);\n expect(logger.subscribers).toHaveLength(0);\n });\n\n it(\"methods are no-ops (do not throw)\", () => {\n const logger = NullLoggerPublisherService(\"test\");\n\n expect(() => logger.debug(\"hello\")).not.toThrow();\n expect(() => logger.info(\"hello\")).not.toThrow();\n expect(() => logger.warn(\"hello\")).not.toThrow();\n expect(() => logger.error(\"hello\")).not.toThrow();\n\n expect(() => logger.debug(\"hello\", { data: { a: 1 } })).not.toThrow();\n });\n\n it(\"returns a new object per call (current implementation)\", () => {\n const logger1 = NullLoggerPublisherService(\"x\");\n const logger2 = NullLoggerPublisherService(\"x\");\n\n expect(logger1).not.toBe(logger2);\n });\n});\n"],
|
|
5
|
+
"mappings": "aACA,IAAAA,EAAqC,kBAErCC,EAA2C,2CAE3C,YAAS,6BAA8B,IAAM,IAC3C,MAAG,4CAA6C,IAAM,CACpD,MAAMC,KAAS,8BACb,SACF,KAEA,UAAOA,CAAM,EAAE,YAAY,KAC3B,UAAO,OAAOA,EAAO,KAAK,EAAE,KAAK,UAAU,KAC3C,UAAO,OAAOA,EAAO,IAAI,EAAE,KAAK,UAAU,KAC1C,UAAO,OAAOA,EAAO,IAAI,EAAE,KAAK,UAAU,KAC1C,UAAO,OAAOA,EAAO,KAAK,EAAE,KAAK,UAAU,KAC3C,UAAO,MAAM,QAAQA,EAAO,WAAW,CAAC,EAAE,KAAK,EAAI,KACnD,UAAOA,EAAO,WAAW,EAAE,aAAa,CAAC,CAC3C,CAAC,KAED,MAAG,oCAAqC,IAAM,CAC5C,MAAMA,KAAS,8BAA2B,MAAM,KAEhD,UAAO,IAAMA,EAAO,MAAM,OAAO,CAAC,EAAE,IAAI,QAAQ,KAChD,UAAO,IAAMA,EAAO,KAAK,OAAO,CAAC,EAAE,IAAI,QAAQ,KAC/C,UAAO,IAAMA,EAAO,KAAK,OAAO,CAAC,EAAE,IAAI,QAAQ,KAC/C,UAAO,IAAMA,EAAO,MAAM,OAAO,CAAC,EAAE,IAAI,QAAQ,KAEhD,UAAO,IAAMA,EAAO,MAAM,QAAS,CAAE,KAAM,CAAE,EAAG,CAAE,CAAE,CAAC,CAAC,EAAE,IAAI,QAAQ,CACtE,CAAC,KAED,MAAG,yDAA0D,IAAM,CACjE,MAAMC,KAAU,8BAA2B,GAAG,EACxCC,KAAU,8BAA2B,GAAG,KAE9C,UAAOD,CAAO,EAAE,IAAI,KAAKC,CAAO,CAClC,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_vitest", "import_NullLoggerPublisherService", "logger", "logger1", "logger2"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var N=(o,e)=>{for(var r in e)m(o,r,{get:e[r],enumerable:!0})},E=(o,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of _(e))!h.call(o,t)&&t!==r&&m(o,t,{get:()=>e[t],enumerable:!(a=u(e,t))||a.enumerable});return o};var A=o=>E(m({},"__esModule",{value:!0}),o),L=(o,e,r,a)=>{for(var t=a>1?void 0:a?u(e,r):e,s=o.length-1,c;s>=0;s--)(c=o[s])&&(t=(a?c(e,r,t):c(t))||t);return a&&t&&m(e,r,t),t},d=(o,e)=>(r,a)=>e(r,a,o);var O={};N(O,{DefaultSolanaContextLoader:()=>l});module.exports=A(O);var n=require("inversify"),g=require("purify-ts"),S=require("../../config/di/configTypes"),y=require("../../pki/di/pkiTypes"),T=require("../../pki/model/KeyUsage"),p=require("../../shared/model/SolanaContextTypes"),C=require("../../solana/di/solanaContextTypes"),k=require("../../solanaToken/di/solanaTokenTypes");let l=class{constructor(e,r,a,t){this._dataSource=e;this._certificateLoader=r;this._solanaTokenLoader=a;this.logger=t("DefaultSolanaContextLoader")}logger;async load(e){this.logger.debug("[load] Loading solana context",{data:{input:e}});const{deviceModelId:r}=e,a=await this._certificateLoader.loadCertificate({keyId:"domain_metadata_key",keyUsage:T.KeyUsage.TrustedName,targetDevice:r});if(!a)return(0,g.Left)(new Error("[ContextModule] DefaultSolanaContextLoader: trustedNamePKICertificate is missing"));const s=[{loader:this._solanaTokenLoader,expectedType:p.SolanaContextTypes.SOLANA_TOKEN}].map(({loader:i,expectedType:f})=>{if(i.canHandle(e,f))return i.loadField(e)}).filter(i=>i!==void 0),v=(await Promise.allSettled(s)).map(i=>i.status==="fulfilled"?i.value:void 0).filter(i=>i!==void 0).sort((i,f)=>{const P=i.type===p.SolanaContextTypes.SOLANA_TOKEN?0:1,x=f.type===p.SolanaContextTypes.SOLANA_TOKEN?0:1;return P-x});return(await this._dataSource.getOwnerInfo(e)).map(({tlvDescriptor:i})=>({trustedNamePKICertificate:a,tlvDescriptor:i,loadersResults:v}))}};l=L([(0,n.injectable)(),d(0,(0,n.inject)(C.solanaContextTypes.SolanaDataSource)),d(1,(0,n.inject)(y.pkiTypes.PkiCertificateLoader)),d(2,(0,n.inject)(k.solanaTokenTypes.SolanaTokenContextLoader)),d(3,(0,n.inject)(S.configTypes.ContextModuleLoggerFactory))],l);0&&(module.exports={DefaultSolanaContextLoader});
|
|
2
2
|
//# sourceMappingURL=DefaultSolanaContextLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/solana/domain/DefaultSolanaContextLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { Left } from \"purify-ts\";\n\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport {\n LoaderResult,\n SolanaContextTypes,\n} from \"@/shared/model/SolanaContextTypes\";\nimport { type SolanaDataSource } from \"@/solana/data/SolanaDataSource\";\nimport { solanaContextTypes } from \"@/solana/di/solanaContextTypes\";\n// import { lifiTypes } from \"@/solanaLifi/di/solanaLifiTypes\";\n// import { SolanaLifiContextLoader } from \"@/solanaLifi/domain/SolanaLifiContextLoader\";\nimport { solanaTokenTypes } from \"@/solanaToken/di/solanaTokenTypes\";\nimport { SolanaTokenContextLoader } from \"@/solanaToken/domain/SolanaTokenContextLoader\";\n\nimport { type SolanaContextLoader } from \"./SolanaContextLoader\";\nimport {\n SolanaTransactionContext,\n SolanaTransactionContextResult,\n} from \"./solanaContextTypes\";\n\n@injectable()\nexport class DefaultSolanaContextLoader implements SolanaContextLoader {\n constructor(\n @inject(solanaContextTypes.SolanaDataSource)\n private readonly _dataSource: SolanaDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n @inject(solanaTokenTypes.SolanaTokenContextLoader)\n private readonly _solanaTokenLoader: SolanaTokenContextLoader,\n // @inject(lifiTypes.SolanaLifiContextLoader)\n // private readonly _solanaLifiLoader: SolanaLifiContextLoader,\n ) {}\n\n async load(\n solanaContext: SolanaTransactionContext,\n ): Promise<SolanaTransactionContextResult> {\n const { deviceModelId } = solanaContext;\n\n const trustedNamePKICertificate =\n await this._certificateLoader.loadCertificate({\n keyId: \"domain_metadata_key\",\n keyUsage: KeyUsage.TrustedName,\n targetDevice: deviceModelId,\n });\n\n if (!trustedNamePKICertificate) {\n return Left(\n new Error(\n \"[ContextModule] DefaultSolanaContextLoader: trustedNamePKICertificate is missing\",\n ),\n );\n }\n\n const loaderEntries = [\n {\n loader: this._solanaTokenLoader,\n expectedType: SolanaContextTypes.SOLANA_TOKEN,\n },\n // TODO LIFI\n // Lifi loader currently disabled as WIP\n // {\n // loader: this._solanaLifiLoader,\n // expectedType: SolanaContextTypes.SOLANA_LIFI,\n // },\n ] as const;\n\n const loaderPromises: Promise<LoaderResult>[] = loaderEntries\n .map(({ loader, expectedType }) => {\n if (loader.canHandle(solanaContext, expectedType)) {\n return loader.loadField(solanaContext);\n }\n return undefined;\n })\n .filter((p): p is Promise<LoaderResult> => p !== undefined);\n\n const settledLoaders = await Promise.allSettled(loaderPromises);\n\n const loadersResults = settledLoaders\n .map((r) => (r.status === \"fulfilled\" ? r.value : undefined))\n .filter((v): v is LoaderResult => v !== undefined)\n // always sort with SOLANA_TOKEN first\n .sort((a, b) => {\n const A = a.type === SolanaContextTypes.SOLANA_TOKEN ? 0 : 1;\n const B = b.type === SolanaContextTypes.SOLANA_TOKEN ? 0 : 1;\n return A - B;\n });\n\n const tlvDescriptorEither =\n await this._dataSource.getOwnerInfo(solanaContext);\n\n return tlvDescriptorEither.map(({ tlvDescriptor }) => ({\n trustedNamePKICertificate,\n tlvDescriptor,\n loadersResults,\n }));\n }\n}\n"],
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["DefaultSolanaContextLoader_exports", "__export", "DefaultSolanaContextLoader", "__toCommonJS", "import_inversify", "import_purify_ts", "import_pkiTypes", "import_KeyUsage", "import_SolanaContextTypes", "import_solanaContextTypes", "import_solanaTokenTypes", "DefaultSolanaContextLoader", "_dataSource", "_certificateLoader", "_solanaTokenLoader", "solanaContext", "deviceModelId", "trustedNamePKICertificate", "loaderPromises", "loader", "expectedType", "p", "loadersResults", "r", "v", "a", "b", "A", "B", "tlvDescriptor", "__decorateClass", "__decorateParam"]
|
|
4
|
+
"sourcesContent": ["import { LoggerPublisherService } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Left } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport {\n LoaderResult,\n SolanaContextTypes,\n} from \"@/shared/model/SolanaContextTypes\";\nimport { type SolanaDataSource } from \"@/solana/data/SolanaDataSource\";\nimport { solanaContextTypes } from \"@/solana/di/solanaContextTypes\";\n// import { lifiTypes } from \"@/solanaLifi/di/solanaLifiTypes\";\n// import { SolanaLifiContextLoader } from \"@/solanaLifi/domain/SolanaLifiContextLoader\";\nimport { solanaTokenTypes } from \"@/solanaToken/di/solanaTokenTypes\";\nimport { SolanaTokenContextLoader } from \"@/solanaToken/domain/SolanaTokenContextLoader\";\n\nimport { type SolanaContextLoader } from \"./SolanaContextLoader\";\nimport {\n SolanaTransactionContext,\n SolanaTransactionContextResult,\n} from \"./solanaContextTypes\";\n\n@injectable()\nexport class DefaultSolanaContextLoader implements SolanaContextLoader {\n private logger: LoggerPublisherService;\n\n constructor(\n @inject(solanaContextTypes.SolanaDataSource)\n private readonly _dataSource: SolanaDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n @inject(solanaTokenTypes.SolanaTokenContextLoader)\n private readonly _solanaTokenLoader: SolanaTokenContextLoader,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n // @inject(lifiTypes.SolanaLifiContextLoader)\n // private readonly _solanaLifiLoader: SolanaLifiContextLoader,\n ) {\n this.logger = loggerFactory(\"DefaultSolanaContextLoader\");\n }\n\n async load(\n solanaContext: SolanaTransactionContext,\n ): Promise<SolanaTransactionContextResult> {\n this.logger.debug(\"[load] Loading solana context\", {\n data: { input: solanaContext },\n });\n const { deviceModelId } = solanaContext;\n\n const trustedNamePKICertificate =\n await this._certificateLoader.loadCertificate({\n keyId: \"domain_metadata_key\",\n keyUsage: KeyUsage.TrustedName,\n targetDevice: deviceModelId,\n });\n\n if (!trustedNamePKICertificate) {\n return Left(\n new Error(\n \"[ContextModule] DefaultSolanaContextLoader: trustedNamePKICertificate is missing\",\n ),\n );\n }\n\n const loaderEntries = [\n {\n loader: this._solanaTokenLoader,\n expectedType: SolanaContextTypes.SOLANA_TOKEN,\n },\n // TODO LIFI\n // Lifi loader currently disabled as WIP\n // {\n // loader: this._solanaLifiLoader,\n // expectedType: SolanaContextTypes.SOLANA_LIFI,\n // },\n ] as const;\n\n const loaderPromises: Promise<LoaderResult>[] = loaderEntries\n .map(({ loader, expectedType }) => {\n if (loader.canHandle(solanaContext, expectedType)) {\n return loader.loadField(solanaContext);\n }\n return undefined;\n })\n .filter((p): p is Promise<LoaderResult> => p !== undefined);\n\n const settledLoaders = await Promise.allSettled(loaderPromises);\n\n const loadersResults = settledLoaders\n .map((r) => (r.status === \"fulfilled\" ? r.value : undefined))\n .filter((v): v is LoaderResult => v !== undefined)\n // always sort with SOLANA_TOKEN first\n .sort((a, b) => {\n const A = a.type === SolanaContextTypes.SOLANA_TOKEN ? 0 : 1;\n const B = b.type === SolanaContextTypes.SOLANA_TOKEN ? 0 : 1;\n return A - B;\n });\n\n const tlvDescriptorEither =\n await this._dataSource.getOwnerInfo(solanaContext);\n\n return tlvDescript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,EAAI,EACrDG,EAAIF,EAAE,OAAS,qBAAmB,aAAe,EAAI,EAC3D,OAAOC,EAAIC,CACb,CAAC,EAKH,OAFE,MAAM,KAAK,YAAY,aAAab,CAAa,GAExB,IAAI,CAAC,CAAE,cAAAc,CAAc,KAAO,CACrD,0BAAAZ,EACA,cAAAY,EACA,eAAAP,CACF,EAAE,CACJ,CACF,EApFaZ,EAANoB,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,qBAAmB,gBAAgB,GAE1CA,EAAA,eAAO,WAAS,oBAAoB,GAEpCA,EAAA,eAAO,mBAAiB,wBAAwB,GAEhDA,EAAA,eAAO,cAAY,0BAA0B,IAVrCrB",
|
|
6
|
+
"names": ["DefaultSolanaContextLoader_exports", "__export", "DefaultSolanaContextLoader", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_pkiTypes", "import_KeyUsage", "import_SolanaContextTypes", "import_solanaContextTypes", "import_solanaTokenTypes", "DefaultSolanaContextLoader", "_dataSource", "_certificateLoader", "_solanaTokenLoader", "loggerFactory", "solanaContext", "deviceModelId", "trustedNamePKICertificate", "loaderPromises", "loader", "expectedType", "p", "loadersResults", "r", "v", "a", "b", "A", "B", "tlvDescriptor", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|