@ledgerhq/context-module 1.2.0 → 1.3.1
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/index.js.map +1 -1
- package/lib/cjs/package.json +2 -2
- package/lib/cjs/src/ContextModule.js +1 -1
- package/lib/cjs/src/ContextModule.js.map +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.js +1 -1
- package/lib/cjs/src/DefaultContextModule.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/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/index.js +1 -1
- package/lib/cjs/src/index.js.map +2 -2
- package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
- package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
- package/lib/cjs/src/pki/model/PkiCertificateInfo.js +1 -1
- package/lib/cjs/src/pki/model/PkiCertificateInfo.js.map +1 -1
- package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
- package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
- package/lib/cjs/src/shared/model/TransactionSubset.js +1 -1
- package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
- 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/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
- package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
- package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js +1 -1
- package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js.map +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
- package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
- package/lib/cjs/src/typed-data/data/FiltersDto.js +1 -1
- 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 +3 -3
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +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/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js +2 -0
- package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js.map +7 -0
- package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js +2 -0
- package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +7 -0
- package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js +2 -0
- package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js.map +7 -0
- package/lib/cjs/src/web3-check/data/Web3CheckDto.js +2 -0
- package/lib/cjs/src/web3-check/data/Web3CheckDto.js.map +7 -0
- package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +2 -0
- package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +7 -0
- package/lib/cjs/src/web3-check/di/web3CheckTypes.js +2 -0
- package/lib/cjs/src/web3-check/di/web3CheckTypes.js.map +7 -0
- package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js +2 -0
- package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +7 -0
- package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +2 -0
- package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +7 -0
- package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js +2 -0
- package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js.map +7 -0
- package/lib/cjs/src/web3-check/domain/web3CheckTypes.js +2 -0
- package/lib/cjs/src/web3-check/domain/web3CheckTypes.js.map +7 -0
- package/lib/esm/package.json +2 -2
- 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.js +1 -1
- package/lib/esm/src/DefaultContextModule.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/di.js +1 -1
- package/lib/esm/src/di.js.map +3 -3
- package/lib/esm/src/index.js +1 -1
- package/lib/esm/src/index.js.map +2 -2
- package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
- package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
- package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
- package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
- package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +2 -2
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
- package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
- package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.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 +3 -3
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +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/esm/src/web3-check/data/HttpWeb3CheckDataSource.js +2 -0
- package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js.map +7 -0
- package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js +2 -0
- package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +7 -0
- package/lib/esm/src/web3-check/data/Web3CheckDataSource.js +1 -0
- package/lib/esm/src/web3-check/data/Web3CheckDataSource.js.map +7 -0
- package/lib/esm/src/web3-check/data/Web3CheckDto.js +1 -0
- package/lib/esm/src/web3-check/data/Web3CheckDto.js.map +7 -0
- package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +2 -0
- package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +7 -0
- package/lib/esm/src/web3-check/di/web3CheckTypes.js +2 -0
- package/lib/esm/src/web3-check/di/web3CheckTypes.js.map +7 -0
- package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js +2 -0
- package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +7 -0
- package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +2 -0
- package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +7 -0
- package/lib/esm/src/web3-check/domain/Web3CheckContextLoader.js +1 -0
- package/lib/esm/src/web3-check/domain/Web3CheckContextLoader.js.map +7 -0
- package/lib/esm/src/web3-check/domain/web3CheckTypes.js +1 -0
- package/lib/esm/src/web3-check/domain/web3CheckTypes.js.map +7 -0
- package/lib/types/src/ContextModule.d.ts +2 -0
- package/lib/types/src/ContextModule.d.ts.map +1 -1
- package/lib/types/src/ContextModuleBuilder.d.ts +16 -1
- package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
- package/lib/types/src/DefaultContextModule.d.ts +5 -1
- package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
- package/lib/types/src/config/model/ContextModuleConfig.d.ts +6 -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/index.d.ts +2 -0
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/pki/model/PkiCertificateInfo.d.ts +1 -1
- package/lib/types/src/pki/model/PkiCertificateInfo.d.ts.map +1 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts +1 -0
- package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
- package/lib/types/src/shared/model/TransactionSubset.d.ts +2 -0
- package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -1
- package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +17 -5
- package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -1
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +2 -2
- package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
- package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts +2 -0
- package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -1
- package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/FiltersDto.d.ts +17 -1
- package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -1
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +2 -0
- package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
- package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
- package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts +14 -0
- package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts.map +1 -0
- package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts +2 -0
- package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts.map +1 -0
- package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts +6 -0
- package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts.map +1 -0
- package/lib/types/src/web3-check/data/Web3CheckDto.d.ts +20 -0
- package/lib/types/src/web3-check/data/Web3CheckDto.d.ts.map +1 -0
- package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts +3 -0
- package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts.map +1 -0
- package/lib/types/src/web3-check/di/web3CheckTypes.d.ts +5 -0
- package/lib/types/src/web3-check/di/web3CheckTypes.d.ts.map +1 -0
- package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts +10 -0
- package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts.map +1 -0
- package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts +2 -0
- package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts.map +1 -0
- package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts +6 -0
- package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts.map +1 -0
- package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts +35 -0
- package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -4
package/lib/cjs/index.js.map
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
"sources": ["../../index.ts"],
|
|
4
4
|
"sourcesContent": ["// inversify requirement\nimport \"reflect-metadata\";\n\nexport * from \"./src/index\";\n"],
|
|
5
5
|
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GACA,IAAAE,EAAO,4BAEPC,EAAAH,EAAc,uBAHd",
|
|
6
|
-
"names": ["
|
|
6
|
+
"names": ["index_exports", "__toCommonJS", "import_reflect_metadata", "__reExport"]
|
|
7
7
|
}
|
package/lib/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/context-module",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"ts-node": "^10.9.2"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"axios": "^1.
|
|
48
|
+
"axios": "^1.8.2",
|
|
49
49
|
"crypto-js": "^4.2.0",
|
|
50
50
|
"ethers": "6.13.4",
|
|
51
51
|
"inversify": "^6.2.2",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var p=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of i(t))!x.call(e,o)&&o!==r&&a(e,o,{get:()=>t[o],enumerable:!(n=C(t,o))||n.enumerable});return e};var m=e=>p(a({},"__esModule",{value:!0}),e);var l={};module.exports=m(l);
|
|
2
2
|
//# sourceMappingURL=ContextModule.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ContextModule.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ClearSignContext } from \"@/shared/model/ClearSignContext\";\n\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { type TypedDataClearSignContext } from \"./shared/model/TypedDataClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\n\nexport interface ContextModule {\n getContext(field: TransactionFieldContext): Promise<ClearSignContext>;\n getContexts(transaction: TransactionContext): Promise<ClearSignContext[]>;\n getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext>;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { type ClearSignContext } from \"@/shared/model/ClearSignContext\";\n\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { type TypedDataClearSignContext } from \"./shared/model/TypedDataClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport { type Web3CheckContext } from \"./web3-check/domain/web3CheckTypes\";\n\nexport interface ContextModule {\n getContext(field: TransactionFieldContext): Promise<ClearSignContext>;\n getContexts(transaction: TransactionContext): Promise<ClearSignContext[]>;\n getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext>;\n getWeb3Checks(\n transactionContext: Web3CheckContext,\n ): Promise<ClearSignContext | null>;\n}\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["ContextModule_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var u=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},f=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of c(e))!C.call(t,o)&&o!==r&&a(t,o,{get:()=>e[o],enumerable:!(n=s(e,o))||n.enumerable});return t};var l=t=>f(a({},"__esModule",{value:!0}),t);var m={};u(m,{ContextModuleBuilder:()=>L,DEFAULT_CONFIG:()=>d});module.exports=l(m);var i=require("./DefaultContextModule");const h="https://crypto-assets-service.api.ledger.com/v1",p="https://web3checks-backend.api.ledger.com/v3",d={cal:{url:h,mode:"prod",branch:"main"},web3checks:{url:p},defaultLoaders:!0,customLoaders:[],customTypedDataLoader:void 0};class L{config=d;constructor(){}removeDefaultLoaders(){return this.config.defaultLoaders=!1,this}addLoader(e){return this.config.customLoaders.push(e),this}addTypedDataLoader(e){return this.config.customTypedDataLoader=e,this}addWeb3CheckLoader(e){return this.config.customWeb3CheckLoader=e,this}addCalConfig(e){return this.config.cal={...d.cal,...e},this}addWeb3ChecksConfig(e){return this.config.web3checks={...d.web3checks,...e},this}build(){return new i.DefaultContextModule(this.config)}}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 {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\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\";\n\nexport const DEFAULT_CONFIG: ContextModuleConfig = {\n cal: {\n url: DEFAULT_CAL_URL,\n mode: \"prod\",\n branch: \"main\",\n },\n defaultLoaders: true,\n customLoaders: [],\n customTypedDataLoader: undefined,\n};\n\nexport class ContextModuleBuilder {\n private config: ContextModuleConfig = DEFAULT_CONFIG;\n\n constructor() {}\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 * Add a custom CAL configuration\n *\n * @param calConfig\n * @returns this\n */\n addCalConfig(calConfig: ContextModuleCalConfig) {\n this.config.cal = { ...DEFAULT_CONFIG.cal, ...calConfig };\n return this;\n }\n\n /**\n * Build the context module\n *\n * @returns the context module\n */\n build(): ContextModule {\n return new DefaultContextModule(this.config);\n }\n}\n"],
|
|
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", "loader", "calConfig"]
|
|
4
|
+
"sourcesContent": ["import {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleWeb3ChecksConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { type TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type Web3CheckContextLoader } from \"./web3-check/domain/Web3CheckContextLoader\";\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\";\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 defaultLoaders: true,\n customLoaders: [],\n customTypedDataLoader: undefined,\n};\n\nexport class ContextModuleBuilder {\n private config: ContextModuleConfig = DEFAULT_CONFIG;\n\n constructor() {}\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 web3 checks\n *\n * @param loader loader to use for web3 checks\n * @returns this\n */\n addWeb3CheckLoader(loader: Web3CheckContextLoader) {\n this.config.customWeb3CheckLoader = loader;\n return this;\n }\n\n /**\n * Add a custom CAL configuration\n *\n * @param calConfig\n * @returns this\n */\n addCalConfig(calConfig: ContextModuleCalConfig) {\n this.config.cal = { ...DEFAULT_CONFIG.cal, ...calConfig };\n return this;\n }\n\n /**\n * Add a custom web3 checks configuration\n *\n * @param web3ChecksConfig\n * @returns this\n */\n addWeb3ChecksConfig(web3ChecksConfig: ContextModuleWeb3ChecksConfig) {\n this.config.web3checks = {\n ...DEFAULT_CONFIG.web3checks,\n ...web3ChecksConfig,\n };\n return this;\n }\n\n /**\n * Build the context module\n *\n * @returns the context module\n */\n build(): ContextModule {\n return new DefaultContextModule(this.config);\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,mBAAAC,IAAA,eAAAC,EAAAJ,GASA,IAAAK,EAAqC,kCAErC,MAAMC,EAAkB,kDAClBC,EAA0B,+CAEnBJ,EAAsC,CACjD,IAAK,CACH,IAAKG,EACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAKC,CACP,EACA,eAAgB,GAChB,cAAe,CAAC,EAChB,sBAAuB,MACzB,EAEO,MAAML,CAAqB,CACxB,OAA8BC,EAEtC,aAAc,CAAC,CAOf,sBAAuB,CACrB,YAAK,OAAO,eAAiB,GACtB,IACT,CAQA,UAAUK,EAAuB,CAC/B,YAAK,OAAO,cAAc,KAAKA,CAAM,EAC9B,IACT,CAQA,mBAAmBA,EAAgC,CACjD,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,mBAAmBA,EAAgC,CACjD,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,aAAaC,EAAmC,CAC9C,YAAK,OAAO,IAAM,CAAE,GAAGN,EAAe,IAAK,GAAGM,CAAU,EACjD,IACT,CAQA,oBAAoBC,EAAiD,CACnE,YAAK,OAAO,WAAa,CACvB,GAAGP,EAAe,WAClB,GAAGO,CACL,EACO,IACT,CAOA,OAAuB,CACrB,OAAO,IAAI,uBAAqB,KAAK,MAAM,CAC7C,CACF",
|
|
6
|
+
"names": ["ContextModuleBuilder_exports", "__export", "ContextModuleBuilder", "DEFAULT_CONFIG", "__toCommonJS", "import_DefaultContextModule", "DEFAULT_CAL_URL", "DEFAULT_WEB3_CHECKS_URL", "loader", "calConfig", "web3ChecksConfig"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=require("./config/di/configTypes"),n=require("./ContextModuleBuilder"),d=require("./DefaultContextModule");describe("ContextModuleBuilder",()=>{const c={url:"https://cal/v1",mode:"prod",branch:"main"},u={url:"https://web3checks/v1"};it("should return a default context module",()=>{const e=new n.ContextModuleBuilder().build();expect(e).toBeInstanceOf(d.DefaultContextModule)}),it("should return a custom context module",()=>{const o=new n.ContextModuleBuilder,e={load:vi.fn()},t=o.removeDefaultLoaders().addLoader(e).build();expect(t).toBeInstanceOf(d.DefaultContextModule)}),it("should return a custom context module with a custom typed data loader",()=>{const o=new n.ContextModuleBuilder,e={load:vi.fn()},t=o.removeDefaultLoaders().addTypedDataLoader(e).build();expect(t).toBeInstanceOf(d.DefaultContextModule),expect(t._typedDataLoader).toBe(e)}),it("should return a custom context module with a custom config",()=>{const e=new n.ContextModuleBuilder().addCalConfig(c).addWeb3ChecksConfig(u).build(),t=e._container.get(a.configTypes.Config);expect(e).toBeInstanceOf(d.DefaultContextModule),expect(t.cal).toEqual(c),expect(t.web3checks).toEqual(u)}),it("should return a custom context module with a custom custom web3checks loader",()=>{const o=new n.ContextModuleBuilder,e={load:vi.fn()},t=o.removeDefaultLoaders().addWeb3CheckLoader(e).build();expect(t).toBeInstanceOf(d.DefaultContextModule),expect(t._web3CheckLoader).toBe(e)})});
|
|
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 ContextModuleCalConfig } from \"./config/model/ContextModuleConfig\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["import_ContextModuleBuilder", "import_DefaultContextModule", "defaultCalConfig", "res", "contextModuleBuilder", "customLoader"]
|
|
4
|
+
"sourcesContent": ["import { type Container } from \"inversify\";\n\nimport { configTypes } from \"./config/di/configTypes\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n} from \"./config/model/ContextModuleConfig\";\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 it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\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();\n const customLoader = { load: vi.fn() };\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();\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();\n\n const res = contextModuleBuilder\n .addCalConfig(defaultCalConfig)\n .addWeb3ChecksConfig(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 return a custom context module with a custom custom web3checks loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addWeb3CheckLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _web3CheckLoader is private\n expect(res[\"_web3CheckLoader\"]).toBe(customLoader);\n });\n});\n"],
|
|
5
|
+
"mappings": "aAEA,IAAAA,EAA4B,mCAK5BC,EAAqC,kCACrCC,EAAqC,kCAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA2C,CAC/C,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACMC,EAA0B,CAC9B,IAAK,uBACP,EACA,GAAG,yCAA0C,IAAM,CAGjD,MAAMC,EAFuB,IAAI,uBAAqB,EAErB,MAAM,EAEvC,OAAOA,CAAG,EAAE,eAAe,sBAAoB,CACjD,CAAC,EAED,GAAG,wCAAyC,IAAM,CAChD,MAAMC,EAAuB,IAAI,uBAC3BC,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,UAAUC,CAAY,EACtB,MAAM,EAET,OAAOF,CAAG,EAAE,eAAe,sBAAoB,CACjD,CAAC,EAED,GAAG,wEAAyE,IAAM,CAChF,MAAMC,EAAuB,IAAI,uBAC3BC,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,mBAAmBC,CAAY,EAC/B,MAAM,EAET,OAAOF,CAAG,EAAE,eAAe,sBAAoB,EAE/C,OAAOA,EAAI,gBAAmB,EAAE,KAAKE,CAAY,CACnD,CAAC,EAED,GAAG,6DAA8D,IAAM,CAGrE,MAAMF,EAFuB,IAAI,uBAAqB,EAGnD,aAAaF,CAAgB,EAC7B,oBAAoBC,CAAuB,EAC3C,MAAM,EAEHI,EAAUH,EAAI,WAA4B,IAC9C,cAAY,MACd,EAEA,OAAOA,CAAG,EAAE,eAAe,sBAAoB,EAC/C,OAAOG,EAAO,GAAG,EAAE,QAAQL,CAAgB,EAC3C,OAAOK,EAAO,UAAU,EAAE,QAAQJ,CAAuB,CAC3D,CAAC,EAED,GAAG,+EAAgF,IAAM,CACvF,MAAME,EAAuB,IAAI,uBAC3BC,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,mBAAmBC,CAAY,EAC/B,MAAM,EAET,OAAOF,CAAG,EAAE,eAAe,sBAAoB,EAE/C,OAAOA,EAAI,gBAAmB,EAAE,KAAKE,CAAY,CACnD,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_configTypes", "import_ContextModuleBuilder", "import_DefaultContextModule", "defaultCalConfig", "defaultWeb3ChecksConfig", "res", "contextModuleBuilder", "customLoader", "config"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var u=(r,e)=>{for(var o in e)n(r,o,{get:e[o],enumerable:!0})},T=(r,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of f(e))!h.call(r,t)&&t!==o&&n(r,t,{get:()=>e[t],enumerable:!(a=L(e,t))||a.enumerable});return r};var g=r=>T(n({},"__esModule",{value:!0}),r);var D={};u(D,{DefaultContextModule:()=>_});module.exports=g(D);var p=require("./transaction/di/transactionTypes"),d=require("./trusted-name/di/trustedNameTypes"),s=require("./external-plugin/di/externalPluginTypes"),C=require("./nft/di/nftTypes"),i=require("./shared/model/ClearSignContext"),m=require("./token/di/tokenTypes"),c=require("./typed-data/di/typedDataTypes"),l=require("./uniswap/di/uniswapTypes"),x=require("./web3-check/di/web3CheckTypes"),y=require("./di");class _{_container;_loaders;_typedDataLoader;_web3CheckLoader;constructor(e){this._container=(0,y.makeContainer)({config:e}),this._loaders=e.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...e.customLoaders),this._typedDataLoader=e.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._web3CheckLoader=e.customWeb3CheckLoader??this._getWeb3CheckLoader()}_getDefaultLoaders(){return[this._container.get(s.externalPluginTypes.ExternalPluginContextLoader),this._container.get(d.trustedNameTypes.TrustedNameContextLoader),this._container.get(C.nftTypes.NftContextLoader),this._container.get(m.tokenTypes.TokenContextLoader),this._container.get(p.transactionTypes.TransactionContextLoader),this._container.get(l.uniswapTypes.UniswapContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(c.typedDataTypes.TypedDataContextLoader)}_getWeb3CheckLoader(){return this._container.get(x.web3CheckTypes.Web3CheckContextLoader)}async getContexts(e){const o=this._loaders.map(t=>t.load(e));return(await Promise.all(o)).flat()}async getContext(e){const o=this._loaders.filter(t=>t.loadField).map(t=>t.loadField(e));return(await Promise.all(o)).find(t=>t!==null)||{type:i.ClearSignContextType.ERROR,error:new Error(`Field type not supported: ${e.type}`)}}async getTypedDataFilters(e){return this._typedDataLoader.load(e)}async getWeb3Checks(e){return(await this._web3CheckLoader.load(e)).caseOf({Right:a=>({type:i.ClearSignContextType.WEB3_CHECK,payload:a.descriptor,certificate:a.certificate}),Left:()=>null})}}0&&(module.exports={DefaultContextModule});
|
|
2
2
|
//# sourceMappingURL=DefaultContextModule.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/DefaultContextModule.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Container } from \"inversify\";\n\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { type ExternalPluginContextLoader } from \"./external-plugin/domain/ExternalPluginContextLoader\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { type NftContextLoader } from \"./nft/domain/NftContextLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { type TokenContextLoader } from \"./token/domain/TokenContextLoader\";\nimport { type TransactionContextLoader } from \"./transaction/domain/TransactionContextLoader\";\nimport { type TrustedNameContextLoader } from \"./trusted-name/domain/TrustedNameContextLoader\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { uniswapTypes } from \"./uniswap/di/uniswapTypes\";\nimport { type UniswapContextLoader } from \"./uniswap/domain/UniswapContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader[];\n private _typedDataLoader: TypedDataContextLoader;\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n }\n\n private _getDefaultLoaders(): ContextLoader[] {\n return [\n this._container.get<ExternalPluginContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<TrustedNameContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<NftContextLoader>(nftTypes.NftContextLoader),\n this._container.get<TokenContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<TransactionContextLoader>(\n transactionTypes.TransactionContextLoader,\n ),\n this._container.get<UniswapContextLoader>(\n uniswapTypes.UniswapContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n public async getContexts(\n transaction: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const promises = this._loaders.map((fetcher) => fetcher.load(transaction));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getContext(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext> {\n const promises = this._loaders\n .filter((fetcher) => fetcher.loadField)\n .map((fetcher) => fetcher.loadField!(field));\n const responses = await Promise.all(promises);\n return (\n responses.find((resp) => resp !== null) || {\n type: ClearSignContextType.ERROR,\n error: new Error(`Field type not supported: ${field.type}`),\n }\n );\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAiC,6CACjCC,EAAiC,8CAGjCC,EAAoC,oDAEpCC,EAAyB,6BAGzBC,
|
|
6
|
-
"names": ["DefaultContextModule_exports", "__export", "DefaultContextModule", "__toCommonJS", "import_transactionTypes", "import_trustedNameTypes", "import_externalPluginTypes", "import_nftTypes", "import_ClearSignContext", "import_tokenTypes", "import_typedDataTypes", "import_uniswapTypes", "import_di", "args", "transaction", "promises", "fetcher", "field", "resp", "typedData"]
|
|
4
|
+
"sourcesContent": ["import { type Container } from \"inversify\";\n\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { type ExternalPluginContextLoader } from \"./external-plugin/domain/ExternalPluginContextLoader\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { type NftContextLoader } from \"./nft/domain/NftContextLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { type TokenContextLoader } from \"./token/domain/TokenContextLoader\";\nimport { type TransactionContextLoader } from \"./transaction/domain/TransactionContextLoader\";\nimport { type TrustedNameContextLoader } from \"./trusted-name/domain/TrustedNameContextLoader\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { uniswapTypes } from \"./uniswap/di/uniswapTypes\";\nimport { type UniswapContextLoader } from \"./uniswap/domain/UniswapContextLoader\";\nimport { web3CheckTypes } from \"./web3-check/di/web3CheckTypes\";\nimport { type Web3CheckContextLoader } from \"./web3-check/domain/Web3CheckContextLoader\";\nimport {\n type Web3CheckContext,\n type Web3Checks,\n} from \"./web3-check/domain/web3CheckTypes\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader[];\n private _typedDataLoader: TypedDataContextLoader;\n private _web3CheckLoader: Web3CheckContextLoader;\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n this._web3CheckLoader =\n args.customWeb3CheckLoader ?? this._getWeb3CheckLoader();\n }\n\n private _getDefaultLoaders(): ContextLoader[] {\n return [\n this._container.get<ExternalPluginContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<TrustedNameContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<NftContextLoader>(nftTypes.NftContextLoader),\n this._container.get<TokenContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<TransactionContextLoader>(\n transactionTypes.TransactionContextLoader,\n ),\n this._container.get<UniswapContextLoader>(\n uniswapTypes.UniswapContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getWeb3CheckLoader(): Web3CheckContextLoader {\n return this._container.get<Web3CheckContextLoader>(\n web3CheckTypes.Web3CheckContextLoader,\n );\n }\n\n public async getContexts(\n transaction: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const promises = this._loaders.map((fetcher) => fetcher.load(transaction));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getContext(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext> {\n const promises = this._loaders\n .filter((fetcher) => fetcher.loadField)\n .map((fetcher) => fetcher.loadField!(field));\n const responses = await Promise.all(promises);\n return (\n responses.find((resp) => resp !== null) || {\n type: ClearSignContextType.ERROR,\n error: new Error(`Field type not supported: ${field.type}`),\n }\n );\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n\n public async getWeb3Checks(\n transactionContext: Web3CheckContext,\n ): Promise<ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null> {\n const web3Checks = await this._web3CheckLoader.load(transactionContext);\n\n return web3Checks.caseOf({\n Right: (checks: Web3Checks) => ({\n type: ClearSignContextType.WEB3_CHECK,\n payload: checks.descriptor,\n certificate: checks.certificate,\n }),\n Left: () => null,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAiC,6CACjCC,EAAiC,8CAGjCC,EAAoC,oDAEpCC,EAAyB,6BAGzBC,EAIO,2CAKPC,EAA2B,iCAI3BC,EAA+B,0CAE/BC,EAA6B,qCAE7BC,EAA+B,0CAO/BC,EAA8B,gBAEvB,MAAMX,CAA8C,CACjD,WACA,SACA,iBACA,iBAER,YAAYY,EAA2B,CACrC,KAAK,cAAa,iBAAc,CAAE,OAAQA,CAAK,CAAC,EAChD,KAAK,SAAWA,EAAK,eAAiB,KAAK,mBAAmB,EAAI,CAAC,EACnE,KAAK,SAAS,KAAK,GAAGA,EAAK,aAAa,EACxC,KAAK,iBACHA,EAAK,uBAAyB,KAAK,2BAA2B,EAChE,KAAK,iBACHA,EAAK,uBAAyB,KAAK,oBAAoB,CAC3D,CAEQ,oBAAsC,CAC5C,MAAO,CACL,KAAK,WAAW,IACd,sBAAoB,2BACtB,EACA,KAAK,WAAW,IACd,mBAAiB,wBACnB,EACA,KAAK,WAAW,IAAsB,WAAS,gBAAgB,EAC/D,KAAK,WAAW,IAAwB,aAAW,kBAAkB,EACrE,KAAK,WAAW,IACd,mBAAiB,wBACnB,EACA,KAAK,WAAW,IACd,eAAa,oBACf,CACF,CACF,CAEQ,4BAAqD,CAC3D,OAAO,KAAK,WAAW,IACrB,iBAAe,sBACjB,CACF,CAEQ,qBAA8C,CACpD,OAAO,KAAK,WAAW,IACrB,iBAAe,sBACjB,CACF,CAEA,MAAa,YACXC,EAC6B,CAC7B,MAAMC,EAAW,KAAK,SAAS,IAAKC,GAAYA,EAAQ,KAAKF,CAAW,CAAC,EAEzE,OADkB,MAAM,QAAQ,IAAIC,CAAQ,GAC3B,KAAK,CACxB,CAEA,MAAa,WACXE,EAC2B,CAC3B,MAAMF,EAAW,KAAK,SACnB,OAAQC,GAAYA,EAAQ,SAAS,EACrC,IAAKA,GAAYA,EAAQ,UAAWC,CAAK,CAAC,EAE7C,OADkB,MAAM,QAAQ,IAAIF,CAAQ,GAEhC,KAAMG,GAASA,IAAS,IAAI,GAAK,CACzC,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,6BAA6BD,EAAM,IAAI,EAAE,CAC5D,CAEJ,CAEA,MAAa,oBACXE,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CAEA,MAAa,cACXC,EAC0E,CAG1E,OAFmB,MAAM,KAAK,iBAAiB,KAAKA,CAAkB,GAEpD,OAAO,CACvB,MAAQC,IAAwB,CAC9B,KAAM,uBAAqB,WAC3B,QAASA,EAAO,WAChB,YAAaA,EAAO,WACtB,GACA,KAAM,IAAM,IACd,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["DefaultContextModule_exports", "__export", "DefaultContextModule", "__toCommonJS", "import_transactionTypes", "import_trustedNameTypes", "import_externalPluginTypes", "import_nftTypes", "import_ClearSignContext", "import_tokenTypes", "import_typedDataTypes", "import_uniswapTypes", "import_web3CheckTypes", "import_di", "args", "transaction", "promises", "fetcher", "field", "resp", "typedData", "transactionContext", "checks"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=require("./DefaultContextModule");const l=()=>({load:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const
|
|
1
|
+
"use strict";var r=require("@ledgerhq/device-management-kit"),c=require("purify-ts"),o=require("./DefaultContextModule");const l=()=>({load:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const s={load:vi.fn()},a={customLoaders:[],defaultLoaders:!1,customTypedDataLoader:s,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"}};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new o.DefaultContextModule(a).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new o.DefaultContextModule(a).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=l();await new o.DefaultContextModule({...a,customLoaders:[e,e]}).getContexts({}),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=l(),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const d=await new o.DefaultContextModule({...a,customLoaders:[e,e]}).getContexts({});expect(e.load).toHaveBeenCalledTimes(2),expect(d).toEqual(t.flat())}),it("should call the typed data loader",async()=>{await new o.DefaultContextModule({...a,customTypedDataLoader:s}).getTypedDataFilters({}),expect(s.load).toHaveBeenCalledTimes(1)}),it("should return a single context",async()=>{const e=l(),t=[null,{type:"token",payload:"payload"}];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const d=await new o.DefaultContextModule({...a,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(d).toEqual({type:"token",payload:"payload"})}),it("should return a web3 check context",async()=>{const e=l();vi.spyOn(e,"load").mockResolvedValueOnce((0,c.Right)({descriptor:"payload"}));const n=await new o.DefaultContextModule({...a,customLoaders:[],customWeb3CheckLoader:e}).getWeb3Checks({deviceModelId:r.DeviceModelId.FLEX,from:"from",rawTx:"rawTx",chainId:1});expect(e.load).toHaveBeenCalledTimes(1),expect(n).toEqual({type:"web3Check",payload:"payload"})}),it("should return null if no web3 check context",async()=>{const e=l();vi.spyOn(e,"load").mockResolvedValue((0,c.Left)(new Error("error")));const n=await new o.DefaultContextModule({...a,customLoaders:[],customWeb3CheckLoader:e}).getWeb3Checks({deviceModelId:r.DeviceModelId.FLEX,from:"from",rawTx:"rawTx",chainId:1});expect(e.load).toHaveBeenCalledTimes(1),expect(n).toBeNull()}),it("context field not supported",async()=>{const e=l(),t=[null,null];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const d=await new o.DefaultContextModule({...a,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(d).toEqual({type:"error",error:new Error("Field type not supported: token")})}),it("getField not implemented",async()=>{const t=await new o.DefaultContextModule({...a,customLoaders:[{load:vi.fn()}]}).getContext({type:"token"});expect(t).toEqual({type:"error",error:new Error("Field type not supported: token")})})});
|
|
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 {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = () => {\n return { load: vi.fn(), loadField: vi.fn() };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["import_DefaultContextModule", "contextLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses"]
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = () => {\n return { load: vi.fn(), loadField: vi.fn() };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\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 };\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({} as TransactionContext);\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({} as TransactionContext);\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder();\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ];\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({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\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 it(\"should return a single context\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, { type: \"token\", payload: \"payload\" }];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({ type: \"token\", payload: \"payload\" });\n });\n\n it(\"should return a web3 check context\", async () => {\n const loader = contextLoaderStubBuilder();\n vi.spyOn(loader, \"load\").mockResolvedValueOnce(\n Right({ descriptor: \"payload\" }),\n );\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toEqual({ type: \"web3Check\", payload: \"payload\" });\n });\n\n it(\"should return null if no web3 check context\", async () => {\n const loader = contextLoaderStubBuilder();\n vi.spyOn(loader, \"load\").mockResolvedValue(Left(new Error(\"error\")));\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toBeNull();\n });\n\n it(\"context field not supported\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, null];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n\n it(\"getField not implemented\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [{ load: vi.fn() }],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAA8B,2CAC9BC,EAA4B,qBAS5BC,EAAqC,kCAErC,MAAMC,EAA2B,KACxB,CAAE,KAAM,GAAG,GAAG,EAAG,UAAW,GAAG,GAAG,CAAE,GAG7C,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,EAC1DC,EAAkD,CACtD,cAAe,CAAC,EAChB,eAAgB,GAChB,sBAAuBD,EACvB,IAAK,CACH,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAK,uBACP,CACF,EAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,CACrB,CAAC,EAED,GAAG,oEAAqE,SAAY,CAGlF,MAAME,EAAM,MAFU,IAAI,uBAAqBD,CAA0B,EAEzC,YAAY,CAAC,CAAuB,EAEpE,OAAOC,CAAG,EAAE,QAAQ,CAAC,CAAC,CACxB,CAAC,EAED,GAAG,+CAAgD,SAAY,CAG7D,MAAMA,EAAM,MAFU,IAAI,uBAAqBD,CAA0B,EAEzC,YAAY,CAAC,CAAuB,EAEpE,OAAOC,CAAG,EAAE,QAAQ,CAAC,CAAC,CACxB,CAAC,EAED,GAAG,qDAAsD,SAAY,CACnE,MAAMC,EAASJ,EAAyB,EAMxC,MALsB,IAAI,uBAAqB,CAC7C,GAAGE,EACH,cAAe,CAACE,EAAQA,CAAM,CAChC,CAAC,EAEmB,YAAY,CAAC,CAAuB,EAExD,OAAOA,EAAO,IAAI,EAAE,sBAAsB,CAAC,CAC7C,CAAC,EAED,GAAG,6CAA8C,SAAY,CAC3D,MAAMA,EAASJ,EAAyB,EAClCK,EAAY,CAChB,CAAC,CAAE,KAAM,mBAAoB,QAAS,UAAW,CAAC,EAClD,CACE,CAAE,KAAM,mBAAoB,QAAS,UAAW,EAChD,CAAE,KAAM,SAAU,QAAS,UAAW,CACxC,CACF,EACA,GAAG,MAAMD,EAAQ,MAAM,EACpB,sBAAsBC,EAAU,CAAC,CAAC,EAClC,sBAAsBA,EAAU,CAAC,CAAC,EAMrC,MAAMF,EAAM,MALU,IAAI,uBAAqB,CAC7C,GAAGD,EACH,cAAe,CAACE,EAAQA,CAAM,CAChC,CAAC,EAE+B,YAAY,CAAC,CAAuB,EAEpE,OAAOA,EAAO,IAAI,EAAE,sBAAsB,CAAC,EAC3C,OAAOD,CAAG,EAAE,QAAQE,EAAU,KAAK,CAAC,CACtC,CAAC,EAED,GAAG,oCAAqC,SAAY,CAMlD,MALsB,IAAI,uBAAqB,CAC7C,GAAGH,EACH,sBAAuBD,CACzB,CAAC,EAEmB,oBAAoB,CAAC,CAAqB,EAE9D,OAAOA,EAAgB,IAAI,EAAE,sBAAsB,CAAC,CACtD,CAAC,EAED,GAAG,iCAAkC,SAAY,CAC/C,MAAMG,EAASJ,EAAyB,EAClCK,EAAY,CAAC,KAAM,CAAE,KAAM,QAAS,QAAS,SAAU,CAAC,EAC9D,GAAG,MAAMD,EAAQ,WAAW,EACzB,sBAAsBC,EAAU,CAAC,CAAC,EAClC,sBAAsBA,EAAU,CAAC,CAAC,EAMrC,MAAMF,EAAM,MALU,IAAI,uBAAqB,CAC7C,GAAGD,EACH,cAAe,CAACE,EAAQ,CAAE,KAAM,GAAG,GAAG,CAAE,EAAGA,CAAM,CACnD,CAAC,EAE+B,WAAW,CACzC,KAAM,OACR,CAA4B,EAE5B,OAAOA,EAAO,SAAS,EAAE,sBAAsB,CAAC,EAChD,OAAOD,CAAG,EAAE,QAAQ,CAAE,KAAM,QAAS,QAAS,SAAU,CAAC,CAC3D,CAAC,EAED,GAAG,qCAAsC,SAAY,CACnD,MAAMC,EAASJ,EAAyB,EACxC,GAAG,MAAMI,EAAQ,MAAM,EAAE,yBACvB,SAAM,CAAE,WAAY,SAAU,CAAC,CACjC,EAOA,MAAMD,EAAM,MANU,IAAI,uBAAqB,CAC7C,GAAGD,EACH,cAAe,CAAC,EAChB,sBAAuBE,CACzB,CAAC,EAE+B,cAAc,CAC5C,cAAe,gBAAc,KAC7B,KAAM,OACN,MAAO,QACP,QAAS,CACX,CAAC,EAED,OAAOA,EAAO,IAAI,EAAE,sBAAsB,CAAC,EAC3C,OAAOD,CAAG,EAAE,QAAQ,CAAE,KAAM,YAAa,QAAS,SAAU,CAAC,CAC/D,CAAC,EAED,GAAG,8CAA+C,SAAY,CAC5D,MAAMC,EAASJ,EAAyB,EACxC,GAAG,MAAMI,EAAQ,MAAM,EAAE,qBAAkB,QAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EAOnE,MAAMD,EAAM,MANU,IAAI,uBAAqB,CAC7C,GAAGD,EACH,cAAe,CAAC,EAChB,sBAAuBE,CACzB,CAAC,EAE+B,cAAc,CAC5C,cAAe,gBAAc,KAC7B,KAAM,OACN,MAAO,QACP,QAAS,CACX,CAAC,EAED,OAAOA,EAAO,IAAI,EAAE,sBAAsB,CAAC,EAC3C,OAAOD,CAAG,EAAE,SAAS,CACvB,CAAC,EAED,GAAG,8BAA+B,SAAY,CAC5C,MAAMC,EAASJ,EAAyB,EAClCK,EAAY,CAAC,KAAM,IAAI,EAC7B,GAAG,MAAMD,EAAQ,WAAW,EACzB,sBAAsBC,EAAU,CAAC,CAAC,EAClC,sBAAsBA,EAAU,CAAC,CAAC,EAMrC,MAAMF,EAAM,MALU,IAAI,uBAAqB,CAC7C,GAAGD,EACH,cAAe,CAACE,EAAQ,CAAE,KAAM,GAAG,GAAG,CAAE,EAAGA,CAAM,CACnD,CAAC,EAE+B,WAAW,CACzC,KAAM,OACR,CAA4B,EAE5B,OAAOA,EAAO,SAAS,EAAE,sBAAsB,CAAC,EAChD,OAAOD,CAAG,EAAE,QAAQ,CAClB,KAAM,QACN,MAAO,IAAI,MAAM,iCAAiC,CACpD,CAAC,CACH,CAAC,EAED,GAAG,2BAA4B,SAAY,CAMzC,MAAMA,EAAM,MALU,IAAI,uBAAqB,CAC7C,GAAGD,EACH,cAAe,CAAC,CAAE,KAAM,GAAG,GAAG,CAAE,CAAC,CACnC,CAAC,EAE+B,WAAW,CACzC,KAAM,OACR,CAA4B,EAE5B,OAAOC,CAAG,EAAE,QAAQ,CAClB,KAAM,QACN,MAAO,IAAI,MAAM,iCAAiC,CACpD,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_device_management_kit", "import_purify_ts", "import_DefaultContextModule", "contextLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var l=(o,e,r,C)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of n(e))!x.call(o,t)&&t!==r&&a(o,t,{get:()=>e[t],enumerable:!(C=d(e,t))||C.enumerable});return o};var p=o=>l(a({},"__esModule",{value:!0}),o);var u={};module.exports=p(u);
|
|
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 ContextLoader } from \"@/shared/domain/ContextLoader\";\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 ContextModuleConfig = {\n cal: ContextModuleCalConfig;\n defaultLoaders: boolean;\n customLoaders: ContextLoader[];\n customTypedDataLoader?: TypedDataContextLoader;\n};\n"],
|
|
4
|
+
"sourcesContent": ["import { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport { type TypedDataContextLoader } from \"@/typed-data/domain/TypedDataContextLoader\";\nimport { type Web3CheckContextLoader } from \"@/web3-check/domain/Web3CheckContextLoader\";\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 ContextModuleConfig = {\n cal: ContextModuleCalConfig;\n web3checks: ContextModuleWeb3ChecksConfig;\n defaultLoaders: boolean;\n customLoaders: ContextLoader[];\n customTypedDataLoader?: TypedDataContextLoader;\n customWeb3CheckLoader?: Web3CheckContextLoader;\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 n=Object.defineProperty;var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var k=(r,o)=>{for(var e in o)n(r,e,{get:o[e],enumerable:!0})},x=(r,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of g(o))!s.call(r,t)&&t!==e&&n(r,t,{get:()=>o[t],enumerable:!(a=C(o,t))||a.enumerable});return r};var w=r=>x(n({},"__esModule",{value:!0}),r);var P={};k(P,{makeContainer:()=>A});module.exports=w(P);var m=require("inversify"),i=require("./config/di/configModuleFactory"),c=require("./external-plugin/di/externalPluginModuleFactory"),f=require("./nft/di/nftModuleFactory"),p=require("./pki/di/pkiModuleFactory"),u=require("./token/di/tokenModuleFactory"),d=require("./transaction/di/transactionModuleFactory"),l=require("./trusted-name/di/trustedNameModuleFactory"),M=require("./typed-data/di/typedDataModuleFactory"),y=require("./uniswap/di/uniswapModuleFactory"),F=require("./web3-check/di/web3CheckModuleFactory");const A=({config:r})=>{const o=new m.Container;return o.load((0,i.configModuleFactory)(r),(0,c.externalPluginModuleFactory)(),(0,f.nftModuleFactory)(),(0,u.tokenModuleFactory)(),(0,d.transactionModuleFactory)(),(0,l.trustedNameModuleFactory)(),(0,M.typedDataModuleFactory)(),(0,p.nanoPkiModuleFactory)(),(0,y.uniswapModuleFactory)(),(0,F.web3CheckModuleFactory)()),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 { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionModuleFactory } from \"@/transaction/di/transactionModuleFactory\";\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.load(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n nftModuleFactory(),\n tokenModuleFactory(),\n transactionModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n );\n\n return container;\n};\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAE1BC,EAAoC,2CAEpCC,EAA4C,4DAC5CC,EAAiC,qCACjCC,EAAqC,qCACrCC,EAAmC,yCACnCC,EAAyC,qDACzCC,EAAyC,sDACzCC,EAAuC,kDACvCC,EAAqC,
|
|
6
|
-
"names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_configModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_pkiModuleFactory", "import_tokenModuleFactory", "import_transactionModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "import_uniswapModuleFactory", "config", "container"]
|
|
4
|
+
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionModuleFactory } from \"@/transaction/di/transactionModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\nimport { web3CheckModuleFactory } from \"@/web3-check/di/web3CheckModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.load(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n nftModuleFactory(),\n tokenModuleFactory(),\n transactionModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n web3CheckModuleFactory(),\n );\n\n return container;\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAE1BC,EAAoC,2CAEpCC,EAA4C,4DAC5CC,EAAiC,qCACjCC,EAAqC,qCACrCC,EAAmC,yCACnCC,EAAyC,qDACzCC,EAAyC,sDACzCC,EAAuC,kDACvCC,EAAqC,6CACrCC,EAAuC,kDAMhC,MAAMZ,EAAgB,CAAC,CAAE,OAAAa,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAI,YAEtB,OAAAA,EAAU,QACR,uBAAoBD,CAAM,KAC1B,+BAA4B,KAC5B,oBAAiB,KACjB,sBAAmB,KACnB,4BAAyB,KACzB,4BAAyB,KACzB,0BAAuB,KACvB,wBAAqB,KACrB,wBAAqB,KACrB,0BAAuB,CACzB,EAEOC,CACT",
|
|
6
|
+
"names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_configModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_pkiModuleFactory", "import_tokenModuleFactory", "import_transactionModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "import_uniswapModuleFactory", "import_web3CheckModuleFactory", "config", "container"]
|
|
7
7
|
}
|
package/lib/cjs/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("./config/model/ContextModuleConfig"),module.exports);r(o,require("./ContextModule"),module.exports);r(o,require("./ContextModuleBuilder"),module.exports);r(o,require("./DefaultContextModule"),module.exports);r(o,require("./external-plugin/domain/ExternalPluginContextLoader"),module.exports);r(o,require("./nft/domain/NftContextLoader"),module.exports);r(o,require("./pki/domain/PkiCertificateLoader"),module.exports);r(o,require("./pki/model/KeyId"),module.exports);r(o,require("./pki/model/KeyUsage"),module.exports);r(o,require("./pki/model/PkiCertificate"),module.exports);r(o,require("./pki/model/PkiCertificateInfo"),module.exports);r(o,require("./shared/domain/ContextLoader"),module.exports);r(o,require("./shared/model/ClearSignContext"),module.exports);r(o,require("./shared/model/GenericPath"),module.exports);r(o,require("./shared/model/TransactionContext"),module.exports);r(o,require("./shared/model/TransactionSubset"),module.exports);r(o,require("./shared/model/TypedDataClearSignContext"),module.exports);r(o,require("./shared/model/TypedDataContext"),module.exports);r(o,require("./token/domain/TokenContextLoader"),module.exports);r(o,require("./trusted-name/domain/TrustedNameContextLoader"),module.exports);0&&(module.exports={...require("./config/model/ContextModuleConfig"),...require("./ContextModule"),...require("./ContextModuleBuilder"),...require("./DefaultContextModule"),...require("./external-plugin/domain/ExternalPluginContextLoader"),...require("./nft/domain/NftContextLoader"),...require("./pki/domain/PkiCertificateLoader"),...require("./pki/model/KeyId"),...require("./pki/model/KeyUsage"),...require("./pki/model/PkiCertificate"),...require("./pki/model/PkiCertificateInfo"),...require("./shared/domain/ContextLoader"),...require("./shared/model/ClearSignContext"),...require("./shared/model/GenericPath"),...require("./shared/model/TransactionContext"),...require("./shared/model/TransactionSubset"),...require("./shared/model/TypedDataClearSignContext"),...require("./shared/model/TypedDataContext"),...require("./token/domain/TokenContextLoader"),...require("./trusted-name/domain/TrustedNameContextLoader")});
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("./config/model/ContextModuleConfig"),module.exports);r(o,require("./ContextModule"),module.exports);r(o,require("./ContextModuleBuilder"),module.exports);r(o,require("./DefaultContextModule"),module.exports);r(o,require("./external-plugin/domain/ExternalPluginContextLoader"),module.exports);r(o,require("./nft/domain/NftContextLoader"),module.exports);r(o,require("./pki/domain/PkiCertificateLoader"),module.exports);r(o,require("./pki/model/KeyId"),module.exports);r(o,require("./pki/model/KeyUsage"),module.exports);r(o,require("./pki/model/PkiCertificate"),module.exports);r(o,require("./pki/model/PkiCertificateInfo"),module.exports);r(o,require("./shared/domain/ContextLoader"),module.exports);r(o,require("./shared/model/ClearSignContext"),module.exports);r(o,require("./shared/model/GenericPath"),module.exports);r(o,require("./shared/model/TransactionContext"),module.exports);r(o,require("./shared/model/TransactionSubset"),module.exports);r(o,require("./shared/model/TypedDataClearSignContext"),module.exports);r(o,require("./shared/model/TypedDataContext"),module.exports);r(o,require("./token/domain/TokenContextLoader"),module.exports);r(o,require("./trusted-name/domain/TrustedNameContextLoader"),module.exports);r(o,require("./web3-check/domain/Web3CheckContextLoader"),module.exports);r(o,require("./web3-check/domain/web3CheckTypes"),module.exports);0&&(module.exports={...require("./config/model/ContextModuleConfig"),...require("./ContextModule"),...require("./ContextModuleBuilder"),...require("./DefaultContextModule"),...require("./external-plugin/domain/ExternalPluginContextLoader"),...require("./nft/domain/NftContextLoader"),...require("./pki/domain/PkiCertificateLoader"),...require("./pki/model/KeyId"),...require("./pki/model/KeyUsage"),...require("./pki/model/PkiCertificate"),...require("./pki/model/PkiCertificateInfo"),...require("./shared/domain/ContextLoader"),...require("./shared/model/ClearSignContext"),...require("./shared/model/GenericPath"),...require("./shared/model/TransactionContext"),...require("./shared/model/TransactionSubset"),...require("./shared/model/TypedDataClearSignContext"),...require("./shared/model/TypedDataContext"),...require("./token/domain/TokenContextLoader"),...require("./trusted-name/domain/TrustedNameContextLoader"),...require("./web3-check/domain/Web3CheckContextLoader"),...require("./web3-check/domain/web3CheckTypes")});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/src/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionContext\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\n"],
|
|
5
|
-
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,8CAAd,gBACAE,EAAAF,EAAc,2BADd,gBAEAE,EAAAF,EAAc,kCAFd,gBAGAE,EAAAF,EAAc,kCAHd,gBAIAE,EAAAF,EAAc,gEAJd,gBAKAE,EAAAF,EAAc,yCALd,gBAMAE,EAAAF,EAAc,6CANd,gBAOAE,EAAAF,EAAc,6BAPd,gBAQAE,EAAAF,EAAc,gCARd,gBASAE,EAAAF,EAAc,sCATd,gBAUAE,EAAAF,EAAc,0CAVd,gBAWAE,EAAAF,EAAc,yCAXd,gBAYAE,EAAAF,EAAc,2CAZd,gBAaAE,EAAAF,EAAc,sCAbd,gBAcAE,EAAAF,EAAc,6CAdd,gBAeAE,EAAAF,EAAc,4CAfd,gBAgBAE,EAAAF,EAAc,oDAhBd,gBAiBAE,EAAAF,EAAc,2CAjBd,gBAkBAE,EAAAF,EAAc,6CAlBd,gBAmBAE,EAAAF,EAAc,0DAnBd",
|
|
4
|
+
"sourcesContent": ["export * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionContext\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./web3-check/domain/Web3CheckContextLoader\";\nexport * from \"./web3-check/domain/web3CheckTypes\";\n"],
|
|
5
|
+
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,8CAAd,gBACAE,EAAAF,EAAc,2BADd,gBAEAE,EAAAF,EAAc,kCAFd,gBAGAE,EAAAF,EAAc,kCAHd,gBAIAE,EAAAF,EAAc,gEAJd,gBAKAE,EAAAF,EAAc,yCALd,gBAMAE,EAAAF,EAAc,6CANd,gBAOAE,EAAAF,EAAc,6BAPd,gBAQAE,EAAAF,EAAc,gCARd,gBASAE,EAAAF,EAAc,sCATd,gBAUAE,EAAAF,EAAc,0CAVd,gBAWAE,EAAAF,EAAc,yCAXd,gBAYAE,EAAAF,EAAc,2CAZd,gBAaAE,EAAAF,EAAc,sCAbd,gBAcAE,EAAAF,EAAc,6CAdd,gBAeAE,EAAAF,EAAc,4CAfd,gBAgBAE,EAAAF,EAAc,oDAhBd,gBAiBAE,EAAAF,EAAc,2CAjBd,gBAkBAE,EAAAF,EAAc,6CAlBd,gBAmBAE,EAAAF,EAAc,0DAnBd,gBAoBAE,EAAAF,EAAc,sDApBd,gBAqBAE,EAAAF,EAAc,8CArBd",
|
|
6
6
|
"names": ["src_exports", "__toCommonJS", "__reExport"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=require("purify-ts"),r=require("../../pki/domain/DefaultPkiCertificateLoader"),c=require("../../pki/model/KeyUsage");describe("DefaultPkiCertificateLoader",()=>{describe("loadCertificate",()=>{it("should call loadCertificate",async()=>{const e={targetDevice:"targetDevice",keyUsage:c.KeyUsage.Calldata,keyId:
|
|
1
|
+
"use strict";var i=require("purify-ts"),r=require("../../pki/domain/DefaultPkiCertificateLoader"),o=require("../../pki/model/KeyId"),c=require("../../pki/model/KeyUsage");describe("DefaultPkiCertificateLoader",()=>{describe("loadCertificate",()=>{it("should call loadCertificate",async()=>{const e={targetDevice:"targetDevice",keyUsage:c.KeyUsage.Calldata,keyId:o.KeyId.CalNetwork},t={keyUsageNumber:11,payload:new Uint8Array([1,2,3,4,21,4,5,6,7,8])},a={fetchCertificate:vi.fn().mockResolvedValue((0,i.Right)(t))},f=await new r.DefaultPkiCertificateLoader(a).loadCertificate(e);expect(f).toEqual(t),expect(a.fetchCertificate).toHaveBeenCalledWith(e)})})});
|
|
2
2
|
//# sourceMappingURL=DefaultPkiCertificateLoader.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/pki/domain/DefaultPkiCertificateLoader.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Right } from \"purify-ts\";\n\nimport { DefaultPkiCertificateLoader } from \"@/pki/domain/DefaultPkiCertificateLoader\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\n\ndescribe(\"DefaultPkiCertificateLoader\", () => {\n describe(\"loadCertificate\", () => {\n it(\"should call loadCertificate\", async () => {\n // GIVEN\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: \"targetDevice\",\n keyUsage: KeyUsage.Calldata,\n keyId:
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAAsB,qBAEtBC,EAA4C,oDAC5CC,EAAyB,gCAGzB,SAAS,8BAA+B,IAAM,CAC5C,SAAS,kBAAmB,IAAM,CAChC,GAAG,8BAA+B,SAAY,CAE5C,MAAMC,EAAuC,CAC3C,aAAc,eACd,SAAU,WAAS,SACnB,MAAO,
|
|
6
|
-
"names": ["import_purify_ts", "import_DefaultPkiCertificateLoader", "import_KeyUsage", "certificateInfos", "certificate", "dataSource", "result"]
|
|
4
|
+
"sourcesContent": ["import { Right } from \"purify-ts\";\n\nimport { DefaultPkiCertificateLoader } from \"@/pki/domain/DefaultPkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\n\ndescribe(\"DefaultPkiCertificateLoader\", () => {\n describe(\"loadCertificate\", () => {\n it(\"should call loadCertificate\", async () => {\n // GIVEN\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: \"targetDevice\",\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalNetwork,\n };\n const certificate = {\n keyUsageNumber: 11,\n payload: new Uint8Array([\n 0x01, 0x02, 0x03, 0x04, 0x15, 0x04, 0x05, 0x06, 0x07, 0x08,\n ]),\n };\n const dataSource = {\n fetchCertificate: vi.fn().mockResolvedValue(Right(certificate)),\n };\n\n // WHEN\n const loader = new DefaultPkiCertificateLoader(dataSource);\n const result = await loader.loadCertificate(certificateInfos);\n\n // THEN\n expect(result).toEqual(certificate);\n expect(dataSource.fetchCertificate).toHaveBeenCalledWith(\n certificateInfos,\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAAsB,qBAEtBC,EAA4C,oDAC5CC,EAAsB,6BACtBC,EAAyB,gCAGzB,SAAS,8BAA+B,IAAM,CAC5C,SAAS,kBAAmB,IAAM,CAChC,GAAG,8BAA+B,SAAY,CAE5C,MAAMC,EAAuC,CAC3C,aAAc,eACd,SAAU,WAAS,SACnB,MAAO,QAAM,UACf,EACMC,EAAc,CAClB,eAAgB,GAChB,QAAS,IAAI,WAAW,CACtB,EAAM,EAAM,EAAM,EAAM,GAAM,EAAM,EAAM,EAAM,EAAM,CACxD,CAAC,CACH,EACMC,EAAa,CACjB,iBAAkB,GAAG,GAAG,EAAE,qBAAkB,SAAMD,CAAW,CAAC,CAChE,EAIME,EAAS,MADA,IAAI,8BAA4BD,CAAU,EAC7B,gBAAgBF,CAAgB,EAG5D,OAAOG,CAAM,EAAE,QAAQF,CAAW,EAClC,OAAOC,EAAW,gBAAgB,EAAE,qBAClCF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_purify_ts", "import_DefaultPkiCertificateLoader", "import_KeyId", "import_KeyUsage", "certificateInfos", "certificate", "dataSource", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var
|
|
1
|
+
"use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var p=(t,e,y,g)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of s(e))!o.call(t,i)&&i!==y&&r(t,i,{get:()=>e[i],enumerable:!(g=a(e,i))||g.enumerable});return t};var k=t=>p(r({},"__esModule",{value:!0}),t);var U={};module.exports=k(U);
|
|
2
2
|
//# sourceMappingURL=PkiCertificateInfo.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/pki/model/PkiCertificateInfo.ts"],
|
|
4
|
-
"sourcesContent": ["import type { KeyUsage } from \"@/pki/model/KeyUsage\";\n\nexport type PkiCertificateInfo = {\n targetDevice: string;\n keyUsage: KeyUsage;\n keyId
|
|
4
|
+
"sourcesContent": ["import type { KeyUsage } from \"@/pki/model/KeyUsage\";\n\nexport type PkiCertificateInfo = {\n targetDevice: string;\n keyUsage: KeyUsage;\n keyId: string;\n};\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["PkiCertificateInfo_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var c=(r,t)=>{for(var i in t)a(r,i,{get:t[i],enumerable:!0})},l=(r,t,i,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of y(t))!T.call(r,n)&&n!==i&&a(r,n,{get:()=>t[n],enumerable:!(p=o(t,n))||p.enumerable});return r};var x=r=>l(a({},"__esModule",{value:!0}),r);var E={};c(E,{ClearSignContextType:()=>C});module.exports=x(E);var C=(e=>(e.TOKEN="token",e.NFT="nft",e.TRUSTED_NAME="trustedName",e.PLUGIN="plugin",e.EXTERNAL_PLUGIN="externalPlugin",e.TRANSACTION_INFO="transactionInfo",e.ENUM="enum",e.TRANSACTION_FIELD_DESCRIPTION="transactionFieldDescription",e.WEB3_CHECK="web3Check",e.ERROR="error",e))(C||{});0&&(module.exports={ClearSignContextType});
|
|
2
2
|
//# sourceMappingURL=ClearSignContext.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/model/ClearSignContext.ts"],
|
|
4
|
-
"sourcesContent": ["import { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nimport { type GenericPath } from \"./GenericPath\";\n\nexport enum ClearSignContextType {\n TOKEN = \"token\",\n NFT = \"nft\",\n TRUSTED_NAME = \"trustedName\",\n PLUGIN = \"plugin\",\n EXTERNAL_PLUGIN = \"externalPlugin\",\n TRANSACTION_INFO = \"transactionInfo\",\n ENUM = \"enum\",\n TRANSACTION_FIELD_DESCRIPTION = \"transactionFieldDescription\",\n ERROR = \"error\",\n}\n\nexport type ClearSignContextReferenceType =\n | ClearSignContextType.TOKEN\n | ClearSignContextType.NFT\n | ClearSignContextType.ENUM\n | ClearSignContextType.TRUSTED_NAME;\n\nexport type ClearSignContextReference<\n Type extends ClearSignContextReferenceType = ClearSignContextReferenceType,\n> = Type extends ClearSignContextType.ENUM\n ? {\n type: ClearSignContextType.ENUM;\n valuePath: GenericPath;\n id: number; // enum id to reference\n }\n : Type extends ClearSignContextType.TRUSTED_NAME\n ? {\n type: ClearSignContextType.TRUSTED_NAME;\n valuePath: GenericPath;\n types: string[];\n sources: string[];\n }\n :\n | {\n type: Type;\n valuePath: GenericPath;\n value?: never;\n }\n | {\n type: Type;\n valuePath?: never;\n value: string;\n };\n\nexport type ClearSignContextSuccessType = Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n>;\n\n// NOTE: this is a union of all possible success types\n// There is currently two types of success:\n// - ENUM: which is a special case, we need to handle it differently\n// because we don't want to send the whole enum\n// but only the parts that are needed.\n// - id: the enum id to reference\n// - payload: the payload to send with a provideEnum command\n// - name: the name of the enum to be displayed on the device\n// - value: the value of the enum to be retrieved from the transaction\n// - All other types\n// - payload: the payload to send with a provide command\n// - reference: the reference to the value to be retrieved from the transaction\nexport type ClearSignContextSuccess<\n Type extends ClearSignContextSuccessType = ClearSignContextSuccessType,\n> = Type extends ClearSignContextType.ENUM\n ? {\n type: ClearSignContextType.ENUM;\n id: number;\n payload: string;\n value: number;\n certificate?: PkiCertificate;\n }\n : {\n type: Exclude<\n ClearSignContextType,\n ClearSignContextType.ENUM | ClearSignContextType.ERROR\n >;\n payload: string;\n reference?: ClearSignContextReference;\n certificate?: PkiCertificate;\n };\n\nexport type ClearSignContextError = {\n type: ClearSignContextType.ERROR;\n error: Error;\n};\n\nexport type ClearSignContext = ClearSignContextSuccess | ClearSignContextError;\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAIO,IAAKE,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,OAAS,SACTA,EAAA,gBAAkB,iBAClBA,EAAA,iBAAmB,kBACnBA,EAAA,KAAO,OACPA,EAAA,8BAAgC,8BAChCA,EAAA,MAAQ,
|
|
4
|
+
"sourcesContent": ["import { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nimport { type GenericPath } from \"./GenericPath\";\n\nexport enum ClearSignContextType {\n TOKEN = \"token\",\n NFT = \"nft\",\n TRUSTED_NAME = \"trustedName\",\n PLUGIN = \"plugin\",\n EXTERNAL_PLUGIN = \"externalPlugin\",\n TRANSACTION_INFO = \"transactionInfo\",\n ENUM = \"enum\",\n TRANSACTION_FIELD_DESCRIPTION = \"transactionFieldDescription\",\n WEB3_CHECK = \"web3Check\",\n ERROR = \"error\",\n}\n\nexport type ClearSignContextReferenceType =\n | ClearSignContextType.TOKEN\n | ClearSignContextType.NFT\n | ClearSignContextType.ENUM\n | ClearSignContextType.TRUSTED_NAME;\n\nexport type ClearSignContextReference<\n Type extends ClearSignContextReferenceType = ClearSignContextReferenceType,\n> = Type extends ClearSignContextType.ENUM\n ? {\n type: ClearSignContextType.ENUM;\n valuePath: GenericPath;\n id: number; // enum id to reference\n }\n : Type extends ClearSignContextType.TRUSTED_NAME\n ? {\n type: ClearSignContextType.TRUSTED_NAME;\n valuePath: GenericPath;\n types: string[];\n sources: string[];\n }\n :\n | {\n type: Type;\n valuePath: GenericPath;\n value?: never;\n }\n | {\n type: Type;\n valuePath?: never;\n value: string;\n };\n\nexport type ClearSignContextSuccessType = Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n>;\n\n// NOTE: this is a union of all possible success types\n// There is currently two types of success:\n// - ENUM: which is a special case, we need to handle it differently\n// because we don't want to send the whole enum\n// but only the parts that are needed.\n// - id: the enum id to reference\n// - payload: the payload to send with a provideEnum command\n// - name: the name of the enum to be displayed on the device\n// - value: the value of the enum to be retrieved from the transaction\n// - All other types\n// - payload: the payload to send with a provide command\n// - reference: the reference to the value to be retrieved from the transaction\nexport type ClearSignContextSuccess<\n Type extends ClearSignContextSuccessType = ClearSignContextSuccessType,\n> = Type extends ClearSignContextType.ENUM\n ? {\n type: ClearSignContextType.ENUM;\n id: number;\n payload: string;\n value: number;\n certificate?: PkiCertificate;\n }\n : {\n type: Exclude<\n ClearSignContextType,\n ClearSignContextType.ENUM | ClearSignContextType.ERROR\n >;\n payload: string;\n reference?: ClearSignContextReference;\n certificate?: PkiCertificate;\n };\n\nexport type ClearSignContextError = {\n type: ClearSignContextType.ERROR;\n error: Error;\n};\n\nexport type ClearSignContext = ClearSignContextSuccess | ClearSignContextError;\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAIO,IAAKE,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,OAAS,SACTA,EAAA,gBAAkB,iBAClBA,EAAA,iBAAmB,kBACnBA,EAAA,KAAO,OACPA,EAAA,8BAAgC,8BAChCA,EAAA,WAAa,YACbA,EAAA,MAAQ,QAVEA,OAAA",
|
|
6
6
|
"names": ["ClearSignContext_exports", "__export", "ClearSignContextType", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var b=(r,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of g(t))!o.call(r,n)&&n!==s&&i(r,n,{get:()=>t[n],enumerable:!(a=e(t,n))||a.enumerable});return r};var c=r=>b(i({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
|
|
2
2
|
//# sourceMappingURL=TransactionSubset.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/model/TransactionSubset.ts"],
|
|
4
|
-
"sourcesContent": ["export type TransactionSubset = {\n chainId: number;\n to?: string;\n data?: string;\n};\n"],
|
|
4
|
+
"sourcesContent": ["export type TransactionSubset = {\n chainId: number;\n to?: string;\n data?: string;\n from?: string;\n rawTx?: string;\n};\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["TransactionSubset_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},o=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of i(e))!y.call(t,a)&&a!==r&&p(t,a,{get:()=>e[a],enumerable:!(n=s(e,a))||n.enumerable});return t};var T=t=>o(p({},"__esModule",{value:!0}),t);var l={};d(l,{VERIFYING_CONTRACT_TOKEN_INDEX:()=>g});module.exports=T(l);const g=255;0&&(module.exports={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": ["// 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// 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
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oCAAAE,IAAA,eAAAC,EAAAH,
|
|
4
|
+
"sourcesContent": ["import type { HexaString } from \"@ledgerhq/device-management-kit\";\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// 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 TypedDataFilter =\n | {\n type: \"datetime\" | \"raw\";\n displayName: string;\n path: TypedDataFilterPath;\n signature: string;\n }\n | TypedDataFilterWithToken\n | TypedDataFilterWithTrustedName;\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};\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,IAAA,eAAAC,EAAAH,GAaO,MAAME,EAAiC",
|
|
6
6
|
"names": ["TypedDataClearSignContext_exports", "__export", "VERIFYING_CONTRACT_TOKEN_INDEX", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var E=Object.create;var d=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var w=(o,e)=>{for(var t in e)d(o,t,{get:e[t],enumerable:!0})},y=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of x(e))!P.call(o,r)&&r!==t&&d(o,r,{get:()=>e[r],enumerable:!(n=h(e,r))||n.enumerable});return o};var $=(o,e,t)=>(t=o!=null?E(v(o)):{},y(e||!o||!o.__esModule?d(t,"default",{value:o,enumerable:!0}):t,o)),G=o=>y(d({},"__esModule",{value:!0}),o),D=(o,e,t,n)=>{for(var r=n>1?void 0:n?h(e,t):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&d(e,t,r),r},N=(o,e)=>(t,n)=>e(t,n,o);var M={};w(M,{HttpTrustedNameDataSource:()=>c});module.exports=G(M);var g=$(require("axios")),u=require("inversify"),a=require("purify-ts"),T=require("../../config/di/configTypes"),l=$(require("../../../package.json"));let c=class{constructor(e){this.config=e}async getDomainNamePayload({chainId:e,domain:t,challenge:n}){try{const s=await g.default.request({method:"GET",url:`https://nft.api.live.ledger.com/v2/names/ethereum/${e}/forward/${t}?types=eoa&sources=ens&challenge=${n}`,headers:{"X-Ledger-Client-Version":`context-module/${l.default.version}`}});return s.data.signedDescriptor?.data?(0,a.Right)(s.data.signedDescriptor.data):(0,a.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload"))}catch{return(0,a.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name"))}}async getTrustedNamePayload({chainId:e,address:t,challenge:n,sources:r,types:i}){try{r=r.filter(f=>f==="ens"||f==="crypto_asset_list");const m=(await g.default.request({method:"GET",url:`https://nft.api.live.ledger.com/v2/names/ethereum/${e}/reverse/${t}?types=${i.join(",")}&sources=${r.join(",")}&challenge=${n}`,headers:{"X-Ledger-Client-Version":`context-module/${l.default.version}`}})).data;if(!m?.signedDescriptor?.data)return(0,a.Left)(new Error(`[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${t}`));const p=m.signedDescriptor.data;if(!m.signedDescriptor.signatures||typeof m.signedDescriptor.signatures[this.config.cal.mode]!="string")return(0,a.Right)(p);const C=m.signedDescriptor.signatures[this.config.cal.mode];return(0,a.Right)(this.formatTrustedName(p,C))}catch{return(0,a.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name"))}}formatTrustedName(e,t){t.length%2!==0&&(t="0"+t);const n="15",r=(t.length/2).toString(16);return`${e}${n}${r}${t}`}};c=D([(0,u.injectable)(),N(0,(0,u.inject)(T.configTypes.Config))],c);0&&(module.exports={HttpTrustedNameDataSource});
|
|
2
2
|
//# sourceMappingURL=HttpTrustedNameDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error, string>> {\n try {\n const type = \"eoa\"; // Externally owned account\n const source = \"ens\"; // Ethereum name service\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/
|
|
5
|
-
"mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAO5BC,EAAoB,iCAKb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,qBAAqB,CAChC,OAAAC,EACA,UAAAC,CACF,EAA6D,CAC3D,GAAI,CAGF,MAAMC,EAAW,MAAM,EAAAC,QAAM,QAAwB,CACnD,OAAQ,MACR,IAAK
|
|
6
|
-
"names": ["HttpTrustedNameDataSource_exports", "__export", "HttpTrustedNameDataSource", "__toCommonJS", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_package", "HttpTrustedNameDataSource", "config", "domain", "challenge", "response", "axios", "PACKAGE", "address", "sources", "types", "source", "trustedName", "payload", "signature", "signatureTag", "signatureLength", "__decorateClass", "__decorateParam"]
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n chainId,\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error, string>> {\n try {\n const type = \"eoa\"; // Externally owned account\n const source = \"ens\"; // Ethereum name service\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/${chainId}/forward/${domain}?types=${type}&sources=${source}&challenge=${challenge}`,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n return response.data.signedDescriptor?.data\n ? Right(response.data.signedDescriptor.data)\n : Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n );\n }\n }\n\n public async getTrustedNamePayload({\n chainId,\n address,\n challenge,\n sources,\n types,\n }: GetTrustedNameInfosParams): Promise<Either<Error, string>> {\n try {\n // TODO remove that filtering once https://ledgerhq.atlassian.net/browse/BACK-8075 is done\n // For now we have to filter or trusted names won't work with the generic parser, because transaction\n // fields descriptors can contain unsupported sources.\n sources = sources.filter(\n (source) => source === \"ens\" || source === \"crypto_asset_list\",\n );\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/${chainId}/reverse/${address}?types=${types.join(\",\")}&sources=${sources.join(\",\")}&challenge=${challenge}`,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n const trustedName = response.data;\n if (!trustedName?.signedDescriptor?.data) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${address}`,\n ),\n );\n }\n const payload = trustedName.signedDescriptor.data;\n\n if (\n !trustedName.signedDescriptor.signatures ||\n typeof trustedName.signedDescriptor.signatures[this.config.cal.mode] !==\n \"string\"\n ) {\n // If we have no separated signature but a valid descriptor, it may mean the descriptor was\n // signed on-the-fly for dynamic sources such as ens\n return Right(payload);\n }\n\n const signature =\n trustedName.signedDescriptor.signatures[this.config.cal.mode]!;\n return Right(this.formatTrustedName(payload, signature));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n );\n }\n }\n\n private formatTrustedName(payload: string, signature: string): string {\n // Ensure correct padding\n if (signature.length % 2 !== 0) {\n signature = \"0\" + signature;\n }\n // TLV encoding as according to trusted name documentation\n const signatureTag = \"15\";\n const signatureLength = (signature.length / 2).toString(16);\n return `${payload}${signatureTag}${signatureLength}${signature}`;\n }\n}\n"],
|
|
5
|
+
"mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAO5BC,EAAoB,iCAKb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,qBAAqB,CAChC,QAAAC,EACA,OAAAC,EACA,UAAAC,CACF,EAA6D,CAC3D,GAAI,CAGF,MAAMC,EAAW,MAAM,EAAAC,QAAM,QAAwB,CACnD,OAAQ,MACR,IAAK,qDAAqDJ,CAAO,YAAYC,CAAM,oCAA8CC,CAAS,GAC1I,QAAS,CACP,0BAA2B,kBAAkB,EAAAG,QAAQ,OAAO,EAC9D,CACF,CAAC,EAED,OAAOF,EAAS,KAAK,kBAAkB,QACnC,SAAMA,EAAS,KAAK,iBAAiB,IAAI,KACzC,QACE,IAAI,MACF,yEACF,CACF,CACN,MAAiB,CACf,SAAO,QACL,IAAI,MACF,wEACF,CACF,CACF,CACF,CAEA,MAAa,sBAAsB,CACjC,QAAAH,EACA,QAAAM,EACA,UAAAJ,EACA,QAAAK,EACA,MAAAC,CACF,EAA8D,CAC5D,GAAI,CAIFD,EAAUA,EAAQ,OACfE,GAAWA,IAAW,OAASA,IAAW,mBAC7C,EAQA,MAAMC,GAPW,MAAM,EAAAN,QAAM,QAAwB,CACnD,OAAQ,MACR,IAAK,qDAAqDJ,CAAO,YAAYM,CAAO,UAAUE,EAAM,KAAK,GAAG,CAAC,YAAYD,EAAQ,KAAK,GAAG,CAAC,cAAcL,CAAS,GACjK,QAAS,CACP,0BAA2B,kBAAkB,EAAAG,QAAQ,OAAO,EAC9D,CACF,CAAC,GAC4B,KAC7B,GAAI,CAACK,GAAa,kBAAkB,KAClC,SAAO,QACL,IAAI,MACF,mFAAmFJ,CAAO,EAC5F,CACF,EAEF,MAAMK,EAAUD,EAAY,iBAAiB,KAE7C,GACE,CAACA,EAAY,iBAAiB,YAC9B,OAAOA,EAAY,iBAAiB,WAAW,KAAK,OAAO,IAAI,IAAI,GACjE,SAIF,SAAO,SAAMC,CAAO,EAGtB,MAAMC,EACJF,EAAY,iBAAiB,WAAW,KAAK,OAAO,IAAI,IAAI,EAC9D,SAAO,SAAM,KAAK,kBAAkBC,EAASC,CAAS,CAAC,CACzD,MAAiB,CACf,SAAO,QACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CAEQ,kBAAkBD,EAAiBC,EAA2B,CAEhEA,EAAU,OAAS,IAAM,IAC3BA,EAAY,IAAMA,GAGpB,MAAMC,EAAe,KACfC,GAAmBF,EAAU,OAAS,GAAG,SAAS,EAAE,EAC1D,MAAO,GAAGD,CAAO,GAAGE,CAAY,GAAGC,CAAe,GAAGF,CAAS,EAChE,CACF,EApGad,EAANiB,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,IAFjBlB",
|
|
6
|
+
"names": ["HttpTrustedNameDataSource_exports", "__export", "HttpTrustedNameDataSource", "__toCommonJS", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_package", "HttpTrustedNameDataSource", "config", "chainId", "domain", "challenge", "response", "axios", "PACKAGE", "address", "sources", "types", "source", "trustedName", "payload", "signature", "signatureTag", "signatureLength", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|