@ledgerhq/device-signer-kit-solana 1.13.4 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +1 -1
- package/lib/cjs/internal/app-binder/constants.js +1 -1
- package/lib/cjs/internal/app-binder/constants.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/generic-flow-router/BasicFlowRule.js +2 -0
- package/lib/cjs/internal/app-binder/generic-flow-router/BasicFlowRule.js.map +7 -0
- package/lib/cjs/internal/app-binder/generic-flow-router/GenericFlowRouter.js +2 -0
- package/lib/cjs/internal/app-binder/generic-flow-router/GenericFlowRouter.js.map +7 -0
- package/lib/cjs/internal/app-binder/generic-flow-router/GenericFlowRouter.test.js +2 -0
- package/lib/cjs/internal/app-binder/generic-flow-router/GenericFlowRouter.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/generic-flow-router/basicFlowRules.js +2 -0
- package/lib/cjs/internal/app-binder/generic-flow-router/basicFlowRules.js.map +7 -0
- package/lib/cjs/internal/app-binder/generic-flow-router/basicFlowRules.test.js +2 -0
- package/lib/cjs/internal/app-binder/generic-flow-router/basicFlowRules.test.js.map +7 -0
- package/lib/cjs/package.json +1 -1
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +1 -1
- package/lib/esm/internal/app-binder/constants.js +1 -1
- package/lib/esm/internal/app-binder/constants.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.test.js.map +3 -3
- package/lib/esm/internal/app-binder/generic-flow-router/BasicFlowRule.js +1 -0
- package/lib/esm/internal/app-binder/generic-flow-router/BasicFlowRule.js.map +7 -0
- package/lib/esm/internal/app-binder/generic-flow-router/GenericFlowRouter.js +2 -0
- package/lib/esm/internal/app-binder/generic-flow-router/GenericFlowRouter.js.map +7 -0
- package/lib/esm/internal/app-binder/generic-flow-router/GenericFlowRouter.test.js +2 -0
- package/lib/esm/internal/app-binder/generic-flow-router/GenericFlowRouter.test.js.map +7 -0
- package/lib/esm/internal/app-binder/generic-flow-router/basicFlowRules.js +2 -0
- package/lib/esm/internal/app-binder/generic-flow-router/basicFlowRules.js.map +7 -0
- package/lib/esm/internal/app-binder/generic-flow-router/basicFlowRules.test.js +2 -0
- package/lib/esm/internal/app-binder/generic-flow-router/basicFlowRules.test.js.map +7 -0
- package/lib/esm/package.json +1 -1
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +1 -0
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/internal/app-binder/constants.d.ts +1 -0
- package/lib/types/internal/app-binder/constants.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransactionDeviceAction.d.ts +5 -0
- package/lib/types/internal/app-binder/device-action/SignTransactionDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/generic-flow-router/BasicFlowRule.d.ts +22 -0
- package/lib/types/internal/app-binder/generic-flow-router/BasicFlowRule.d.ts.map +1 -0
- package/lib/types/internal/app-binder/generic-flow-router/GenericFlowRouter.d.ts +26 -0
- package/lib/types/internal/app-binder/generic-flow-router/GenericFlowRouter.d.ts.map +1 -0
- package/lib/types/internal/app-binder/generic-flow-router/GenericFlowRouter.test.d.ts +2 -0
- package/lib/types/internal/app-binder/generic-flow-router/GenericFlowRouter.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/generic-flow-router/basicFlowRules.d.ts +15 -0
- package/lib/types/internal/app-binder/generic-flow-router/basicFlowRules.d.ts.map +1 -0
- package/lib/types/internal/app-binder/generic-flow-router/basicFlowRules.test.d.ts +2 -0
- package/lib/types/internal/app-binder/generic-flow-router/basicFlowRules.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type SendCommandInAppDAError,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type AppConfiguration } from \"@api/model/AppConfiguration\";\nimport { type Signature } from \"@api/model/Signature\";\nimport { type SolanaTransactionOptionalConfig } from \"@api/model/SolanaTransactionOptionalConfig\";\nimport { type Transaction } from \"@api/model/Transaction\";\nimport { type SolanaAppErrorCodes } from \"@internal/app-binder/command/utils/SolanaApplicationErrors\";\nimport { type BlockhashService } from \"@internal/app-binder/services/BlockhashService\";\nimport { type SolanaSignerFeaturesNames } from \"@internal/app-binder/SolanaApplicationResolver\";\n\nimport { type SignClearSignDAStateStep } from \"./SignClearSignDeviceActionTypes\";\n\nexport const signTransactionDAStateSteps = Object.freeze({\n OPEN_APP: \"signer.sol.steps.openApp\",\n GET_APP_CONFIG: \"signer.sol.steps.getAppConfig\",\n TRANSACTION_CHECKS_OPT_IN: \"signer.sol.steps.transactionChecksOptIn\",\n TRANSACTION_CHECKS_OPT_IN_RESULT:\n \"signer.sol.steps.transactionChecksOptInResult\",\n TRANSACTION_CHECKS_PROVIDE: \"signer.sol.steps.transactionChecksProvide\",\n INSPECT_TRANSACTION: \"signer.sol.steps.inspectTransaction\",\n GET_PUB_KEY: \"signer.sol.steps.getPubKey\",\n BUILD_BASIC_CLEAR_SIGN_CONTEXT: \"signer.sol.steps.buildBasicClearSignContext\",\n PROVIDE_BASIC_CLEAR_SIGN_CONTEXT:\n \"signer.sol.steps.provideBasicClearSignContext\",\n BUILD_GENERIC_CLEAR_SIGN_CONTEXT:\n \"signer.sol.steps.buildGenericClearSignContext\",\n PROVIDE_GENERIC_CLEAR_SIGN_CONTEXT:\n \"signer.sol.steps.provideGenericClearSignContext\",\n FINALIZE_GENERIC_CLEAR_SIGN: \"signer.sol.steps.finalizeGenericClearSign\",\n PROMPT_UI_DISPLAY: \"signer.sol.steps.promptUiDisplay\",\n SIGN_TRANSACTION: \"signer.sol.steps.signTransaction\",\n DELAYED_SIGN: \"signer.sol.steps.delayedSign\",\n} as const);\n\n/**\n * Which clear-signing path produced the signature.\n * `full` = device ran the merge engine\n * `srfc39-only` = partial CAL coverage, device auto-rendered per-instruction without merge\n * `none` = blind/legacy fallback (no instruction recognised or capability absent).\n */\nexport type ClearSignMode = \"full\" | \"srfc39-only\" | \"none\";\n\nexport type SignTransactionDAStateStep =\n | (typeof signTransactionDAStateSteps)[keyof typeof signTransactionDAStateSteps]\n | SignClearSignDAStateStep;\n\nexport type SignTransactionDAOutput = Signature;\n\nexport type SignTransactionDAInput = {\n readonly derivationPath: string;\n readonly transaction: Transaction;\n readonly contextModule: ContextModule;\n readonly transactionOptions?: SolanaTransactionOptionalConfig;\n readonly solanaRPCURL?: string;\n readonly blockhashService?: BlockhashService;\n readonly disabledFeatures?: ReadonlyArray<SolanaSignerFeaturesNames>;\n};\n\nexport type SignTransactionDAError =\n | OpenAppDAError\n | SendCommandInAppDAError<SolanaAppErrorCodes>;\n\ntype SignTransactionDARequiredInteraction =\n | UserInteractionRequired\n | OpenAppDARequiredInteraction;\n\n/**\n * The intermediate value shared by every sign-transaction step except the\n * TRANSACTION_CHECKS_OPT_IN_RESULT branch (which carries an extra `result`). The\n * clear-sign child machines emit exactly this shape, so the parent can fold\n * their snapshots into its own intermediate value without a cast.\n */\nexport type SignTransactionDASimpleIntermediateValue = {\n requiredUserInteraction: SignTransactionDARequiredInteraction;\n step: Exclude<\n SignTransactionDAStateStep,\n typeof signTransactionDAStateSteps.TRANSACTION_CHECKS_OPT_IN_RESULT\n >;\n};\n\nexport type SignTransactionDAIntermediateValue =\n | SignTransactionDASimpleIntermediateValue\n | {\n requiredUserInteraction: UserInteractionRequired.None;\n step: typeof signTransactionDAStateSteps.TRANSACTION_CHECKS_OPT_IN_RESULT;\n result: boolean;\n };\n\nexport type SignTransactionDAInternalState = {\n readonly error: SignTransactionDAError | null;\n readonly signature: Signature | null;\n readonly appConfig: AppConfiguration | null;\n // Updated by NormalizeTransaction; starts as the raw input and is replaced\n // with the extracted message bytes once the actor completes. serializedForTxCheck\n // is only set when the input was tx.serialize().\n readonly messageBytes: Uint8Array;\n readonly serializedForTxCheck: Uint8Array | undefined;\n // Set when the generic clear-sign path streamed + FINALIZE-validated the\n // descriptors, so the terminal sign runs the generic PROMPT UI DISPLAY flow\n // instead of the legacy preview.\n readonly clearSignPrepared: boolean;\n // Unrecognized program IDs from generic clear-sign, used for blind-sign reporting.\n readonly unrecognizedProgramIds: string[];\n // Set when generic clear-sign degraded specifically due to an ACCOUNT_SCHEMA\n // pre-check failure (stale CAL descriptor), used for blind-sign reporting.\n readonly staleDescriptor: boolean;\n};\n\nexport type SignTransactionDAReturnType = ExecuteDeviceActionReturnType<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n>;\n"],
|
|
4
|
+
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type SendCommandInAppDAError,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type AppConfiguration } from \"@api/model/AppConfiguration\";\nimport { type Signature } from \"@api/model/Signature\";\nimport { type SolanaTransactionOptionalConfig } from \"@api/model/SolanaTransactionOptionalConfig\";\nimport { type Transaction } from \"@api/model/Transaction\";\nimport { type SolanaAppErrorCodes } from \"@internal/app-binder/command/utils/SolanaApplicationErrors\";\nimport { type BlockhashService } from \"@internal/app-binder/services/BlockhashService\";\nimport { type SolanaSignerFeaturesNames } from \"@internal/app-binder/SolanaApplicationResolver\";\n\nimport { type SignClearSignDAStateStep } from \"./SignClearSignDeviceActionTypes\";\n\nexport const signTransactionDAStateSteps = Object.freeze({\n OPEN_APP: \"signer.sol.steps.openApp\",\n GET_APP_CONFIG: \"signer.sol.steps.getAppConfig\",\n TRANSACTION_CHECKS_OPT_IN: \"signer.sol.steps.transactionChecksOptIn\",\n TRANSACTION_CHECKS_OPT_IN_RESULT:\n \"signer.sol.steps.transactionChecksOptInResult\",\n TRANSACTION_CHECKS_PROVIDE: \"signer.sol.steps.transactionChecksProvide\",\n INSPECT_TRANSACTION: \"signer.sol.steps.inspectTransaction\",\n GET_PUB_KEY: \"signer.sol.steps.getPubKey\",\n BUILD_BASIC_CLEAR_SIGN_CONTEXT: \"signer.sol.steps.buildBasicClearSignContext\",\n PROVIDE_BASIC_CLEAR_SIGN_CONTEXT:\n \"signer.sol.steps.provideBasicClearSignContext\",\n BUILD_GENERIC_CLEAR_SIGN_CONTEXT:\n \"signer.sol.steps.buildGenericClearSignContext\",\n PROVIDE_GENERIC_CLEAR_SIGN_CONTEXT:\n \"signer.sol.steps.provideGenericClearSignContext\",\n FINALIZE_GENERIC_CLEAR_SIGN: \"signer.sol.steps.finalizeGenericClearSign\",\n PROMPT_UI_DISPLAY: \"signer.sol.steps.promptUiDisplay\",\n SIGN_TRANSACTION: \"signer.sol.steps.signTransaction\",\n DELAYED_SIGN: \"signer.sol.steps.delayedSign\",\n} as const);\n\n/**\n * Which clear-signing path produced the signature.\n * `full` = device ran the merge engine\n * `srfc39-only` = partial CAL coverage, device auto-rendered per-instruction without merge\n * `none` = blind/legacy fallback (no instruction recognised or capability absent).\n */\nexport type ClearSignMode = \"full\" | \"srfc39-only\" | \"none\";\n\nexport type SignTransactionDAStateStep =\n | (typeof signTransactionDAStateSteps)[keyof typeof signTransactionDAStateSteps]\n | SignClearSignDAStateStep;\n\nexport type SignTransactionDAOutput = Signature;\n\nexport type SignTransactionDAInput = {\n readonly derivationPath: string;\n readonly transaction: Transaction;\n readonly contextModule: ContextModule;\n readonly transactionOptions?: SolanaTransactionOptionalConfig;\n readonly solanaRPCURL?: string;\n readonly blockhashService?: BlockhashService;\n readonly disabledFeatures?: ReadonlyArray<SolanaSignerFeaturesNames>;\n};\n\nexport type SignTransactionDAError =\n | OpenAppDAError\n | SendCommandInAppDAError<SolanaAppErrorCodes>;\n\ntype SignTransactionDARequiredInteraction =\n | UserInteractionRequired\n | OpenAppDARequiredInteraction;\n\n/**\n * The intermediate value shared by every sign-transaction step except the\n * TRANSACTION_CHECKS_OPT_IN_RESULT branch (which carries an extra `result`). The\n * clear-sign child machines emit exactly this shape, so the parent can fold\n * their snapshots into its own intermediate value without a cast.\n */\nexport type SignTransactionDASimpleIntermediateValue = {\n requiredUserInteraction: SignTransactionDARequiredInteraction;\n step: Exclude<\n SignTransactionDAStateStep,\n typeof signTransactionDAStateSteps.TRANSACTION_CHECKS_OPT_IN_RESULT\n >;\n};\n\nexport type SignTransactionDAIntermediateValue =\n | SignTransactionDASimpleIntermediateValue\n | {\n requiredUserInteraction: UserInteractionRequired.None;\n step: typeof signTransactionDAStateSteps.TRANSACTION_CHECKS_OPT_IN_RESULT;\n result: boolean;\n };\n\nexport type SignTransactionDAInternalState = {\n readonly error: SignTransactionDAError | null;\n readonly signature: Signature | null;\n readonly appConfig: AppConfiguration | null;\n // Updated by NormalizeTransaction; starts as the raw input and is replaced\n // with the extracted message bytes once the actor completes. serializedForTxCheck\n // is only set when the input was tx.serialize().\n readonly messageBytes: Uint8Array;\n readonly serializedForTxCheck: Uint8Array | undefined;\n // Set when the generic clear-sign path streamed + FINALIZE-validated the\n // descriptors, so the terminal sign runs the generic PROMPT UI DISPLAY flow\n // instead of the legacy preview.\n readonly clearSignPrepared: boolean;\n // Unrecognized program IDs from generic clear-sign, used for blind-sign reporting.\n readonly unrecognizedProgramIds: string[];\n // Set when generic clear-sign degraded specifically due to an ACCOUNT_SCHEMA\n // pre-check failure (stale CAL descriptor), used for blind-sign reporting.\n readonly staleDescriptor: boolean;\n // Id of the basic-flow rule that routed the transaction straight to the\n // basic flow (skipping generic clear-sign), or null when none matched.\n readonly basicFlowRuleId: string | null;\n};\n\nexport type SignTransactionDAReturnType = ExecuteDeviceActionReturnType<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n>;\n"],
|
|
5
5
|
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAmBO,MAAME,EAA8B,OAAO,OAAO,CACvD,SAAU,2BACV,eAAgB,gCAChB,0BAA2B,0CAC3B,iCACE,gDACF,2BAA4B,4CAC5B,oBAAqB,sCACrB,YAAa,6BACb,+BAAgC,8CAChC,iCACE,gDACF,iCACE,gDACF,mCACE,kDACF,4BAA6B,4CAC7B,kBAAmB,mCACnB,iBAAkB,mCAClB,aAAc,8BAChB,CAAU",
|
|
6
6
|
"names": ["SignTransactionDeviceActionTypes_exports", "__export", "signTransactionDAStateSteps", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var A=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var M=(t
|
|
1
|
+
"use strict";var A=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var M=(o,t)=>{for(var e in t)A(o,e,{get:t[e],enumerable:!0})},R=(o,t,e,E)=>{if(t&&typeof t=="object"||typeof t=="function")for(let _ of n(t))!p.call(o,_)&&_!==e&&A(o,_,{get:()=>t[_],enumerable:!(E=P(t,_))||E.enumerable});return o};var S=o=>R(A({},"__esModule",{value:!0}),o);var D={};M(D,{APP_NAME:()=>c,COMPUTE_BUDGET_PROGRAM_ID:()=>s,SOLANA_PUBKEY_LEN:()=>r,STAKE_PROGRAM_ID:()=>O,SYSTEM_PROGRAM_ID:()=>x});module.exports=S(D);const c="Solana",r=32,s="ComputeBudget111111111111111111111111111111",x="11111111111111111111111111111111",O="Stake11111111111111111111111111111111111111";0&&(module.exports={APP_NAME,COMPUTE_BUDGET_PROGRAM_ID,SOLANA_PUBKEY_LEN,STAKE_PROGRAM_ID,SYSTEM_PROGRAM_ID});
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/app-binder/constants.ts"],
|
|
4
|
-
"sourcesContent": ["export const APP_NAME = \"Solana\";\nexport const SOLANA_PUBKEY_LEN = 32;\nexport const COMPUTE_BUDGET_PROGRAM_ID =\n \"ComputeBudget111111111111111111111111111111\";\nexport const SYSTEM_PROGRAM_ID = \"11111111111111111111111111111111\";\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,8BAAAC,EAAA,sBAAAC,EAAA,sBAAAC,IAAA,eAAAC,
|
|
6
|
-
"names": ["constants_exports", "__export", "APP_NAME", "COMPUTE_BUDGET_PROGRAM_ID", "SOLANA_PUBKEY_LEN", "SYSTEM_PROGRAM_ID", "__toCommonJS"]
|
|
4
|
+
"sourcesContent": ["export const APP_NAME = \"Solana\";\nexport const SOLANA_PUBKEY_LEN = 32;\nexport const COMPUTE_BUDGET_PROGRAM_ID =\n \"ComputeBudget111111111111111111111111111111\";\nexport const SYSTEM_PROGRAM_ID = \"11111111111111111111111111111111\";\nexport const STAKE_PROGRAM_ID = \"Stake11111111111111111111111111111111111111\";\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,8BAAAC,EAAA,sBAAAC,EAAA,qBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAP,GAAO,MAAME,EAAW,SACXE,EAAoB,GACpBD,EACX,8CACWG,EAAoB,mCACpBD,EAAmB",
|
|
6
|
+
"names": ["constants_exports", "__export", "APP_NAME", "COMPUTE_BUDGET_PROGRAM_ID", "SOLANA_PUBKEY_LEN", "STAKE_PROGRAM_ID", "SYSTEM_PROGRAM_ID", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var O=(o,a)=>{for(var c in a)d(o,c,{get:a[c],enumerable:!0})},G=(o,a,c,l)=>{if(a&&typeof a=="object"||typeof a=="function")for(let s of B(a))!F.call(o,s)&&s!==c&&d(o,s,{get:()=>a[s],enumerable:!(l=E(a,s))||l.enumerable});return o};var z=o=>G(d({},"__esModule",{value:!0}),o);var V={};O(V,{SignTransactionDeviceAction:()=>w});module.exports=z(V);var r=require("@ledgerhq/device-management-kit"),u=require("purify-ts"),n=require("xstate"),p=require("../../../api/app-binder/SignTransactionDeviceActionTypes"),k=require("../../app-binder/command/GetAppConfigurationCommand"),h=require("../../app-binder/constants"),f=require("../../app-binder/services/TransactionInputNormaliser"),y=require("../../app-binder/SolanaApplicationResolver"),v=require("../../app-binder/task/SolanaSigningReportTask"),A=require("./ProvisionBasicClearSignDeviceAction"),D=require("./ProvisionGenericClearSignDeviceAction"),_=require("./ProvisionTransactionCheckDeviceAction"),P=require("./SignBasicClearSignDeviceAction"),M=require("./SignGenericClearSignDeviceAction");function T(o){return o.transactionOptions?.solanaRPCURL??o.solanaRPCURL}class w extends r.XStateDeviceAction{makeStateMachine(a){const{normalizeTransaction:c,getAppConfig:l,reportSign:s}=this.extractDependencies(a),g=this.getLoggerFactory(a),I=g("SignTransactionDeviceAction"),R=this.input.disabledFeatures?new Set(this.input.disabledFeatures):void 0,S=(e,t)=>(0,y.isSolanaSignerFeatureSupported)(a,e,t,R),C=e=>{const t=T(e.input),i=e.input.transactionOptions?.fetchBlockhash,m=!!!e.input.transactionOptions?.transactionResolutionContext?.templateId&&e.input.transactionOptions?.delayed===!0&&!!(t||i)&&S("delayedSigning",e._internalState.appConfig);return{rpcUrl:m?t:void 0,fetchBlockhash:m?i:void 0}};return(0,n.setup)({types:{input:{},context:{},output:{}},actors:{normalizeTransaction:(0,n.fromPromise)(c),reportSign:(0,n.fromPromise)(s),openAppStateMachine:new r.OpenAppDeviceAction({input:{appName:h.APP_NAME}}).makeStateMachine(a),getAppConfig:(0,n.fromPromise)(l),transactionCheckStateMachine:new _.ProvisionTransactionCheckDeviceAction({input:{derivationPath:this.input.derivationPath,transaction:this.input.transaction,contextModule:this.input.contextModule},loggerFactory:this.getLoggerFactory(a)}).makeStateMachine(a),provisionGenericClearSignStateMachine:new D.ProvisionGenericClearSignDeviceAction({input:{derivationPath:this.input.derivationPath,transaction:this.input.transaction,contextModule:this.input.contextModule},loggerFactory:this.getLoggerFactory(a)}).makeStateMachine(a),provisionBasicClearSignStateMachine:new A.ProvisionBasicClearSignDeviceAction({input:{derivationPath:this.input.derivationPath,transaction:this.input.transaction,contextModule:this.input.contextModule},loggerFactory:this.getLoggerFactory(a)}).makeStateMachine(a),signGenericClearSignStateMachine:new M.SignGenericClearSignDeviceAction({input:{derivationPath:this.input.derivationPath,transaction:this.input.transaction},loggerFactory:this.getLoggerFactory(a)}).makeStateMachine(a),signBasicClearSignStateMachine:new P.SignBasicClearSignDeviceAction({input:{derivationPath:this.input.derivationPath,transaction:this.input.transaction},loggerFactory:this.getLoggerFactory(a)}).makeStateMachine(a)},guards:{noInternalError:({context:e})=>e._internalState.error===null,skipOpenApp:({context:e})=>e.input.transactionOptions?.skipOpenApp||!1,isTransactionChecksSupported:({context:e})=>S("transactionChecks",e._internalState.appConfig),isGenericClearSignAvailable:({context:e})=>S("genericClearSign",e._internalState.appConfig),isClearSignPrepared:({context:e})=>e._internalState.clearSignPrepared,hasSignature:({context:e})=>e._internalState.signature!==null},actions:{assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new r.UnknownDAError(e.event.error instanceof Error?e.event.error.message:String(e.event.error))})})}}).createMachine({id:"SignTransactionDeviceAction",initial:"NormalizeTransaction",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:r.UserInteractionRequired.None,step:p.signTransactionDAStateSteps.OPEN_APP},_internalState:{error:null,signature:null,appConfig:null,messageBytes:this.input.transaction,serializedForTxCheck:void 0,clearSignPrepared:!1,unrecognizedProgramIds:[],staleDescriptor:!1}}),states:{NormalizeTransaction:{entry:(0,n.assign)({intermediateValue:({context:e})=>({requiredUserInteraction:r.UserInteractionRequired.None,step:e.input.transactionOptions?.skipOpenApp?p.signTransactionDAStateSteps.GET_APP_CONFIG:p.signTransactionDAStateSteps.OPEN_APP})}),invoke:{id:"normalizeTransaction",src:"normalizeTransaction",onDone:[{target:"GetAppConfig",guard:"skipOpenApp",actions:(0,n.assign)({_internalState:({event:e,context:t})=>({...t._internalState,messageBytes:e.output.messageBytes,serializedForTxCheck:e.output.serializedForTxCheck})})},{target:"OpenAppDeviceAction",actions:(0,n.assign)({_internalState:({event:e,context:t})=>({...t._internalState,messageBytes:e.output.messageBytes,serializedForTxCheck:e.output.serializedForTxCheck})})}]}},OpenAppDeviceAction:{entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:r.UserInteractionRequired.None,step:p.signTransactionDAStateSteps.OPEN_APP})}),invoke:{id:"openAppStateMachine",src:"openAppStateMachine",input:()=>({appName:h.APP_NAME}),onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>({...e.snapshot.context.intermediateValue,step:p.signTransactionDAStateSteps.OPEN_APP})})},onDone:{target:"OpenAppResultCheck",actions:(0,n.assign)({_internalState:({event:e,context:t})=>e.output.caseOf({Right:()=>t._internalState,Left:i=>({...t._internalState,error:i})})})}}},OpenAppResultCheck:{always:[{target:"GetAppConfig",guard:"noInternalError"},{target:"Error"}]},GetAppConfig:{entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:r.UserInteractionRequired.None,step:p.signTransactionDAStateSteps.GET_APP_CONFIG})}),invoke:{id:"getAppConfig",src:"getAppConfig",onDone:{target:"GetAppConfigResultCheck",actions:(0,n.assign)({_internalState:({event:e,context:t})=>(0,r.isSuccessCommandResult)(e.output)?{...t._internalState,appConfig:e.output.data}:{...t._internalState,error:e.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetAppConfigResultCheck:{always:[{target:"CheckTransactionCheckSupported",guard:"noInternalError"},{target:"Error"}]},CheckTransactionCheckSupported:{always:[{target:"TxCheck",guard:"isTransactionChecksSupported"},{target:"CheckGenericClearSignSupported"}]},TxCheck:{invoke:{id:"transactionCheckStateMachine",src:"transactionCheckStateMachine",input:({context:e})=>({appConfig:e._internalState.appConfig,derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,contextModule:e.input.contextModule,serializedForTxCheck:e._internalState.serializedForTxCheck}),onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"CheckGenericClearSignSupported",actions:(0,n.assign)({_internalState:({event:e,context:t})=>e.output.caseOf({Right:({transactionChecksEnabled:i})=>({...t._internalState,appConfig:{...t._internalState.appConfig,transactionChecksEnabled:i,transactionChecksOptIn:!0}}),Left:()=>t._internalState})})}}},CheckGenericClearSignSupported:{always:[{target:"GenericClearSign",guard:(0,n.and)(["noInternalError","isGenericClearSignAvailable"])},{target:"BasicClearSign",guard:"noInternalError"},{target:"Error"}]},GenericClearSign:{invoke:{id:"provisionGenericClearSignStateMachine",src:"provisionGenericClearSignStateMachine",input:({context:e})=>({derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,contextModule:e.input.contextModule}),onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"CheckGenericClearSignResult",actions:(0,n.assign)({_internalState:({event:e,context:t})=>e.output.caseOf({Right:i=>({...t._internalState,clearSignPrepared:i.status==="prepared",unrecognizedProgramIds:i.unrecognizedProgramIds,staleDescriptor:i.staleDescriptor}),Left:i=>({...t._internalState,error:i})})})},onError:{target:"CheckTxCheckReprovision",actions:({event:e})=>I.info("[ClearSign] generic clear-sign threw; falling back to legacy",{data:{error:String(e.error)}})}}},CheckGenericClearSignResult:{always:[{target:"GenericTerminalSign",guard:(0,n.and)(["noInternalError","isClearSignPrepared"])},{target:"CheckTxCheckReprovision",guard:"noInternalError"},{target:"Error"}]},GenericTerminalSign:{invoke:{id:"signGenericClearSignStateMachine",src:"signGenericClearSignStateMachine",input:({context:e})=>{const{rpcUrl:t,fetchBlockhash:i}=C(e);return{derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,rpcUrl:t,fetchBlockhash:i,userInputType:e.input.transactionOptions?.transactionResolutionContext?.userInputType,blockhashService:e.input.blockhashService}},onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"CheckGenericTerminalSignResult",actions:(0,n.assign)({_internalState:({event:e,context:t})=>e.output.caseOf({Right:i=>i==="degraded"?t._internalState:{...t._internalState,signature:i},Left:i=>({...t._internalState,error:i})})})}}},CheckGenericTerminalSignResult:{always:[{target:"Report",guard:"hasSignature"},{target:"CheckTxCheckReprovision",guard:"noInternalError"},{target:"Report"}]},CheckTxCheckReprovision:{always:[{target:"TxCheckReprovision",guard:"isTransactionChecksSupported"},{target:"BasicClearSign"}]},TxCheckReprovision:{invoke:{id:"transactionCheckReprovisionStateMachine",src:"transactionCheckStateMachine",input:({context:e})=>({appConfig:e._internalState.appConfig,derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,contextModule:e.input.contextModule,serializedForTxCheck:e._internalState.serializedForTxCheck}),onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"BasicClearSign"}}},BasicClearSign:{invoke:{id:"provisionBasicClearSignStateMachine",src:"provisionBasicClearSignStateMachine",input:({context:e})=>({derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,contextModule:e.input.contextModule,appConfig:e._internalState.appConfig,rpcUrl:T(e.input),resolutionContext:e.input.transactionOptions?.transactionResolutionContext}),onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"Report"},onError:{target:"Report"}}},Report:{invoke:{src:"reportSign",input:({context:e})=>{const t=a.getDeviceSessionState(),i=t.sessionStateType!==r.DeviceSessionStateType.Connected?t.firmwareVersion?.os??null:null;return{isBlindSign:e._internalState.signature===null&&e._internalState.error===null,messageBytes:e._internalState.messageBytes,unrecognizedProgramIds:e._internalState.unrecognizedProgramIds,staleDescriptor:e._internalState.staleDescriptor,contextModule:e.input.contextModule,signerAppVersion:e._internalState.appConfig.version,deviceModelId:t.deviceModelId,deviceVersion:i,loggerFactory:g}},onDone:[{target:"SignTransactionResultCheck",guard:"hasSignature"},{target:"Error",guard:({context:e})=>e._internalState.error!==null},{target:"BasicTerminalSign"}],onError:[{target:"SignTransactionResultCheck",guard:"hasSignature"},{target:"Error",guard:({context:e})=>e._internalState.error!==null},{target:"BasicTerminalSign"}]}},BasicTerminalSign:{invoke:{id:"signBasicClearSignStateMachine",src:"signBasicClearSignStateMachine",input:({context:e})=>{const{rpcUrl:t,fetchBlockhash:i}=C(e);return{derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,rpcUrl:t,fetchBlockhash:i,userInputType:e.input.transactionOptions?.transactionResolutionContext?.userInputType,blockhashService:e.input.blockhashService}},onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"SignTransactionResultCheck",actions:(0,n.assign)({_internalState:({event:e,context:t})=>e.output.caseOf({Right:i=>({...t._internalState,signature:i}),Left:i=>({...t._internalState,error:i})})})}}},SignTransactionResultCheck:{always:[{guard:"noInternalError",target:"Success"},{target:"Error"}]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.signature?(0,u.Right)(e._internalState.signature):(0,u.Left)(e._internalState.error||new r.UnknownDAError("No error or signature available"))})}extractDependencies(a){return{normalizeTransaction:async()=>{try{return new f.TransactionInputNormaliser().normalize(this.input.transaction)}catch(g){return this.getLoggerFactory(a)("NormalizeTransaction").warn("[normalizeTransaction] format detection failed; treating input as message bytes",{data:{error:String(g)}}),{messageBytes:this.input.transaction,serializedForTxCheck:void 0}}},getAppConfig:async()=>a.sendCommand(new k.GetAppConfigurationCommand),reportSign:async g=>new v.SolanaSigningReportTask(g.input).run()}}}0&&(module.exports={SignTransactionDeviceAction});
|
|
1
|
+
"use strict";var f=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var V=(o,a)=>{for(var l in a)f(o,l,{get:a[l],enumerable:!0})},N=(o,a,l,S)=>{if(a&&typeof a=="object"||typeof a=="function")for(let s of O(a))!z.call(o,s)&&s!==l&&f(o,s,{get:()=>a[s],enumerable:!(S=G(a,s))||S.enumerable});return o};var U=o=>N(f({},"__esModule",{value:!0}),o);var L={};V(L,{SignTransactionDeviceAction:()=>b});module.exports=U(L);var r=require("@ledgerhq/device-management-kit"),C=require("purify-ts"),n=require("xstate"),g=require("../../../api/app-binder/SignTransactionDeviceActionTypes"),v=require("../../app-binder/command/GetAppConfigurationCommand"),u=require("../../app-binder/constants"),A=require("../../app-binder/generic-flow-router/basicFlowRules"),R=require("../../app-binder/generic-flow-router/GenericFlowRouter"),_=require("../../app-binder/services/TransactionInputNormaliser"),P=require("../../app-binder/services/utils/TransactionParser"),D=require("../../app-binder/SolanaApplicationResolver"),I=require("../../app-binder/task/SolanaSigningReportTask"),M=require("./ProvisionBasicClearSignDeviceAction"),B=require("./ProvisionGenericClearSignDeviceAction"),w=require("./ProvisionTransactionCheckDeviceAction"),E=require("./SignBasicClearSignDeviceAction"),F=require("./SignGenericClearSignDeviceAction");function y(o){return o.transactionOptions?.solanaRPCURL??o.solanaRPCURL}class b extends r.XStateDeviceAction{makeStateMachine(a){const{normalizeTransaction:l,getAppConfig:S,reportSign:s,resolveSigningRoute:T}=this.extractDependencies(a),c=this.getLoggerFactory(a),p=c("SignTransactionDeviceAction"),h=this.input.disabledFeatures?new Set(this.input.disabledFeatures):void 0,d=(e,t)=>(0,D.isSolanaSignerFeatureSupported)(a,e,t,h),m=e=>{const t=y(e.input),i=e.input.transactionOptions?.fetchBlockhash,k=!!!e.input.transactionOptions?.transactionResolutionContext?.templateId&&e.input.transactionOptions?.delayed===!0&&!!(t||i)&&d("delayedSigning",e._internalState.appConfig);return{rpcUrl:k?t:void 0,fetchBlockhash:k?i:void 0}};return(0,n.setup)({types:{input:{},context:{},output:{}},actors:{normalizeTransaction:(0,n.fromPromise)(l),reportSign:(0,n.fromPromise)(s),resolveSigningRoute:(0,n.fromPromise)(T),openAppStateMachine:new r.OpenAppDeviceAction({input:{appName:u.APP_NAME}}).makeStateMachine(a),getAppConfig:(0,n.fromPromise)(S),transactionCheckStateMachine:new w.ProvisionTransactionCheckDeviceAction({input:{derivationPath:this.input.derivationPath,transaction:this.input.transaction,contextModule:this.input.contextModule},loggerFactory:this.getLoggerFactory(a)}).makeStateMachine(a),provisionGenericClearSignStateMachine:new B.ProvisionGenericClearSignDeviceAction({input:{derivationPath:this.input.derivationPath,transaction:this.input.transaction,contextModule:this.input.contextModule},loggerFactory:this.getLoggerFactory(a)}).makeStateMachine(a),provisionBasicClearSignStateMachine:new M.ProvisionBasicClearSignDeviceAction({input:{derivationPath:this.input.derivationPath,transaction:this.input.transaction,contextModule:this.input.contextModule},loggerFactory:this.getLoggerFactory(a)}).makeStateMachine(a),signGenericClearSignStateMachine:new F.SignGenericClearSignDeviceAction({input:{derivationPath:this.input.derivationPath,transaction:this.input.transaction},loggerFactory:this.getLoggerFactory(a)}).makeStateMachine(a),signBasicClearSignStateMachine:new E.SignBasicClearSignDeviceAction({input:{derivationPath:this.input.derivationPath,transaction:this.input.transaction},loggerFactory:this.getLoggerFactory(a)}).makeStateMachine(a)},guards:{noInternalError:({context:e})=>e._internalState.error===null,skipOpenApp:({context:e})=>e.input.transactionOptions?.skipOpenApp||!1,isTransactionChecksSupported:({context:e})=>d("transactionChecks",e._internalState.appConfig),isGenericClearSignAvailable:({context:e})=>d("genericClearSign",e._internalState.appConfig),isClearSignPrepared:({context:e})=>e._internalState.clearSignPrepared,hasSignature:({context:e})=>e._internalState.signature!==null,hasBasicFlowRule:({context:e})=>e._internalState.basicFlowRuleId!==null},actions:{assignErrorFromEvent:(0,n.assign)({_internalState:e=>({...e.context._internalState,error:new r.UnknownDAError(e.event.error instanceof Error?e.event.error.message:String(e.event.error))})})}}).createMachine({id:"SignTransactionDeviceAction",initial:"NormalizeTransaction",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:r.UserInteractionRequired.None,step:g.signTransactionDAStateSteps.OPEN_APP},_internalState:{error:null,signature:null,appConfig:null,messageBytes:this.input.transaction,serializedForTxCheck:void 0,clearSignPrepared:!1,unrecognizedProgramIds:[],staleDescriptor:!1,basicFlowRuleId:null}}),states:{NormalizeTransaction:{entry:(0,n.assign)({intermediateValue:({context:e})=>({requiredUserInteraction:r.UserInteractionRequired.None,step:e.input.transactionOptions?.skipOpenApp?g.signTransactionDAStateSteps.GET_APP_CONFIG:g.signTransactionDAStateSteps.OPEN_APP})}),invoke:{id:"normalizeTransaction",src:"normalizeTransaction",onDone:[{target:"GetAppConfig",guard:"skipOpenApp",actions:(0,n.assign)({_internalState:({event:e,context:t})=>({...t._internalState,messageBytes:e.output.messageBytes,serializedForTxCheck:e.output.serializedForTxCheck})})},{target:"OpenAppDeviceAction",actions:(0,n.assign)({_internalState:({event:e,context:t})=>({...t._internalState,messageBytes:e.output.messageBytes,serializedForTxCheck:e.output.serializedForTxCheck})})}]}},OpenAppDeviceAction:{entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:r.UserInteractionRequired.None,step:g.signTransactionDAStateSteps.OPEN_APP})}),invoke:{id:"openAppStateMachine",src:"openAppStateMachine",input:()=>({appName:u.APP_NAME}),onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>({...e.snapshot.context.intermediateValue,step:g.signTransactionDAStateSteps.OPEN_APP})})},onDone:{target:"OpenAppResultCheck",actions:(0,n.assign)({_internalState:({event:e,context:t})=>e.output.caseOf({Right:()=>t._internalState,Left:i=>({...t._internalState,error:i})})})}}},OpenAppResultCheck:{always:[{target:"GetAppConfig",guard:"noInternalError"},{target:"Error"}]},GetAppConfig:{entry:(0,n.assign)({intermediateValue:()=>({requiredUserInteraction:r.UserInteractionRequired.None,step:g.signTransactionDAStateSteps.GET_APP_CONFIG})}),invoke:{id:"getAppConfig",src:"getAppConfig",onDone:{target:"GetAppConfigResultCheck",actions:(0,n.assign)({_internalState:({event:e,context:t})=>(0,r.isSuccessCommandResult)(e.output)?{...t._internalState,appConfig:e.output.data}:{...t._internalState,error:e.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetAppConfigResultCheck:{always:[{target:"CheckTransactionCheckSupported",guard:"noInternalError"},{target:"Error"}]},CheckTransactionCheckSupported:{always:[{target:"TxCheck",guard:"isTransactionChecksSupported"},{target:"CheckGenericClearSignSupported"}]},TxCheck:{invoke:{id:"transactionCheckStateMachine",src:"transactionCheckStateMachine",input:({context:e})=>({appConfig:e._internalState.appConfig,derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,contextModule:e.input.contextModule,serializedForTxCheck:e._internalState.serializedForTxCheck}),onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"CheckGenericClearSignSupported",actions:(0,n.assign)({_internalState:({event:e,context:t})=>e.output.caseOf({Right:({transactionChecksEnabled:i})=>({...t._internalState,appConfig:{...t._internalState.appConfig,transactionChecksEnabled:i,transactionChecksOptIn:!0}}),Left:()=>t._internalState})})}}},CheckGenericClearSignSupported:{always:[{target:"ResolveSigningRoute",guard:(0,n.and)(["noInternalError","isGenericClearSignAvailable"])},{target:"BasicClearSign",guard:"noInternalError"},{target:"Error"}]},ResolveSigningRoute:{invoke:{id:"resolveSigningRoute",src:"resolveSigningRoute",input:({context:e})=>({messageBytes:e._internalState.messageBytes}),onDone:{target:"CheckSigningRoute",actions:(0,n.assign)({_internalState:({event:e,context:t})=>({...t._internalState,basicFlowRuleId:e.output})})},onError:{target:"GenericClearSign"}}},CheckSigningRoute:{always:[{target:"BasicClearSign",guard:"hasBasicFlowRule",actions:({context:e})=>p.info("[ClearSign] basic-flow rule matched; skipping generic clear-sign",{data:{rule:e._internalState.basicFlowRuleId}})},{target:"GenericClearSign"}]},GenericClearSign:{invoke:{id:"provisionGenericClearSignStateMachine",src:"provisionGenericClearSignStateMachine",input:({context:e})=>({derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,contextModule:e.input.contextModule}),onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"CheckGenericClearSignResult",actions:(0,n.assign)({_internalState:({event:e,context:t})=>e.output.caseOf({Right:i=>({...t._internalState,clearSignPrepared:i.status==="prepared",unrecognizedProgramIds:i.unrecognizedProgramIds,staleDescriptor:i.staleDescriptor}),Left:i=>({...t._internalState,error:i})})})},onError:{target:"CheckTxCheckReprovision",actions:({event:e})=>p.info("[ClearSign] generic clear-sign threw; falling back to legacy",{data:{error:String(e.error)}})}}},CheckGenericClearSignResult:{always:[{target:"GenericTerminalSign",guard:(0,n.and)(["noInternalError","isClearSignPrepared"])},{target:"CheckTxCheckReprovision",guard:"noInternalError"},{target:"Error"}]},GenericTerminalSign:{invoke:{id:"signGenericClearSignStateMachine",src:"signGenericClearSignStateMachine",input:({context:e})=>{const{rpcUrl:t,fetchBlockhash:i}=m(e);return{derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,rpcUrl:t,fetchBlockhash:i,userInputType:e.input.transactionOptions?.transactionResolutionContext?.userInputType,blockhashService:e.input.blockhashService}},onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"CheckGenericTerminalSignResult",actions:(0,n.assign)({_internalState:({event:e,context:t})=>e.output.caseOf({Right:i=>i==="degraded"?t._internalState:{...t._internalState,signature:i},Left:i=>({...t._internalState,error:i})})})}}},CheckGenericTerminalSignResult:{always:[{target:"Report",guard:"hasSignature"},{target:"CheckTxCheckReprovision",guard:"noInternalError"},{target:"Report"}]},CheckTxCheckReprovision:{always:[{target:"TxCheckReprovision",guard:"isTransactionChecksSupported"},{target:"BasicClearSign"}]},TxCheckReprovision:{invoke:{id:"transactionCheckReprovisionStateMachine",src:"transactionCheckStateMachine",input:({context:e})=>({appConfig:e._internalState.appConfig,derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,contextModule:e.input.contextModule,serializedForTxCheck:e._internalState.serializedForTxCheck}),onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"BasicClearSign"}}},BasicClearSign:{invoke:{id:"provisionBasicClearSignStateMachine",src:"provisionBasicClearSignStateMachine",input:({context:e})=>({derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,contextModule:e.input.contextModule,appConfig:e._internalState.appConfig,rpcUrl:y(e.input),resolutionContext:e.input.transactionOptions?.transactionResolutionContext}),onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"Report"},onError:{target:"Report"}}},Report:{invoke:{src:"reportSign",input:({context:e})=>{const t=a.getDeviceSessionState(),i=t.sessionStateType!==r.DeviceSessionStateType.Connected?t.firmwareVersion?.os??null:null;return{isBlindSign:e._internalState.basicFlowRuleId===null&&e._internalState.signature===null&&e._internalState.error===null,messageBytes:e._internalState.messageBytes,unrecognizedProgramIds:e._internalState.unrecognizedProgramIds,staleDescriptor:e._internalState.staleDescriptor,contextModule:e.input.contextModule,signerAppVersion:e._internalState.appConfig.version,deviceModelId:t.deviceModelId,deviceVersion:i,loggerFactory:c}},onDone:[{target:"SignTransactionResultCheck",guard:"hasSignature"},{target:"Error",guard:({context:e})=>e._internalState.error!==null},{target:"BasicTerminalSign"}],onError:[{target:"SignTransactionResultCheck",guard:"hasSignature"},{target:"Error",guard:({context:e})=>e._internalState.error!==null},{target:"BasicTerminalSign"}]}},BasicTerminalSign:{invoke:{id:"signBasicClearSignStateMachine",src:"signBasicClearSignStateMachine",input:({context:e})=>{const{rpcUrl:t,fetchBlockhash:i}=m(e);return{derivationPath:e.input.derivationPath,transaction:e._internalState.messageBytes,rpcUrl:t,fetchBlockhash:i,userInputType:e.input.transactionOptions?.transactionResolutionContext?.userInputType,blockhashService:e.input.blockhashService}},onSnapshot:{actions:(0,n.assign)({intermediateValue:({event:e})=>e.snapshot.context.intermediateValue})},onDone:{target:"SignTransactionResultCheck",actions:(0,n.assign)({_internalState:({event:e,context:t})=>e.output.caseOf({Right:i=>({...t._internalState,signature:i}),Left:i=>({...t._internalState,error:i})})})}}},SignTransactionResultCheck:{always:[{guard:"noInternalError",target:"Success"},{target:"Error"}]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.signature?(0,C.Right)(e._internalState.signature):(0,C.Left)(e._internalState.error||new r.UnknownDAError("No error or signature available"))})}extractDependencies(a){return{normalizeTransaction:async()=>{try{return new _.TransactionInputNormaliser().normalize(this.input.transaction)}catch(c){return this.getLoggerFactory(a)("NormalizeTransaction").warn("[normalizeTransaction] format detection failed; treating input as message bytes",{data:{error:String(c)}}),{messageBytes:this.input.transaction,serializedForTxCheck:void 0}}},getAppConfig:async()=>a.sendCommand(new v.GetAppConfigurationCommand),reportSign:async c=>new I.SolanaSigningReportTask(c.input).run(),resolveSigningRoute:async c=>{try{const p=await new P.TransactionParser().parse(c.input.messageBytes).run();if(p.isLeft())return null;const h=p.unsafeCoerce().message,d=[...new Set(h.compiledInstructions.map(e=>h.allKeys[e.programIdIndex]?.toBase58()))].filter(e=>e!==void 0&&e!==u.COMPUTE_BUDGET_PROGRAM_ID),m=await(0,A.resolveBasicFlowRules)(this.input.contextModule,d);return new R.GenericFlowRouter(m,{leadingAllowed:[u.COMPUTE_BUDGET_PROGRAM_ID]}).match(p.unsafeCoerce())}catch(p){return this.getLoggerFactory(a)("ResolveSigningRoute").warn("[resolveSigningRoute] failed; keeping the generic clear-sign path",{data:{error:String(p)}}),null}}}}}0&&(module.exports={SignTransactionDeviceAction});
|
|
2
2
|
//# sourceMappingURL=SignTransactionDeviceAction.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/device-action/SignTransactionDeviceAction.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type CommandResult,\n type DeviceActionStateMachine,\n DeviceSessionStateType,\n type InternalApi,\n isSuccessCommandResult,\n OpenAppDeviceAction,\n type StateMachineTypes,\n UnknownDAError,\n UserInteractionRequired,\n XStateDeviceAction,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { and, assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type SignTransactionDAError,\n type SignTransactionDAInput,\n type SignTransactionDAIntermediateValue,\n type SignTransactionDAInternalState,\n type SignTransactionDAOutput,\n signTransactionDAStateSteps,\n} from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { type AppConfiguration } from \"@api/model/AppConfiguration\";\nimport { GetAppConfigurationCommand } from \"@internal/app-binder/command/GetAppConfigurationCommand\";\nimport { type SolanaAppErrorCodes } from \"@internal/app-binder/command/utils/SolanaApplicationErrors\";\nimport { APP_NAME } from \"@internal/app-binder/constants\";\nimport {\n type NormalizedTransactionInput,\n TransactionInputNormaliser,\n} from \"@internal/app-binder/services/TransactionInputNormaliser\";\nimport {\n isSolanaSignerFeatureSupported,\n type SolanaSignerFeaturesNames,\n} from \"@internal/app-binder/SolanaApplicationResolver\";\nimport {\n SolanaSigningReportTask,\n type SolanaSigningReportTaskArgs,\n} from \"@internal/app-binder/task/SolanaSigningReportTask\";\n\nimport { ProvisionBasicClearSignDeviceAction } from \"./ProvisionBasicClearSignDeviceAction\";\nimport { ProvisionGenericClearSignDeviceAction } from \"./ProvisionGenericClearSignDeviceAction\";\nimport { ProvisionTransactionCheckDeviceAction } from \"./ProvisionTransactionCheckDeviceAction\";\nimport { SignBasicClearSignDeviceAction } from \"./SignBasicClearSignDeviceAction\";\nimport { SignGenericClearSignDeviceAction } from \"./SignGenericClearSignDeviceAction\";\n\n/**\n * Per-sign `transactionOptions.solanaRPCURL` overrides the builder default\n * (`input.solanaRPCURL`) for inspection and delayed signing.\n */\nfunction resolveSolanaRpcUrl(\n input: SignTransactionDAInput,\n): string | undefined {\n return input.transactionOptions?.solanaRPCURL ?? input.solanaRPCURL;\n}\n\nexport type MachineDependencies = {\n readonly normalizeTransaction: () => Promise<NormalizedTransactionInput>;\n readonly getAppConfig: () => Promise<\n CommandResult<AppConfiguration, SolanaAppErrorCodes>\n >;\n readonly reportSign: (arg0: {\n input: SolanaSigningReportTaskArgs;\n }) => Promise<void>;\n};\n\nexport class SignTransactionDeviceAction extends XStateDeviceAction<\n SignTransactionDAOutput,\n SignTransactionDAInput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue,\n SignTransactionDAInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n SignTransactionDAOutput,\n SignTransactionDAInput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue,\n SignTransactionDAInternalState\n > {\n type types = StateMachineTypes<\n SignTransactionDAOutput,\n SignTransactionDAInput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue,\n SignTransactionDAInternalState\n >;\n\n const { normalizeTransaction, getAppConfig, reportSign } =\n this.extractDependencies(internalApi);\n\n const loggerFactory = this.getLoggerFactory(internalApi);\n const logger = loggerFactory(\"SignTransactionDeviceAction\");\n\n const disabledFeaturesSet:\n | ReadonlySet<SolanaSignerFeaturesNames>\n | undefined = this.input.disabledFeatures\n ? new Set(this.input.disabledFeatures)\n : undefined;\n\n const isSupported = (\n feature: SolanaSignerFeaturesNames,\n appConfig: AppConfiguration,\n ): boolean =>\n isSolanaSignerFeatureSupported(\n internalApi,\n feature,\n appConfig,\n disabledFeaturesSet,\n );\n\n // Blockhash refresh is opt-in and shared by both terminal-sign machines:\n // only when `delayed: true` is requested, a blockhash source exists, and\n // the app supports delayed signing. When it isn't allowed we withhold the\n // source so the signing machine signs the original transaction.\n //\n // Template-based swaps (LiFi, etc.) always sign with the original blockhash:\n // CAL-provided e016 descriptors are computed for the original transaction, so\n // refreshing the blockhash would invalidate them and make the Exchange app\n // reject the sign with a descriptor-mismatch error.\n const resolveRefreshSource = (\n context: types[\"context\"],\n ): {\n rpcUrl: string | undefined;\n fetchBlockhash: (() => Promise<Uint8Array>) | undefined;\n } => {\n const rpcUrl = resolveSolanaRpcUrl(context.input);\n const fetchBlockhash = context.input.transactionOptions?.fetchBlockhash;\n const isTemplateSwap =\n !!context.input.transactionOptions?.transactionResolutionContext\n ?.templateId;\n const refreshBlockhash =\n !isTemplateSwap &&\n context.input.transactionOptions?.delayed === true &&\n !!(rpcUrl || fetchBlockhash) &&\n isSupported(\"delayedSigning\", context._internalState.appConfig!);\n return {\n rpcUrl: refreshBlockhash ? rpcUrl : undefined,\n fetchBlockhash: refreshBlockhash ? fetchBlockhash : undefined,\n };\n };\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n normalizeTransaction: fromPromise(normalizeTransaction),\n reportSign: fromPromise(reportSign),\n openAppStateMachine: new OpenAppDeviceAction({\n input: { appName: APP_NAME },\n }).makeStateMachine(internalApi),\n getAppConfig: fromPromise(getAppConfig),\n transactionCheckStateMachine: new ProvisionTransactionCheckDeviceAction(\n {\n input: {\n derivationPath: this.input.derivationPath,\n transaction: this.input.transaction,\n contextModule: this.input.contextModule,\n },\n loggerFactory: this.getLoggerFactory(internalApi),\n },\n ).makeStateMachine(internalApi),\n provisionGenericClearSignStateMachine:\n new ProvisionGenericClearSignDeviceAction({\n input: {\n derivationPath: this.input.derivationPath,\n transaction: this.input.transaction,\n contextModule: this.input.contextModule,\n },\n loggerFactory: this.getLoggerFactory(internalApi),\n }).makeStateMachine(internalApi),\n provisionBasicClearSignStateMachine:\n new ProvisionBasicClearSignDeviceAction({\n // `appConfig` is unknown at construction; it is supplied at invoke\n // time (see the BasicClearSign state input below).\n input: {\n derivationPath: this.input.derivationPath,\n transaction: this.input.transaction,\n contextModule: this.input.contextModule,\n },\n loggerFactory: this.getLoggerFactory(internalApi),\n }).makeStateMachine(internalApi),\n signGenericClearSignStateMachine: new SignGenericClearSignDeviceAction({\n input: {\n derivationPath: this.input.derivationPath,\n transaction: this.input.transaction,\n },\n loggerFactory: this.getLoggerFactory(internalApi),\n }).makeStateMachine(internalApi),\n signBasicClearSignStateMachine: new SignBasicClearSignDeviceAction({\n input: {\n derivationPath: this.input.derivationPath,\n transaction: this.input.transaction,\n },\n loggerFactory: this.getLoggerFactory(internalApi),\n }).makeStateMachine(internalApi),\n },\n guards: {\n noInternalError: ({ context }) => context._internalState.error === null,\n skipOpenApp: ({ context }) =>\n context.input.transactionOptions?.skipOpenApp || false,\n isTransactionChecksSupported: ({ context }) =>\n isSupported(\"transactionChecks\", context._internalState.appConfig!),\n // Generic clear-signing terminates via SIGN MESSAGE DELAYED (0x09) on\n // the original message, so it only needs the capability bit \u2014 no RPC /\n // blockhash prerequisite.\n isGenericClearSignAvailable: ({ context }) =>\n isSupported(\"genericClearSign\", context._internalState.appConfig!),\n // Generic clear-sign child streamed + finalized the descriptors (its\n // Right(\"prepared\") outcome was folded into the context by the\n // GenericClearSign onDone).\n isClearSignPrepared: ({ context }) =>\n context._internalState.clearSignPrepared,\n hasSignature: ({ context }) =>\n context._internalState.signature !== null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\n _.event[\"error\"] instanceof Error\n ? _.event[\"error\"].message\n : String(_.event[\"error\"]),\n ),\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QGUCWUB2AVATgQw1jwGMAXVAewwBEwA3VYsAQTMowDoBJDVcvADbJSeUmADEAbQAMAXUSgADhVh92CkAA9EARgDsAZg4AOAJzSAbAYAsOgKymdN08YA0IAJ67LxjnbvWxjoW-kGGxgC+Ee5omLgERGxUtAxMrORU3Lz8QiJiUjrySCDKqhkYGtoI+kZmljb2js5unojmRgbS1haG0o5OllEx6Nj4hCTlKYwsSZwA8opgGMyKilNps+IQVGAcqBh0FADWuxSLy6vComAAsiQAFvtgMkVKKmpUlYh6dgBMHL8bJ0LKY7AZOr87O4vAhjHpTCZfkEDHo+nprL8ekMQLFRgkJux1jNyhwFksVooAEpwACuAlIAGF7mBiEcpHINKUPhVilUdL9gn5TCjfr9rNJ+X8WjDzAi9AKDGLwb94RZrNjcfFxrMiel2KTzhTqbA6YzmayCq8Su9yl9qgKLEKRWKJZCkdDEEE-NIffLAX8LPUNSMtYlJvRpnrMgBxMCkCkMqgAM3QWx2ewOx12MHjq0TGBTUBenJt6l5uj9JmsBjhxjhdn0pg91S61gB1kCPT0aosxiRwbiYzDhIjGxJsdzinzhfEYBwOAoOA4igEoiTi4Athwcwnk+hi8Uubby9VK8Zq7X643m78fRwfT7+fCxQ2B3jteHUsT9RPdwX0MappMiybIHm8ZRlqAVQCuYHAWJClj8qYSpQq0LZ6HoHA2D2PpwuCphvqGBLJKO34xnGf6FoB9LARakiFCWEGfCeMHSHBCEWEhKHNt2dj3ghdh9FYgLGHYhFDsRNCkVGnC-nme5QNRZogVIvxWkekFaIgrHsYJnG-Mh1aoTCDQcKYvG9sYaIuJE0Q4iGEk6tJ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yGVzGosx0yyehInWQYehCJtkdkZn8YO0Soh2QwBQCAcANDnIls5OpI06ZVAALQWGbLC+8D4kXIrVBY0ZV9OA8DUDki6cz-pVAxM2HQlg2I1hmtIES61Bn2WSSMyWJIyQXDWOCzSkLNZ2EdICasAs-imIMKCAq-g-ABHgv0Wwok0X0v1Iyo0tIaKxTxVC7wFL7z2EEsEUWcNuzQwlMKjewozDNJ0JKll5FJzTnQIqu0OhxSYQbKLLogJ4agleWhYlxKTB1iaYZDsARDk0uGWCsZZrKIATlcpVkVqTw6GFP7FmoIBQrTWToIllg+LmRtaiTmqJlQmuDZwfaMUQJHR4FGsaYonAg1yhCBs2VGapv5feFm-K4lOA3nmjFdUDrFu+uGstAMDJmA4MS8GQRRSKnMgVbKZl4Z9H5KKJEgQO2nOlgQzxH8lYU0gP2qoUc+JjvZhKZC8E4VoX6Iw5EfY4nVmNUkwNJy0n21TvYzAO7EA1jWdQn4GEzD6HlAVOEJgwS3lwvG9hd7jlINqjYyRdiZGvpuYEglok+Iit3lYfoKa0ImzMsBroyF9BxOXWkjJPVslCBGG+hA-gGz3lncLMUBlXUwnhm2Qx0SNrBHMtS0FD7oO90mZckCVH4J-DMgKeUIQwHswKvoLCeyJQbXgvKYj0GaTECYLAeAiG6kLPlJhTEgR5QNxVMxz0oo-AM26PBYI-KzGqZcgAUTajgET+mAQ7OMwKUzzYlqYXDhytZ6q8Lqj+UAA */\n id: \"SignTransactionDeviceAction\",\n initial: \"NormalizeTransaction\",\n context: ({ input }) => ({\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: signTransactionDAStateSteps.OPEN_APP,\n },\n _internalState: {\n error: null,\n signature: null,\n appConfig: null,\n messageBytes: this.input.transaction,\n serializedForTxCheck: undefined,\n clearSignPrepared: false,\n unrecognizedProgramIds: [],\n staleDescriptor: false,\n },\n }),\n states: {\n NormalizeTransaction: {\n // Emit the correct first step immediately so the snapshot produced\n // while the actor runs already reflects where we are headed.\n entry: assign({\n intermediateValue: ({ context }) => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: context.input.transactionOptions?.skipOpenApp\n ? signTransactionDAStateSteps.GET_APP_CONFIG\n : signTransactionDAStateSteps.OPEN_APP,\n }),\n }),\n invoke: {\n id: \"normalizeTransaction\",\n src: \"normalizeTransaction\",\n onDone: [\n {\n target: \"GetAppConfig\",\n guard: \"skipOpenApp\",\n actions: assign({\n _internalState: ({ event, context }) => ({\n ...context._internalState,\n messageBytes: event.output.messageBytes,\n serializedForTxCheck: event.output.serializedForTxCheck,\n }),\n }),\n },\n {\n target: \"OpenAppDeviceAction\",\n actions: assign({\n _internalState: ({ event, context }) => ({\n ...context._internalState,\n messageBytes: event.output.messageBytes,\n serializedForTxCheck: event.output.serializedForTxCheck,\n }),\n }),\n },\n ],\n },\n },\n OpenAppDeviceAction: {\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: signTransactionDAStateSteps.OPEN_APP,\n }),\n }),\n invoke: {\n id: \"openAppStateMachine\",\n src: \"openAppStateMachine\",\n input: () => ({ appName: APP_NAME }),\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) => ({\n ...event.snapshot.context.intermediateValue,\n step: signTransactionDAStateSteps.OPEN_APP,\n }),\n }),\n },\n onDone: {\n target: \"OpenAppResultCheck\",\n actions: assign({\n _internalState: ({ event, context }) =>\n event.output.caseOf({\n Right: () => context._internalState,\n Left: (error) => ({\n ...context._internalState,\n error,\n }),\n }),\n }),\n },\n },\n },\n OpenAppResultCheck: {\n always: [\n { target: \"GetAppConfig\", guard: \"noInternalError\" },\n { target: \"Error\" },\n ],\n },\n GetAppConfig: {\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: signTransactionDAStateSteps.GET_APP_CONFIG,\n }),\n }),\n invoke: {\n id: \"getAppConfig\",\n src: \"getAppConfig\",\n onDone: {\n target: \"GetAppConfigResultCheck\",\n actions: assign({\n _internalState: ({ event, context }) =>\n isSuccessCommandResult(event.output)\n ? {\n ...context._internalState,\n appConfig: event.output.data,\n }\n : { ...context._internalState, error: event.output.error },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetAppConfigResultCheck: {\n always: [\n {\n target: \"CheckTransactionCheckSupported\",\n guard: \"noInternalError\",\n },\n { target: \"Error\" },\n ],\n },\n CheckTransactionCheckSupported: {\n always: [\n // Feature supported: delegate opt-in + provide to the child machine.\n {\n target: \"TxCheck\",\n guard: \"isTransactionChecksSupported\",\n },\n // Feature not supported: skip the child machine entirely.\n { target: \"CheckGenericClearSignSupported\" },\n ],\n },\n // Web3-checks child machine: handles opt-in prompt and scan-descriptor\n // provisioning. Only reached when the feature is supported; opt-in and\n // provide decisions are made internally.\n TxCheck: {\n invoke: {\n id: \"transactionCheckStateMachine\",\n src: \"transactionCheckStateMachine\",\n // The scan descriptor must hash the exact message the device\n // reviews, i.e. the original bytes (blockhash included).\n input: ({ context }) => ({\n appConfig: context._internalState.appConfig!,\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n contextModule: context.input.contextModule,\n serializedForTxCheck: context._internalState.serializedForTxCheck,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n // The opt-in has now been answered (or skipped): record the outcome\n // so the re-provision after a generic fallback never prompts again.\n onDone: {\n target: \"CheckGenericClearSignSupported\",\n actions: assign({\n _internalState: ({ event, context }) =>\n event.output.caseOf<SignTransactionDAInternalState>({\n Right: ({ transactionChecksEnabled }) => ({\n ...context._internalState,\n appConfig: {\n ...context._internalState.appConfig!,\n transactionChecksEnabled,\n transactionChecksOptIn: true,\n },\n }),\n Left: () => context._internalState,\n }),\n }),\n },\n },\n },\n CheckGenericClearSignSupported: {\n always: [\n {\n target: \"GenericClearSign\",\n guard: and([\"noInternalError\", \"isGenericClearSignAvailable\"]),\n },\n { target: \"BasicClearSign\", guard: \"noInternalError\" },\n { target: \"Error\" },\n ],\n },\n // Generic clear-sign child: streams + validates the descriptors (no\n // signing, no UI). `\"prepared\"` runs the generic terminal sign;\n // `\"degraded\"` falls back to legacy basic provisioning.\n GenericClearSign: {\n invoke: {\n id: \"provisionGenericClearSignStateMachine\",\n src: \"provisionGenericClearSignStateMachine\",\n input: ({ context }) => ({\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n contextModule: context.input.contextModule,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n // Fold the child's Either output into the context here (where\n // xstate types `event.output`), then branch on the context in\n // CheckGenericClearSignResult \u2014 no event cast in the guards.\n onDone: {\n target: \"CheckGenericClearSignResult\",\n actions: assign({\n _internalState: ({ event, context }) =>\n event.output.caseOf<SignTransactionDAInternalState>({\n Right: (outcome) => ({\n ...context._internalState,\n clearSignPrepared: outcome.status === \"prepared\",\n unrecognizedProgramIds: outcome.unrecognizedProgramIds,\n staleDescriptor: outcome.staleDescriptor,\n }),\n // Left never occurs (the prepare phase has no UI), but stay\n // defensive and surface it.\n Left: (error) => ({ ...context._internalState, error }),\n }),\n }),\n },\n onError: {\n target: \"CheckTxCheckReprovision\",\n actions: ({ event }) =>\n logger.info(\n \"[ClearSign] generic clear-sign threw; falling back to legacy\",\n { data: { error: String(event.error) } },\n ),\n },\n },\n },\n CheckGenericClearSignResult: {\n always: [\n // Prepared: run the generic terminal sign; report fires after.\n {\n target: \"GenericTerminalSign\",\n guard: and([\"noInternalError\", \"isClearSignPrepared\"]),\n },\n // Degraded (Right(\"degraded\")): fall back to the legacy path.\n { target: \"CheckTxCheckReprovision\", guard: \"noInternalError\" },\n // Defensive: surface an unexpected Left.\n { target: \"Error\" },\n ],\n },\n // Generic terminal sign: prompt + best-effort blockhash refresh +\n // delayed sign. A user cancel / signing failure surfaces; a non-cancel\n // prompt failure resolves to `\"degraded\"` and falls back to the legacy\n // basic path.\n GenericTerminalSign: {\n invoke: {\n id: \"signGenericClearSignStateMachine\",\n src: \"signGenericClearSignStateMachine\",\n input: ({ context }) => {\n const { rpcUrl, fetchBlockhash } = resolveRefreshSource(context);\n return {\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n rpcUrl,\n fetchBlockhash,\n userInputType:\n context.input.transactionOptions?.transactionResolutionContext\n ?.userInputType,\n blockhashService: context.input.blockhashService,\n };\n },\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckGenericTerminalSignResult\",\n actions: assign({\n _internalState: ({ event, context }) =>\n event.output.caseOf<SignTransactionDAInternalState>({\n // Right(Signature) on success; Right(\"degraded\") when the\n // prompt failed for a non-cancel reason (leave signature\n // unset so the result check falls back to legacy).\n Right: (signatureOrDegraded) =>\n signatureOrDegraded === \"degraded\"\n ? context._internalState\n : {\n ...context._internalState,\n signature: signatureOrDegraded,\n },\n // Left: the user cancelled or signing failed; surface it.\n Left: (error) => ({ ...context._internalState, error }),\n }),\n }),\n },\n },\n },\n CheckGenericTerminalSignResult: {\n always: [\n // Signed: report (isBlindSign: false) then surface result.\n { target: \"Report\", guard: \"hasSignature\" },\n // Degraded (no signature, no error): fall back to the legacy path.\n { target: \"CheckTxCheckReprovision\", guard: \"noInternalError\" },\n // User cancel / signing failure: report (isBlindSign: false) then surface error.\n { target: \"Report\" },\n ],\n },\n // A failed generic clear-sign attempt wipes the device's provisioned\n // context, including the tx-check descriptor sent in TxCheck. Provide\n // it again before falling back to the basic path. The opt-in was\n // already answered in TxCheck, so this pass never prompts.\n CheckTxCheckReprovision: {\n always: [\n {\n target: \"TxCheckReprovision\",\n guard: \"isTransactionChecksSupported\",\n },\n { target: \"BasicClearSign\" },\n ],\n },\n TxCheckReprovision: {\n invoke: {\n id: \"transactionCheckReprovisionStateMachine\",\n src: \"transactionCheckStateMachine\",\n input: ({ context }) => ({\n appConfig: context._internalState.appConfig!,\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n contextModule: context.input.contextModule,\n serializedForTxCheck: context._internalState.serializedForTxCheck,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n onDone: { target: \"BasicClearSign\" },\n },\n },\n // Legacy SPL / token provisioning child (best-effort, never signs). It\n // streams descriptors; control always proceeds to the basic terminal\n // sign.\n BasicClearSign: {\n invoke: {\n id: \"provisionBasicClearSignStateMachine\",\n src: \"provisionBasicClearSignStateMachine\",\n input: ({ context }) => ({\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n contextModule: context.input.contextModule,\n appConfig: context._internalState.appConfig!,\n rpcUrl: resolveSolanaRpcUrl(context.input),\n resolutionContext:\n context.input.transactionOptions?.transactionResolutionContext,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n onDone: { target: \"Report\" },\n onError: { target: \"Report\" },\n },\n },\n // Single report state for all paths.\n // isBlindSign is derived from context: false when a signature or error is\n // already set (clear-sign path \u2014 success or cancel), true otherwise\n // (basic/legacy path, neither has run yet).\n // Routes to: SignTransactionResultCheck (clear-sign success),\n // Error (clear-sign cancel/failure), or\n // BasicTerminalSign (basic path).\n Report: {\n invoke: {\n src: \"reportSign\",\n input: ({ context }) => {\n const sessionState = internalApi.getDeviceSessionState();\n const deviceVersion =\n sessionState.sessionStateType !==\n DeviceSessionStateType.Connected\n ? (sessionState.firmwareVersion?.os ?? null)\n : null;\n return {\n isBlindSign:\n context._internalState.signature === null &&\n context._internalState.error === null,\n messageBytes: context._internalState.messageBytes,\n unrecognizedProgramIds:\n context._internalState.unrecognizedProgramIds,\n staleDescriptor: context._internalState.staleDescriptor,\n contextModule: context.input.contextModule,\n signerAppVersion: context._internalState.appConfig!.version,\n deviceModelId: sessionState.deviceModelId,\n deviceVersion,\n loggerFactory,\n } satisfies SolanaSigningReportTaskArgs;\n },\n onDone: [\n {\n target: \"SignTransactionResultCheck\",\n guard: \"hasSignature\",\n },\n {\n target: \"Error\",\n guard: ({ context }) => context._internalState.error !== null,\n },\n { target: \"BasicTerminalSign\" },\n ],\n onError: [\n {\n target: \"SignTransactionResultCheck\",\n guard: \"hasSignature\",\n },\n {\n target: \"Error\",\n guard: ({ context }) => context._internalState.error !== null,\n },\n { target: \"BasicTerminalSign\" },\n ],\n },\n },\n // Basic terminal sign: the legacy preview/one-shot path. It decides\n // delayed-vs-one-shot from the blockhash source (opt-in refresh).\n BasicTerminalSign: {\n invoke: {\n id: \"signBasicClearSignStateMachine\",\n src: \"signBasicClearSignStateMachine\",\n input: ({ context }) => {\n const { rpcUrl, fetchBlockhash } = resolveRefreshSource(context);\n return {\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n rpcUrl,\n fetchBlockhash,\n userInputType:\n context.input.transactionOptions?.transactionResolutionContext\n ?.userInputType,\n blockhashService: context.input.blockhashService,\n };\n },\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"SignTransactionResultCheck\",\n actions: assign({\n _internalState: ({ event, context }) =>\n event.output.caseOf<SignTransactionDAInternalState>({\n Right: (signature) => ({\n ...context._internalState,\n signature,\n }),\n Left: (error) => ({ ...context._internalState, error }),\n }),\n }),\n },\n },\n },\n SignTransactionResultCheck: {\n always: [\n { guard: \"noInternalError\", target: \"Success\" },\n { target: \"Error\" },\n ],\n },\n Success: { type: \"final\" },\n Error: { type: \"final\" },\n },\n output: ({ context }) =>\n context._internalState.signature\n ? Right(context._internalState.signature)\n : Left(\n context._internalState.error ||\n new UnknownDAError(`No error or signature available`),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const normalizeTransaction = async () => {\n try {\n return new TransactionInputNormaliser().normalize(\n this.input.transaction,\n );\n } catch (error) {\n this.getLoggerFactory(internalApi)(\"NormalizeTransaction\").warn(\n \"[normalizeTransaction] format detection failed; treating input as message bytes\",\n { data: { error: String(error) } },\n );\n return {\n messageBytes: this.input.transaction,\n serializedForTxCheck: undefined,\n };\n }\n };\n\n const getAppConfig = async () =>\n internalApi.sendCommand(new GetAppConfigurationCommand());\n\n const reportSign = async (arg0: { input: SolanaSigningReportTaskArgs }) =>\n new SolanaSigningReportTask(arg0.input).run();\n\n return {\n normalizeTransaction,\n getAppConfig,\n reportSign,\n };\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAWO,2CACPC,EAA4B,qBAC5BC,EAAgD,kBAEhDC,EAOO,4DAEPC,EAA2C,mEAE3CC,EAAyB,0CACzBC,EAGO,oEACPC,EAGO,0DACPC,EAGO,6DAEPC,EAAoD,iDACpDC,EAAsD,mDACtDC,EAAsD,mDACtDC,EAA+C,4CAC/CC,EAAiD,8CAMjD,SAASC,EACPC,EACoB,CACpB,OAAOA,EAAM,oBAAoB,cAAgBA,EAAM,YACzD,CAYO,MAAMjB,UAAoC,oBAM/C,CACA,iBACEkB,EAOA,CASA,KAAM,CAAE,qBAAAC,EAAsB,aAAAC,EAAc,WAAAC,CAAW,EACrD,KAAK,oBAAoBH,CAAW,EAEhCI,EAAgB,KAAK,iBAAiBJ,CAAW,EACjDK,EAASD,EAAc,6BAA6B,EAEpDE,EAEU,KAAK,MAAM,iBACvB,IAAI,IAAI,KAAK,MAAM,gBAAgB,EACnC,OAEEC,EAAc,CAClBC,EACAC,OAEA,kCACET,EACAQ,EACAC,EACAH,CACF,EAWII,EACJC,GAIG,CACH,MAAMC,EAASd,EAAoBa,EAAQ,KAAK,EAC1CE,EAAiBF,EAAQ,MAAM,oBAAoB,eAInDG,EACJ,CAHA,CAAC,CAACH,EAAQ,MAAM,oBAAoB,8BAChC,YAGJA,EAAQ,MAAM,oBAAoB,UAAY,IAC9C,CAAC,EAAEC,GA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CACF,OAAO,IAAI,6BAA2B,EAAE,UACtC,KAAK,MAAM,WACb,CACF,OAASiB,EAAO,CACd,YAAK,iBAAiBjB,CAAW,EAAE,sBAAsB,EAAE,KACzD,kFACA,CAAE,KAAM,CAAE,MAAO,OAAOiB,CAAK,CAAE,CAAE,CACnC,EACO,CACL,aAAc,KAAK,MAAM,YACzB,qBAAsB,MACxB,CACF,CACF,EAUE,aARmB,SACnBjB,EAAY,YAAY,IAAI,4BAA4B,EAQxD,WANiB,MAAOwB,GACxB,IAAI,0BAAwBA,EAAK,KAAK,EAAE,IAAI,CAM9C,CACF,CACF",
|
|
6
|
-
"names": ["SignTransactionDeviceAction_exports", "__export", "SignTransactionDeviceAction", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_xstate", "import_SignTransactionDeviceActionTypes", "import_GetAppConfigurationCommand", "import_constants", "import_TransactionInputNormaliser", "import_SolanaApplicationResolver", "import_SolanaSigningReportTask", "import_ProvisionBasicClearSignDeviceAction", "import_ProvisionGenericClearSignDeviceAction", "import_ProvisionTransactionCheckDeviceAction", "import_SignBasicClearSignDeviceAction", "import_SignGenericClearSignDeviceAction", "resolveSolanaRpcUrl", "input", "internalApi", "normalizeTransaction", "getAppConfig", "reportSign", "loggerFactory", "logger", "disabledFeaturesSet", "isSupported", "feature", "appConfig", "resolveRefreshSource", "context", "rpcUrl", "fetchBlockhash", "refreshBlockhash", "_", "event", "error", "transactionChecksEnabled", "outcome", "signatureOrDegraded", "sessionState", "deviceVersion", "signature", "arg0"]
|
|
4
|
+
"sourcesContent": ["import {\n type CommandResult,\n type DeviceActionStateMachine,\n DeviceSessionStateType,\n type InternalApi,\n isSuccessCommandResult,\n OpenAppDeviceAction,\n type StateMachineTypes,\n UnknownDAError,\n UserInteractionRequired,\n XStateDeviceAction,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { and, assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type SignTransactionDAError,\n type SignTransactionDAInput,\n type SignTransactionDAIntermediateValue,\n type SignTransactionDAInternalState,\n type SignTransactionDAOutput,\n signTransactionDAStateSteps,\n} from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { type AppConfiguration } from \"@api/model/AppConfiguration\";\nimport { GetAppConfigurationCommand } from \"@internal/app-binder/command/GetAppConfigurationCommand\";\nimport { type SolanaAppErrorCodes } from \"@internal/app-binder/command/utils/SolanaApplicationErrors\";\nimport {\n APP_NAME,\n COMPUTE_BUDGET_PROGRAM_ID,\n} from \"@internal/app-binder/constants\";\nimport { resolveBasicFlowRules } from \"@internal/app-binder/generic-flow-router/basicFlowRules\";\nimport { GenericFlowRouter } from \"@internal/app-binder/generic-flow-router/GenericFlowRouter\";\nimport {\n type NormalizedTransactionInput,\n TransactionInputNormaliser,\n} from \"@internal/app-binder/services/TransactionInputNormaliser\";\nimport { TransactionParser } from \"@internal/app-binder/services/utils/TransactionParser\";\nimport {\n isSolanaSignerFeatureSupported,\n type SolanaSignerFeaturesNames,\n} from \"@internal/app-binder/SolanaApplicationResolver\";\nimport {\n SolanaSigningReportTask,\n type SolanaSigningReportTaskArgs,\n} from \"@internal/app-binder/task/SolanaSigningReportTask\";\n\nimport { ProvisionBasicClearSignDeviceAction } from \"./ProvisionBasicClearSignDeviceAction\";\nimport { ProvisionGenericClearSignDeviceAction } from \"./ProvisionGenericClearSignDeviceAction\";\nimport { ProvisionTransactionCheckDeviceAction } from \"./ProvisionTransactionCheckDeviceAction\";\nimport { SignBasicClearSignDeviceAction } from \"./SignBasicClearSignDeviceAction\";\nimport { SignGenericClearSignDeviceAction } from \"./SignGenericClearSignDeviceAction\";\n\n/**\n * Per-sign `transactionOptions.solanaRPCURL` overrides the builder default\n * (`input.solanaRPCURL`) for inspection and delayed signing.\n */\nfunction resolveSolanaRpcUrl(\n input: SignTransactionDAInput,\n): string | undefined {\n return input.transactionOptions?.solanaRPCURL ?? input.solanaRPCURL;\n}\n\nexport type MachineDependencies = {\n readonly normalizeTransaction: () => Promise<NormalizedTransactionInput>;\n readonly getAppConfig: () => Promise<\n CommandResult<AppConfiguration, SolanaAppErrorCodes>\n >;\n readonly reportSign: (arg0: {\n input: SolanaSigningReportTaskArgs;\n }) => Promise<void>;\n readonly resolveSigningRoute: (arg0: {\n input: { messageBytes: Uint8Array };\n }) => Promise<string | null>;\n};\n\nexport class SignTransactionDeviceAction extends XStateDeviceAction<\n SignTransactionDAOutput,\n SignTransactionDAInput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue,\n SignTransactionDAInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n SignTransactionDAOutput,\n SignTransactionDAInput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue,\n SignTransactionDAInternalState\n > {\n type types = StateMachineTypes<\n SignTransactionDAOutput,\n SignTransactionDAInput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue,\n SignTransactionDAInternalState\n >;\n\n const {\n normalizeTransaction,\n getAppConfig,\n reportSign,\n resolveSigningRoute,\n } = this.extractDependencies(internalApi);\n\n const loggerFactory = this.getLoggerFactory(internalApi);\n const logger = loggerFactory(\"SignTransactionDeviceAction\");\n\n const disabledFeaturesSet:\n | ReadonlySet<SolanaSignerFeaturesNames>\n | undefined = this.input.disabledFeatures\n ? new Set(this.input.disabledFeatures)\n : undefined;\n\n const isSupported = (\n feature: SolanaSignerFeaturesNames,\n appConfig: AppConfiguration,\n ): boolean =>\n isSolanaSignerFeatureSupported(\n internalApi,\n feature,\n appConfig,\n disabledFeaturesSet,\n );\n\n // Blockhash refresh is opt-in and shared by both terminal-sign machines:\n // only when `delayed: true` is requested, a blockhash source exists, and\n // the app supports delayed signing. When it isn't allowed we withhold the\n // source so the signing machine signs the original transaction.\n //\n // Template-based swaps (LiFi, etc.) always sign with the original blockhash:\n // CAL-provided e016 descriptors are computed for the original transaction, so\n // refreshing the blockhash would invalidate them and make the Exchange app\n // reject the sign with a descriptor-mismatch error.\n const resolveRefreshSource = (\n context: types[\"context\"],\n ): {\n rpcUrl: string | undefined;\n fetchBlockhash: (() => Promise<Uint8Array>) | undefined;\n } => {\n const rpcUrl = resolveSolanaRpcUrl(context.input);\n const fetchBlockhash = context.input.transactionOptions?.fetchBlockhash;\n const isTemplateSwap =\n !!context.input.transactionOptions?.transactionResolutionContext\n ?.templateId;\n const refreshBlockhash =\n !isTemplateSwap &&\n context.input.transactionOptions?.delayed === true &&\n !!(rpcUrl || fetchBlockhash) &&\n isSupported(\"delayedSigning\", context._internalState.appConfig!);\n return {\n rpcUrl: refreshBlockhash ? rpcUrl : undefined,\n fetchBlockhash: refreshBlockhash ? fetchBlockhash : undefined,\n };\n };\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n normalizeTransaction: fromPromise(normalizeTransaction),\n reportSign: fromPromise(reportSign),\n resolveSigningRoute: fromPromise(resolveSigningRoute),\n openAppStateMachine: new OpenAppDeviceAction({\n input: { appName: APP_NAME },\n }).makeStateMachine(internalApi),\n getAppConfig: fromPromise(getAppConfig),\n transactionCheckStateMachine: new ProvisionTransactionCheckDeviceAction(\n {\n input: {\n derivationPath: this.input.derivationPath,\n transaction: this.input.transaction,\n contextModule: this.input.contextModule,\n },\n loggerFactory: this.getLoggerFactory(internalApi),\n },\n ).makeStateMachine(internalApi),\n provisionGenericClearSignStateMachine:\n new ProvisionGenericClearSignDeviceAction({\n input: {\n derivationPath: this.input.derivationPath,\n transaction: this.input.transaction,\n contextModule: this.input.contextModule,\n },\n loggerFactory: this.getLoggerFactory(internalApi),\n }).makeStateMachine(internalApi),\n provisionBasicClearSignStateMachine:\n new ProvisionBasicClearSignDeviceAction({\n // `appConfig` is unknown at construction; it is supplied at invoke\n // time (see the BasicClearSign state input below).\n input: {\n derivationPath: this.input.derivationPath,\n transaction: this.input.transaction,\n contextModule: this.input.contextModule,\n },\n loggerFactory: this.getLoggerFactory(internalApi),\n }).makeStateMachine(internalApi),\n signGenericClearSignStateMachine: new SignGenericClearSignDeviceAction({\n input: {\n derivationPath: this.input.derivationPath,\n transaction: this.input.transaction,\n },\n loggerFactory: this.getLoggerFactory(internalApi),\n }).makeStateMachine(internalApi),\n signBasicClearSignStateMachine: new SignBasicClearSignDeviceAction({\n input: {\n derivationPath: this.input.derivationPath,\n transaction: this.input.transaction,\n },\n loggerFactory: this.getLoggerFactory(internalApi),\n }).makeStateMachine(internalApi),\n },\n guards: {\n noInternalError: ({ context }) => context._internalState.error === null,\n skipOpenApp: ({ context }) =>\n context.input.transactionOptions?.skipOpenApp || false,\n isTransactionChecksSupported: ({ context }) =>\n isSupported(\"transactionChecks\", context._internalState.appConfig!),\n // Generic clear-signing terminates via SIGN MESSAGE DELAYED (0x09) on\n // the original message, so it only needs the capability bit \u2014 no RPC /\n // blockhash prerequisite.\n isGenericClearSignAvailable: ({ context }) =>\n isSupported(\"genericClearSign\", context._internalState.appConfig!),\n // Generic clear-sign child streamed + finalized the descriptors (its\n // Right(\"prepared\") outcome was folded into the context by the\n // GenericClearSign onDone).\n isClearSignPrepared: ({ context }) =>\n context._internalState.clearSignPrepared,\n hasSignature: ({ context }) =>\n context._internalState.signature !== null,\n hasBasicFlowRule: ({ context }) =>\n context._internalState.basicFlowRuleId !== null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: new UnknownDAError(\n _.event[\"error\"] instanceof Error\n ? _.event[\"error\"].message\n : String(_.event[\"error\"]),\n ),\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QGUCWUB2AVATgQw1jwGMAXVAewwBEwA3VYsAQTMowDoBJDVcvADbJSeUmADEAbQAMAXUSgADhVh92CkAA9EARgDsAZg4AOAJzSAbAYAsOgKymdN08YA0IAJ67LxjnbvWxjoW-kGGxgC+Ee5omLgERGxUtAxMrORU3Lz8QiJiUjrySCDKqhkYGtoI+kZmljb2js5unojmRgbS1haG0o5OllEx6Nj4hCTlKYw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8lYU0gP2qoUc+JjvZhKZC8E4VoX6Iw5EfY4nVmNUkwNJy0n21TvYzAO7EA1jWdQn4GEzD6HlAVOEJgwS3lwvG9hd7jlINqjYyRdiZGvpuYEglok+Iit3lYfoKa0ImzMsBroyF9BxOXWkjJPVslCBGG+hA-gGz3lncLMUBlXUwnhm2Qx0SNrBHMtS0FD7oO90mZckCVH4J-DMgKeUIQwHswKvoLCeyJQbXgvKYj0GaTECYLAeAiG6kLPlJhTEgR5QNxVMxz0oo-AM26PBYI-KzGqZcgAUTajgET+mAQ7OMwKUzzYlqYXDhytZ6q8Lqj+UAA */\n id: \"SignTransactionDeviceAction\",\n initial: \"NormalizeTransaction\",\n context: ({ input }) => ({\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: signTransactionDAStateSteps.OPEN_APP,\n },\n _internalState: {\n error: null,\n signature: null,\n appConfig: null,\n messageBytes: this.input.transaction,\n serializedForTxCheck: undefined,\n clearSignPrepared: false,\n unrecognizedProgramIds: [],\n staleDescriptor: false,\n basicFlowRuleId: null,\n },\n }),\n states: {\n NormalizeTransaction: {\n // Emit the correct first step immediately so the snapshot produced\n // while the actor runs already reflects where we are headed.\n entry: assign({\n intermediateValue: ({ context }) => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: context.input.transactionOptions?.skipOpenApp\n ? signTransactionDAStateSteps.GET_APP_CONFIG\n : signTransactionDAStateSteps.OPEN_APP,\n }),\n }),\n invoke: {\n id: \"normalizeTransaction\",\n src: \"normalizeTransaction\",\n onDone: [\n {\n target: \"GetAppConfig\",\n guard: \"skipOpenApp\",\n actions: assign({\n _internalState: ({ event, context }) => ({\n ...context._internalState,\n messageBytes: event.output.messageBytes,\n serializedForTxCheck: event.output.serializedForTxCheck,\n }),\n }),\n },\n {\n target: \"OpenAppDeviceAction\",\n actions: assign({\n _internalState: ({ event, context }) => ({\n ...context._internalState,\n messageBytes: event.output.messageBytes,\n serializedForTxCheck: event.output.serializedForTxCheck,\n }),\n }),\n },\n ],\n },\n },\n OpenAppDeviceAction: {\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: signTransactionDAStateSteps.OPEN_APP,\n }),\n }),\n invoke: {\n id: \"openAppStateMachine\",\n src: \"openAppStateMachine\",\n input: () => ({ appName: APP_NAME }),\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) => ({\n ...event.snapshot.context.intermediateValue,\n step: signTransactionDAStateSteps.OPEN_APP,\n }),\n }),\n },\n onDone: {\n target: \"OpenAppResultCheck\",\n actions: assign({\n _internalState: ({ event, context }) =>\n event.output.caseOf({\n Right: () => context._internalState,\n Left: (error) => ({\n ...context._internalState,\n error,\n }),\n }),\n }),\n },\n },\n },\n OpenAppResultCheck: {\n always: [\n { target: \"GetAppConfig\", guard: \"noInternalError\" },\n { target: \"Error\" },\n ],\n },\n GetAppConfig: {\n entry: assign({\n intermediateValue: () => ({\n requiredUserInteraction: UserInteractionRequired.None,\n step: signTransactionDAStateSteps.GET_APP_CONFIG,\n }),\n }),\n invoke: {\n id: \"getAppConfig\",\n src: \"getAppConfig\",\n onDone: {\n target: \"GetAppConfigResultCheck\",\n actions: assign({\n _internalState: ({ event, context }) =>\n isSuccessCommandResult(event.output)\n ? {\n ...context._internalState,\n appConfig: event.output.data,\n }\n : { ...context._internalState, error: event.output.error },\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetAppConfigResultCheck: {\n always: [\n {\n target: \"CheckTransactionCheckSupported\",\n guard: \"noInternalError\",\n },\n { target: \"Error\" },\n ],\n },\n CheckTransactionCheckSupported: {\n always: [\n // Feature supported: delegate opt-in + provide to the child machine.\n {\n target: \"TxCheck\",\n guard: \"isTransactionChecksSupported\",\n },\n // Feature not supported: skip the child machine entirely.\n { target: \"CheckGenericClearSignSupported\" },\n ],\n },\n // Web3-checks child machine: handles opt-in prompt and scan-descriptor\n // provisioning. Only reached when the feature is supported; opt-in and\n // provide decisions are made internally.\n TxCheck: {\n invoke: {\n id: \"transactionCheckStateMachine\",\n src: \"transactionCheckStateMachine\",\n // The scan descriptor must hash the exact message the device\n // reviews, i.e. the original bytes (blockhash included).\n input: ({ context }) => ({\n appConfig: context._internalState.appConfig!,\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n contextModule: context.input.contextModule,\n serializedForTxCheck: context._internalState.serializedForTxCheck,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n // The opt-in has now been answered (or skipped): record the outcome\n // so the re-provision after a generic fallback never prompts again.\n onDone: {\n target: \"CheckGenericClearSignSupported\",\n actions: assign({\n _internalState: ({ event, context }) =>\n event.output.caseOf<SignTransactionDAInternalState>({\n Right: ({ transactionChecksEnabled }) => ({\n ...context._internalState,\n appConfig: {\n ...context._internalState.appConfig!,\n transactionChecksEnabled,\n transactionChecksOptIn: true,\n },\n }),\n Left: () => context._internalState,\n }),\n }),\n },\n },\n },\n CheckGenericClearSignSupported: {\n always: [\n {\n target: \"ResolveSigningRoute\",\n guard: and([\"noInternalError\", \"isGenericClearSignAvailable\"]),\n },\n { target: \"BasicClearSign\", guard: \"noInternalError\" },\n { target: \"Error\" },\n ],\n },\n // Basic-flow rules: a matching transaction skips generic clear-sign\n // and goes straight to the basic flow, where the app parses it\n // natively. Generic never ran, so the tx-check descriptor provided in\n // TxCheck is still in place and no re-provision is needed. The actor\n // never rejects; onError is purely defensive.\n ResolveSigningRoute: {\n invoke: {\n id: \"resolveSigningRoute\",\n src: \"resolveSigningRoute\",\n input: ({ context }) => ({\n messageBytes: context._internalState.messageBytes,\n }),\n onDone: {\n target: \"CheckSigningRoute\",\n actions: assign({\n _internalState: ({ event, context }) => ({\n ...context._internalState,\n basicFlowRuleId: event.output,\n }),\n }),\n },\n onError: { target: \"GenericClearSign\" },\n },\n },\n CheckSigningRoute: {\n always: [\n {\n target: \"BasicClearSign\",\n guard: \"hasBasicFlowRule\",\n actions: ({ context }) =>\n logger.info(\n \"[ClearSign] basic-flow rule matched; skipping generic clear-sign\",\n { data: { rule: context._internalState.basicFlowRuleId } },\n ),\n },\n { target: \"GenericClearSign\" },\n ],\n },\n // Generic clear-sign child: streams + validates the descriptors (no\n // signing, no UI). `\"prepared\"` runs the generic terminal sign;\n // `\"degraded\"` falls back to legacy basic provisioning.\n GenericClearSign: {\n invoke: {\n id: \"provisionGenericClearSignStateMachine\",\n src: \"provisionGenericClearSignStateMachine\",\n input: ({ context }) => ({\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n contextModule: context.input.contextModule,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n // Fold the child's Either output into the context here (where\n // xstate types `event.output`), then branch on the context in\n // CheckGenericClearSignResult \u2014 no event cast in the guards.\n onDone: {\n target: \"CheckGenericClearSignResult\",\n actions: assign({\n _internalState: ({ event, context }) =>\n event.output.caseOf<SignTransactionDAInternalState>({\n Right: (outcome) => ({\n ...context._internalState,\n clearSignPrepared: outcome.status === \"prepared\",\n unrecognizedProgramIds: outcome.unrecognizedProgramIds,\n staleDescriptor: outcome.staleDescriptor,\n }),\n // Left never occurs (the prepare phase has no UI), but stay\n // defensive and surface it.\n Left: (error) => ({ ...context._internalState, error }),\n }),\n }),\n },\n onError: {\n target: \"CheckTxCheckReprovision\",\n actions: ({ event }) =>\n logger.info(\n \"[ClearSign] generic clear-sign threw; falling back to legacy\",\n { data: { error: String(event.error) } },\n ),\n },\n },\n },\n CheckGenericClearSignResult: {\n always: [\n // Prepared: run the generic terminal sign; report fires after.\n {\n target: \"GenericTerminalSign\",\n guard: and([\"noInternalError\", \"isClearSignPrepared\"]),\n },\n // Degraded (Right(\"degraded\")): fall back to the legacy path.\n { target: \"CheckTxCheckReprovision\", guard: \"noInternalError\" },\n // Defensive: surface an unexpected Left.\n { target: \"Error\" },\n ],\n },\n // Generic terminal sign: prompt + best-effort blockhash refresh +\n // delayed sign. A user cancel / signing failure surfaces; a non-cancel\n // prompt failure resolves to `\"degraded\"` and falls back to the legacy\n // basic path.\n GenericTerminalSign: {\n invoke: {\n id: \"signGenericClearSignStateMachine\",\n src: \"signGenericClearSignStateMachine\",\n input: ({ context }) => {\n const { rpcUrl, fetchBlockhash } = resolveRefreshSource(context);\n return {\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n rpcUrl,\n fetchBlockhash,\n userInputType:\n context.input.transactionOptions?.transactionResolutionContext\n ?.userInputType,\n blockhashService: context.input.blockhashService,\n };\n },\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"CheckGenericTerminalSignResult\",\n actions: assign({\n _internalState: ({ event, context }) =>\n event.output.caseOf<SignTransactionDAInternalState>({\n // Right(Signature) on success; Right(\"degraded\") when the\n // prompt failed for a non-cancel reason (leave signature\n // unset so the result check falls back to legacy).\n Right: (signatureOrDegraded) =>\n signatureOrDegraded === \"degraded\"\n ? context._internalState\n : {\n ...context._internalState,\n signature: signatureOrDegraded,\n },\n // Left: the user cancelled or signing failed; surface it.\n Left: (error) => ({ ...context._internalState, error }),\n }),\n }),\n },\n },\n },\n CheckGenericTerminalSignResult: {\n always: [\n // Signed: report (isBlindSign: false) then surface result.\n { target: \"Report\", guard: \"hasSignature\" },\n // Degraded (no signature, no error): fall back to the legacy path.\n { target: \"CheckTxCheckReprovision\", guard: \"noInternalError\" },\n // User cancel / signing failure: report (isBlindSign: false) then surface error.\n { target: \"Report\" },\n ],\n },\n // A failed generic clear-sign attempt wipes the device's provisioned\n // context, including the tx-check descriptor sent in TxCheck. Provide\n // it again before falling back to the basic path. The opt-in was\n // already answered in TxCheck, so this pass never prompts.\n CheckTxCheckReprovision: {\n always: [\n {\n target: \"TxCheckReprovision\",\n guard: \"isTransactionChecksSupported\",\n },\n { target: \"BasicClearSign\" },\n ],\n },\n TxCheckReprovision: {\n invoke: {\n id: \"transactionCheckReprovisionStateMachine\",\n src: \"transactionCheckStateMachine\",\n input: ({ context }) => ({\n appConfig: context._internalState.appConfig!,\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n contextModule: context.input.contextModule,\n serializedForTxCheck: context._internalState.serializedForTxCheck,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n onDone: { target: \"BasicClearSign\" },\n },\n },\n // Legacy SPL / token provisioning child (best-effort, never signs). It\n // streams descriptors; control always proceeds to the basic terminal\n // sign.\n BasicClearSign: {\n invoke: {\n id: \"provisionBasicClearSignStateMachine\",\n src: \"provisionBasicClearSignStateMachine\",\n input: ({ context }) => ({\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n contextModule: context.input.contextModule,\n appConfig: context._internalState.appConfig!,\n rpcUrl: resolveSolanaRpcUrl(context.input),\n resolutionContext:\n context.input.transactionOptions?.transactionResolutionContext,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n onDone: { target: \"Report\" },\n onError: { target: \"Report\" },\n },\n },\n // Single report state for all paths.\n // isBlindSign is derived from context: false when a signature or error is\n // already set (clear-sign path \u2014 success or cancel) or when a\n // basic-flow rule routed the transaction (the app clear-signs it\n // natively), true otherwise (basic path, neither has run yet).\n // Routes to: SignTransactionResultCheck (clear-sign success),\n // Error (clear-sign cancel/failure), or\n // BasicTerminalSign (basic path).\n Report: {\n invoke: {\n src: \"reportSign\",\n input: ({ context }) => {\n const sessionState = internalApi.getDeviceSessionState();\n const deviceVersion =\n sessionState.sessionStateType !==\n DeviceSessionStateType.Connected\n ? (sessionState.firmwareVersion?.os ?? null)\n : null;\n return {\n isBlindSign:\n context._internalState.basicFlowRuleId === null &&\n context._internalState.signature === null &&\n context._internalState.error === null,\n messageBytes: context._internalState.messageBytes,\n unrecognizedProgramIds:\n context._internalState.unrecognizedProgramIds,\n staleDescriptor: context._internalState.staleDescriptor,\n contextModule: context.input.contextModule,\n signerAppVersion: context._internalState.appConfig!.version,\n deviceModelId: sessionState.deviceModelId,\n deviceVersion,\n loggerFactory,\n } satisfies SolanaSigningReportTaskArgs;\n },\n onDone: [\n {\n target: \"SignTransactionResultCheck\",\n guard: \"hasSignature\",\n },\n {\n target: \"Error\",\n guard: ({ context }) => context._internalState.error !== null,\n },\n { target: \"BasicTerminalSign\" },\n ],\n onError: [\n {\n target: \"SignTransactionResultCheck\",\n guard: \"hasSignature\",\n },\n {\n target: \"Error\",\n guard: ({ context }) => context._internalState.error !== null,\n },\n { target: \"BasicTerminalSign\" },\n ],\n },\n },\n // Basic terminal sign: the legacy preview/one-shot path. It decides\n // delayed-vs-one-shot from the blockhash source (opt-in refresh).\n BasicTerminalSign: {\n invoke: {\n id: \"signBasicClearSignStateMachine\",\n src: \"signBasicClearSignStateMachine\",\n input: ({ context }) => {\n const { rpcUrl, fetchBlockhash } = resolveRefreshSource(context);\n return {\n derivationPath: context.input.derivationPath,\n transaction: context._internalState.messageBytes,\n rpcUrl,\n fetchBlockhash,\n userInputType:\n context.input.transactionOptions?.transactionResolutionContext\n ?.userInputType,\n blockhashService: context.input.blockhashService,\n };\n },\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n target: \"SignTransactionResultCheck\",\n actions: assign({\n _internalState: ({ event, context }) =>\n event.output.caseOf<SignTransactionDAInternalState>({\n Right: (signature) => ({\n ...context._internalState,\n signature,\n }),\n Left: (error) => ({ ...context._internalState, error }),\n }),\n }),\n },\n },\n },\n SignTransactionResultCheck: {\n always: [\n { guard: \"noInternalError\", target: \"Success\" },\n { target: \"Error\" },\n ],\n },\n Success: { type: \"final\" },\n Error: { type: \"final\" },\n },\n output: ({ context }) =>\n context._internalState.signature\n ? Right(context._internalState.signature)\n : Left(\n context._internalState.error ||\n new UnknownDAError(`No error or signature available`),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi): MachineDependencies {\n const normalizeTransaction = async () => {\n try {\n return new TransactionInputNormaliser().normalize(\n this.input.transaction,\n );\n } catch (error) {\n this.getLoggerFactory(internalApi)(\"NormalizeTransaction\").warn(\n \"[normalizeTransaction] format detection failed; treating input as message bytes\",\n { data: { error: String(error) } },\n );\n return {\n messageBytes: this.input.transaction,\n serializedForTxCheck: undefined,\n };\n }\n };\n\n const getAppConfig = async () =>\n internalApi.sendCommand(new GetAppConfigurationCommand());\n\n const reportSign = async (arg0: { input: SolanaSigningReportTaskArgs }) =>\n new SolanaSigningReportTask(arg0.input).run();\n\n // Never rejects: any failure means no rule matched, so the transaction\n // stays on the generic path. Program IDs are always static keys, so no\n // ALT resolver is needed.\n const resolveSigningRoute = async (arg0: {\n input: { messageBytes: Uint8Array };\n }): Promise<string | null> => {\n try {\n const parsed = await new TransactionParser()\n .parse(arg0.input.messageBytes)\n .run();\n if (parsed.isLeft()) return null;\n const message = parsed.unsafeCoerce().message;\n // ComputeBudget isn't in CAL: don't look it up.\n const programIds = [\n ...new Set(\n message.compiledInstructions.map((ix) =>\n message.allKeys[ix.programIdIndex]?.toBase58(),\n ),\n ),\n ].filter(\n (id): id is string =>\n id !== undefined && id !== COMPUTE_BUDGET_PROGRAM_ID,\n );\n const rules = await resolveBasicFlowRules(\n this.input.contextModule,\n programIds,\n );\n return new GenericFlowRouter(rules, {\n leadingAllowed: [COMPUTE_BUDGET_PROGRAM_ID],\n }).match(parsed.unsafeCoerce());\n } catch (error) {\n this.getLoggerFactory(internalApi)(\"ResolveSigningRoute\").warn(\n \"[resolveSigningRoute] failed; keeping the generic clear-sign path\",\n { data: { error: String(error) } },\n );\n return null;\n }\n };\n\n return {\n normalizeTransaction,\n getAppConfig,\n reportSign,\n resolveSigningRoute,\n };\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC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CAAC,EAAE,MAAML,EAAO,aAAa,CAAC,CAChC,OAASR,EAAO,CACd,YAAK,iBAAiBlB,CAAW,EAAE,qBAAqB,EAAE,KACxD,oEACA,CAAE,KAAM,CAAE,MAAO,OAAOkB,CAAK,CAAE,CAAE,CACnC,EACO,IACT,CACF,CAOA,CACF,CACF",
|
|
6
|
+
"names": ["SignTransactionDeviceAction_exports", "__export", "SignTransactionDeviceAction", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_xstate", "import_SignTransactionDeviceActionTypes", "import_GetAppConfigurationCommand", "import_constants", "import_basicFlowRules", "import_GenericFlowRouter", "import_TransactionInputNormaliser", "import_TransactionParser", "import_SolanaApplicationResolver", "import_SolanaSigningReportTask", "import_ProvisionBasicClearSignDeviceAction", "import_ProvisionGenericClearSignDeviceAction", "import_ProvisionTransactionCheckDeviceAction", "import_SignBasicClearSignDeviceAction", "import_SignGenericClearSignDeviceAction", "resolveSolanaRpcUrl", "input", "internalApi", "normalizeTransaction", "getAppConfig", "reportSign", "resolveSigningRoute", "loggerFactory", "logger", "disabledFeaturesSet", "isSupported", "feature", "appConfig", "resolveRefreshSource", "context", "rpcUrl", "fetchBlockhash", "refreshBlockhash", "_", "event", "error", "transactionChecksEnabled", "outcome", "signatureOrDegraded", "sessionState", "deviceVersion", "signature", "arg0", "parsed", "message", "programIds", "ix", "id", "rules"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=require("@ledgerhq/device-management-kit"),b=require("purify-ts"),e=require("vitest"),A=require("../../../api/app-binder/SignClearSignDeviceActionTypes"),y=require("../../../api/app-binder/SignTransactionDeviceActionTypes"),N=require("../../../api/model/PublicKeyDisplayMode"),I=require("../../app-binder/command/utils/SolanaApplicationErrors"),_=require("../../app-binder/services/TransactionInspector"),r=require("../../app-binder/SolanaApplicationResolver"),G=require("./__test-utils__/makeInternalApi"),M=require("./ProvisionBasicClearSignDeviceAction"),L=require("./ProvisionGenericClearSignDeviceAction"),U=require("./ProvisionTransactionCheckDeviceAction"),z=require("./SignBasicClearSignDeviceAction"),F=require("./SignGenericClearSignDeviceAction"),q=require("./SignTransactionDeviceAction");const te="44'/501'/0'/0'",X=new Uint8Array([222,173,190,239]),P=new Uint8Array([170,187]),H=new Uint8Array([119,136]),w="1.15.5",oe={getContexts:e.vi.fn()};let u,p,d,K,Y,f,W,J,O,S,k,h,D,R,B,T,Z,Q,$,j,ee,ne;function m(i){return{blindSigningEnabled:!0,pubKeyDisplayMode:N.PublicKeyDisplayMode.LONG,version:i,transactionChecksEnabled:!1,transactionChecksOptIn:!1}}function v(i,o=a.DeviceModelId.NANO_X){return{sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Solana",version:i},deviceModelId:o,isSecureConnectionAllowed:!0}}function ae(){Q=e.vi.spyOn(L.ProvisionGenericClearSignDeviceAction.prototype,"extractDependencies").mockReturnValue({buildGenericClearSignContext:d,provideGenericClearSignContext:K,finalizeGenericClearSign:Y}),$=e.vi.spyOn(M.ProvisionBasicClearSignDeviceAction.prototype,"extractDependencies").mockReturnValue({inspectTransaction:f,buildBasicClearSignContext:W,provideBasicClearSignContext:J}),j=e.vi.spyOn(U.ProvisionTransactionCheckDeviceAction.prototype,"extractDependencies").mockReturnValue({transactionCheckOptIn:O,provideTransactionCheck:S}),ee=e.vi.spyOn(F.SignGenericClearSignDeviceAction.prototype,"extractDependencies").mockReturnValue({promptUiDisplay:h,refreshBlockhash:T,delayedSignTransaction:R}),ne=e.vi.spyOn(z.SignBasicClearSignDeviceAction.prototype,"extractDependencies").mockReturnValue({previewTransaction:D,refreshBlockhash:T,delayedSignTransaction:R,signTransaction:B})}function s(i,o,t){const n=new q.SignTransactionDeviceAction({input:i});Z=e.vi.spyOn(n,"extractDependencies").mockReturnValue({normalizeTransaction:e.vi.fn().mockResolvedValue({messageBytes:X,serializedForTxCheck:void 0}),getAppConfig:p,reportSign:k});const{observable:l}=n._execute(u),c=[];l.subscribe({next:g=>c.push(g),error:t,complete:()=>o(c)})}const C={derivationPath:te,transaction:X,transactionOptions:{skipOpenApp:!0},contextModule:oe},V={...C,solanaRPCURL:"https://api.devnet.solana.com"},E={...V,transactionOptions:{...C.transactionOptions,delayed:!0}};function x(i){const o=[];for(const t of i){if(t.status!==a.DeviceActionStatus.Pending)continue;const n=t.intermediateValue.step;o[o.length-1]!==n&&o.push(n)}return o}(0,e.describe)("SignTransactionDeviceAction (Solana) \u2013 orchestration",()=>{(0,e.beforeEach)(()=>{u=(0,G.makeDeviceActionInternalApiMock)(),u.getDeviceSessionState.mockReturnValue(v(w)),p=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:m(w)})),d=e.vi.fn().mockResolvedValue({mode:"none",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),K=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),Y=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),h=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),f=e.vi.fn().mockResolvedValue({transactionType:_.SolanaTransactionTypes.STANDARD}),W=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:{loadersResults:[],contextErrorCount:0}})),J=e.vi.fn().mockResolvedValue(void 0),D=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:b.Nothing})),T=e.vi.fn().mockImplementation(async i=>i.input.transaction),R=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:(0,b.Just)(H)})),B=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:(0,b.Just)(P)})),O=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:{enabled:!0}})),S=e.vi.fn().mockResolvedValue(void 0),k=e.vi.fn().mockResolvedValue(void 0),ae()}),(0,e.afterEach)(()=>{Z?.mockRestore(),Q.mockRestore(),$.mockRestore(),j.mockRestore(),ee.mockRestore(),ne.mockRestore()}),(0,e.it)("generic unavailable then basic provisions then terminal one-shot sign (no RPC)",()=>new Promise((i,o)=>{s(C,t=>{try{(0,e.expect)(d).not.toHaveBeenCalled(),(0,e.expect)(f).toHaveBeenCalled(),(0,e.expect)(B).toHaveBeenCalled(),(0,e.expect)(R).not.toHaveBeenCalled();const n=t[t.length-1];(0,e.expect)(n.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(n.status===a.DeviceActionStatus.Completed&&n.output).toEqual(P),i()}catch(n){o(n)}},o)})),(0,e.it)("generic available + armed then terminal delayed sign (alreadyArmed, refreshed)",()=>new Promise((i,o)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),p.mockResolvedValue((0,a.CommandResultFactory)({data:m(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),d.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),s(E,t=>{try{(0,e.expect)(d).toHaveBeenCalled(),(0,e.expect)(h).toHaveBeenCalled(),(0,e.expect)(D).not.toHaveBeenCalled(),(0,e.expect)(T).toHaveBeenCalled(),(0,e.expect)(T.mock.calls[0][0].input.rpcUrl).toBeDefined(),(0,e.expect)(R).toHaveBeenCalled(),(0,e.expect)(f).not.toHaveBeenCalled();const n=t[t.length-1];(0,e.expect)(n.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(n.status===a.DeviceActionStatus.Completed&&n.output).toEqual(H),i()}catch(n){o(n)}},o)})),(0,e.it)("generic available + armed, RPC but no delayed then delayed sign on original (no refresh)",()=>new Promise((i,o)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),p.mockResolvedValue((0,a.CommandResultFactory)({data:m(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),d.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),s(V,t=>{try{(0,e.expect)(h).toHaveBeenCalled(),(0,e.expect)(D).not.toHaveBeenCalled(),(0,e.expect)(T.mock.calls[0][0].input.rpcUrl).toBeUndefined(),(0,e.expect)(R).toHaveBeenCalled(),(0,e.expect)(B).not.toHaveBeenCalled();const n=t[t.length-1];(0,e.expect)(n.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(n.status===a.DeviceActionStatus.Completed&&n.output).toEqual(H),i()}catch(n){o(n)}},o)})),(0,e.it)("not armed, RPC but no delayed then terminal one-shot sign (no refresh)",()=>new Promise((i,o)=>{s(V,t=>{try{(0,e.expect)(B).toHaveBeenCalled(),(0,e.expect)(D).not.toHaveBeenCalled(),(0,e.expect)(T).not.toHaveBeenCalled(),(0,e.expect)(R).not.toHaveBeenCalled();const n=t[t.length-1];(0,e.expect)(n.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(n.status===a.DeviceActionStatus.Completed&&n.output).toEqual(P),i()}catch(n){o(n)}},o)})),(0,e.it)("delayed requested + RPC but app lacks delayed-signing then one-shot sign (refresh withheld)",()=>new Promise((i,o)=>{const t="1.13.0";u.getDeviceSessionState.mockReturnValue(v(t)),p.mockResolvedValue((0,a.CommandResultFactory)({data:m(t)})),s(E,n=>{try{(0,e.expect)(B).toHaveBeenCalled(),(0,e.expect)(D).not.toHaveBeenCalled(),(0,e.expect)(T).not.toHaveBeenCalled(),(0,e.expect)(R).not.toHaveBeenCalled();const l=n[n.length-1];(0,e.expect)(l.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(l.status===a.DeviceActionStatus.Completed&&l.output).toEqual(P),i()}catch(l){o(l)}},o)})),(0,e.it)("generic degraded then basic then terminal",()=>new Promise((i,o)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),p.mockResolvedValue((0,a.CommandResultFactory)({data:m(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),s(E,t=>{try{(0,e.expect)(d).toHaveBeenCalled(),(0,e.expect)(f).toHaveBeenCalled(),(0,e.expect)(D).toHaveBeenCalled(),(0,e.expect)(R).toHaveBeenCalled(),(0,e.expect)(t[t.length-1].status).toBe(a.DeviceActionStatus.Completed),i()}catch(n){o(n)}},o)})),(0,e.it)("generic user cancel (6985) then error, no basic / no terminal",()=>new Promise((i,o)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),p.mockResolvedValue((0,a.CommandResultFactory)({data:m(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),d.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),h.mockResolvedValue((0,a.CommandResultFactory)({error:new I.SolanaAppCommandError({errorCode:"6985",message:"Canceled by user"})})),s(V,t=>{try{(0,e.expect)(f).not.toHaveBeenCalled(),(0,e.expect)(R).not.toHaveBeenCalled(),(0,e.expect)(B).not.toHaveBeenCalled(),(0,e.expect)(t[t.length-1].status).toBe(a.DeviceActionStatus.Error),i()}catch(n){o(n)}},o)})),(0,e.it)("terminal sign failure then error",()=>new Promise((i,o)=>{B.mockResolvedValue((0,a.CommandResultFactory)({error:new I.SolanaAppCommandError({errorCode:"6f01",message:"sign failed"})})),s(C,t=>{try{(0,e.expect)(B).toHaveBeenCalled(),(0,e.expect)(t[t.length-1].status).toBe(a.DeviceActionStatus.Error),i()}catch(n){o(n)}},o)})),(0,e.it)("getAppConfig error then error",()=>new Promise((i,o)=>{p.mockResolvedValue((0,a.CommandResultFactory)({error:new I.SolanaAppCommandError({errorCode:"6e00",message:"no app config"})})),s(C,t=>{try{(0,e.expect)(f).not.toHaveBeenCalled(),(0,e.expect)(t[t.length-1].status).toBe(a.DeviceActionStatus.Error),i()}catch(n){o(n)}},o)})),(0,e.it)("ProvisionTransactionCheckDeviceAction child is invoked when feature is supported",()=>new Promise((i,o)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_TRANSACTION_CHECKS_VERSION,a.DeviceModelId.FLEX)),p.mockResolvedValue((0,a.CommandResultFactory)({data:{...m(r.SOLANA_MIN_TRANSACTION_CHECKS_VERSION),transactionChecksEnabled:!0,transactionChecksOptIn:!0}})),s(C,t=>{try{const n=x(t);(0,e.expect)(n).toContain(y.signTransactionDAStateSteps.TRANSACTION_CHECKS_PROVIDE),(0,e.expect)(t[t.length-1].status).toBe(a.DeviceActionStatus.Completed),i()}catch(n){o(n)}},o)})),(0,e.it)("skips transaction-checks when transactionChecks is in disabledFeatures",()=>new Promise((i,o)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_TRANSACTION_CHECKS_VERSION,a.DeviceModelId.FLEX)),p.mockResolvedValue((0,a.CommandResultFactory)({data:{...m(r.SOLANA_MIN_TRANSACTION_CHECKS_VERSION),transactionChecksEnabled:!1,transactionChecksOptIn:!1}})),s({...C,disabledFeatures:["transactionChecks"]},t=>{try{const n=x(t);(0,e.expect)(n).not.toContain(y.signTransactionDAStateSteps.TRANSACTION_CHECKS_OPT_IN),(0,e.expect)(n).not.toContain(y.signTransactionDAStateSteps.TRANSACTION_CHECKS_PROVIDE),(0,e.expect)(t[t.length-1].status).toBe(a.DeviceActionStatus.Completed),i()}catch(n){o(n)}},o)})),(0,e.describe)("transaction-check re-provision after a generic fallback",()=>{const i=r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION;function o(n){u.getDeviceSessionState.mockReturnValue(v(i,a.DeviceModelId.FLEX)),p.mockResolvedValue((0,a.CommandResultFactory)({data:{...m(i),...n}}))}const t={mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]};(0,e.it)("generic degraded \u2192 tx-check provided again before basic",()=>new Promise((n,l)=>{o({transactionChecksEnabled:!0,transactionChecksOptIn:!0}),s(C,c=>{try{(0,e.expect)(d).toHaveBeenCalled(),(0,e.expect)(S).toHaveBeenCalledTimes(2),(0,e.expect)(O).not.toHaveBeenCalled(),(0,e.expect)(S.mock.invocationCallOrder[1]).toBeGreaterThan(d.mock.invocationCallOrder[0]),(0,e.expect)(S.mock.invocationCallOrder[1]).toBeLessThan(f.mock.invocationCallOrder[0]),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),n()}catch(g){l(g)}},l)})),(0,e.it)("generic prompt failure (non-cancel) \u2192 tx-check provided again before basic",()=>new Promise((n,l)=>{o({transactionChecksEnabled:!0,transactionChecksOptIn:!0}),d.mockResolvedValue(t),h.mockResolvedValue((0,a.CommandResultFactory)({error:new I.SolanaAppCommandError({errorCode:"6a80",message:"bad descriptor"})})),s(C,c=>{try{(0,e.expect)(h).toHaveBeenCalled(),(0,e.expect)(S).toHaveBeenCalledTimes(2),(0,e.expect)(S.mock.invocationCallOrder[1]).toBeGreaterThan(h.mock.invocationCallOrder[0]),(0,e.expect)(f).toHaveBeenCalled(),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),n()}catch(g){l(g)}},l)})),(0,e.it)("opt-in accepted on first pass \u2192 re-provision does not prompt again",()=>new Promise((n,l)=>{o({transactionChecksEnabled:!1,transactionChecksOptIn:!1}),s(C,c=>{try{(0,e.expect)(O).toHaveBeenCalledTimes(1),(0,e.expect)(S).toHaveBeenCalledTimes(2),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),n()}catch(g){l(g)}},l)})),(0,e.it)("opt-in declined on first pass \u2192 no prompt and no provide on fallback",()=>new Promise((n,l)=>{o({transactionChecksEnabled:!1,transactionChecksOptIn:!1}),O.mockResolvedValue((0,a.CommandResultFactory)({data:{enabled:!1}})),s(C,c=>{try{(0,e.expect)(O).toHaveBeenCalledTimes(1),(0,e.expect)(S).not.toHaveBeenCalled(),(0,e.expect)(f).toHaveBeenCalled(),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),n()}catch(g){l(g)}},l)})),(0,e.it)("generic prepared + signed \u2192 tx-check provided once",()=>new Promise((n,l)=>{o({transactionChecksEnabled:!0,transactionChecksOptIn:!0}),d.mockResolvedValue(t),s(C,c=>{try{(0,e.expect)(S).toHaveBeenCalledTimes(1),(0,e.expect)(f).not.toHaveBeenCalled(),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),n()}catch(g){l(g)}},l)})),(0,e.it)("generic unavailable \u2192 tx-check provided once before basic",()=>new Promise((n,l)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_TRANSACTION_CHECKS_VERSION,a.DeviceModelId.FLEX)),p.mockResolvedValue((0,a.CommandResultFactory)({data:{...m(r.SOLANA_MIN_TRANSACTION_CHECKS_VERSION),transactionChecksEnabled:!0,transactionChecksOptIn:!0}})),s(C,c=>{try{(0,e.expect)(d).not.toHaveBeenCalled(),(0,e.expect)(S).toHaveBeenCalledTimes(1),(0,e.expect)(f).toHaveBeenCalled(),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),n()}catch(g){l(g)}},l)}))}),(0,e.it)("e2e sequence: legacy SPL path with RPC then basic provisioning then delayed terminal",()=>new Promise((i,o)=>{f.mockResolvedValue({transactionType:_.SolanaTransactionTypes.SPL,data:{tokenAddress:null,createATA:!1}}),s(E,t=>{try{(0,e.expect)(x(t)).toEqual([y.signTransactionDAStateSteps.GET_APP_CONFIG,y.signTransactionDAStateSteps.INSPECT_TRANSACTION,y.signTransactionDAStateSteps.BUILD_BASIC_CLEAR_SIGN_CONTEXT,y.signTransactionDAStateSteps.PROVIDE_BASIC_CLEAR_SIGN_CONTEXT,A.signClearSignDAStateSteps.PREVIEW_TRANSACTION,A.signClearSignDAStateSteps.FETCH_BLOCKHASH,A.signClearSignDAStateSteps.DELAYED_SIGN]);const n=t[t.length-1];(0,e.expect)(n.status).toBe(a.DeviceActionStatus.Completed),i()}catch(n){o(n)}},o)})),(0,e.it)("e2e sequence: generic clear-sign armed then terminal refresh + delayed sign",()=>new Promise((i,o)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),p.mockResolvedValue((0,a.CommandResultFactory)({data:m(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),d.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),s(E,t=>{try{(0,e.expect)(x(t)).toEqual([y.signTransactionDAStateSteps.GET_APP_CONFIG,y.signTransactionDAStateSteps.BUILD_GENERIC_CLEAR_SIGN_CONTEXT,y.signTransactionDAStateSteps.PROVIDE_GENERIC_CLEAR_SIGN_CONTEXT,y.signTransactionDAStateSteps.FINALIZE_GENERIC_CLEAR_SIGN,A.signClearSignDAStateSteps.PROMPT_UI_DISPLAY,A.signClearSignDAStateSteps.FETCH_BLOCKHASH,A.signClearSignDAStateSteps.DELAYED_SIGN]);const n=t[t.length-1];(0,e.expect)(n.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(n.status===a.DeviceActionStatus.Completed&&n.output).toEqual(H),i()}catch(n){o(n)}},o)})),(0,e.describe)("Report state \u2014 isBlindSign contract",()=>{(0,e.it)("legacy path (generic gate skipped) \u2192 isBlindSign: true, reportSign called once",()=>new Promise((i,o)=>{s(C,()=>{try{(0,e.expect)(k).toHaveBeenCalledOnce();const t=k.mock.calls[0][0];(0,e.expect)(t.input.isBlindSign).toBe(!0),i()}catch(t){o(t)}},o)})),(0,e.it)("generic clear-sign success \u2192 isBlindSign: false, reportSign called once",()=>new Promise((i,o)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),p.mockResolvedValue((0,a.CommandResultFactory)({data:m(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),d.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),s(E,()=>{try{(0,e.expect)(k).toHaveBeenCalledOnce();const t=k.mock.calls[0][0];(0,e.expect)(t.input.isBlindSign).toBe(!1),i()}catch(t){o(t)}},o)})),(0,e.it)("generic cancel (6985) \u2192 isBlindSign: false, reportSign called once",()=>new Promise((i,o)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),p.mockResolvedValue((0,a.CommandResultFactory)({data:m(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),d.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),h.mockResolvedValue((0,a.CommandResultFactory)({error:new I.SolanaAppCommandError({errorCode:"6985",message:"Canceled by user"})})),s(V,()=>{try{(0,e.expect)(k).toHaveBeenCalledOnce();const t=k.mock.calls[0][0];(0,e.expect)(t.input.isBlindSign).toBe(!1),i()}catch(t){o(t)}},o)})),(0,e.it)("generic non-cancel prompt failure degrades to basic \u2192 isBlindSign: true, reportSign called once",()=>new Promise((i,o)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),p.mockResolvedValue((0,a.CommandResultFactory)({data:m(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),d.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),h.mockResolvedValue((0,a.CommandResultFactory)({error:new I.SolanaAppCommandError({errorCode:"6f01",message:"Display error"})})),s(V,()=>{try{(0,e.expect)(k).toHaveBeenCalledOnce();const t=k.mock.calls[0][0];(0,e.expect)(t.input.isBlindSign).toBe(!0),i()}catch(t){o(t)}},o)})),(0,e.it)("generic build degrades with staleDescriptor \u2192 reportSign receives staleDescriptor: true",()=>new Promise((i,o)=>{u.getDeviceSessionState.mockReturnValue(v(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),p.mockResolvedValue((0,a.CommandResultFactory)({data:m(r.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),d.mockResolvedValue({mode:"none",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[],staleDescriptor:!0}),s(V,()=>{try{(0,e.expect)(k).toHaveBeenCalledOnce();const t=k.mock.calls[0][0];(0,e.expect)(t.input.isBlindSign).toBe(!0),(0,e.expect)(t.input.staleDescriptor).toBe(!0),i()}catch(t){o(t)}},o)}))})});
|
|
1
|
+
"use strict";var G=require("@ledgerhq/context-module"),a=require("@ledgerhq/device-management-kit"),_=require("purify-ts"),e=require("vitest"),A=require("../../../api/app-binder/SignClearSignDeviceActionTypes"),k=require("../../../api/app-binder/SignTransactionDeviceActionTypes"),U=require("../../../api/model/PublicKeyDisplayMode"),V=require("../../app-binder/command/utils/SolanaApplicationErrors"),w=require("../../app-binder/services/__test-utils__/ambiguousMessages"),M=require("../../app-binder/services/TransactionInspector"),s=require("../../app-binder/SolanaApplicationResolver"),F=require("./__test-utils__/makeInternalApi"),X=require("./ProvisionBasicClearSignDeviceAction"),z=require("./ProvisionGenericClearSignDeviceAction"),K=require("./ProvisionTransactionCheckDeviceAction"),W=require("./SignBasicClearSignDeviceAction"),Y=require("./SignGenericClearSignDeviceAction"),N=require("./SignTransactionDeviceAction");const le="44'/501'/0'/0'",L=new Uint8Array([222,173,190,239]),P=new Uint8Array([170,187]),x=new Uint8Array([119,136]),q="1.15.5",se={getContexts:e.vi.fn()};let d,m,u,J,Z,S,Q,$,b,y,f,h,R,D,T,B,E,j,ee,ne,te,oe,ae;function C(i){return{blindSigningEnabled:!0,pubKeyDisplayMode:U.PublicKeyDisplayMode.LONG,version:i,transactionChecksEnabled:!1,transactionChecksOptIn:!1}}function g(i,o=a.DeviceModelId.NANO_X){return{sessionStateType:a.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Solana",version:i},deviceModelId:o,isSecureConnectionAllowed:!0}}function re(){ee=e.vi.spyOn(z.ProvisionGenericClearSignDeviceAction.prototype,"extractDependencies").mockReturnValue({buildGenericClearSignContext:u,provideGenericClearSignContext:J,finalizeGenericClearSign:Z}),ne=e.vi.spyOn(X.ProvisionBasicClearSignDeviceAction.prototype,"extractDependencies").mockReturnValue({inspectTransaction:S,buildBasicClearSignContext:Q,provideBasicClearSignContext:$}),te=e.vi.spyOn(K.ProvisionTransactionCheckDeviceAction.prototype,"extractDependencies").mockReturnValue({transactionCheckOptIn:b,provideTransactionCheck:y}),oe=e.vi.spyOn(Y.SignGenericClearSignDeviceAction.prototype,"extractDependencies").mockReturnValue({promptUiDisplay:R,refreshBlockhash:E,delayedSignTransaction:T}),ae=e.vi.spyOn(W.SignBasicClearSignDeviceAction.prototype,"extractDependencies").mockReturnValue({previewTransaction:D,refreshBlockhash:E,delayedSignTransaction:T,signTransaction:B})}function r(i,o,n){const t=new N.SignTransactionDeviceAction({input:i});j=e.vi.spyOn(t,"extractDependencies").mockReturnValue({normalizeTransaction:e.vi.fn().mockResolvedValue({messageBytes:L,serializedForTxCheck:void 0}),getAppConfig:m,reportSign:f,resolveSigningRoute:h});const{observable:l}=t._execute(d),c=[];l.subscribe({next:v=>c.push(v),error:n,complete:()=>o(c)})}const p={derivationPath:le,transaction:L,transactionOptions:{skipOpenApp:!0},contextModule:se},H={...p,solanaRPCURL:"https://api.devnet.solana.com"},I={...H,transactionOptions:{...p.transactionOptions,delayed:!0}};function O(i){const o=[];for(const n of i){if(n.status!==a.DeviceActionStatus.Pending)continue;const t=n.intermediateValue.step;o[o.length-1]!==t&&o.push(t)}return o}(0,e.describe)("SignTransactionDeviceAction (Solana) \u2013 orchestration",()=>{(0,e.beforeEach)(()=>{d=(0,F.makeDeviceActionInternalApiMock)(),d.getDeviceSessionState.mockReturnValue(g(q)),m=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:C(q)})),u=e.vi.fn().mockResolvedValue({mode:"none",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),J=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),Z=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),R=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:void 0})),S=e.vi.fn().mockResolvedValue({transactionType:M.SolanaTransactionTypes.STANDARD}),Q=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:{loadersResults:[],contextErrorCount:0}})),$=e.vi.fn().mockResolvedValue(void 0),D=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:_.Nothing})),E=e.vi.fn().mockImplementation(async i=>i.input.transaction),T=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:(0,_.Just)(x)})),B=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:(0,_.Just)(P)})),b=e.vi.fn().mockResolvedValue((0,a.CommandResultFactory)({data:{enabled:!0}})),y=e.vi.fn().mockResolvedValue(void 0),f=e.vi.fn().mockResolvedValue(void 0),h=e.vi.fn().mockResolvedValue(null),re()}),(0,e.afterEach)(()=>{j?.mockRestore(),ee.mockRestore(),ne.mockRestore(),te.mockRestore(),oe.mockRestore(),ae.mockRestore()}),(0,e.it)("generic unavailable then basic provisions then terminal one-shot sign (no RPC)",()=>new Promise((i,o)=>{r(p,n=>{try{(0,e.expect)(u).not.toHaveBeenCalled(),(0,e.expect)(S).toHaveBeenCalled(),(0,e.expect)(B).toHaveBeenCalled(),(0,e.expect)(T).not.toHaveBeenCalled();const t=n[n.length-1];(0,e.expect)(t.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(t.status===a.DeviceActionStatus.Completed&&t.output).toEqual(P),i()}catch(t){o(t)}},o)})),(0,e.it)("generic available + armed then terminal delayed sign (alreadyArmed, refreshed)",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),u.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),r(I,n=>{try{(0,e.expect)(u).toHaveBeenCalled(),(0,e.expect)(R).toHaveBeenCalled(),(0,e.expect)(D).not.toHaveBeenCalled(),(0,e.expect)(E).toHaveBeenCalled(),(0,e.expect)(E.mock.calls[0][0].input.rpcUrl).toBeDefined(),(0,e.expect)(T).toHaveBeenCalled(),(0,e.expect)(S).not.toHaveBeenCalled();const t=n[n.length-1];(0,e.expect)(t.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(t.status===a.DeviceActionStatus.Completed&&t.output).toEqual(x),i()}catch(t){o(t)}},o)})),(0,e.it)("generic available + armed, RPC but no delayed then delayed sign on original (no refresh)",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),u.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),r(H,n=>{try{(0,e.expect)(R).toHaveBeenCalled(),(0,e.expect)(D).not.toHaveBeenCalled(),(0,e.expect)(E.mock.calls[0][0].input.rpcUrl).toBeUndefined(),(0,e.expect)(T).toHaveBeenCalled(),(0,e.expect)(B).not.toHaveBeenCalled();const t=n[n.length-1];(0,e.expect)(t.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(t.status===a.DeviceActionStatus.Completed&&t.output).toEqual(x),i()}catch(t){o(t)}},o)})),(0,e.it)("not armed, RPC but no delayed then terminal one-shot sign (no refresh)",()=>new Promise((i,o)=>{r(H,n=>{try{(0,e.expect)(B).toHaveBeenCalled(),(0,e.expect)(D).not.toHaveBeenCalled(),(0,e.expect)(E).not.toHaveBeenCalled(),(0,e.expect)(T).not.toHaveBeenCalled();const t=n[n.length-1];(0,e.expect)(t.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(t.status===a.DeviceActionStatus.Completed&&t.output).toEqual(P),i()}catch(t){o(t)}},o)})),(0,e.it)("delayed requested + RPC but app lacks delayed-signing then one-shot sign (refresh withheld)",()=>new Promise((i,o)=>{const n="1.13.0";d.getDeviceSessionState.mockReturnValue(g(n)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(n)})),r(I,t=>{try{(0,e.expect)(B).toHaveBeenCalled(),(0,e.expect)(D).not.toHaveBeenCalled(),(0,e.expect)(E).not.toHaveBeenCalled(),(0,e.expect)(T).not.toHaveBeenCalled();const l=t[t.length-1];(0,e.expect)(l.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(l.status===a.DeviceActionStatus.Completed&&l.output).toEqual(P),i()}catch(l){o(l)}},o)})),(0,e.it)("generic degraded then basic then terminal",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),r(I,n=>{try{(0,e.expect)(u).toHaveBeenCalled(),(0,e.expect)(S).toHaveBeenCalled(),(0,e.expect)(D).toHaveBeenCalled(),(0,e.expect)(T).toHaveBeenCalled(),(0,e.expect)(n[n.length-1].status).toBe(a.DeviceActionStatus.Completed),i()}catch(t){o(t)}},o)})),(0,e.it)("generic user cancel (6985) then error, no basic / no terminal",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),u.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),R.mockResolvedValue((0,a.CommandResultFactory)({error:new V.SolanaAppCommandError({errorCode:"6985",message:"Canceled by user"})})),r(H,n=>{try{(0,e.expect)(S).not.toHaveBeenCalled(),(0,e.expect)(T).not.toHaveBeenCalled(),(0,e.expect)(B).not.toHaveBeenCalled(),(0,e.expect)(n[n.length-1].status).toBe(a.DeviceActionStatus.Error),i()}catch(t){o(t)}},o)})),(0,e.it)("terminal sign failure then error",()=>new Promise((i,o)=>{B.mockResolvedValue((0,a.CommandResultFactory)({error:new V.SolanaAppCommandError({errorCode:"6f01",message:"sign failed"})})),r(p,n=>{try{(0,e.expect)(B).toHaveBeenCalled(),(0,e.expect)(n[n.length-1].status).toBe(a.DeviceActionStatus.Error),i()}catch(t){o(t)}},o)})),(0,e.it)("getAppConfig error then error",()=>new Promise((i,o)=>{m.mockResolvedValue((0,a.CommandResultFactory)({error:new V.SolanaAppCommandError({errorCode:"6e00",message:"no app config"})})),r(p,n=>{try{(0,e.expect)(S).not.toHaveBeenCalled(),(0,e.expect)(n[n.length-1].status).toBe(a.DeviceActionStatus.Error),i()}catch(t){o(t)}},o)})),(0,e.it)("ProvisionTransactionCheckDeviceAction child is invoked when feature is supported",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_TRANSACTION_CHECKS_VERSION,a.DeviceModelId.FLEX)),m.mockResolvedValue((0,a.CommandResultFactory)({data:{...C(s.SOLANA_MIN_TRANSACTION_CHECKS_VERSION),transactionChecksEnabled:!0,transactionChecksOptIn:!0}})),r(p,n=>{try{const t=O(n);(0,e.expect)(t).toContain(k.signTransactionDAStateSteps.TRANSACTION_CHECKS_PROVIDE),(0,e.expect)(n[n.length-1].status).toBe(a.DeviceActionStatus.Completed),i()}catch(t){o(t)}},o)})),(0,e.it)("skips transaction-checks when transactionChecks is in disabledFeatures",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_TRANSACTION_CHECKS_VERSION,a.DeviceModelId.FLEX)),m.mockResolvedValue((0,a.CommandResultFactory)({data:{...C(s.SOLANA_MIN_TRANSACTION_CHECKS_VERSION),transactionChecksEnabled:!1,transactionChecksOptIn:!1}})),r({...p,disabledFeatures:["transactionChecks"]},n=>{try{const t=O(n);(0,e.expect)(t).not.toContain(k.signTransactionDAStateSteps.TRANSACTION_CHECKS_OPT_IN),(0,e.expect)(t).not.toContain(k.signTransactionDAStateSteps.TRANSACTION_CHECKS_PROVIDE),(0,e.expect)(n[n.length-1].status).toBe(a.DeviceActionStatus.Completed),i()}catch(t){o(t)}},o)})),(0,e.describe)("transaction-check re-provision after a generic fallback",()=>{const i=s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION;function o(t){d.getDeviceSessionState.mockReturnValue(g(i,a.DeviceModelId.FLEX)),m.mockResolvedValue((0,a.CommandResultFactory)({data:{...C(i),...t}}))}const n={mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]};(0,e.it)("generic degraded \u2192 tx-check provided again before basic",()=>new Promise((t,l)=>{o({transactionChecksEnabled:!0,transactionChecksOptIn:!0}),r(p,c=>{try{(0,e.expect)(u).toHaveBeenCalled(),(0,e.expect)(y).toHaveBeenCalledTimes(2),(0,e.expect)(b).not.toHaveBeenCalled(),(0,e.expect)(y.mock.invocationCallOrder[1]).toBeGreaterThan(u.mock.invocationCallOrder[0]),(0,e.expect)(y.mock.invocationCallOrder[1]).toBeLessThan(S.mock.invocationCallOrder[0]),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),t()}catch(v){l(v)}},l)})),(0,e.it)("generic prompt failure (non-cancel) \u2192 tx-check provided again before basic",()=>new Promise((t,l)=>{o({transactionChecksEnabled:!0,transactionChecksOptIn:!0}),u.mockResolvedValue(n),R.mockResolvedValue((0,a.CommandResultFactory)({error:new V.SolanaAppCommandError({errorCode:"6a80",message:"bad descriptor"})})),r(p,c=>{try{(0,e.expect)(R).toHaveBeenCalled(),(0,e.expect)(y).toHaveBeenCalledTimes(2),(0,e.expect)(y.mock.invocationCallOrder[1]).toBeGreaterThan(R.mock.invocationCallOrder[0]),(0,e.expect)(S).toHaveBeenCalled(),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),t()}catch(v){l(v)}},l)})),(0,e.it)("opt-in accepted on first pass \u2192 re-provision does not prompt again",()=>new Promise((t,l)=>{o({transactionChecksEnabled:!1,transactionChecksOptIn:!1}),r(p,c=>{try{(0,e.expect)(b).toHaveBeenCalledTimes(1),(0,e.expect)(y).toHaveBeenCalledTimes(2),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),t()}catch(v){l(v)}},l)})),(0,e.it)("opt-in declined on first pass \u2192 no prompt and no provide on fallback",()=>new Promise((t,l)=>{o({transactionChecksEnabled:!1,transactionChecksOptIn:!1}),b.mockResolvedValue((0,a.CommandResultFactory)({data:{enabled:!1}})),r(p,c=>{try{(0,e.expect)(b).toHaveBeenCalledTimes(1),(0,e.expect)(y).not.toHaveBeenCalled(),(0,e.expect)(S).toHaveBeenCalled(),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),t()}catch(v){l(v)}},l)})),(0,e.it)("generic prepared + signed \u2192 tx-check provided once",()=>new Promise((t,l)=>{o({transactionChecksEnabled:!0,transactionChecksOptIn:!0}),u.mockResolvedValue(n),r(p,c=>{try{(0,e.expect)(y).toHaveBeenCalledTimes(1),(0,e.expect)(S).not.toHaveBeenCalled(),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),t()}catch(v){l(v)}},l)})),(0,e.it)("generic unavailable \u2192 tx-check provided once before basic",()=>new Promise((t,l)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_TRANSACTION_CHECKS_VERSION,a.DeviceModelId.FLEX)),m.mockResolvedValue((0,a.CommandResultFactory)({data:{...C(s.SOLANA_MIN_TRANSACTION_CHECKS_VERSION),transactionChecksEnabled:!0,transactionChecksOptIn:!0}})),r(p,c=>{try{(0,e.expect)(u).not.toHaveBeenCalled(),(0,e.expect)(y).toHaveBeenCalledTimes(1),(0,e.expect)(S).toHaveBeenCalled(),(0,e.expect)(c[c.length-1].status).toBe(a.DeviceActionStatus.Completed),t()}catch(v){l(v)}},l)}))}),(0,e.it)("e2e sequence: legacy SPL path with RPC then basic provisioning then delayed terminal",()=>new Promise((i,o)=>{S.mockResolvedValue({transactionType:M.SolanaTransactionTypes.SPL,data:{tokenAddress:null,createATA:!1}}),r(I,n=>{try{(0,e.expect)(O(n)).toEqual([k.signTransactionDAStateSteps.GET_APP_CONFIG,k.signTransactionDAStateSteps.INSPECT_TRANSACTION,k.signTransactionDAStateSteps.BUILD_BASIC_CLEAR_SIGN_CONTEXT,k.signTransactionDAStateSteps.PROVIDE_BASIC_CLEAR_SIGN_CONTEXT,A.signClearSignDAStateSteps.PREVIEW_TRANSACTION,A.signClearSignDAStateSteps.FETCH_BLOCKHASH,A.signClearSignDAStateSteps.DELAYED_SIGN]);const t=n[n.length-1];(0,e.expect)(t.status).toBe(a.DeviceActionStatus.Completed),i()}catch(t){o(t)}},o)})),(0,e.it)("e2e sequence: generic clear-sign armed then terminal refresh + delayed sign",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),u.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),r(I,n=>{try{(0,e.expect)(O(n)).toEqual([k.signTransactionDAStateSteps.GET_APP_CONFIG,k.signTransactionDAStateSteps.BUILD_GENERIC_CLEAR_SIGN_CONTEXT,k.signTransactionDAStateSteps.PROVIDE_GENERIC_CLEAR_SIGN_CONTEXT,k.signTransactionDAStateSteps.FINALIZE_GENERIC_CLEAR_SIGN,A.signClearSignDAStateSteps.PROMPT_UI_DISPLAY,A.signClearSignDAStateSteps.FETCH_BLOCKHASH,A.signClearSignDAStateSteps.DELAYED_SIGN]);const t=n[n.length-1];(0,e.expect)(t.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(t.status===a.DeviceActionStatus.Completed&&t.output).toEqual(x),i()}catch(t){o(t)}},o)})),(0,e.describe)("Report state \u2014 isBlindSign contract",()=>{(0,e.it)("legacy path (generic gate skipped) \u2192 isBlindSign: true, reportSign called once",()=>new Promise((i,o)=>{r(p,()=>{try{(0,e.expect)(f).toHaveBeenCalledOnce();const n=f.mock.calls[0][0];(0,e.expect)(n.input.isBlindSign).toBe(!0),i()}catch(n){o(n)}},o)})),(0,e.it)("generic clear-sign success \u2192 isBlindSign: false, reportSign called once",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),u.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),r(I,()=>{try{(0,e.expect)(f).toHaveBeenCalledOnce();const n=f.mock.calls[0][0];(0,e.expect)(n.input.isBlindSign).toBe(!1),i()}catch(n){o(n)}},o)})),(0,e.it)("generic cancel (6985) \u2192 isBlindSign: false, reportSign called once",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),u.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),R.mockResolvedValue((0,a.CommandResultFactory)({error:new V.SolanaAppCommandError({errorCode:"6985",message:"Canceled by user"})})),r(H,()=>{try{(0,e.expect)(f).toHaveBeenCalledOnce();const n=f.mock.calls[0][0];(0,e.expect)(n.input.isBlindSign).toBe(!1),i()}catch(n){o(n)}},o)})),(0,e.it)("generic non-cancel prompt failure degrades to basic \u2192 isBlindSign: true, reportSign called once",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),u.mockResolvedValue({mode:"full",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[]}),R.mockResolvedValue((0,a.CommandResultFactory)({error:new V.SolanaAppCommandError({errorCode:"6f01",message:"Display error"})})),r(H,()=>{try{(0,e.expect)(f).toHaveBeenCalledOnce();const n=f.mock.calls[0][0];(0,e.expect)(n.input.isBlindSign).toBe(!0),i()}catch(n){o(n)}},o)})),(0,e.it)("generic build degrades with staleDescriptor \u2192 reportSign receives staleDescriptor: true",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),u.mockResolvedValue({mode:"none",poolContexts:[],instructionInfoContexts:[],unrecognizedProgramIds:[],staleDescriptor:!0}),r(H,()=>{try{(0,e.expect)(f).toHaveBeenCalledOnce();const n=f.mock.calls[0][0];(0,e.expect)(n.input.isBlindSign).toBe(!0),(0,e.expect)(n.input.staleDescriptor).toBe(!0),i()}catch(n){o(n)}},o)})),(0,e.it)("basic-flow rule match \u2192 isBlindSign: false, reportSign called once",()=>new Promise((i,o)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),h.mockResolvedValue("native-staking"),r(p,()=>{try{(0,e.expect)(f).toHaveBeenCalledOnce();const n=f.mock.calls[0][0];(0,e.expect)(n.input.isBlindSign).toBe(!1),i()}catch(n){o(n)}},o)}))}),(0,e.describe)("basic-flow routing",()=>{function i(){d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION,a.DeviceModelId.FLEX)),m.mockResolvedValue((0,a.CommandResultFactory)({data:{...C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION),transactionChecksEnabled:!0,transactionChecksOptIn:!0}}))}(0,e.it)("rule match \u2192 TxCheck then basic, skipping generic and the tx-check re-provision",()=>new Promise((o,n)=>{i(),h.mockResolvedValue("native-staking"),r(p,t=>{try{(0,e.expect)(h).toHaveBeenCalledOnce();const l=h.mock.calls[0][0];(0,e.expect)(l.input).toEqual({messageBytes:L}),(0,e.expect)(y).toHaveBeenCalledOnce(),(0,e.expect)(y.mock.invocationCallOrder[0]).toBeLessThan(h.mock.invocationCallOrder[0]),(0,e.expect)(u).not.toHaveBeenCalled(),(0,e.expect)(R).not.toHaveBeenCalled(),(0,e.expect)(S).toHaveBeenCalled(),(0,e.expect)(B).toHaveBeenCalled();const c=O(t);(0,e.expect)(c).not.toContain(k.signTransactionDAStateSteps.BUILD_GENERIC_CLEAR_SIGN_CONTEXT);const v=t[t.length-1];(0,e.expect)(v.status).toBe(a.DeviceActionStatus.Completed),(0,e.expect)(v.status===a.DeviceActionStatus.Completed&&v.output).toEqual(P),o()}catch(l){n(l)}},n)})),(0,e.it)("rule match + delayed \u2192 basic terminal still refreshes the blockhash",()=>new Promise((o,n)=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)})),h.mockResolvedValue("native-staking"),r(I,t=>{try{(0,e.expect)(u).not.toHaveBeenCalled(),(0,e.expect)(O(t)).toEqual([k.signTransactionDAStateSteps.GET_APP_CONFIG,k.signTransactionDAStateSteps.INSPECT_TRANSACTION,A.signClearSignDAStateSteps.PREVIEW_TRANSACTION,A.signClearSignDAStateSteps.FETCH_BLOCKHASH,A.signClearSignDAStateSteps.DELAYED_SIGN]),(0,e.expect)(E).toHaveBeenCalled(),o()}catch(l){n(l)}},n)})),(0,e.it)("no rule match \u2192 generic path unchanged",()=>new Promise((o,n)=>{i(),r(p,t=>{try{(0,e.expect)(h).toHaveBeenCalledOnce(),(0,e.expect)(u).toHaveBeenCalled(),(0,e.expect)(y).toHaveBeenCalledTimes(2),(0,e.expect)(S).toHaveBeenCalled(),(0,e.expect)(t[t.length-1].status).toBe(a.DeviceActionStatus.Completed),o()}catch(l){n(l)}},n)})),(0,e.it)("routing actor failure \u2192 falls through to generic",()=>new Promise((o,n)=>{i(),h.mockRejectedValue(new Error("boom")),r(p,t=>{try{(0,e.expect)(u).toHaveBeenCalled(),(0,e.expect)(t[t.length-1].status).toBe(a.DeviceActionStatus.Completed),o()}catch(l){n(l)}},n)})),e.it.each([["app below the generic min version",()=>{},p],["Nano S",()=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION,a.DeviceModelId.NANO_S)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)}))},p],["genericClearSign in disabledFeatures",()=>{d.getDeviceSessionState.mockReturnValue(g(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)),m.mockResolvedValue((0,a.CommandResultFactory)({data:C(s.SOLANA_MIN_GENERIC_CLEAR_SIGN_VERSION)}))},{...p,disabledFeatures:["genericClearSign"]}]])("generic unavailable (%s) \u2192 routing is not resolved",(o,n,t)=>new Promise((l,c)=>{n(),r(t,v=>{try{(0,e.expect)(h).not.toHaveBeenCalled(),(0,e.expect)(u).not.toHaveBeenCalled(),(0,e.expect)(B).toHaveBeenCalled(),(0,e.expect)(v[v.length-1].status).toBe(a.DeviceActionStatus.Completed),l()}catch(ie){c(ie)}},c)}))}),(0,e.describe)("resolveSigningRoute dependency",()=>{const i=o=>new N.SignTransactionDeviceAction({input:p}).extractDependencies(d).resolveSigningRoute({input:{messageBytes:o}});(0,e.it)("returns the native-staking rule for a Ledger Wallet unstake",async()=>{await(0,e.expect)(i(w.UNSTAKE_MESSAGE)).resolves.toBe("native-staking")}),(0,e.it)("returns null for a non-staking transaction",async()=>{await(0,e.expect)(i(w.SEND_WITH_MEMO_MESSAGE)).resolves.toBeNull()}),(0,e.it)("returns null for an unparseable message",async()=>{await(0,e.expect)(i(L)).resolves.toBeNull()}),(0,e.it)("matches a rule served by CAL and looks up the transaction's programs",async()=>{const o=e.vi.fn().mockResolvedValue([{type:G.ClearSignContextType.SOLANA_BASIC_FLOW_RULE,payload:{id:"send-with-memo",required:[{programId:"MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"}],allowed:[{programId:"11111111111111111111111111111111"}]}}]),n={getContexts:o};await(0,e.expect)(new N.SignTransactionDeviceAction({input:{...p,contextModule:n}}).extractDependencies(d).resolveSigningRoute({input:{messageBytes:w.SEND_WITH_MEMO_MESSAGE}})).resolves.toBe("send-with-memo"),(0,e.expect)(o).toHaveBeenCalledWith({programIds:e.expect.arrayContaining(["11111111111111111111111111111111","MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"])},[G.ClearSignContextType.SOLANA_BASIC_FLOW_RULE])})})});
|
|
2
2
|
//# sourceMappingURL=SignTransactionDeviceAction.test.js.map
|