@ledgerhq/context-module 0.0.0-develop-20260804002603 → 0.0.0-develop-20260807010949
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/modules/solana/alt-resolution/data/AltResolutionDataSource.js +1 -1
- package/lib/cjs/src/modules/solana/alt-resolution/data/AltResolutionDataSource.js.map +1 -1
- package/lib/cjs/src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.js +1 -1
- package/lib/cjs/src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.js.map +2 -2
- package/lib/cjs/src/modules/solana/alt-resolution/domain/AltResolutionContextLoader.js +1 -1
- package/lib/cjs/src/modules/solana/alt-resolution/domain/AltResolutionContextLoader.js.map +2 -2
- package/lib/cjs/src/modules/solana/model/SolanaPayloads.js +1 -1
- package/lib/cjs/src/modules/solana/model/SolanaPayloads.js.map +1 -1
- package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js +1 -1
- package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js.map +2 -2
- package/lib/cjs/src/modules/solana/token-account-state/data/TokenAccountStateDataSource.js +1 -1
- package/lib/cjs/src/modules/solana/token-account-state/data/TokenAccountStateDataSource.js.map +1 -1
- package/lib/cjs/src/modules/solana/token-account-state/domain/TokenAccountStateContextLoader.js +1 -1
- package/lib/cjs/src/modules/solana/token-account-state/domain/TokenAccountStateContextLoader.js.map +2 -2
- package/lib/cjs/src/modules/solana/token-info/data/HttpTokenInfoDataSource.js +1 -1
- package/lib/cjs/src/modules/solana/token-info/data/HttpTokenInfoDataSource.js.map +3 -3
- package/lib/cjs/src/modules/solana/token-info/data/HttpTokenInfoDataSource.test.js +1 -1
- package/lib/cjs/src/modules/solana/token-info/data/HttpTokenInfoDataSource.test.js.map +2 -2
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.js +1 -1
- package/lib/esm/src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.js.map +2 -2
- package/lib/esm/src/modules/solana/alt-resolution/domain/AltResolutionContextLoader.js +1 -1
- package/lib/esm/src/modules/solana/alt-resolution/domain/AltResolutionContextLoader.js.map +2 -2
- package/lib/esm/src/modules/solana/model/SolanaPayloads.js.map +1 -1
- package/lib/esm/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js +1 -1
- package/lib/esm/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js.map +2 -2
- package/lib/esm/src/modules/solana/token-account-state/domain/TokenAccountStateContextLoader.js +1 -1
- package/lib/esm/src/modules/solana/token-account-state/domain/TokenAccountStateContextLoader.js.map +3 -3
- package/lib/esm/src/modules/solana/token-info/data/HttpTokenInfoDataSource.js +1 -1
- package/lib/esm/src/modules/solana/token-info/data/HttpTokenInfoDataSource.js.map +3 -3
- package/lib/esm/src/modules/solana/token-info/data/HttpTokenInfoDataSource.test.js +1 -1
- package/lib/esm/src/modules/solana/token-info/data/HttpTokenInfoDataSource.test.js.map +2 -2
- package/lib/types/src/modules/solana/alt-resolution/data/AltResolutionDataSource.d.ts +1 -0
- package/lib/types/src/modules/solana/alt-resolution/data/AltResolutionDataSource.d.ts.map +1 -1
- package/lib/types/src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.d.ts.map +1 -1
- package/lib/types/src/modules/solana/alt-resolution/domain/AltResolutionContextLoader.d.ts.map +1 -1
- package/lib/types/src/modules/solana/model/SolanaPayloads.d.ts +2 -0
- package/lib/types/src/modules/solana/model/SolanaPayloads.d.ts.map +1 -1
- package/lib/types/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.d.ts.map +1 -1
- package/lib/types/src/modules/solana/token-account-state/data/TokenAccountStateDataSource.d.ts +1 -0
- package/lib/types/src/modules/solana/token-account-state/data/TokenAccountStateDataSource.d.ts.map +1 -1
- package/lib/types/src/modules/solana/token-account-state/domain/TokenAccountStateContextLoader.d.ts.map +1 -1
- package/lib/types/src/modules/solana/token-info/data/HttpTokenInfoDataSource.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -4
package/lib/cjs/package.json
CHANGED
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
59
59
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
60
60
|
},
|
|
61
|
-
"version": "0.0.0-develop-
|
|
61
|
+
"version": "0.0.0-develop-20260807010949"
|
|
62
62
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var d=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of l(e))!a.call(t,r)&&r!==n&&o(t,r,{get:()=>e[r],enumerable:!(s=i(e,r))||s.enumerable});return t};var u=t=>d(o({},"__esModule",{value:!0}),t);var A={};module.exports=u(A);
|
|
2
2
|
//# sourceMappingURL=AltResolutionDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/alt-resolution/data/AltResolutionDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Either } from \"purify-ts\";\n\nexport type GetAltResolutionParams = {\n altAddress: string;\n entryIndex: number;\n challenge: string;\n};\n\nexport type AltResolutionResult = {\n altAddress: string;\n entryIndex: number;\n // Raw signed TLV bytes decoded from the backend response.\n descriptor: Uint8Array;\n keyId: string;\n keyUsage: string;\n};\n\nexport interface AltResolutionDataSource {\n getAltResolution(\n params: GetAltResolutionParams,\n ): Promise<Either<Error, AltResolutionResult>>;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { type Either } from \"purify-ts\";\n\nexport type GetAltResolutionParams = {\n altAddress: string;\n entryIndex: number;\n challenge: string;\n};\n\nexport type AltResolutionResult = {\n altAddress: string;\n entryIndex: number;\n // Raw signed TLV bytes decoded from the backend response.\n descriptor: Uint8Array;\n resolvedAddress?: string;\n keyId: string;\n keyUsage: string;\n};\n\nexport interface AltResolutionDataSource {\n getAltResolution(\n params: GetAltResolutionParams,\n ): Promise<Either<Error, AltResolutionResult>>;\n}\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["AltResolutionDataSource_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var $=(r,e)=>{for(var t in e)c(r,t,{get:e[t],enumerable:!0})},E=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!k.call(r,o)&&o!==t&&c(r,o,{get:()=>e[o],enumerable:!(s=d(e,o))||s.enumerable});return r};var v=r=>E(c({},"__esModule",{value:!0}),r),f=(r,e,t,s)=>{for(var o=s>1?void 0:s?d(e,t):e,n=r.length-1,i;n>=0;n--)(i=r[n])&&(o=(s?i(e,t,o):i(o))||o);return s&&o&&c(e,t,o),o},m=(r,e)=>(t,s)=>e(t,s,r);var w={};$(w,{HttpAltResolutionDataSource:()=>a});module.exports=v(w);var u=require("inversify"),l=require("purify-ts"),g=require("../../../../config/di/configTypes"),R=require("../../../../shared/network/di/networkTypes"),y=require("../../../../shared/utils/HexStringUtils"),A=require("../../../../shared/utils/signedDescriptorDto"),D=require("../../../../shared/utils/uIntCodec");let a=class{constructor(e,t){this.config=e;this.http=t}async getAltResolution({altAddress:e,entryIndex:t,challenge:s}){const o=D.u8Codec.decode(t);if(o.isLeft())return(0,l.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: invalid entryIndex (got ${t}): ${o.leftOrDefault("")}`));let n;try{n=await this.http.get(`${this.config.metadataServiceDomain.url}/v2/solana/alt-resolution/${e}/${t}`,{params:{challenge:s}})}catch(i){const p=i instanceof Error?i.message:String(i);return(0,l.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: Failed to fetch ALT resolution: ${p}`))}return A.signedDescriptorDtoCodec.decode(n).caseOf({Left:i=>(0,l.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: malformed response for (${e}, ${t}): ${i}`)),Right:i=>{let p;try{p=y.HexStringUtils.hexToBytes(i.signedDescriptor)}catch(h){return(0,l.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: invalid hex in signedDescriptor for (${e}, ${t}): ${h.message}`))}return(0,l.Right)({altAddress:e,entryIndex:t,descriptor:p,resolvedAddress:n.resolvedAddress,keyId:i.keyId,keyUsage:i.keyUsage})}})}};a=f([(0,u.injectable)(),m(0,(0,u.inject)(g.configTypes.Config)),m(1,(0,u.inject)(R.networkTypes.NetworkClient))],a);0&&(module.exports={HttpAltResolutionDataSource});
|
|
2
2
|
//# sourceMappingURL=HttpAltResolutionDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport { signedDescriptorDtoCodec } from \"@/shared/utils/signedDescriptorDto\";\nimport { u8Codec } from \"@/shared/utils/uIntCodec\";\n\nimport {\n type AltResolutionDataSource,\n type AltResolutionResult,\n type GetAltResolutionParams,\n} from \"./AltResolutionDataSource\";\n\ntype AltResolutionResponseDto = {\n descriptorType?: string;\n descriptorVersion?: number;\n altAddress?: string;\n entryIndex?: number;\n resolvedAddress?: string;\n signedDescriptor: string;\n keyId: string;\n keyUsage: string;\n};\n\n@injectable()\nexport class HttpAltResolutionDataSource implements AltResolutionDataSource {\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getAltResolution({\n altAddress,\n entryIndex,\n challenge,\n }: GetAltResolutionParams): Promise<Either<Error, AltResolutionResult>> {\n const entryIndexResult = u8Codec.decode(entryIndex);\n if (entryIndexResult.isLeft()) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid entryIndex (got ${entryIndex}): ${entryIndexResult.leftOrDefault(\"\")}`,\n ),\n );\n }\n\n let dto: AltResolutionResponseDto;\n try {\n dto = (await this.http.get(\n `${this.config.metadataServiceDomain.url}/v2/solana/alt-resolution/${altAddress}/${entryIndex}`,\n { params: { challenge } },\n )) as AltResolutionResponseDto;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: Failed to fetch ALT resolution: ${reason}`,\n ),\n );\n }\n\n return signedDescriptorDtoCodec\n .decode(dto)\n .caseOf<Either<Error, AltResolutionResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: malformed response for (${altAddress}, ${entryIndex}): ${error}`,\n ),\n ),\n Right: (validated) => {\n let descriptor: Uint8Array;\n try {\n descriptor = HexStringUtils.hexToBytes(validated.signedDescriptor);\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid hex in signedDescriptor for (${altAddress}, ${entryIndex}): ${(error as Error).message}`,\n ),\n );\n }\n\n return Right({\n altAddress,\n entryIndex,\n descriptor,\n keyId: validated.keyId,\n keyUsage: validated.keyUsage,\n });\n },\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAA6B,4CAC7BC,EAA+B,yCAC/BC,EAAyC,8CACzCC,EAAwB,oCAoBjB,IAAMC,EAAN,KAAqE,CAC1E,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAa,iBAAiB,CAC5B,WAAAC,EACA,WAAAC,EACA,UAAAC,CACF,EAAwE,CACtE,MAAMC,EAAmB,UAAQ,OAAOF,CAAU,EAClD,GAAIE,EAAiB,OAAO,EAC1B,SAAO,QACL,IAAI,MACF,wEAAwEF,CAAU,MAAME,EAAiB,cAAc,EAAE,CAAC,EAC5H,CACF,EAGF,IAAIC,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IACrB,GAAG,KAAK,OAAO,sBAAsB,GAAG,6BAA6BJ,CAAU,IAAIC,CAAU,GAC7F,CAAE,OAAQ,CAAE,UAAAC,CAAU,CAAE,CAC1B,CACF,OAASG,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,SAAO,QACL,IAAI,MACF,gFAAgFC,CAAM,EACxF,CACF,CACF,CAEA,OAAO,2BACJ,OAAOF,CAAG,EACV,OAA2C,CAC1C,KAAOC,MACL,QACE,IAAI,MACF,wEAAwEL,CAAU,KAAKC,CAAU,MAAMI,CAAK,EAC9G,CACF,EACF,MAAQE,GAAc,CACpB,IAAIC,EACJ,GAAI,CACFA,EAAa,iBAAe,WAAWD,EAAU,gBAAgB,CACnE,OAASF,EAAO,CACd,SAAO,QACL,IAAI,MACF,qFAAqFL,CAAU,KAAKC,CAAU,MAAOI,EAAgB,OAAO,EAC9I,CACF,CACF,CAEA,SAAO,SAAM,CACX,WAAAL,EACA,WAAAC,EACA,WAAAO,EACA,
|
|
4
|
+
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport { signedDescriptorDtoCodec } from \"@/shared/utils/signedDescriptorDto\";\nimport { u8Codec } from \"@/shared/utils/uIntCodec\";\n\nimport {\n type AltResolutionDataSource,\n type AltResolutionResult,\n type GetAltResolutionParams,\n} from \"./AltResolutionDataSource\";\n\ntype AltResolutionResponseDto = {\n descriptorType?: string;\n descriptorVersion?: number;\n altAddress?: string;\n entryIndex?: number;\n resolvedAddress?: string;\n signedDescriptor: string;\n keyId: string;\n keyUsage: string;\n};\n\n@injectable()\nexport class HttpAltResolutionDataSource implements AltResolutionDataSource {\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getAltResolution({\n altAddress,\n entryIndex,\n challenge,\n }: GetAltResolutionParams): Promise<Either<Error, AltResolutionResult>> {\n const entryIndexResult = u8Codec.decode(entryIndex);\n if (entryIndexResult.isLeft()) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid entryIndex (got ${entryIndex}): ${entryIndexResult.leftOrDefault(\"\")}`,\n ),\n );\n }\n\n let dto: AltResolutionResponseDto;\n try {\n dto = (await this.http.get(\n `${this.config.metadataServiceDomain.url}/v2/solana/alt-resolution/${altAddress}/${entryIndex}`,\n { params: { challenge } },\n )) as AltResolutionResponseDto;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: Failed to fetch ALT resolution: ${reason}`,\n ),\n );\n }\n\n return signedDescriptorDtoCodec\n .decode(dto)\n .caseOf<Either<Error, AltResolutionResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: malformed response for (${altAddress}, ${entryIndex}): ${error}`,\n ),\n ),\n Right: (validated) => {\n let descriptor: Uint8Array;\n try {\n descriptor = HexStringUtils.hexToBytes(validated.signedDescriptor);\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid hex in signedDescriptor for (${altAddress}, ${entryIndex}): ${(error as Error).message}`,\n ),\n );\n }\n\n return Right({\n altAddress,\n entryIndex,\n descriptor,\n resolvedAddress: dto.resolvedAddress,\n keyId: validated.keyId,\n keyUsage: validated.keyUsage,\n });\n },\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAA6B,4CAC7BC,EAA+B,yCAC/BC,EAAyC,8CACzCC,EAAwB,oCAoBjB,IAAMC,EAAN,KAAqE,CAC1E,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAa,iBAAiB,CAC5B,WAAAC,EACA,WAAAC,EACA,UAAAC,CACF,EAAwE,CACtE,MAAMC,EAAmB,UAAQ,OAAOF,CAAU,EAClD,GAAIE,EAAiB,OAAO,EAC1B,SAAO,QACL,IAAI,MACF,wEAAwEF,CAAU,MAAME,EAAiB,cAAc,EAAE,CAAC,EAC5H,CACF,EAGF,IAAIC,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IACrB,GAAG,KAAK,OAAO,sBAAsB,GAAG,6BAA6BJ,CAAU,IAAIC,CAAU,GAC7F,CAAE,OAAQ,CAAE,UAAAC,CAAU,CAAE,CAC1B,CACF,OAASG,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,SAAO,QACL,IAAI,MACF,gFAAgFC,CAAM,EACxF,CACF,CACF,CAEA,OAAO,2BACJ,OAAOF,CAAG,EACV,OAA2C,CAC1C,KAAOC,MACL,QACE,IAAI,MACF,wEAAwEL,CAAU,KAAKC,CAAU,MAAMI,CAAK,EAC9G,CACF,EACF,MAAQE,GAAc,CACpB,IAAIC,EACJ,GAAI,CACFA,EAAa,iBAAe,WAAWD,EAAU,gBAAgB,CACnE,OAASF,EAAO,CACd,SAAO,QACL,IAAI,MACF,qFAAqFL,CAAU,KAAKC,CAAU,MAAOI,EAAgB,OAAO,EAC9I,CACF,CACF,CAEA,SAAO,SAAM,CACX,WAAAL,EACA,WAAAC,EACA,WAAAO,EACA,gBAAiBJ,EAAI,gBACrB,MAAOG,EAAU,MACjB,SAAUA,EAAU,QACtB,CAAC,CACH,CACF,CAAC,CACL,CACF,EArEaV,EAANY,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,eAAa,aAAa,IAJzBb",
|
|
6
6
|
"names": ["HttpAltResolutionDataSource_exports", "__export", "HttpAltResolutionDataSource", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_networkTypes", "import_HexStringUtils", "import_signedDescriptorDto", "import_uIntCodec", "HttpAltResolutionDataSource", "config", "http", "altAddress", "entryIndex", "challenge", "entryIndexResult", "dto", "error", "reason", "validated", "descriptor", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var L=(l,e)=>{for(var t in e)s(l,t,{get:e[t],enumerable:!0})},h=(l,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of x(e))!I.call(l,r)&&r!==t&&s(l,r,{get:()=>e[r],enumerable:!(o=g(e,r))||o.enumerable});return l};var v=l=>h(s({},"__esModule",{value:!0}),l),m=(l,e,t,o)=>{for(var r=o>1?void 0:o?g(e,t):e,c=l.length-1,p;c>=0;c--)(p=l[c])&&(r=(o?p(e,t,r):p(r))||r);return o&&r&&s(e,t,r),r},d=(l,e)=>(t,o)=>e(t,o,l);var b={};L(b,{AltResolutionContextLoader:()=>a});module.exports=v(b);var i=require("inversify"),n=require("purify-ts"),y=require("../../../../config/di/configTypes"),f=require("../../../../modules/multichain/pki/di/pkiTypes"),S=require("../../../../modules/solana/alt-resolution/di/altResolutionTypes"),u=require("../../../../shared/model/ClearSignContext"),C=require("../../../../shared/utils/challengeBoundLoader"),A=require("../../../../shared/utils/deviceModelIdCodec"),R=require("../../../../shared/utils/uIntCodec");const T=[u.ClearSignContextType.SOLANA_ALT_RESOLUTION],P=n.Codec.interface({altAddress:n.string,entryIndex:R.u8Codec,challenge:n.string}),O=n.Codec.interface({deviceModelId:A.deviceModelIdCodec,requests:(0,n.array)(P)});let a=class{constructor(e,t,o){this.dataSource=e;this.certificateLoader=t;this.logger=o("AltResolutionContextLoader")}logger;canHandle(e,t){return T.every(o=>t.includes(o))?O.decode(e).caseOf({Left:()=>!1,Right:({requests:o})=>o.length>0&&o.every(r=>r.altAddress.length>0&&r.challenge.length>0)}):!1}async load(e){return(0,C.loadChallengeBoundContexts)({requests:e.requests,deviceModelId:e.deviceModelId,certificateLoader:this.certificateLoader,logger:this.logger,label:"ALT_RESOLUTION",fetch:t=>this.dataSource.getAltResolution(t),toContext:(t,o)=>{const r={descriptor:t.descriptor};return{type:u.ClearSignContextType.SOLANA_ALT_RESOLUTION,payload:r,certificate:o}},describe:t=>({altAddress:t.altAddress,entryIndex:t.entryIndex})})}};a=m([(0,i.injectable)(),d(0,(0,i.inject)(S.altResolutionTypes.AltResolutionDataSource)),d(1,(0,i.inject)(f.pkiTypes.PkiCertificateLoader)),d(2,(0,i.inject)(y.configTypes.ContextModuleLoggerFactory))],a);0&&(module.exports={AltResolutionContextLoader});
|
|
1
|
+
"use strict";var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var L=(l,e)=>{for(var t in e)s(l,t,{get:e[t],enumerable:!0})},h=(l,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of x(e))!I.call(l,r)&&r!==t&&s(l,r,{get:()=>e[r],enumerable:!(o=g(e,r))||o.enumerable});return l};var v=l=>h(s({},"__esModule",{value:!0}),l),m=(l,e,t,o)=>{for(var r=o>1?void 0:o?g(e,t):e,c=l.length-1,p;c>=0;c--)(p=l[c])&&(r=(o?p(e,t,r):p(r))||r);return o&&r&&s(e,t,r),r},d=(l,e)=>(t,o)=>e(t,o,l);var b={};L(b,{AltResolutionContextLoader:()=>a});module.exports=v(b);var i=require("inversify"),n=require("purify-ts"),y=require("../../../../config/di/configTypes"),f=require("../../../../modules/multichain/pki/di/pkiTypes"),S=require("../../../../modules/solana/alt-resolution/di/altResolutionTypes"),u=require("../../../../shared/model/ClearSignContext"),C=require("../../../../shared/utils/challengeBoundLoader"),A=require("../../../../shared/utils/deviceModelIdCodec"),R=require("../../../../shared/utils/uIntCodec");const T=[u.ClearSignContextType.SOLANA_ALT_RESOLUTION],P=n.Codec.interface({altAddress:n.string,entryIndex:R.u8Codec,challenge:n.string}),O=n.Codec.interface({deviceModelId:A.deviceModelIdCodec,requests:(0,n.array)(P)});let a=class{constructor(e,t,o){this.dataSource=e;this.certificateLoader=t;this.logger=o("AltResolutionContextLoader")}logger;canHandle(e,t){return T.every(o=>t.includes(o))?O.decode(e).caseOf({Left:()=>!1,Right:({requests:o})=>o.length>0&&o.every(r=>r.altAddress.length>0&&r.challenge.length>0)}):!1}async load(e){return(0,C.loadChallengeBoundContexts)({requests:e.requests,deviceModelId:e.deviceModelId,certificateLoader:this.certificateLoader,logger:this.logger,label:"ALT_RESOLUTION",fetch:t=>this.dataSource.getAltResolution(t),toContext:(t,o)=>{const r={descriptor:t.descriptor,resolvedAddress:t.resolvedAddress};return{type:u.ClearSignContextType.SOLANA_ALT_RESOLUTION,payload:r,certificate:o}},describe:t=>({altAddress:t.altAddress,entryIndex:t.entryIndex})})}};a=m([(0,i.injectable)(),d(0,(0,i.inject)(S.altResolutionTypes.AltResolutionDataSource)),d(1,(0,i.inject)(f.pkiTypes.PkiCertificateLoader)),d(2,(0,i.inject)(y.configTypes.ContextModuleLoggerFactory))],a);0&&(module.exports={AltResolutionContextLoader});
|
|
2
2
|
//# sourceMappingURL=AltResolutionContextLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/alt-resolution/domain/AltResolutionContextLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type DeviceModelId,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { array, Codec, string } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { pkiTypes } from \"@/modules/multichain/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/modules/multichain/pki/domain/PkiCertificateLoader\";\nimport { type AltResolutionDataSource } from \"@/modules/solana/alt-resolution/data/AltResolutionDataSource\";\nimport { altResolutionTypes } from \"@/modules/solana/alt-resolution/di/altResolutionTypes\";\nimport { type SolanaAltResolutionPayload } from \"@/modules/solana/model/SolanaPayloads\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { loadChallengeBoundContexts } from \"@/shared/utils/challengeBoundLoader\";\nimport { deviceModelIdCodec } from \"@/shared/utils/deviceModelIdCodec\";\nimport { u8Codec } from \"@/shared/utils/uIntCodec\";\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.SOLANA_ALT_RESOLUTION,\n];\n\nexport type SolanaAltResolutionRequest = {\n altAddress: string;\n entryIndex: number;\n challenge: string;\n};\n\nexport type SolanaAltResolutionContextInput = {\n deviceModelId: DeviceModelId;\n requests: SolanaAltResolutionRequest[];\n};\n\nconst altResolutionRequestCodec = Codec.interface({\n altAddress: string,\n entryIndex: u8Codec,\n challenge: string,\n});\n\nconst solanaAltResolutionInputCodec = Codec.interface({\n deviceModelId: deviceModelIdCodec,\n requests: array(altResolutionRequestCodec),\n});\n\n@injectable()\nexport class AltResolutionContextLoader\n implements ContextLoader<SolanaAltResolutionContextInput>\n{\n private readonly logger: LoggerPublisherService;\n\n constructor(\n @inject(altResolutionTypes.AltResolutionDataSource)\n private readonly dataSource: AltResolutionDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly certificateLoader: PkiCertificateLoader,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n ) {\n this.logger = loggerFactory(\"AltResolutionContextLoader\");\n }\n\n public canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is SolanaAltResolutionContextInput {\n if (!SUPPORTED_TYPES.every((t) => expectedTypes.includes(t))) return false;\n return solanaAltResolutionInputCodec.decode(input).caseOf({\n Left: () => false,\n Right: ({ requests }) =>\n requests.length > 0 &&\n requests.every(\n (r) => r.altAddress.length > 0 && r.challenge.length > 0,\n ),\n });\n }\n\n public async load(\n input: SolanaAltResolutionContextInput,\n ): Promise<ClearSignContext[]> {\n return loadChallengeBoundContexts({\n requests: input.requests,\n deviceModelId: input.deviceModelId,\n certificateLoader: this.certificateLoader,\n logger: this.logger,\n label: \"ALT_RESOLUTION\",\n fetch: (request) => this.dataSource.getAltResolution(request),\n toContext: (value, certificate) => {\n const payload: SolanaAltResolutionPayload = {\n descriptor: value.descriptor,\n };\n return {\n type: ClearSignContextType.SOLANA_ALT_RESOLUTION,\n payload,\n certificate,\n };\n },\n describe: (request) => ({\n altAddress: request.altAddress,\n entryIndex: request.entryIndex,\n }),\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAmC,qBACnCC,EAAqC,qBAErCC,EAA4B,mCAC5BC,EAAyB,gDAGzBC,EAAmC,iEAGnCC,EAGO,2CACPC,EAA2C,+CAC3CC,EAAmC,6CACnCC,EAAwB,oCAExB,MAAMC,EAA0C,CAC9C,uBAAqB,qBACvB,EAaMC,EAA4B,QAAM,UAAU,CAChD,WAAY,SACZ,WAAY,UACZ,UAAW,QACb,CAAC,EAEKC,EAAgC,QAAM,UAAU,CACpD,cAAe,qBACf,YAAU,SAAMD,CAAyB,CAC3C,CAAC,EAGM,IAAME,EAAN,KAEP,CAGE,YAEmBC,EAEAC,EAEjBC,EACA,CALiB,gBAAAF,EAEA,uBAAAC,EAIjB,KAAK,OAASC,EAAc,4BAA4B,CAC1D,CAXiB,OAaV,UACLC,EACAC,EAC0C,CAC1C,OAAKR,EAAgB,MAAOS,GAAMD,EAAc,SAASC,CAAC,CAAC,EACpDP,EAA8B,OAAOK,CAAK,EAAE,OAAO,CACxD,KAAM,IAAM,GACZ,MAAO,CAAC,CAAE,SAAAG,CAAS,IACjBA,EAAS,OAAS,GAClBA,EAAS,MACN,GAAM,EAAE,WAAW,OAAS,GAAK,EAAE,UAAU,OAAS,CACzD,CACJ,CAAC,EARoE,EASvE,CAEA,MAAa,KACXH,EAC6B,CAC7B,SAAO,8BAA2B,CAChC,SAAUA,EAAM,SAChB,cAAeA,EAAM,cACrB,kBAAmB,KAAK,kBACxB,OAAQ,KAAK,OACb,MAAO,iBACP,MAAQI,GAAY,KAAK,WAAW,iBAAiBA,CAAO,EAC5D,UAAW,CAACC,EAAOC,IAAgB,CACjC,MAAMC,EAAsC,CAC1C,WAAYF,EAAM,
|
|
4
|
+
"sourcesContent": ["import {\n type DeviceModelId,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { array, Codec, string } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { pkiTypes } from \"@/modules/multichain/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/modules/multichain/pki/domain/PkiCertificateLoader\";\nimport { type AltResolutionDataSource } from \"@/modules/solana/alt-resolution/data/AltResolutionDataSource\";\nimport { altResolutionTypes } from \"@/modules/solana/alt-resolution/di/altResolutionTypes\";\nimport { type SolanaAltResolutionPayload } from \"@/modules/solana/model/SolanaPayloads\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { loadChallengeBoundContexts } from \"@/shared/utils/challengeBoundLoader\";\nimport { deviceModelIdCodec } from \"@/shared/utils/deviceModelIdCodec\";\nimport { u8Codec } from \"@/shared/utils/uIntCodec\";\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.SOLANA_ALT_RESOLUTION,\n];\n\nexport type SolanaAltResolutionRequest = {\n altAddress: string;\n entryIndex: number;\n challenge: string;\n};\n\nexport type SolanaAltResolutionContextInput = {\n deviceModelId: DeviceModelId;\n requests: SolanaAltResolutionRequest[];\n};\n\nconst altResolutionRequestCodec = Codec.interface({\n altAddress: string,\n entryIndex: u8Codec,\n challenge: string,\n});\n\nconst solanaAltResolutionInputCodec = Codec.interface({\n deviceModelId: deviceModelIdCodec,\n requests: array(altResolutionRequestCodec),\n});\n\n@injectable()\nexport class AltResolutionContextLoader\n implements ContextLoader<SolanaAltResolutionContextInput>\n{\n private readonly logger: LoggerPublisherService;\n\n constructor(\n @inject(altResolutionTypes.AltResolutionDataSource)\n private readonly dataSource: AltResolutionDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly certificateLoader: PkiCertificateLoader,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n ) {\n this.logger = loggerFactory(\"AltResolutionContextLoader\");\n }\n\n public canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is SolanaAltResolutionContextInput {\n if (!SUPPORTED_TYPES.every((t) => expectedTypes.includes(t))) return false;\n return solanaAltResolutionInputCodec.decode(input).caseOf({\n Left: () => false,\n Right: ({ requests }) =>\n requests.length > 0 &&\n requests.every(\n (r) => r.altAddress.length > 0 && r.challenge.length > 0,\n ),\n });\n }\n\n public async load(\n input: SolanaAltResolutionContextInput,\n ): Promise<ClearSignContext[]> {\n return loadChallengeBoundContexts({\n requests: input.requests,\n deviceModelId: input.deviceModelId,\n certificateLoader: this.certificateLoader,\n logger: this.logger,\n label: \"ALT_RESOLUTION\",\n fetch: (request) => this.dataSource.getAltResolution(request),\n toContext: (value, certificate) => {\n const payload: SolanaAltResolutionPayload = {\n descriptor: value.descriptor,\n resolvedAddress: value.resolvedAddress,\n };\n return {\n type: ClearSignContextType.SOLANA_ALT_RESOLUTION,\n payload,\n certificate,\n };\n },\n describe: (request) => ({\n altAddress: request.altAddress,\n entryIndex: request.entryIndex,\n }),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAmC,qBACnCC,EAAqC,qBAErCC,EAA4B,mCAC5BC,EAAyB,gDAGzBC,EAAmC,iEAGnCC,EAGO,2CACPC,EAA2C,+CAC3CC,EAAmC,6CACnCC,EAAwB,oCAExB,MAAMC,EAA0C,CAC9C,uBAAqB,qBACvB,EAaMC,EAA4B,QAAM,UAAU,CAChD,WAAY,SACZ,WAAY,UACZ,UAAW,QACb,CAAC,EAEKC,EAAgC,QAAM,UAAU,CACpD,cAAe,qBACf,YAAU,SAAMD,CAAyB,CAC3C,CAAC,EAGM,IAAME,EAAN,KAEP,CAGE,YAEmBC,EAEAC,EAEjBC,EACA,CALiB,gBAAAF,EAEA,uBAAAC,EAIjB,KAAK,OAASC,EAAc,4BAA4B,CAC1D,CAXiB,OAaV,UACLC,EACAC,EAC0C,CAC1C,OAAKR,EAAgB,MAAOS,GAAMD,EAAc,SAASC,CAAC,CAAC,EACpDP,EAA8B,OAAOK,CAAK,EAAE,OAAO,CACxD,KAAM,IAAM,GACZ,MAAO,CAAC,CAAE,SAAAG,CAAS,IACjBA,EAAS,OAAS,GAClBA,EAAS,MACN,GAAM,EAAE,WAAW,OAAS,GAAK,EAAE,UAAU,OAAS,CACzD,CACJ,CAAC,EARoE,EASvE,CAEA,MAAa,KACXH,EAC6B,CAC7B,SAAO,8BAA2B,CAChC,SAAUA,EAAM,SAChB,cAAeA,EAAM,cACrB,kBAAmB,KAAK,kBACxB,OAAQ,KAAK,OACb,MAAO,iBACP,MAAQI,GAAY,KAAK,WAAW,iBAAiBA,CAAO,EAC5D,UAAW,CAACC,EAAOC,IAAgB,CACjC,MAAMC,EAAsC,CAC1C,WAAYF,EAAM,WAClB,gBAAiBA,EAAM,eACzB,EACA,MAAO,CACL,KAAM,uBAAqB,sBAC3B,QAAAE,EACA,YAAAD,CACF,CACF,EACA,SAAWF,IAAa,CACtB,WAAYA,EAAQ,WACpB,WAAYA,EAAQ,UACtB,EACF,CAAC,CACH,CACF,EA1DaR,EAANY,EAAA,IADN,cAAW,EAOPC,EAAA,eAAO,qBAAmB,uBAAuB,GAEjDA,EAAA,eAAO,WAAS,oBAAoB,GAEpCA,EAAA,eAAO,cAAY,0BAA0B,IAVrCb",
|
|
6
6
|
"names": ["AltResolutionContextLoader_exports", "__export", "AltResolutionContextLoader", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_pkiTypes", "import_altResolutionTypes", "import_ClearSignContext", "import_challengeBoundLoader", "import_deviceModelIdCodec", "import_uIntCodec", "SUPPORTED_TYPES", "altResolutionRequestCodec", "solanaAltResolutionInputCodec", "AltResolutionContextLoader", "dataSource", "certificateLoader", "loggerFactory", "input", "expectedTypes", "t", "requests", "request", "value", "certificate", "payload", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(t,n)=>{for(var e in n)o(t,e,{get:n[e],enumerable:!0})},c=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of l(n))!p.call(t,a)&&a!==e&&o(t,a,{get:()=>n[a],enumerable:!(r=s(n,a))||r.enumerable});return t};var g=t=>c(o({},"__esModule",{value:!0}),t);var u={};d(u,{SolanaInstructionSubstructureKind:()=>i});module.exports=g(u);var i=(a=>(a[a.DISPLAY_FIELD=0]="DISPLAY_FIELD",a[a.VALUE_FLOW_PORT=1]="VALUE_FLOW_PORT",a[a.HIDE_RULE=2]="HIDE_RULE",a[a.ACCOUNT_RESET=3]="ACCOUNT_RESET",a))(i||{});0&&(module.exports={SolanaInstructionSubstructureKind});
|
|
2
2
|
//# sourceMappingURL=SolanaPayloads.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/solana/model/SolanaPayloads.ts"],
|
|
4
|
-
"sourcesContent": ["// Solana payload types \u2014 used both by Solana loaders and (type-only)\n// referenced by the shared ClearSignContext union for typed-payload variants.\n\nexport type SolanaTokenData = {\n solanaTokenDescriptor: {\n data: string;\n signature: string;\n };\n};\n\nexport type SolanaTransactionDescriptor = {\n data: string;\n descriptorType: string;\n descriptorVersion: string;\n signature: string;\n has_basis_point?: boolean;\n};\n\nexport type SolanaLifiInstructionMeta = {\n program_id: string;\n discriminator_hex?: string;\n has_basis_point?: boolean;\n};\n\nexport type SolanaLifiPayload = {\n descriptors: Record<string, SolanaTransactionDescriptor[]>;\n instructions: SolanaLifiInstructionMeta[];\n};\n\nexport type SolanaTransactionCheckPayload = {\n descriptor: string;\n};\n\n// --- Generic clear-signing payloads ---\n\n// CAL static descriptor payloads. `data` is the signed TLV (hex string);\n// `signature` is the resolved signature for the configured CAL signature\n// kind (`prod` | `test`).\n\nexport type SolanaSignedDescriptor = {\n data: string;\n signature: string;\n};\n\n/**\n * One enum-variant descriptor bundled with an instruction descriptor by CAL.\n * The signed TLV (`descriptor.data`) feeds the host-side type-pool decode\n * cache, `enumId`/`variantIndex` identify which variant it describes (and let\n * the host stream the selected variant's signed descriptor to the device).\n */\nexport type SolanaInstructionEnumVariant = {\n enumId: string;\n variantIndex: number;\n descriptor: SolanaSignedDescriptor;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_INSTRUCTION_INFO.\n *\n * `instructionInfo` + `substructures` are the signed TLVs streamed to the\n * device, and `enumVariants` are the signed enum-variant descriptors CAL\n * bundles for the program's enums (used to build the host decode cache). The\n * remaining fields are CAL's decoded JSON consumed host-side by the\n * requirement builder.\n */\nexport type SolanaInstructionInfoPayload = {\n programId: string;\n discriminator: string;\n instructionInfo: SolanaSignedDescriptor;\n substructures: SolanaInstructionSubstructure[];\n enumVariants: SolanaInstructionEnumVariant[];\n idlDescriptor: {\n typePool: SolanaCalTypePoolEntry[];\n rootType: number;\n };\n mintAssociations: SolanaCalMintAssociation[];\n valueFlowPorts: SolanaCalValueFlowPort[];\n accountResets: SolanaCalAccountReset[];\n displayFields: SolanaCalDisplayField[];\n};\n\nexport enum SolanaInstructionSubstructureKind {\n DISPLAY_FIELD = 0x00,\n VALUE_FLOW_PORT = 0x01,\n HIDE_RULE = 0x02,\n ACCOUNT_RESET = 0x03,\n}\n\nexport type SolanaInstructionSubstructure = {\n kind: SolanaInstructionSubstructureKind;\n // TLV payload (hex string) for the substructure.\n data: string;\n};\n\n// --- Decoded CAL JSON (snake_case mirrors the CAL response) ---\n\nexport type SolanaCalValue = {\n source: string;\n /** ACCOUNT_PATH: index into the instruction's accounts. */\n account_index?: number;\n /** CONSTANT: hex-encoded bytes. */\n data?: string;\n /** ARGUMENT_PATH: decoded steps. */\n path?: { steps: number[] };\n};\n\nexport type SolanaCalTokenValue = {\n kind: string;\n value?: SolanaCalValue;\n account_index?: number;\n};\n\nexport type SolanaCalValueFlowPort = {\n /** Ordered candidate list of account indices (length 1 for a single-account port). */\n account_indices: number[];\n optional_account_strategy?: string;\n token_value: SolanaCalTokenValue;\n};\n\nexport type SolanaCalAccountReset = {\n account_index: number;\n require_pre_balance_zero?: boolean;\n};\n\nexport type SolanaCalDisplayField = {\n name?: string;\n param: { type: string; value?: SolanaCalValue; token?: SolanaCalValue };\n};\n\nexport type SolanaCalTypePoolEntry = {\n index: number;\n kind: string;\n refs?: number[];\n size?: number;\n encoding?: number;\n len_kind?: string;\n flag_kind?: string;\n sentinel?: string;\n disc_kind?: string;\n total_variants?: number;\n enum_id?: string;\n};\n\nexport type SolanaCalMintAssociation = {\n account_index: number;\n mint_index: number;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_ENUM_VARIANT: one signed\n * ENUM_VARIANT descriptor for a `(programId, enumId, variantIndex)` triple.\n */\nexport type SolanaEnumVariantPayload = {\n programId: string;\n enumId: string;\n variantIndex: number;\n descriptor: SolanaSignedDescriptor;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_TOKEN_INFO, keyed by mint pubkey.\n * Distinct from the legacy SOLANA_TOKEN context.\n */\nexport type SolanaTokenInfoPayload = {\n mint: string;\n descriptor: SolanaSignedDescriptor;\n};\n\n// --- Dynamic descriptor payloads (challenge-bound) ---\n//\n// Each payload carries the raw signed TLV bytes decoded from the backend's\n// hex `signedDescriptor`.\n\nexport type SolanaTokenAccountStatePayload = {\n descriptor: Uint8Array;\n};\n\nexport type SolanaAltResolutionPayload = {\n descriptor: Uint8Array;\n};\n\n// SOLANA_TRUSTED_NAME (generic flow, with 2-byte length prefix) is emitted by\n// SolanaTrustedNameContextLoader. SOLANA_BASIC_TRUSTED_NAME (basic flow, raw\n// bytes) is emitted by OwnerInfoContextLoader. Both carry `payload: Uint8Array`.\n"],
|
|
4
|
+
"sourcesContent": ["// Solana payload types \u2014 used both by Solana loaders and (type-only)\n// referenced by the shared ClearSignContext union for typed-payload variants.\n\nexport type SolanaTokenData = {\n solanaTokenDescriptor: {\n data: string;\n signature: string;\n };\n};\n\nexport type SolanaTransactionDescriptor = {\n data: string;\n descriptorType: string;\n descriptorVersion: string;\n signature: string;\n has_basis_point?: boolean;\n};\n\nexport type SolanaLifiInstructionMeta = {\n program_id: string;\n discriminator_hex?: string;\n has_basis_point?: boolean;\n};\n\nexport type SolanaLifiPayload = {\n descriptors: Record<string, SolanaTransactionDescriptor[]>;\n instructions: SolanaLifiInstructionMeta[];\n};\n\nexport type SolanaTransactionCheckPayload = {\n descriptor: string;\n};\n\n// --- Generic clear-signing payloads ---\n\n// CAL static descriptor payloads. `data` is the signed TLV (hex string);\n// `signature` is the resolved signature for the configured CAL signature\n// kind (`prod` | `test`).\n\nexport type SolanaSignedDescriptor = {\n data: string;\n signature: string;\n};\n\n/**\n * One enum-variant descriptor bundled with an instruction descriptor by CAL.\n * The signed TLV (`descriptor.data`) feeds the host-side type-pool decode\n * cache, `enumId`/`variantIndex` identify which variant it describes (and let\n * the host stream the selected variant's signed descriptor to the device).\n */\nexport type SolanaInstructionEnumVariant = {\n enumId: string;\n variantIndex: number;\n descriptor: SolanaSignedDescriptor;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_INSTRUCTION_INFO.\n *\n * `instructionInfo` + `substructures` are the signed TLVs streamed to the\n * device, and `enumVariants` are the signed enum-variant descriptors CAL\n * bundles for the program's enums (used to build the host decode cache). The\n * remaining fields are CAL's decoded JSON consumed host-side by the\n * requirement builder.\n */\nexport type SolanaInstructionInfoPayload = {\n programId: string;\n discriminator: string;\n instructionInfo: SolanaSignedDescriptor;\n substructures: SolanaInstructionSubstructure[];\n enumVariants: SolanaInstructionEnumVariant[];\n idlDescriptor: {\n typePool: SolanaCalTypePoolEntry[];\n rootType: number;\n };\n mintAssociations: SolanaCalMintAssociation[];\n valueFlowPorts: SolanaCalValueFlowPort[];\n accountResets: SolanaCalAccountReset[];\n displayFields: SolanaCalDisplayField[];\n};\n\nexport enum SolanaInstructionSubstructureKind {\n DISPLAY_FIELD = 0x00,\n VALUE_FLOW_PORT = 0x01,\n HIDE_RULE = 0x02,\n ACCOUNT_RESET = 0x03,\n}\n\nexport type SolanaInstructionSubstructure = {\n kind: SolanaInstructionSubstructureKind;\n // TLV payload (hex string) for the substructure.\n data: string;\n};\n\n// --- Decoded CAL JSON (snake_case mirrors the CAL response) ---\n\nexport type SolanaCalValue = {\n source: string;\n /** ACCOUNT_PATH: index into the instruction's accounts. */\n account_index?: number;\n /** CONSTANT: hex-encoded bytes. */\n data?: string;\n /** ARGUMENT_PATH: decoded steps. */\n path?: { steps: number[] };\n};\n\nexport type SolanaCalTokenValue = {\n kind: string;\n value?: SolanaCalValue;\n account_index?: number;\n};\n\nexport type SolanaCalValueFlowPort = {\n /** Ordered candidate list of account indices (length 1 for a single-account port). */\n account_indices: number[];\n optional_account_strategy?: string;\n token_value: SolanaCalTokenValue;\n};\n\nexport type SolanaCalAccountReset = {\n account_index: number;\n require_pre_balance_zero?: boolean;\n};\n\nexport type SolanaCalDisplayField = {\n name?: string;\n param: { type: string; value?: SolanaCalValue; token?: SolanaCalValue };\n};\n\nexport type SolanaCalTypePoolEntry = {\n index: number;\n kind: string;\n refs?: number[];\n size?: number;\n encoding?: number;\n len_kind?: string;\n flag_kind?: string;\n sentinel?: string;\n disc_kind?: string;\n total_variants?: number;\n enum_id?: string;\n};\n\nexport type SolanaCalMintAssociation = {\n account_index: number;\n mint_index: number;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_ENUM_VARIANT: one signed\n * ENUM_VARIANT descriptor for a `(programId, enumId, variantIndex)` triple.\n */\nexport type SolanaEnumVariantPayload = {\n programId: string;\n enumId: string;\n variantIndex: number;\n descriptor: SolanaSignedDescriptor;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_TOKEN_INFO, keyed by mint pubkey.\n * Distinct from the legacy SOLANA_TOKEN context.\n */\nexport type SolanaTokenInfoPayload = {\n mint: string;\n descriptor: SolanaSignedDescriptor;\n};\n\n// --- Dynamic descriptor payloads (challenge-bound) ---\n//\n// Each payload carries the raw signed TLV bytes decoded from the backend's\n// hex `signedDescriptor`.\n\nexport type SolanaTokenAccountStatePayload = {\n descriptor: Uint8Array;\n mint?: string;\n};\n\nexport type SolanaAltResolutionPayload = {\n descriptor: Uint8Array;\n resolvedAddress?: string;\n};\n\n// SOLANA_TRUSTED_NAME (generic flow, with 2-byte length prefix) is emitted by\n// SolanaTrustedNameContextLoader. SOLANA_BASIC_TRUSTED_NAME (basic flow, raw\n// bytes) is emitted by OwnerInfoContextLoader. Both carry `payload: Uint8Array`.\n"],
|
|
5
5
|
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uCAAAE,IAAA,eAAAC,EAAAH,GAiFO,IAAKE,OACVA,IAAA,cAAgB,GAAhB,gBACAA,IAAA,gBAAkB,GAAlB,kBACAA,IAAA,UAAY,GAAZ,YACAA,IAAA,cAAgB,GAAhB,gBAJUA,OAAA",
|
|
6
6
|
"names": ["SolanaPayloads_exports", "__export", "SolanaInstructionSubstructureKind", "__toCommonJS"]
|
|
7
7
|
}
|
package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var h=(r,t)=>{for(var o in t)p(r,o,{get:t[o],enumerable:!0})},D=(r,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of S(t))!T.call(r,e)&&e!==o&&p(r,e,{get:()=>t[e],enumerable:!(n=g(t,e))||n.enumerable});return r};var C=r=>D(p({},"__esModule",{value:!0}),r),l=(r,t,o,n)=>{for(var e=n>1?void 0:n?g(t,o):t,i=r.length-1,c;i>=0;i--)(c=r[i])&&(e=(n?c(t,o,e):c(e))||e);return n&&e&&p(t,o,e),e},u=(r,t)=>(o,n)=>t(o,n,r);var A={};h(A,{HttpTokenAccountStateDataSource:()=>a});module.exports=C(A);var m=require("inversify"),s=require("purify-ts"),f=require("../../../../config/di/configTypes"),k=require("../../../../shared/network/di/networkTypes"),d=require("../../../../shared/utils/HexStringUtils"),y=require("../../../../shared/utils/signedDescriptorDto");let a=class{constructor(t,o){this.config=t;this.http=o}async getTokenAccountState({tokenAccount:t,challenge:o}){let n;try{n=await this.http.get(`${this.config.metadataServiceDomain.url}/v2/solana/token-account-state/${t}`,{params:{challenge:o}})}catch(e){const i=e instanceof Error?e.message:String(e);return(0,s.Left)(new Error(`[ContextModule] HttpTokenAccountStateDataSource: Failed to fetch token account state: ${i}`))}return y.signedDescriptorDtoCodec.decode(n).caseOf({Left:e=>(0,s.Left)(new Error(`[ContextModule] HttpTokenAccountStateDataSource: malformed response for ${t}: ${e}`)),Right:e=>{let i;try{i=d.HexStringUtils.hexToBytes(e.signedDescriptor)}catch(c){return(0,s.Left)(new Error(`[ContextModule] HttpTokenAccountStateDataSource: invalid hex in signedDescriptor for ${t}: ${c.message}`))}return(0,s.Right)({tokenAccount:t,descriptor:i,mint:n.mint,keyId:e.keyId,keyUsage:e.keyUsage})}})}};a=l([(0,m.injectable)(),u(0,(0,m.inject)(f.configTypes.Config)),u(1,(0,m.inject)(k.networkTypes.NetworkClient))],a);0&&(module.exports={HttpTokenAccountStateDataSource});
|
|
2
2
|
//# sourceMappingURL=HttpTokenAccountStateDataSource.js.map
|
package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport { signedDescriptorDtoCodec } from \"@/shared/utils/signedDescriptorDto\";\n\nimport {\n type GetTokenAccountStateParams,\n type TokenAccountStateDataSource,\n type TokenAccountStateResult,\n} from \"./TokenAccountStateDataSource\";\n\ntype TokenAccountStateResponseDto = {\n descriptorType?: string;\n descriptorVersion?: number;\n tokenAccount?: string;\n mint?: string;\n owner?: string;\n preBalance?: number;\n signedDescriptor: string;\n keyId: string;\n keyUsage: string;\n};\n\n@injectable()\nexport class HttpTokenAccountStateDataSource\n implements TokenAccountStateDataSource\n{\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getTokenAccountState({\n tokenAccount,\n challenge,\n }: GetTokenAccountStateParams): Promise<\n Either<Error, TokenAccountStateResult>\n > {\n let dto: TokenAccountStateResponseDto;\n try {\n dto = (await this.http.get(\n `${this.config.metadataServiceDomain.url}/v2/solana/token-account-state/${tokenAccount}`,\n { params: { challenge } },\n )) as TokenAccountStateResponseDto;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpTokenAccountStateDataSource: Failed to fetch token account state: ${reason}`,\n ),\n );\n }\n\n return signedDescriptorDtoCodec\n .decode(dto)\n .caseOf<Either<Error, TokenAccountStateResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpTokenAccountStateDataSource: malformed response for ${tokenAccount}: ${error}`,\n ),\n ),\n Right: (validated) => {\n let descriptor: Uint8Array;\n try {\n descriptor = HexStringUtils.hexToBytes(validated.signedDescriptor);\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTokenAccountStateDataSource: invalid hex in signedDescriptor for ${tokenAccount}: ${(error as Error).message}`,\n ),\n );\n }\n\n return Right({\n tokenAccount,\n descriptor,\n keyId: validated.keyId,\n keyUsage: validated.keyUsage,\n });\n },\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAA6B,4CAC7BC,EAA+B,yCAC/BC,EAAyC,8CAqBlC,IAAMC,EAAN,KAEP,CACE,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAa,qBAAqB,CAChC,aAAAC,EACA,UAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IACrB,GAAG,KAAK,OAAO,sBAAsB,GAAG,kCAAkCF,CAAY,GACtF,CAAE,OAAQ,CAAE,UAAAC,CAAU,CAAE,CAC1B,CACF,OAASE,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,SAAO,QACL,IAAI,MACF,yFAAyFC,CAAM,EACjG,CACF,CACF,CAEA,OAAO,2BACJ,OAAOF,CAAG,EACV,OAA+C,CAC9C,KAAOC,MACL,QACE,IAAI,MACF,2EAA2EH,CAAY,KAAKG,CAAK,EACnG,CACF,EACF,MAAQE,GAAc,CACpB,IAAIC,EACJ,GAAI,CACFA,EAAa,iBAAe,WAAWD,EAAU,gBAAgB,CACnE,OAASF,EAAO,CACd,SAAO,QACL,IAAI,MACF,wFAAwFH,CAAY,KAAMG,EAAgB,OAAO,EACnI,CACF,CACF,CAEA,SAAO,SAAM,CACX,aAAAH,EACA,WAAAM,EACA,
|
|
4
|
+
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport { signedDescriptorDtoCodec } from \"@/shared/utils/signedDescriptorDto\";\n\nimport {\n type GetTokenAccountStateParams,\n type TokenAccountStateDataSource,\n type TokenAccountStateResult,\n} from \"./TokenAccountStateDataSource\";\n\ntype TokenAccountStateResponseDto = {\n descriptorType?: string;\n descriptorVersion?: number;\n tokenAccount?: string;\n mint?: string;\n owner?: string;\n preBalance?: number;\n signedDescriptor: string;\n keyId: string;\n keyUsage: string;\n};\n\n@injectable()\nexport class HttpTokenAccountStateDataSource\n implements TokenAccountStateDataSource\n{\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getTokenAccountState({\n tokenAccount,\n challenge,\n }: GetTokenAccountStateParams): Promise<\n Either<Error, TokenAccountStateResult>\n > {\n let dto: TokenAccountStateResponseDto;\n try {\n dto = (await this.http.get(\n `${this.config.metadataServiceDomain.url}/v2/solana/token-account-state/${tokenAccount}`,\n { params: { challenge } },\n )) as TokenAccountStateResponseDto;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpTokenAccountStateDataSource: Failed to fetch token account state: ${reason}`,\n ),\n );\n }\n\n return signedDescriptorDtoCodec\n .decode(dto)\n .caseOf<Either<Error, TokenAccountStateResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpTokenAccountStateDataSource: malformed response for ${tokenAccount}: ${error}`,\n ),\n ),\n Right: (validated) => {\n let descriptor: Uint8Array;\n try {\n descriptor = HexStringUtils.hexToBytes(validated.signedDescriptor);\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTokenAccountStateDataSource: invalid hex in signedDescriptor for ${tokenAccount}: ${(error as Error).message}`,\n ),\n );\n }\n\n return Right({\n tokenAccount,\n descriptor,\n mint: dto.mint,\n keyId: validated.keyId,\n keyUsage: validated.keyUsage,\n });\n },\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAA6B,4CAC7BC,EAA+B,yCAC/BC,EAAyC,8CAqBlC,IAAMC,EAAN,KAEP,CACE,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAa,qBAAqB,CAChC,aAAAC,EACA,UAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IACrB,GAAG,KAAK,OAAO,sBAAsB,GAAG,kCAAkCF,CAAY,GACtF,CAAE,OAAQ,CAAE,UAAAC,CAAU,CAAE,CAC1B,CACF,OAASE,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,SAAO,QACL,IAAI,MACF,yFAAyFC,CAAM,EACjG,CACF,CACF,CAEA,OAAO,2BACJ,OAAOF,CAAG,EACV,OAA+C,CAC9C,KAAOC,MACL,QACE,IAAI,MACF,2EAA2EH,CAAY,KAAKG,CAAK,EACnG,CACF,EACF,MAAQE,GAAc,CACpB,IAAIC,EACJ,GAAI,CACFA,EAAa,iBAAe,WAAWD,EAAU,gBAAgB,CACnE,OAASF,EAAO,CACd,SAAO,QACL,IAAI,MACF,wFAAwFH,CAAY,KAAMG,EAAgB,OAAO,EACnI,CACF,CACF,CAEA,SAAO,SAAM,CACX,aAAAH,EACA,WAAAM,EACA,KAAMJ,EAAI,KACV,MAAOG,EAAU,MACjB,SAAUA,EAAU,QACtB,CAAC,CACH,CACF,CAAC,CACL,CACF,EA9DaR,EAANU,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,eAAa,aAAa,IANzBX",
|
|
6
6
|
"names": ["HttpTokenAccountStateDataSource_exports", "__export", "HttpTokenAccountStateDataSource", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_networkTypes", "import_HexStringUtils", "import_signedDescriptorDto", "HttpTokenAccountStateDataSource", "config", "http", "tokenAccount", "challenge", "dto", "error", "reason", "validated", "descriptor", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var u=(e,t,c,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of i(t))!s.call(e,n)&&n!==c&&o(e,n,{get:()=>t[n],enumerable:!(r=a(t,n))||r.enumerable});return e};var k=e=>u(o({},"__esModule",{value:!0}),e);var g={};module.exports=k(g);
|
|
2
2
|
//# sourceMappingURL=TokenAccountStateDataSource.js.map
|
package/lib/cjs/src/modules/solana/token-account-state/data/TokenAccountStateDataSource.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/token-account-state/data/TokenAccountStateDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Either } from \"purify-ts\";\n\nexport type GetTokenAccountStateParams = {\n tokenAccount: string;\n challenge: string;\n};\n\nexport type TokenAccountStateResult = {\n tokenAccount: string;\n // Raw signed TLV bytes decoded from the backend response.\n descriptor: Uint8Array;\n keyId: string;\n keyUsage: string;\n};\n\nexport interface TokenAccountStateDataSource {\n getTokenAccountState(\n params: GetTokenAccountStateParams,\n ): Promise<Either<Error, TokenAccountStateResult>>;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { type Either } from \"purify-ts\";\n\nexport type GetTokenAccountStateParams = {\n tokenAccount: string;\n challenge: string;\n};\n\nexport type TokenAccountStateResult = {\n tokenAccount: string;\n // Raw signed TLV bytes decoded from the backend response.\n descriptor: Uint8Array;\n mint?: string;\n keyId: string;\n keyUsage: string;\n};\n\nexport interface TokenAccountStateDataSource {\n getTokenAccountState(\n params: GetTokenAccountStateParams,\n ): Promise<Either<Error, TokenAccountStateResult>>;\n}\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["TokenAccountStateDataSource_exports", "__toCommonJS"]
|
|
7
7
|
}
|
package/lib/cjs/src/modules/solana/token-account-state/domain/TokenAccountStateContextLoader.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var h=(r,e)=>{for(var t in e)l(r,t,{get:e[t],enumerable:!0})},
|
|
1
|
+
"use strict";var l=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var h=(r,e)=>{for(var t in e)l(r,t,{get:e[t],enumerable:!0})},x=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!k.call(r,n)&&n!==t&&l(r,n,{get:()=>e[n],enumerable:!(o=S(e,n))||o.enumerable});return r};var v=r=>x(l({},"__esModule",{value:!0}),r),g=(r,e,t,o)=>{for(var n=o>1?void 0:o?S(e,t):e,p=r.length-1,u;p>=0;p--)(u=r[p])&&(n=(o?u(e,t,n):u(n))||n);return o&&n&&l(e,t,n),n},d=(r,e)=>(t,o)=>e(t,o,r);var O={};h(O,{TokenAccountStateContextLoader:()=>i});module.exports=v(O);var a=require("inversify"),c=require("purify-ts"),m=require("../../../../config/di/configTypes"),C=require("../../../../modules/multichain/pki/di/pkiTypes"),T=require("../../../../modules/solana/token-account-state/di/tokenAccountStateTypes"),s=require("../../../../shared/model/ClearSignContext"),f=require("../../../../shared/utils/challengeBoundLoader"),A=require("../../../../shared/utils/deviceModelIdCodec");const L=[s.ClearSignContextType.SOLANA_TOKEN_ACCOUNT_STATE],I=c.Codec.interface({tokenAccount:c.string,challenge:c.string}),P=c.Codec.interface({deviceModelId:A.deviceModelIdCodec,requests:(0,c.array)(I)});let i=class{constructor(e,t,o){this.dataSource=e;this.certificateLoader=t;this.logger=o("TokenAccountStateContextLoader")}logger;canHandle(e,t){return L.every(o=>t.includes(o))?P.decode(e).caseOf({Left:()=>!1,Right:({requests:o})=>o.length>0&&o.every(n=>n.tokenAccount.length>0&&n.challenge.length>0)}):!1}async load(e){return(0,f.loadChallengeBoundContexts)({requests:e.requests,deviceModelId:e.deviceModelId,certificateLoader:this.certificateLoader,logger:this.logger,label:"TOKEN_ACCOUNT_STATE",fetch:t=>this.dataSource.getTokenAccountState(t),toContext:(t,o)=>{const n={descriptor:t.descriptor,mint:t.mint};return{type:s.ClearSignContextType.SOLANA_TOKEN_ACCOUNT_STATE,payload:n,certificate:o}},describe:t=>({tokenAccount:t.tokenAccount})})}};i=g([(0,a.injectable)(),d(0,(0,a.inject)(T.tokenAccountStateTypes.TokenAccountStateDataSource)),d(1,(0,a.inject)(C.pkiTypes.PkiCertificateLoader)),d(2,(0,a.inject)(m.configTypes.ContextModuleLoggerFactory))],i);0&&(module.exports={TokenAccountStateContextLoader});
|
|
2
2
|
//# sourceMappingURL=TokenAccountStateContextLoader.js.map
|
package/lib/cjs/src/modules/solana/token-account-state/domain/TokenAccountStateContextLoader.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/token-account-state/domain/TokenAccountStateContextLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type DeviceModelId,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { array, Codec, string } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { pkiTypes } from \"@/modules/multichain/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/modules/multichain/pki/domain/PkiCertificateLoader\";\nimport { type SolanaTokenAccountStatePayload } from \"@/modules/solana/model/SolanaPayloads\";\nimport { type TokenAccountStateDataSource } from \"@/modules/solana/token-account-state/data/TokenAccountStateDataSource\";\nimport { tokenAccountStateTypes } from \"@/modules/solana/token-account-state/di/tokenAccountStateTypes\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { loadChallengeBoundContexts } from \"@/shared/utils/challengeBoundLoader\";\nimport { deviceModelIdCodec } from \"@/shared/utils/deviceModelIdCodec\";\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.SOLANA_TOKEN_ACCOUNT_STATE,\n];\n\n/**\n * One token-account-state request. The caller must obtain a fresh challenge\n * immediately before fetching each entry.\n */\nexport type SolanaTokenAccountStateRequest = {\n tokenAccount: string;\n challenge: string;\n};\n\nexport type SolanaTokenAccountStateContextInput = {\n deviceModelId: DeviceModelId;\n requests: SolanaTokenAccountStateRequest[];\n};\n\nconst tokenAccountStateRequestCodec = Codec.interface({\n tokenAccount: string,\n challenge: string,\n});\n\nconst solanaTokenAccountStateInputCodec = Codec.interface({\n deviceModelId: deviceModelIdCodec,\n requests: array(tokenAccountStateRequestCodec),\n});\n\n@injectable()\nexport class TokenAccountStateContextLoader\n implements ContextLoader<SolanaTokenAccountStateContextInput>\n{\n private readonly logger: LoggerPublisherService;\n\n constructor(\n @inject(tokenAccountStateTypes.TokenAccountStateDataSource)\n private readonly dataSource: TokenAccountStateDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly certificateLoader: PkiCertificateLoader,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n ) {\n this.logger = loggerFactory(\"TokenAccountStateContextLoader\");\n }\n\n public canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is SolanaTokenAccountStateContextInput {\n if (!SUPPORTED_TYPES.every((t) => expectedTypes.includes(t))) return false;\n return solanaTokenAccountStateInputCodec.decode(input).caseOf({\n Left: () => false,\n Right: ({ requests }) =>\n requests.length > 0 &&\n requests.every(\n (r) => r.tokenAccount.length > 0 && r.challenge.length > 0,\n ),\n });\n }\n\n public async load(\n input: SolanaTokenAccountStateContextInput,\n ): Promise<ClearSignContext[]> {\n return loadChallengeBoundContexts({\n requests: input.requests,\n deviceModelId: input.deviceModelId,\n certificateLoader: this.certificateLoader,\n logger: this.logger,\n label: \"TOKEN_ACCOUNT_STATE\",\n fetch: (request) => this.dataSource.getTokenAccountState(request),\n toContext: (value, certificate) => {\n const payload: SolanaTokenAccountStatePayload = {\n descriptor: value.descriptor,\n };\n return {\n type: ClearSignContextType.SOLANA_TOKEN_ACCOUNT_STATE,\n payload,\n certificate,\n };\n },\n describe: (request) => ({ tokenAccount: request.tokenAccount }),\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oCAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAmC,qBACnCC,EAAqC,qBAErCC,EAA4B,mCAC5BC,EAAyB,gDAIzBC,EAAuC,0EAEvCC,EAGO,2CACPC,EAA2C,+CAC3CC,EAAmC,6CAEnC,MAAMC,EAA0C,CAC9C,uBAAqB,0BACvB,EAgBMC,EAAgC,QAAM,UAAU,CACpD,aAAc,SACd,UAAW,QACb,CAAC,EAEKC,EAAoC,QAAM,UAAU,CACxD,cAAe,qBACf,YAAU,SAAMD,CAA6B,CAC/C,CAAC,EAGM,IAAME,EAAN,KAEP,CAGE,YAEmBC,EAEAC,EAEjBC,EACA,CALiB,gBAAAF,EAEA,uBAAAC,EAIjB,KAAK,OAASC,EAAc,gCAAgC,CAC9D,CAXiB,OAaV,UACLC,EACAC,EAC8C,CAC9C,OAAKR,EAAgB,MAAOS,GAAMD,EAAc,SAASC,CAAC,CAAC,EACpDP,EAAkC,OAAOK,CAAK,EAAE,OAAO,CAC5D,KAAM,IAAM,GACZ,MAAO,CAAC,CAAE,SAAAG,CAAS,IACjBA,EAAS,OAAS,GAClBA,EAAS,MACNC,GAAMA,EAAE,aAAa,OAAS,GAAKA,EAAE,UAAU,OAAS,CAC3D,CACJ,CAAC,EARoE,EASvE,CAEA,MAAa,KACXJ,EAC6B,CAC7B,SAAO,8BAA2B,CAChC,SAAUA,EAAM,SAChB,cAAeA,EAAM,cACrB,kBAAmB,KAAK,kBACxB,OAAQ,KAAK,OACb,MAAO,sBACP,MAAQK,GAAY,KAAK,WAAW,qBAAqBA,CAAO,EAChE,UAAW,CAACC,EAAOC,IAAgB,CACjC,MAAMC,EAA0C,CAC9C,WAAYF,EAAM,
|
|
4
|
+
"sourcesContent": ["import {\n type DeviceModelId,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { array, Codec, string } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { pkiTypes } from \"@/modules/multichain/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/modules/multichain/pki/domain/PkiCertificateLoader\";\nimport { type SolanaTokenAccountStatePayload } from \"@/modules/solana/model/SolanaPayloads\";\nimport { type TokenAccountStateDataSource } from \"@/modules/solana/token-account-state/data/TokenAccountStateDataSource\";\nimport { tokenAccountStateTypes } from \"@/modules/solana/token-account-state/di/tokenAccountStateTypes\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { loadChallengeBoundContexts } from \"@/shared/utils/challengeBoundLoader\";\nimport { deviceModelIdCodec } from \"@/shared/utils/deviceModelIdCodec\";\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.SOLANA_TOKEN_ACCOUNT_STATE,\n];\n\n/**\n * One token-account-state request. The caller must obtain a fresh challenge\n * immediately before fetching each entry.\n */\nexport type SolanaTokenAccountStateRequest = {\n tokenAccount: string;\n challenge: string;\n};\n\nexport type SolanaTokenAccountStateContextInput = {\n deviceModelId: DeviceModelId;\n requests: SolanaTokenAccountStateRequest[];\n};\n\nconst tokenAccountStateRequestCodec = Codec.interface({\n tokenAccount: string,\n challenge: string,\n});\n\nconst solanaTokenAccountStateInputCodec = Codec.interface({\n deviceModelId: deviceModelIdCodec,\n requests: array(tokenAccountStateRequestCodec),\n});\n\n@injectable()\nexport class TokenAccountStateContextLoader\n implements ContextLoader<SolanaTokenAccountStateContextInput>\n{\n private readonly logger: LoggerPublisherService;\n\n constructor(\n @inject(tokenAccountStateTypes.TokenAccountStateDataSource)\n private readonly dataSource: TokenAccountStateDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly certificateLoader: PkiCertificateLoader,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n ) {\n this.logger = loggerFactory(\"TokenAccountStateContextLoader\");\n }\n\n public canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is SolanaTokenAccountStateContextInput {\n if (!SUPPORTED_TYPES.every((t) => expectedTypes.includes(t))) return false;\n return solanaTokenAccountStateInputCodec.decode(input).caseOf({\n Left: () => false,\n Right: ({ requests }) =>\n requests.length > 0 &&\n requests.every(\n (r) => r.tokenAccount.length > 0 && r.challenge.length > 0,\n ),\n });\n }\n\n public async load(\n input: SolanaTokenAccountStateContextInput,\n ): Promise<ClearSignContext[]> {\n return loadChallengeBoundContexts({\n requests: input.requests,\n deviceModelId: input.deviceModelId,\n certificateLoader: this.certificateLoader,\n logger: this.logger,\n label: \"TOKEN_ACCOUNT_STATE\",\n fetch: (request) => this.dataSource.getTokenAccountState(request),\n toContext: (value, certificate) => {\n const payload: SolanaTokenAccountStatePayload = {\n descriptor: value.descriptor,\n mint: value.mint,\n };\n return {\n type: ClearSignContextType.SOLANA_TOKEN_ACCOUNT_STATE,\n payload,\n certificate,\n };\n },\n describe: (request) => ({ tokenAccount: request.tokenAccount }),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oCAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAmC,qBACnCC,EAAqC,qBAErCC,EAA4B,mCAC5BC,EAAyB,gDAIzBC,EAAuC,0EAEvCC,EAGO,2CACPC,EAA2C,+CAC3CC,EAAmC,6CAEnC,MAAMC,EAA0C,CAC9C,uBAAqB,0BACvB,EAgBMC,EAAgC,QAAM,UAAU,CACpD,aAAc,SACd,UAAW,QACb,CAAC,EAEKC,EAAoC,QAAM,UAAU,CACxD,cAAe,qBACf,YAAU,SAAMD,CAA6B,CAC/C,CAAC,EAGM,IAAME,EAAN,KAEP,CAGE,YAEmBC,EAEAC,EAEjBC,EACA,CALiB,gBAAAF,EAEA,uBAAAC,EAIjB,KAAK,OAASC,EAAc,gCAAgC,CAC9D,CAXiB,OAaV,UACLC,EACAC,EAC8C,CAC9C,OAAKR,EAAgB,MAAOS,GAAMD,EAAc,SAASC,CAAC,CAAC,EACpDP,EAAkC,OAAOK,CAAK,EAAE,OAAO,CAC5D,KAAM,IAAM,GACZ,MAAO,CAAC,CAAE,SAAAG,CAAS,IACjBA,EAAS,OAAS,GAClBA,EAAS,MACNC,GAAMA,EAAE,aAAa,OAAS,GAAKA,EAAE,UAAU,OAAS,CAC3D,CACJ,CAAC,EARoE,EASvE,CAEA,MAAa,KACXJ,EAC6B,CAC7B,SAAO,8BAA2B,CAChC,SAAUA,EAAM,SAChB,cAAeA,EAAM,cACrB,kBAAmB,KAAK,kBACxB,OAAQ,KAAK,OACb,MAAO,sBACP,MAAQK,GAAY,KAAK,WAAW,qBAAqBA,CAAO,EAChE,UAAW,CAACC,EAAOC,IAAgB,CACjC,MAAMC,EAA0C,CAC9C,WAAYF,EAAM,WAClB,KAAMA,EAAM,IACd,EACA,MAAO,CACL,KAAM,uBAAqB,2BAC3B,QAAAE,EACA,YAAAD,CACF,CACF,EACA,SAAWF,IAAa,CAAE,aAAcA,EAAQ,YAAa,EAC/D,CAAC,CACH,CACF,EAvDaT,EAANa,EAAA,IADN,cAAW,EAOPC,EAAA,eAAO,yBAAuB,2BAA2B,GAEzDA,EAAA,eAAO,WAAS,oBAAoB,GAEpCA,EAAA,eAAO,cAAY,0BAA0B,IAVrCd",
|
|
6
6
|
"names": ["TokenAccountStateContextLoader_exports", "__export", "TokenAccountStateContextLoader", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_pkiTypes", "import_tokenAccountStateTypes", "import_ClearSignContext", "import_challengeBoundLoader", "import_deviceModelIdCodec", "SUPPORTED_TYPES", "tokenAccountStateRequestCodec", "solanaTokenAccountStateInputCodec", "TokenAccountStateContextLoader", "dataSource", "certificateLoader", "loggerFactory", "input", "expectedTypes", "t", "requests", "r", "request", "value", "certificate", "payload", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var y=(a,e)=>{for(var r in e)f(a,r,{get:e[r],enumerable:!0})},C=(a,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of g(e))!h.call(a,o)&&o!==r&&f(a,o,{get:()=>e[o],enumerable:!(n=p(e,o))||n.enumerable});return a};var E=a=>C(f({},"__esModule",{value:!0}),a),m=(a,e,r,n)=>{for(var o=n>1?void 0:n?p(e,r):e,i=a.length-1,l;i>=0;i--)(l=a[i])&&(o=(n?l(e,r,o):l(o))||o);return n&&o&&f(e,r,o),o},d=(a,e)=>(r,n)=>e(r,n,a);var R={};y(R,{HttpTokenInfoDataSource:()=>s});module.exports=E(R);var c=require("inversify"),t=require("purify-ts"),u=require("../../../../config/di/configTypes"),k=require("../../../../shared/network/di/networkTypes");const T=t.Codec.interface({prod:(0,t.optional)(t.string),test:(0,t.optional)(t.string)}),w={"solana-mainnet":"solana","solana-devnet":"solana-devnet"},I=t.Codec.interface({descriptor:t.Codec.interface({data:t.string,signatures:T})});let s=class{constructor(e,r){this.config=e;this.http=r}async getTokenInfo({mint:e,network:r}){let n;try{n=await this.http.get(`${this.config.cal.url}/tokens`,{params:{contract_address:e,network:w[r]??r,output:"contract_address,network,descriptor",ref:`branch:${this.config.cal.branch}`}})}catch(o){const i=o instanceof Error?o.message:String(o);return(0,t.Left)(new Error(`[ContextModule] HttpTokenInfoDataSource: Failed to fetch token info: ${i}`))}return!Array.isArray(n)||n.length===0?(0,t.Left)(new Error(`[ContextModule] HttpTokenInfoDataSource: no token info for mint ${e}`)):I.decode(n[0]).caseOf({Left:o=>(0,t.Left)(new Error(`[ContextModule] HttpTokenInfoDataSource: malformed descriptor for mint ${e}: ${o}`)),Right:o=>(0,t.Right)({mint:e,descriptor:o.descriptor})})}};s=m([(0,c.injectable)(),d(0,(0,c.inject)(u.configTypes.Config)),d(1,(0,c.inject)(k.networkTypes.NetworkClient))],s);0&&(module.exports={HttpTokenInfoDataSource});
|
|
2
2
|
//# sourceMappingURL=HttpTokenInfoDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/token-info/data/HttpTokenInfoDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Codec, Either, Left, optional, Right, string } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\n\nimport {\n type GetTokenInfoParams,\n type TokenInfoDataSource,\n type TokenInfoResult,\n} from \"./TokenInfoDataSource\";\n\nconst calSignaturesCodec = Codec.interface({\n prod: optional(string),\n test: optional(string),\n});\n\nconst tokenInfoResponseEntryCodec = Codec.interface({\n descriptor: Codec.interface({\n data: string,\n signatures: calSignaturesCodec,\n }),\n});\n\n@injectable()\nexport class HttpTokenInfoDataSource implements TokenInfoDataSource {\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getTokenInfo({\n mint,\n network,\n }: GetTokenInfoParams): Promise<Either<Error, TokenInfoResult>> {\n let data: unknown;\n try {\n data = await this.http.get(`${this.config.cal.url}/tokens`, {\n params: {\n contract_address: mint,\n network,\n output: \"contract_address,network,descriptor\",\n ref: `branch:${this.config.cal.branch}`,\n },\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpTokenInfoDataSource: Failed to fetch token info: ${reason}`,\n ),\n );\n }\n\n if (!Array.isArray(data) || data.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpTokenInfoDataSource: no token info for mint ${mint}`,\n ),\n );\n }\n\n return tokenInfoResponseEntryCodec\n .decode(data[0])\n .caseOf<Either<Error, TokenInfoResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpTokenInfoDataSource: malformed descriptor for mint ${mint}: ${error}`,\n ),\n ),\n Right: (entry) =>\n Right({\n mint,\n descriptor: entry.descriptor,\n }),\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnCC,EAA6D,qBAE7DC,EAA4B,mCAE5BC,EAA6B,4CAQ7B,MAAMC,EAAqB,QAAM,UAAU,CACzC,QAAM,YAAS,QAAM,EACrB,QAAM,YAAS,QAAM,CACvB,CAAC,
|
|
6
|
-
"names": ["HttpTokenInfoDataSource_exports", "__export", "HttpTokenInfoDataSource", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_networkTypes", "calSignaturesCodec", "tokenInfoResponseEntryCodec", "HttpTokenInfoDataSource", "config", "http", "mint", "network", "data", "error", "reason", "entry", "__decorateClass", "__decorateParam"]
|
|
4
|
+
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Codec, Either, Left, optional, Right, string } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\n\nimport {\n type GetTokenInfoParams,\n type TokenInfoDataSource,\n type TokenInfoResult,\n} from \"./TokenInfoDataSource\";\n\nconst calSignaturesCodec = Codec.interface({\n prod: optional(string),\n test: optional(string),\n});\n\n// The CAL /tokens endpoint uses short chain slugs (e.g. \"solana\") while the\n// SDK identifies networks with qualified names (e.g. \"solana-mainnet\").\nconst NETWORK_SLUG: Readonly<Record<string, string>> = {\n \"solana-mainnet\": \"solana\",\n \"solana-devnet\": \"solana-devnet\",\n};\n\nconst tokenInfoResponseEntryCodec = Codec.interface({\n descriptor: Codec.interface({\n data: string,\n signatures: calSignaturesCodec,\n }),\n});\n\n@injectable()\nexport class HttpTokenInfoDataSource implements TokenInfoDataSource {\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getTokenInfo({\n mint,\n network,\n }: GetTokenInfoParams): Promise<Either<Error, TokenInfoResult>> {\n let data: unknown;\n try {\n data = await this.http.get(`${this.config.cal.url}/tokens`, {\n params: {\n contract_address: mint,\n network: NETWORK_SLUG[network] ?? network,\n output: \"contract_address,network,descriptor\",\n ref: `branch:${this.config.cal.branch}`,\n },\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpTokenInfoDataSource: Failed to fetch token info: ${reason}`,\n ),\n );\n }\n\n if (!Array.isArray(data) || data.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpTokenInfoDataSource: no token info for mint ${mint}`,\n ),\n );\n }\n\n return tokenInfoResponseEntryCodec\n .decode(data[0])\n .caseOf<Either<Error, TokenInfoResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpTokenInfoDataSource: malformed descriptor for mint ${mint}: ${error}`,\n ),\n ),\n Right: (entry) =>\n Right({\n mint,\n descriptor: entry.descriptor,\n }),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnCC,EAA6D,qBAE7DC,EAA4B,mCAE5BC,EAA6B,4CAQ7B,MAAMC,EAAqB,QAAM,UAAU,CACzC,QAAM,YAAS,QAAM,EACrB,QAAM,YAAS,QAAM,CACvB,CAAC,EAIKC,EAAiD,CACrD,iBAAkB,SAClB,gBAAiB,eACnB,EAEMC,EAA8B,QAAM,UAAU,CAClD,WAAY,QAAM,UAAU,CAC1B,KAAM,SACN,WAAYF,CACd,CAAC,CACH,CAAC,EAGM,IAAMG,EAAN,KAA6D,CAClE,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAa,aAAa,CACxB,KAAAC,EACA,QAAAC,CACF,EAAgE,CAC9D,IAAIC,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,UAAW,CAC1D,OAAQ,CACN,iBAAkBF,EAClB,QAASL,EAAaM,CAAO,GAAKA,EAClC,OAAQ,sCACR,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,CACF,CAAC,CACH,OAASE,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,SAAO,QACL,IAAI,MACF,wEAAwEC,CAAM,EAChF,CACF,CACF,CAEA,MAAI,CAAC,MAAM,QAAQF,CAAI,GAAKA,EAAK,SAAW,KACnC,QACL,IAAI,MACF,mEAAmEF,CAAI,EACzE,CACF,EAGKJ,EACJ,OAAOM,EAAK,CAAC,CAAC,EACd,OAAuC,CACtC,KAAOC,MACL,QACE,IAAI,MACF,0EAA0EH,CAAI,KAAKG,CAAK,EAC1F,CACF,EACF,MAAQE,MACN,SAAM,CACJ,KAAAL,EACA,WAAYK,EAAM,UACpB,CAAC,CACL,CAAC,CACL,CACF,EAvDaR,EAANS,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,eAAa,aAAa,IAJzBV",
|
|
6
|
+
"names": ["HttpTokenInfoDataSource_exports", "__export", "HttpTokenInfoDataSource", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_networkTypes", "calSignaturesCodec", "NETWORK_SLUG", "tokenInfoResponseEntryCodec", "HttpTokenInfoDataSource", "config", "http", "mint", "network", "data", "error", "reason", "entry", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var s=require("purify-ts"),t=require("vitest"),c=require("./HttpTokenInfoDataSource");(0,t.describe)("HttpTokenInfoDataSource",()=>{let
|
|
1
|
+
"use strict";var s=require("purify-ts"),t=require("vitest"),c=require("./HttpTokenInfoDataSource");(0,t.describe)("HttpTokenInfoDataSource",()=>{let r,o;const e="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",a="solana-mainnet",i={cal:{url:"https://global.api.prd.ledger.com/cal/v1",mode:"prod",branch:"main"}};(0,t.beforeEach)(()=>{t.vi.clearAllMocks(),o={get:t.vi.fn()},r=new c.HttpTokenInfoDataSource(i,o)}),(0,t.it)("calls /tokens with contract_address, network and ref params",async()=>{o.get.mockResolvedValue([{contract_address:e,network:"solana-mainnet",descriptor:{data:"01020304",signatures:{prod:"p",test:"t"}}}]),await r.getTokenInfo({mint:e,network:a}),(0,t.expect)(o.get).toHaveBeenCalledWith("https://global.api.prd.ledger.com/cal/v1/tokens",{params:{contract_address:e,network:"solana",output:"contract_address,network,descriptor",ref:"branch:main"}})}),(0,t.it)("returns Right on success",async()=>{o.get.mockResolvedValue([{contract_address:e,descriptor:{data:"01020304",signatures:{prod:"psig",test:"tsig"}}}]);const n=await r.getTokenInfo({mint:e,network:a});(0,t.expect)(n).toEqual((0,s.Right)({mint:e,descriptor:{data:"01020304",signatures:{prod:"psig",test:"tsig"}}}))}),(0,t.it)("returns Left when response is empty",async()=>{o.get.mockResolvedValue([]);const n=await r.getTokenInfo({mint:e,network:a});(0,t.expect)(n).toEqual((0,s.Left)(new Error(`[ContextModule] HttpTokenInfoDataSource: no token info for mint ${e}`)))}),(0,t.it)("returns Left when descriptor is malformed",async()=>{o.get.mockResolvedValue([{contract_address:e}]);const n=await r.getTokenInfo({mint:e,network:a});(0,t.expect)(n.isLeft()).toBe(!0),(0,t.expect)(n.extract().message).toMatch(new RegExp(String.raw`\[ContextModule\] HttpTokenInfoDataSource: malformed descriptor for mint ${e}:`))}),(0,t.it)("returns Left when HTTP client throws",async()=>{o.get.mockRejectedValue(new Error("net"));const n=await r.getTokenInfo({mint:e,network:a});(0,t.expect)(n).toEqual((0,s.Left)(new Error("[ContextModule] HttpTokenInfoDataSource: Failed to fetch token info: net")))})});
|
|
2
2
|
//# sourceMappingURL=HttpTokenInfoDataSource.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/token-info/data/HttpTokenInfoDataSource.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { HttpTokenInfoDataSource } from \"./HttpTokenInfoDataSource\";\nimport { type TokenInfoDataSource } from \"./TokenInfoDataSource\";\n\ndescribe(\"HttpTokenInfoDataSource\", () => {\n let datasource: TokenInfoDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n const mint = \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\";\n const network = \"solana-mainnet\";\n const config: ContextModuleServiceConfig = {\n cal: {\n url: \"https://global.api.prd.ledger.com/cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleServiceConfig;\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpTokenInfoDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n it(\"calls /tokens with contract_address, network and ref params\", async () => {\n httpMock.get.mockResolvedValue([\n {\n contract_address: mint,\n network: \"solana-mainnet\",\n descriptor: { data: \"01020304\", signatures: { prod: \"p\", test: \"t\" } },\n },\n ]);\n\n await datasource.getTokenInfo({ mint, network });\n\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/tokens\",\n {\n params: {\n contract_address: mint,\n network
|
|
5
|
-
"mappings": "aAEA,IAAAA,EAA4B,qBAC5BC,EAAqD,kBAIrDC,EAAwC,wCAGxC,YAAS,0BAA2B,IAAM,CACxC,IAAIC,EACAC,EACJ,MAAMC,EAAO,+CACPC,EAAU,iBACVC,EAAqC,CACzC,IAAK,CACH,IAAK,2CACL,KAAM,OACN,OAAQ,MACV,CACF,KAEA,cAAW,IAAM,CACf,KAAG,cAAc,EACjBH,EAAW,CAAE,IAAK,KAAG,GAAG,CAAE,EAC1BD,EAAa,IAAI,0BACfI,EACAH,CACF,CACF,CAAC,KAED,MAAG,8DAA+D,SAAY,CAC5EA,EAAS,IAAI,kBAAkB,CAC7B,CACE,iBAAkBC,EAClB,QAAS,iBACT,WAAY,CAAE,KAAM,WAAY,WAAY,CAAE,KAAM,IAAK,KAAM,GAAI,CAAE,CACvE,CACF,CAAC,EAED,MAAMF,EAAW,aAAa,CAAE,KAAAE,EAAM,QAAAC,CAAQ,CAAC,KAE/C,UAAOF,EAAS,GAAG,EAAE,qBACnB,kDACA,CACE,OAAQ,CACN,iBAAkBC,EAClB,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { HttpTokenInfoDataSource } from \"./HttpTokenInfoDataSource\";\nimport { type TokenInfoDataSource } from \"./TokenInfoDataSource\";\n\ndescribe(\"HttpTokenInfoDataSource\", () => {\n let datasource: TokenInfoDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n const mint = \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\";\n const network = \"solana-mainnet\";\n const config: ContextModuleServiceConfig = {\n cal: {\n url: \"https://global.api.prd.ledger.com/cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleServiceConfig;\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpTokenInfoDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n it(\"calls /tokens with contract_address, network and ref params\", async () => {\n httpMock.get.mockResolvedValue([\n {\n contract_address: mint,\n network: \"solana-mainnet\",\n descriptor: { data: \"01020304\", signatures: { prod: \"p\", test: \"t\" } },\n },\n ]);\n\n await datasource.getTokenInfo({ mint, network });\n\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/tokens\",\n {\n params: {\n contract_address: mint,\n network: \"solana\", // \"solana-mainnet\" mapped to the CAL short slug\n output: \"contract_address,network,descriptor\",\n ref: \"branch:main\",\n },\n },\n );\n });\n\n it(\"returns Right on success\", async () => {\n httpMock.get.mockResolvedValue([\n {\n contract_address: mint,\n descriptor: {\n data: \"01020304\",\n signatures: { prod: \"psig\", test: \"tsig\" },\n },\n },\n ]);\n\n const result = await datasource.getTokenInfo({ mint, network });\n\n expect(result).toEqual(\n Right({\n mint,\n descriptor: {\n data: \"01020304\",\n signatures: { prod: \"psig\", test: \"tsig\" },\n },\n }),\n );\n });\n\n it(\"returns Left when response is empty\", async () => {\n httpMock.get.mockResolvedValue([]);\n\n const result = await datasource.getTokenInfo({ mint, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpTokenInfoDataSource: no token info for mint ${mint}`,\n ),\n ),\n );\n });\n\n it(\"returns Left when descriptor is malformed\", async () => {\n httpMock.get.mockResolvedValue([{ contract_address: mint } as any]);\n\n const result = await datasource.getTokenInfo({ mint, network });\n\n expect(result.isLeft()).toBe(true);\n expect((result.extract() as Error).message).toMatch(\n new RegExp(\n String.raw`\\[ContextModule\\] HttpTokenInfoDataSource: malformed descriptor for mint ${mint}:`,\n ),\n );\n });\n\n it(\"returns Left when HTTP client throws\", async () => {\n httpMock.get.mockRejectedValue(new Error(\"net\"));\n\n const result = await datasource.getTokenInfo({ mint, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenInfoDataSource: Failed to fetch token info: net\",\n ),\n ),\n );\n });\n});\n"],
|
|
5
|
+
"mappings": "aAEA,IAAAA,EAA4B,qBAC5BC,EAAqD,kBAIrDC,EAAwC,wCAGxC,YAAS,0BAA2B,IAAM,CACxC,IAAIC,EACAC,EACJ,MAAMC,EAAO,+CACPC,EAAU,iBACVC,EAAqC,CACzC,IAAK,CACH,IAAK,2CACL,KAAM,OACN,OAAQ,MACV,CACF,KAEA,cAAW,IAAM,CACf,KAAG,cAAc,EACjBH,EAAW,CAAE,IAAK,KAAG,GAAG,CAAE,EAC1BD,EAAa,IAAI,0BACfI,EACAH,CACF,CACF,CAAC,KAED,MAAG,8DAA+D,SAAY,CAC5EA,EAAS,IAAI,kBAAkB,CAC7B,CACE,iBAAkBC,EAClB,QAAS,iBACT,WAAY,CAAE,KAAM,WAAY,WAAY,CAAE,KAAM,IAAK,KAAM,GAAI,CAAE,CACvE,CACF,CAAC,EAED,MAAMF,EAAW,aAAa,CAAE,KAAAE,EAAM,QAAAC,CAAQ,CAAC,KAE/C,UAAOF,EAAS,GAAG,EAAE,qBACnB,kDACA,CACE,OAAQ,CACN,iBAAkBC,EAClB,QAAS,SACT,OAAQ,sCACR,IAAK,aACP,CACF,CACF,CACF,CAAC,KAED,MAAG,2BAA4B,SAAY,CACzCD,EAAS,IAAI,kBAAkB,CAC7B,CACE,iBAAkBC,EAClB,WAAY,CACV,KAAM,WACN,WAAY,CAAE,KAAM,OAAQ,KAAM,MAAO,CAC3C,CACF,CACF,CAAC,EAED,MAAMG,EAAS,MAAML,EAAW,aAAa,CAAE,KAAAE,EAAM,QAAAC,CAAQ,CAAC,KAE9D,UAAOE,CAAM,EAAE,WACb,SAAM,CACJ,KAAAH,EACA,WAAY,CACV,KAAM,WACN,WAAY,CAAE,KAAM,OAAQ,KAAM,MAAO,CAC3C,CACF,CAAC,CACH,CACF,CAAC,KAED,MAAG,sCAAuC,SAAY,CACpDD,EAAS,IAAI,kBAAkB,CAAC,CAAC,EAEjC,MAAMI,EAAS,MAAML,EAAW,aAAa,CAAE,KAAAE,EAAM,QAAAC,CAAQ,CAAC,KAE9D,UAAOE,CAAM,EAAE,WACb,QACE,IAAI,MACF,mEAAmEH,CAAI,EACzE,CACF,CACF,CACF,CAAC,KAED,MAAG,4CAA6C,SAAY,CAC1DD,EAAS,IAAI,kBAAkB,CAAC,CAAE,iBAAkBC,CAAK,CAAQ,CAAC,EAElE,MAAMG,EAAS,MAAML,EAAW,aAAa,CAAE,KAAAE,EAAM,QAAAC,CAAQ,CAAC,KAE9D,UAAOE,EAAO,OAAO,CAAC,EAAE,KAAK,EAAI,KACjC,UAAQA,EAAO,QAAQ,EAAY,OAAO,EAAE,QAC1C,IAAI,OACF,OAAO,+EAA+EH,CAAI,GAC5F,CACF,CACF,CAAC,KAED,MAAG,uCAAwC,SAAY,CACrDD,EAAS,IAAI,kBAAkB,IAAI,MAAM,KAAK,CAAC,EAE/C,MAAMI,EAAS,MAAML,EAAW,aAAa,CAAE,KAAAE,EAAM,QAAAC,CAAQ,CAAC,KAE9D,UAAOE,CAAM,EAAE,WACb,QACE,IAAI,MACF,0EACF,CACF,CACF,CACF,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_purify_ts", "import_vitest", "import_HttpTokenInfoDataSource", "datasource", "httpMock", "mint", "network", "config", "result"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
59
59
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
60
60
|
},
|
|
61
|
-
"version": "0.0.0-develop-
|
|
61
|
+
"version": "0.0.0-develop-20260807010949"
|
|
62
62
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var f=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var c=(n,o,e,i)=>{for(var r=i>1?void 0:i?g(o,e):o,s=n.length-1,t;s>=0;s--)(t=n[s])&&(r=(i?t(o,e,r):t(r))||r);return i&&r&&f(o,e,r),r},p=(n,o)=>(e,i)=>o(e,i,n);import{inject as m,injectable as R}from"inversify";import{Left as a,Right as y}from"purify-ts";import{configTypes as A}from"../../../../config/di/configTypes";import{networkTypes as D}from"../../../../shared/network/di/networkTypes";import{HexStringUtils as h}from"../../../../shared/utils/HexStringUtils";import{signedDescriptorDtoCodec as C}from"../../../../shared/utils/signedDescriptorDto";import{u8Codec as k}from"../../../../shared/utils/uIntCodec";let u=class{constructor(o,e){this.config=o;this.http=e}async getAltResolution({altAddress:o,entryIndex:e,challenge:i}){const r=k.decode(e);if(r.isLeft())return a(new Error(`[ContextModule] HttpAltResolutionDataSource: invalid entryIndex (got ${e}): ${r.leftOrDefault("")}`));let s;try{s=await this.http.get(`${this.config.metadataServiceDomain.url}/v2/solana/alt-resolution/${o}/${e}`,{params:{challenge:i}})}catch(t){const l=t instanceof Error?t.message:String(t);return a(new Error(`[ContextModule] HttpAltResolutionDataSource: Failed to fetch ALT resolution: ${l}`))}return C.decode(s).caseOf({Left:t=>a(new Error(`[ContextModule] HttpAltResolutionDataSource: malformed response for (${o}, ${e}): ${t}`)),Right:t=>{let l;try{l=h.hexToBytes(t.signedDescriptor)}catch(d){return a(new Error(`[ContextModule] HttpAltResolutionDataSource: invalid hex in signedDescriptor for (${o}, ${e}): ${d.message}`))}return y({altAddress:o,entryIndex:e,descriptor:l,resolvedAddress:s.resolvedAddress,keyId:t.keyId,keyUsage:t.keyUsage})}})}};u=c([R(),p(0,m(A.Config)),p(1,m(D.NetworkClient))],u);export{u as HttpAltResolutionDataSource};
|
|
2
2
|
//# sourceMappingURL=HttpAltResolutionDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport { signedDescriptorDtoCodec } from \"@/shared/utils/signedDescriptorDto\";\nimport { u8Codec } from \"@/shared/utils/uIntCodec\";\n\nimport {\n type AltResolutionDataSource,\n type AltResolutionResult,\n type GetAltResolutionParams,\n} from \"./AltResolutionDataSource\";\n\ntype AltResolutionResponseDto = {\n descriptorType?: string;\n descriptorVersion?: number;\n altAddress?: string;\n entryIndex?: number;\n resolvedAddress?: string;\n signedDescriptor: string;\n keyId: string;\n keyUsage: string;\n};\n\n@injectable()\nexport class HttpAltResolutionDataSource implements AltResolutionDataSource {\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getAltResolution({\n altAddress,\n entryIndex,\n challenge,\n }: GetAltResolutionParams): Promise<Either<Error, AltResolutionResult>> {\n const entryIndexResult = u8Codec.decode(entryIndex);\n if (entryIndexResult.isLeft()) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid entryIndex (got ${entryIndex}): ${entryIndexResult.leftOrDefault(\"\")}`,\n ),\n );\n }\n\n let dto: AltResolutionResponseDto;\n try {\n dto = (await this.http.get(\n `${this.config.metadataServiceDomain.url}/v2/solana/alt-resolution/${altAddress}/${entryIndex}`,\n { params: { challenge } },\n )) as AltResolutionResponseDto;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: Failed to fetch ALT resolution: ${reason}`,\n ),\n );\n }\n\n return signedDescriptorDtoCodec\n .decode(dto)\n .caseOf<Either<Error, AltResolutionResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: malformed response for (${altAddress}, ${entryIndex}): ${error}`,\n ),\n ),\n Right: (validated) => {\n let descriptor: Uint8Array;\n try {\n descriptor = HexStringUtils.hexToBytes(validated.signedDescriptor);\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid hex in signedDescriptor for (${altAddress}, ${entryIndex}): ${(error as Error).message}`,\n ),\n );\n }\n\n return Right({\n altAddress,\n entryIndex,\n descriptor,\n keyId: validated.keyId,\n keyUsage: validated.keyUsage,\n });\n },\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,gBAAAC,MAAoB,mCAC7B,OAAS,kBAAAC,MAAsB,gCAC/B,OAAS,4BAAAC,MAAgC,qCACzC,OAAS,WAAAC,MAAe,2BAoBjB,IAAMC,EAAN,KAAqE,CAC1E,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAa,iBAAiB,CAC5B,WAAAC,EACA,WAAAC,EACA,UAAAC,CACF,EAAwE,CACtE,MAAMC,EAAmBC,EAAQ,OAAOH,CAAU,EAClD,GAAIE,EAAiB,OAAO,EAC1B,OAAOE,EACL,IAAI,MACF,wEAAwEJ,CAAU,MAAME,EAAiB,cAAc,EAAE,CAAC,EAC5H,CACF,EAGF,IAAIG,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IACrB,GAAG,KAAK,OAAO,sBAAsB,GAAG,6BAA6BN,CAAU,IAAIC,CAAU,GAC7F,CAAE,OAAQ,CAAE,UAAAC,CAAU,CAAE,CAC1B,CACF,OAASK,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,OAAOF,EACL,IAAI,MACF,gFAAgFG,CAAM,EACxF,CACF,CACF,CAEA,OAAOC,EACJ,OAAOH,CAAG,EACV,OAA2C,CAC1C,KAAOC,GACLF,EACE,IAAI,MACF,wEAAwEL,CAAU,KAAKC,CAAU,MAAMM,CAAK,EAC9G,CACF,EACF,MAAQG,GAAc,CACpB,IAAIC,EACJ,GAAI,CACFA,EAAaC,EAAe,WAAWF,EAAU,gBAAgB,CACnE,OAASH,EAAO,CACd,OAAOF,EACL,IAAI,MACF,qFAAqFL,CAAU,KAAKC,CAAU,MAAOM,EAAgB,OAAO,EAC9I,CACF,CACF,CAEA,OAAOM,EAAM,CACX,WAAAb,EACA,WAAAC,EACA,WAAAU,EACA,
|
|
4
|
+
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport { signedDescriptorDtoCodec } from \"@/shared/utils/signedDescriptorDto\";\nimport { u8Codec } from \"@/shared/utils/uIntCodec\";\n\nimport {\n type AltResolutionDataSource,\n type AltResolutionResult,\n type GetAltResolutionParams,\n} from \"./AltResolutionDataSource\";\n\ntype AltResolutionResponseDto = {\n descriptorType?: string;\n descriptorVersion?: number;\n altAddress?: string;\n entryIndex?: number;\n resolvedAddress?: string;\n signedDescriptor: string;\n keyId: string;\n keyUsage: string;\n};\n\n@injectable()\nexport class HttpAltResolutionDataSource implements AltResolutionDataSource {\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getAltResolution({\n altAddress,\n entryIndex,\n challenge,\n }: GetAltResolutionParams): Promise<Either<Error, AltResolutionResult>> {\n const entryIndexResult = u8Codec.decode(entryIndex);\n if (entryIndexResult.isLeft()) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid entryIndex (got ${entryIndex}): ${entryIndexResult.leftOrDefault(\"\")}`,\n ),\n );\n }\n\n let dto: AltResolutionResponseDto;\n try {\n dto = (await this.http.get(\n `${this.config.metadataServiceDomain.url}/v2/solana/alt-resolution/${altAddress}/${entryIndex}`,\n { params: { challenge } },\n )) as AltResolutionResponseDto;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: Failed to fetch ALT resolution: ${reason}`,\n ),\n );\n }\n\n return signedDescriptorDtoCodec\n .decode(dto)\n .caseOf<Either<Error, AltResolutionResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: malformed response for (${altAddress}, ${entryIndex}): ${error}`,\n ),\n ),\n Right: (validated) => {\n let descriptor: Uint8Array;\n try {\n descriptor = HexStringUtils.hexToBytes(validated.signedDescriptor);\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid hex in signedDescriptor for (${altAddress}, ${entryIndex}): ${(error as Error).message}`,\n ),\n );\n }\n\n return Right({\n altAddress,\n entryIndex,\n descriptor,\n resolvedAddress: dto.resolvedAddress,\n keyId: validated.keyId,\n keyUsage: validated.keyUsage,\n });\n },\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,gBAAAC,MAAoB,mCAC7B,OAAS,kBAAAC,MAAsB,gCAC/B,OAAS,4BAAAC,MAAgC,qCACzC,OAAS,WAAAC,MAAe,2BAoBjB,IAAMC,EAAN,KAAqE,CAC1E,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAa,iBAAiB,CAC5B,WAAAC,EACA,WAAAC,EACA,UAAAC,CACF,EAAwE,CACtE,MAAMC,EAAmBC,EAAQ,OAAOH,CAAU,EAClD,GAAIE,EAAiB,OAAO,EAC1B,OAAOE,EACL,IAAI,MACF,wEAAwEJ,CAAU,MAAME,EAAiB,cAAc,EAAE,CAAC,EAC5H,CACF,EAGF,IAAIG,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IACrB,GAAG,KAAK,OAAO,sBAAsB,GAAG,6BAA6BN,CAAU,IAAIC,CAAU,GAC7F,CAAE,OAAQ,CAAE,UAAAC,CAAU,CAAE,CAC1B,CACF,OAASK,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,OAAOF,EACL,IAAI,MACF,gFAAgFG,CAAM,EACxF,CACF,CACF,CAEA,OAAOC,EACJ,OAAOH,CAAG,EACV,OAA2C,CAC1C,KAAOC,GACLF,EACE,IAAI,MACF,wEAAwEL,CAAU,KAAKC,CAAU,MAAMM,CAAK,EAC9G,CACF,EACF,MAAQG,GAAc,CACpB,IAAIC,EACJ,GAAI,CACFA,EAAaC,EAAe,WAAWF,EAAU,gBAAgB,CACnE,OAASH,EAAO,CACd,OAAOF,EACL,IAAI,MACF,qFAAqFL,CAAU,KAAKC,CAAU,MAAOM,EAAgB,OAAO,EAC9I,CACF,CACF,CAEA,OAAOM,EAAM,CACX,WAAAb,EACA,WAAAC,EACA,WAAAU,EACA,gBAAiBL,EAAI,gBACrB,MAAOI,EAAU,MACjB,SAAUA,EAAU,QACtB,CAAC,CACH,CACF,CAAC,CACL,CACF,EArEab,EAANiB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GAEzBF,EAAA,EAAAC,EAAOE,EAAa,aAAa,IAJzBtB",
|
|
6
6
|
"names": ["inject", "injectable", "Left", "Right", "configTypes", "networkTypes", "HexStringUtils", "signedDescriptorDtoCodec", "u8Codec", "HttpAltResolutionDataSource", "config", "http", "altAddress", "entryIndex", "challenge", "entryIndexResult", "u8Codec", "Left", "dto", "error", "reason", "signedDescriptorDtoCodec", "validated", "descriptor", "HexStringUtils", "Right", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "networkTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var m=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var c=(l,o,e,t)=>{for(var r=t>1?void 0:t?y(o,e):o,a=l.length-1,s;a>=0;a--)(s=l[a])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&m(o,e,r),r},n=(l,o)=>(e,t)=>o(e,t,l);import{inject as d,injectable as f}from"inversify";import{array as S,Codec as u,string as p}from"purify-ts";import{configTypes as C}from"../../../../config/di/configTypes";import{pkiTypes as A}from"../../../../modules/multichain/pki/di/pkiTypes";import{altResolutionTypes as R}from"../../../../modules/solana/alt-resolution/di/altResolutionTypes";import{ClearSignContextType as g}from"../../../../shared/model/ClearSignContext";import{loadChallengeBoundContexts as x}from"../../../../shared/utils/challengeBoundLoader";import{deviceModelIdCodec as I}from"../../../../shared/utils/deviceModelIdCodec";import{u8Codec as L}from"../../../../shared/utils/uIntCodec";const h=[g.SOLANA_ALT_RESOLUTION],v=u.interface({altAddress:p,entryIndex:L,challenge:p}),T=u.interface({deviceModelId:I,requests:S(v)});let i=class{constructor(o,e,t){this.dataSource=o;this.certificateLoader=e;this.logger=t("AltResolutionContextLoader")}logger;canHandle(o,e){return h.every(t=>e.includes(t))?T.decode(o).caseOf({Left:()=>!1,Right:({requests:t})=>t.length>0&&t.every(r=>r.altAddress.length>0&&r.challenge.length>0)}):!1}async load(o){return x({requests:o.requests,deviceModelId:o.deviceModelId,certificateLoader:this.certificateLoader,logger:this.logger,label:"ALT_RESOLUTION",fetch:e=>this.dataSource.getAltResolution(e),toContext:(e,t)=>{const r={descriptor:e.descriptor};return{type:g.SOLANA_ALT_RESOLUTION,payload:r,certificate:t}},describe:e=>({altAddress:e.altAddress,entryIndex:e.entryIndex})})}};i=c([f(),n(0,d(R.AltResolutionDataSource)),n(1,d(A.PkiCertificateLoader)),n(2,d(C.ContextModuleLoggerFactory))],i);export{i as AltResolutionContextLoader};
|
|
1
|
+
var m=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var c=(l,o,e,t)=>{for(var r=t>1?void 0:t?y(o,e):o,a=l.length-1,s;a>=0;a--)(s=l[a])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&m(o,e,r),r},n=(l,o)=>(e,t)=>o(e,t,l);import{inject as d,injectable as f}from"inversify";import{array as S,Codec as u,string as p}from"purify-ts";import{configTypes as C}from"../../../../config/di/configTypes";import{pkiTypes as A}from"../../../../modules/multichain/pki/di/pkiTypes";import{altResolutionTypes as R}from"../../../../modules/solana/alt-resolution/di/altResolutionTypes";import{ClearSignContextType as g}from"../../../../shared/model/ClearSignContext";import{loadChallengeBoundContexts as x}from"../../../../shared/utils/challengeBoundLoader";import{deviceModelIdCodec as I}from"../../../../shared/utils/deviceModelIdCodec";import{u8Codec as L}from"../../../../shared/utils/uIntCodec";const h=[g.SOLANA_ALT_RESOLUTION],v=u.interface({altAddress:p,entryIndex:L,challenge:p}),T=u.interface({deviceModelId:I,requests:S(v)});let i=class{constructor(o,e,t){this.dataSource=o;this.certificateLoader=e;this.logger=t("AltResolutionContextLoader")}logger;canHandle(o,e){return h.every(t=>e.includes(t))?T.decode(o).caseOf({Left:()=>!1,Right:({requests:t})=>t.length>0&&t.every(r=>r.altAddress.length>0&&r.challenge.length>0)}):!1}async load(o){return x({requests:o.requests,deviceModelId:o.deviceModelId,certificateLoader:this.certificateLoader,logger:this.logger,label:"ALT_RESOLUTION",fetch:e=>this.dataSource.getAltResolution(e),toContext:(e,t)=>{const r={descriptor:e.descriptor,resolvedAddress:e.resolvedAddress};return{type:g.SOLANA_ALT_RESOLUTION,payload:r,certificate:t}},describe:e=>({altAddress:e.altAddress,entryIndex:e.entryIndex})})}};i=c([f(),n(0,d(R.AltResolutionDataSource)),n(1,d(A.PkiCertificateLoader)),n(2,d(C.ContextModuleLoggerFactory))],i);export{i as AltResolutionContextLoader};
|
|
2
2
|
//# sourceMappingURL=AltResolutionContextLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/alt-resolution/domain/AltResolutionContextLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type DeviceModelId,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { array, Codec, string } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { pkiTypes } from \"@/modules/multichain/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/modules/multichain/pki/domain/PkiCertificateLoader\";\nimport { type AltResolutionDataSource } from \"@/modules/solana/alt-resolution/data/AltResolutionDataSource\";\nimport { altResolutionTypes } from \"@/modules/solana/alt-resolution/di/altResolutionTypes\";\nimport { type SolanaAltResolutionPayload } from \"@/modules/solana/model/SolanaPayloads\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { loadChallengeBoundContexts } from \"@/shared/utils/challengeBoundLoader\";\nimport { deviceModelIdCodec } from \"@/shared/utils/deviceModelIdCodec\";\nimport { u8Codec } from \"@/shared/utils/uIntCodec\";\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.SOLANA_ALT_RESOLUTION,\n];\n\nexport type SolanaAltResolutionRequest = {\n altAddress: string;\n entryIndex: number;\n challenge: string;\n};\n\nexport type SolanaAltResolutionContextInput = {\n deviceModelId: DeviceModelId;\n requests: SolanaAltResolutionRequest[];\n};\n\nconst altResolutionRequestCodec = Codec.interface({\n altAddress: string,\n entryIndex: u8Codec,\n challenge: string,\n});\n\nconst solanaAltResolutionInputCodec = Codec.interface({\n deviceModelId: deviceModelIdCodec,\n requests: array(altResolutionRequestCodec),\n});\n\n@injectable()\nexport class AltResolutionContextLoader\n implements ContextLoader<SolanaAltResolutionContextInput>\n{\n private readonly logger: LoggerPublisherService;\n\n constructor(\n @inject(altResolutionTypes.AltResolutionDataSource)\n private readonly dataSource: AltResolutionDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly certificateLoader: PkiCertificateLoader,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n ) {\n this.logger = loggerFactory(\"AltResolutionContextLoader\");\n }\n\n public canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is SolanaAltResolutionContextInput {\n if (!SUPPORTED_TYPES.every((t) => expectedTypes.includes(t))) return false;\n return solanaAltResolutionInputCodec.decode(input).caseOf({\n Left: () => false,\n Right: ({ requests }) =>\n requests.length > 0 &&\n requests.every(\n (r) => r.altAddress.length > 0 && r.challenge.length > 0,\n ),\n });\n }\n\n public async load(\n input: SolanaAltResolutionContextInput,\n ): Promise<ClearSignContext[]> {\n return loadChallengeBoundContexts({\n requests: input.requests,\n deviceModelId: input.deviceModelId,\n certificateLoader: this.certificateLoader,\n logger: this.logger,\n label: \"ALT_RESOLUTION\",\n fetch: (request) => this.dataSource.getAltResolution(request),\n toContext: (value, certificate) => {\n const payload: SolanaAltResolutionPayload = {\n descriptor: value.descriptor,\n };\n return {\n type: ClearSignContextType.SOLANA_ALT_RESOLUTION,\n payload,\n certificate,\n };\n },\n describe: (request) => ({\n altAddress: request.altAddress,\n entryIndex: request.entryIndex,\n }),\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "iOAIA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAS,SAAAC,EAAO,SAAAC,EAAO,UAAAC,MAAc,YAErC,OAAS,eAAAC,MAAmB,0BAC5B,OAAS,YAAAC,MAAgB,uCAGzB,OAAS,sBAAAC,MAA0B,wDAGnC,OAEE,wBAAAC,MACK,kCACP,OAAS,8BAAAC,MAAkC,sCAC3C,OAAS,sBAAAC,MAA0B,oCACnC,OAAS,WAAAC,MAAe,2BAExB,MAAMC,EAA0C,CAC9CC,EAAqB,qBACvB,EAaMC,EAA4BC,EAAM,UAAU,CAChD,WAAYC,EACZ,WAAYC,EACZ,UAAWD,CACb,CAAC,EAEKE,EAAgCH,EAAM,UAAU,CACpD,cAAeI,EACf,SAAUC,EAAMN,CAAyB,CAC3C,CAAC,EAGM,IAAMO,EAAN,KAEP,CAGE,YAEmBC,EAEAC,EAEjBC,EACA,CALiB,gBAAAF,EAEA,uBAAAC,EAIjB,KAAK,OAASC,EAAc,4BAA4B,CAC1D,CAXiB,OAaV,UACLC,EACAC,EAC0C,CAC1C,OAAKd,EAAgB,MAAO,GAAMc,EAAc,SAAS,CAAC,CAAC,EACpDR,EAA8B,OAAOO,CAAK,EAAE,OAAO,CACxD,KAAM,IAAM,GACZ,MAAO,CAAC,CAAE,SAAAE,CAAS,IACjBA,EAAS,OAAS,GAClBA,EAAS,MACN,GAAM,EAAE,WAAW,OAAS,GAAK,EAAE,UAAU,OAAS,CACzD,CACJ,CAAC,EARoE,EASvE,CAEA,MAAa,KACXF,EAC6B,CAC7B,OAAOG,EAA2B,CAChC,SAAUH,EAAM,SAChB,cAAeA,EAAM,cACrB,kBAAmB,KAAK,kBACxB,OAAQ,KAAK,OACb,MAAO,iBACP,MAAQI,GAAY,KAAK,WAAW,iBAAiBA,CAAO,EAC5D,UAAW,CAACC,EAAOC,IAAgB,CACjC,MAAMC,EAAsC,CAC1C,WAAYF,EAAM,
|
|
4
|
+
"sourcesContent": ["import {\n type DeviceModelId,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { array, Codec, string } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { pkiTypes } from \"@/modules/multichain/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/modules/multichain/pki/domain/PkiCertificateLoader\";\nimport { type AltResolutionDataSource } from \"@/modules/solana/alt-resolution/data/AltResolutionDataSource\";\nimport { altResolutionTypes } from \"@/modules/solana/alt-resolution/di/altResolutionTypes\";\nimport { type SolanaAltResolutionPayload } from \"@/modules/solana/model/SolanaPayloads\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { loadChallengeBoundContexts } from \"@/shared/utils/challengeBoundLoader\";\nimport { deviceModelIdCodec } from \"@/shared/utils/deviceModelIdCodec\";\nimport { u8Codec } from \"@/shared/utils/uIntCodec\";\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.SOLANA_ALT_RESOLUTION,\n];\n\nexport type SolanaAltResolutionRequest = {\n altAddress: string;\n entryIndex: number;\n challenge: string;\n};\n\nexport type SolanaAltResolutionContextInput = {\n deviceModelId: DeviceModelId;\n requests: SolanaAltResolutionRequest[];\n};\n\nconst altResolutionRequestCodec = Codec.interface({\n altAddress: string,\n entryIndex: u8Codec,\n challenge: string,\n});\n\nconst solanaAltResolutionInputCodec = Codec.interface({\n deviceModelId: deviceModelIdCodec,\n requests: array(altResolutionRequestCodec),\n});\n\n@injectable()\nexport class AltResolutionContextLoader\n implements ContextLoader<SolanaAltResolutionContextInput>\n{\n private readonly logger: LoggerPublisherService;\n\n constructor(\n @inject(altResolutionTypes.AltResolutionDataSource)\n private readonly dataSource: AltResolutionDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly certificateLoader: PkiCertificateLoader,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n ) {\n this.logger = loggerFactory(\"AltResolutionContextLoader\");\n }\n\n public canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is SolanaAltResolutionContextInput {\n if (!SUPPORTED_TYPES.every((t) => expectedTypes.includes(t))) return false;\n return solanaAltResolutionInputCodec.decode(input).caseOf({\n Left: () => false,\n Right: ({ requests }) =>\n requests.length > 0 &&\n requests.every(\n (r) => r.altAddress.length > 0 && r.challenge.length > 0,\n ),\n });\n }\n\n public async load(\n input: SolanaAltResolutionContextInput,\n ): Promise<ClearSignContext[]> {\n return loadChallengeBoundContexts({\n requests: input.requests,\n deviceModelId: input.deviceModelId,\n certificateLoader: this.certificateLoader,\n logger: this.logger,\n label: \"ALT_RESOLUTION\",\n fetch: (request) => this.dataSource.getAltResolution(request),\n toContext: (value, certificate) => {\n const payload: SolanaAltResolutionPayload = {\n descriptor: value.descriptor,\n resolvedAddress: value.resolvedAddress,\n };\n return {\n type: ClearSignContextType.SOLANA_ALT_RESOLUTION,\n payload,\n certificate,\n };\n },\n describe: (request) => ({\n altAddress: request.altAddress,\n entryIndex: request.entryIndex,\n }),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAIA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAS,SAAAC,EAAO,SAAAC,EAAO,UAAAC,MAAc,YAErC,OAAS,eAAAC,MAAmB,0BAC5B,OAAS,YAAAC,MAAgB,uCAGzB,OAAS,sBAAAC,MAA0B,wDAGnC,OAEE,wBAAAC,MACK,kCACP,OAAS,8BAAAC,MAAkC,sCAC3C,OAAS,sBAAAC,MAA0B,oCACnC,OAAS,WAAAC,MAAe,2BAExB,MAAMC,EAA0C,CAC9CC,EAAqB,qBACvB,EAaMC,EAA4BC,EAAM,UAAU,CAChD,WAAYC,EACZ,WAAYC,EACZ,UAAWD,CACb,CAAC,EAEKE,EAAgCH,EAAM,UAAU,CACpD,cAAeI,EACf,SAAUC,EAAMN,CAAyB,CAC3C,CAAC,EAGM,IAAMO,EAAN,KAEP,CAGE,YAEmBC,EAEAC,EAEjBC,EACA,CALiB,gBAAAF,EAEA,uBAAAC,EAIjB,KAAK,OAASC,EAAc,4BAA4B,CAC1D,CAXiB,OAaV,UACLC,EACAC,EAC0C,CAC1C,OAAKd,EAAgB,MAAO,GAAMc,EAAc,SAAS,CAAC,CAAC,EACpDR,EAA8B,OAAOO,CAAK,EAAE,OAAO,CACxD,KAAM,IAAM,GACZ,MAAO,CAAC,CAAE,SAAAE,CAAS,IACjBA,EAAS,OAAS,GAClBA,EAAS,MACN,GAAM,EAAE,WAAW,OAAS,GAAK,EAAE,UAAU,OAAS,CACzD,CACJ,CAAC,EARoE,EASvE,CAEA,MAAa,KACXF,EAC6B,CAC7B,OAAOG,EAA2B,CAChC,SAAUH,EAAM,SAChB,cAAeA,EAAM,cACrB,kBAAmB,KAAK,kBACxB,OAAQ,KAAK,OACb,MAAO,iBACP,MAAQI,GAAY,KAAK,WAAW,iBAAiBA,CAAO,EAC5D,UAAW,CAACC,EAAOC,IAAgB,CACjC,MAAMC,EAAsC,CAC1C,WAAYF,EAAM,WAClB,gBAAiBA,EAAM,eACzB,EACA,MAAO,CACL,KAAMjB,EAAqB,sBAC3B,QAAAmB,EACA,YAAAD,CACF,CACF,EACA,SAAWF,IAAa,CACtB,WAAYA,EAAQ,WACpB,WAAYA,EAAQ,UACtB,EACF,CAAC,CACH,CACF,EA1DaR,EAANY,EAAA,CADNC,EAAW,EAOPC,EAAA,EAAAC,EAAOC,EAAmB,uBAAuB,GAEjDF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,GAEpCH,EAAA,EAAAC,EAAOG,EAAY,0BAA0B,IAVrClB",
|
|
6
6
|
"names": ["inject", "injectable", "array", "Codec", "string", "configTypes", "pkiTypes", "altResolutionTypes", "ClearSignContextType", "loadChallengeBoundContexts", "deviceModelIdCodec", "u8Codec", "SUPPORTED_TYPES", "ClearSignContextType", "altResolutionRequestCodec", "Codec", "string", "u8Codec", "solanaAltResolutionInputCodec", "deviceModelIdCodec", "array", "AltResolutionContextLoader", "dataSource", "certificateLoader", "loggerFactory", "input", "expectedTypes", "requests", "loadChallengeBoundContexts", "request", "value", "certificate", "payload", "__decorateClass", "injectable", "__decorateParam", "inject", "altResolutionTypes", "pkiTypes", "configTypes"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/solana/model/SolanaPayloads.ts"],
|
|
4
|
-
"sourcesContent": ["// Solana payload types \u2014 used both by Solana loaders and (type-only)\n// referenced by the shared ClearSignContext union for typed-payload variants.\n\nexport type SolanaTokenData = {\n solanaTokenDescriptor: {\n data: string;\n signature: string;\n };\n};\n\nexport type SolanaTransactionDescriptor = {\n data: string;\n descriptorType: string;\n descriptorVersion: string;\n signature: string;\n has_basis_point?: boolean;\n};\n\nexport type SolanaLifiInstructionMeta = {\n program_id: string;\n discriminator_hex?: string;\n has_basis_point?: boolean;\n};\n\nexport type SolanaLifiPayload = {\n descriptors: Record<string, SolanaTransactionDescriptor[]>;\n instructions: SolanaLifiInstructionMeta[];\n};\n\nexport type SolanaTransactionCheckPayload = {\n descriptor: string;\n};\n\n// --- Generic clear-signing payloads ---\n\n// CAL static descriptor payloads. `data` is the signed TLV (hex string);\n// `signature` is the resolved signature for the configured CAL signature\n// kind (`prod` | `test`).\n\nexport type SolanaSignedDescriptor = {\n data: string;\n signature: string;\n};\n\n/**\n * One enum-variant descriptor bundled with an instruction descriptor by CAL.\n * The signed TLV (`descriptor.data`) feeds the host-side type-pool decode\n * cache, `enumId`/`variantIndex` identify which variant it describes (and let\n * the host stream the selected variant's signed descriptor to the device).\n */\nexport type SolanaInstructionEnumVariant = {\n enumId: string;\n variantIndex: number;\n descriptor: SolanaSignedDescriptor;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_INSTRUCTION_INFO.\n *\n * `instructionInfo` + `substructures` are the signed TLVs streamed to the\n * device, and `enumVariants` are the signed enum-variant descriptors CAL\n * bundles for the program's enums (used to build the host decode cache). The\n * remaining fields are CAL's decoded JSON consumed host-side by the\n * requirement builder.\n */\nexport type SolanaInstructionInfoPayload = {\n programId: string;\n discriminator: string;\n instructionInfo: SolanaSignedDescriptor;\n substructures: SolanaInstructionSubstructure[];\n enumVariants: SolanaInstructionEnumVariant[];\n idlDescriptor: {\n typePool: SolanaCalTypePoolEntry[];\n rootType: number;\n };\n mintAssociations: SolanaCalMintAssociation[];\n valueFlowPorts: SolanaCalValueFlowPort[];\n accountResets: SolanaCalAccountReset[];\n displayFields: SolanaCalDisplayField[];\n};\n\nexport enum SolanaInstructionSubstructureKind {\n DISPLAY_FIELD = 0x00,\n VALUE_FLOW_PORT = 0x01,\n HIDE_RULE = 0x02,\n ACCOUNT_RESET = 0x03,\n}\n\nexport type SolanaInstructionSubstructure = {\n kind: SolanaInstructionSubstructureKind;\n // TLV payload (hex string) for the substructure.\n data: string;\n};\n\n// --- Decoded CAL JSON (snake_case mirrors the CAL response) ---\n\nexport type SolanaCalValue = {\n source: string;\n /** ACCOUNT_PATH: index into the instruction's accounts. */\n account_index?: number;\n /** CONSTANT: hex-encoded bytes. */\n data?: string;\n /** ARGUMENT_PATH: decoded steps. */\n path?: { steps: number[] };\n};\n\nexport type SolanaCalTokenValue = {\n kind: string;\n value?: SolanaCalValue;\n account_index?: number;\n};\n\nexport type SolanaCalValueFlowPort = {\n /** Ordered candidate list of account indices (length 1 for a single-account port). */\n account_indices: number[];\n optional_account_strategy?: string;\n token_value: SolanaCalTokenValue;\n};\n\nexport type SolanaCalAccountReset = {\n account_index: number;\n require_pre_balance_zero?: boolean;\n};\n\nexport type SolanaCalDisplayField = {\n name?: string;\n param: { type: string; value?: SolanaCalValue; token?: SolanaCalValue };\n};\n\nexport type SolanaCalTypePoolEntry = {\n index: number;\n kind: string;\n refs?: number[];\n size?: number;\n encoding?: number;\n len_kind?: string;\n flag_kind?: string;\n sentinel?: string;\n disc_kind?: string;\n total_variants?: number;\n enum_id?: string;\n};\n\nexport type SolanaCalMintAssociation = {\n account_index: number;\n mint_index: number;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_ENUM_VARIANT: one signed\n * ENUM_VARIANT descriptor for a `(programId, enumId, variantIndex)` triple.\n */\nexport type SolanaEnumVariantPayload = {\n programId: string;\n enumId: string;\n variantIndex: number;\n descriptor: SolanaSignedDescriptor;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_TOKEN_INFO, keyed by mint pubkey.\n * Distinct from the legacy SOLANA_TOKEN context.\n */\nexport type SolanaTokenInfoPayload = {\n mint: string;\n descriptor: SolanaSignedDescriptor;\n};\n\n// --- Dynamic descriptor payloads (challenge-bound) ---\n//\n// Each payload carries the raw signed TLV bytes decoded from the backend's\n// hex `signedDescriptor`.\n\nexport type SolanaTokenAccountStatePayload = {\n descriptor: Uint8Array;\n};\n\nexport type SolanaAltResolutionPayload = {\n descriptor: Uint8Array;\n};\n\n// SOLANA_TRUSTED_NAME (generic flow, with 2-byte length prefix) is emitted by\n// SolanaTrustedNameContextLoader. SOLANA_BASIC_TRUSTED_NAME (basic flow, raw\n// bytes) is emitted by OwnerInfoContextLoader. Both carry `payload: Uint8Array`.\n"],
|
|
4
|
+
"sourcesContent": ["// Solana payload types \u2014 used both by Solana loaders and (type-only)\n// referenced by the shared ClearSignContext union for typed-payload variants.\n\nexport type SolanaTokenData = {\n solanaTokenDescriptor: {\n data: string;\n signature: string;\n };\n};\n\nexport type SolanaTransactionDescriptor = {\n data: string;\n descriptorType: string;\n descriptorVersion: string;\n signature: string;\n has_basis_point?: boolean;\n};\n\nexport type SolanaLifiInstructionMeta = {\n program_id: string;\n discriminator_hex?: string;\n has_basis_point?: boolean;\n};\n\nexport type SolanaLifiPayload = {\n descriptors: Record<string, SolanaTransactionDescriptor[]>;\n instructions: SolanaLifiInstructionMeta[];\n};\n\nexport type SolanaTransactionCheckPayload = {\n descriptor: string;\n};\n\n// --- Generic clear-signing payloads ---\n\n// CAL static descriptor payloads. `data` is the signed TLV (hex string);\n// `signature` is the resolved signature for the configured CAL signature\n// kind (`prod` | `test`).\n\nexport type SolanaSignedDescriptor = {\n data: string;\n signature: string;\n};\n\n/**\n * One enum-variant descriptor bundled with an instruction descriptor by CAL.\n * The signed TLV (`descriptor.data`) feeds the host-side type-pool decode\n * cache, `enumId`/`variantIndex` identify which variant it describes (and let\n * the host stream the selected variant's signed descriptor to the device).\n */\nexport type SolanaInstructionEnumVariant = {\n enumId: string;\n variantIndex: number;\n descriptor: SolanaSignedDescriptor;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_INSTRUCTION_INFO.\n *\n * `instructionInfo` + `substructures` are the signed TLVs streamed to the\n * device, and `enumVariants` are the signed enum-variant descriptors CAL\n * bundles for the program's enums (used to build the host decode cache). The\n * remaining fields are CAL's decoded JSON consumed host-side by the\n * requirement builder.\n */\nexport type SolanaInstructionInfoPayload = {\n programId: string;\n discriminator: string;\n instructionInfo: SolanaSignedDescriptor;\n substructures: SolanaInstructionSubstructure[];\n enumVariants: SolanaInstructionEnumVariant[];\n idlDescriptor: {\n typePool: SolanaCalTypePoolEntry[];\n rootType: number;\n };\n mintAssociations: SolanaCalMintAssociation[];\n valueFlowPorts: SolanaCalValueFlowPort[];\n accountResets: SolanaCalAccountReset[];\n displayFields: SolanaCalDisplayField[];\n};\n\nexport enum SolanaInstructionSubstructureKind {\n DISPLAY_FIELD = 0x00,\n VALUE_FLOW_PORT = 0x01,\n HIDE_RULE = 0x02,\n ACCOUNT_RESET = 0x03,\n}\n\nexport type SolanaInstructionSubstructure = {\n kind: SolanaInstructionSubstructureKind;\n // TLV payload (hex string) for the substructure.\n data: string;\n};\n\n// --- Decoded CAL JSON (snake_case mirrors the CAL response) ---\n\nexport type SolanaCalValue = {\n source: string;\n /** ACCOUNT_PATH: index into the instruction's accounts. */\n account_index?: number;\n /** CONSTANT: hex-encoded bytes. */\n data?: string;\n /** ARGUMENT_PATH: decoded steps. */\n path?: { steps: number[] };\n};\n\nexport type SolanaCalTokenValue = {\n kind: string;\n value?: SolanaCalValue;\n account_index?: number;\n};\n\nexport type SolanaCalValueFlowPort = {\n /** Ordered candidate list of account indices (length 1 for a single-account port). */\n account_indices: number[];\n optional_account_strategy?: string;\n token_value: SolanaCalTokenValue;\n};\n\nexport type SolanaCalAccountReset = {\n account_index: number;\n require_pre_balance_zero?: boolean;\n};\n\nexport type SolanaCalDisplayField = {\n name?: string;\n param: { type: string; value?: SolanaCalValue; token?: SolanaCalValue };\n};\n\nexport type SolanaCalTypePoolEntry = {\n index: number;\n kind: string;\n refs?: number[];\n size?: number;\n encoding?: number;\n len_kind?: string;\n flag_kind?: string;\n sentinel?: string;\n disc_kind?: string;\n total_variants?: number;\n enum_id?: string;\n};\n\nexport type SolanaCalMintAssociation = {\n account_index: number;\n mint_index: number;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_ENUM_VARIANT: one signed\n * ENUM_VARIANT descriptor for a `(programId, enumId, variantIndex)` triple.\n */\nexport type SolanaEnumVariantPayload = {\n programId: string;\n enumId: string;\n variantIndex: number;\n descriptor: SolanaSignedDescriptor;\n};\n\n/**\n * Payload for ClearSignContextType.SOLANA_TOKEN_INFO, keyed by mint pubkey.\n * Distinct from the legacy SOLANA_TOKEN context.\n */\nexport type SolanaTokenInfoPayload = {\n mint: string;\n descriptor: SolanaSignedDescriptor;\n};\n\n// --- Dynamic descriptor payloads (challenge-bound) ---\n//\n// Each payload carries the raw signed TLV bytes decoded from the backend's\n// hex `signedDescriptor`.\n\nexport type SolanaTokenAccountStatePayload = {\n descriptor: Uint8Array;\n mint?: string;\n};\n\nexport type SolanaAltResolutionPayload = {\n descriptor: Uint8Array;\n resolvedAddress?: string;\n};\n\n// SOLANA_TRUSTED_NAME (generic flow, with 2-byte length prefix) is emitted by\n// SolanaTrustedNameContextLoader. SOLANA_BASIC_TRUSTED_NAME (basic flow, raw\n// bytes) is emitted by OwnerInfoContextLoader. Both carry `payload: Uint8Array`.\n"],
|
|
5
5
|
"mappings": "AAiFO,IAAKA,OACVA,IAAA,cAAgB,GAAhB,gBACAA,IAAA,gBAAkB,GAAlB,kBACAA,IAAA,UAAY,GAAZ,YACAA,IAAA,cAAgB,GAAhB,gBAJUA,OAAA",
|
|
6
6
|
"names": ["SolanaInstructionSubstructureKind"]
|
|
7
7
|
}
|
package/lib/esm/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var g=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
var g=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=(i,t,o,r)=>{for(var e=r>1?void 0:r?l(t,o):t,n=i.length-1,s;n>=0;n--)(s=i[n])&&(e=(r?s(t,o,e):s(e))||e);return r&&e&&g(t,o,e),e},a=(i,t)=>(o,r)=>t(o,r,i);import{inject as u,injectable as f}from"inversify";import{Left as m,Right as k}from"purify-ts";import{configTypes as d}from"../../../../config/di/configTypes";import{networkTypes as y}from"../../../../shared/network/di/networkTypes";import{HexStringUtils as S}from"../../../../shared/utils/HexStringUtils";import{signedDescriptorDtoCodec as T}from"../../../../shared/utils/signedDescriptorDto";let c=class{constructor(t,o){this.config=t;this.http=o}async getTokenAccountState({tokenAccount:t,challenge:o}){let r;try{r=await this.http.get(`${this.config.metadataServiceDomain.url}/v2/solana/token-account-state/${t}`,{params:{challenge:o}})}catch(e){const n=e instanceof Error?e.message:String(e);return m(new Error(`[ContextModule] HttpTokenAccountStateDataSource: Failed to fetch token account state: ${n}`))}return T.decode(r).caseOf({Left:e=>m(new Error(`[ContextModule] HttpTokenAccountStateDataSource: malformed response for ${t}: ${e}`)),Right:e=>{let n;try{n=S.hexToBytes(e.signedDescriptor)}catch(s){return m(new Error(`[ContextModule] HttpTokenAccountStateDataSource: invalid hex in signedDescriptor for ${t}: ${s.message}`))}return k({tokenAccount:t,descriptor:n,mint:r.mint,keyId:e.keyId,keyUsage:e.keyUsage})}})}};c=p([f(),a(0,u(d.Config)),a(1,u(y.NetworkClient))],c);export{c as HttpTokenAccountStateDataSource};
|
|
2
2
|
//# sourceMappingURL=HttpTokenAccountStateDataSource.js.map
|