@ledgerhq/context-module 0.0.0-develop-20240926001103
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/README.md +118 -0
- package/lib/cjs/index.d.ts +3 -0
- package/lib/cjs/index.d.ts.map +1 -0
- package/lib/cjs/index.js +20 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/package.json +63 -0
- package/lib/cjs/src/ContextModule.d.ts +9 -0
- package/lib/cjs/src/ContextModule.d.ts.map +1 -0
- package/lib/cjs/src/ContextModule.js +3 -0
- package/lib/cjs/src/ContextModule.js.map +1 -0
- package/lib/cjs/src/ContextModuleBuilder.d.ts +35 -0
- package/lib/cjs/src/ContextModuleBuilder.d.ts.map +1 -0
- package/lib/cjs/src/ContextModuleBuilder.js +67 -0
- package/lib/cjs/src/ContextModuleBuilder.js.map +1 -0
- package/lib/cjs/src/DefaultContextModule.d.ts +20 -0
- package/lib/cjs/src/DefaultContextModule.d.ts.map +1 -0
- package/lib/cjs/src/DefaultContextModule.js +21 -0
- package/lib/cjs/src/DefaultContextModule.js.map +1 -0
- package/lib/cjs/src/di.d.ts +3 -0
- package/lib/cjs/src/di.d.ts.map +1 -0
- package/lib/cjs/src/di.js +16 -0
- package/lib/cjs/src/di.js.map +1 -0
- package/lib/cjs/src/external-plugin/data/DAppDto.d.ts +38 -0
- package/lib/cjs/src/external-plugin/data/DAppDto.d.ts.map +1 -0
- package/lib/cjs/src/external-plugin/data/DAppDto.js +3 -0
- package/lib/cjs/src/external-plugin/data/DAppDto.js.map +1 -0
- package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.d.ts +12 -0
- package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.d.ts.map +1 -0
- package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js +3 -0
- package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js.map +1 -0
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.d.ts +8 -0
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -0
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +71 -0
- package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +1 -0
- package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.d.ts +3 -0
- package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.d.ts.map +1 -0
- package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +13 -0
- package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +1 -0
- package/lib/cjs/src/external-plugin/di/externalPluginTypes.d.ts +5 -0
- package/lib/cjs/src/external-plugin/di/externalPluginTypes.d.ts.map +1 -0
- package/lib/cjs/src/external-plugin/di/externalPluginTypes.js +8 -0
- package/lib/cjs/src/external-plugin/di/externalPluginTypes.js.map +1 -0
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +15 -0
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -0
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +136 -0
- package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +1 -0
- package/lib/cjs/src/external-plugin/model/DappInfos.d.ts +6 -0
- package/lib/cjs/src/external-plugin/model/DappInfos.d.ts.map +1 -0
- package/lib/cjs/src/external-plugin/model/DappInfos.js +3 -0
- package/lib/cjs/src/external-plugin/model/DappInfos.js.map +1 -0
- package/lib/cjs/src/external-plugin/model/SelectorDetails.d.ts +8 -0
- package/lib/cjs/src/external-plugin/model/SelectorDetails.d.ts.map +1 -0
- package/lib/cjs/src/external-plugin/model/SelectorDetails.js +3 -0
- package/lib/cjs/src/external-plugin/model/SelectorDetails.js.map +1 -0
- package/lib/cjs/src/forward-domain/data/ForwardDomainDataSource.d.ts +9 -0
- package/lib/cjs/src/forward-domain/data/ForwardDomainDataSource.d.ts.map +1 -0
- package/lib/cjs/src/forward-domain/data/ForwardDomainDataSource.js +3 -0
- package/lib/cjs/src/forward-domain/data/ForwardDomainDataSource.js.map +1 -0
- package/lib/cjs/src/forward-domain/data/HttpForwardDomainDataSource.d.ts +6 -0
- package/lib/cjs/src/forward-domain/data/HttpForwardDomainDataSource.d.ts.map +1 -0
- package/lib/cjs/src/forward-domain/data/HttpForwardDomainDataSource.js +40 -0
- package/lib/cjs/src/forward-domain/data/HttpForwardDomainDataSource.js.map +1 -0
- package/lib/cjs/src/forward-domain/di/forwardDomainModuleFactory.d.ts +3 -0
- package/lib/cjs/src/forward-domain/di/forwardDomainModuleFactory.d.ts.map +1 -0
- package/lib/cjs/src/forward-domain/di/forwardDomainModuleFactory.js +13 -0
- package/lib/cjs/src/forward-domain/di/forwardDomainModuleFactory.js.map +1 -0
- package/lib/cjs/src/forward-domain/di/forwardDomainTypes.d.ts +5 -0
- package/lib/cjs/src/forward-domain/di/forwardDomainTypes.d.ts.map +1 -0
- package/lib/cjs/src/forward-domain/di/forwardDomainTypes.js +8 -0
- package/lib/cjs/src/forward-domain/di/forwardDomainTypes.js.map +1 -0
- package/lib/cjs/src/forward-domain/domain/ForwardDomainContextLoader.d.ts +11 -0
- package/lib/cjs/src/forward-domain/domain/ForwardDomainContextLoader.d.ts.map +1 -0
- package/lib/cjs/src/forward-domain/domain/ForwardDomainContextLoader.js +66 -0
- package/lib/cjs/src/forward-domain/domain/ForwardDomainContextLoader.js.map +1 -0
- package/lib/cjs/src/index.d.ts +13 -0
- package/lib/cjs/src/index.d.ts.map +1 -0
- package/lib/cjs/src/index.js +29 -0
- package/lib/cjs/src/index.js.map +1 -0
- package/lib/cjs/src/nft/data/HttpNftDataSource.d.ts +7 -0
- package/lib/cjs/src/nft/data/HttpNftDataSource.d.ts.map +1 -0
- package/lib/cjs/src/nft/data/HttpNftDataSource.js +57 -0
- package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +1 -0
- package/lib/cjs/src/nft/data/NftDataSource.d.ts +15 -0
- package/lib/cjs/src/nft/data/NftDataSource.d.ts.map +1 -0
- package/lib/cjs/src/nft/data/NftDataSource.js +3 -0
- package/lib/cjs/src/nft/data/NftDataSource.js.map +1 -0
- package/lib/cjs/src/nft/di/nftModuleFactory.d.ts +3 -0
- package/lib/cjs/src/nft/di/nftModuleFactory.d.ts.map +1 -0
- package/lib/cjs/src/nft/di/nftModuleFactory.js +13 -0
- package/lib/cjs/src/nft/di/nftModuleFactory.js.map +1 -0
- package/lib/cjs/src/nft/di/nftTypes.d.ts +5 -0
- package/lib/cjs/src/nft/di/nftTypes.d.ts.map +1 -0
- package/lib/cjs/src/nft/di/nftTypes.js +8 -0
- package/lib/cjs/src/nft/di/nftTypes.js.map +1 -0
- package/lib/cjs/src/nft/domain/NftContextLoader.d.ts +11 -0
- package/lib/cjs/src/nft/domain/NftContextLoader.d.ts.map +1 -0
- package/lib/cjs/src/nft/domain/NftContextLoader.js +111 -0
- package/lib/cjs/src/nft/domain/NftContextLoader.js.map +1 -0
- package/lib/cjs/src/shared/domain/ContextLoader.d.ts +6 -0
- package/lib/cjs/src/shared/domain/ContextLoader.d.ts.map +1 -0
- package/lib/cjs/src/shared/domain/ContextLoader.js +3 -0
- package/lib/cjs/src/shared/domain/ContextLoader.js.map +1 -0
- package/lib/cjs/src/shared/model/ClearSignContext.d.ts +21 -0
- package/lib/cjs/src/shared/model/ClearSignContext.d.ts.map +1 -0
- package/lib/cjs/src/shared/model/ClearSignContext.js +13 -0
- package/lib/cjs/src/shared/model/ClearSignContext.js.map +1 -0
- package/lib/cjs/src/shared/model/TransactionContext.d.ts +6 -0
- package/lib/cjs/src/shared/model/TransactionContext.d.ts.map +1 -0
- package/lib/cjs/src/shared/model/TransactionContext.js +3 -0
- package/lib/cjs/src/shared/model/TransactionContext.js.map +1 -0
- package/lib/cjs/src/shared/model/TransactionSubset.d.ts +6 -0
- package/lib/cjs/src/shared/model/TransactionSubset.d.ts.map +1 -0
- package/lib/cjs/src/shared/model/TransactionSubset.js +3 -0
- package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -0
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.d.ts +33 -0
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -0
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +6 -0
- package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +1 -0
- package/lib/cjs/src/shared/model/TypedDataContext.d.ts +16 -0
- package/lib/cjs/src/shared/model/TypedDataContext.d.ts.map +1 -0
- package/lib/cjs/src/shared/model/TypedDataContext.js +3 -0
- package/lib/cjs/src/shared/model/TypedDataContext.js.map +1 -0
- package/lib/cjs/src/shared/utils/HexStringUtils.d.ts +4 -0
- package/lib/cjs/src/shared/utils/HexStringUtils.d.ts.map +1 -0
- package/lib/cjs/src/shared/utils/HexStringUtils.js +15 -0
- package/lib/cjs/src/shared/utils/HexStringUtils.js.map +1 -0
- package/lib/cjs/src/token/data/HttpTokenDataSource.d.ts +6 -0
- package/lib/cjs/src/token/data/HttpTokenDataSource.d.ts.map +1 -0
- package/lib/cjs/src/token/data/HttpTokenDataSource.js +70 -0
- package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +1 -0
- package/lib/cjs/src/token/data/TokenDataSource.d.ts +9 -0
- package/lib/cjs/src/token/data/TokenDataSource.d.ts.map +1 -0
- package/lib/cjs/src/token/data/TokenDataSource.js +3 -0
- package/lib/cjs/src/token/data/TokenDataSource.js.map +1 -0
- package/lib/cjs/src/token/data/TokenDto.d.ts +6 -0
- package/lib/cjs/src/token/data/TokenDto.d.ts.map +1 -0
- package/lib/cjs/src/token/data/TokenDto.js +3 -0
- package/lib/cjs/src/token/data/TokenDto.js.map +1 -0
- package/lib/cjs/src/token/di/tokenModuleFactory.d.ts +3 -0
- package/lib/cjs/src/token/di/tokenModuleFactory.d.ts.map +1 -0
- package/lib/cjs/src/token/di/tokenModuleFactory.js +13 -0
- package/lib/cjs/src/token/di/tokenModuleFactory.js.map +1 -0
- package/lib/cjs/src/token/di/tokenTypes.d.ts +5 -0
- package/lib/cjs/src/token/di/tokenTypes.d.ts.map +1 -0
- package/lib/cjs/src/token/di/tokenTypes.js +8 -0
- package/lib/cjs/src/token/di/tokenTypes.js.map +1 -0
- package/lib/cjs/src/token/domain/TokenContextLoader.d.ts +15 -0
- package/lib/cjs/src/token/domain/TokenContextLoader.d.ts.map +1 -0
- package/lib/cjs/src/token/domain/TokenContextLoader.js +74 -0
- package/lib/cjs/src/token/domain/TokenContextLoader.js.map +1 -0
- package/lib/cjs/src/typed-data/data/FiltersDto.d.ts +35 -0
- package/lib/cjs/src/typed-data/data/FiltersDto.d.ts.map +1 -0
- package/lib/cjs/src/typed-data/data/FiltersDto.js +3 -0
- package/lib/cjs/src/typed-data/data/FiltersDto.js.map +1 -0
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.d.ts +10 -0
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -0
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +128 -0
- package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +1 -0
- package/lib/cjs/src/typed-data/data/TypedDataDataSource.d.ts +17 -0
- package/lib/cjs/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -0
- package/lib/cjs/src/typed-data/data/TypedDataDataSource.js +3 -0
- package/lib/cjs/src/typed-data/data/TypedDataDataSource.js.map +1 -0
- package/lib/cjs/src/typed-data/di/typedDataModuleFactory.d.ts +3 -0
- package/lib/cjs/src/typed-data/di/typedDataModuleFactory.d.ts.map +1 -0
- package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +13 -0
- package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +1 -0
- package/lib/cjs/src/typed-data/di/typedDataTypes.d.ts +5 -0
- package/lib/cjs/src/typed-data/di/typedDataTypes.d.ts.map +1 -0
- package/lib/cjs/src/typed-data/di/typedDataTypes.js +8 -0
- package/lib/cjs/src/typed-data/di/typedDataTypes.js.map +1 -0
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +13 -0
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -0
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +127 -0
- package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +1 -0
- package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.d.ts +6 -0
- package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.d.ts.map +1 -0
- package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js +3 -0
- package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js.map +1 -0
- package/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/lib/esm/index.d.ts +3 -0
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +4 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/package.json +63 -0
- package/lib/esm/src/ContextModule.d.ts +9 -0
- package/lib/esm/src/ContextModule.d.ts.map +1 -0
- package/lib/esm/src/ContextModule.js +2 -0
- package/lib/esm/src/ContextModule.js.map +1 -0
- package/lib/esm/src/ContextModuleBuilder.d.ts +35 -0
- package/lib/esm/src/ContextModuleBuilder.d.ts.map +1 -0
- package/lib/esm/src/ContextModuleBuilder.js +63 -0
- package/lib/esm/src/ContextModuleBuilder.js.map +1 -0
- package/lib/esm/src/DefaultContextModule.d.ts +20 -0
- package/lib/esm/src/DefaultContextModule.d.ts.map +1 -0
- package/lib/esm/src/DefaultContextModule.js +17 -0
- package/lib/esm/src/DefaultContextModule.js.map +1 -0
- package/lib/esm/src/di.d.ts +3 -0
- package/lib/esm/src/di.d.ts.map +1 -0
- package/lib/esm/src/di.js +12 -0
- package/lib/esm/src/di.js.map +1 -0
- package/lib/esm/src/external-plugin/data/DAppDto.d.ts +38 -0
- package/lib/esm/src/external-plugin/data/DAppDto.d.ts.map +1 -0
- package/lib/esm/src/external-plugin/data/DAppDto.js +2 -0
- package/lib/esm/src/external-plugin/data/DAppDto.js.map +1 -0
- package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.d.ts +12 -0
- package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.d.ts.map +1 -0
- package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js +2 -0
- package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js.map +1 -0
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.d.ts +8 -0
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -0
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +65 -0
- package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +1 -0
- package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.d.ts +3 -0
- package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.d.ts.map +1 -0
- package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +9 -0
- package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +1 -0
- package/lib/esm/src/external-plugin/di/externalPluginTypes.d.ts +5 -0
- package/lib/esm/src/external-plugin/di/externalPluginTypes.d.ts.map +1 -0
- package/lib/esm/src/external-plugin/di/externalPluginTypes.js +5 -0
- package/lib/esm/src/external-plugin/di/externalPluginTypes.js.map +1 -0
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +15 -0
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -0
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +133 -0
- package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +1 -0
- package/lib/esm/src/external-plugin/model/DappInfos.d.ts +6 -0
- package/lib/esm/src/external-plugin/model/DappInfos.d.ts.map +1 -0
- package/lib/esm/src/external-plugin/model/DappInfos.js +2 -0
- package/lib/esm/src/external-plugin/model/DappInfos.js.map +1 -0
- package/lib/esm/src/external-plugin/model/SelectorDetails.d.ts +8 -0
- package/lib/esm/src/external-plugin/model/SelectorDetails.d.ts.map +1 -0
- package/lib/esm/src/external-plugin/model/SelectorDetails.js +2 -0
- package/lib/esm/src/external-plugin/model/SelectorDetails.js.map +1 -0
- package/lib/esm/src/forward-domain/data/ForwardDomainDataSource.d.ts +9 -0
- package/lib/esm/src/forward-domain/data/ForwardDomainDataSource.d.ts.map +1 -0
- package/lib/esm/src/forward-domain/data/ForwardDomainDataSource.js +2 -0
- package/lib/esm/src/forward-domain/data/ForwardDomainDataSource.js.map +1 -0
- package/lib/esm/src/forward-domain/data/HttpForwardDomainDataSource.d.ts +6 -0
- package/lib/esm/src/forward-domain/data/HttpForwardDomainDataSource.d.ts.map +1 -0
- package/lib/esm/src/forward-domain/data/HttpForwardDomainDataSource.js +34 -0
- package/lib/esm/src/forward-domain/data/HttpForwardDomainDataSource.js.map +1 -0
- package/lib/esm/src/forward-domain/di/forwardDomainModuleFactory.d.ts +3 -0
- package/lib/esm/src/forward-domain/di/forwardDomainModuleFactory.d.ts.map +1 -0
- package/lib/esm/src/forward-domain/di/forwardDomainModuleFactory.js +9 -0
- package/lib/esm/src/forward-domain/di/forwardDomainModuleFactory.js.map +1 -0
- package/lib/esm/src/forward-domain/di/forwardDomainTypes.d.ts +5 -0
- package/lib/esm/src/forward-domain/di/forwardDomainTypes.d.ts.map +1 -0
- package/lib/esm/src/forward-domain/di/forwardDomainTypes.js +5 -0
- package/lib/esm/src/forward-domain/di/forwardDomainTypes.js.map +1 -0
- package/lib/esm/src/forward-domain/domain/ForwardDomainContextLoader.d.ts +11 -0
- package/lib/esm/src/forward-domain/domain/ForwardDomainContextLoader.d.ts.map +1 -0
- package/lib/esm/src/forward-domain/domain/ForwardDomainContextLoader.js +63 -0
- package/lib/esm/src/forward-domain/domain/ForwardDomainContextLoader.js.map +1 -0
- package/lib/esm/src/index.d.ts +13 -0
- package/lib/esm/src/index.d.ts.map +1 -0
- package/lib/esm/src/index.js +13 -0
- package/lib/esm/src/index.js.map +1 -0
- package/lib/esm/src/nft/data/HttpNftDataSource.d.ts +7 -0
- package/lib/esm/src/nft/data/HttpNftDataSource.d.ts.map +1 -0
- package/lib/esm/src/nft/data/HttpNftDataSource.js +51 -0
- package/lib/esm/src/nft/data/HttpNftDataSource.js.map +1 -0
- package/lib/esm/src/nft/data/NftDataSource.d.ts +15 -0
- package/lib/esm/src/nft/data/NftDataSource.d.ts.map +1 -0
- package/lib/esm/src/nft/data/NftDataSource.js +2 -0
- package/lib/esm/src/nft/data/NftDataSource.js.map +1 -0
- package/lib/esm/src/nft/di/nftModuleFactory.d.ts +3 -0
- package/lib/esm/src/nft/di/nftModuleFactory.d.ts.map +1 -0
- package/lib/esm/src/nft/di/nftModuleFactory.js +9 -0
- package/lib/esm/src/nft/di/nftModuleFactory.js.map +1 -0
- package/lib/esm/src/nft/di/nftTypes.d.ts +5 -0
- package/lib/esm/src/nft/di/nftTypes.d.ts.map +1 -0
- package/lib/esm/src/nft/di/nftTypes.js +5 -0
- package/lib/esm/src/nft/di/nftTypes.js.map +1 -0
- package/lib/esm/src/nft/domain/NftContextLoader.d.ts +11 -0
- package/lib/esm/src/nft/domain/NftContextLoader.d.ts.map +1 -0
- package/lib/esm/src/nft/domain/NftContextLoader.js +108 -0
- package/lib/esm/src/nft/domain/NftContextLoader.js.map +1 -0
- package/lib/esm/src/shared/domain/ContextLoader.d.ts +6 -0
- package/lib/esm/src/shared/domain/ContextLoader.d.ts.map +1 -0
- package/lib/esm/src/shared/domain/ContextLoader.js +2 -0
- package/lib/esm/src/shared/domain/ContextLoader.js.map +1 -0
- package/lib/esm/src/shared/model/ClearSignContext.d.ts +21 -0
- package/lib/esm/src/shared/model/ClearSignContext.d.ts.map +1 -0
- package/lib/esm/src/shared/model/ClearSignContext.js +10 -0
- package/lib/esm/src/shared/model/ClearSignContext.js.map +1 -0
- package/lib/esm/src/shared/model/TransactionContext.d.ts +6 -0
- package/lib/esm/src/shared/model/TransactionContext.d.ts.map +1 -0
- package/lib/esm/src/shared/model/TransactionContext.js +2 -0
- package/lib/esm/src/shared/model/TransactionContext.js.map +1 -0
- package/lib/esm/src/shared/model/TransactionSubset.d.ts +6 -0
- package/lib/esm/src/shared/model/TransactionSubset.d.ts.map +1 -0
- package/lib/esm/src/shared/model/TransactionSubset.js +2 -0
- package/lib/esm/src/shared/model/TransactionSubset.js.map +1 -0
- package/lib/esm/src/shared/model/TypedDataClearSignContext.d.ts +33 -0
- package/lib/esm/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -0
- package/lib/esm/src/shared/model/TypedDataClearSignContext.js +3 -0
- package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +1 -0
- package/lib/esm/src/shared/model/TypedDataContext.d.ts +16 -0
- package/lib/esm/src/shared/model/TypedDataContext.d.ts.map +1 -0
- package/lib/esm/src/shared/model/TypedDataContext.js +2 -0
- package/lib/esm/src/shared/model/TypedDataContext.js.map +1 -0
- package/lib/esm/src/shared/utils/HexStringUtils.d.ts +4 -0
- package/lib/esm/src/shared/utils/HexStringUtils.d.ts.map +1 -0
- package/lib/esm/src/shared/utils/HexStringUtils.js +11 -0
- package/lib/esm/src/shared/utils/HexStringUtils.js.map +1 -0
- package/lib/esm/src/token/data/HttpTokenDataSource.d.ts +6 -0
- package/lib/esm/src/token/data/HttpTokenDataSource.d.ts.map +1 -0
- package/lib/esm/src/token/data/HttpTokenDataSource.js +64 -0
- package/lib/esm/src/token/data/HttpTokenDataSource.js.map +1 -0
- package/lib/esm/src/token/data/TokenDataSource.d.ts +9 -0
- package/lib/esm/src/token/data/TokenDataSource.d.ts.map +1 -0
- package/lib/esm/src/token/data/TokenDataSource.js +2 -0
- package/lib/esm/src/token/data/TokenDataSource.js.map +1 -0
- package/lib/esm/src/token/data/TokenDto.d.ts +6 -0
- package/lib/esm/src/token/data/TokenDto.d.ts.map +1 -0
- package/lib/esm/src/token/data/TokenDto.js +2 -0
- package/lib/esm/src/token/data/TokenDto.js.map +1 -0
- package/lib/esm/src/token/di/tokenModuleFactory.d.ts +3 -0
- package/lib/esm/src/token/di/tokenModuleFactory.d.ts.map +1 -0
- package/lib/esm/src/token/di/tokenModuleFactory.js +9 -0
- package/lib/esm/src/token/di/tokenModuleFactory.js.map +1 -0
- package/lib/esm/src/token/di/tokenTypes.d.ts +5 -0
- package/lib/esm/src/token/di/tokenTypes.d.ts.map +1 -0
- package/lib/esm/src/token/di/tokenTypes.js +5 -0
- package/lib/esm/src/token/di/tokenTypes.js.map +1 -0
- package/lib/esm/src/token/domain/TokenContextLoader.d.ts +15 -0
- package/lib/esm/src/token/domain/TokenContextLoader.d.ts.map +1 -0
- package/lib/esm/src/token/domain/TokenContextLoader.js +71 -0
- package/lib/esm/src/token/domain/TokenContextLoader.js.map +1 -0
- package/lib/esm/src/typed-data/data/FiltersDto.d.ts +35 -0
- package/lib/esm/src/typed-data/data/FiltersDto.d.ts.map +1 -0
- package/lib/esm/src/typed-data/data/FiltersDto.js +2 -0
- package/lib/esm/src/typed-data/data/FiltersDto.js.map +1 -0
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.d.ts +10 -0
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -0
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +122 -0
- package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +1 -0
- package/lib/esm/src/typed-data/data/TypedDataDataSource.d.ts +17 -0
- package/lib/esm/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -0
- package/lib/esm/src/typed-data/data/TypedDataDataSource.js +2 -0
- package/lib/esm/src/typed-data/data/TypedDataDataSource.js.map +1 -0
- package/lib/esm/src/typed-data/di/typedDataModuleFactory.d.ts +3 -0
- package/lib/esm/src/typed-data/di/typedDataModuleFactory.d.ts.map +1 -0
- package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +9 -0
- package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +1 -0
- package/lib/esm/src/typed-data/di/typedDataTypes.d.ts +5 -0
- package/lib/esm/src/typed-data/di/typedDataTypes.d.ts.map +1 -0
- package/lib/esm/src/typed-data/di/typedDataTypes.js +5 -0
- package/lib/esm/src/typed-data/di/typedDataTypes.js.map +1 -0
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +13 -0
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -0
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +124 -0
- package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +1 -0
- package/lib/esm/src/typed-data/domain/TypedDataContextLoader.d.ts +6 -0
- package/lib/esm/src/typed-data/domain/TypedDataContextLoader.d.ts.map +1 -0
- package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js +2 -0
- package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js.map +1 -0
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TokenContextLoader = exports.ERC20_SUPPORTED_SELECTORS = void 0;
|
|
16
|
+
const device_management_kit_1 = require("@ledgerhq/device-management-kit");
|
|
17
|
+
const inversify_1 = require("inversify");
|
|
18
|
+
const ClearSignContext_1 = require("../../shared/model/ClearSignContext");
|
|
19
|
+
const tokenTypes_1 = require("../../token/di/tokenTypes");
|
|
20
|
+
var ERC20_SUPPORTED_SELECTORS;
|
|
21
|
+
(function (ERC20_SUPPORTED_SELECTORS) {
|
|
22
|
+
ERC20_SUPPORTED_SELECTORS["Approve"] = "0x095ea7b3";
|
|
23
|
+
ERC20_SUPPORTED_SELECTORS["Transfer"] = "0xa9059cbb";
|
|
24
|
+
})(ERC20_SUPPORTED_SELECTORS || (exports.ERC20_SUPPORTED_SELECTORS = ERC20_SUPPORTED_SELECTORS = {}));
|
|
25
|
+
const SUPPORTED_SELECTORS = Object.values(ERC20_SUPPORTED_SELECTORS);
|
|
26
|
+
let TokenContextLoader = class TokenContextLoader {
|
|
27
|
+
_dataSource;
|
|
28
|
+
constructor(dataSource) {
|
|
29
|
+
this._dataSource = dataSource;
|
|
30
|
+
}
|
|
31
|
+
async load(transaction) {
|
|
32
|
+
if (!transaction.to || !transaction.data || transaction.data === "0x") {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
const selector = transaction.data.slice(0, 10);
|
|
36
|
+
if (!(0, device_management_kit_1.isHexaString)(selector)) {
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
type: ClearSignContext_1.ClearSignContextType.ERROR,
|
|
40
|
+
error: new Error("Invalid selector"),
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
if (!this.isSelectorSupported(selector)) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const payload = await this._dataSource.getTokenInfosPayload({
|
|
48
|
+
address: transaction.to,
|
|
49
|
+
chainId: transaction.chainId,
|
|
50
|
+
});
|
|
51
|
+
return [
|
|
52
|
+
payload.caseOf({
|
|
53
|
+
Left: (error) => ({
|
|
54
|
+
type: ClearSignContext_1.ClearSignContextType.ERROR,
|
|
55
|
+
error,
|
|
56
|
+
}),
|
|
57
|
+
Right: (value) => ({
|
|
58
|
+
type: ClearSignContext_1.ClearSignContextType.TOKEN,
|
|
59
|
+
payload: value,
|
|
60
|
+
}),
|
|
61
|
+
}),
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
isSelectorSupported(selector) {
|
|
65
|
+
return Object.values(SUPPORTED_SELECTORS).includes(selector);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.TokenContextLoader = TokenContextLoader;
|
|
69
|
+
exports.TokenContextLoader = TokenContextLoader = __decorate([
|
|
70
|
+
(0, inversify_1.injectable)(),
|
|
71
|
+
__param(0, (0, inversify_1.inject)(tokenTypes_1.tokenTypes.TokenDataSource)),
|
|
72
|
+
__metadata("design:paramtypes", [Object])
|
|
73
|
+
], TokenContextLoader);
|
|
74
|
+
//# sourceMappingURL=TokenContextLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenContextLoader.js","sourceRoot":"","sources":["../../../../../src/token/domain/TokenContextLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2EAA2E;AAC3E,yCAA+C;AAG/C,sEAGyC;AAGzC,sDAAmD;AAEnD,IAAY,yBAGX;AAHD,WAAY,yBAAyB;IACnC,mDAAsB,CAAA;IACtB,oDAAuB,CAAA;AACzB,CAAC,EAHW,yBAAyB,yCAAzB,yBAAyB,QAGpC;AAED,MAAM,mBAAmB,GAAiB,MAAM,CAAC,MAAM,CACrD,yBAAyB,CAC1B,CAAC;AAGK,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACrB,WAAW,CAAkB;IAErC,YAAgD,UAA2B;QACzE,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,WAA+B;QACxC,IAAI,CAAC,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AAA,kBAAM,EAAC,uBAAU,CAAC,eAAe,CAAC,CAAA;;GAHpC,kBAAkB,CAiD9B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type FilterFieldV1 = {
|
|
2
|
+
label: string;
|
|
3
|
+
path: string;
|
|
4
|
+
signature: string;
|
|
5
|
+
format?: never;
|
|
6
|
+
};
|
|
7
|
+
export type FilterFieldV2 = {
|
|
8
|
+
label: string;
|
|
9
|
+
path: string;
|
|
10
|
+
signature: string;
|
|
11
|
+
format: "raw" | "datetime";
|
|
12
|
+
coin_ref?: never;
|
|
13
|
+
};
|
|
14
|
+
export type FilterFieldV2WithCoinRef = {
|
|
15
|
+
label: string;
|
|
16
|
+
path: string;
|
|
17
|
+
signature: string;
|
|
18
|
+
format: "token" | "amount";
|
|
19
|
+
coin_ref: number;
|
|
20
|
+
};
|
|
21
|
+
export type FilterField = FilterFieldV1 | FilterFieldV2 | FilterFieldV2WithCoinRef;
|
|
22
|
+
export type FiltersDto = {
|
|
23
|
+
eip712_signatures: {
|
|
24
|
+
[contractAddress: string]: {
|
|
25
|
+
[schemaHash: string]: {
|
|
26
|
+
contractName: {
|
|
27
|
+
label: string;
|
|
28
|
+
signature: string;
|
|
29
|
+
};
|
|
30
|
+
fields: Array<FilterField>;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=FiltersDto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FiltersDto.d.ts","sourceRoot":"","sources":["../../../../../src/typed-data/data/FiltersDto.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,KAAK,GAAG,UAAU,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,aAAa,GACb,aAAa,GACb,wBAAwB,CAAC;AAE7B,MAAM,MAAM,UAAU,GAAG;IACvB,iBAAiB,EAAE;QACjB,CAAC,eAAe,EAAE,MAAM,GAAG;YACzB,CAAC,UAAU,EAAE,MAAM,GAAG;gBACpB,YAAY,EAAE;oBACZ,KAAK,EAAE,MAAM,CAAC;oBACd,SAAS,EAAE,MAAM,CAAC;iBACnB,CAAC;gBACF,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;aAC5B,CAAC;SACH,CAAC;KACH,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FiltersDto.js","sourceRoot":"","sources":["../../../../../src/typed-data/data/FiltersDto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Either } from "purify-ts";
|
|
2
|
+
import { GetTypedDataFiltersParams, GetTypedDataFiltersResult, TypedDataDataSource } from "./TypedDataDataSource";
|
|
3
|
+
export declare class HttpTypedDataDataSource implements TypedDataDataSource {
|
|
4
|
+
getTypedDataFilters({ chainId, address, schema, version, }: GetTypedDataFiltersParams): Promise<Either<Error, GetTypedDataFiltersResult>>;
|
|
5
|
+
private isFieldFilterV1;
|
|
6
|
+
private isFieldFilterV2;
|
|
7
|
+
private isFieldFilterV2WithCoinRef;
|
|
8
|
+
private sortTypes;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=HttpTypedDataDataSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpTypedDataDataSource.d.ts","sourceRoot":"","sources":["../../../../../src/typed-data/data/HttpTypedDataDataSource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAe,MAAM,WAAW,CAAC;AAgBhD,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAE/B,qBACa,uBAAwB,YAAW,mBAAmB;IACpD,mBAAmB,CAAC,EAC/B,OAAO,EACP,OAAO,EACP,MAAM,EACN,OAAO,GACR,EAAE,yBAAyB,GAAG,OAAO,CACpC,MAAM,CAAC,KAAK,EAAE,yBAAyB,CAAC,CACzC;IA6FD,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,SAAS;CAUlB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.HttpTypedDataDataSource = void 0;
|
|
13
|
+
const axios_1 = __importDefault(require("axios"));
|
|
14
|
+
const sha224_1 = __importDefault(require("crypto-js/sha224"));
|
|
15
|
+
const inversify_1 = require("inversify");
|
|
16
|
+
const purify_ts_1 = require("purify-ts");
|
|
17
|
+
const package_json_1 = __importDefault(require("../../../package.json"));
|
|
18
|
+
let HttpTypedDataDataSource = class HttpTypedDataDataSource {
|
|
19
|
+
async getTypedDataFilters({ chainId, address, schema, version, }) {
|
|
20
|
+
try {
|
|
21
|
+
const response = await axios_1.default.request({
|
|
22
|
+
method: "GET",
|
|
23
|
+
url: `https://crypto-assets-service.api.ledger.com/v1/dapps`,
|
|
24
|
+
params: {
|
|
25
|
+
contracts: address,
|
|
26
|
+
chain_id: chainId,
|
|
27
|
+
output: "eip712_signatures",
|
|
28
|
+
eip712_signatures_version: version,
|
|
29
|
+
},
|
|
30
|
+
headers: {
|
|
31
|
+
"X-Ledger-Client-Version": `context-module/${package_json_1.default.version}`,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
// Try to get the filters JSON descriptor, from address and schema hash
|
|
35
|
+
const schemaHash = (0, sha224_1.default)(JSON.stringify(this.sortTypes(schema)).replace(" ", "")).toString();
|
|
36
|
+
const filtersJson = response.data?.[0]?.eip712_signatures?.[address]?.[schemaHash];
|
|
37
|
+
if (!filtersJson) {
|
|
38
|
+
return (0, purify_ts_1.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${address} on chain ${chainId} for schema ${schemaHash}`));
|
|
39
|
+
}
|
|
40
|
+
// Parse the message type, if available
|
|
41
|
+
if (!filtersJson.contractName ||
|
|
42
|
+
typeof filtersJson.contractName.label !== "string" ||
|
|
43
|
+
typeof filtersJson.contractName.signature !== "string" ||
|
|
44
|
+
!Array.isArray(filtersJson.fields)) {
|
|
45
|
+
return (0, purify_ts_1.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${address} on chain ${chainId} for schema ${schemaHash}`));
|
|
46
|
+
}
|
|
47
|
+
const messageInfo = {
|
|
48
|
+
displayName: filtersJson.contractName.label,
|
|
49
|
+
filtersCount: filtersJson.fields.length,
|
|
50
|
+
signature: filtersJson.contractName.signature,
|
|
51
|
+
};
|
|
52
|
+
// Parse all the filters
|
|
53
|
+
const filters = [];
|
|
54
|
+
for (const field of filtersJson.fields) {
|
|
55
|
+
if (this.isFieldFilterV1(field)) {
|
|
56
|
+
filters.push({
|
|
57
|
+
type: "raw",
|
|
58
|
+
displayName: field.label,
|
|
59
|
+
path: field.path,
|
|
60
|
+
signature: field.signature,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else if (this.isFieldFilterV2(field)) {
|
|
64
|
+
filters.push({
|
|
65
|
+
type: field.format,
|
|
66
|
+
displayName: field.label,
|
|
67
|
+
path: field.path,
|
|
68
|
+
signature: field.signature,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else if (this.isFieldFilterV2WithCoinRef(field)) {
|
|
72
|
+
filters.push({
|
|
73
|
+
type: field.format,
|
|
74
|
+
displayName: field.label,
|
|
75
|
+
path: field.path,
|
|
76
|
+
signature: field.signature,
|
|
77
|
+
tokenIndex: field.coin_ref,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return (0, purify_ts_1.Left)(new Error(`[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${address} on chain ${chainId} for schema ${schemaHash}`));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return (0, purify_ts_1.Right)({ messageInfo, filters });
|
|
85
|
+
}
|
|
86
|
+
catch (_error) {
|
|
87
|
+
return (0, purify_ts_1.Left)(new Error("[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations"));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
isFieldFilterV1(data) {
|
|
91
|
+
return (typeof data === "object" &&
|
|
92
|
+
typeof data.label === "string" &&
|
|
93
|
+
typeof data.path === "string" &&
|
|
94
|
+
typeof data.signature === "string" &&
|
|
95
|
+
(data.format === undefined || data.format === null));
|
|
96
|
+
}
|
|
97
|
+
isFieldFilterV2(data) {
|
|
98
|
+
return (typeof data === "object" &&
|
|
99
|
+
typeof data.label === "string" &&
|
|
100
|
+
typeof data.path === "string" &&
|
|
101
|
+
typeof data.signature === "string" &&
|
|
102
|
+
typeof data.format === "string" &&
|
|
103
|
+
["raw", "datetime"].includes(data.format) &&
|
|
104
|
+
(data.coin_ref === undefined || data.coin_ref === null));
|
|
105
|
+
}
|
|
106
|
+
isFieldFilterV2WithCoinRef(data) {
|
|
107
|
+
return (typeof data === "object" &&
|
|
108
|
+
typeof data.label === "string" &&
|
|
109
|
+
typeof data.path === "string" &&
|
|
110
|
+
typeof data.signature === "string" &&
|
|
111
|
+
typeof data.format === "string" &&
|
|
112
|
+
["token", "amount"].includes(data.format) &&
|
|
113
|
+
typeof data.coin_ref === "number");
|
|
114
|
+
}
|
|
115
|
+
sortTypes(types) {
|
|
116
|
+
return Object.fromEntries(Object.entries(types)
|
|
117
|
+
.sort(([aKey], [bKey]) => aKey.localeCompare(bKey))
|
|
118
|
+
.map(([key, value]) => [
|
|
119
|
+
key,
|
|
120
|
+
value.map((v) => ({ name: v.name, type: v.type })),
|
|
121
|
+
]));
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
exports.HttpTypedDataDataSource = HttpTypedDataDataSource;
|
|
125
|
+
exports.HttpTypedDataDataSource = HttpTypedDataDataSource = __decorate([
|
|
126
|
+
(0, inversify_1.injectable)()
|
|
127
|
+
], HttpTypedDataDataSource);
|
|
128
|
+
//# sourceMappingURL=HttpTypedDataDataSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpTypedDataDataSource.js","sourceRoot":"","sources":["../../../../../src/typed-data/data/HttpTypedDataDataSource.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA0B;AAC1B,8DAAsC;AACtC,yCAAuC;AACvC,yCAAgD;AAOhD,sEAAyC;AA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AAO,IAAI,CAAC,IAAI,KAAK,QAAQ;YAC7B,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ;YAClC,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ;YAC/B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;YACzC,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAClC,CAAC;IACJ,CAAC;IAEO,SAAS,CAAC,KAAsB;QACtC,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;aAClB,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;aAClD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YACrB,GAAG;YACH,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;SACnD,CAAC,CACL,CAAC;IACJ,CAAC;CACF,CAAA;AAnJY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CAmJnC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Either } from "purify-ts";
|
|
2
|
+
import { TypedDataFilter, TypedDataMessageInfo } from "../../shared/model/TypedDataClearSignContext";
|
|
3
|
+
import { TypedDataSchema } from "../../shared/model/TypedDataContext";
|
|
4
|
+
export type GetTypedDataFiltersParams = {
|
|
5
|
+
address: string;
|
|
6
|
+
chainId: number;
|
|
7
|
+
version: "v1" | "v2";
|
|
8
|
+
schema: TypedDataSchema;
|
|
9
|
+
};
|
|
10
|
+
export type GetTypedDataFiltersResult = {
|
|
11
|
+
messageInfo: TypedDataMessageInfo;
|
|
12
|
+
filters: TypedDataFilter[];
|
|
13
|
+
};
|
|
14
|
+
export interface TypedDataDataSource {
|
|
15
|
+
getTypedDataFilters(params: GetTypedDataFiltersParams): Promise<Either<Error, GetTypedDataFiltersResult>>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=TypedDataDataSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedDataDataSource.d.ts","sourceRoot":"","sources":["../../../../../src/typed-data/data/TypedDataDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EACL,eAAe,EACf,oBAAoB,EACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,oBAAoB,CAAC;IAClC,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,mBAAmB,CACjB,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,yBAAyB,CAAC,CAAC,CAAC;CACtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedDataDataSource.js","sourceRoot":"","sources":["../../../../../src/typed-data/data/TypedDataDataSource.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedDataModuleFactory.d.ts","sourceRoot":"","sources":["../../../../../src/typed-data/di/typedDataModuleFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAM5C,eAAO,MAAM,sBAAsB,uBAM/B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typedDataModuleFactory = void 0;
|
|
4
|
+
const inversify_1 = require("inversify");
|
|
5
|
+
const HttpTypedDataDataSource_1 = require("../../typed-data/data/HttpTypedDataDataSource");
|
|
6
|
+
const typedDataTypes_1 = require("../../typed-data/di/typedDataTypes");
|
|
7
|
+
const DefaultTypedDataContextLoader_1 = require("../../typed-data/domain/DefaultTypedDataContextLoader");
|
|
8
|
+
const typedDataModuleFactory = () => new inversify_1.ContainerModule((bind, _unbind, _isBound, _rebind) => {
|
|
9
|
+
bind(typedDataTypes_1.typedDataTypes.TypedDataDataSource).to(HttpTypedDataDataSource_1.HttpTypedDataDataSource);
|
|
10
|
+
bind(typedDataTypes_1.typedDataTypes.TypedDataContextLoader).to(DefaultTypedDataContextLoader_1.DefaultTypedDataContextLoader);
|
|
11
|
+
});
|
|
12
|
+
exports.typedDataModuleFactory = typedDataModuleFactory;
|
|
13
|
+
//# sourceMappingURL=typedDataModuleFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedDataModuleFactory.js","sourceRoot":"","sources":["../../../../../src/typed-data/di/typedDataModuleFactory.ts"],"names":[],"mappings":";;;AAAA,yCAA4C;AAE5C,uFAAoF;AACpF,mEAAgE;AAChE,qGAAkG;AAE3F,MAAM,sBAAsB,GAAG,GAAG,EAAE,CACzC,IAAI,2BAAe,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;IACvD,IAAI,CAAC,+BAAc,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,iDAAuB,CAAC,CAAC;IACrE,IAAI,CAAC,+BAAc,CAAC,sBAAsB,CAAC,CAAC,EAAE,CAC5C,6DAA6B,CAC9B,CAAC;AACJ,CAAC,CAAC,CAAC;AANQ,QAAA,sBAAsB,0BAM9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedDataTypes.d.ts","sourceRoot":"","sources":["../../../../../src/typed-data/di/typedDataTypes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;CAG1B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typedDataTypes = void 0;
|
|
4
|
+
exports.typedDataTypes = {
|
|
5
|
+
TypedDataDataSource: Symbol.for("TypedDataDataSource"),
|
|
6
|
+
TypedDataContextLoader: Symbol.for("TypedDataContextLoader"),
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=typedDataTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedDataTypes.js","sourceRoot":"","sources":["../../../../../src/typed-data/di/typedDataTypes.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;IAC5B,mBAAmB,EAAE,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC;IACtD,sBAAsB,EAAE,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC;CAC7D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TypedDataClearSignContext } from "../../shared/model/TypedDataClearSignContext";
|
|
2
|
+
import type { TypedDataContext } from "../../shared/model/TypedDataContext";
|
|
3
|
+
import type { TokenDataSource } from "../../token/data/TokenDataSource";
|
|
4
|
+
import type { TypedDataDataSource } from "../../typed-data/data/TypedDataDataSource";
|
|
5
|
+
import type { TypedDataContextLoader } from "../../typed-data/domain/TypedDataContextLoader";
|
|
6
|
+
export declare class DefaultTypedDataContextLoader implements TypedDataContextLoader {
|
|
7
|
+
private dataSource;
|
|
8
|
+
private tokenDataSource;
|
|
9
|
+
constructor(dataSource: TypedDataDataSource, tokenDataSource: TokenDataSource);
|
|
10
|
+
load(typedData: TypedDataContext): Promise<TypedDataClearSignContext>;
|
|
11
|
+
private convertAddressToHexaString;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=DefaultTypedDataContextLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultTypedDataContextLoader.d.ts","sourceRoot":"","sources":["../../../../../src/typed-data/domain/DefaultTypedDataContextLoader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yBAAyB,EAK1B,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAEjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEzF,qBACa,6BAA8B,YAAW,sBAAsB;IAGxE,OAAO,CAAC,UAAU;IAElB,OAAO,CAAC,eAAe;gBAFf,UAAU,EAAE,mBAAmB,EAE/B,eAAe,EAAE,eAAe;IAGpC,IAAI,CAAC,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAoG3E,OAAO,CAAC,0BAA0B;CAQnC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DefaultTypedDataContextLoader = void 0;
|
|
16
|
+
const inversify_1 = require("inversify");
|
|
17
|
+
const TypedDataClearSignContext_1 = require("../../shared/model/TypedDataClearSignContext");
|
|
18
|
+
const tokenTypes_1 = require("../../token/di/tokenTypes");
|
|
19
|
+
const typedDataTypes_1 = require("../../typed-data/di/typedDataTypes");
|
|
20
|
+
let DefaultTypedDataContextLoader = class DefaultTypedDataContextLoader {
|
|
21
|
+
dataSource;
|
|
22
|
+
tokenDataSource;
|
|
23
|
+
constructor(dataSource, tokenDataSource) {
|
|
24
|
+
this.dataSource = dataSource;
|
|
25
|
+
this.tokenDataSource = tokenDataSource;
|
|
26
|
+
}
|
|
27
|
+
async load(typedData) {
|
|
28
|
+
// Get the typed data filters from the data source
|
|
29
|
+
const data = await this.dataSource.getTypedDataFilters({
|
|
30
|
+
address: typedData.verifyingContract,
|
|
31
|
+
chainId: typedData.chainId,
|
|
32
|
+
version: typedData.version,
|
|
33
|
+
schema: typedData.schema,
|
|
34
|
+
});
|
|
35
|
+
// If there was an error getting the typed data filters, return an error immediately
|
|
36
|
+
if (data.isLeft()) {
|
|
37
|
+
return {
|
|
38
|
+
type: "error",
|
|
39
|
+
error: data.extract(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// Else, extract the message info and filters
|
|
43
|
+
const { messageInfo, filters } = data.unsafeCoerce();
|
|
44
|
+
// Loop through the typed data filters to extract informations
|
|
45
|
+
const mappedFilters = {};
|
|
46
|
+
const mappedTokens = {};
|
|
47
|
+
for (const filter of filters) {
|
|
48
|
+
// Add the filter to the clear signing context
|
|
49
|
+
mappedFilters[filter.path] = filter;
|
|
50
|
+
if (filter.type !== "token" && filter.type !== "amount") {
|
|
51
|
+
continue; // no token reference
|
|
52
|
+
}
|
|
53
|
+
// If the filter references a token, retrieve its descriptor from the tokens data source
|
|
54
|
+
const tokenIndex = filter.tokenIndex;
|
|
55
|
+
if (mappedTokens[tokenIndex] !== undefined) {
|
|
56
|
+
continue; // Already fetched for a previous filter
|
|
57
|
+
}
|
|
58
|
+
// If the filter is a token, get token address from typed message values, and fetch descriptor
|
|
59
|
+
if (filter.type === "token") {
|
|
60
|
+
const value = typedData.fieldsValues.find((entry) => entry.path === filter.path);
|
|
61
|
+
if (value === undefined) {
|
|
62
|
+
return {
|
|
63
|
+
type: "error",
|
|
64
|
+
error: new Error(`The token filter references the value ${filter.path} which is absent from the message`),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Fetch descriptor
|
|
68
|
+
const address = this.convertAddressToHexaString(value.value);
|
|
69
|
+
const chainId = typedData.chainId;
|
|
70
|
+
const payload = await this.tokenDataSource.getTokenInfosPayload({
|
|
71
|
+
address,
|
|
72
|
+
chainId,
|
|
73
|
+
});
|
|
74
|
+
if (payload.isLeft()) {
|
|
75
|
+
return {
|
|
76
|
+
type: "error",
|
|
77
|
+
error: payload.extract(),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
payload.ifRight((payload) => {
|
|
81
|
+
mappedTokens[tokenIndex] = payload;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
// If the filter is an amount with a reference to the verifyingContract, fetch verifyingContract descriptor.
|
|
85
|
+
// This is because descriptors data-sources should be compatible with Ledger devices specifications:
|
|
86
|
+
// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#amount-join-value
|
|
87
|
+
else if (filter.type === "amount" &&
|
|
88
|
+
tokenIndex === TypedDataClearSignContext_1.VERIFYING_CONTRACT_TOKEN_INDEX) {
|
|
89
|
+
const address = typedData.verifyingContract;
|
|
90
|
+
const chainId = typedData.chainId;
|
|
91
|
+
const payload = await this.tokenDataSource.getTokenInfosPayload({
|
|
92
|
+
address,
|
|
93
|
+
chainId,
|
|
94
|
+
});
|
|
95
|
+
if (payload.isLeft()) {
|
|
96
|
+
return {
|
|
97
|
+
type: "error",
|
|
98
|
+
error: payload.extract(),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
payload.ifRight((payload) => {
|
|
102
|
+
mappedTokens[tokenIndex] = payload;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
type: "success",
|
|
108
|
+
messageInfo,
|
|
109
|
+
filters: mappedFilters,
|
|
110
|
+
tokens: mappedTokens,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
convertAddressToHexaString(address) {
|
|
114
|
+
// Address size is 20 bytes so 40 characters, padded with zeros on the left
|
|
115
|
+
return `0x${Array.from(address, (byte) => byte.toString(16).padStart(2, "0"))
|
|
116
|
+
.join("")
|
|
117
|
+
.padStart(40, "0")}`;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
exports.DefaultTypedDataContextLoader = DefaultTypedDataContextLoader;
|
|
121
|
+
exports.DefaultTypedDataContextLoader = DefaultTypedDataContextLoader = __decorate([
|
|
122
|
+
(0, inversify_1.injectable)(),
|
|
123
|
+
__param(0, (0, inversify_1.inject)(typedDataTypes_1.typedDataTypes.TypedDataDataSource)),
|
|
124
|
+
__param(1, (0, inversify_1.inject)(tokenTypes_1.tokenTypes.TokenDataSource)),
|
|
125
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
126
|
+
], DefaultTypedDataContextLoader);
|
|
127
|
+
//# sourceMappingURL=DefaultTypedDataContextLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultTypedDataContextLoader.js","sourceRoot":"","sources":["../../../../../src/typed-data/domain/DefaultT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C5C,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;gBAClC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,oBAAoB,CAAC;oBAC9D,OAAO;oBACP,OAAO;iBACR,CAAC,CAAC;gBACH,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;oBACrB,OAAO;wBACL,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE;qBACzB,CAAC;gBACJ,CAAC;gBACD,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;oBAC1B,YAAY,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC;gBACrC,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,IAAI,EAAE,SAAS;YACf,WAAW;YACX,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SACrB,CAAC;IACJ,CAAC;IAEO,0BAA0B,CAAC,OAAmB;QACpD,2EAA2E;QAC3E,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CACvC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CACnC;aACE,IAAI,CAAC,EAAE,CAAC;aACR,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC;IACzB,CAAC;CACF,CAAA;AApHY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,sBAAU,GAAE;IAGR,WAAA,IAAA,kBAAM,EAAC,+BAAc,CAAC,mBAAmB,CAAC,CAAA;IAE1C,WAAA,IAAA,kBAAM,EAAC,uBAAU,CAAC,eAAe,CAAC,CAAA;;GAJ1B,6BAA6B,CAoHzC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TypedDataClearSignContext } from "../../shared/model/TypedDataClearSignContext";
|
|
2
|
+
import type { TypedDataContext } from "../../shared/model/TypedDataContext";
|
|
3
|
+
export interface TypedDataContextLoader {
|
|
4
|
+
load(typedData: TypedDataContext): Promise<TypedDataClearSignContext>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=TypedDataContextLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedDataContextLoader.d.ts","sourceRoot":"","sources":["../../../../../src/typed-data/domain/TypedDataContextLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAC1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedDataContextLoader.js","sourceRoot":"","sources":["../../../../../src/typed-data/domain/TypedDataContextLoader.ts"],"names":[],"mappings":""}
|