@ledgerhq/device-contacts-kit 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +22 -13
  2. package/lib/cjs/api/app-binder/RenameContactDeviceActionTypes.js.map +1 -1
  3. package/lib/cjs/api/index.js +1 -1
  4. package/lib/cjs/api/index.js.map +3 -3
  5. package/lib/cjs/api/model/ContactsVersionRequirements.js +1 -1
  6. package/lib/cjs/api/model/ContactsVersionRequirements.js.map +3 -3
  7. package/lib/cjs/api/model/ContactsVersionRequirements.test.js +1 -1
  8. package/lib/cjs/api/model/ContactsVersionRequirements.test.js.map +3 -3
  9. package/lib/cjs/api/model/ProvideContact.js +2 -0
  10. package/lib/cjs/api/model/ProvideContact.js.map +7 -0
  11. package/lib/cjs/api/model/RenameContact.js.map +1 -1
  12. package/lib/cjs/internal/app-binder/command/EditExternalAddressIdentifierCommand.js +1 -1
  13. package/lib/cjs/internal/app-binder/command/EditExternalAddressIdentifierCommand.js.map +3 -3
  14. package/lib/cjs/internal/app-binder/command/EditExternalAddressScopeCommand.js +1 -1
  15. package/lib/cjs/internal/app-binder/command/EditExternalAddressScopeCommand.js.map +3 -3
  16. package/lib/cjs/internal/app-binder/command/ProvideContactCommand.js +2 -0
  17. package/lib/cjs/internal/app-binder/command/ProvideContactCommand.js.map +7 -0
  18. package/lib/cjs/internal/app-binder/command/ProvideContactCommand.test.js +2 -0
  19. package/lib/cjs/internal/app-binder/command/ProvideContactCommand.test.js.map +7 -0
  20. package/lib/cjs/internal/app-binder/command/RegisterIdentityCommand.js +1 -1
  21. package/lib/cjs/internal/app-binder/command/RegisterIdentityCommand.js.map +3 -3
  22. package/lib/cjs/internal/app-binder/command/RenameContactCommand.js +1 -1
  23. package/lib/cjs/internal/app-binder/command/RenameContactCommand.js.map +3 -3
  24. package/lib/cjs/internal/app-binder/command/RenameContactCommand.test.js +1 -1
  25. package/lib/cjs/internal/app-binder/command/RenameContactCommand.test.js.map +2 -2
  26. package/lib/cjs/internal/app-binder/contactsVersionGuards.js +1 -1
  27. package/lib/cjs/internal/app-binder/contactsVersionGuards.js.map +3 -3
  28. package/lib/cjs/internal/app-binder/contactsVersionGuards.test.js +1 -1
  29. package/lib/cjs/internal/app-binder/contactsVersionGuards.test.js.map +2 -2
  30. package/lib/cjs/internal/app-binder/device-action/RenameContact/RenameContactDeviceAction.js +1 -1
  31. package/lib/cjs/internal/app-binder/device-action/RenameContact/RenameContactDeviceAction.js.map +3 -3
  32. package/lib/cjs/internal/app-binder/device-action/RenameContact/RenameContactDeviceAction.test.js +1 -1
  33. package/lib/cjs/internal/app-binder/device-action/RenameContact/RenameContactDeviceAction.test.js.map +3 -3
  34. package/lib/cjs/internal/app-binder/model/contactsConstants.js +1 -1
  35. package/lib/cjs/internal/app-binder/model/contactsConstants.js.map +3 -3
  36. package/lib/cjs/internal/app-binder/model/contactsErrors.js +1 -1
  37. package/lib/cjs/internal/app-binder/model/contactsErrors.js.map +3 -3
  38. package/lib/cjs/internal/app-binder/services/provideContact.js +2 -0
  39. package/lib/cjs/internal/app-binder/services/provideContact.js.map +7 -0
  40. package/lib/cjs/internal/app-binder/services/provideContact.test.js +2 -0
  41. package/lib/cjs/internal/app-binder/services/provideContact.test.js.map +7 -0
  42. package/lib/cjs/internal/app-binder/task/SendRegisterIdentityTask.js.map +2 -2
  43. package/lib/cjs/internal/app-binder/task/SendRegisterIdentityTask.test.js.map +1 -1
  44. package/lib/cjs/internal/app-binder/task/SendRenameContactTask.js +1 -1
  45. package/lib/cjs/internal/app-binder/task/SendRenameContactTask.js.map +2 -2
  46. package/lib/cjs/internal/app-binder/task/SendRenameContactTask.test.js +1 -1
  47. package/lib/cjs/internal/app-binder/task/SendRenameContactTask.test.js.map +3 -3
  48. package/lib/cjs/package.json +2 -2
  49. package/lib/esm/api/index.js +1 -1
  50. package/lib/esm/api/index.js.map +3 -3
  51. package/lib/esm/api/model/ContactsVersionRequirements.js +1 -1
  52. package/lib/esm/api/model/ContactsVersionRequirements.js.map +3 -3
  53. package/lib/esm/api/model/ContactsVersionRequirements.test.js +1 -1
  54. package/lib/esm/api/model/ContactsVersionRequirements.test.js.map +3 -3
  55. package/lib/esm/api/model/ProvideContact.js +1 -0
  56. package/lib/esm/api/model/ProvideContact.js.map +7 -0
  57. package/lib/esm/internal/app-binder/command/EditExternalAddressIdentifierCommand.js +1 -1
  58. package/lib/esm/internal/app-binder/command/EditExternalAddressIdentifierCommand.js.map +3 -3
  59. package/lib/esm/internal/app-binder/command/EditExternalAddressScopeCommand.js +1 -1
  60. package/lib/esm/internal/app-binder/command/EditExternalAddressScopeCommand.js.map +3 -3
  61. package/lib/esm/internal/app-binder/command/ProvideContactCommand.js +2 -0
  62. package/lib/esm/internal/app-binder/command/ProvideContactCommand.js.map +7 -0
  63. package/lib/esm/internal/app-binder/command/ProvideContactCommand.test.js +2 -0
  64. package/lib/esm/internal/app-binder/command/ProvideContactCommand.test.js.map +7 -0
  65. package/lib/esm/internal/app-binder/command/RegisterIdentityCommand.js +1 -1
  66. package/lib/esm/internal/app-binder/command/RegisterIdentityCommand.js.map +3 -3
  67. package/lib/esm/internal/app-binder/command/RenameContactCommand.js +1 -1
  68. package/lib/esm/internal/app-binder/command/RenameContactCommand.js.map +3 -3
  69. package/lib/esm/internal/app-binder/command/RenameContactCommand.test.js +1 -1
  70. package/lib/esm/internal/app-binder/command/RenameContactCommand.test.js.map +3 -3
  71. package/lib/esm/internal/app-binder/contactsVersionGuards.js +1 -1
  72. package/lib/esm/internal/app-binder/contactsVersionGuards.js.map +3 -3
  73. package/lib/esm/internal/app-binder/contactsVersionGuards.test.js +1 -1
  74. package/lib/esm/internal/app-binder/contactsVersionGuards.test.js.map +3 -3
  75. package/lib/esm/internal/app-binder/device-action/RenameContact/RenameContactDeviceAction.js +1 -1
  76. package/lib/esm/internal/app-binder/device-action/RenameContact/RenameContactDeviceAction.js.map +3 -3
  77. package/lib/esm/internal/app-binder/device-action/RenameContact/RenameContactDeviceAction.test.js +1 -1
  78. package/lib/esm/internal/app-binder/device-action/RenameContact/RenameContactDeviceAction.test.js.map +3 -3
  79. package/lib/esm/internal/app-binder/model/contactsConstants.js +1 -1
  80. package/lib/esm/internal/app-binder/model/contactsConstants.js.map +3 -3
  81. package/lib/esm/internal/app-binder/model/contactsErrors.js +1 -1
  82. package/lib/esm/internal/app-binder/model/contactsErrors.js.map +3 -3
  83. package/lib/esm/internal/app-binder/services/provideContact.js +2 -0
  84. package/lib/esm/internal/app-binder/services/provideContact.js.map +7 -0
  85. package/lib/esm/internal/app-binder/services/provideContact.test.js +2 -0
  86. package/lib/esm/internal/app-binder/services/provideContact.test.js.map +7 -0
  87. package/lib/esm/internal/app-binder/task/SendRegisterIdentityTask.js.map +2 -2
  88. package/lib/esm/internal/app-binder/task/SendRegisterIdentityTask.test.js.map +1 -1
  89. package/lib/esm/internal/app-binder/task/SendRenameContactTask.js +1 -1
  90. package/lib/esm/internal/app-binder/task/SendRenameContactTask.js.map +2 -2
  91. package/lib/esm/internal/app-binder/task/SendRenameContactTask.test.js +1 -1
  92. package/lib/esm/internal/app-binder/task/SendRenameContactTask.test.js.map +3 -3
  93. package/lib/esm/package.json +2 -2
  94. package/lib/types/api/app-binder/RenameContactDeviceActionTypes.d.ts +2 -1
  95. package/lib/types/api/app-binder/RenameContactDeviceActionTypes.d.ts.map +1 -1
  96. package/lib/types/api/index.d.ts +4 -1
  97. package/lib/types/api/index.d.ts.map +1 -1
  98. package/lib/types/api/model/ContactsVersionRequirements.d.ts +38 -23
  99. package/lib/types/api/model/ContactsVersionRequirements.d.ts.map +1 -1
  100. package/lib/types/api/model/ProvideContact.d.ts +20 -0
  101. package/lib/types/api/model/ProvideContact.d.ts.map +1 -0
  102. package/lib/types/api/model/RenameContact.d.ts +5 -3
  103. package/lib/types/api/model/RenameContact.d.ts.map +1 -1
  104. package/lib/types/internal/app-binder/command/EditExternalAddressIdentifierCommand.d.ts.map +1 -1
  105. package/lib/types/internal/app-binder/command/EditExternalAddressScopeCommand.d.ts.map +1 -1
  106. package/lib/types/internal/app-binder/command/ProvideContactCommand.d.ts +18 -0
  107. package/lib/types/internal/app-binder/command/ProvideContactCommand.d.ts.map +1 -0
  108. package/lib/types/internal/app-binder/command/ProvideContactCommand.test.d.ts +2 -0
  109. package/lib/types/internal/app-binder/command/ProvideContactCommand.test.d.ts.map +1 -0
  110. package/lib/types/internal/app-binder/command/RegisterIdentityCommand.d.ts.map +1 -1
  111. package/lib/types/internal/app-binder/command/RenameContactCommand.d.ts.map +1 -1
  112. package/lib/types/internal/app-binder/contactsVersionGuards.d.ts +9 -1
  113. package/lib/types/internal/app-binder/contactsVersionGuards.d.ts.map +1 -1
  114. package/lib/types/internal/app-binder/device-action/RenameContact/RenameContactDeviceAction.d.ts +4 -3
  115. package/lib/types/internal/app-binder/device-action/RenameContact/RenameContactDeviceAction.d.ts.map +1 -1
  116. package/lib/types/internal/app-binder/model/contactsConstants.d.ts +2 -0
  117. package/lib/types/internal/app-binder/model/contactsConstants.d.ts.map +1 -1
  118. package/lib/types/internal/app-binder/model/contactsErrors.d.ts +21 -2
  119. package/lib/types/internal/app-binder/model/contactsErrors.d.ts.map +1 -1
  120. package/lib/types/internal/app-binder/services/provideContact.d.ts +15 -0
  121. package/lib/types/internal/app-binder/services/provideContact.d.ts.map +1 -0
  122. package/lib/types/internal/app-binder/services/provideContact.test.d.ts +2 -0
  123. package/lib/types/internal/app-binder/services/provideContact.test.d.ts.map +1 -0
  124. package/lib/types/internal/app-binder/task/SendRegisterIdentityTask.d.ts.map +1 -1
  125. package/lib/types/internal/app-binder/task/SendRenameContactTask.d.ts +8 -0
  126. package/lib/types/internal/app-binder/task/SendRenameContactTask.d.ts.map +1 -1
  127. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  128. package/package.json +6 -6
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/model/contactsErrors.ts"],
4
- "sourcesContent": ["import {\n type CommandErrorArgs,\n type CommandErrors,\n DeviceExchangeError,\n type DmkError,\n} from \"@ledgerhq/device-management-kit\";\n\n/**\n * Status word returned by the app's Address Book *edit* operations when the\n * seed-bound HMAC / group-handle verification fails \u2014 i.e. the entry was\n * registered with a different seed than the one currently on the device.\n *\n * The device runs this check *before* showing any UI and returns 0x6982 *only*\n * for seed-binding failures (user rejection and TLV errors return 0x6a80,\n * address validation returns 0x6af0), so 0x6982 is an unambiguous \"wrong seed\"\n * signal that consumers (e.g. Ledger Wallet) can catch to guide the user.\n */\nexport const CONTACT_SEED_MISMATCH_ERROR_CODE = \"6982\" as const;\n\nexport type ContactsErrorCodes =\n | \"6982\"\n | \"6800\"\n | \"6983\"\n | \"6984\"\n | \"6985\"\n | \"6a80\"\n | \"6a84\"\n | \"6a88\"\n | \"6af0\"\n | \"6b00\"\n | \"6f00\";\n\nexport const CONTACTS_APP_ERRORS: CommandErrors<ContactsErrorCodes> = {\n [CONTACT_SEED_MISMATCH_ERROR_CODE]: {\n message:\n \"This address-book entry was registered with a different seed. Connect the Ledger device that registered it to modify this contact.\",\n },\n \"6800\": { message: \"Internal error (Please report)\" },\n \"6983\": { message: \"Wrong data length\" },\n \"6984\": {\n message:\n \"Unsupported address-book operation for this device or app configuration\",\n },\n \"6985\": { message: \"Condition not satisfied\" },\n \"6a80\": { message: \"Invalid contact data, or operation refused on device\" },\n \"6a84\": { message: \"Insufficient memory: the device address book is full\" },\n \"6a88\": { message: \"Contact data not found\" },\n \"6af0\": { message: \"Invalid value for this contact entry\" },\n \"6b00\": { message: \"The app rejected the contact data\" },\n \"6f00\": { message: \"Technical problem (Internal error, please report)\" },\n};\n\nexport class ContactsCommandError extends DeviceExchangeError<ContactsErrorCodes> {\n constructor(args: CommandErrorArgs<ContactsErrorCodes>) {\n super({ tag: \"ContactsCommandError\", ...args });\n }\n}\n\nexport const contactsCommandErrorFactory = (\n args: CommandErrorArgs<ContactsErrorCodes>,\n) => new ContactsCommandError(args);\n\n/**\n * Raised by a Contacts `DeviceAction` when the connected device model, app\n * version, or OS version does not meet the Contacts requirements \u2014 i.e. the\n * DSDK-1376 support check fails before any APDU is sent.\n */\nexport class ContactsVersionRequirementError implements DmkError {\n readonly _tag = \"ContactsVersionRequirementError\";\n readonly originalError?: unknown;\n constructor(\n readonly message = \"The connected device or app does not meet the Contacts version requirements.\",\n ) {}\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,qCAAAC,EAAA,yBAAAC,EAAA,oCAAAC,EAAA,gCAAAC,IAAA,eAAAC,EAAAP,GAAA,IAAAQ,EAKO,2CAYA,MAAML,EAAmC,OAenCD,EAAyD,CACpE,CAACC,CAAgC,EAAG,CAClC,QACE,oIACJ,EACA,KAAQ,CAAE,QAAS,gCAAiC,EACpD,KAAQ,CAAE,QAAS,mBAAoB,EACvC,KAAQ,CACN,QACE,yEACJ,EACA,KAAQ,CAAE,QAAS,yBAA0B,EAC7C,OAAQ,CAAE,QAAS,sDAAuD,EAC1E,OAAQ,CAAE,QAAS,sDAAuD,EAC1E,OAAQ,CAAE,QAAS,wBAAyB,EAC5C,OAAQ,CAAE,QAAS,sCAAuC,EAC1D,OAAQ,CAAE,QAAS,mCAAoC,EACvD,OAAQ,CAAE,QAAS,mDAAoD,CACzE,EAEO,MAAMC,UAA6B,qBAAwC,CAChF,YAAYK,EAA4C,CACtD,MAAM,CAAE,IAAK,uBAAwB,GAAGA,CAAK,CAAC,CAChD,CACF,CAEO,MAAMH,EACXG,GACG,IAAIL,EAAqBK,CAAI,EAO3B,MAAMJ,CAAoD,CAG/D,YACWK,EAAU,+EACnB,CADS,aAAAA,CACR,CAJM,KAAO,kCACP,aAIX",
6
- "names": ["contactsErrors_exports", "__export", "CONTACTS_APP_ERRORS", "CONTACT_SEED_MISMATCH_ERROR_CODE", "ContactsCommandError", "ContactsVersionRequirementError", "contactsCommandErrorFactory", "__toCommonJS", "import_device_management_kit", "args", "message"]
4
+ "sourcesContent": ["import {\n ApduParser,\n type ApduResponse,\n type CommandErrorArgs,\n type CommandErrorResult,\n type CommandErrors,\n type CommandResult,\n DeviceExchangeError,\n type DmkError,\n DmkResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\n\n/**\n * Status word returned by the app's Address Book *edit* operations when the\n * seed-bound HMAC / group-handle verification fails \u2014 i.e. the entry was\n * registered with a different seed than the one currently on the device.\n *\n * The device runs this check *before* showing any UI and returns 0x6982 *only*\n * for seed-binding failures (user rejection and TLV errors return 0x6a80,\n * address validation returns 0x6af0), so 0x6982 is an unambiguous \"wrong seed\"\n * signal that consumers (e.g. Ledger Wallet) can catch to guide the user.\n */\nexport const CONTACT_SEED_MISMATCH_ERROR_CODE = \"6982\" as const;\n\nexport type ContactsErrorCodes =\n | \"6982\"\n | \"6800\"\n | \"6983\"\n | \"6984\"\n | \"6985\"\n | \"686a\"\n | \"6a80\"\n | \"6a84\"\n | \"6a88\"\n | \"6af0\"\n | \"6b00\"\n | \"6f00\";\n\nexport const CONTACTS_APP_ERRORS: CommandErrors<ContactsErrorCodes> = {\n [CONTACT_SEED_MISMATCH_ERROR_CODE]: {\n message:\n \"This address-book entry was registered with a different seed. Connect the Ledger device that registered it to modify this contact.\",\n },\n \"6800\": { message: \"Internal error (Please report)\" },\n \"6983\": { message: \"Wrong data length\" },\n \"6984\": {\n message:\n \"Unsupported address-book operation for this device or app configuration\",\n },\n \"6985\": { message: \"Condition not satisfied\" },\n // Dashboard EDIT CONTACT NAME on an OS build that still mandates the\n // DERIVATION_PATH (tag 0x69) but received a payload without it. DSDK-1481\n // sends the path conditionally by OS version so this should not occur in\n // practice; mapped here so that, if it ever does, the host gets an actionable\n // message instead of a bare UnknownDeviceExchangeError.\n \"686a\": {\n message:\n \"This device's firmware is out of date for the address book. Update your Ledger device to the latest firmware, then try again.\",\n },\n \"6a80\": { message: \"Invalid contact data, or operation refused on device\" },\n \"6a84\": { message: \"Insufficient memory: the device address book is full\" },\n \"6a88\": { message: \"Contact data not found\" },\n \"6af0\": { message: \"Invalid value for this contact entry\" },\n \"6b00\": { message: \"The app rejected the contact data\" },\n \"6f00\": { message: \"Technical problem (Internal error, please report)\" },\n};\n\nexport class ContactsCommandError extends DeviceExchangeError<ContactsErrorCodes> {\n constructor(args: CommandErrorArgs<ContactsErrorCodes>) {\n super({ tag: \"ContactsCommandError\", ...args });\n }\n}\n\nexport const contactsCommandErrorFactory = (\n args: CommandErrorArgs<ContactsErrorCodes>,\n) => new ContactsCommandError(args);\n\n/**\n * A {@link CommandErrorHelper} preconfigured with the Contacts error map, that\n * additionally guarantees no address-book command ever surfaces a bare\n * `UnknownDeviceExchangeError`.\n *\n * The base helper maps known status words to a {@link ContactsCommandError} and\n * falls back to the global handler for the rest \u2014 which, for a status word in\n * neither the Contacts nor the global dictionary (e.g. 0x686A before it was\n * mapped), yields an `UnknownDeviceExchangeError` whose message is a generic\n * \"Unexpected device exchange error happened.\" with no status word and no\n * guidance. This subclass replaces that specific case with an\n * `InvalidStatusWordError` naming the actual status word and pointing at a\n * firmware/app update, so the host always has something actionable to show.\n */\nexport class ContactsCommandErrorHelper<Response> extends CommandErrorHelper<\n Response,\n ContactsErrorCodes\n> {\n constructor() {\n super(CONTACTS_APP_ERRORS, contactsCommandErrorFactory);\n }\n\n override getError(\n apduResponse: ApduResponse,\n ): CommandResult<Response, ContactsErrorCodes> | undefined {\n const result = super.getError(apduResponse);\n if (\n result === undefined ||\n isSuccessCommandResult(result) ||\n result.error._tag !== \"UnknownDeviceExchangeError\"\n ) {\n return result;\n }\n const statusWord = new ApduParser(apduResponse).encodeToHexaString(\n apduResponse.statusCode,\n );\n return DmkResultFactory<\n Response,\n CommandErrorResult<ContactsErrorCodes>[\"error\"]\n >({\n error: new InvalidStatusWordError(\n `The device returned an unexpected status word (0x${statusWord}) for this address-book operation. Update your Ledger device and Ethereum app to the latest version, then try again.`,\n ),\n });\n }\n}\n\n/**\n * Raised by a Contacts `DeviceAction` when the connected device model, app\n * version, or OS version does not meet the Contacts requirements \u2014 i.e. the\n * DSDK-1376 support check fails before any APDU is sent.\n */\nexport class ContactsVersionRequirementError implements DmkError {\n readonly _tag = \"ContactsVersionRequirementError\";\n readonly originalError?: unknown;\n constructor(\n readonly message = \"The connected device or app does not meet the Contacts version requirements.\",\n ) {}\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,qCAAAC,EAAA,yBAAAC,EAAA,+BAAAC,EAAA,oCAAAC,EAAA,gCAAAC,IAAA,eAAAC,EAAAR,GAAA,IAAAS,EAYO,2CACPC,EAAmC,kCAY5B,MAAMP,EAAmC,OAgBnCD,EAAyD,CACpE,CAACC,CAAgC,EAAG,CAClC,QACE,oIACJ,EACA,KAAQ,CAAE,QAAS,gCAAiC,EACpD,KAAQ,CAAE,QAAS,mBAAoB,EACvC,KAAQ,CACN,QACE,yEACJ,EACA,KAAQ,CAAE,QAAS,yBAA0B,EAM7C,OAAQ,CACN,QACE,+HACJ,EACA,OAAQ,CAAE,QAAS,sDAAuD,EAC1E,OAAQ,CAAE,QAAS,sDAAuD,EAC1E,OAAQ,CAAE,QAAS,wBAAyB,EAC5C,OAAQ,CAAE,QAAS,sCAAuC,EAC1D,OAAQ,CAAE,QAAS,mCAAoC,EACvD,OAAQ,CAAE,QAAS,mDAAoD,CACzE,EAEO,MAAMC,UAA6B,qBAAwC,CAChF,YAAYO,EAA4C,CACtD,MAAM,CAAE,IAAK,uBAAwB,GAAGA,CAAK,CAAC,CAChD,CACF,CAEO,MAAMJ,EACXI,GACG,IAAIP,EAAqBO,CAAI,EAgB3B,MAAMN,UAA6C,oBAGxD,CACA,aAAc,CACZ,MAAMH,EAAqBK,CAA2B,CACxD,CAES,SACPK,EACyD,CACzD,MAAMC,EAAS,MAAM,SAASD,CAAY,EAC1C,GACEC,IAAW,WACX,0BAAuBA,CAAM,GAC7BA,EAAO,MAAM,OAAS,6BAEtB,OAAOA,EAET,MAAMC,EAAa,IAAI,aAAWF,CAAY,EAAE,mBAC9CA,EAAa,UACf,EACA,SAAO,oBAGL,CACA,MAAO,IAAI,yBACT,oDAAoDE,CAAU,sHAChE,CACF,CAAC,CACH,CACF,CAOO,MAAMR,CAAoD,CAG/D,YACWS,EAAU,+EACnB,CADS,aAAAA,CACR,CAJM,KAAO,kCACP,aAIX",
6
+ "names": ["contactsErrors_exports", "__export", "CONTACTS_APP_ERRORS", "CONTACT_SEED_MISMATCH_ERROR_CODE", "ContactsCommandError", "ContactsCommandErrorHelper", "ContactsVersionRequirementError", "contactsCommandErrorFactory", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "args", "apduResponse", "result", "statusWord", "message"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var C=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var A=(e,a)=>{for(var r in a)C(e,r,{get:a[r],enumerable:!0})},P=(e,a,r,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let t of T(a))!s.call(e,t)&&t!==r&&C(e,t,{get:()=>a[t],enumerable:!(n=l(a,t))||n.enumerable});return e};var y=e=>P(C({},"__esModule",{value:!0}),e);var f={};A(f,{buildProvideContactPayload:()=>_,sendProvideContactPayload:()=>I});module.exports=y(f);var i=require("@ledgerhq/device-management-kit"),c=require("../../app-binder/command/ProvideContactCommand"),d=require("../../app-binder/model/contactsConstants"),o=require("../../app-binder/services/contactsTlvSerializer"),m=require("../../app-binder/services/sendFramedContactsPayload");function _(e){const a=d.BLOCKCHAIN_FAMILY_BY_NAME[e.blockchainFamily.toLowerCase()];if(a===void 0)throw new Error(`Unsupported blockchain family: ${e.blockchainFamily}`);const r=new i.ByteArrayBuilder;return(0,o.encodeTlvUInt8)(r,o.CONTACTS_TLV_TAG.STRUCT_TYPE,o.STRUCT_TYPE_PROVIDE_CONTACT),(0,o.encodeTlvUInt8)(r,o.CONTACTS_TLV_TAG.STRUCT_VERSION,o.STRUCT_VERSION_VALUE),(0,o.encodeTlvAscii)(r,o.CONTACTS_TLV_TAG.CONTACT_NAME,e.contactName),(0,o.encodeTlvAscii)(r,o.CONTACTS_TLV_TAG.SCOPE,e.scope),(0,o.encodeTlvBuffer)(r,o.CONTACTS_TLV_TAG.ACCOUNT_IDENTIFIER,e.identifier),(0,o.encodeTlvBuffer)(r,o.CONTACTS_TLV_TAG.GROUP_HANDLE,e.groupHandle),e.chainId!==void 0&&(0,o.encodeTlvChainId)(r,o.CONTACTS_TLV_TAG.CHAIN_ID,e.chainId),(0,o.encodeTlvUInt8)(r,o.CONTACTS_TLV_TAG.BLOCKCHAIN_FAMILY,a),(0,o.encodeTlvBuffer)(r,o.CONTACTS_TLV_TAG.HMAC_PROOF,e.hmacProof),(0,o.encodeTlvBuffer)(r,o.CONTACTS_TLV_TAG.HMAC_REST,e.hmacRest),r.build()}function I(e,{payload:a,logger:r}){return(0,m.sendFramedContactsPayload)(e,{payload:a,p1:d.SUB_CMD_PROVIDE_CONTACT,makeCommand:(n,t)=>new c.ProvideContactCommand({data:n,p2:t}),logger:r,commandTag:"provideContact"})}0&&(module.exports={buildProvideContactPayload,sendProvideContactPayload});
2
+ //# sourceMappingURL=provideContact.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/app-binder/services/provideContact.ts"],
4
+ "sourcesContent": ["// TLV assembly and transport for op 0x20 (Provide Contact), dispatched via the\n// chunked-framing scheme shared with the other address-book ops.\n//\n// Reference: Address Book Final Specifications \u2014 Provide Contact. Tag order:\n// STRUCT_TYPE, STRUCT_VERSION, CONTACT_NAME, SCOPE, ACCOUNT_IDENTIFIER,\n// GROUP_HANDLE, CHAIN_ID (Ethereum only), BLOCKCHAIN_FAMILY, HMAC_PROOF,\n// HMAC_REST. No DERIVATION_PATH \u2014 that tag is Ledger-Account only.\n//\n// Device replies SW=0x9000 with empty data on success \u2014 no fields to extract.\nimport {\n ByteArrayBuilder,\n type CommandResult,\n type InternalApi,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type ProvideContactInput } from \"@api/model/ProvideContact\";\nimport { ProvideContactCommand } from \"@internal/app-binder/command/ProvideContactCommand\";\nimport {\n BLOCKCHAIN_FAMILY_BY_NAME,\n SUB_CMD_PROVIDE_CONTACT,\n} from \"@internal/app-binder/model/contactsConstants\";\nimport { type ContactsErrorCodes } from \"@internal/app-binder/model/contactsErrors\";\nimport {\n CONTACTS_TLV_TAG,\n encodeTlvAscii,\n encodeTlvBuffer,\n encodeTlvChainId,\n encodeTlvUInt8,\n STRUCT_TYPE_PROVIDE_CONTACT,\n STRUCT_VERSION_VALUE,\n} from \"@internal/app-binder/services/contactsTlvSerializer\";\nimport { sendFramedContactsPayload } from \"@internal/app-binder/services/sendFramedContactsPayload\";\n\n/**\n * Encode a matched contact as the PROVIDE CONTACT TLV payload, without the\n * chunk framing. Pure, so callers can build it while matching a recipient\n * against the address book, with no device involved.\n */\nexport function buildProvideContactPayload(\n input: ProvideContactInput,\n): Uint8Array {\n const family =\n BLOCKCHAIN_FAMILY_BY_NAME[input.blockchainFamily.toLowerCase()];\n if (family === undefined) {\n throw new Error(`Unsupported blockchain family: ${input.blockchainFamily}`);\n }\n\n const builder = new ByteArrayBuilder();\n encodeTlvUInt8(\n builder,\n CONTACTS_TLV_TAG.STRUCT_TYPE,\n STRUCT_TYPE_PROVIDE_CONTACT,\n );\n encodeTlvUInt8(\n builder,\n CONTACTS_TLV_TAG.STRUCT_VERSION,\n STRUCT_VERSION_VALUE,\n );\n encodeTlvAscii(builder, CONTACTS_TLV_TAG.CONTACT_NAME, input.contactName);\n encodeTlvAscii(builder, CONTACTS_TLV_TAG.SCOPE, input.scope);\n encodeTlvBuffer(\n builder,\n CONTACTS_TLV_TAG.ACCOUNT_IDENTIFIER,\n input.identifier,\n );\n encodeTlvBuffer(builder, CONTACTS_TLV_TAG.GROUP_HANDLE, input.groupHandle);\n if (input.chainId !== undefined) {\n encodeTlvChainId(builder, CONTACTS_TLV_TAG.CHAIN_ID, input.chainId);\n }\n encodeTlvUInt8(builder, CONTACTS_TLV_TAG.BLOCKCHAIN_FAMILY, family);\n encodeTlvBuffer(builder, CONTACTS_TLV_TAG.HMAC_PROOF, input.hmacProof);\n encodeTlvBuffer(builder, CONTACTS_TLV_TAG.HMAC_REST, input.hmacRest);\n\n return builder.build();\n}\n\nexport type SendProvideContactPayloadArgs = {\n readonly payload: Uint8Array;\n readonly logger?: LoggerPublisherService;\n};\n\nexport function sendProvideContactPayload(\n api: InternalApi,\n { payload, logger }: SendProvideContactPayloadArgs,\n): Promise<CommandResult<void, ContactsErrorCodes>> {\n return sendFramedContactsPayload(api, {\n payload,\n p1: SUB_CMD_PROVIDE_CONTACT,\n makeCommand: (chunk, p2) => new ProvideContactCommand({ data: chunk, p2 }),\n logger,\n commandTag: \"provideContact\",\n }) as Promise<CommandResult<void, ContactsErrorCodes>>;\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,EAAA,8BAAAC,IAAA,eAAAC,EAAAJ,GASA,IAAAK,EAKO,2CAGPC,EAAsC,8DACtCC,EAGO,wDAEPC,EAQO,+DACPC,EAA0C,mEAOnC,SAASP,EACdQ,EACY,CACZ,MAAMC,EACJ,4BAA0BD,EAAM,iBAAiB,YAAY,CAAC,EAChE,GAAIC,IAAW,OACb,MAAM,IAAI,MAAM,kCAAkCD,EAAM,gBAAgB,EAAE,EAG5E,MAAME,EAAU,IAAI,mBACpB,2BACEA,EACA,mBAAiB,YACjB,6BACF,KACA,kBACEA,EACA,mBAAiB,eACjB,sBACF,KACA,kBAAeA,EAAS,mBAAiB,aAAcF,EAAM,WAAW,KACxE,kBAAeE,EAAS,mBAAiB,MAAOF,EAAM,KAAK,KAC3D,mBACEE,EACA,mBAAiB,mBACjBF,EAAM,UACR,KACA,mBAAgBE,EAAS,mBAAiB,aAAcF,EAAM,WAAW,EACrEA,EAAM,UAAY,WACpB,oBAAiBE,EAAS,mBAAiB,SAAUF,EAAM,OAAO,KAEpE,kBAAeE,EAAS,mBAAiB,kBAAmBD,CAAM,KAClE,mBAAgBC,EAAS,mBAAiB,WAAYF,EAAM,SAAS,KACrE,mBAAgBE,EAAS,mBAAiB,UAAWF,EAAM,QAAQ,EAE5DE,EAAQ,MAAM,CACvB,CAOO,SAAST,EACdU,EACA,CAAE,QAAAC,EAAS,OAAAC,CAAO,EACgC,CAClD,SAAO,6BAA0BF,EAAK,CACpC,QAAAC,EACA,GAAI,0BACJ,YAAa,CAACE,EAAOC,IAAO,IAAI,wBAAsB,CAAE,KAAMD,EAAO,GAAAC,CAAG,CAAC,EACzE,OAAAF,EACA,WAAY,gBACd,CAAC,CACH",
6
+ "names": ["provideContact_exports", "__export", "buildProvideContactPayload", "sendProvideContactPayload", "__toCommonJS", "import_device_management_kit", "import_ProvideContactCommand", "import_contactsConstants", "import_contactsTlvSerializer", "import_sendFramedContactsPayload", "input", "family", "builder", "api", "payload", "logger", "chunk", "p2"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=require("@ledgerhq/device-management-kit"),r=require("../../app-binder/command/ProvideContactCommand"),i=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),d=require("../../app-binder/model/contactsErrors"),t=require("./provideContact");const m=new Uint8Array(20).fill(17),p=new Uint8Array(64).fill(34),f=new Uint8Array(32).fill(51),h=new Uint8Array(32).fill(68),n={contactName:"Alice",scope:"Ethereum",identifier:m,groupHandle:p,hmacProof:f,hmacRest:h,blockchainFamily:"ethereum",chainId:1n},C="010133",u="020101",y="81f005416c696365",T="81f108457468657265756d",x="81f214"+"11".repeat(20),s="81f640"+"22".repeat(64),E="230101",P="510101",_="2920"+"33".repeat(32),I="81f720"+"44".repeat(32);describe("buildProvideContactPayload",()=>{it("encodes every tag in the order the spec lists",()=>{const e=(0,t.buildProvideContactPayload)(n);expect((0,o.bufferToHexaString)(e,!1)).toBe(C+u+y+T+x+s+E+P+_+I)}),it("fits an Ethereum contact in a single 255-byte chunk",()=>{expect((0,t.buildProvideContactPayload)(n).length).toBeLessThanOrEqual(253)}),it("omits CHAIN_ID for a family that does not carry one",()=>{const e=(0,t.buildProvideContactPayload)({...n,blockchainFamily:"bitcoin",chainId:void 0});expect((0,o.bufferToHexaString)(e,!1)).toContain(s+"510100")}),it("encodes a multi-byte chain id big-endian with no leading zeroes",()=>{const e=(0,t.buildProvideContactPayload)({...n,chainId:8453n});expect((0,o.bufferToHexaString)(e,!1)).toContain("23022105")}),it("accepts the family name case-insensitively",()=>{expect((0,t.buildProvideContactPayload)({...n,blockchainFamily:"Ethereum"})).toStrictEqual((0,t.buildProvideContactPayload)(n))}),it("throws on an unknown blockchain family",()=>{expect(()=>(0,t.buildProvideContactPayload)({...n,blockchainFamily:"dogecoin"})).toThrow("Unsupported blockchain family: dogecoin")})});describe("sendProvideContactPayload",()=>{it("sends one chunk under P2=0x00, prefixed with the 2-byte BE total length",async()=>{const e=(0,i.makeDeviceActionInternalApiMock)();e.sendCommand.mockResolvedValue((0,o.CommandResultFactory)({data:void 0}));const a=(0,t.buildProvideContactPayload)(n),l=await(0,t.sendProvideContactPayload)(e,{payload:a});expect(e.sendCommand).toHaveBeenCalledTimes(1);const c=e.sendCommand.mock.calls[0][0];expect(c).toBeInstanceOf(r.ProvideContactCommand),expect(c.args.p2).toBe(0),expect(c.args.data.slice(0,2)).toStrictEqual(Uint8Array.from([a.length>>8&255,a.length&255])),expect(c.args.data.slice(2)).toStrictEqual(a),expect(l.status).toBe(o.CommandResultStatus.Success)}),it("propagates a device rejection instead of throwing",async()=>{const e=(0,i.makeDeviceActionInternalApiMock)();e.sendCommand.mockResolvedValue((0,o.CommandResultFactory)({error:new d.ContactsCommandError({errorCode:"6982",message:"wrong seed"})}));const a=await(0,t.sendProvideContactPayload)(e,{payload:(0,t.buildProvideContactPayload)(n)});expect(a.status).toBe(o.CommandResultStatus.Error)})});
2
+ //# sourceMappingURL=provideContact.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/app-binder/services/provideContact.test.ts"],
4
+ "sourcesContent": ["import {\n bufferToHexaString,\n CommandResultFactory,\n CommandResultStatus,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type ProvideContactInput } from \"@api/model/ProvideContact\";\nimport { ProvideContactCommand } from \"@internal/app-binder/command/ProvideContactCommand\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { ContactsCommandError } from \"@internal/app-binder/model/contactsErrors\";\n\nimport {\n buildProvideContactPayload,\n sendProvideContactPayload,\n} from \"./provideContact\";\n\nconst IDENTIFIER = new Uint8Array(20).fill(0x11);\nconst GROUP_HANDLE = new Uint8Array(64).fill(0x22);\nconst HMAC_PROOF = new Uint8Array(32).fill(0x33);\nconst HMAC_REST = new Uint8Array(32).fill(0x44);\n\nconst INPUT: ProvideContactInput = {\n contactName: \"Alice\",\n scope: \"Ethereum\",\n identifier: IDENTIFIER,\n groupHandle: GROUP_HANDLE,\n hmacProof: HMAC_PROOF,\n hmacRest: HMAC_REST,\n blockchainFamily: \"ethereum\",\n chainId: 1n,\n};\n\n// Tags >= 0x80 use the DER long form (0x81 then the tag), hence the \"81\" prefix\n// on CONTACT_NAME (0xf0), SCOPE (0xf1), ACCOUNT_IDENTIFIER (0xf2),\n// GROUP_HANDLE (0xf6) and HMAC_REST (0xf7).\nconst STRUCT_TYPE_TLV = \"010133\";\nconst STRUCT_VERSION_TLV = \"020101\";\nconst CONTACT_NAME_TLV = \"81f005\" + \"416c696365\"; // \"Alice\"\nconst SCOPE_TLV = \"81f108\" + \"457468657265756d\"; // \"Ethereum\"\nconst IDENTIFIER_TLV = \"81f214\" + \"11\".repeat(20);\nconst GROUP_HANDLE_TLV = \"81f640\" + \"22\".repeat(64);\nconst CHAIN_ID_TLV = \"230101\";\nconst FAMILY_TLV = \"510101\";\nconst HMAC_PROOF_TLV = \"2920\" + \"33\".repeat(32);\nconst HMAC_REST_TLV = \"81f720\" + \"44\".repeat(32);\n\ndescribe(\"buildProvideContactPayload\", () => {\n it(\"encodes every tag in the order the spec lists\", () => {\n const payload = buildProvideContactPayload(INPUT);\n\n expect(bufferToHexaString(payload, false)).toBe(\n STRUCT_TYPE_TLV +\n STRUCT_VERSION_TLV +\n CONTACT_NAME_TLV +\n SCOPE_TLV +\n IDENTIFIER_TLV +\n GROUP_HANDLE_TLV +\n CHAIN_ID_TLV +\n FAMILY_TLV +\n HMAC_PROOF_TLV +\n HMAC_REST_TLV,\n );\n });\n\n it(\"fits an Ethereum contact in a single 255-byte chunk\", () => {\n expect(buildProvideContactPayload(INPUT).length).toBeLessThanOrEqual(253);\n });\n\n it(\"omits CHAIN_ID for a family that does not carry one\", () => {\n const payload = buildProvideContactPayload({\n ...INPUT,\n blockchainFamily: \"bitcoin\",\n chainId: undefined,\n });\n\n expect(bufferToHexaString(payload, false)).toContain(\n GROUP_HANDLE_TLV + \"510100\",\n );\n });\n\n it(\"encodes a multi-byte chain id big-endian with no leading zeroes\", () => {\n const payload = buildProvideContactPayload({ ...INPUT, chainId: 8453n });\n\n expect(bufferToHexaString(payload, false)).toContain(\"2302\" + \"2105\");\n });\n\n it(\"accepts the family name case-insensitively\", () => {\n expect(\n buildProvideContactPayload({ ...INPUT, blockchainFamily: \"Ethereum\" }),\n ).toStrictEqual(buildProvideContactPayload(INPUT));\n });\n\n it(\"throws on an unknown blockchain family\", () => {\n expect(() =>\n buildProvideContactPayload({ ...INPUT, blockchainFamily: \"dogecoin\" }),\n ).toThrow(\"Unsupported blockchain family: dogecoin\");\n });\n});\n\ndescribe(\"sendProvideContactPayload\", () => {\n it(\"sends one chunk under P2=0x00, prefixed with the 2-byte BE total length\", async () => {\n const api = makeDeviceActionInternalApiMock();\n api.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n const payload = buildProvideContactPayload(INPUT);\n\n const result = await sendProvideContactPayload(api, { payload });\n\n expect(api.sendCommand).toHaveBeenCalledTimes(1);\n const command = api.sendCommand.mock.calls[0]![0] as ProvideContactCommand;\n expect(command).toBeInstanceOf(ProvideContactCommand);\n expect(command.args.p2).toBe(0x00);\n expect(command.args.data.slice(0, 2)).toStrictEqual(\n Uint8Array.from([(payload.length >> 8) & 0xff, payload.length & 0xff]),\n );\n expect(command.args.data.slice(2)).toStrictEqual(payload);\n expect(result.status).toBe(CommandResultStatus.Success);\n });\n\n it(\"propagates a device rejection instead of throwing\", async () => {\n const api = makeDeviceActionInternalApiMock();\n api.sendCommand.mockResolvedValue(\n CommandResultFactory({\n error: new ContactsCommandError({\n errorCode: \"6982\",\n message: \"wrong seed\",\n }),\n }),\n );\n\n const result = await sendProvideContactPayload(api, {\n payload: buildProvideContactPayload(INPUT),\n });\n\n expect(result.status).toBe(CommandResultStatus.Error);\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAIO,2CAGPC,EAAsC,8DACtCC,EAAgD,6EAChDC,EAAqC,qDAErCC,EAGO,4BAEP,MAAMC,EAAa,IAAI,WAAW,EAAE,EAAE,KAAK,EAAI,EACzCC,EAAe,IAAI,WAAW,EAAE,EAAE,KAAK,EAAI,EAC3CC,EAAa,IAAI,WAAW,EAAE,EAAE,KAAK,EAAI,EACzCC,EAAY,IAAI,WAAW,EAAE,EAAE,KAAK,EAAI,EAExCC,EAA6B,CACjC,YAAa,QACb,MAAO,WACP,WAAYJ,EACZ,YAAaC,EACb,UAAWC,EACX,SAAUC,EACV,iBAAkB,WAClB,QAAS,EACX,EAKME,EAAkB,SAClBC,EAAqB,SACrBC,EAAmB,mBACnBC,EAAY,yBACZC,EAAiB,SAAW,KAAK,OAAO,EAAE,EAC1CC,EAAmB,SAAW,KAAK,OAAO,EAAE,EAC5CC,EAAe,SACfC,EAAa,SACbC,EAAiB,OAAS,KAAK,OAAO,E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AOC,EAAI,WAAW,EAAE,sBAAsB,CAAC,EAC/C,MAAME,EAAUF,EAAI,YAAY,KAAK,MAAM,CAAC,EAAG,CAAC,EAChD,OAAOE,CAAO,EAAE,eAAe,uBAAqB,EACpD,OAAOA,EAAQ,KAAK,EAAE,EAAE,KAAK,CAAI,EACjC,OAAOA,EAAQ,KAAK,KAAK,MAAM,EAAG,CAAC,CAAC,EAAE,cACpC,WAAW,KAAK,CAAEH,EAAQ,QAAU,EAAK,IAAMA,EAAQ,OAAS,GAAI,CAAC,CACvE,EACA,OAAOG,EAAQ,KAAK,KAAK,MAAM,CAAC,CAAC,EAAE,cAAcH,CAAO,EACxD,OAAOE,EAAO,MAAM,EAAE,KAAK,sBAAoB,OAAO,CACxD,CAAC,EAED,GAAG,oDAAqD,SAAY,CAClE,MAAMD,KAAM,mCAAgC,EAC5CA,EAAI,YAAY,qBACd,wBAAqB,CACnB,MAAO,IAAI,uBAAqB,CAC9B,UAAW,OACX,QAAS,YACX,CAAC,CACH,CAAC,CACH,EAEA,MAAMC,EAAS,QAAM,6BAA0BD,EAAK,CAClD,WAAS,8BAA2BZ,CAAK,CAC3C,CAAC,EAED,OAAOa,EAAO,MAAM,EAAE,KAAK,sBAAoB,KAAK,CACtD,CAAC,CACH,CAAC",
6
+ "names": ["import_device_management_kit", "import_ProvideContactCommand", "import_makeInternalApi", "import_contactsErrors", "import_provideContact", "IDENTIFIER", "GROUP_HANDLE", "HMAC_PROOF", "HMAC_REST", "INPUT", "STRUCT_TYPE_TLV", "STRUCT_VERSION_TLV", "CONTACT_NAME_TLV", "SCOPE_TLV", "IDENTIFIER_TLV", "GROUP_HANDLE_TLV", "CHAIN_ID_TLV", "FAMILY_TLV", "HMAC_PROOF_TLV", "HMAC_REST_TLV", "payload", "api", "result", "command"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/SendRegisterIdentityTask.ts"],
4
- "sourcesContent": ["// Builds the TLV payload for op 1 (Register Identity / Register External\n// Address) and dispatches it via the chunked-framing scheme shared with the\n// other address-book ops (2-byte BE total length + <=255B chunks). The device\n// returns the 129-byte register response on the final chunk.\n//\n// Reference: Address Book Final Specifications \u2014 Register Identity. Tag order:\n// STRUCT_TYPE, STRUCT_VERSION, CONTACT_NAME, SCOPE, ACCOUNT_IDENTIFIER,\n// CHAIN_ID (Ethereum only), BLOCKCHAIN_FAMILY, then optional\n// GROUP_HANDLE + HMAC_PROOF when extending an existing group.\n//\n// No DERIVATION_PATH: external-address ops carry no path. The current Ethereum\n// app rejects the tag when present (0x6a80) and no longer requires it; the tag\n// is Ledger-Account only (verified on-device, DSDK-1465).\nimport {\n ByteArrayBuilder,\n type CommandResult,\n DmkResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type ExistingContactGroup } from \"@api/model/RegisterExternalAddress\";\nimport { RegisterIdentityCommand } from \"@internal/app-binder/command/RegisterIdentityCommand\";\nimport {\n BLOCKCHAIN_FAMILY_BY_NAME,\n SUB_CMD_REGISTER_IDENTITY,\n} from \"@internal/app-binder/model/contactsConstants\";\nimport { type ContactsErrorCodes } from \"@internal/app-binder/model/contactsErrors\";\nimport {\n CONTACTS_TLV_TAG,\n encodeTlvAscii,\n encodeTlvBuffer,\n encodeTlvChainId,\n encodeTlvUInt8,\n STRUCT_TYPE_REGISTER_IDENTITY,\n STRUCT_VERSION_VALUE,\n} from \"@internal/app-binder/services/contactsTlvSerializer\";\nimport { sendFramedContactsPayload } from \"@internal/app-binder/services/sendFramedContactsPayload\";\n\nexport type RegisterIdentityProofs = {\n readonly groupHandle: Uint8Array;\n readonly hmacProof: Uint8Array;\n readonly hmacRest: Uint8Array;\n};\n\nexport type SendRegisterIdentityTaskArgs = {\n readonly contactName: string;\n readonly scope: string;\n readonly identifier: Uint8Array;\n readonly blockchainFamily: string;\n readonly chainId?: bigint;\n readonly existingContactGroup?: ExistingContactGroup;\n readonly logger?: LoggerPublisherService;\n};\n\nexport class SendRegisterIdentityTask {\n constructor(\n private readonly api: InternalApi,\n private readonly args: SendRegisterIdentityTaskArgs,\n ) {}\n\n async run(): Promise<\n CommandResult<RegisterIdentityProofs, ContactsErrorCodes>\n > {\n const payload = this.buildPayload(this.args);\n\n const result = (await sendFramedContactsPayload(this.api, {\n payload,\n p1: SUB_CMD_REGISTER_IDENTITY,\n makeCommand: (chunk, p2) =>\n new RegisterIdentityCommand({ data: chunk, p2 }),\n logger: this.args.logger,\n commandTag: \"SendRegisterIdentityTask\",\n })) as CommandResult<\n {\n readonly groupHandle?: Uint8Array;\n readonly hmacProof?: Uint8Array;\n readonly hmacRest?: Uint8Array;\n },\n ContactsErrorCodes\n >;\n\n if (!isSuccessCommandResult(result)) {\n return result;\n }\n\n const { groupHandle, hmacProof, hmacRest } = result.data;\n if (!groupHandle || !hmacProof || !hmacRest) {\n return DmkResultFactory({\n error: new InvalidStatusWordError(\n \"RegisterIdentity final-chunk response was incomplete\",\n ),\n });\n }\n return DmkResultFactory({ data: { groupHandle, hmacProof, hmacRest } });\n }\n\n private buildPayload(args: SendRegisterIdentityTaskArgs): Uint8Array {\n const family =\n BLOCKCHAIN_FAMILY_BY_NAME[args.blockchainFamily.toLowerCase()];\n if (family === undefined) {\n throw new Error(\n `Unsupported blockchain family: ${args.blockchainFamily}`,\n );\n }\n\n const builder = new ByteArrayBuilder();\n encodeTlvUInt8(\n builder,\n CONTACTS_TLV_TAG.STRUCT_TYPE,\n STRUCT_TYPE_REGISTER_IDENTITY,\n );\n encodeTlvUInt8(\n builder,\n CONTACTS_TLV_TAG.STRUCT_VERSION,\n STRUCT_VERSION_VALUE,\n );\n encodeTlvAscii(builder, CONTACTS_TLV_TAG.CONTACT_NAME, args.contactName);\n encodeTlvAscii(builder, CONTACTS_TLV_TAG.SCOPE, args.scope);\n encodeTlvBuffer(\n builder,\n CONTACTS_TLV_TAG.ACCOUNT_IDENTIFIER,\n args.identifier,\n );\n if (args.chainId !== undefined) {\n encodeTlvChainId(builder, CONTACTS_TLV_TAG.CHAIN_ID, args.chainId);\n }\n encodeTlvUInt8(builder, CONTACTS_TLV_TAG.BLOCKCHAIN_FAMILY, family);\n\n if (args.existingContactGroup) {\n encodeTlvBuffer(\n builder,\n CONTACTS_TLV_TAG.GROUP_HANDLE,\n args.existingContactGroup.groupHandle,\n );\n encodeTlvBuffer(\n builder,\n CONTACTS_TLV_TAG.HMAC_PROOF,\n args.existingContactGroup.hmacProof,\n );\n }\n\n return builder.build();\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAaA,IAAAI,EAQO,2CAGPC,EAAwC,gEACxCC,EAGO,wDAEPC,EAQO,+DACPC,EAA0C,mEAkBnC,MAAMN,CAAyB,CACpC,YACmBO,EACAC,EACjB,CAFiB,SAAAD,EACA,UAAAC,CAChB,CAEH,MAAM,KAEJ,CACA,MAAMC,EAAU,KAAK,aAAa,KAAK,IAAI,EAErCC,EAAU,QAAM,6BAA0B,KAAK,IAAK,CACxD,QAAAD,EACA,GAAI,4BACJ,YAAa,CAACE,EAAOC,IACnB,IAAI,0BAAwB,CAAE,KAAMD,EAAO,GAAAC,CAAG,CAAC,EACjD,OAAQ,KAAK,KAAK,OAClB,WAAY,0BACd,CAAC,EASD,GAAI,IAAC,0BAAuBF,CAAM,EAChC,OAAOA,EAGT,KAAM,CAAE,YAAAG,EAAa,UAAAC,EAAW,SAAAC,CAAS,EAAIL,EAAO,KACpD,MAAI,CAACG,GAAe,CAACC,GAAa,CAACC,KAC1B,oBAAiB,CACtB,MAAO,IAAI,yBACT,sDACF,CACF,CAAC,KAEI,oBAAiB,CAAE,KAAM,CAAE,YAAAF,EAAa,UAAAC,EAAW,SAAAC,CAAS,CAAE,CAAC,CACxE,CAEQ,aAAaP,EAAgD,CACnE,MAAMQ,EACJ,4BAA0BR,EAAK,iBAAiB,YAAY,CAAC,EAC/D,GAAIQ,IAAW,OACb,MAAM,IAAI,MACR,kCAAkCR,EAAK,gBAAgB,EACzD,EAGF,MAAMS,EAAU,IAAI,mBACpB,2BACEA,EACA,mBAAiB,YACjB,+BACF,KACA,kBACEA,EACA,mBAAiB,eACjB,sBACF,KACA,kBAAeA,EAAS,mBAAiB,aAAcT,EAAK,WAAW,KACvE,kBAAeS,EAAS,mBAAiB,MAAOT,EAAK,KAAK,KAC1D,mBACES,EACA,mBAAiB,mBACjBT,EAAK,UACP,EACIA,EAAK,UAAY,WACnB,oBAAiBS,EAAS,mBAAiB,SAAUT,EAAK,OAAO,KAEnE,kBAAeS,EAAS,mBAAiB,kBAAmBD,CAAM,EAE9DR,EAAK,0BACP,mBACES,EACA,mBAAiB,aACjBT,EAAK,qBAAqB,WAC5B,KACA,mBACES,EACA,mBAAiB,WACjBT,EAAK,qBAAqB,SAC5B,GAGKS,EAAQ,MAAM,CACvB,CACF",
4
+ "sourcesContent": ["// Builds the TLV payload for op 1 (Register Identity / Register External\n// Address) and dispatches it via the chunked-framing scheme shared with the\n// other address-book ops (2-byte BE total length + <=255B chunks). The device\n// returns the 129-byte register response on the final chunk.\n//\n// Reference: Address Book Final Specifications \u2014 Register Identity. Tag order:\n// STRUCT_TYPE, STRUCT_VERSION, CONTACT_NAME, SCOPE, ACCOUNT_IDENTIFIER,\n// CHAIN_ID (Ethereum only), BLOCKCHAIN_FAMILY, then optional GROUP_HANDLE +\n// HMAC_PROOF when extending an existing group.\n//\n// No DERIVATION_PATH. The tag's status changed three times in the BOLOS SDK,\n// and the address-book TLV parser is compiled into the app (app_features/), so\n// the SDK revision the app was *built* against decides \u2014 not the app version,\n// which reads 1.23.0-dev either way:\n// - before 2026-08-07: tag 0x69 present and MANDATORY, omitting it -> 0x6a80\n// - 8e7e7a4f (2026-08-07): made optional, both forms accepted\n// - a0bb21f5 (2026-08-10): removed, sending it -> 0x6a80 (unknown tag)\n// Omitting it is therefore correct for any app built from 2026-08-07 onward,\n// and wrong for one built before. Both ends verified on hardware: a Flex\n// running a pre-08-07 build of app-ethereum a79f9f8f rejects the payload\n// without the tag in 9ms and no review screen; Speculos running a post-08-10\n// build of the same commit rejects it *with* the tag, the same way.\n// The OS derives the HMAC key from a fixed internal path.\nimport {\n ByteArrayBuilder,\n type CommandResult,\n DmkResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type ExistingContactGroup } from \"@api/model/RegisterExternalAddress\";\nimport { RegisterIdentityCommand } from \"@internal/app-binder/command/RegisterIdentityCommand\";\nimport {\n BLOCKCHAIN_FAMILY_BY_NAME,\n SUB_CMD_REGISTER_IDENTITY,\n} from \"@internal/app-binder/model/contactsConstants\";\nimport { type ContactsErrorCodes } from \"@internal/app-binder/model/contactsErrors\";\nimport {\n CONTACTS_TLV_TAG,\n encodeTlvAscii,\n encodeTlvBuffer,\n encodeTlvChainId,\n encodeTlvUInt8,\n STRUCT_TYPE_REGISTER_IDENTITY,\n STRUCT_VERSION_VALUE,\n} from \"@internal/app-binder/services/contactsTlvSerializer\";\nimport { sendFramedContactsPayload } from \"@internal/app-binder/services/sendFramedContactsPayload\";\n\nexport type RegisterIdentityProofs = {\n readonly groupHandle: Uint8Array;\n readonly hmacProof: Uint8Array;\n readonly hmacRest: Uint8Array;\n};\n\nexport type SendRegisterIdentityTaskArgs = {\n readonly contactName: string;\n readonly scope: string;\n readonly identifier: Uint8Array;\n readonly blockchainFamily: string;\n readonly chainId?: bigint;\n readonly existingContactGroup?: ExistingContactGroup;\n readonly logger?: LoggerPublisherService;\n};\n\nexport class SendRegisterIdentityTask {\n constructor(\n private readonly api: InternalApi,\n private readonly args: SendRegisterIdentityTaskArgs,\n ) {}\n\n async run(): Promise<\n CommandResult<RegisterIdentityProofs, ContactsErrorCodes>\n > {\n const payload = this.buildPayload(this.args);\n\n const result = (await sendFramedContactsPayload(this.api, {\n payload,\n p1: SUB_CMD_REGISTER_IDENTITY,\n makeCommand: (chunk, p2) =>\n new RegisterIdentityCommand({ data: chunk, p2 }),\n logger: this.args.logger,\n commandTag: \"SendRegisterIdentityTask\",\n })) as CommandResult<\n {\n readonly groupHandle?: Uint8Array;\n readonly hmacProof?: Uint8Array;\n readonly hmacRest?: Uint8Array;\n },\n ContactsErrorCodes\n >;\n\n if (!isSuccessCommandResult(result)) {\n return result;\n }\n\n const { groupHandle, hmacProof, hmacRest } = result.data;\n if (!groupHandle || !hmacProof || !hmacRest) {\n return DmkResultFactory({\n error: new InvalidStatusWordError(\n \"RegisterIdentity final-chunk response was incomplete\",\n ),\n });\n }\n return DmkResultFactory({ data: { groupHandle, hmacProof, hmacRest } });\n }\n\n private buildPayload(args: SendRegisterIdentityTaskArgs): Uint8Array {\n const family =\n BLOCKCHAIN_FAMILY_BY_NAME[args.blockchainFamily.toLowerCase()];\n if (family === undefined) {\n throw new Error(\n `Unsupported blockchain family: ${args.blockchainFamily}`,\n );\n }\n\n const builder = new ByteArrayBuilder();\n encodeTlvUInt8(\n builder,\n CONTACTS_TLV_TAG.STRUCT_TYPE,\n STRUCT_TYPE_REGISTER_IDENTITY,\n );\n encodeTlvUInt8(\n builder,\n CONTACTS_TLV_TAG.STRUCT_VERSION,\n STRUCT_VERSION_VALUE,\n );\n encodeTlvAscii(builder, CONTACTS_TLV_TAG.CONTACT_NAME, args.contactName);\n encodeTlvAscii(builder, CONTACTS_TLV_TAG.SCOPE, args.scope);\n encodeTlvBuffer(\n builder,\n CONTACTS_TLV_TAG.ACCOUNT_IDENTIFIER,\n args.identifier,\n );\n if (args.chainId !== undefined) {\n encodeTlvChainId(builder, CONTACTS_TLV_TAG.CHAIN_ID, args.chainId);\n }\n encodeTlvUInt8(builder, CONTACTS_TLV_TAG.BLOCKCHAIN_FAMILY, family);\n\n if (args.existingContactGroup) {\n encodeTlvBuffer(\n builder,\n CONTACTS_TLV_TAG.GROUP_HANDLE,\n args.existingContactGroup.groupHandle,\n );\n encodeTlvBuffer(\n builder,\n CONTACTS_TLV_TAG.HMAC_PROOF,\n args.existingContactGroup.hmacProof,\n );\n }\n\n return builder.build();\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAuBA,IAAAI,EAQO,2CAGPC,EAAwC,gEACxCC,EAGO,wDAEPC,EAQO,+DACPC,EAA0C,mEAkBnC,MAAMN,CAAyB,CACpC,YACmBO,EACAC,EACjB,CAFiB,SAAAD,EACA,UAAAC,CAChB,CAEH,MAAM,KAEJ,CACA,MAAMC,EAAU,KAAK,aAAa,KAAK,IAAI,EAErCC,EAAU,QAAM,6BAA0B,KAAK,IAAK,CACxD,QAAAD,EACA,GAAI,4BACJ,YAAa,CAACE,EAAOC,IACnB,IAAI,0BAAwB,CAAE,KAAMD,EAAO,GAAAC,CAAG,CAAC,EACjD,OAAQ,KAAK,KAAK,OAClB,WAAY,0BACd,CAAC,EASD,GAAI,IAAC,0BAAuBF,CAAM,EAChC,OAAOA,EAGT,KAAM,CAAE,YAAAG,EAAa,UAAAC,EAAW,SAAAC,CAAS,EAAIL,EAAO,KACpD,MAAI,CAACG,GAAe,CAACC,GAAa,CAACC,KAC1B,oBAAiB,CACtB,MAAO,IAAI,yBACT,sDACF,CACF,CAAC,KAEI,oBAAiB,CAAE,KAAM,CAAE,YAAAF,EAAa,UAAAC,EAAW,SAAAC,CAAS,CAAE,CAAC,CACxE,CAEQ,aAAaP,EAAgD,CACnE,MAAMQ,EACJ,4BAA0BR,EAAK,iBAAiB,YAAY,CAAC,EAC/D,GAAIQ,IAAW,OACb,MAAM,IAAI,MACR,kCAAkCR,EAAK,gBAAgB,EACzD,EAGF,MAAMS,EAAU,IAAI,mBACpB,2BACEA,EACA,mBAAiB,YACjB,+BACF,KACA,kBACEA,EACA,mBAAiB,eACjB,sBACF,KACA,kBAAeA,EAAS,mBAAiB,aAAcT,EAAK,WAAW,KACvE,kBAAeS,EAAS,mBAAiB,MAAOT,EAAK,KAAK,KAC1D,mBACES,EACA,mBAAiB,mBACjBT,EAAK,UACP,EACIA,EAAK,UAAY,WACnB,oBAAiBS,EAAS,mBAAiB,SAAUT,EAAK,OAAO,KAEnE,kBAAeS,EAAS,mBAAiB,kBAAmBD,CAAM,EAE9DR,EAAK,0BACP,mBACES,EACA,mBAAiB,aACjBT,EAAK,qBAAqB,WAC5B,KACA,mBACES,EACA,mBAAiB,WACjBT,EAAK,qBAAqB,SAC5B,GAGKS,EAAQ,MAAM,CACvB,CACF",
6
6
  "names": ["SendRegisterIdentityTask_exports", "__export", "SendRegisterIdentityTask", "__toCommonJS", "import_device_management_kit", "import_RegisterIdentityCommand", "import_contactsConstants", "import_contactsTlvSerializer", "import_sendFramedContactsPayload", "api", "args", "payload", "result", "chunk", "p2", "groupHandle", "hmacProof", "hmacRest", "family", "builder"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/SendRegisterIdentityTask.test.ts"],
4
- "sourcesContent": ["// Validates that the TLV serializer + tag ordering + chunk framing produce the\n// expected wire bytes for op 1 (Register Identity): tags >= 0x80 use the 2-byte\n// DER form [0x81, tag], and Register Identity carries NO DERIVATION_PATH (the\n// Ethereum app rejects the tag on external-address ops). The framed chunk =\n// 2-byte BE total length + TLV.\nimport {\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { RegisterIdentityCommand } from \"@internal/app-binder/command/RegisterIdentityCommand\";\n\nimport { SendRegisterIdentityTask } from \"./SendRegisterIdentityTask\";\n\nfunction hexToBytes(hex: string): Uint8Array {\n const out = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n out[i / 2] = parseInt(hex.slice(i, i + 2), 16);\n }\n return out;\n}\n\n// Framed chunk = \"00 <Lc>\" (2-byte BE total TLV length) + TLV. Tag order:\n// STRUCT_TYPE, STRUCT_VERSION, CONTACT_NAME, SCOPE, ACCOUNT_IDENTIFIER,\n// CHAIN_ID, BLOCKCHAIN_FAMILY, then optional GROUP_HANDLE + HMAC_PROOF. Tags\n// >= 0x80 are encoded as [0x81, tag]. No DERIVATION_PATH TLV.\nconst FRESH_FRAMED_CHUNK = hexToBytes(\n \"003601012d020101\" +\n \"81f005416c696365\" +\n \"81f108457468206d61696e\" +\n \"81f21400000000000000000000000000000000deadbeef\" +\n \"230101510101\",\n);\n\nconst EXTENSION_FRAMED_CHUNK = hexToBytes(\n \"009c01012d020101\" +\n \"81f005416c696365\" +\n \"81f108417262206d61696e\" +\n \"81f2144444444444444444444444444444444444444444\" +\n \"2302a4b1510101\" +\n \"81f640cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\" +\n \"2920dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\n);\n\nconst OK_PROOFS = {\n groupHandle: hexToBytes(\"cc\".repeat(64)),\n hmacProof: hexToBytes(\"dd\".repeat(32)),\n hmacRest: hexToBytes(\"aa\".repeat(32)),\n};\n\nfunction makeApiMock(): InternalApi & {\n sendCommand: ReturnType<typeof vi.fn>;\n} {\n return { sendCommand: vi.fn() } as unknown as InternalApi & {\n sendCommand: ReturnType<typeof vi.fn>;\n };\n}\n\ndescribe(\"SendRegisterIdentityTask\", () => {\n it(\"assembles a fresh-register framed chunk and dispatches RegisterIdentityCommand\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: OK_PROOFS }),\n );\n\n const result = await new SendRegisterIdentityTask(api, {\n contactName: \"Alice\",\n scope: \"Eth main\",\n identifier: hexToBytes(\"00000000000000000000000000000000deadbeef\"),\n blockchainFamily: \"ethereum\",\n chainId: 1n,\n }).run();\n\n expect(api.sendCommand.mock.calls).toHaveLength(1);\n expect(api.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new RegisterIdentityCommand({ data: FRESH_FRAMED_CHUNK, p2: 0x00 }),\n );\n expect(result).toStrictEqual(CommandResultFactory({ data: OK_PROOFS }));\n });\n\n it(\"appends GROUP_HANDLE + HMAC_PROOF on extension and frames the extension payload\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: OK_PROOFS }),\n );\n\n await new SendRegisterIdentityTask(api, {\n contactName: \"Alice\",\n scope: \"Arb main\",\n identifier: hexToBytes(\"44\".repeat(20)),\n blockchainFamily: \"ethereum\",\n chainId: 42161n,\n existingContactGroup: {\n groupHandle: hexToBytes(\"cc\".repeat(64)),\n hmacProof: hexToBytes(\"dd\".repeat(32)),\n },\n }).run();\n\n expect(api.sendCommand.mock.calls).toHaveLength(1);\n expect(api.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new RegisterIdentityCommand({ data: EXTENSION_FRAMED_CHUNK, p2: 0x00 }),\n );\n });\n\n it(\"omits the CHAIN_ID TLV when chainId is not provided\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: OK_PROOFS }),\n );\n\n await new SendRegisterIdentityTask(api, {\n contactName: \"Alice\",\n scope: \"Eth main\",\n identifier: hexToBytes(\"00000000000000000000000000000000deadbeef\"),\n blockchainFamily: \"ethereum\",\n }).run();\n\n const command = api.sendCommand.mock\n .calls[0]![0] as RegisterIdentityCommand;\n // No `23 01 ..` CHAIN_ID TLV; BLOCKCHAIN_FAMILY 51 01 01 follows the path.\n const framedHex = Buffer.from(command.args.data).toString(\"hex\");\n expect(framedHex).not.toContain(\"230101\");\n expect(framedHex.endsWith(\"510101\")).toBe(true);\n });\n\n it(\"propagates command-level errors\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"user cancelled\"),\n }),\n );\n\n const result = await new SendRegisterIdentityTask(api, {\n contactName: \"Alice\",\n scope: \"Eth main\",\n identifier: hexToBytes(\"00000000000000000000000000000000deadbeef\"),\n blockchainFamily: \"ethereum\",\n chainId: 1n,\n }).run();\n\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"user cancelled\"),\n }),\n );\n });\n\n it(\"throws on an unsupported blockchain family\", async () => {\n const api = makeApiMock();\n\n await expect(\n new SendRegisterIdentityTask(api, {\n contactName: \"Alice\",\n scope: \"Eth main\",\n identifier: hexToBytes(\"00000000000000000000000000000000deadbeef\"),\n blockchainFamily: \"dogecoin\",\n chainId: 1n,\n }).run(),\n ).rejects.toThrow(/Unsupported blockchain family/);\n expect(api.sendCommand).not.toHaveBeenCalled();\n });\n});\n"],
4
+ "sourcesContent": ["// Validates that the TLV serializer + tag ordering + chunk framing produce the\n// expected wire bytes for op 1 (Register Identity): tags >= 0x80 use the 2-byte\n// DER form [0x81, tag], and no DERIVATION_PATH is sent (the SDK removed tag\n// 0x69 from REGISTER_IDENTITY_TAGS on 2026-08-10 and rejects payloads carrying\n// it). The framed chunk = 2-byte BE total length + TLV.\nimport {\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { RegisterIdentityCommand } from \"@internal/app-binder/command/RegisterIdentityCommand\";\n\nimport { SendRegisterIdentityTask } from \"./SendRegisterIdentityTask\";\n\nfunction hexToBytes(hex: string): Uint8Array {\n const out = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n out[i / 2] = parseInt(hex.slice(i, i + 2), 16);\n }\n return out;\n}\n\n// Framed chunk = \"00 <Lc>\" (2-byte BE total TLV length) + TLV. Tag order:\n// STRUCT_TYPE, STRUCT_VERSION, CONTACT_NAME, SCOPE, ACCOUNT_IDENTIFIER,\n// CHAIN_ID, BLOCKCHAIN_FAMILY, then optional GROUP_HANDLE + HMAC_PROOF. Tags\n// >= 0x80 are encoded as [0x81, tag].\nconst FRESH_FRAMED_CHUNK = hexToBytes(\n \"003601012d020101\" +\n \"81f005416c696365\" +\n \"81f108457468206d61696e\" +\n \"81f21400000000000000000000000000000000deadbeef\" +\n \"230101510101\",\n);\n\nconst EXTENSION_FRAMED_CHUNK = hexToBytes(\n \"009c01012d020101\" +\n \"81f005416c696365\" +\n \"81f108417262206d61696e\" +\n \"81f2144444444444444444444444444444444444444444\" +\n \"2302a4b1510101\" +\n \"81f640cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\" +\n \"2920dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\",\n);\n\nconst OK_PROOFS = {\n groupHandle: hexToBytes(\"cc\".repeat(64)),\n hmacProof: hexToBytes(\"dd\".repeat(32)),\n hmacRest: hexToBytes(\"aa\".repeat(32)),\n};\n\nfunction makeApiMock(): InternalApi & {\n sendCommand: ReturnType<typeof vi.fn>;\n} {\n return { sendCommand: vi.fn() } as unknown as InternalApi & {\n sendCommand: ReturnType<typeof vi.fn>;\n };\n}\n\ndescribe(\"SendRegisterIdentityTask\", () => {\n it(\"assembles a fresh-register framed chunk and dispatches RegisterIdentityCommand\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: OK_PROOFS }),\n );\n\n const result = await new SendRegisterIdentityTask(api, {\n contactName: \"Alice\",\n scope: \"Eth main\",\n identifier: hexToBytes(\"00000000000000000000000000000000deadbeef\"),\n blockchainFamily: \"ethereum\",\n chainId: 1n,\n }).run();\n\n expect(api.sendCommand.mock.calls).toHaveLength(1);\n expect(api.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new RegisterIdentityCommand({ data: FRESH_FRAMED_CHUNK, p2: 0x00 }),\n );\n expect(result).toStrictEqual(CommandResultFactory({ data: OK_PROOFS }));\n });\n\n it(\"appends GROUP_HANDLE + HMAC_PROOF on extension and frames the extension payload\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: OK_PROOFS }),\n );\n\n await new SendRegisterIdentityTask(api, {\n contactName: \"Alice\",\n scope: \"Arb main\",\n identifier: hexToBytes(\"44\".repeat(20)),\n blockchainFamily: \"ethereum\",\n chainId: 42161n,\n existingContactGroup: {\n groupHandle: hexToBytes(\"cc\".repeat(64)),\n hmacProof: hexToBytes(\"dd\".repeat(32)),\n },\n }).run();\n\n expect(api.sendCommand.mock.calls).toHaveLength(1);\n expect(api.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new RegisterIdentityCommand({ data: EXTENSION_FRAMED_CHUNK, p2: 0x00 }),\n );\n });\n\n it(\"omits the CHAIN_ID TLV when chainId is not provided\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: OK_PROOFS }),\n );\n\n await new SendRegisterIdentityTask(api, {\n contactName: \"Alice\",\n scope: \"Eth main\",\n identifier: hexToBytes(\"00000000000000000000000000000000deadbeef\"),\n blockchainFamily: \"ethereum\",\n }).run();\n\n const command = api.sendCommand.mock\n .calls[0]![0] as RegisterIdentityCommand;\n // No `23 01 ..` CHAIN_ID TLV; BLOCKCHAIN_FAMILY 51 01 01 follows the path.\n const framedHex = Buffer.from(command.args.data).toString(\"hex\");\n expect(framedHex).not.toContain(\"230101\");\n expect(framedHex.endsWith(\"510101\")).toBe(true);\n });\n\n it(\"propagates command-level errors\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"user cancelled\"),\n }),\n );\n\n const result = await new SendRegisterIdentityTask(api, {\n contactName: \"Alice\",\n scope: \"Eth main\",\n identifier: hexToBytes(\"00000000000000000000000000000000deadbeef\"),\n blockchainFamily: \"ethereum\",\n chainId: 1n,\n }).run();\n\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"user cancelled\"),\n }),\n );\n });\n\n it(\"throws on an unsupported blockchain family\", async () => {\n const api = makeApiMock();\n\n await expect(\n new SendRegisterIdentityTask(api, {\n contactName: \"Alice\",\n scope: \"Eth main\",\n identifier: hexToBytes(\"00000000000000000000000000000000deadbeef\"),\n blockchainFamily: \"dogecoin\",\n chainId: 1n,\n }).run(),\n ).rejects.toThrow(/Unsupported blockchain family/);\n expect(api.sendCommand).not.toHaveBeenCalled();\n });\n});\n"],
5
5
  "mappings": "aAKA,IAAAA,EAIO,2CAEPC,EAAwC,gEAExCC,EAAyC,sCAEzC,SAASC,EAAWC,EAAyB,CAC3C,MAAMC,EAAM,IAAI,WAAWD,EAAI,OAAS,CAAC,EACzC,QAASE,EAAI,EAAGA,EAAIF,EAAI,OAAQE,GAAK,EACnCD,EAAIC,EAAI,CAAC,EAAI,SAASF,EAAI,MAAME,EAAGA,EAAI,CAAC,EAAG,EAAE,EAE/C,OAAOD,CACT,CAMA,MAAME,EAAqBJ,EACzB,kHAKF,EAEMK,EAAyBL,EAC7B,8TAOF,EAEMM,EAAY,CAChB,YAAaN,EAAW,KAAK,OAAO,EAAE,CAAC,EACvC,UAAWA,EAAW,KAAK,OAAO,EAAE,CAAC,EACrC,SAAUA,EAAW,KAAK,OAAO,EAAE,CAAC,CACtC,EAEA,SAASO,GAEP,CACA,MAAO,CAAE,YAAa,GAAG,GAAG,CAAE,CAGhC,CAEA,SAAS,2BAA4B,IAAM,CACzC,GAAG,iFAAkF,SAAY,CAC/F,MAAMC,EAAMD,EAAY,EACxBC,EAAI,YAAY,yBACd,wBAAqB,CAAE,KAAMF,CAAU,CAAC,CAC1C,EAEA,MAAMG,EAAS,MAAM,IAAI,2BAAyBD,EAAK,CACrD,YAAa,QACb,MAAO,WACP,WAAYR,EAAW,0CAA0C,EACjE,iBAAkB,WAClB,QAAS,EACX,CAAC,EAAE,IAAI,EAEP,OAAOQ,EAAI,YAAY,KAAK,KAAK,EAAE,aAAa,CAAC,EACjD,OAAOA,EAAI,YAAY,KAAK,MAAM,CAAC,EAAG,CAAC,CAAC,EAAE,cACxC,IAAI,0BAAwB,CAAE,KAAMJ,EAAoB,GAAI,CAAK,CAAC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MAAO,IAAI,yBAAuB,gBAAgB,CACpD,CAAC,CACH,EAEA,MAAMC,EAAS,MAAM,IAAI,2BAAyBD,EAAK,CACrD,YAAa,QACb,MAAO,WACP,WAAYR,EAAW,0CAA0C,EACjE,iBAAkB,WAClB,QAAS,EACX,CAAC,EAAE,IAAI,EAEP,OAAOS,CAAM,EAAE,iBACb,wBAAqB,CACnB,MAAO,IAAI,yBAAuB,gBAAgB,CACpD,CAAC,CACH,CACF,CAAC,EAED,GAAG,6CAA8C,SAAY,CAC3D,MAAMD,EAAMD,EAAY,EAExB,MAAM,OACJ,IAAI,2BAAyBC,EAAK,CAChC,YAAa,QACb,MAAO,WACP,WAAYR,EAAW,0CAA0C,EACjE,iBAAkB,WAClB,QAAS,EACX,CAAC,EAAE,IAAI,CACT,EAAE,QAAQ,QAAQ,+BAA+B,EACjD,OAAOQ,EAAI,WAAW,EAAE,IAAI,iBAAiB,CAC/C,CAAC,CACH,CAAC",
6
6
  "names": ["import_device_management_kit", "import_RegisterIdentityCommand", "import_SendRegisterIdentityTask", "hexToBytes", "hex", "out", "i", "FRESH_FRAMED_CHUNK", "EXTENSION_FRAMED_CHUNK", "OK_PROOFS", "makeApiMock", "api", "result", "command", "framedHex"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var a in e)s(t,a,{get:e[a],enumerable:!0})},u=(t,e,a,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of T(e))!p.call(t,n)&&n!==a&&s(t,n,{get:()=>e[n],enumerable:!(m=l(e,n))||m.enumerable});return t};var A=t=>u(s({},"__esModule",{value:!0}),t);var P={};y(P,{SendRenameContactTask:()=>R});module.exports=A(P);var o=require("@ledgerhq/device-management-kit"),d=require("../../app-binder/command/RenameContactCommand"),i=require("../../app-binder/model/contactsConstants"),r=require("../../app-binder/services/contactsTlvSerializer"),c=require("../../app-binder/services/sendFramedContactsPayload");class R{constructor(e,a){this.api=e;this.args=a}async run(){const e=this.buildPayload(this.args),a=await(0,c.sendFramedContactsPayload)(this.api,{payload:e,p1:i.RENAME_CONTACT_P1,makeCommand:(n,C)=>new d.RenameContactCommand({data:n,p2:C}),logger:this.args.logger,commandTag:"SendRenameContactTask"});if(!(0,o.isSuccessCommandResult)(a))return a;const{hmacProof:m}=a.data;return m?(0,o.DmkResultFactory)({data:{hmacProof:m}}):(0,o.DmkResultFactory)({error:new o.InvalidStatusWordError("RenameContact final-chunk response did not carry hmac_name")})}buildPayload(e){const a=new o.ByteArrayBuilder;return(0,r.encodeTlvUInt8)(a,r.CONTACTS_TLV_TAG.STRUCT_TYPE,r.STRUCT_TYPE_EDIT_CONTACT_NAME),(0,r.encodeTlvUInt8)(a,r.CONTACTS_TLV_TAG.STRUCT_VERSION,r.STRUCT_VERSION_VALUE),(0,r.encodeTlvAscii)(a,r.CONTACTS_TLV_TAG.CONTACT_NAME,e.newContactName),(0,r.encodeTlvAscii)(a,r.CONTACTS_TLV_TAG.PREVIOUS_CONTACT_NAME,e.previousContactName),(0,r.encodeTlvBuffer)(a,r.CONTACTS_TLV_TAG.GROUP_HANDLE,e.groupHandle),(0,r.encodeTlvBuffer)(a,r.CONTACTS_TLV_TAG.DERIVATION_PATH,(0,r.packDerivationPath)([2147483692,2147483708,2147483648,0,0])),(0,r.encodeTlvBuffer)(a,r.CONTACTS_TLV_TAG.HMAC_PROOF,e.hmacProof),a.build()}}0&&(module.exports={SendRenameContactTask});
1
+ "use strict";var d=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var y=(t,a)=>{for(var r in a)d(t,r,{get:a[r],enumerable:!0})},u=(t,a,r,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of T(a))!p.call(t,n)&&n!==r&&d(t,n,{get:()=>a[n],enumerable:!(i=C(a,n))||i.enumerable});return t};var A=t=>u(d({},"__esModule",{value:!0}),t);var P={};y(P,{SendRenameContactTask:()=>R});module.exports=A(P);var o=require("@ledgerhq/device-management-kit"),m=require("../../app-binder/command/RenameContactCommand"),c=require("../../app-binder/model/contactsConstants"),e=require("../../app-binder/services/contactsTlvSerializer"),s=require("../../app-binder/services/sendFramedContactsPayload");class R{constructor(a,r){this.api=a;this.args=r}async run(){const a=this.buildPayload(this.args),r=await(0,s.sendFramedContactsPayload)(this.api,{payload:a,p1:c.RENAME_CONTACT_P1,makeCommand:(n,l)=>new m.RenameContactCommand({data:n,p2:l}),logger:this.args.logger,commandTag:"SendRenameContactTask"});if(!(0,o.isSuccessCommandResult)(r))return r;const{hmacProof:i}=r.data;return i?(0,o.DmkResultFactory)({data:{hmacProof:i}}):(0,o.DmkResultFactory)({error:new o.InvalidStatusWordError("RenameContact final-chunk response did not carry hmac_name")})}buildPayload(a){const r=new o.ByteArrayBuilder;return(0,e.encodeTlvUInt8)(r,e.CONTACTS_TLV_TAG.STRUCT_TYPE,e.STRUCT_TYPE_EDIT_CONTACT_NAME),(0,e.encodeTlvUInt8)(r,e.CONTACTS_TLV_TAG.STRUCT_VERSION,e.STRUCT_VERSION_VALUE),(0,e.encodeTlvAscii)(r,e.CONTACTS_TLV_TAG.CONTACT_NAME,a.newContactName),(0,e.encodeTlvAscii)(r,e.CONTACTS_TLV_TAG.PREVIOUS_CONTACT_NAME,a.previousContactName),(0,e.encodeTlvBuffer)(r,e.CONTACTS_TLV_TAG.GROUP_HANDLE,a.groupHandle),a.includeDerivationPath&&(0,e.encodeTlvBuffer)(r,e.CONTACTS_TLV_TAG.DERIVATION_PATH,(0,e.packDerivationPath)([2147483692,2147483708,2147483648,0,0])),(0,e.encodeTlvBuffer)(r,e.CONTACTS_TLV_TAG.HMAC_PROOF,a.hmacProof),r.build()}}0&&(module.exports={SendRenameContactTask});
2
2
  //# sourceMappingURL=SendRenameContactTask.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/SendRenameContactTask.ts"],
4
- "sourcesContent": ["// Builds the TLV payload for the Rename Contact (EDIT CONTACT NAME) op and\n// dispatches it via the chunked-framing scheme shared with the other\n// address-book ops (2-byte BE total length + <=255B chunks). Rename is an\n// OS/dashboard command (CLA 0xE0 / INS 0x2E) \u2014 the caller runs this task after\n// navigating to the dashboard (GoToDashboardDeviceAction), never inside an app.\n//\n// The device rotates the contact-level hmac_name and returns the fresh proof on\n// the final chunk; per-entry hmac_rest values are untouched (they bind\n// gid|scope|id|family|chain_id, never the name), so a single APDU regardless of\n// the contact's entry count.\n//\n// Reference: Address Book Final Specifications \u2014 Edit Contact Name. Tag order:\n// STRUCT_TYPE, STRUCT_VERSION, CONTACT_NAME (new), PREVIOUS_CONTACT_NAME\n// (old), GROUP_HANDLE, DERIVATION_PATH, HMAC_PROOF.\nimport {\n ByteArrayBuilder,\n type CommandResult,\n DmkResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { RenameContactCommand } from \"@internal/app-binder/command/RenameContactCommand\";\nimport { RENAME_CONTACT_P1 } from \"@internal/app-binder/model/contactsConstants\";\nimport { type ContactsErrorCodes } from \"@internal/app-binder/model/contactsErrors\";\nimport {\n CONTACTS_TLV_TAG,\n encodeTlvAscii,\n encodeTlvBuffer,\n encodeTlvUInt8,\n packDerivationPath,\n STRUCT_TYPE_EDIT_CONTACT_NAME,\n STRUCT_VERSION_VALUE,\n} from \"@internal/app-binder/services/contactsTlvSerializer\";\nimport { sendFramedContactsPayload } from \"@internal/app-binder/services/sendFramedContactsPayload\";\n\nexport type RenameContactProof = {\n readonly hmacProof: Uint8Array;\n};\n\nexport type SendRenameContactTaskArgs = {\n readonly previousContactName: string;\n readonly newContactName: string;\n readonly groupHandle: Uint8Array;\n readonly hmacProof: Uint8Array;\n readonly logger?: LoggerPublisherService;\n};\n\nexport class SendRenameContactTask {\n constructor(\n private readonly api: InternalApi,\n private readonly args: SendRenameContactTaskArgs,\n ) {}\n\n async run(): Promise<CommandResult<RenameContactProof, ContactsErrorCodes>> {\n const payload = this.buildPayload(this.args);\n\n const result = (await sendFramedContactsPayload(this.api, {\n payload,\n p1: RENAME_CONTACT_P1,\n makeCommand: (chunk, p2) => new RenameContactCommand({ data: chunk, p2 }),\n logger: this.args.logger,\n commandTag: \"SendRenameContactTask\",\n })) as CommandResult<\n { readonly hmacProof?: Uint8Array },\n ContactsErrorCodes\n >;\n\n if (!isSuccessCommandResult(result)) {\n return result;\n }\n\n const { hmacProof } = result.data;\n if (!hmacProof) {\n return DmkResultFactory({\n error: new InvalidStatusWordError(\n \"RenameContact final-chunk response did not carry hmac_name\",\n ),\n });\n }\n return DmkResultFactory({ data: { hmacProof } });\n }\n\n private buildPayload(args: SendRenameContactTaskArgs): Uint8Array {\n const builder = new ByteArrayBuilder();\n encodeTlvUInt8(\n builder,\n CONTACTS_TLV_TAG.STRUCT_TYPE,\n STRUCT_TYPE_EDIT_CONTACT_NAME,\n );\n encodeTlvUInt8(\n builder,\n CONTACTS_TLV_TAG.STRUCT_VERSION,\n STRUCT_VERSION_VALUE,\n );\n encodeTlvAscii(builder, CONTACTS_TLV_TAG.CONTACT_NAME, args.newContactName);\n encodeTlvAscii(\n builder,\n CONTACTS_TLV_TAG.PREVIOUS_CONTACT_NAME,\n args.previousContactName,\n );\n encodeTlvBuffer(builder, CONTACTS_TLV_TAG.GROUP_HANDLE, args.groupHandle);\n // The Ethereum app requires DERIVATION_PATH on Edit Contact Name (0x6a80\n // without it), same as Register Identity. Default m/44'/60'/0'/0/0.\n encodeTlvBuffer(\n builder,\n CONTACTS_TLV_TAG.DERIVATION_PATH,\n packDerivationPath([0x8000002c, 0x8000003c, 0x80000000, 0, 0]),\n );\n encodeTlvBuffer(builder, CONTACTS_TLV_TAG.HMAC_PROOF, args.hmacProof);\n\n return builder.build();\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GAcA,IAAAI,EAQO,2CAEPC,EAAqC,6DACrCC,EAAkC,wDAElCC,EAQO,+DACPC,EAA0C,mEAcnC,MAAMN,CAAsB,CACjC,YACmBO,EACAC,EACjB,CAFiB,SAAAD,EACA,UAAAC,CAChB,CAEH,MAAM,KAAsE,CAC1E,MAAMC,EAAU,KAAK,aAAa,KAAK,IAAI,EAErCC,EAAU,QAAM,6BAA0B,KAAK,IAAK,CACxD,QAAAD,EACA,GAAI,oBACJ,YAAa,CAACE,EAAOC,IAAO,IAAI,uBAAqB,CAAE,KAAMD,EAAO,GAAAC,CAAG,CAAC,EACxE,OAAQ,KAAK,KAAK,OAClB,WAAY,uBACd,CAAC,EAKD,GAAI,IAAC,0BAAuBF,CAAM,EAChC,OAAOA,EAGT,KAAM,CAAE,UAAAG,CAAU,EAAIH,EAAO,KAC7B,OAAKG,KAOE,oBAAiB,CAAE,KAAM,CAAE,UAAAA,CAAU,CAAE,CAAC,KANtC,oBAAiB,CACtB,MAAO,IAAI,yBACT,4DACF,CACF,CAAC,CAGL,CAEQ,aAAaL,EAA6C,CAChE,MAAMM,EAAU,IAAI,mBACpB,2BACEA,EACA,mBAAiB,YACjB,+BACF,KACA,kBACEA,EACA,mBAAiB,eACjB,sBACF,KACA,kBAAeA,EAAS,mBAAiB,aAAcN,EAAK,cAAc,KAC1E,kBACEM,EACA,mBAAiB,sBACjBN,EAAK,mBACP,KACA,mBAAgBM,EAAS,mBAAiB,aAAcN,EAAK,WAAW,KAGxE,mBACEM,EACA,mBAAiB,mBACjB,sBAAmB,CAAC,WAAY,WAAY,WAAY,EAAG,CAAC,CAAC,CAC/D,KACA,mBAAgBA,EAAS,mBAAiB,WAAYN,EAAK,SAAS,EAE7DM,EAAQ,MAAM,CACvB,CACF",
4
+ "sourcesContent": ["// Builds the TLV payload for the Rename Contact (EDIT CONTACT NAME) op and\n// dispatches it via the chunked-framing scheme shared with the other\n// address-book ops (2-byte BE total length + <=255B chunks). Rename is an\n// OS/dashboard command (CLA 0xE0 / INS 0x2E) \u2014 the caller runs this task after\n// navigating to the dashboard (GoToDashboardDeviceAction), never inside an app.\n//\n// The device rotates the contact-level hmac_name and returns the fresh proof on\n// the final chunk; per-entry hmac_rest values are untouched (they bind\n// gid|scope|id|family|chain_id, never the name), so a single APDU regardless of\n// the contact's entry count.\n//\n// Reference: Address Book Final Specifications \u2014 Edit Contact Name. Tag order:\n// STRUCT_TYPE, STRUCT_VERSION, CONTACT_NAME (new), PREVIOUS_CONTACT_NAME\n// (old), GROUP_HANDLE, [DERIVATION_PATH], HMAC_PROOF.\n//\n// DERIVATION_PATH (tag 0x69) is CONDITIONAL (DSDK-1481). The final product\n// serves rename from the OS, which needs no path \u2014 but the OS build decides the\n// payload shape, and the two shapes are mutually exclusive across builds:\n// - OS below the model's cutoff (e.g. Flex 1.7.0-rc2 and earlier): the path\n// is still MANDATORY, omitting it -> 0x686A (before any review screen).\n// - OS at/after the cutoff (Flex 1.7.0-rc3, final, later): the path is\n// rejected, sending it -> 0x6A80 (unknown tag).\n// So the caller passes includeDerivationPath, computed from the device OS\n// version read *freshly* from the device (renameRequiresDerivationPath), and we\n// emit the tag only for the older builds. This shim \u2014 the flag, the cutoff\n// table entries, and renameRequiresDerivationPath \u2014 is removed in one commit\n// once no in-the-field OS predates the cutoff. The rc2 requirement was verified\n// on hardware: a Flex on OS 1.7.0-rc2 rejects the path-free payload with 0x686A.\nimport {\n ByteArrayBuilder,\n type CommandResult,\n DmkResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { RenameContactCommand } from \"@internal/app-binder/command/RenameContactCommand\";\nimport { RENAME_CONTACT_P1 } from \"@internal/app-binder/model/contactsConstants\";\nimport { type ContactsErrorCodes } from \"@internal/app-binder/model/contactsErrors\";\nimport {\n CONTACTS_TLV_TAG,\n encodeTlvAscii,\n encodeTlvBuffer,\n encodeTlvUInt8,\n packDerivationPath,\n STRUCT_TYPE_EDIT_CONTACT_NAME,\n STRUCT_VERSION_VALUE,\n} from \"@internal/app-binder/services/contactsTlvSerializer\";\nimport { sendFramedContactsPayload } from \"@internal/app-binder/services/sendFramedContactsPayload\";\n\nexport type RenameContactProof = {\n readonly hmacProof: Uint8Array;\n};\n\nexport type SendRenameContactTaskArgs = {\n readonly previousContactName: string;\n readonly newContactName: string;\n readonly groupHandle: Uint8Array;\n readonly hmacProof: Uint8Array;\n /**\n * TEMPORARY (DSDK-1481) \u2014 emit the `DERIVATION_PATH` (tag 0x69) TLV. Defaults\n * to `false` (the GA payload, path-free). The caller sets it `true` only for\n * OS builds below the model's cutoff, which still mandate the path; see\n * {@link renameRequiresDerivationPath}. Not exposed on the public\n * `RenameContactInput` \u2014 the host never chooses this.\n */\n readonly includeDerivationPath?: boolean;\n readonly logger?: LoggerPublisherService;\n};\n\nexport class SendRenameContactTask {\n constructor(\n private readonly api: InternalApi,\n private readonly args: SendRenameContactTaskArgs,\n ) {}\n\n async run(): Promise<CommandResult<RenameContactProof, ContactsErrorCodes>> {\n const payload = this.buildPayload(this.args);\n\n const result = (await sendFramedContactsPayload(this.api, {\n payload,\n p1: RENAME_CONTACT_P1,\n makeCommand: (chunk, p2) => new RenameContactCommand({ data: chunk, p2 }),\n logger: this.args.logger,\n commandTag: \"SendRenameContactTask\",\n })) as CommandResult<\n { readonly hmacProof?: Uint8Array },\n ContactsErrorCodes\n >;\n\n if (!isSuccessCommandResult(result)) {\n return result;\n }\n\n const { hmacProof } = result.data;\n if (!hmacProof) {\n return DmkResultFactory({\n error: new InvalidStatusWordError(\n \"RenameContact final-chunk response did not carry hmac_name\",\n ),\n });\n }\n return DmkResultFactory({ data: { hmacProof } });\n }\n\n private buildPayload(args: SendRenameContactTaskArgs): Uint8Array {\n const builder = new ByteArrayBuilder();\n encodeTlvUInt8(\n builder,\n CONTACTS_TLV_TAG.STRUCT_TYPE,\n STRUCT_TYPE_EDIT_CONTACT_NAME,\n );\n encodeTlvUInt8(\n builder,\n CONTACTS_TLV_TAG.STRUCT_VERSION,\n STRUCT_VERSION_VALUE,\n );\n encodeTlvAscii(builder, CONTACTS_TLV_TAG.CONTACT_NAME, args.newContactName);\n encodeTlvAscii(\n builder,\n CONTACTS_TLV_TAG.PREVIOUS_CONTACT_NAME,\n args.previousContactName,\n );\n encodeTlvBuffer(builder, CONTACTS_TLV_TAG.GROUP_HANDLE, args.groupHandle);\n // TEMPORARY (DSDK-1481): OS builds below the model's cutoff still mandate\n // DERIVATION_PATH for EDIT CONTACT NAME (0x686A without it); newer builds\n // reject it (0x6A80). The caller sets includeDerivationPath from the fresh\n // device OS version. Fixed m/44'/60'/0'/0/0 \u2014 rename is name-only, the path\n // is a payload-shape formality the old OS parser requires.\n if (args.includeDerivationPath) {\n encodeTlvBuffer(\n builder,\n CONTACTS_TLV_TAG.DERIVATION_PATH,\n packDerivationPath([0x8000002c, 0x8000003c, 0x80000000, 0, 0]),\n );\n }\n encodeTlvBuffer(builder, CONTACTS_TLV_TAG.HMAC_PROOF, args.hmacProof);\n\n return builder.build();\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GA4BA,IAAAI,EAQO,2CAEPC,EAAqC,6DACrCC,EAAkC,wDAElCC,EAQO,+DACPC,EAA0C,mEAsBnC,MAAMN,CAAsB,CACjC,YACmBO,EACAC,EACjB,CAFiB,SAAAD,EACA,UAAAC,CAChB,CAEH,MAAM,KAAsE,CAC1E,MAAMC,EAAU,KAAK,aAAa,KAAK,IAAI,EAErCC,EAAU,QAAM,6BAA0B,KAAK,IAAK,CACxD,QAAAD,EACA,GAAI,oBACJ,YAAa,CAACE,EAAOC,IAAO,IAAI,uBAAqB,CAAE,KAAMD,EAAO,GAAAC,CAAG,CAAC,EACxE,OAAQ,KAAK,KAAK,OAClB,WAAY,uBACd,CAAC,EAKD,GAAI,IAAC,0BAAuBF,CAAM,EAChC,OAAOA,EAGT,KAAM,CAAE,UAAAG,CAAU,EAAIH,EAAO,KAC7B,OAAKG,KAOE,oBAAiB,CAAE,KAAM,CAAE,UAAAA,CAAU,CAAE,CAAC,KANtC,oBAAiB,CACtB,MAAO,IAAI,yBACT,4DACF,CACF,CAAC,CAGL,CAEQ,aAAaL,EAA6C,CAChE,MAAMM,EAAU,IAAI,mBACpB,2BACEA,EACA,mBAAiB,YACjB,+BACF,KACA,kBACEA,EACA,mBAAiB,eACjB,sBACF,KACA,kBAAeA,EAAS,mBAAiB,aAAcN,EAAK,cAAc,KAC1E,kBACEM,EACA,mBAAiB,sBACjBN,EAAK,mBACP,KACA,mBAAgBM,EAAS,mBAAiB,aAAcN,EAAK,WAAW,EAMpEA,EAAK,0BACP,mBACEM,EACA,mBAAiB,mBACjB,sBAAmB,CAAC,WAAY,WAAY,WAAY,EAAG,CAAC,CAAC,CAC/D,KAEF,mBAAgBA,EAAS,mBAAiB,WAAYN,EAAK,SAAS,EAE7DM,EAAQ,MAAM,CACvB,CACF",
6
6
  "names": ["SendRenameContactTask_exports", "__export", "SendRenameContactTask", "__toCommonJS", "import_device_management_kit", "import_RenameContactCommand", "import_contactsConstants", "import_contactsTlvSerializer", "import_sendFramedContactsPayload", "api", "args", "payload", "result", "chunk", "p2", "hmacProof", "builder"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=require("@ledgerhq/device-management-kit"),i=require("../../app-binder/command/RenameContactCommand"),o=require("./SendRenameContactTask");function s(e){const n=new Uint8Array(e.length/2);for(let t=0;t<e.length;t+=2)n[t/2]=parseInt(e.slice(t,t+2),16);return n}const r=s("cc".repeat(64)),c=s("dd".repeat(32)),d=s("ee".repeat(32)),l="6915058000002c8000003c800000000000000000000000",p=s("009001012e02010181f003426f6281f305416c69636581f640"+"cc".repeat(64)+l+"2920"+"dd".repeat(32));function m(){return{sendCommand:vi.fn()}}describe("SendRenameContactTask",()=>{it("assembles the rename framed chunk and dispatches RenameContactCommand",async()=>{const e=m();e.sendCommand.mockResolvedValueOnce((0,a.CommandResultFactory)({data:{hmacProof:d}}));const n=await new o.SendRenameContactTask(e,{previousContactName:"Alice",newContactName:"Bob",groupHandle:r,hmacProof:c}).run();expect(e.sendCommand.mock.calls).toHaveLength(1),expect(e.sendCommand.mock.calls[0][0]).toStrictEqual(new i.RenameContactCommand({data:p,p2:0})),expect(n).toStrictEqual((0,a.CommandResultFactory)({data:{hmacProof:d}}))}),it("emits the DERIVATION_PATH tag immediately before HMAC_PROOF",async()=>{const e=m();e.sendCommand.mockResolvedValueOnce((0,a.CommandResultFactory)({data:{hmacProof:d}})),await new o.SendRenameContactTask(e,{previousContactName:"Alice",newContactName:"Bob",groupHandle:r,hmacProof:c}).run();const n=e.sendCommand.mock.calls[0][0],t=Buffer.from(n.args.data).toString("hex");expect(t.endsWith(l+"2920"+"dd".repeat(32))).toBe(!0)}),it("propagates command-level errors",async()=>{const e=m();e.sendCommand.mockResolvedValueOnce((0,a.CommandResultFactory)({error:new a.InvalidStatusWordError("user cancelled")}));const n=await new o.SendRenameContactTask(e,{previousContactName:"Alice",newContactName:"Bob",groupHandle:r,hmacProof:c}).run();expect(n).toStrictEqual((0,a.CommandResultFactory)({error:new a.InvalidStatusWordError("user cancelled")}))}),it("returns InvalidStatusWordError when the final response carries no hmac_name",async()=>{const e=m();e.sendCommand.mockResolvedValueOnce((0,a.CommandResultFactory)({data:{}}));const n=await new o.SendRenameContactTask(e,{previousContactName:"Alice",newContactName:"Bob",groupHandle:r,hmacProof:c}).run();expect(n.status).not.toBe(void 0),"error"in n&&expect(n.error).toBeInstanceOf(a.InvalidStatusWordError)})});
1
+ "use strict";var t=require("@ledgerhq/device-management-kit"),i=require("../../app-binder/command/RenameContactCommand"),o=require("./SendRenameContactTask");function s(e){const a=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)a[n/2]=parseInt(e.slice(n,n+2),16);return a}const c=s("cc".repeat(64)),r=s("dd".repeat(32)),d=s("ee".repeat(32)),p=s("007901012e02010181f003426f6281f305416c69636581f640"+"cc".repeat(64)+"2920"+"dd".repeat(32));function m(){return{sendCommand:vi.fn()}}describe("SendRenameContactTask",()=>{it("assembles the rename framed chunk and dispatches RenameContactCommand",async()=>{const e=m();e.sendCommand.mockResolvedValueOnce((0,t.CommandResultFactory)({data:{hmacProof:d}}));const a=await new o.SendRenameContactTask(e,{previousContactName:"Alice",newContactName:"Bob",groupHandle:c,hmacProof:r}).run();expect(e.sendCommand.mock.calls).toHaveLength(1),expect(e.sendCommand.mock.calls[0][0]).toStrictEqual(new i.RenameContactCommand({data:p,p2:0})),expect(a).toStrictEqual((0,t.CommandResultFactory)({data:{hmacProof:d}}))}),it("does not emit a DERIVATION_PATH tag by default",async()=>{const e=m();e.sendCommand.mockResolvedValueOnce((0,t.CommandResultFactory)({data:{hmacProof:d}})),await new o.SendRenameContactTask(e,{previousContactName:"Alice",newContactName:"Bob",groupHandle:c,hmacProof:r}).run();const a=e.sendCommand.mock.calls[0][0],n=Buffer.from(a.args.data).toString("hex");expect(n).not.toContain("6915"),expect(n.endsWith("81f640"+"cc".repeat(64)+"2920"+"dd".repeat(32))).toBe(!0)}),it("emits the DERIVATION_PATH tag when includeDerivationPath is set",async()=>{const e=m();e.sendCommand.mockResolvedValueOnce((0,t.CommandResultFactory)({data:{hmacProof:d}})),await new o.SendRenameContactTask(e,{previousContactName:"Alice",newContactName:"Bob",groupHandle:c,hmacProof:r,includeDerivationPath:!0}).run();const n=s("009001012e02010181f003426f6281f305416c69636581f640"+"cc".repeat(64)+"6915058000002c8000003c800000000000000000000000"+"2920"+"dd".repeat(32)),l=e.sendCommand.mock.calls[0][0];expect(l).toStrictEqual(new i.RenameContactCommand({data:n,p2:0}))}),it("propagates command-level errors",async()=>{const e=m();e.sendCommand.mockResolvedValueOnce((0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("user cancelled")}));const a=await new o.SendRenameContactTask(e,{previousContactName:"Alice",newContactName:"Bob",groupHandle:c,hmacProof:r}).run();expect(a).toStrictEqual((0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("user cancelled")}))}),it("returns InvalidStatusWordError when the final response carries no hmac_name",async()=>{const e=m();e.sendCommand.mockResolvedValueOnce((0,t.CommandResultFactory)({data:{}}));const a=await new o.SendRenameContactTask(e,{previousContactName:"Alice",newContactName:"Bob",groupHandle:c,hmacProof:r}).run();expect(a.status).not.toBe(void 0),"error"in a&&expect(a.error).toBeInstanceOf(t.InvalidStatusWordError)})});
2
2
  //# sourceMappingURL=SendRenameContactTask.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/SendRenameContactTask.test.ts"],
4
- "sourcesContent": ["// Validates that the TLV serializer + tag ordering + chunk framing produce the\n// expected wire bytes for the Rename Contact (EDIT CONTACT NAME) op. The framed\n// chunk = 2-byte BE total length + TLV. Tag order: STRUCT_TYPE, STRUCT_VERSION,\n// CONTACT_NAME (new), PREVIOUS_CONTACT_NAME (old), GROUP_HANDLE, DERIVATION_PATH,\n// HMAC_PROOF \u2014 with tags >= 0x80 (0xf0/0xf3/0xf6) encoded as the 2-byte DER form\n// [0x81, tag].\nimport {\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { RenameContactCommand } from \"@internal/app-binder/command/RenameContactCommand\";\n\nimport { SendRenameContactTask } from \"./SendRenameContactTask\";\n\nfunction hexToBytes(hex: string): Uint8Array {\n const out = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n out[i / 2] = parseInt(hex.slice(i, i + 2), 16);\n }\n return out;\n}\n\nconst GROUP_HANDLE = hexToBytes(\"cc\".repeat(64));\nconst HMAC_PROOF_IN = hexToBytes(\"dd\".repeat(32));\nconst HMAC_PROOF_OUT = hexToBytes(\"ee\".repeat(32));\n\n// Framed chunk = \"00 90\" (2-byte BE total TLV length = 144) + TLV:\n// 01 01 2e STRUCT_TYPE = EDIT_CONTACT_NAME (0x2e)\n// 02 01 01 STRUCT_VERSION = 1\n// 81 f0 03 \"Bob\" CONTACT_NAME (new), tag 0xf0 -> [81 f0]\n// 81 f3 05 \"Alice\" PREVIOUS_CONTACT_NAME (old), tag 0xf3 -> [81 f3]\n// 81 f6 40 <64x cc> GROUP_HANDLE, tag 0xf6 -> [81 f6]\n// 69 15 05 <5x path> DERIVATION_PATH (0x69), m/44'/60'/0'/0/0\n// 29 20 <32x dd> HMAC_PROOF\nconst DERIVATION_PATH_TLV = \"6915058000002c8000003c800000000000000000000000\";\nconst FRAMED_CHUNK = hexToBytes(\n \"0090\" +\n \"01012e\" +\n \"020101\" +\n \"81f003426f62\" +\n \"81f305416c696365\" +\n \"81f640\" +\n \"cc\".repeat(64) +\n DERIVATION_PATH_TLV +\n \"2920\" +\n \"dd\".repeat(32),\n);\n\nfunction makeApiMock(): InternalApi & {\n sendCommand: ReturnType<typeof vi.fn>;\n} {\n return { sendCommand: vi.fn() } as unknown as InternalApi & {\n sendCommand: ReturnType<typeof vi.fn>;\n };\n}\n\ndescribe(\"SendRenameContactTask\", () => {\n it(\"assembles the rename framed chunk and dispatches RenameContactCommand\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: { hmacProof: HMAC_PROOF_OUT } }),\n );\n\n const result = await new SendRenameContactTask(api, {\n previousContactName: \"Alice\",\n newContactName: \"Bob\",\n groupHandle: GROUP_HANDLE,\n hmacProof: HMAC_PROOF_IN,\n }).run();\n\n expect(api.sendCommand.mock.calls).toHaveLength(1);\n expect(api.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new RenameContactCommand({ data: FRAMED_CHUNK, p2: 0x00 }),\n );\n expect(result).toStrictEqual(\n CommandResultFactory({ data: { hmacProof: HMAC_PROOF_OUT } }),\n );\n });\n\n it(\"emits the DERIVATION_PATH tag immediately before HMAC_PROOF\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: { hmacProof: HMAC_PROOF_OUT } }),\n );\n\n await new SendRenameContactTask(api, {\n previousContactName: \"Alice\",\n newContactName: \"Bob\",\n groupHandle: GROUP_HANDLE,\n hmacProof: HMAC_PROOF_IN,\n }).run();\n\n // The Ethereum app requires DERIVATION_PATH (0x69); it sits immediately\n // before HMAC_PROOF (0x29), matching Register Identity.\n const command = api.sendCommand.mock.calls[0]![0] as RenameContactCommand;\n const framedHex = Buffer.from(command.args.data).toString(\"hex\");\n expect(\n framedHex.endsWith(DERIVATION_PATH_TLV + \"2920\" + \"dd\".repeat(32)),\n ).toBe(true);\n });\n\n it(\"propagates command-level errors\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"user cancelled\"),\n }),\n );\n\n const result = await new SendRenameContactTask(api, {\n previousContactName: \"Alice\",\n newContactName: \"Bob\",\n groupHandle: GROUP_HANDLE,\n hmacProof: HMAC_PROOF_IN,\n }).run();\n\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"user cancelled\"),\n }),\n );\n });\n\n it(\"returns InvalidStatusWordError when the final response carries no hmac_name\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(CommandResultFactory({ data: {} }));\n\n const result = await new SendRenameContactTask(api, {\n previousContactName: \"Alice\",\n newContactName: \"Bob\",\n groupHandle: GROUP_HANDLE,\n hmacProof: HMAC_PROOF_IN,\n }).run();\n\n expect(result.status).not.toBe(undefined);\n if (\"error\" in result) {\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n }\n });\n});\n"],
5
- "mappings": "aAMA,IAAAA,EAIO,2CAEPC,EAAqC,6DAErCC,EAAsC,mCAEtC,SAASC,EAAWC,EAAyB,CAC3C,MAAMC,EAAM,IAAI,WAAWD,EAAI,OAAS,CAAC,EACzC,QAASE,EAAI,EAAGA,EAAI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,CACb,CAAC,EAAE,IAAI,EAIP,MAAMO,EAAUF,EAAI,YAAY,KAAK,MAAM,CAAC,EAAG,CAAC,EAC1CG,EAAY,OAAO,KAAKD,EAAQ,KAAK,IAAI,EAAE,SAAS,KAAK,EAC/D,OACEC,EAAU,SAASN,EAAsB,OAAS,KAAK,OAAO,EAAE,CAAC,CACnE,EAAE,KAAK,EAAI,CACb,CAAC,EAED,GAAG,kCAAmC,SAAY,CAChD,MAAMG,EAAMD,EAAY,EACxBC,EAAI,YAAY,yBACd,wBAAqB,CACnB,MAAO,IAAI,yBAAuB,gBAAgB,CACpD,CAAC,CACH,EAEA,MAAMC,EAAS,MAAM,IAAI,wBAAsBD,EAAK,CAClD,oBAAqB,QACrB,eAAgB,MAChB,YAAaN,EACb,UAAWC,CACb,CAAC,EAAE,IAAI,EAEP,OAAOM,CAAM,EAAE,iBACb,wBAAqB,CACnB,MAAO,IAAI,yBAAuB,gBAAgB,CACpD,CAAC,CACH,CACF,CAAC,EAED,GAAG,8EAA+E,SAAY,CAC5F,MAAMD,EAAMD,EAAY,EACxBC,EAAI,YAAY,yBAAsB,wBAAqB,CAAE,KAAM,CAAC,CAAE,CAAC,CAAC,EAExE,MAAMC,EAAS,MAAM,IAAI,wBAAsBD,EAAK,CAClD,oBAAqB,QACrB,eAAgB,MAChB,YAAaN,EACb,UAAWC,CACb,CAAC,EAAE,IAAI,EAEP,OAAOM,EAAO,MAAM,EAAE,IAAI,KAAK,MAAS,EACpC,UAAWA,GACb,OAAOA,EAAO,KAAK,EAAE,eAAe,wBAAsB,CAE9D,CAAC,CACH,CAAC",
6
- "names": ["import_device_management_kit", "import_RenameContactCommand", "import_SendRenameContactTask", "hexToBytes", "hex", "out", "i", "GROUP_HANDLE", "HMAC_PROOF_IN", "HMAC_PROOF_OUT", "DERIVATION_PATH_TLV", "FRAMED_CHUNK", "makeApiMock", "api", "result", "command", "framedHex"]
4
+ "sourcesContent": ["// Validates that the TLV serializer + tag ordering + chunk framing produce the\n// expected wire bytes for the Rename Contact (EDIT CONTACT NAME) op. The framed\n// chunk = 2-byte BE total length + TLV. Tag order: STRUCT_TYPE, STRUCT_VERSION,\n// CONTACT_NAME (new), PREVIOUS_CONTACT_NAME (old), GROUP_HANDLE, HMAC_PROOF \u2014\n// with tags >= 0x80 (0xf0/0xf3/0xf6) encoded as the 2-byte DER form [0x81, tag].\n// DERIVATION_PATH (tag 0x69) is CONDITIONAL (DSDK-1481): omitted by default (the\n// GA payload), and inserted between GROUP_HANDLE and HMAC_PROOF only when the\n// caller passes includeDerivationPath \u2014 the shape older OS builds still require.\nimport {\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { RenameContactCommand } from \"@internal/app-binder/command/RenameContactCommand\";\n\nimport { SendRenameContactTask } from \"./SendRenameContactTask\";\n\nfunction hexToBytes(hex: string): Uint8Array {\n const out = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n out[i / 2] = parseInt(hex.slice(i, i + 2), 16);\n }\n return out;\n}\n\nconst GROUP_HANDLE = hexToBytes(\"cc\".repeat(64));\nconst HMAC_PROOF_IN = hexToBytes(\"dd\".repeat(32));\nconst HMAC_PROOF_OUT = hexToBytes(\"ee\".repeat(32));\n\n// Framed chunk = \"00 79\" (2-byte BE total TLV length = 121) + TLV:\n// 01 01 2e STRUCT_TYPE = EDIT_CONTACT_NAME (0x2e)\n// 02 01 01 STRUCT_VERSION = 1\n// 81 f0 03 \"Bob\" CONTACT_NAME (new), tag 0xf0 -> [81 f0]\n// 81 f3 05 \"Alice\" PREVIOUS_CONTACT_NAME (old), tag 0xf3 -> [81 f3]\n// 81 f6 40 <64x cc> GROUP_HANDLE, tag 0xf6 -> [81 f6]\n// 29 20 <32x dd> HMAC_PROOF\nconst FRAMED_CHUNK = hexToBytes(\n \"0079\" +\n \"01012e\" +\n \"020101\" +\n \"81f003426f62\" +\n \"81f305416c696365\" +\n \"81f640\" +\n \"cc\".repeat(64) +\n \"2920\" +\n \"dd\".repeat(32),\n);\n\nfunction makeApiMock(): InternalApi & {\n sendCommand: ReturnType<typeof vi.fn>;\n} {\n return { sendCommand: vi.fn() } as unknown as InternalApi & {\n sendCommand: ReturnType<typeof vi.fn>;\n };\n}\n\ndescribe(\"SendRenameContactTask\", () => {\n it(\"assembles the rename framed chunk and dispatches RenameContactCommand\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: { hmacProof: HMAC_PROOF_OUT } }),\n );\n\n const result = await new SendRenameContactTask(api, {\n previousContactName: \"Alice\",\n newContactName: \"Bob\",\n groupHandle: GROUP_HANDLE,\n hmacProof: HMAC_PROOF_IN,\n }).run();\n\n expect(api.sendCommand.mock.calls).toHaveLength(1);\n expect(api.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new RenameContactCommand({ data: FRAMED_CHUNK, p2: 0x00 }),\n );\n expect(result).toStrictEqual(\n CommandResultFactory({ data: { hmacProof: HMAC_PROOF_OUT } }),\n );\n });\n\n it(\"does not emit a DERIVATION_PATH tag by default\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: { hmacProof: HMAC_PROOF_OUT } }),\n );\n\n await new SendRenameContactTask(api, {\n previousContactName: \"Alice\",\n newContactName: \"Bob\",\n groupHandle: GROUP_HANDLE,\n hmacProof: HMAC_PROOF_IN,\n }).run();\n\n // GA payload (includeDerivationPath omitted): newer OS builds reject tag\n // 0x69, so HMAC_PROOF (0x29) follows GROUP_HANDLE directly.\n const command = api.sendCommand.mock.calls[0]![0] as RenameContactCommand;\n const framedHex = Buffer.from(command.args.data).toString(\"hex\");\n expect(framedHex).not.toContain(\"6915\");\n expect(\n framedHex.endsWith(\"81f640\" + \"cc\".repeat(64) + \"2920\" + \"dd\".repeat(32)),\n ).toBe(true);\n });\n\n it(\"emits the DERIVATION_PATH tag when includeDerivationPath is set\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ data: { hmacProof: HMAC_PROOF_OUT } }),\n );\n\n await new SendRenameContactTask(api, {\n previousContactName: \"Alice\",\n newContactName: \"Bob\",\n groupHandle: GROUP_HANDLE,\n hmacProof: HMAC_PROOF_IN,\n includeDerivationPath: true,\n }).run();\n\n // Older OS builds (below the model cutoff) mandate tag 0x69. The path TLV\n // (fixed m/44'/60'/0'/0/0) sits between GROUP_HANDLE and HMAC_PROOF, and the\n // framed total length grows by its 23 bytes: 0x0079 -> 0x0090.\n // 69 15 05 8000002c 8000003c 80000000 00000000 00000000\n const pathTlv =\n \"6915\" +\n \"05\" +\n \"8000002c\" +\n \"8000003c\" +\n \"80000000\" +\n \"00000000\" +\n \"00000000\";\n const expectedFramed = hexToBytes(\n \"0090\" +\n \"01012e\" +\n \"020101\" +\n \"81f003426f62\" +\n \"81f305416c696365\" +\n \"81f640\" +\n \"cc\".repeat(64) +\n pathTlv +\n \"2920\" +\n \"dd\".repeat(32),\n );\n const command = api.sendCommand.mock.calls[0]![0] as RenameContactCommand;\n expect(command).toStrictEqual(\n new RenameContactCommand({ data: expectedFramed, p2: 0x00 }),\n );\n });\n\n it(\"propagates command-level errors\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"user cancelled\"),\n }),\n );\n\n const result = await new SendRenameContactTask(api, {\n previousContactName: \"Alice\",\n newContactName: \"Bob\",\n groupHandle: GROUP_HANDLE,\n hmacProof: HMAC_PROOF_IN,\n }).run();\n\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"user cancelled\"),\n }),\n );\n });\n\n it(\"returns InvalidStatusWordError when the final response carries no hmac_name\", async () => {\n const api = makeApiMock();\n api.sendCommand.mockResolvedValueOnce(CommandResultFactory({ data: {} }));\n\n const result = await new SendRenameContactTask(api, {\n previousContactName: \"Alice\",\n newContactName: \"Bob\",\n groupHandle: GROUP_HANDLE,\n hmacProof: HMAC_PROOF_IN,\n }).run();\n\n expect(result.status).not.toBe(undefined);\n if (\"error\" in result) {\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n }\n });\n});\n"],
5
+ "mappings": "aAQA,IAAAA,EAIO,2CAEPC,EAAqC,6DAErCC,EAAsC,mCAEtC,SAASC,EAAWC,EAAyB,CAC3C,MAAMC,EAAM,IAAI,WAAWD,EAAI,OAAS,CAAC,EACzC,QAASE,EAAI,EAAGA,EAAIF,EAAI,OAAQE,GAAK,EACnCD,EAAIC,EAAI,CAAC,EAAI,SAASF,EAAI,MAAME,EAAGA,EAAI,CAAC,EAAG,EAAE,EAE/C,OAAOD,CACT,CAEA,MAAME,EAAeJ,EAAW,KAAK,OAAO,EAAE,CAAC,EACzCK,EAAgBL,EAAW,KAAK,OAAO,EAAE,CAAC,EAC1CM,EAAiBN,EAAW,KAAK,OAAO,EAAE,CAAC,EAS3CO,EAAeP,EACnB,qDAME,KAAK,OAAO,EAAE,EACd,OACA,KAAK,OAAO,EAAE,CAClB,EAEA,SAASQ,GAEP,CACA,MAAO,CAAE,YAAa,GAAG,GAAG,CAAE,CAGhC,CAEA,SAAS,wBAAyB,IAAM,CACtC,GAAG,wEAAyE,SAAY,CACtF,MAAMC,EAAMD,EAAY,EACxBC,EAAI,YAAY,yBACd,wBAAqB,CAAE,KAAM,CAAE,UAAWH,CAAe,CAAE,CAAC,CAC9D,EAEA,MAAMI,EAAS,MAAM,IAAI,wBAAsBD,EAAK,CAClD,oBAAqB,QACrB,eAAgB,MAChB,YAAaL,EACb,UAAWC,CACb,CAAC,EAAE,IAAI,EAEP,OAAOI,EAAI,YAAY,KAAK,KAAK,EAAE,aAAa,CAAC,EACjD,OAAOA,EAAI,YAAY,KAAK,MAAM,CAAC,EAAG,CAAC,CAAC,EAAE,cACxC,IAAI,uBAAqB,CAAE,KAAMF,EAAc,GAAI,CAAK,CAAC,CAC3D,EACA,OAAOG,CAAM,EAAE,iBACb,wBAAqB,CAAE,KAAM,C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C,CACH,EAEA,MAAMC,EAAS,MAAM,IAAI,wBAAsBD,EAAK,CAClD,oBAAqB,QACrB,eAAgB,MAChB,YAAaL,EACb,UAAWC,CACb,CAAC,EAAE,IAAI,EAEP,OAAOK,CAAM,EAAE,iBACb,wBAAqB,CACnB,MAAO,IAAI,yBAAuB,gBAAgB,CACpD,CAAC,CACH,CACF,CAAC,EAED,GAAG,8EAA+E,SAAY,CAC5F,MAAMD,EAAMD,EAAY,EACxBC,EAAI,YAAY,yBAAsB,wBAAqB,CAAE,KAAM,CAAC,CAAE,CAAC,CAAC,EAExE,MAAMC,EAAS,MAAM,IAAI,wBAAsBD,EAAK,CAClD,oBAAqB,QACrB,eAAgB,MAChB,YAAaL,EACb,UAAWC,CACb,CAAC,EAAE,IAAI,EAEP,OAAOK,EAAO,MAAM,EAAE,IAAI,KAAK,MAAS,EACpC,UAAWA,GACb,OAAOA,EAAO,KAAK,EAAE,eAAe,wBAAsB,CAE9D,CAAC,CACH,CAAC",
6
+ "names": ["import_device_management_kit", "import_RenameContactCommand", "import_SendRenameContactTask", "hexToBytes", "hex", "out", "i", "GROUP_HANDLE", "HMAC_PROOF_IN", "HMAC_PROOF_OUT", "FRAMED_CHUNK", "makeApiMock", "api", "result", "command", "framedHex", "expectedFramed"]
7
7
  }
@@ -36,7 +36,7 @@
36
36
  "license": "Apache-2.0",
37
37
  "name": "@ledgerhq/device-contacts-kit",
38
38
  "peerDependencies": {
39
- "@ledgerhq/device-management-kit": "^1.8.0"
39
+ "@ledgerhq/device-management-kit": "^1.9.0"
40
40
  },
41
41
  "private": false,
42
42
  "repository": {
@@ -58,5 +58,5 @@
58
58
  "watch:builds": "pnpm ldmk-tool watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
59
59
  "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
60
60
  },
61
- "version": "0.3.1"
61
+ "version": "0.4.1"
62
62
  }
@@ -1,2 +1,2 @@
1
- import{ContactsManagerBuilder as r}from"./ContactsManagerBuilder";import{CONTACTS_VERSION_REQUIREMENTS as d,ETHEREUM_APP_NAME as p,isContactsSupported as s,isVersionAtLeast as a,resolveContactsVersionRequirements as o}from"./model/ContactsVersionRequirements";export{d as CONTACTS_VERSION_REQUIREMENTS,r as ContactsManagerBuilder,p as ETHEREUM_APP_NAME,s as isContactsSupported,a as isVersionAtLeast,o as resolveContactsVersionRequirements};
1
+ import{ContactsManagerBuilder as r}from"./ContactsManagerBuilder";import{CONTACTS_VERSION_REQUIREMENTS as n,ETHEREUM_APP_NAME as p,isVersionAtLeast as o,resolveContactsVersionRequirements as s}from"./model/ContactsVersionRequirements";import{buildProvideContactPayload as i,sendProvideContactPayload as A}from"../internal/app-binder/services/provideContact";export{n as CONTACTS_VERSION_REQUIREMENTS,r as ContactsManagerBuilder,p as ETHEREUM_APP_NAME,i as buildProvideContactPayload,o as isVersionAtLeast,s as resolveContactsVersionRequirements,A as sendProvideContactPayload};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/api/index.ts"],
4
- "sourcesContent": ["export {\n type EditExternalAddressIdentifierDAError,\n type EditExternalAddressIdentifierDAInput,\n type EditExternalAddressIdentifierDAIntermediateValue,\n type EditExternalAddressIdentifierDAOutput,\n type EditExternalAddressIdentifierDARequiredInteraction,\n type EditExternalAddressIdentifierDAReturnType,\n type EditExternalAddressIdentifierDAState,\n} from \"@api/app-binder/EditExternalAddressIdentifierDeviceActionTypes\";\nexport {\n type EditExternalAddressScopeDAError,\n type EditExternalAddressScopeDAInput,\n type EditExternalAddressScopeDAIntermediateValue,\n type EditExternalAddressScopeDAOutput,\n type EditExternalAddressScopeDARequiredInteraction,\n type EditExternalAddressScopeDAReturnType,\n type EditExternalAddressScopeDAState,\n} from \"@api/app-binder/EditExternalAddressScopeDeviceActionTypes\";\nexport {\n type RegisterExternalAddressDAError,\n type RegisterExternalAddressDAInput,\n type RegisterExternalAddressDAIntermediateValue,\n type RegisterExternalAddressDAOutput,\n type RegisterExternalAddressDARequiredInteraction,\n type RegisterExternalAddressDAReturnType,\n type RegisterExternalAddressDAState,\n} from \"@api/app-binder/RegisterExternalAddressDeviceActionTypes\";\nexport {\n type RenameContactDAError,\n type RenameContactDAInput,\n type RenameContactDAIntermediateValue,\n type RenameContactDAOutput,\n type RenameContactDARequiredInteraction,\n type RenameContactDAReturnType,\n type RenameContactDAState,\n} from \"@api/app-binder/RenameContactDeviceActionTypes\";\nexport { type ContactsManager } from \"@api/ContactsManager\";\nexport { ContactsManagerBuilder } from \"@api/ContactsManagerBuilder\";\nexport {\n CONTACTS_VERSION_REQUIREMENTS,\n type ContactsModelRequirement,\n type ContactsModelSupport,\n type ContactsModelUnsupported,\n type ContactsSupportQuery,\n type ContactsVersionRequirements,\n ETHEREUM_APP_NAME,\n isContactsSupported,\n isVersionAtLeast,\n resolveContactsVersionRequirements,\n} from \"@api/model/ContactsVersionRequirements\";\nexport {\n type EditExternalAddressIdentifierInput,\n type EditExternalAddressIdentifierOutput,\n} from \"@api/model/EditExternalAddressIdentifier\";\nexport {\n type EditExternalAddressScopeInput,\n type EditExternalAddressScopeOutput,\n} from \"@api/model/EditExternalAddressScope\";\nexport {\n type ExistingContactGroup,\n type RegisterExternalAddressInput,\n type RegisterExternalAddressMode,\n type RegisterExternalAddressOutput,\n} from \"@api/model/RegisterExternalAddress\";\nexport {\n type RenameContactInput,\n type RenameContactOutput,\n} from \"@api/model/RenameContact\";\n"],
5
- "mappings": "AAqCA,OAAS,0BAAAA,MAA8B,8BACvC,OACE,iCAAAC,EAMA,qBAAAC,EACA,uBAAAC,EACA,oBAAAC,EACA,sCAAAC,MACK",
6
- "names": ["ContactsManagerBuilder", "CONTACTS_VERSION_REQUIREMENTS", "ETHEREUM_APP_NAME", "isContactsSupported", "isVersionAtLeast", "resolveContactsVersionRequirements"]
4
+ "sourcesContent": ["export {\n type EditExternalAddressIdentifierDAError,\n type EditExternalAddressIdentifierDAInput,\n type EditExternalAddressIdentifierDAIntermediateValue,\n type EditExternalAddressIdentifierDAOutput,\n type EditExternalAddressIdentifierDARequiredInteraction,\n type EditExternalAddressIdentifierDAReturnType,\n type EditExternalAddressIdentifierDAState,\n} from \"@api/app-binder/EditExternalAddressIdentifierDeviceActionTypes\";\nexport {\n type EditExternalAddressScopeDAError,\n type EditExternalAddressScopeDAInput,\n type EditExternalAddressScopeDAIntermediateValue,\n type EditExternalAddressScopeDAOutput,\n type EditExternalAddressScopeDARequiredInteraction,\n type EditExternalAddressScopeDAReturnType,\n type EditExternalAddressScopeDAState,\n} from \"@api/app-binder/EditExternalAddressScopeDeviceActionTypes\";\nexport {\n type RegisterExternalAddressDAError,\n type RegisterExternalAddressDAInput,\n type RegisterExternalAddressDAIntermediateValue,\n type RegisterExternalAddressDAOutput,\n type RegisterExternalAddressDARequiredInteraction,\n type RegisterExternalAddressDAReturnType,\n type RegisterExternalAddressDAState,\n} from \"@api/app-binder/RegisterExternalAddressDeviceActionTypes\";\nexport {\n type RenameContactDAError,\n type RenameContactDAInput,\n type RenameContactDAIntermediateValue,\n type RenameContactDAOutput,\n type RenameContactDARequiredInteraction,\n type RenameContactDAReturnType,\n type RenameContactDAState,\n} from \"@api/app-binder/RenameContactDeviceActionTypes\";\nexport { type ContactsManager } from \"@api/ContactsManager\";\nexport { ContactsManagerBuilder } from \"@api/ContactsManagerBuilder\";\nexport {\n CONTACTS_VERSION_REQUIREMENTS,\n type ContactsModelRequirement,\n type ContactsModelSupport,\n type ContactsModelUnsupported,\n type ContactsVersionRequirements,\n ETHEREUM_APP_NAME,\n isVersionAtLeast,\n resolveContactsVersionRequirements,\n} from \"@api/model/ContactsVersionRequirements\";\nexport {\n type EditExternalAddressIdentifierInput,\n type EditExternalAddressIdentifierOutput,\n} from \"@api/model/EditExternalAddressIdentifier\";\nexport {\n type EditExternalAddressScopeInput,\n type EditExternalAddressScopeOutput,\n} from \"@api/model/EditExternalAddressScope\";\nexport { type ProvideContactInput } from \"@api/model/ProvideContact\";\nexport {\n type ExistingContactGroup,\n type RegisterExternalAddressInput,\n type RegisterExternalAddressMode,\n type RegisterExternalAddressOutput,\n} from \"@api/model/RegisterExternalAddress\";\nexport {\n type RenameContactInput,\n type RenameContactOutput,\n} from \"@api/model/RenameContact\";\nexport { type ContactsErrorCodes } from \"@internal/app-binder/model/contactsErrors\";\nexport {\n buildProvideContactPayload,\n sendProvideContactPayload,\n type SendProvideContactPayloadArgs,\n} from \"@internal/app-binder/services/provideContact\";\n"],
5
+ "mappings": "AAqCA,OAAS,0BAAAA,MAA8B,8BACvC,OACE,iCAAAC,EAKA,qBAAAC,EACA,oBAAAC,EACA,sCAAAC,MACK,yCAqBP,OACE,8BAAAC,EACA,6BAAAC,MAEK",
6
+ "names": ["ContactsManagerBuilder", "CONTACTS_VERSION_REQUIREMENTS", "ETHEREUM_APP_NAME", "isVersionAtLeast", "resolveContactsVersionRequirements", "buildProvideContactPayload", "sendProvideContactPayload"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{DeviceModelId as o}from"@ledgerhq/device-management-kit";import{coerce as c,gte as V,valid as s}from"semver";const i="Ethereum",d={supported:!1},m="1.5.0",E="1.2.0",M="0.9.0",u="1.15.0",N={[o.NANO_S]:d,[o.NANO_SP]:d,[o.NANO_X]:d,[o.STAX]:{supported:!0,minOsVersion:m,minAppVersion:{[i]:u}},[o.FLEX]:{supported:!0,minOsVersion:E,minAppVersion:{[i]:u}},[o.APEX]:{supported:!0,minOsVersion:M,minAppVersion:{[i]:u}}};function R(e){return N[e]}function l(e,t){const n=s(e)??s(c(e)),r=s(t)??s(c(t));return n===null||r===null?!1:V(n,r)}function A({deviceModelId:e,osVersion:t,appName:n,appVersion:r}){const p=R(e);if(!p.supported||!l(t,p.minOsVersion))return!1;const a=p.minAppVersion[n];return a===void 0?!1:l(r,a)}export{N as CONTACTS_VERSION_REQUIREMENTS,i as ETHEREUM_APP_NAME,A as isContactsSupported,l as isVersionAtLeast,R as resolveContactsVersionRequirements};
1
+ import{DeviceModelId as r}from"@ledgerhq/device-management-kit";import{coerce as a,gte as N,lt as E,valid as p}from"semver";const s="Ethereum",R={supported:!1},u="1.11.0",c="1.7.0",d="1.2.0",l="2.8.0",_="1.7.0",i="1.23.0",A=`${u}-rc3`,m=`${c}-rc3`,V=`${d}-rc3`,M=`${l}-rc3`,P=`${_}-rc3`,O={[r.NANO_S]:R,[r.NANO_SP]:{supported:!0,minOsVersion:_,minAppVersion:{[s]:i},renameDerivationPathRequiredBelowOsVersion:P},[r.NANO_X]:{supported:!0,minOsVersion:l,minAppVersion:{[s]:i},renameDerivationPathRequiredBelowOsVersion:M},[r.STAX]:{supported:!0,minOsVersion:u,minAppVersion:{[s]:i},renameDerivationPathRequiredBelowOsVersion:A},[r.FLEX]:{supported:!0,minOsVersion:c,minAppVersion:{[s]:i},renameDerivationPathRequiredBelowOsVersion:m},[r.APEX]:{supported:!0,minOsVersion:d,minAppVersion:{[s]:i},renameDerivationPathRequiredBelowOsVersion:V}};function C(o){return O[o]}function I(o,t){const e=p(a(o)),n=p(a(t));return e===null||n===null?!1:N(e,n)}function S(o,t){const e=p(o),n=p(t);return e===null||n===null?!1:E(e,n)}function q(o,t){const e=O[o];if(!e.supported)return!1;const n=e.renameDerivationPathRequiredBelowOsVersion;return n===void 0?!1:S(t,n)}export{O as CONTACTS_VERSION_REQUIREMENTS,s as ETHEREUM_APP_NAME,I as isVersionAtLeast,S as isVersionBelow,q as renameRequiresDerivationPath,C as resolveContactsVersionRequirements};
2
2
  //# sourceMappingURL=ContactsVersionRequirements.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/model/ContactsVersionRequirements.ts"],
4
- "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { coerce, gte, valid } from \"semver\";\n\n/**\n * Version requirements for a device model on which Contacts (Address Book)\n * operations are supported.\n *\n * Contacts has two independent version axes:\n * - `minOsVersion` gates OS-owned operations (e.g. renaming a contact from the\n * device dashboard), which are served by the device OS.\n * - `minAppVersion` gates app-owned operations (registering / editing external\n * addresses and Ledger accounts), which are served by the embedded app. It is\n * keyed by app name because the required version differs per app; v1 ships\n * Ethereum only.\n */\nexport type ContactsModelSupport = {\n readonly supported: true;\n readonly minOsVersion: string;\n readonly minAppVersion: Readonly<Record<string, string>>;\n};\n\n/** Marks a device model on which Contacts is not supported at all. */\nexport type ContactsModelUnsupported = {\n readonly supported: false;\n};\n\nexport type ContactsModelRequirement =\n | ContactsModelSupport\n | ContactsModelUnsupported;\n\n/**\n * The full, static Contacts version-requirement table, keyed by device model.\n * Serializable plain data with no runtime dependencies, so hosts (e.g. Ledger\n * Wallet) can import and consume it directly when composing their own\n * app-readiness checks, without duplicating the values.\n */\nexport type ContactsVersionRequirements = Readonly<\n Record<DeviceModelId, ContactsModelRequirement>\n>;\n\n/** The name of the Ethereum embedded app (the only app supported in v1). */\nexport const ETHEREUM_APP_NAME = \"Ethereum\";\n\nconst UNSUPPORTED: ContactsModelUnsupported = { supported: false };\n\n// TODO(DSDK-1376): replace these placeholder versions with the real minimums\n// confirmed by the firmware and Ethereum-app owners. The shape and consumers\n// are final; only the version strings below are provisional.\nconst MIN_OS_VERSION_STAX = \"1.5.0\";\nconst MIN_OS_VERSION_FLEX = \"1.2.0\";\nconst MIN_OS_VERSION_APEX = \"0.9.0\";\nconst MIN_ETHEREUM_APP_VERSION = \"1.15.0\";\n\n/**\n * Contacts APDUs are supported only on the touchscreen device models (Stax,\n * Flex, Apex). The Nano models do not support Contacts at all.\n */\nexport const CONTACTS_VERSION_REQUIREMENTS: ContactsVersionRequirements = {\n [DeviceModelId.NANO_S]: UNSUPPORTED,\n [DeviceModelId.NANO_SP]: UNSUPPORTED,\n [DeviceModelId.NANO_X]: UNSUPPORTED,\n [DeviceModelId.STAX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_STAX,\n minAppVersion: { [ETHEREUM_APP_NAME]: MIN_ETHEREUM_APP_VERSION },\n },\n [DeviceModelId.FLEX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_FLEX,\n minAppVersion: { [ETHEREUM_APP_NAME]: MIN_ETHEREUM_APP_VERSION },\n },\n [DeviceModelId.APEX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_APEX,\n minAppVersion: { [ETHEREUM_APP_NAME]: MIN_ETHEREUM_APP_VERSION },\n },\n};\n\n/**\n * Resolve the Contacts version requirements for a device model \u2014 i.e. the\n * minimum supported OS and app versions, or that the model is unsupported.\n */\nexport function resolveContactsVersionRequirements(\n deviceModelId: DeviceModelId,\n): ContactsModelRequirement {\n return CONTACTS_VERSION_REQUIREMENTS[deviceModelId];\n}\n\n/**\n * Whether `actual` is greater than or equal to `minimum`, comparing as semver.\n * Tolerant of non-strict version strings (coerces where possible) and returns\n * `false` (i.e. requirement not met) when either version cannot be parsed, so\n * an unknown version never passes a check.\n */\nexport function isVersionAtLeast(actual: string, minimum: string): boolean {\n const a = valid(actual) ?? valid(coerce(actual));\n const b = valid(minimum) ?? valid(coerce(minimum));\n if (a === null || b === null) return false;\n return gte(a, b);\n}\n\n/** Inputs for {@link isContactsSupported}. */\nexport type ContactsSupportQuery = {\n readonly deviceModelId: DeviceModelId;\n /** The device OS (firmware) version. */\n readonly osVersion: string;\n /** The name of the currently running embedded app. */\n readonly appName: string;\n /** The version of the currently running embedded app. */\n readonly appVersion: string;\n};\n\n/**\n * Whether Contacts app-owned operations are supported for the given device\n * model, OS version, and running app \u2014 checking the model is supported, the OS\n * meets its minimum, the app is known to Contacts, and the app meets its\n * minimum.\n *\n * Pure and dependency-light: hosts can call this directly, or read\n * {@link CONTACTS_VERSION_REQUIREMENTS} to build their own checks.\n */\nexport function isContactsSupported({\n deviceModelId,\n osVersion,\n appName,\n appVersion,\n}: ContactsSupportQuery): boolean {\n const requirement = resolveContactsVersionRequirements(deviceModelId);\n if (!requirement.supported) return false;\n if (!isVersionAtLeast(osVersion, requirement.minOsVersion)) return false;\n\n const minAppVersion = requirement.minAppVersion[appName];\n if (minAppVersion === undefined) return false;\n return isVersionAtLeast(appVersion, minAppVersion);\n}\n"],
5
- "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,UAAAC,EAAQ,OAAAC,EAAK,SAAAC,MAAa,SAwC5B,MAAMC,EAAoB,WAE3BC,EAAwC,CAAE,UAAW,EAAM,EAK3DC,EAAsB,QACtBC,EAAsB,QACtBC,EAAsB,QACtBC,EAA2B,SAMpBC,EAA6D,CACxE,CAACV,EAAc,MAAM,EAAGK,EACxB,CAACL,EAAc,OAAO,EAAGK,EACzB,CAACL,EAAc,MAAM,EAAGK,EACxB,CAACL,EAAc,IAAI,EAAG,CACpB,UAAW,GACX,aAAcM,EACd,cAAe,CAAE,CAACF,CAAiB,EAAGK,CAAyB,CACjE,EACA,CAACT,EAAc,IAAI,EAAG,CACpB,UAAW,GACX,aAAcO,EACd,cAAe,CAAE,CAACH,CAAiB,EAAGK,CAAyB,CACjE,EACA,CAACT,EAAc,IAAI,EAAG,CACpB,UAAW,GACX,aAAcQ,EACd,cAAe,CAAE,CAACJ,CAAiB,EAAGK,CAAyB,CACjE,CACF,EAMO,SAASE,EACdC,EAC0B,CAC1B,OAAOF,EAA8BE,CAAa,CACpD,CAQO,SAASC,EAAiBC,EAAgBC,EAA0B,CACzE,MAAMC,EAAIb,EAAMW,CAAM,GAAKX,EAAMF,EAAOa,CAAM,CAAC,EACzCG,EAAId,EAAMY,CAAO,GAAKZ,EAAMF,EAAOc,CAAO,CAAC,EACjD,OAAIC,IAAM,MAAQC,IAAM,KAAa,GAC9Bf,EAAIc,EAAGC,CAAC,CACjB,CAsBO,SAASC,EAAoB,CAClC,cAAAN,EACA,UAAAO,EACA,QAAAC,EACA,WAAAC,CACF,EAAkC,CAChC,MAAMC,EAAcX,EAAmCC,CAAa,EAEpE,GADI,CAACU,EAAY,WACb,CAACT,EAAiBM,EAAWG,EAAY,YAAY,EAAG,MAAO,GAEnE,MAAMC,EAAgBD,EAAY,cAAcF,CAAO,EACvD,OAAIG,IAAkB,OAAkB,GACjCV,EAAiBQ,EAAYE,CAAa,CACnD",
6
- "names": ["DeviceModelId", "coerce", "gte", "valid", "ETHEREUM_APP_NAME", "UNSUPPORTED", "MIN_OS_VERSION_STAX", "MIN_OS_VERSION_FLEX", "MIN_OS_VERSION_APEX", "MIN_ETHEREUM_APP_VERSION", "CONTACTS_VERSION_REQUIREMENTS", "resolveContactsVersionRequirements", "deviceModelId", "isVersionAtLeast", "actual", "minimum", "a", "b", "isContactsSupported", "osVersion", "appName", "appVersion", "requirement", "minAppVersion"]
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { coerce, gte, lt, valid } from \"semver\";\n\n/**\n * Version requirements for a device model on which Contacts (Address Book)\n * operations are supported.\n *\n * Contacts has two independent version axes:\n * - `minOsVersion` gates OS-owned operations (e.g. renaming a contact from the\n * device dashboard), which are served by the device OS.\n * - `minAppVersion` gates app-owned operations (registering / editing external\n * addresses and Ledger accounts), which are served by the embedded app. It is\n * keyed by app name because the required version differs per app; v1 ships\n * Ethereum only.\n */\nexport type ContactsModelSupport = {\n readonly supported: true;\n readonly minOsVersion: string;\n readonly minAppVersion: Readonly<Record<string, string>>;\n /**\n * TEMPORARY (DSDK-1481) \u2014 the first OS build for this model that no longer\n * wants the `DERIVATION_PATH` (tag 0x69) on EDIT CONTACT NAME. Rename is\n * served by the OS, and OS builds *below* this version still require the path\n * (omitting it yields 0x686A), while this build and later reject it\n * (0x6A80). So the path is sent only when the device OS is below this\n * cutoff. Absent means the model never wanted the path (send nothing \u2014 the\n * GA end-state). Delete this field, its constants, and\n * {@link renameRequiresDerivationPath} once no in-the-field OS predates the\n * cutoff.\n */\n readonly renameDerivationPathRequiredBelowOsVersion?: string;\n};\n\n/** Marks a device model on which Contacts is not supported at all. */\nexport type ContactsModelUnsupported = {\n readonly supported: false;\n};\n\nexport type ContactsModelRequirement =\n | ContactsModelSupport\n | ContactsModelUnsupported;\n\n/**\n * The full, static Contacts version-requirement table, keyed by device model.\n * Serializable plain data with no runtime dependencies, so hosts (e.g. Ledger\n * Wallet) can import and consume it directly when composing their own\n * app-readiness checks, without duplicating the values.\n */\nexport type ContactsVersionRequirements = Readonly<\n Record<DeviceModelId, ContactsModelRequirement>\n>;\n\n/** The name of the Ethereum embedded app (the only app supported in v1). */\nexport const ETHEREUM_APP_NAME = \"Ethereum\";\n\nconst UNSUPPORTED: ContactsModelUnsupported = { supported: false };\n\nconst MIN_OS_VERSION_STAX = \"1.11.0\";\nconst MIN_OS_VERSION_FLEX = \"1.7.0\";\nconst MIN_OS_VERSION_APEX = \"1.2.0\";\nconst MIN_OS_VERSION_NANO_X = \"2.8.0\";\nconst MIN_OS_VERSION_NANO_SP = \"1.7.0\";\n\nconst MIN_ETHEREUM_APP_VERSION = \"1.23.0\";\n\n// TEMPORARY (DSDK-1481) \u2014 per-model cutoff below which the OS still requires the\n// EDIT CONTACT NAME derivation path. Each model's Address-Book-introducing OS\n// release shipped an rc2 that mandates the path (0x686A without it) and an rc3\n// that drops it (0x6A80 with it), so the cutoff is that release's `-rc3`. Only\n// Flex is hardware-confirmed (rc2 on a real device); the others follow the same\n// rc2/rc3 split per firmware \u2014 revise here if firmware says a model differs.\nconst RENAME_PATH_CUTOFF_STAX = `${MIN_OS_VERSION_STAX}-rc3`;\nconst RENAME_PATH_CUTOFF_FLEX = `${MIN_OS_VERSION_FLEX}-rc3`;\nconst RENAME_PATH_CUTOFF_APEX = `${MIN_OS_VERSION_APEX}-rc3`;\nconst RENAME_PATH_CUTOFF_NANO_X = `${MIN_OS_VERSION_NANO_X}-rc3`;\nconst RENAME_PATH_CUTOFF_NANO_SP = `${MIN_OS_VERSION_NANO_SP}-rc3`;\n\n/**\n * Contacts APDUs are supported on the touchscreen device models (Stax, Flex,\n * Apex) and on Nano X / Nano SP. Nano S does not support Contacts at all.\n */\nexport const CONTACTS_VERSION_REQUIREMENTS: ContactsVersionRequirements = {\n [DeviceModelId.NANO_S]: UNSUPPORTED,\n [DeviceModelId.NANO_SP]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_NANO_SP,\n minAppVersion: { [ETHEREUM_APP_NAME]: MIN_ETHEREUM_APP_VERSION },\n renameDerivationPathRequiredBelowOsVersion: RENAME_PATH_CUTOFF_NANO_SP,\n },\n [DeviceModelId.NANO_X]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_NANO_X,\n minAppVersion: { [ETHEREUM_APP_NAME]: MIN_ETHEREUM_APP_VERSION },\n renameDerivationPathRequiredBelowOsVersion: RENAME_PATH_CUTOFF_NANO_X,\n },\n [DeviceModelId.STAX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_STAX,\n minAppVersion: { [ETHEREUM_APP_NAME]: MIN_ETHEREUM_APP_VERSION },\n renameDerivationPathRequiredBelowOsVersion: RENAME_PATH_CUTOFF_STAX,\n },\n [DeviceModelId.FLEX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_FLEX,\n minAppVersion: { [ETHEREUM_APP_NAME]: MIN_ETHEREUM_APP_VERSION },\n renameDerivationPathRequiredBelowOsVersion: RENAME_PATH_CUTOFF_FLEX,\n },\n [DeviceModelId.APEX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_APEX,\n minAppVersion: { [ETHEREUM_APP_NAME]: MIN_ETHEREUM_APP_VERSION },\n renameDerivationPathRequiredBelowOsVersion: RENAME_PATH_CUTOFF_APEX,\n },\n};\n\n/**\n * Resolve the Contacts version requirements for a device model \u2014 i.e. the\n * minimum supported OS and app versions, or that the model is unsupported.\n */\nexport function resolveContactsVersionRequirements(\n deviceModelId: DeviceModelId,\n): ContactsModelRequirement {\n return CONTACTS_VERSION_REQUIREMENTS[deviceModelId];\n}\n\n/**\n * Whether `actual` is greater than or equal to `minimum`, comparing as semver.\n * Tolerant of non-strict version strings and prerelease/build tags (coerces\n * both sides, which drops them) so a release candidate such as `1.7.0-rc2`\n * counts as meeting a `1.7.0` minimum. Returns `false` (i.e. requirement not\n * met) when either version cannot be parsed, so an unknown version never\n * passes a check.\n */\nexport function isVersionAtLeast(actual: string, minimum: string): boolean {\n const a = valid(coerce(actual));\n const b = valid(coerce(minimum));\n if (a === null || b === null) return false;\n return gte(a, b);\n}\n\n/**\n * Whether `actual` is strictly less than `boundary`, comparing as semver with\n * prerelease precedence preserved \u2014 unlike {@link isVersionAtLeast}, neither\n * side is coerced, so `1.7.0-rc2` sorts *below* `1.7.0-rc3` (and both below the\n * `1.7.0` release). Used to tell release candidates apart for the DSDK-1481\n * derivation-path cutoff, which `isVersionAtLeast` cannot do (it drops the\n * `-rcN` tag). Requires strict semver on both sides; returns `false` when\n * either cannot be parsed, so an unknown version is treated as *not* below the\n * boundary (i.e. the newer/GA payload shape).\n */\nexport function isVersionBelow(actual: string, boundary: string): boolean {\n const a = valid(actual);\n const b = valid(boundary);\n if (a === null || b === null) return false;\n return lt(a, b);\n}\n\n/**\n * TEMPORARY (DSDK-1481) \u2014 whether the EDIT CONTACT NAME (rename) payload must\n * carry the `DERIVATION_PATH` (tag 0x69) for a device on `osVersion`. True only\n * when the model is supported, declares a\n * {@link ContactsModelSupport.renameDerivationPathRequiredBelowOsVersion}\n * cutoff, and the fresh device OS version is strictly below that cutoff\n * (prerelease-aware). Callers pass the OS version read freshly from the device\n * (not the session state, which may be stale/absent on the dashboard path).\n */\nexport function renameRequiresDerivationPath(\n deviceModelId: DeviceModelId,\n osVersion: string,\n): boolean {\n const requirement = CONTACTS_VERSION_REQUIREMENTS[deviceModelId];\n if (!requirement.supported) return false;\n const cutoff = requirement.renameDerivationPathRequiredBelowOsVersion;\n if (cutoff === undefined) return false;\n return isVersionBelow(osVersion, cutoff);\n}\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,UAAAC,EAAQ,OAAAC,EAAK,MAAAC,EAAI,SAAAC,MAAa,SAoDhC,MAAMC,EAAoB,WAE3BC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ACxE,MAAMH,EAAIpB,EAAMkB,CAAM,EAChBG,EAAIrB,EAAMuB,CAAQ,EACxB,OAAIH,IAAM,MAAQC,IAAM,KAAa,GAC9BtB,EAAGqB,EAAGC,CAAC,CAChB,CAWO,SAASG,EACdR,EACAS,EACS,CACT,MAAMC,EAAcZ,EAA8BE,CAAa,EAC/D,GAAI,CAACU,EAAY,UAAW,MAAO,GACnC,MAAMC,EAASD,EAAY,2CAC3B,OAAIC,IAAW,OAAkB,GAC1BL,EAAeG,EAAWE,CAAM,CACzC",
6
+ "names": ["DeviceModelId", "coerce", "gte", "lt", "valid", "ETHEREUM_APP_NAME", "UNSUPPORTED", "MIN_OS_VERSION_STAX", "MIN_OS_VERSION_FLEX", "MIN_OS_VERSION_APEX", "MIN_OS_VERSION_NANO_X", "MIN_OS_VERSION_NANO_SP", "MIN_ETHEREUM_APP_VERSION", "RENAME_PATH_CUTOFF_STAX", "RENAME_PATH_CUTOFF_FLEX", "RENAME_PATH_CUTOFF_APEX", "RENAME_PATH_CUTOFF_NANO_X", "RENAME_PATH_CUTOFF_NANO_SP", "CONTACTS_VERSION_REQUIREMENTS", "resolveContactsVersionRequirements", "deviceModelId", "isVersionAtLeast", "actual", "minimum", "a", "b", "isVersionBelow", "boundary", "renameRequiresDerivationPath", "osVersion", "requirement", "cutoff"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{DeviceModelId as t}from"@ledgerhq/device-management-kit";import{CONTACTS_VERSION_REQUIREMENTS as l,ETHEREUM_APP_NAME as p,isContactsSupported as s,isVersionAtLeast as n,resolveContactsVersionRequirements as u}from"./ContactsVersionRequirements";const d="0.0.1",c="999.0.0";function r(e){const o=u(e);if(!o.supported)throw new Error(`expected ${e} to be supported in the test fixture`);return o}function i(e){const o=e.minAppVersion[p];if(o===void 0)throw new Error("expected an Ethereum minimum app version in the fixture");return o}describe("ContactsVersionRequirements",()=>{describe("resolveContactsVersionRequirements",()=>{it("marks every device model, supported or not",()=>{for(const e of Object.values(t))expect(l[e]).toBeDefined()}),it("reports Nano models as unsupported",()=>{expect(u(t.NANO_S)).toEqual({supported:!1}),expect(u(t.NANO_X)).toEqual({supported:!1})}),it("reports touchscreen models as supported with OS and app minimums",()=>{const e=r(t.FLEX);expect(e.minOsVersion).toEqual(expect.any(String)),expect(i(e)).toEqual(expect.any(String))})}),describe("isContactsSupported",()=>{it("returns false for an unsupported device model",()=>{const e=r(t.FLEX);expect(s({deviceModelId:t.NANO_S,osVersion:c,appName:p,appVersion:i(e)})).toBe(!1)}),it("gates on the minimum app version",()=>{const e=r(t.FLEX),o=i(e),a={deviceModelId:t.FLEX,osVersion:e.minOsVersion,appName:p};expect(s({...a,appVersion:d})).toBe(!1),expect(s({...a,appVersion:o})).toBe(!0),expect(s({...a,appVersion:c})).toBe(!0)}),it("returns false for an app that is unknown to Contacts",()=>{const e=r(t.FLEX);expect(s({deviceModelId:t.FLEX,osVersion:e.minOsVersion,appName:"Bitcoin",appVersion:c})).toBe(!1)}),it("gates on the minimum OS version",()=>{const e=r(t.FLEX),o={deviceModelId:t.FLEX,appName:p,appVersion:i(e)};expect(s({...o,osVersion:d})).toBe(!1),expect(s({...o,osVersion:e.minOsVersion})).toBe(!0)})}),describe("isVersionAtLeast",()=>{it("compares versions as semver, inclusive of equality",()=>{expect(n("1.2.0","1.2.0")).toBe(!0),expect(n("1.3.0","1.2.0")).toBe(!0),expect(n("1.1.9","1.2.0")).toBe(!1)}),it("coerces non-strict version strings",()=>{expect(n("1.2","1.2.0")).toBe(!0)}),it("returns false when a version cannot be parsed",()=>{expect(n("not-a-version","1.2.0")).toBe(!1),expect(n("1.2.0","not-a-version")).toBe(!1)})})});
1
+ import{DeviceModelId as e}from"@ledgerhq/device-management-kit";import{CONTACTS_VERSION_REQUIREMENTS as i,ETHEREUM_APP_NAME as n,isVersionAtLeast as t,isVersionBelow as r,renameRequiresDerivationPath as s,resolveContactsVersionRequirements as a}from"./ContactsVersionRequirements";describe("ContactsVersionRequirements",()=>{describe("resolveContactsVersionRequirements",()=>{it("marks every device model, supported or not",()=>{for(const o of Object.values(e))expect(i[o]).toBeDefined()}),it("reports Nano S as unsupported",()=>{expect(a(e.NANO_S)).toEqual({supported:!1})}),it("pins the minimum OS and app versions of every supported model",()=>{const o={[n]:"1.23.0"};expect(i).toEqual({[e.NANO_S]:{supported:!1},[e.NANO_SP]:{supported:!0,minOsVersion:"1.7.0",minAppVersion:o,renameDerivationPathRequiredBelowOsVersion:"1.7.0-rc3"},[e.NANO_X]:{supported:!0,minOsVersion:"2.8.0",minAppVersion:o,renameDerivationPathRequiredBelowOsVersion:"2.8.0-rc3"},[e.STAX]:{supported:!0,minOsVersion:"1.11.0",minAppVersion:o,renameDerivationPathRequiredBelowOsVersion:"1.11.0-rc3"},[e.FLEX]:{supported:!0,minOsVersion:"1.7.0",minAppVersion:o,renameDerivationPathRequiredBelowOsVersion:"1.7.0-rc3"},[e.APEX]:{supported:!0,minOsVersion:"1.2.0",minAppVersion:o,renameDerivationPathRequiredBelowOsVersion:"1.2.0-rc3"}})})}),describe("isVersionAtLeast",()=>{it("compares versions as semver, inclusive of equality",()=>{expect(t("1.2.0","1.2.0")).toBe(!0),expect(t("1.3.0","1.2.0")).toBe(!0),expect(t("1.1.9","1.2.0")).toBe(!1)}),it("coerces non-strict version strings",()=>{expect(t("1.2","1.2.0")).toBe(!0)}),it("returns false when a version cannot be parsed",()=>{expect(t("not-a-version","1.2.0")).toBe(!1),expect(t("1.2.0","not-a-version")).toBe(!1)}),it("ignores prerelease and build tags when comparing to the minimum",()=>{expect(t("1.7.0-rc2","1.7.0")).toBe(!0),expect(t("1.23.0-dev","1.23.0")).toBe(!0)}),it("still fails a minimum strictly above the tagged version's core",()=>{expect(t("1.6.9-rc5","1.7.0")).toBe(!1)})}),describe("isVersionBelow",()=>{it("orders release candidates of the same core (unlike isVersionAtLeast)",()=>{expect(r("1.7.0-rc2","1.7.0-rc3")).toBe(!0),expect(r("1.7.0-rc3","1.7.0-rc3")).toBe(!1),expect(r("1.7.0-rc4","1.7.0-rc3")).toBe(!1)}),it("treats the final release as newer than any of its prereleases",()=>{expect(r("1.7.0","1.7.0-rc3")).toBe(!1)}),it("compares the release core when it differs",()=>{expect(r("1.6.9","1.7.0-rc3")).toBe(!0),expect(r("1.8.0","1.7.0-rc3")).toBe(!1)}),it("does not coerce, so a non-strict version is unparseable and returns false",()=>{expect(r("1.7","1.7.0-rc3")).toBe(!1),expect(r("not-a-version","1.7.0-rc3")).toBe(!1),expect(r("1.7.0-rc2","not-a-version")).toBe(!1)})}),describe("renameRequiresDerivationPath",()=>{it("requires the path below the model's cutoff (rc2) and not at/after it",()=>{expect(s(e.FLEX,"1.7.0-rc2")).toBe(!0),expect(s(e.FLEX,"1.7.0-rc3")).toBe(!1),expect(s(e.FLEX,"1.7.0")).toBe(!1),expect(s(e.FLEX,"1.8.0")).toBe(!1)}),it("applies the same rc2/rc3 split to the other supported models",()=>{expect(s(e.STAX,"1.11.0-rc2")).toBe(!0),expect(s(e.STAX,"1.11.0-rc3")).toBe(!1),expect(s(e.NANO_SP,"1.7.0-rc2")).toBe(!0)}),it("returns false for an unsupported model",()=>{expect(s(e.NANO_S,"1.7.0-rc2")).toBe(!1)}),it("returns false (no path) when the OS version is unparseable",()=>{expect(s(e.FLEX,"")).toBe(!1)})})});
2
2
  //# sourceMappingURL=ContactsVersionRequirements.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/model/ContactsVersionRequirements.test.ts"],
4
- "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\n\nimport {\n CONTACTS_VERSION_REQUIREMENTS,\n type ContactsModelSupport,\n ETHEREUM_APP_NAME,\n isContactsSupported,\n isVersionAtLeast,\n resolveContactsVersionRequirements,\n} from \"./ContactsVersionRequirements\";\n\nconst BELOW_ANY_VERSION = \"0.0.1\";\nconst ABOVE_ANY_VERSION = \"999.0.0\";\n\nfunction supportOf(modelId: DeviceModelId): ContactsModelSupport {\n const requirement = resolveContactsVersionRequirements(modelId);\n if (!requirement.supported) {\n throw new Error(`expected ${modelId} to be supported in the test fixture`);\n }\n return requirement;\n}\n\nfunction ethAppVersionOf(support: ContactsModelSupport): string {\n const version = support.minAppVersion[ETHEREUM_APP_NAME];\n if (version === undefined) {\n throw new Error(\"expected an Ethereum minimum app version in the fixture\");\n }\n return version;\n}\n\ndescribe(\"ContactsVersionRequirements\", () => {\n describe(\"resolveContactsVersionRequirements\", () => {\n it(\"marks every device model, supported or not\", () => {\n for (const modelId of Object.values(DeviceModelId)) {\n expect(CONTACTS_VERSION_REQUIREMENTS[modelId]).toBeDefined();\n }\n });\n\n it(\"reports Nano models as unsupported\", () => {\n expect(resolveContactsVersionRequirements(DeviceModelId.NANO_S)).toEqual({\n supported: false,\n });\n expect(resolveContactsVersionRequirements(DeviceModelId.NANO_X)).toEqual({\n supported: false,\n });\n });\n\n it(\"reports touchscreen models as supported with OS and app minimums\", () => {\n const flex = supportOf(DeviceModelId.FLEX);\n expect(flex.minOsVersion).toEqual(expect.any(String));\n expect(ethAppVersionOf(flex)).toEqual(expect.any(String));\n });\n });\n\n describe(\"isContactsSupported\", () => {\n it(\"returns false for an unsupported device model\", () => {\n const flex = supportOf(DeviceModelId.FLEX);\n expect(\n isContactsSupported({\n deviceModelId: DeviceModelId.NANO_S,\n osVersion: ABOVE_ANY_VERSION,\n appName: ETHEREUM_APP_NAME,\n appVersion: ethAppVersionOf(flex),\n }),\n ).toBe(false);\n });\n\n // App-version requirement.\n it(\"gates on the minimum app version\", () => {\n const flex = supportOf(DeviceModelId.FLEX);\n const minAppVersion = ethAppVersionOf(flex);\n const base = {\n deviceModelId: DeviceModelId.FLEX,\n osVersion: flex.minOsVersion,\n appName: ETHEREUM_APP_NAME,\n };\n\n expect(\n isContactsSupported({ ...base, appVersion: BELOW_ANY_VERSION }),\n ).toBe(false);\n expect(isContactsSupported({ ...base, appVersion: minAppVersion })).toBe(\n true,\n );\n expect(\n isContactsSupported({ ...base, appVersion: ABOVE_ANY_VERSION }),\n ).toBe(true);\n });\n\n it(\"returns false for an app that is unknown to Contacts\", () => {\n const flex = supportOf(DeviceModelId.FLEX);\n expect(\n isContactsSupported({\n deviceModelId: DeviceModelId.FLEX,\n osVersion: flex.minOsVersion,\n appName: \"Bitcoin\",\n appVersion: ABOVE_ANY_VERSION,\n }),\n ).toBe(false);\n });\n\n // OS-version requirement.\n it(\"gates on the minimum OS version\", () => {\n const flex = supportOf(DeviceModelId.FLEX);\n const base = {\n deviceModelId: DeviceModelId.FLEX,\n appName: ETHEREUM_APP_NAME,\n appVersion: ethAppVersionOf(flex),\n };\n\n expect(\n isContactsSupported({ ...base, osVersion: BELOW_ANY_VERSION }),\n ).toBe(false);\n expect(\n isContactsSupported({ ...base, osVersion: flex.minOsVersion }),\n ).toBe(true);\n });\n });\n\n describe(\"isVersionAtLeast\", () => {\n it(\"compares versions as semver, inclusive of equality\", () => {\n expect(isVersionAtLeast(\"1.2.0\", \"1.2.0\")).toBe(true);\n expect(isVersionAtLeast(\"1.3.0\", \"1.2.0\")).toBe(true);\n expect(isVersionAtLeast(\"1.1.9\", \"1.2.0\")).toBe(false);\n });\n\n it(\"coerces non-strict version strings\", () => {\n expect(isVersionAtLeast(\"1.2\", \"1.2.0\")).toBe(true);\n });\n\n it(\"returns false when a version cannot be parsed\", () => {\n expect(isVersionAtLeast(\"not-a-version\", \"1.2.0\")).toBe(false);\n expect(isVersionAtLeast(\"1.2.0\", \"not-a-version\")).toBe(false);\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAE9B,OACE,iCAAAC,EAEA,qBAAAC,EACA,uBAAAC,EACA,oBAAAC,EACA,sCAAAC,MACK,gCAEP,MAAMC,EAAoB,QACpBC,EAAoB,UAE1B,SAASC,EAAUC,EAA8C,CAC/D,MAAMC,EAAcL,EAAmCI,CAAO,EAC9D,GAAI,CAACC,EAAY,UACf,MAAM,IAAI,MAAM,YAAYD,CAAO,sCAA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elId", "CONTACTS_VERSION_REQUIREMENTS", "ETHEREUM_APP_NAME", "isContactsSupported", "isVersionAtLeast", "resolveContactsVersionRequirements", "BELOW_ANY_VERSION", "ABOVE_ANY_VERSION", "supportOf", "modelId", "requirement", "ethAppVersionOf", "support", "version", "flex", "minAppVersion", "base"]
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\n\nimport {\n CONTACTS_VERSION_REQUIREMENTS,\n ETHEREUM_APP_NAME,\n isVersionAtLeast,\n isVersionBelow,\n renameRequiresDerivationPath,\n resolveContactsVersionRequirements,\n} from \"./ContactsVersionRequirements\";\n\ndescribe(\"ContactsVersionRequirements\", () => {\n describe(\"resolveContactsVersionRequirements\", () => {\n it(\"marks every device model, supported or not\", () => {\n for (const modelId of Object.values(DeviceModelId)) {\n expect(CONTACTS_VERSION_REQUIREMENTS[modelId]).toBeDefined();\n }\n });\n\n it(\"reports Nano S as unsupported\", () => {\n expect(resolveContactsVersionRequirements(DeviceModelId.NANO_S)).toEqual({\n supported: false,\n });\n });\n\n // Pins the minimums themselves, not just their shape: each OS version is\n // the release whose changelog introduces the Address Book feature, so a\n // change here has to be a deliberate one, reviewed against that release.\n it(\"pins the minimum OS and app versions of every supported model\", () => {\n const ethereum = { [ETHEREUM_APP_NAME]: \"1.23.0\" };\n\n expect(CONTACTS_VERSION_REQUIREMENTS).toEqual({\n [DeviceModelId.NANO_S]: { supported: false },\n [DeviceModelId.NANO_SP]: {\n supported: true,\n minOsVersion: \"1.7.0\",\n minAppVersion: ethereum,\n renameDerivationPathRequiredBelowOsVersion: \"1.7.0-rc3\",\n },\n [DeviceModelId.NANO_X]: {\n supported: true,\n minOsVersion: \"2.8.0\",\n minAppVersion: ethereum,\n renameDerivationPathRequiredBelowOsVersion: \"2.8.0-rc3\",\n },\n [DeviceModelId.STAX]: {\n supported: true,\n minOsVersion: \"1.11.0\",\n minAppVersion: ethereum,\n renameDerivationPathRequiredBelowOsVersion: \"1.11.0-rc3\",\n },\n [DeviceModelId.FLEX]: {\n supported: true,\n minOsVersion: \"1.7.0\",\n minAppVersion: ethereum,\n renameDerivationPathRequiredBelowOsVersion: \"1.7.0-rc3\",\n },\n [DeviceModelId.APEX]: {\n supported: true,\n minOsVersion: \"1.2.0\",\n minAppVersion: ethereum,\n renameDerivationPathRequiredBelowOsVersion: \"1.2.0-rc3\",\n },\n });\n });\n });\n\n describe(\"isVersionAtLeast\", () => {\n it(\"compares versions as semver, inclusive of equality\", () => {\n expect(isVersionAtLeast(\"1.2.0\", \"1.2.0\")).toBe(true);\n expect(isVersionAtLeast(\"1.3.0\", \"1.2.0\")).toBe(true);\n expect(isVersionAtLeast(\"1.1.9\", \"1.2.0\")).toBe(false);\n });\n\n it(\"coerces non-strict version strings\", () => {\n expect(isVersionAtLeast(\"1.2\", \"1.2.0\")).toBe(true);\n });\n\n it(\"returns false when a version cannot be parsed\", () => {\n expect(isVersionAtLeast(\"not-a-version\", \"1.2.0\")).toBe(false);\n expect(isVersionAtLeast(\"1.2.0\", \"not-a-version\")).toBe(false);\n });\n\n it(\"ignores prerelease and build tags when comparing to the minimum\", () => {\n expect(isVersionAtLeast(\"1.7.0-rc2\", \"1.7.0\")).toBe(true);\n expect(isVersionAtLeast(\"1.23.0-dev\", \"1.23.0\")).toBe(true);\n });\n\n it(\"still fails a minimum strictly above the tagged version's core\", () => {\n expect(isVersionAtLeast(\"1.6.9-rc5\", \"1.7.0\")).toBe(false);\n });\n });\n\n describe(\"isVersionBelow\", () => {\n it(\"orders release candidates of the same core (unlike isVersionAtLeast)\", () => {\n // The whole reason this helper exists: rc2 must sort below rc3.\n expect(isVersionBelow(\"1.7.0-rc2\", \"1.7.0-rc3\")).toBe(true);\n expect(isVersionBelow(\"1.7.0-rc3\", \"1.7.0-rc3\")).toBe(false);\n expect(isVersionBelow(\"1.7.0-rc4\", \"1.7.0-rc3\")).toBe(false);\n });\n\n it(\"treats the final release as newer than any of its prereleases\", () => {\n expect(isVersionBelow(\"1.7.0\", \"1.7.0-rc3\")).toBe(false);\n });\n\n it(\"compares the release core when it differs\", () => {\n expect(isVersionBelow(\"1.6.9\", \"1.7.0-rc3\")).toBe(true);\n expect(isVersionBelow(\"1.8.0\", \"1.7.0-rc3\")).toBe(false);\n });\n\n it(\"does not coerce, so a non-strict version is unparseable and returns false\", () => {\n expect(isVersionBelow(\"1.7\", \"1.7.0-rc3\")).toBe(false);\n expect(isVersionBelow(\"not-a-version\", \"1.7.0-rc3\")).toBe(false);\n expect(isVersionBelow(\"1.7.0-rc2\", \"not-a-version\")).toBe(false);\n });\n });\n\n describe(\"renameRequiresDerivationPath\", () => {\n it(\"requires the path below the model's cutoff (rc2) and not at/after it\", () => {\n expect(\n renameRequiresDerivationPath(DeviceModelId.FLEX, \"1.7.0-rc2\"),\n ).toBe(true);\n expect(\n renameRequiresDerivationPath(DeviceModelId.FLEX, \"1.7.0-rc3\"),\n ).toBe(false);\n // GA and later never want the path.\n expect(renameRequiresDerivationPath(DeviceModelId.FLEX, \"1.7.0\")).toBe(\n false,\n );\n expect(renameRequiresDerivationPath(DeviceModelId.FLEX, \"1.8.0\")).toBe(\n false,\n );\n });\n\n it(\"applies the same rc2/rc3 split to the other supported models\", () => {\n expect(\n renameRequiresDerivationPath(DeviceModelId.STAX, \"1.11.0-rc2\"),\n ).toBe(true);\n expect(\n renameRequiresDerivationPath(DeviceModelId.STAX, \"1.11.0-rc3\"),\n ).toBe(false);\n expect(\n renameRequiresDerivationPath(DeviceModelId.NANO_SP, \"1.7.0-rc2\"),\n ).toBe(true);\n });\n\n it(\"returns false for an unsupported model\", () => {\n expect(\n renameRequiresDerivationPath(DeviceModelId.NANO_S, \"1.7.0-rc2\"),\n ).toBe(false);\n });\n\n it(\"returns false (no path) when the OS version is unparseable\", () => {\n expect(renameRequiresDerivationPath(DeviceModelId.FLEX, \"\")).toBe(false);\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAE9B,OACE,iCAAAC,EACA,qBA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,IAAM,CAC/E,OACEC,EAA6BL,EAAc,KAAM,WAAW,CAC9D,EAAE,KAAK,EAAI,EACX,OACEK,EAA6BL,EAAc,KAAM,WAAW,CAC9D,EAAE,KAAK,EAAK,EAEZ,OAAOK,EAA6BL,EAAc,KAAM,OAAO,CAAC,EAAE,KAChE,EACF,EACA,OAAOK,EAA6BL,EAAc,KAAM,OAAO,CAAC,EAAE,KAChE,EACF,CACF,CAAC,EAED,GAAG,+DAAgE,IAAM,CACvE,OACEK,EAA6BL,EAAc,KAAM,YAAY,CAC/D,EAAE,KAAK,EAAI,EACX,OACEK,EAA6BL,EAAc,KAAM,YAAY,CAC/D,EAAE,KAAK,EAAK,EACZ,OACEK,EAA6BL,EAAc,QAAS,WAAW,CACjE,EAAE,KAAK,EAAI,CACb,CAAC,EAED,GAAG,yCAA0C,IAAM,CACjD,OACEK,EAA6BL,EAAc,OAAQ,WAAW,CAChE,EAAE,KAAK,EAAK,CACd,CAAC,EAED,GAAG,6DAA8D,IAAM,CACrE,OAAOK,EAA6BL,EAAc,KAAM,EAAE,CAAC,EAAE,KAAK,EAAK,CACzE,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["DeviceModelId", "CONTACTS_VERSION_REQUIREMENTS", "ETHEREUM_APP_NAME", "isVersionAtLeast", "isVersionBelow", "renameRequiresDerivationPath", "resolveContactsVersionRequirements", "modelId", "ethereum"]
7
7
  }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=ProvideContact.js.map