@ledgerhq/device-contacts-kit 0.0.0-develop-20261008001410 → 0.0.0-develop-20261010001520
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -2
- package/lib/cjs/api/index.js +1 -1
- package/lib/cjs/api/index.js.map +2 -2
- package/lib/cjs/api/model/ContactsVersionRequirements.js +1 -1
- package/lib/cjs/api/model/ContactsVersionRequirements.js.map +3 -3
- package/lib/cjs/api/model/ContactsVersionRequirements.test.js +1 -1
- package/lib/cjs/api/model/ContactsVersionRequirements.test.js.map +2 -2
- package/lib/cjs/api/model/EditExternalAddressIdentifier.js.map +1 -1
- package/lib/cjs/api/model/EditExternalAddressScope.js.map +1 -1
- package/lib/cjs/api/model/ProvideContact.js.map +1 -1
- package/lib/cjs/api/model/RegisterExternalAddress.js.map +1 -1
- package/lib/cjs/internal/app-binder/contactsVersionGuards.test.js +1 -1
- package/lib/cjs/internal/app-binder/contactsVersionGuards.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/EditExternalAddressIdentifier/validateEditExternalAddressIdentifierInput.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/EditExternalAddressIdentifier/validateEditExternalAddressIdentifierInput.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/EditExternalAddressIdentifier/validateEditExternalAddressIdentifierInput.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/EditExternalAddressIdentifier/validateEditExternalAddressIdentifierInput.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/EditExternalAddressScope/validateEditExternalAddressScopeInput.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/EditExternalAddressScope/validateEditExternalAddressScopeInput.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/EditExternalAddressScope/validateEditExternalAddressScopeInput.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/EditExternalAddressScope/validateEditExternalAddressScopeInput.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/RegisterExternalAddress/validateRegisterExternalAddressInput.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/RegisterExternalAddress/validateRegisterExternalAddressInput.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/RegisterExternalAddress/validateRegisterExternalAddressInput.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/RegisterExternalAddress/validateRegisterExternalAddressInput.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/model/contactsValidation.js +1 -1
- package/lib/cjs/internal/app-binder/model/contactsValidation.js.map +3 -3
- package/lib/cjs/internal/app-binder/model/contactsValidation.test.js +1 -1
- package/lib/cjs/internal/app-binder/model/contactsValidation.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/services/provideContact.js +1 -1
- package/lib/cjs/internal/app-binder/services/provideContact.js.map +3 -3
- package/lib/cjs/internal/app-binder/services/provideContact.test.js +1 -1
- package/lib/cjs/internal/app-binder/services/provideContact.test.js.map +2 -2
- package/lib/cjs/package.json +1 -1
- package/lib/esm/api/index.js +1 -1
- package/lib/esm/api/index.js.map +3 -3
- package/lib/esm/api/model/ContactsVersionRequirements.js +1 -1
- package/lib/esm/api/model/ContactsVersionRequirements.js.map +3 -3
- package/lib/esm/api/model/ContactsVersionRequirements.test.js +1 -1
- package/lib/esm/api/model/ContactsVersionRequirements.test.js.map +3 -3
- package/lib/esm/internal/app-binder/contactsVersionGuards.test.js +1 -1
- package/lib/esm/internal/app-binder/contactsVersionGuards.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/EditExternalAddressIdentifier/validateEditExternalAddressIdentifierInput.js +1 -1
- package/lib/esm/internal/app-binder/device-action/EditExternalAddressIdentifier/validateEditExternalAddressIdentifierInput.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/EditExternalAddressIdentifier/validateEditExternalAddressIdentifierInput.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/EditExternalAddressIdentifier/validateEditExternalAddressIdentifierInput.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/EditExternalAddressScope/validateEditExternalAddressScopeInput.js +1 -1
- package/lib/esm/internal/app-binder/device-action/EditExternalAddressScope/validateEditExternalAddressScopeInput.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/EditExternalAddressScope/validateEditExternalAddressScopeInput.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/EditExternalAddressScope/validateEditExternalAddressScopeInput.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/RegisterExternalAddress/validateRegisterExternalAddressInput.js +1 -1
- package/lib/esm/internal/app-binder/device-action/RegisterExternalAddress/validateRegisterExternalAddressInput.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/RegisterExternalAddress/validateRegisterExternalAddressInput.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/RegisterExternalAddress/validateRegisterExternalAddressInput.test.js.map +3 -3
- package/lib/esm/internal/app-binder/model/contactsValidation.js +1 -1
- package/lib/esm/internal/app-binder/model/contactsValidation.js.map +3 -3
- package/lib/esm/internal/app-binder/model/contactsValidation.test.js +1 -1
- package/lib/esm/internal/app-binder/model/contactsValidation.test.js.map +3 -3
- package/lib/esm/internal/app-binder/services/provideContact.js +1 -1
- package/lib/esm/internal/app-binder/services/provideContact.js.map +3 -3
- package/lib/esm/internal/app-binder/services/provideContact.test.js +1 -1
- package/lib/esm/internal/app-binder/services/provideContact.test.js.map +2 -2
- package/lib/esm/package.json +1 -1
- package/lib/types/api/index.d.ts +1 -1
- package/lib/types/api/index.d.ts.map +1 -1
- package/lib/types/api/model/ContactsVersionRequirements.d.ts +1 -0
- package/lib/types/api/model/ContactsVersionRequirements.d.ts.map +1 -1
- package/lib/types/api/model/EditExternalAddressIdentifier.d.ts +2 -2
- package/lib/types/api/model/EditExternalAddressIdentifier.d.ts.map +1 -1
- package/lib/types/api/model/EditExternalAddressScope.d.ts +2 -2
- package/lib/types/api/model/EditExternalAddressScope.d.ts.map +1 -1
- package/lib/types/api/model/ProvideContact.d.ts +1 -1
- package/lib/types/api/model/ProvideContact.d.ts.map +1 -1
- package/lib/types/api/model/RegisterExternalAddress.d.ts +2 -2
- package/lib/types/api/model/RegisterExternalAddress.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/EditExternalAddressIdentifier/validateEditExternalAddressIdentifierInput.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/EditExternalAddressScope/validateEditExternalAddressScopeInput.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/RegisterExternalAddress/validateRegisterExternalAddressInput.d.ts.map +1 -1
- package/lib/types/internal/app-binder/model/contactsValidation.d.ts +23 -0
- package/lib/types/internal/app-binder/model/contactsValidation.d.ts.map +1 -1
- package/lib/types/internal/app-binder/services/provideContact.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -55,6 +55,18 @@ observable.subscribe((state) => {
|
|
|
55
55
|
});
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
`identifier` is the address as raw bytes; converting an address string to bytes (hex for
|
|
59
|
+
Ethereum, base58 for Tron and Solana) is up to the host. The kit checks it against the blockchain
|
|
60
|
+
family before anything reaches the device:
|
|
61
|
+
|
|
62
|
+
| `blockchainFamily` | `identifier` | `chainId` | Embedded app |
|
|
63
|
+
| ------------------ | ----------------------- | ----------- | ------------ |
|
|
64
|
+
| `"ethereum"` | 20-byte address | Required | `Ethereum` |
|
|
65
|
+
| `"tron"` | Non-empty address bytes | Not used | `Tron` |
|
|
66
|
+
| `"solana"` | 32-byte public key | Not allowed | `Solana` |
|
|
67
|
+
|
|
68
|
+
The same rules apply to the edit operations and to `buildProvideContactPayload`.
|
|
69
|
+
|
|
58
70
|
## Renaming a contact
|
|
59
71
|
|
|
60
72
|
`renameContact` runs the device's EDIT CONTACT NAME operation. Unlike the register operations, this
|
|
@@ -116,8 +128,8 @@ if (requirement.supported) {
|
|
|
116
128
|
|
|
117
129
|
The two axes are checked independently, never as one combined verdict: `minOsVersion` gates
|
|
118
130
|
OS-owned operations (served by the device OS, e.g. renaming a contact from the dashboard) and
|
|
119
|
-
`minAppVersion` gates app-owned operations (served by the embedded app, keyed by app name
|
|
120
|
-
|
|
131
|
+
`minAppVersion` gates app-owned operations (served by the embedded app, keyed by app name: `ETHEREUM_APP_NAME`,
|
|
132
|
+
`TRON_APP_NAME`, `SOLANA_APP_NAME`). A device can satisfy one and not the other, and each Contacts operation
|
|
121
133
|
depends on exactly one of them, so collapsing them into a single "is Contacts supported" answer
|
|
122
134
|
would reject devices that can serve the operation the host actually wants.
|
|
123
135
|
|
package/lib/cjs/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var y=(r,t)=>{for(var n in t)o(r,n,{get:t[n],enumerable:!0})},u=(r,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of A(t))!E.call(r,d)&&d!==n&&o(r,d,{get:()=>t[d],enumerable:!(s=i(t,d))||s.enumerable});return r};var x=r=>u(o({},"__esModule",{value:!0}),r);var l={};y(l,{CONTACTS_VERSION_REQUIREMENTS:()=>e.CONTACTS_VERSION_REQUIREMENTS,ContactsManagerBuilder:()=>a.ContactsManagerBuilder,ETHEREUM_APP_NAME:()=>e.ETHEREUM_APP_NAME,TRON_APP_NAME:()=>e.TRON_APP_NAME,buildProvideContactPayload:()=>p.buildProvideContactPayload,isVersionAtLeast:()=>e.isVersionAtLeast,resolveContactsVersionRequirements:()=>e.resolveContactsVersionRequirements,sendProvideContactPayload:()=>p.sendProvideContactPayload});module.exports=x(l);var a=require("./ContactsManagerBuilder"),e=require("./model/ContactsVersionRequirements"),p=require("../internal/app-binder/services/provideContact");0&&(module.exports={CONTACTS_VERSION_REQUIREMENTS,ContactsManagerBuilder,ETHEREUM_APP_NAME,TRON_APP_NAME,buildProvideContactPayload,isVersionAtLeast,resolveContactsVersionRequirements,sendProvideContactPayload});
|
|
1
|
+
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var y=(r,t)=>{for(var n in t)o(r,n,{get:t[n],enumerable:!0})},u=(r,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of A(t))!E.call(r,d)&&d!==n&&o(r,d,{get:()=>t[d],enumerable:!(s=i(t,d))||s.enumerable});return r};var x=r=>u(o({},"__esModule",{value:!0}),r);var l={};y(l,{CONTACTS_VERSION_REQUIREMENTS:()=>e.CONTACTS_VERSION_REQUIREMENTS,ContactsManagerBuilder:()=>a.ContactsManagerBuilder,ETHEREUM_APP_NAME:()=>e.ETHEREUM_APP_NAME,SOLANA_APP_NAME:()=>e.SOLANA_APP_NAME,TRON_APP_NAME:()=>e.TRON_APP_NAME,buildProvideContactPayload:()=>p.buildProvideContactPayload,isVersionAtLeast:()=>e.isVersionAtLeast,resolveContactsVersionRequirements:()=>e.resolveContactsVersionRequirements,sendProvideContactPayload:()=>p.sendProvideContactPayload});module.exports=x(l);var a=require("./ContactsManagerBuilder"),e=require("./model/ContactsVersionRequirements"),p=require("../internal/app-binder/services/provideContact");0&&(module.exports={CONTACTS_VERSION_REQUIREMENTS,ContactsManagerBuilder,ETHEREUM_APP_NAME,SOLANA_APP_NAME,TRON_APP_NAME,buildProvideContactPayload,isVersionAtLeast,resolveContactsVersionRequirements,sendProvideContactPayload});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/api/index.js.map
CHANGED
|
@@ -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 ContactsVersionRequirements,\n ETHEREUM_APP_NAME,\n isVersionAtLeast,\n resolveContactsVersionRequirements,\n TRON_APP_NAME,\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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,
|
|
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 SOLANA_APP_NAME,\n TRON_APP_NAME,\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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oeAAAE,EAAAF,GAqCA,IAAAG,EAAuC,uCACvCC,EAWO,kDAqBPC,EAIO",
|
|
6
6
|
"names": ["api_exports", "__export", "__toCommonJS", "import_ContactsManagerBuilder", "import_ContactsVersionRequirements", "import_provideContact"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var M=(e,o)=>{for(var n in o)a(e,n,{get:o[n],enumerable:!0})},S=(e,o,n,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of V(o))!m.call(e,i)&&i!==n&&a(e,i,{get:()=>o[i],enumerable:!(r=P(o,i))||r.enumerable});return e};var I=e=>S(a({},"__esModule",{value:!0}),e);var h={};M(h,{CONTACTS_VERSION_REQUIREMENTS:()=>_,ETHEREUM_APP_NAME:()=>c,SOLANA_APP_NAME:()=>l,TRON_APP_NAME:()=>u,isVersionAtLeast:()=>y,isVersionBelow:()=>R,renameRequiresDerivationPath:()=>g,resolveContactsVersionRequirements:()=>X});module.exports=I(h);var s=require("@ledgerhq/device-management-kit"),t=require("semver");const c="Ethereum",u="Tron",l="Solana",T={supported:!1},N="1.11.0",d="1.7.0",O="1.2.0",A="2.8.0",E="1.7.0",f="1.23.0",C="0.8.0",q="10.0.0",p={[c]:f,[u]:C,[l]:q},v=`${N}-rc3`,D=`${d}-rc3`,F=`${O}-rc3`,U=`${A}-rc3`,x=`${E}-rc3`,_={[s.DeviceModelId.NANO_S]:T,[s.DeviceModelId.NANO_SP]:{supported:!0,minOsVersion:E,minAppVersion:p,renameDerivationPathRequiredBelowOsVersion:x},[s.DeviceModelId.NANO_X]:{supported:!0,minOsVersion:A,minAppVersion:p,renameDerivationPathRequiredBelowOsVersion:U},[s.DeviceModelId.STAX]:{supported:!0,minOsVersion:N,minAppVersion:p,renameDerivationPathRequiredBelowOsVersion:v},[s.DeviceModelId.FLEX]:{supported:!0,minOsVersion:d,minAppVersion:p,renameDerivationPathRequiredBelowOsVersion:D},[s.DeviceModelId.APEX]:{supported:!0,minOsVersion:O,minAppVersion:p,renameDerivationPathRequiredBelowOsVersion:F}};function X(e){return _[e]}function y(e,o){const n=(0,t.valid)((0,t.coerce)(e)),r=(0,t.valid)((0,t.coerce)(o));return n===null||r===null?!1:(0,t.gte)(n,r)}function R(e,o){const n=(0,t.valid)(e),r=(0,t.valid)(o);return n===null||r===null?!1:(0,t.lt)(n,r)}function g(e,o){const n=_[e];if(!n.supported)return!1;const r=n.renameDerivationPathRequiredBelowOsVersion;return r===void 0?!1:R(o,r)}0&&(module.exports={CONTACTS_VERSION_REQUIREMENTS,ETHEREUM_APP_NAME,SOLANA_APP_NAME,TRON_APP_NAME,isVersionAtLeast,isVersionBelow,renameRequiresDerivationPath,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, 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.\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/** Names of embedded apps supporting Contacts. */\nexport const ETHEREUM_APP_NAME = \"Ethereum\";\nexport const TRON_APP_NAME = \"Tron\";\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\";\nconst MIN_TRON_APP_VERSION = \"0.8.0\";\n\nconst MIN_APP_VERSION = {\n [ETHEREUM_APP_NAME]: MIN_ETHEREUM_APP_VERSION,\n [TRON_APP_NAME]: MIN_TRON_APP_VERSION,\n};\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: MIN_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: MIN_APP_VERSION,\n renameDerivationPathRequiredBelowOsVersion: RENAME_PATH_CUTOFF_NANO_X,\n },\n [DeviceModelId.STAX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_STAX,\n minAppVersion: MIN_APP_VERSION,\n renameDerivationPathRequiredBelowOsVersion: RENAME_PATH_CUTOFF_STAX,\n },\n [DeviceModelId.FLEX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_FLEX,\n minAppVersion: MIN_APP_VERSION,\n renameDerivationPathRequiredBelowOsVersion: RENAME_PATH_CUTOFF_FLEX,\n },\n [DeviceModelId.APEX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_APEX,\n minAppVersion: MIN_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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,EAAA,sBAAAC,EAAA,kBAAAC,EAAA,qBAAAC,EAAA,mBAAAC,EAAA,iCAAAC,EAAA,uCAAAC,IAAA,eAAAC,
|
|
6
|
-
"names": ["ContactsVersionRequirements_exports", "__export", "CONTACTS_VERSION_REQUIREMENTS", "ETHEREUM_APP_NAME", "TRON_APP_NAME", "isVersionAtLeast", "isVersionBelow", "renameRequiresDerivationPath", "resolveContactsVersionRequirements", "__toCommonJS", "import_device_management_kit", "import_semver", "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", "MIN_TRON_APP_VERSION", "MIN_APP_VERSION", "RENAME_PATH_CUTOFF_STAX", "RENAME_PATH_CUTOFF_FLEX", "RENAME_PATH_CUTOFF_APEX", "RENAME_PATH_CUTOFF_NANO_X", "RENAME_PATH_CUTOFF_NANO_SP", "deviceModelId", "actual", "minimum", "a", "b", "boundary", "osVersion", "requirement", "cutoff"]
|
|
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.\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/** Names of embedded apps supporting Contacts. */\nexport const ETHEREUM_APP_NAME = \"Ethereum\";\nexport const TRON_APP_NAME = \"Tron\";\nexport const SOLANA_APP_NAME = \"Solana\";\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\";\nconst MIN_TRON_APP_VERSION = \"0.8.0\";\n// TEMPORARY (DSDK-1571) \u2014 the Solana app does not support Contacts yet and its\n// implementation is not scheduled, so this unreleased version keeps every\n// existing build out. Pin it to the first Contacts-enabled release once the\n// Solana app team names it.\nconst MIN_SOLANA_APP_VERSION = \"10.0.0\";\n\nconst MIN_APP_VERSION = {\n [ETHEREUM_APP_NAME]: MIN_ETHEREUM_APP_VERSION,\n [TRON_APP_NAME]: MIN_TRON_APP_VERSION,\n [SOLANA_APP_NAME]: MIN_SOLANA_APP_VERSION,\n};\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: MIN_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: MIN_APP_VERSION,\n renameDerivationPathRequiredBelowOsVersion: RENAME_PATH_CUTOFF_NANO_X,\n },\n [DeviceModelId.STAX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_STAX,\n minAppVersion: MIN_APP_VERSION,\n renameDerivationPathRequiredBelowOsVersion: RENAME_PATH_CUTOFF_STAX,\n },\n [DeviceModelId.FLEX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_FLEX,\n minAppVersion: MIN_APP_VERSION,\n renameDerivationPathRequiredBelowOsVersion: RENAME_PATH_CUTOFF_FLEX,\n },\n [DeviceModelId.APEX]: {\n supported: true,\n minOsVersion: MIN_OS_VERSION_APEX,\n minAppVersion: MIN_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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,EAAA,sBAAAC,EAAA,oBAAAC,EAAA,kBAAAC,EAAA,qBAAAC,EAAA,mBAAAC,EAAA,iCAAAC,EAAA,uCAAAC,IAAA,eAAAC,EAAAV,GAAA,IAAAW,EAA8B,2CAC9BC,EAAuC,kBAmDhC,MAAMT,EAAoB,WACpBE,EAAgB,OAChBD,EAAkB,SAEzBS,EAAwC,CAAE,UAAW,EAAM,EAE3DC,EAAsB,SACtBC,EAAsB,QACtBC,EAAsB,QACtBC,EAAwB,QACxBC,EAAyB,QAEzBC,EAA2B,SAC3BC,EAAuB,QAKvBC,EAAyB,SAEzBC,EAAkB,CACtB,CAACnB,CAAiB,EAAGgB,EACrB,CAACd,CAAa,EAAGe,EACjB,CAAChB,CAAe,EAAGiB,CACrB,EAQME,EAA0B,GAAGT,CAAmB,OAChDU,EAA0B,GAAGT,CAAmB,OAChDU,EAA0B,GAAGT,CAAmB,OAChDU,EAA4B,GAAGT,CAAqB,OACpDU,EAA6B,GAAGT,CAAsB,OAM/ChB,EAA6D,CACxE,CAAC,gBAAc,MAAM,EAAGW,EACxB,CAAC,gBAAc,OAAO,EAAG,CACvB,UAAW,GACX,aAAcK,EACd,cAAeI,EACf,2CAA4CK,CAC9C,EACA,CAAC,gBAAc,MAAM,EAAG,CACtB,UAAW,GACX,aAAcV,EACd,cAAeK,EACf,2CAA4CI,CAC9C,EACA,CAAC,gBAAc,IAAI,EAAG,CACpB,UAAW,GACX,aAAcZ,EACd,cAAeQ,EACf,2CAA4CC,CAC9C,EACA,CAAC,gBAAc,IAAI,EAAG,CACpB,UAAW,GACX,aAAcR,EACd,cAAeO,EACf,2CAA4CE,CAC9C,EACA,CAAC,gBAAc,IAAI,EAAG,CACpB,UAAW,GACX,aAAcR,EACd,cAAeM,EACf,2CAA4CG,CAC9C,CACF,EAMO,SAAShB,EACdmB,EAC0B,CAC1B,OAAO1B,EAA8B0B,CAAa,CACpD,CAUO,SAAStB,EAAiBuB,EAAgBC,EAA0B,CACzE,MAAMC,KAAI,YAAM,UAAOF,CAAM,CAAC,EACxBG,KAAI,YAAM,UAAOF,CAAO,CAAC,EAC/B,OAAIC,IAAM,MAAQC,IAAM,KAAa,MAC9B,OAAID,EAAGC,CAAC,CACjB,CAYO,SAASzB,EAAesB,EAAgBI,EAA2B,CACxE,MAAMF,KAAI,SAAMF,CAAM,EAChBG,KAAI,SAAMC,CAAQ,EACxB,OAAIF,IAAM,MAAQC,IAAM,KAAa,MAC9B,MAAGD,EAAGC,CAAC,CAChB,CAWO,SAASxB,EACdoB,EACAM,EACS,CACT,MAAMC,EAAcjC,EAA8B0B,CAAa,EAC/D,GAAI,CAACO,EAAY,UAAW,MAAO,GACnC,MAAMC,EAASD,EAAY,2CAC3B,OAAIC,IAAW,OAAkB,GAC1B7B,EAAe2B,EAAWE,CAAM,CACzC",
|
|
6
|
+
"names": ["ContactsVersionRequirements_exports", "__export", "CONTACTS_VERSION_REQUIREMENTS", "ETHEREUM_APP_NAME", "SOLANA_APP_NAME", "TRON_APP_NAME", "isVersionAtLeast", "isVersionBelow", "renameRequiresDerivationPath", "resolveContactsVersionRequirements", "__toCommonJS", "import_device_management_kit", "import_semver", "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", "MIN_TRON_APP_VERSION", "MIN_SOLANA_APP_VERSION", "MIN_APP_VERSION", "RENAME_PATH_CUTOFF_STAX", "RENAME_PATH_CUTOFF_FLEX", "RENAME_PATH_CUTOFF_APEX", "RENAME_PATH_CUTOFF_NANO_X", "RENAME_PATH_CUTOFF_NANO_SP", "deviceModelId", "actual", "minimum", "a", "b", "boundary", "osVersion", "requirement", "cutoff"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("@ledgerhq/device-management-kit"),e=require("./ContactsVersionRequirements");describe("ContactsVersionRequirements",()=>{describe("resolveContactsVersionRequirements",()=>{it("marks every device model, supported or not",()=>{for(const r of Object.values(t.DeviceModelId))expect(e.CONTACTS_VERSION_REQUIREMENTS[r]).toBeDefined()}),it("reports Nano S as unsupported",()=>{expect((0,e.resolveContactsVersionRequirements)(t.DeviceModelId.NANO_S)).toEqual({supported:!1})}),it("pins the minimum OS and app versions of every supported model",()=>{const r={[e.ETHEREUM_APP_NAME]:"1.23.0",[e.TRON_APP_NAME]:"0.8.0"};expect(e.CONTACTS_VERSION_REQUIREMENTS).toEqual({[t.DeviceModelId.NANO_S]:{supported:!1},[t.DeviceModelId.NANO_SP]:{supported:!0,minOsVersion:"1.7.0",minAppVersion:r,renameDerivationPathRequiredBelowOsVersion:"1.7.0-rc3"},[t.DeviceModelId.NANO_X]:{supported:!0,minOsVersion:"2.8.0",minAppVersion:r,renameDerivationPathRequiredBelowOsVersion:"2.8.0-rc3"},[t.DeviceModelId.STAX]:{supported:!0,minOsVersion:"1.11.0",minAppVersion:r,renameDerivationPathRequiredBelowOsVersion:"1.11.0-rc3"},[t.DeviceModelId.FLEX]:{supported:!0,minOsVersion:"1.7.0",minAppVersion:r,renameDerivationPathRequiredBelowOsVersion:"1.7.0-rc3"},[t.DeviceModelId.APEX]:{supported:!0,minOsVersion:"1.2.0",minAppVersion:r,renameDerivationPathRequiredBelowOsVersion:"1.2.0-rc3"}})})}),describe("isVersionAtLeast",()=>{it("compares versions as semver, inclusive of equality",()=>{expect((0,e.isVersionAtLeast)("1.2.0","1.2.0")).toBe(!0),expect((0,e.isVersionAtLeast)("1.3.0","1.2.0")).toBe(!0),expect((0,e.isVersionAtLeast)("1.1.9","1.2.0")).toBe(!1)}),it("coerces non-strict version strings",()=>{expect((0,e.isVersionAtLeast)("1.2","1.2.0")).toBe(!0)}),it("returns false when a version cannot be parsed",()=>{expect((0,e.isVersionAtLeast)("not-a-version","1.2.0")).toBe(!1),expect((0,e.isVersionAtLeast)("1.2.0","not-a-version")).toBe(!1)}),it("ignores prerelease and build tags when comparing to the minimum",()=>{expect((0,e.isVersionAtLeast)("1.7.0-rc2","1.7.0")).toBe(!0),expect((0,e.isVersionAtLeast)("1.23.0-dev","1.23.0")).toBe(!0)}),it("still fails a minimum strictly above the tagged version's core",()=>{expect((0,e.isVersionAtLeast)("1.6.9-rc5","1.7.0")).toBe(!1)})}),describe("isVersionBelow",()=>{it("orders release candidates of the same core (unlike isVersionAtLeast)",()=>{expect((0,e.isVersionBelow)("1.7.0-rc2","1.7.0-rc3")).toBe(!0),expect((0,e.isVersionBelow)("1.7.0-rc3","1.7.0-rc3")).toBe(!1),expect((0,e.isVersionBelow)("1.7.0-rc4","1.7.0-rc3")).toBe(!1)}),it("treats the final release as newer than any of its prereleases",()=>{expect((0,e.isVersionBelow)("1.7.0","1.7.0-rc3")).toBe(!1)}),it("compares the release core when it differs",()=>{expect((0,e.isVersionBelow)("1.6.9","1.7.0-rc3")).toBe(!0),expect((0,e.isVersionBelow)("1.8.0","1.7.0-rc3")).toBe(!1)}),it("does not coerce, so a non-strict version is unparseable and returns false",()=>{expect((0,e.isVersionBelow)("1.7","1.7.0-rc3")).toBe(!1),expect((0,e.isVersionBelow)("not-a-version","1.7.0-rc3")).toBe(!1),expect((0,e.isVersionBelow)("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((0,e.renameRequiresDerivationPath)(t.DeviceModelId.FLEX,"1.7.0-rc2")).toBe(!0),expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.FLEX,"1.7.0-rc3")).toBe(!1),expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.FLEX,"1.7.0")).toBe(!1),expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.FLEX,"1.8.0")).toBe(!1)}),it("applies the same rc2/rc3 split to the other supported models",()=>{expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.STAX,"1.11.0-rc2")).toBe(!0),expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.STAX,"1.11.0-rc3")).toBe(!1),expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.NANO_SP,"1.7.0-rc2")).toBe(!0)}),it("returns false for an unsupported model",()=>{expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.NANO_S,"1.7.0-rc2")).toBe(!1)}),it("returns false (no path) when the OS version is unparseable",()=>{expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.FLEX,"")).toBe(!1)})})});
|
|
1
|
+
"use strict";var t=require("@ledgerhq/device-management-kit"),e=require("./ContactsVersionRequirements");describe("ContactsVersionRequirements",()=>{describe("resolveContactsVersionRequirements",()=>{it("marks every device model, supported or not",()=>{for(const r of Object.values(t.DeviceModelId))expect(e.CONTACTS_VERSION_REQUIREMENTS[r]).toBeDefined()}),it("reports Nano S as unsupported",()=>{expect((0,e.resolveContactsVersionRequirements)(t.DeviceModelId.NANO_S)).toEqual({supported:!1})}),it("pins the minimum OS and app versions of every supported model",()=>{const r={[e.ETHEREUM_APP_NAME]:"1.23.0",[e.TRON_APP_NAME]:"0.8.0",[e.SOLANA_APP_NAME]:"10.0.0"};expect(e.CONTACTS_VERSION_REQUIREMENTS).toEqual({[t.DeviceModelId.NANO_S]:{supported:!1},[t.DeviceModelId.NANO_SP]:{supported:!0,minOsVersion:"1.7.0",minAppVersion:r,renameDerivationPathRequiredBelowOsVersion:"1.7.0-rc3"},[t.DeviceModelId.NANO_X]:{supported:!0,minOsVersion:"2.8.0",minAppVersion:r,renameDerivationPathRequiredBelowOsVersion:"2.8.0-rc3"},[t.DeviceModelId.STAX]:{supported:!0,minOsVersion:"1.11.0",minAppVersion:r,renameDerivationPathRequiredBelowOsVersion:"1.11.0-rc3"},[t.DeviceModelId.FLEX]:{supported:!0,minOsVersion:"1.7.0",minAppVersion:r,renameDerivationPathRequiredBelowOsVersion:"1.7.0-rc3"},[t.DeviceModelId.APEX]:{supported:!0,minOsVersion:"1.2.0",minAppVersion:r,renameDerivationPathRequiredBelowOsVersion:"1.2.0-rc3"}})})}),describe("isVersionAtLeast",()=>{it("compares versions as semver, inclusive of equality",()=>{expect((0,e.isVersionAtLeast)("1.2.0","1.2.0")).toBe(!0),expect((0,e.isVersionAtLeast)("1.3.0","1.2.0")).toBe(!0),expect((0,e.isVersionAtLeast)("1.1.9","1.2.0")).toBe(!1)}),it("coerces non-strict version strings",()=>{expect((0,e.isVersionAtLeast)("1.2","1.2.0")).toBe(!0)}),it("returns false when a version cannot be parsed",()=>{expect((0,e.isVersionAtLeast)("not-a-version","1.2.0")).toBe(!1),expect((0,e.isVersionAtLeast)("1.2.0","not-a-version")).toBe(!1)}),it("ignores prerelease and build tags when comparing to the minimum",()=>{expect((0,e.isVersionAtLeast)("1.7.0-rc2","1.7.0")).toBe(!0),expect((0,e.isVersionAtLeast)("1.23.0-dev","1.23.0")).toBe(!0)}),it("still fails a minimum strictly above the tagged version's core",()=>{expect((0,e.isVersionAtLeast)("1.6.9-rc5","1.7.0")).toBe(!1)})}),describe("isVersionBelow",()=>{it("orders release candidates of the same core (unlike isVersionAtLeast)",()=>{expect((0,e.isVersionBelow)("1.7.0-rc2","1.7.0-rc3")).toBe(!0),expect((0,e.isVersionBelow)("1.7.0-rc3","1.7.0-rc3")).toBe(!1),expect((0,e.isVersionBelow)("1.7.0-rc4","1.7.0-rc3")).toBe(!1)}),it("treats the final release as newer than any of its prereleases",()=>{expect((0,e.isVersionBelow)("1.7.0","1.7.0-rc3")).toBe(!1)}),it("compares the release core when it differs",()=>{expect((0,e.isVersionBelow)("1.6.9","1.7.0-rc3")).toBe(!0),expect((0,e.isVersionBelow)("1.8.0","1.7.0-rc3")).toBe(!1)}),it("does not coerce, so a non-strict version is unparseable and returns false",()=>{expect((0,e.isVersionBelow)("1.7","1.7.0-rc3")).toBe(!1),expect((0,e.isVersionBelow)("not-a-version","1.7.0-rc3")).toBe(!1),expect((0,e.isVersionBelow)("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((0,e.renameRequiresDerivationPath)(t.DeviceModelId.FLEX,"1.7.0-rc2")).toBe(!0),expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.FLEX,"1.7.0-rc3")).toBe(!1),expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.FLEX,"1.7.0")).toBe(!1),expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.FLEX,"1.8.0")).toBe(!1)}),it("applies the same rc2/rc3 split to the other supported models",()=>{expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.STAX,"1.11.0-rc2")).toBe(!0),expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.STAX,"1.11.0-rc3")).toBe(!1),expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.NANO_SP,"1.7.0-rc2")).toBe(!0)}),it("returns false for an unsupported model",()=>{expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.NANO_S,"1.7.0-rc2")).toBe(!1)}),it("returns false (no path) when the OS version is unparseable",()=>{expect((0,e.renameRequiresDerivationPath)(t.DeviceModelId.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 ETHEREUM_APP_NAME,\n isVersionAtLeast,\n isVersionBelow,\n renameRequiresDerivationPath,\n resolveContactsVersionRequirements,\n TRON_APP_NAME,\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 appVersions = {\n [ETHEREUM_APP_NAME]: \"1.23.0\",\n [TRON_APP_NAME]: \"0.8.0\",\n };\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: appVersions,\n renameDerivationPathRequiredBelowOsVersion: \"1.7.0-rc3\",\n },\n [DeviceModelId.NANO_X]: {\n supported: true,\n minOsVersion: \"2.8.0\",\n minAppVersion: appVersions,\n renameDerivationPathRequiredBelowOsVersion: \"2.8.0-rc3\",\n },\n [DeviceModelId.STAX]: {\n supported: true,\n minOsVersion: \"1.11.0\",\n minAppVersion: appVersions,\n renameDerivationPathRequiredBelowOsVersion: \"1.11.0-rc3\",\n },\n [DeviceModelId.FLEX]: {\n supported: true,\n minOsVersion: \"1.7.0\",\n minAppVersion: appVersions,\n renameDerivationPathRequiredBelowOsVersion: \"1.7.0-rc3\",\n },\n [DeviceModelId.APEX]: {\n supported: true,\n minOsVersion: \"1.2.0\",\n minAppVersion: appVersions,\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,IAAAA,EAA8B,2CAE9BC,
|
|
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 SOLANA_APP_NAME,\n TRON_APP_NAME,\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 appVersions = {\n [ETHEREUM_APP_NAME]: \"1.23.0\",\n [TRON_APP_NAME]: \"0.8.0\",\n [SOLANA_APP_NAME]: \"10.0.0\",\n };\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: appVersions,\n renameDerivationPathRequiredBelowOsVersion: \"1.7.0-rc3\",\n },\n [DeviceModelId.NANO_X]: {\n supported: true,\n minOsVersion: \"2.8.0\",\n minAppVersion: appVersions,\n renameDerivationPathRequiredBelowOsVersion: \"2.8.0-rc3\",\n },\n [DeviceModelId.STAX]: {\n supported: true,\n minOsVersion: \"1.11.0\",\n minAppVersion: appVersions,\n renameDerivationPathRequiredBelowOsVersion: \"1.11.0-rc3\",\n },\n [DeviceModelId.FLEX]: {\n supported: true,\n minOsVersion: \"1.7.0\",\n minAppVersion: appVersions,\n renameDerivationPathRequiredBelowOsVersion: \"1.7.0-rc3\",\n },\n [DeviceModelId.APEX]: {\n supported: true,\n minOsVersion: \"1.2.0\",\n minAppVersion: appVersions,\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": "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",
|
|
6
6
|
"names": ["import_device_management_kit", "import_ContactsVersionRequirements", "modelId", "appVersions"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/model/EditExternalAddressIdentifier.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Public input/output types for `ContactsManager.editExternalAddressIdentifier`.\n *\n * EDIT IDENTIFIER replaces an entry's identifier bytes within an existing\n * contact group. Only the address-level `hmacRest` rotates; the group-level\n * `hmacProof` passes through unchanged. Proof material is raw bytes (the host\n * owns persistence); `derivationPath` is kit-internal and not exposed.\n */\n\nexport type EditExternalAddressIdentifierInput = {\n /** The contact's name, proven to the device via `hmacProof`. */\n readonly contactName: string;\n /** The entry's current label/scope; shown on the approval screen. */\n readonly scope: string;\n /** The current (pre-edit) address bytes, proven via `hmacRest`. */\n readonly previousIdentifier: Uint8Array;\n /** The replacement address bytes (20 bytes for Ethereum). */\n readonly newIdentifier: Uint8Array;\n /** Blockchain family name, e.g. \"ethereum\"
|
|
4
|
+
"sourcesContent": ["/**\n * Public input/output types for `ContactsManager.editExternalAddressIdentifier`.\n *\n * EDIT IDENTIFIER replaces an entry's identifier bytes within an existing\n * contact group. Only the address-level `hmacRest` rotates; the group-level\n * `hmacProof` passes through unchanged. Proof material is raw bytes (the host\n * owns persistence); `derivationPath` is kit-internal and not exposed.\n */\n\nexport type EditExternalAddressIdentifierInput = {\n /** The contact's name, proven to the device via `hmacProof`. */\n readonly contactName: string;\n /** The entry's current label/scope; shown on the approval screen. */\n readonly scope: string;\n /** The current (pre-edit) address bytes, proven via `hmacRest`. */\n readonly previousIdentifier: Uint8Array;\n /** The replacement address bytes (20 bytes for Ethereum, 32 for Solana). */\n readonly newIdentifier: Uint8Array;\n /** Blockchain family name, e.g. \"ethereum\", \"tron\" or \"solana\". */\n readonly blockchainFamily: string;\n readonly chainId?: bigint;\n /** 64-byte group handle returned by the group's Register Identity. */\n readonly groupHandle: Uint8Array;\n /**\n * The contact-group name proof (device `hmac_name`) \u2014 passed back so the\n * device can verify the entry belongs to the group. Unchanged by the edit.\n */\n readonly hmacProof: Uint8Array;\n /**\n * The entry's current 32-byte address proof (`hmac_rest`) \u2014 passed back so the\n * device can verify continuity before approving. Replaced by the returned\n * `hmacRest` on success.\n */\n readonly hmacRest: Uint8Array;\n /**\n * When `true`, the open-app step is skipped (the caller guarantees the app is\n * already open). The app-version guard still runs.\n */\n readonly skipOpenApp?: boolean;\n};\n\nexport type EditExternalAddressIdentifierOutput = {\n /** Echoed input, needed by the host to locate the entry it is replacing. */\n readonly contactName: string;\n readonly scope: string;\n /** Echoed previous address bytes, to match the entry being replaced. */\n readonly previousIdentifier: Uint8Array;\n /** The new address bytes now bound to the entry. */\n readonly identifier: Uint8Array;\n readonly blockchainFamily: string;\n readonly chainId?: bigint;\n /** Echoed group handle, unchanged by the edit. */\n readonly groupHandle: Uint8Array;\n /** Echoed group-level name proof, unchanged by the edit. */\n readonly hmacProof: Uint8Array;\n /** The replacement address-level proof (rotated `hmac_rest`) to persist. */\n readonly hmacRest: Uint8Array;\n};\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["EditExternalAddressIdentifier_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/model/EditExternalAddressScope.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Public input/output types for `ContactsManager.editExternalAddressScope`.\n *\n * EDIT SCOPE replaces an entry's scope (its context label) within an existing\n * contact group while keeping the same contact name and identifier. Only the\n * address-level `hmacRest` rotates; the group-level `hmacProof` passes through\n * unchanged. Proof material is raw bytes (the host owns persistence);\n * `derivationPath` is kit-internal and not exposed.\n */\n\nexport type EditExternalAddressScopeInput = {\n /** The contact's name, proven to the device via `hmacProof`. Unchanged. */\n readonly contactName: string;\n /** The entry's current scope; shown on the approval screen and proven via `hmacRest`. */\n readonly previousScope: string;\n /** The replacement scope (max 32 printable ASCII chars). */\n readonly newScope: string;\n /** The entry's identifier bytes (20 bytes for Ethereum). Unchanged by the edit. */\n readonly identifier: Uint8Array;\n /** Blockchain family name, e.g. \"ethereum\"
|
|
4
|
+
"sourcesContent": ["/**\n * Public input/output types for `ContactsManager.editExternalAddressScope`.\n *\n * EDIT SCOPE replaces an entry's scope (its context label) within an existing\n * contact group while keeping the same contact name and identifier. Only the\n * address-level `hmacRest` rotates; the group-level `hmacProof` passes through\n * unchanged. Proof material is raw bytes (the host owns persistence);\n * `derivationPath` is kit-internal and not exposed.\n */\n\nexport type EditExternalAddressScopeInput = {\n /** The contact's name, proven to the device via `hmacProof`. Unchanged. */\n readonly contactName: string;\n /** The entry's current scope; shown on the approval screen and proven via `hmacRest`. */\n readonly previousScope: string;\n /** The replacement scope (max 32 printable ASCII chars). */\n readonly newScope: string;\n /** The entry's identifier bytes (20 bytes for Ethereum, 32 for Solana). Unchanged by the edit. */\n readonly identifier: Uint8Array;\n /** Blockchain family name, e.g. \"ethereum\", \"tron\" or \"solana\". */\n readonly blockchainFamily: string;\n readonly chainId?: bigint;\n /** 64-byte group handle returned by the group's Register Identity. */\n readonly groupHandle: Uint8Array;\n /**\n * The contact-group name proof (device `hmac_name`) \u2014 passed back so the\n * device can verify the entry belongs to the group. Unchanged by the edit.\n */\n readonly hmacProof: Uint8Array;\n /**\n * The entry's current 32-byte address proof (`hmac_rest`) \u2014 passed back so the\n * device can verify the previous scope/identifier before approving. Replaced\n * by the returned `hmacRest` on success.\n */\n readonly hmacRest: Uint8Array;\n /**\n * When `true`, the open-app step is skipped (the caller guarantees the app is\n * already open). The app-version guard still runs.\n */\n readonly skipOpenApp?: boolean;\n};\n\nexport type EditExternalAddressScopeOutput = {\n /** Echoed input, needed by the host to locate the entry it is replacing. */\n readonly contactName: string;\n /** Echoed previous scope, to match the entry being replaced. */\n readonly previousScope: string;\n /** The new scope now bound to the entry. */\n readonly scope: string;\n /** Echoed identifier bytes, unchanged by the edit. */\n readonly identifier: Uint8Array;\n readonly blockchainFamily: string;\n readonly chainId?: bigint;\n /** Echoed group handle, unchanged by the edit. */\n readonly groupHandle: Uint8Array;\n /** Echoed group-level name proof, unchanged by the edit. */\n readonly hmacProof: Uint8Array;\n /** The replacement address-level proof (rotated `hmac_rest`) to persist. */\n readonly hmacRest: Uint8Array;\n};\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["EditExternalAddressScope_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/model/ProvideContact.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Everything the device needs to accept a registered external contact as a\n * decoration for an upcoming signing flow: the name-level material shared by\n * the whole contact group, plus the address-level material of the one matched\n * address.\n */\nexport type ProvideContactInput = {\n readonly contactName: string;\n readonly scope: string;\n /** Raw bytes, chain-dependent: a 20-byte address for Ethereum. */\n readonly identifier: Uint8Array;\n readonly groupHandle: Uint8Array;\n readonly hmacProof: Uint8Array;\n readonly hmacRest: Uint8Array;\n /** Lowercase family name, e.g. `\"ethereum\"`. */\n readonly blockchainFamily: string;\n /** Mandatory for Ethereum, omitted for every other family. */\n readonly chainId?: bigint;\n};\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * Everything the device needs to accept a registered external contact as a\n * decoration for an upcoming signing flow: the name-level material shared by\n * the whole contact group, plus the address-level material of the one matched\n * address.\n */\nexport type ProvideContactInput = {\n readonly contactName: string;\n readonly scope: string;\n /** Raw bytes, chain-dependent: a 20-byte address for Ethereum, a 32-byte public key for Solana. */\n readonly identifier: Uint8Array;\n readonly groupHandle: Uint8Array;\n readonly hmacProof: Uint8Array;\n readonly hmacRest: Uint8Array;\n /** Lowercase family name, e.g. `\"ethereum\"`. */\n readonly blockchainFamily: string;\n /** Mandatory for Ethereum, omitted for every other family. */\n readonly chainId?: bigint;\n};\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["ProvideContact_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/model/RegisterExternalAddress.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Public input/output types for `ContactsManager.registerExternalAddress`.\n *\n * Proof material (`groupHandle`, `hmacProof`, `hmacRest`) is returned as raw\n * bytes; the host owns persistence and address-book state. `derivationPath` is\n * intentionally absent \u2014 the kit owns a single internal value for external\n * addresses and does not expose it.\n */\n\n/** The existing contact group to extend, when adding an address to it. */\nexport type ExistingContactGroup = {\n /** 64-byte group handle returned by the group's first Register Identity. */\n readonly groupHandle: Uint8Array;\n /** 32-byte name proof (device `hmac_name`) bound to that group. */\n readonly hmacProof: Uint8Array;\n};\n\nexport type RegisterExternalAddressInput = {\n readonly contactName: string;\n readonly scope: string;\n /** Chain address bytes (20 bytes for Ethereum). */\n readonly identifier: Uint8Array;\n /** Blockchain family name, e.g. \"ethereum\"
|
|
4
|
+
"sourcesContent": ["/**\n * Public input/output types for `ContactsManager.registerExternalAddress`.\n *\n * Proof material (`groupHandle`, `hmacProof`, `hmacRest`) is returned as raw\n * bytes; the host owns persistence and address-book state. `derivationPath` is\n * intentionally absent \u2014 the kit owns a single internal value for external\n * addresses and does not expose it.\n */\n\n/** The existing contact group to extend, when adding an address to it. */\nexport type ExistingContactGroup = {\n /** 64-byte group handle returned by the group's first Register Identity. */\n readonly groupHandle: Uint8Array;\n /** 32-byte name proof (device `hmac_name`) bound to that group. */\n readonly hmacProof: Uint8Array;\n};\n\nexport type RegisterExternalAddressInput = {\n readonly contactName: string;\n readonly scope: string;\n /** Chain address bytes (20 bytes for Ethereum, 32 for Solana). */\n readonly identifier: Uint8Array;\n /** Blockchain family name, e.g. \"ethereum\", \"tron\" or \"solana\". */\n readonly blockchainFamily: string;\n readonly chainId?: bigint;\n /**\n * Set to add the address to an existing contact group. Omit to create a new\n * contact group.\n */\n readonly existingContactGroup?: ExistingContactGroup;\n /**\n * When `true`, the open-app step is skipped (the caller guarantees the app is\n * already open). The app-version guard still runs.\n */\n readonly skipOpenApp?: boolean;\n};\n\nexport type RegisterExternalAddressMode =\n | \"newContactGroup\"\n | \"existingContactGroup\";\n\nexport type RegisterExternalAddressOutput = {\n /** Whether a new contact group was created or an existing one was extended. */\n readonly mode: RegisterExternalAddressMode;\n /** Echoed input, needed by the host to persist the returned proof material. */\n readonly contactName: string;\n readonly scope: string;\n readonly identifier: Uint8Array;\n readonly blockchainFamily: string;\n readonly chainId?: bigint;\n /** Device-issued proof material. */\n readonly groupHandle: Uint8Array;\n readonly hmacProof: Uint8Array;\n readonly hmacRest: Uint8Array;\n};\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["RegisterExternalAddress_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=require("@ledgerhq/device-management-kit"),i=require("../../api/model/ContactsVersionRequirements"),t=require("./contactsVersionGuards");const u=(()=>{const e=(0,i.resolveContactsVersionRequirements)(s.DeviceModelId.FLEX);if(!e.supported)throw new Error("Flex must be supported");return e})(),p=u.minOsVersion,d=(()=>{const e=u.minAppVersion[i.ETHEREUM_APP_NAME];if(e===void 0)throw new Error("Ethereum min version required");return e})(),c="0.0.1";function o({osVersion:e=p,modelId:a=s.DeviceModelId.FLEX}={}){return{sessionStateType:s.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:s.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:i.ETHEREUM_APP_NAME,version:"0.0.0"},deviceModelId:a,firmwareVersion:{mcu:"1.0.0",bootloader:"1.0.0",os:e},isSecureConnectionAllowed:!1}}function n(e){return{getDeviceSessionState:()=>e}}function r(e=i.ETHEREUM_APP_NAME,a=d){return{name:e,version:a}}describe("isContactsAppVersionSupportedForSession",()=>{it("returns true when the model and app version meet the minimums",()=>{const e=n(o());expect((0,t.isContactsAppVersionSupportedForSession)(e,r())).toBe(!0)}),it("returns true regardless of OS version, since app-owned operations are not gated by it",()=>{const e=n(o({osVersion:c}));expect((0,t.isContactsAppVersionSupportedForSession)(e,r())).toBe(!0)}),it("returns false on an unsupported device model",()=>{const e=n(o({modelId:s.DeviceModelId.NANO_S}));expect((0,t.isContactsAppVersionSupportedForSession)(e,r())).toBe(!1)}),it("returns false when the app version is below the minimum",()=>{const e=n(o());expect((0,t.isContactsAppVersionSupportedForSession)(e,r(i.ETHEREUM_APP_NAME,c))).toBe(!1)}),it("returns false when the running app is unknown to Contacts",()=>{const e=n(o());expect((0,t.isContactsAppVersionSupportedForSession)(e,r("Bitcoin"))).toBe(!1)}),it.each([i.TRON_APP_NAME,i.SOLANA_APP_NAME])("returns true for the %s app at its minimum version",e=>{const a=u.minAppVersion[e];if(a===void 0)throw new Error(`${e} min version`);const l=n(o());expect((0,t.isContactsAppVersionSupportedForSession)(l,r(e,a))).toBe(!0)}),it("returns false for a Solana app below its minimum version",()=>{const e=n(o());expect((0,t.isContactsAppVersionSupportedForSession)(e,r(i.SOLANA_APP_NAME,"1.16.0"))).toBe(!1)}),it("returns true for a prerelease build of the minimum app version",()=>{const e=n(o());expect((0,t.isContactsAppVersionSupportedForSession)(e,r(i.ETHEREUM_APP_NAME,`${d}-rc2`))).toBe(!0)}),it("returns false when the device session has no running app",()=>{const e=n({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:s.DeviceStatus.CONNECTED,deviceModelId:s.DeviceModelId.FLEX});expect((0,t.isContactsAppVersionSupportedForSession)(e,r())).toBe(!1)})});describe("isContactsOsVersionSupportedForSession",()=>{it("returns true when the model and the caller's OS version meet the minimums",()=>{const e=n(o());expect((0,t.isContactsOsVersionSupportedForSession)(e,p)).toBe(!0)}),it("returns false on an unsupported device model",()=>{const e=n(o({modelId:s.DeviceModelId.NANO_S}));expect((0,t.isContactsOsVersionSupportedForSession)(e,p)).toBe(!1)}),it("returns false when the caller's OS version is below the minimum",()=>{const e=n(o());expect((0,t.isContactsOsVersionSupportedForSession)(e,c)).toBe(!1)}),it("returns true for a release candidate of the minimum OS version",()=>{const e=n(o());expect((0,t.isContactsOsVersionSupportedForSession)(e,`${p}-rc2`)).toBe(!0)}),it("returns false for a release candidate below the minimum OS version",()=>{const e=n(o());expect((0,t.isContactsOsVersionSupportedForSession)(e,`${c}-rc2`)).toBe(!1)}),it("never reads the OS version from the device session state",()=>{const e=n({sessionStateType:s.DeviceSessionStateType.Connected,deviceStatus:s.DeviceStatus.CONNECTED,deviceModelId:s.DeviceModelId.FLEX});expect((0,t.isContactsOsVersionSupportedForSession)(e,p)).toBe(!0),expect((0,t.isContactsOsVersionSupportedForSession)(e,c)).toBe(!1)})});
|
|
2
2
|
//# sourceMappingURL=contactsVersionGuards.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/app-binder/contactsVersionGuards.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n type InternalApi,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ETHEREUM_APP_NAME,\n resolveContactsVersionRequirements,\n} from \"@api/model/ContactsVersionRequirements\";\n\nimport {\n isContactsAppVersionSupportedForSession,\n isContactsOsVersionSupportedForSession,\n type RunningApp,\n} from \"./contactsVersionGuards\";\n\nconst flexSupport = (() => {\n const requirement = resolveContactsVersionRequirements(DeviceModelId.FLEX);\n if (!requirement.supported) throw new Error(\"Flex must be supported\");\n return requirement;\n})();\n\nconst MIN_OS_VERSION = flexSupport.minOsVersion;\nconst MIN_APP_VERSION = (() => {\n const version = flexSupport.minAppVersion[ETHEREUM_APP_NAME];\n if (version === undefined) throw new Error(\"Ethereum min version required\");\n return version;\n})();\nconst BELOW_ANY_VERSION = \"0.0.1\";\n\ntype ReadyStateOptions = {\n osVersion?: string;\n modelId?: DeviceModelId;\n};\n\nfunction createReadyState({\n osVersion = MIN_OS_VERSION,\n modelId = DeviceModelId.FLEX,\n}: ReadyStateOptions = {}) {\n return {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: ETHEREUM_APP_NAME, version: \"0.0.0\" },\n deviceModelId: modelId,\n firmwareVersion: { mcu: \"1.0.0\", bootloader: \"1.0.0\", os: osVersion },\n isSecureConnectionAllowed: false,\n };\n}\n\nfunction createInternalApi(deviceState: object): InternalApi {\n return {\n getDeviceSessionState: () => deviceState,\n } as unknown as InternalApi;\n}\n\n// The running app identity now comes from the caller (a fresh\n// WaitForAppAndVersion result), not the device session state.\nfunction runningApp(\n name = ETHEREUM_APP_NAME,\n version = MIN_APP_VERSION,\n): RunningApp {\n return { name, version };\n}\n\ndescribe(\"isContactsAppVersionSupportedForSession\", () => {\n it(\"returns true when the model and app version meet the minimums\", () => {\n const api = createInternalApi(createReadyState());\n expect(isContactsAppVersionSupportedForSession(api, runningApp())).toBe(\n true,\n );\n });\n\n it(\"returns true regardless of OS version, since app-owned operations are not gated by it\", () => {\n const api = createInternalApi(\n createReadyState({ osVersion: BELOW_ANY_VERSION }),\n );\n expect(isContactsAppVersionSupportedForSession(api, runningApp())).toBe(\n true,\n );\n });\n\n it(\"returns false on an unsupported device model\", () => {\n const api = createInternalApi(\n createReadyState({ modelId: DeviceModelId.NANO_S }),\n );\n expect(isContactsAppVersionSupportedForSession(api, runningApp())).toBe(\n false,\n );\n });\n\n it(\"returns false when the app version is below the minimum\", () => {\n const api = createInternalApi(createReadyState());\n expect(\n isContactsAppVersionSupportedForSession(\n api,\n runningApp(ETHEREUM_APP_NAME, BELOW_ANY_VERSION),\n ),\n ).toBe(false);\n });\n\n it(\"returns false when the running app is unknown to Contacts\", () => {\n const api = createInternalApi(createReadyState());\n expect(\n isContactsAppVersionSupportedForSession(api, runningApp(\"Bitcoin\")),\n ).toBe(false);\n });\n\n it(\"returns true for a prerelease build of the minimum app version\", () => {\n const api = createInternalApi(createReadyState());\n expect(\n isContactsAppVersionSupportedForSession(\n api,\n runningApp(ETHEREUM_APP_NAME, `${MIN_APP_VERSION}-rc2`),\n ),\n ).toBe(true);\n });\n\n it(\"returns false when the device session has no running app\", () => {\n const api = createInternalApi({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n expect(isContactsAppVersionSupportedForSession(api, runningApp())).toBe(\n false,\n );\n });\n});\n\ndescribe(\"isContactsOsVersionSupportedForSession\", () => {\n it(\"returns true when the model and the caller's OS version meet the minimums\", () => {\n const api = createInternalApi(createReadyState());\n expect(isContactsOsVersionSupportedForSession(api, MIN_OS_VERSION)).toBe(\n true,\n );\n });\n\n it(\"returns false on an unsupported device model\", () => {\n const api = createInternalApi(\n createReadyState({ modelId: DeviceModelId.NANO_S }),\n );\n expect(isContactsOsVersionSupportedForSession(api, MIN_OS_VERSION)).toBe(\n false,\n );\n });\n\n it(\"returns false when the caller's OS version is below the minimum\", () => {\n const api = createInternalApi(createReadyState());\n expect(isContactsOsVersionSupportedForSession(api, BELOW_ANY_VERSION)).toBe(\n false,\n );\n });\n\n it(\"returns true for a release candidate of the minimum OS version\", () => {\n const api = createInternalApi(createReadyState());\n expect(\n isContactsOsVersionSupportedForSession(api, `${MIN_OS_VERSION}-rc2`),\n ).toBe(true);\n });\n\n it(\"returns false for a release candidate below the minimum OS version\", () => {\n const api = createInternalApi(createReadyState());\n expect(\n isContactsOsVersionSupportedForSession(api, `${BELOW_ANY_VERSION}-rc2`),\n ).toBe(false);\n });\n\n it(\"never reads the OS version from the device session state\", () => {\n // A session with no firmwareVersion at all: the guard must rely solely on\n // the caller-supplied version and still resolve support.\n const api = createInternalApi({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n expect(isContactsOsVersionSupportedForSession(api, MIN_OS_VERSION)).toBe(\n true,\n );\n expect(isContactsOsVersionSupportedForSession(api, BELOW_ANY_VERSION)).toBe(\n false,\n );\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAKO,2CAEPC,
|
|
6
|
-
"names": ["import_device_management_kit", "import_ContactsVersionRequirements", "import_contactsVersionGuards", "flexSupport", "requirement", "MIN_OS_VERSION", "MIN_APP_VERSION", "version", "BELOW_ANY_VERSION", "createReadyState", "osVersion", "modelId", "createInternalApi", "deviceState", "runningApp", "name", "api"]
|
|
4
|
+
"sourcesContent": ["import {\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n type InternalApi,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ETHEREUM_APP_NAME,\n resolveContactsVersionRequirements,\n SOLANA_APP_NAME,\n TRON_APP_NAME,\n} from \"@api/model/ContactsVersionRequirements\";\n\nimport {\n isContactsAppVersionSupportedForSession,\n isContactsOsVersionSupportedForSession,\n type RunningApp,\n} from \"./contactsVersionGuards\";\n\nconst flexSupport = (() => {\n const requirement = resolveContactsVersionRequirements(DeviceModelId.FLEX);\n if (!requirement.supported) throw new Error(\"Flex must be supported\");\n return requirement;\n})();\n\nconst MIN_OS_VERSION = flexSupport.minOsVersion;\nconst MIN_APP_VERSION = (() => {\n const version = flexSupport.minAppVersion[ETHEREUM_APP_NAME];\n if (version === undefined) throw new Error(\"Ethereum min version required\");\n return version;\n})();\nconst BELOW_ANY_VERSION = \"0.0.1\";\n\ntype ReadyStateOptions = {\n osVersion?: string;\n modelId?: DeviceModelId;\n};\n\nfunction createReadyState({\n osVersion = MIN_OS_VERSION,\n modelId = DeviceModelId.FLEX,\n}: ReadyStateOptions = {}) {\n return {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: ETHEREUM_APP_NAME, version: \"0.0.0\" },\n deviceModelId: modelId,\n firmwareVersion: { mcu: \"1.0.0\", bootloader: \"1.0.0\", os: osVersion },\n isSecureConnectionAllowed: false,\n };\n}\n\nfunction createInternalApi(deviceState: object): InternalApi {\n return {\n getDeviceSessionState: () => deviceState,\n } as unknown as InternalApi;\n}\n\n// The running app identity now comes from the caller (a fresh\n// WaitForAppAndVersion result), not the device session state.\nfunction runningApp(\n name = ETHEREUM_APP_NAME,\n version = MIN_APP_VERSION,\n): RunningApp {\n return { name, version };\n}\n\ndescribe(\"isContactsAppVersionSupportedForSession\", () => {\n it(\"returns true when the model and app version meet the minimums\", () => {\n const api = createInternalApi(createReadyState());\n expect(isContactsAppVersionSupportedForSession(api, runningApp())).toBe(\n true,\n );\n });\n\n it(\"returns true regardless of OS version, since app-owned operations are not gated by it\", () => {\n const api = createInternalApi(\n createReadyState({ osVersion: BELOW_ANY_VERSION }),\n );\n expect(isContactsAppVersionSupportedForSession(api, runningApp())).toBe(\n true,\n );\n });\n\n it(\"returns false on an unsupported device model\", () => {\n const api = createInternalApi(\n createReadyState({ modelId: DeviceModelId.NANO_S }),\n );\n expect(isContactsAppVersionSupportedForSession(api, runningApp())).toBe(\n false,\n );\n });\n\n it(\"returns false when the app version is below the minimum\", () => {\n const api = createInternalApi(createReadyState());\n expect(\n isContactsAppVersionSupportedForSession(\n api,\n runningApp(ETHEREUM_APP_NAME, BELOW_ANY_VERSION),\n ),\n ).toBe(false);\n });\n\n it(\"returns false when the running app is unknown to Contacts\", () => {\n const api = createInternalApi(createReadyState());\n expect(\n isContactsAppVersionSupportedForSession(api, runningApp(\"Bitcoin\")),\n ).toBe(false);\n });\n\n it.each([TRON_APP_NAME, SOLANA_APP_NAME])(\n \"returns true for the %s app at its minimum version\",\n (appName) => {\n const version = flexSupport.minAppVersion[appName];\n if (version === undefined) throw new Error(`${appName} min version`);\n const api = createInternalApi(createReadyState());\n expect(\n isContactsAppVersionSupportedForSession(\n api,\n runningApp(appName, version),\n ),\n ).toBe(true);\n },\n );\n\n it(\"returns false for a Solana app below its minimum version\", () => {\n const api = createInternalApi(createReadyState());\n expect(\n isContactsAppVersionSupportedForSession(\n api,\n runningApp(SOLANA_APP_NAME, \"1.16.0\"),\n ),\n ).toBe(false);\n });\n\n it(\"returns true for a prerelease build of the minimum app version\", () => {\n const api = createInternalApi(createReadyState());\n expect(\n isContactsAppVersionSupportedForSession(\n api,\n runningApp(ETHEREUM_APP_NAME, `${MIN_APP_VERSION}-rc2`),\n ),\n ).toBe(true);\n });\n\n it(\"returns false when the device session has no running app\", () => {\n const api = createInternalApi({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n expect(isContactsAppVersionSupportedForSession(api, runningApp())).toBe(\n false,\n );\n });\n});\n\ndescribe(\"isContactsOsVersionSupportedForSession\", () => {\n it(\"returns true when the model and the caller's OS version meet the minimums\", () => {\n const api = createInternalApi(createReadyState());\n expect(isContactsOsVersionSupportedForSession(api, MIN_OS_VERSION)).toBe(\n true,\n );\n });\n\n it(\"returns false on an unsupported device model\", () => {\n const api = createInternalApi(\n createReadyState({ modelId: DeviceModelId.NANO_S }),\n );\n expect(isContactsOsVersionSupportedForSession(api, MIN_OS_VERSION)).toBe(\n false,\n );\n });\n\n it(\"returns false when the caller's OS version is below the minimum\", () => {\n const api = createInternalApi(createReadyState());\n expect(isContactsOsVersionSupportedForSession(api, BELOW_ANY_VERSION)).toBe(\n false,\n );\n });\n\n it(\"returns true for a release candidate of the minimum OS version\", () => {\n const api = createInternalApi(createReadyState());\n expect(\n isContactsOsVersionSupportedForSession(api, `${MIN_OS_VERSION}-rc2`),\n ).toBe(true);\n });\n\n it(\"returns false for a release candidate below the minimum OS version\", () => {\n const api = createInternalApi(createReadyState());\n expect(\n isContactsOsVersionSupportedForSession(api, `${BELOW_ANY_VERSION}-rc2`),\n ).toBe(false);\n });\n\n it(\"never reads the OS version from the device session state\", () => {\n // A session with no firmwareVersion at all: the guard must rely solely on\n // the caller-supplied version and still resolve support.\n const api = createInternalApi({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n expect(isContactsOsVersionSupportedForSession(api, MIN_OS_VERSION)).toBe(\n true,\n );\n expect(isContactsOsVersionSupportedForSession(api, BELOW_ANY_VERSION)).toBe(\n false,\n );\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_device_management_kit", "import_ContactsVersionRequirements", "import_contactsVersionGuards", "flexSupport", "requirement", "MIN_OS_VERSION", "MIN_APP_VERSION", "version", "BELOW_ANY_VERSION", "createReadyState", "osVersion", "modelId", "createInternalApi", "deviceState", "runningApp", "name", "api", "appName"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var c=(t,i)=>{for(var a in i)d(t,a,{get:i[a],enumerable:!0})},s=(t,i,a,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of o(i))!f.call(t,r)&&r!==a&&d(t,r,{get:()=>i[r],enumerable:!(n=l(i,r))||n.enumerable});return t};var E=t=>s(d({},"__esModule",{value:!0}),t);var m={};c(m,{validateEditExternalAddressIdentifierInput:()=>h});module.exports=E(m);var e=require("../../../app-binder/model/contactsValidation");const I=e.HMAC_PROOF_LENGTH;function h(t){try{return(0,e.validatePrintableLabel)(t.contactName,{field:"contactName",bufferLength:e.CONTACT_NAME_BUFFER_LENGTH}),(0,e.validatePrintableLabel)(t.scope,{field:"scope",bufferLength:e.SCOPE_BUFFER_LENGTH}),(0,e.validateFamilyIdentifiers)({blockchainFamily:t.blockchainFamily,identifiers:[{field:"previousIdentifier",value:t.previousIdentifier},{field:"newIdentifier",value:t.newIdentifier}],chainId:t.chainId}),(0,e.validateByteLength)(t.groupHandle,{field:"groupHandle",expectedBytes:e.GROUP_HANDLE_SIZE}),(0,e.validateByteLength)(t.hmacProof,{field:"hmacProof",expectedBytes:e.HMAC_PROOF_LENGTH}),(0,e.validateByteLength)(t.hmacRest,{field:"hmacRest",expectedBytes:I}),null}catch(i){if(i instanceof e.ContactsValidationError)return i;throw i}}0&&(module.exports={validateEditExternalAddressIdentifierInput});
|
|
2
2
|
//# sourceMappingURL=validateEditExternalAddressIdentifierInput.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/app-binder/device-action/EditExternalAddressIdentifier/validateEditExternalAddressIdentifierInput.ts"],
|
|
4
|
-
"sourcesContent": ["import { type EditExternalAddressIdentifierInput } from \"@api/model/EditExternalAddressIdentifier\";\nimport {
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gDAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,
|
|
6
|
-
"names": ["validateEditExternalAddressIdentifierInput_exports", "__export", "validateEditExternalAddressIdentifierInput", "__toCommonJS", "
|
|
4
|
+
"sourcesContent": ["import { type EditExternalAddressIdentifierInput } from \"@api/model/EditExternalAddressIdentifier\";\nimport {\n CONTACT_NAME_BUFFER_LENGTH,\n ContactsValidationError,\n GROUP_HANDLE_SIZE,\n HMAC_PROOF_LENGTH,\n SCOPE_BUFFER_LENGTH,\n validateByteLength,\n validateFamilyIdentifiers,\n validatePrintableLabel,\n} from \"@internal/app-binder/model/contactsValidation\";\n\n// The address-level proof (`hmac_rest`) shares the 32-byte HMAC width.\nconst HMAC_REST_LENGTH = HMAC_PROOF_LENGTH;\n\n/**\n * Validate the caller input for Edit External Address Identifier. Returns the\n * first `ContactsValidationError`, or `null` when valid. Non-throwing so the\n * device action can surface it as a typed terminal error state.\n */\nexport function validateEditExternalAddressIdentifierInput(\n input: EditExternalAddressIdentifierInput,\n): ContactsValidationError | null {\n try {\n validatePrintableLabel(input.contactName, {\n field: \"contactName\",\n bufferLength: CONTACT_NAME_BUFFER_LENGTH,\n });\n validatePrintableLabel(input.scope, {\n field: \"scope\",\n bufferLength: SCOPE_BUFFER_LENGTH,\n });\n\n validateFamilyIdentifiers({\n blockchainFamily: input.blockchainFamily,\n identifiers: [\n { field: \"previousIdentifier\", value: input.previousIdentifier },\n { field: \"newIdentifier\", value: input.newIdentifier },\n ],\n chainId: input.chainId,\n });\n\n validateByteLength(input.groupHandle, {\n field: \"groupHandle\",\n expectedBytes: GROUP_HANDLE_SIZE,\n });\n validateByteLength(input.hmacProof, {\n field: \"hmacProof\",\n expectedBytes: HMAC_PROOF_LENGTH,\n });\n validateByteLength(input.hmacRest, {\n field: \"hmacRest\",\n expectedBytes: HMAC_REST_LENGTH,\n });\n\n return null;\n } catch (error) {\n if (error instanceof ContactsValidationError) {\n return error;\n }\n throw error;\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gDAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EASO,yDAGP,MAAMC,EAAmB,oBAOlB,SAASH,EACdI,EACgC,CAChC,GAAI,CACF,mCAAuBA,EAAM,YAAa,CACxC,MAAO,cACP,aAAc,4BAChB,CAAC,KACD,0BAAuBA,EAAM,MAAO,CAClC,MAAO,QACP,aAAc,qBAChB,CAAC,KAED,6BAA0B,CACxB,iBAAkBA,EAAM,iBACxB,YAAa,CACX,CAAE,MAAO,qBAAsB,MAAOA,EAAM,kBAAmB,EAC/D,CAAE,MAAO,gBAAiB,MAAOA,EAAM,aAAc,CACvD,EACA,QAASA,EAAM,OACjB,CAAC,KAED,sBAAmBA,EAAM,YAAa,CACpC,MAAO,cACP,cAAe,mBACjB,CAAC,KACD,sBAAmBA,EAAM,UAAW,CAClC,MAAO,YACP,cAAe,mBACjB,CAAC,KACD,sBAAmBA,EAAM,SAAU,CACjC,MAAO,WACP,cAAeD,CACjB,CAAC,EAEM,IACT,OAASE,EAAO,CACd,GAAIA,aAAiB,0BACnB,OAAOA,EAET,MAAMA,CACR,CACF",
|
|
6
|
+
"names": ["validateEditExternalAddressIdentifierInput_exports", "__export", "validateEditExternalAddressIdentifierInput", "__toCommonJS", "import_contactsValidation", "HMAC_REST_LENGTH", "input", "error"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=require("../../../app-binder/model/contactsValidation"),t=require("./validateEditExternalAddressIdentifierInput");const r={contactName:"Alice",scope:"Eth main",previousIdentifier:new Uint8Array(20).fill(17),newIdentifier:new Uint8Array(20).fill(34),blockchainFamily:"ethereum",chainId:1n,groupHandle:new Uint8Array(64).fill(204),hmacProof:new Uint8Array(32).fill(221),hmacRest:new Uint8Array(32).fill(170)};describe("validateEditExternalAddressIdentifierInput",()=>{it("returns null for a valid input",()=>{expect((0,t.validateEditExternalAddressIdentifierInput)(r)).toBeNull()}),it("rejects an empty contactName",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,contactName:""});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects a non-printable scope",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,scope:"caf\xE9"});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects an unsupported blockchain family",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,blockchainFamily:"dogecoin"});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects a previousIdentifier of the wrong length for Ethereum",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,previousIdentifier:new Uint8Array(19).fill(17)});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects a newIdentifier of the wrong length for Ethereum",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,newIdentifier:new Uint8Array(21).fill(34)});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("requires chainId for the Ethereum family",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,chainId:void 0});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects a groupHandle of the wrong length",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,groupHandle:new Uint8Array(63).fill(204)});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects an hmacProof of the wrong length",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,hmacProof:new Uint8Array(31).fill(221)});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects an hmacRest of the wrong length",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,hmacRest:new Uint8Array(33).fill(170)});expect(e).toBeInstanceOf(n.ContactsValidationError)})});
|
|
1
|
+
"use strict";var n=require("../../../app-binder/model/contactsValidation"),t=require("./validateEditExternalAddressIdentifierInput");const r={contactName:"Alice",scope:"Eth main",previousIdentifier:new Uint8Array(20).fill(17),newIdentifier:new Uint8Array(20).fill(34),blockchainFamily:"ethereum",chainId:1n,groupHandle:new Uint8Array(64).fill(204),hmacProof:new Uint8Array(32).fill(221),hmacRest:new Uint8Array(32).fill(170)};describe("validateEditExternalAddressIdentifierInput",()=>{it("returns null for a valid input",()=>{expect((0,t.validateEditExternalAddressIdentifierInput)(r)).toBeNull()}),it("rejects an empty contactName",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,contactName:""});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects a non-printable scope",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,scope:"caf\xE9"});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects an unsupported blockchain family",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,blockchainFamily:"dogecoin"});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects a previousIdentifier of the wrong length for Ethereum",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,previousIdentifier:new Uint8Array(19).fill(17)});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects a newIdentifier of the wrong length for Ethereum",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,newIdentifier:new Uint8Array(21).fill(34)});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("requires chainId for the Ethereum family",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,chainId:void 0});expect(e).toBeInstanceOf(n.ContactsValidationError)}),describe("Solana",()=>{const e={...r,previousIdentifier:new Uint8Array(32).fill(17),newIdentifier:new Uint8Array(32).fill(34),blockchainFamily:"solana",chainId:void 0};it("accepts 32-byte public keys without chainId",()=>{expect((0,t.validateEditExternalAddressIdentifierInput)(e)).toBeNull()}),it.each(["previousIdentifier","newIdentifier"])("rejects a %s that is not 32 bytes",i=>{const a=(0,t.validateEditExternalAddressIdentifierInput)({...e,[i]:new Uint8Array(20)});expect(a).toBeInstanceOf(n.ContactsValidationError),expect(a?.message).toContain(i)}),it("rejects a chainId",()=>{expect((0,t.validateEditExternalAddressIdentifierInput)({...e,chainId:1n})).toBeInstanceOf(n.ContactsValidationError)})}),it("rejects a groupHandle of the wrong length",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,groupHandle:new Uint8Array(63).fill(204)});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects an hmacProof of the wrong length",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,hmacProof:new Uint8Array(31).fill(221)});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects an hmacRest of the wrong length",()=>{const e=(0,t.validateEditExternalAddressIdentifierInput)({...r,hmacRest:new Uint8Array(33).fill(170)});expect(e).toBeInstanceOf(n.ContactsValidationError)})});
|
|
2
2
|
//# sourceMappingURL=validateEditExternalAddressIdentifierInput.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/app-binder/device-action/EditExternalAddressIdentifier/validateEditExternalAddressIdentifierInput.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type EditExternalAddressIdentifierInput } from \"@api/model/EditExternalAddressIdentifier\";\nimport { ContactsValidationError } from \"@internal/app-binder/model/contactsValidation\";\n\nimport { validateEditExternalAddressIdentifierInput } from \"./validateEditExternalAddressIdentifierInput\";\n\nconst VALID_INPUT: EditExternalAddressIdentifierInput = {\n contactName: \"Alice\",\n scope: \"Eth main\",\n previousIdentifier: new Uint8Array(20).fill(0x11),\n newIdentifier: new Uint8Array(20).fill(0x22),\n blockchainFamily: \"ethereum\",\n chainId: 1n,\n groupHandle: new Uint8Array(64).fill(0xcc),\n hmacProof: new Uint8Array(32).fill(0xdd),\n hmacRest: new Uint8Array(32).fill(0xaa),\n};\n\ndescribe(\"validateEditExternalAddressIdentifierInput\", () => {\n it(\"returns null for a valid input\", () => {\n expect(validateEditExternalAddressIdentifierInput(VALID_INPUT)).toBeNull();\n });\n\n it(\"rejects an empty contactName\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n contactName: \"\",\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects a non-printable scope\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n scope: \"caf\u00E9\", // 0xC3 0xA9 is non-ASCII\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects an unsupported blockchain family\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n blockchainFamily: \"dogecoin\",\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects a previousIdentifier of the wrong length for Ethereum\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n previousIdentifier: new Uint8Array(19).fill(0x11),\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects a newIdentifier of the wrong length for Ethereum\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n newIdentifier: new Uint8Array(21).fill(0x22),\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"requires chainId for the Ethereum family\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n chainId: undefined,\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects a groupHandle of the wrong length\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n groupHandle: new Uint8Array(63).fill(0xcc),\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects an hmacProof of the wrong length\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n hmacProof: new Uint8Array(31).fill(0xdd),\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects an hmacRest of the wrong length\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n hmacRest: new Uint8Array(33).fill(0xaa),\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n});\n"],
|
|
5
|
-
"mappings": "aACA,IAAAA,EAAwC,yDAExCC,EAA2D,wDAE3D,MAAMC,EAAkD,CACtD,YAAa,QACb,MAAO,WACP,mBAAoB,IAAI,WAAW,EAAE,EAAE,KAAK,EAAI,EAChD,cAAe,IAAI,WAAW,EAAE,EAAE,KAAK,EAAI,EAC3C,iBAAkB,WAClB,QAAS,GACT,YAAa,IAAI,WAAW,EAAE,EAAE,KAAK,GAAI,EACzC,UAAW,IAAI,WAAW,EAAE,EAAE,KAAK,GAAI,EACvC,SAAU,IAAI,WAAW,EAAE,EAAE,KAAK,GAAI,CACxC,EAEA,SAAS,6CAA8C,IAAM,CAC3D,GAAG,iCAAkC,IAAM,CACzC,UAAO,8CAA2CA,CAAW,CAAC,EAAE,SAAS,CAC3E,CAAC,EAED,GAAG,+BAAgC,IAAM,CACvC,MAAMC,KAAQ,8CAA2C,CACvD,GAAGD,EACH,YAAa,EACf,CAAC,EACD,OAAOC,CAAK,EAAE,eAAe,yBAAuB,CACtD,CAAC,EAED,GAAG,gCAAiC,IAAM,CACxC,MAAMA,KAAQ,8CAA2C,CACvD,GAAGD,EACH,MAAO,SACT,CAAC,EACD,OAAOC,CAAK,EAAE,eAAe,yBAAuB,CACtD,CAAC,EAED,GAAG,2CAA4C,IAAM,CACnD,MAAMA,KAAQ,8CAA2C,CACvD,GAAGD,EACH,iBAAkB,UACpB,CAAC,EACD,OAAOC,CAAK,EAAE,eAAe,yBAAuB,CACtD,CAAC,EAED,GAAG,gEAAiE,IAAM,CACxE,MAAMA,KAAQ,8CAA2C,CACvD,GAAGD,EACH,mBAAoB,IAAI,WAAW,EAAE,EAAE,KAAK,EAAI,CAClD,CAAC,EACD,OAAOC,CAAK,EAAE,eAAe,yBAAuB,CACtD,CAAC,EAED,GAAG,2DAA4D,IAAM,CACnE,MAAMA,KAAQ,8CAA2C,CACvD,GAAGD,EACH,cAAe,IAAI,WAAW,EAAE,EAAE,KAAK,EAAI,CAC7C,CAAC,EACD,OAAOC,CAAK,EAAE,eAAe,yBAAuB,CACtD,CAAC,EAED,GAAG,2CAA4C,IAAM,CACnD,MAAMA,KAAQ,8CAA2C,CACvD,GAAGD,EACH,QAAS,MACX,CAAC,EACD,OAAOC,CAAK,EAAE,eAAe,yBAAuB,CACtD,CAAC,EAED,GAAG,4CAA6C,IAAM,CACpD,
|
|
6
|
-
"names": ["import_contactsValidation", "import_validateEditExternalAddressIdentifierInput", "VALID_INPUT", "error"]
|
|
4
|
+
"sourcesContent": ["import { type EditExternalAddressIdentifierInput } from \"@api/model/EditExternalAddressIdentifier\";\nimport { ContactsValidationError } from \"@internal/app-binder/model/contactsValidation\";\n\nimport { validateEditExternalAddressIdentifierInput } from \"./validateEditExternalAddressIdentifierInput\";\n\nconst VALID_INPUT: EditExternalAddressIdentifierInput = {\n contactName: \"Alice\",\n scope: \"Eth main\",\n previousIdentifier: new Uint8Array(20).fill(0x11),\n newIdentifier: new Uint8Array(20).fill(0x22),\n blockchainFamily: \"ethereum\",\n chainId: 1n,\n groupHandle: new Uint8Array(64).fill(0xcc),\n hmacProof: new Uint8Array(32).fill(0xdd),\n hmacRest: new Uint8Array(32).fill(0xaa),\n};\n\ndescribe(\"validateEditExternalAddressIdentifierInput\", () => {\n it(\"returns null for a valid input\", () => {\n expect(validateEditExternalAddressIdentifierInput(VALID_INPUT)).toBeNull();\n });\n\n it(\"rejects an empty contactName\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n contactName: \"\",\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects a non-printable scope\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n scope: \"caf\u00E9\", // 0xC3 0xA9 is non-ASCII\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects an unsupported blockchain family\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n blockchainFamily: \"dogecoin\",\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects a previousIdentifier of the wrong length for Ethereum\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n previousIdentifier: new Uint8Array(19).fill(0x11),\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects a newIdentifier of the wrong length for Ethereum\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n newIdentifier: new Uint8Array(21).fill(0x22),\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"requires chainId for the Ethereum family\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n chainId: undefined,\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n describe(\"Solana\", () => {\n const SOLANA_INPUT: EditExternalAddressIdentifierInput = {\n ...VALID_INPUT,\n previousIdentifier: new Uint8Array(32).fill(0x11),\n newIdentifier: new Uint8Array(32).fill(0x22),\n blockchainFamily: \"solana\",\n chainId: undefined,\n };\n\n it(\"accepts 32-byte public keys without chainId\", () => {\n expect(\n validateEditExternalAddressIdentifierInput(SOLANA_INPUT),\n ).toBeNull();\n });\n\n it.each([\"previousIdentifier\", \"newIdentifier\"] as const)(\n \"rejects a %s that is not 32 bytes\",\n (field) => {\n const error = validateEditExternalAddressIdentifierInput({\n ...SOLANA_INPUT,\n [field]: new Uint8Array(20),\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n expect(error?.message).toContain(field);\n },\n );\n\n it(\"rejects a chainId\", () => {\n expect(\n validateEditExternalAddressIdentifierInput({\n ...SOLANA_INPUT,\n chainId: 1n,\n }),\n ).toBeInstanceOf(ContactsValidationError);\n });\n });\n\n it(\"rejects a groupHandle of the wrong length\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n groupHandle: new Uint8Array(63).fill(0xcc),\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects an hmacProof of the wrong length\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n hmacProof: new Uint8Array(31).fill(0xdd),\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n\n it(\"rejects an hmacRest of the wrong length\", () => {\n const error = validateEditExternalAddressIdentifierInput({\n ...VALID_INPUT,\n hmacRest: new Uint8Array(33).fill(0xaa),\n });\n expect(error).toBeInstanceOf(ContactsValidationError);\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_contactsValidation", "import_validateEditExternalAddressIdentifierInput", "VALID_INPUT", "error", "SOLANA_INPUT", "field"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var f=(t,r)=>{for(var i in r)o(t,i,{get:r[i],enumerable:!0})},s=(t,r,i,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of l(r))!n.call(t,a)&&a!==i&&o(t,a,{get:()=>r[a],enumerable:!(d=c(r,a))||d.enumerable});return t};var E=t=>s(o({},"__esModule",{value:!0}),t);var p={};f(p,{validateEditExternalAddressScopeInput:()=>m});module.exports=E(p);var e=require("../../../app-binder/model/contactsValidation");const h=e.HMAC_PROOF_LENGTH;function m(t){try{return(0,e.validatePrintableLabel)(t.contactName,{field:"contactName",bufferLength:e.CONTACT_NAME_BUFFER_LENGTH}),(0,e.validatePrintableLabel)(t.previousScope,{field:"previousScope",bufferLength:e.SCOPE_BUFFER_LENGTH}),(0,e.validatePrintableLabel)(t.newScope,{field:"newScope",bufferLength:e.SCOPE_BUFFER_LENGTH}),(0,e.validateFamilyIdentifiers)({blockchainFamily:t.blockchainFamily,identifiers:[{field:"identifier",value:t.identifier}],chainId:t.chainId}),(0,e.validateByteLength)(t.groupHandle,{field:"groupHandle",expectedBytes:e.GROUP_HANDLE_SIZE}),(0,e.validateByteLength)(t.hmacProof,{field:"hmacProof",expectedBytes:e.HMAC_PROOF_LENGTH}),(0,e.validateByteLength)(t.hmacRest,{field:"hmacRest",expectedBytes:h}),null}catch(r){if(r instanceof e.ContactsValidationError)return r;throw r}}0&&(module.exports={validateEditExternalAddressScopeInput});
|
|
2
2
|
//# sourceMappingURL=validateEditExternalAddressScopeInput.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/app-binder/device-action/EditExternalAddressScope/validateEditExternalAddressScopeInput.ts"],
|
|
4
|
-
"sourcesContent": ["import { type EditExternalAddressScopeInput } from \"@api/model/EditExternalAddressScope\";\nimport {
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2CAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,
|
|
6
|
-
"names": ["validateEditExternalAddressScopeInput_exports", "__export", "validateEditExternalAddressScopeInput", "__toCommonJS", "
|
|
4
|
+
"sourcesContent": ["import { type EditExternalAddressScopeInput } from \"@api/model/EditExternalAddressScope\";\nimport {\n CONTACT_NAME_BUFFER_LENGTH,\n ContactsValidationError,\n GROUP_HANDLE_SIZE,\n HMAC_PROOF_LENGTH,\n SCOPE_BUFFER_LENGTH,\n validateByteLength,\n validateFamilyIdentifiers,\n validatePrintableLabel,\n} from \"@internal/app-binder/model/contactsValidation\";\n\n// The address-level proof (`hmac_rest`) shares the 32-byte HMAC width.\nconst HMAC_REST_LENGTH = HMAC_PROOF_LENGTH;\n\n/**\n * Validate the caller input for Edit External Address Scope. Returns the first\n * `ContactsValidationError`, or `null` when valid. Non-throwing so the device\n * action can surface it as a typed terminal error state.\n */\nexport function validateEditExternalAddressScopeInput(\n input: EditExternalAddressScopeInput,\n): ContactsValidationError | null {\n try {\n validatePrintableLabel(input.contactName, {\n field: \"contactName\",\n bufferLength: CONTACT_NAME_BUFFER_LENGTH,\n });\n validatePrintableLabel(input.previousScope, {\n field: \"previousScope\",\n bufferLength: SCOPE_BUFFER_LENGTH,\n });\n validatePrintableLabel(input.newScope, {\n field: \"newScope\",\n bufferLength: SCOPE_BUFFER_LENGTH,\n });\n\n validateFamilyIdentifiers({\n blockchainFamily: input.blockchainFamily,\n identifiers: [{ field: \"identifier\", value: input.identifier }],\n chainId: input.chainId,\n });\n\n validateByteLength(input.groupHandle, {\n field: \"groupHandle\",\n expectedBytes: GROUP_HANDLE_SIZE,\n });\n validateByteLength(input.hmacProof, {\n field: \"hmacProof\",\n expectedBytes: HMAC_PROOF_LENGTH,\n });\n validateByteLength(input.hmacRest, {\n field: \"hmacRest\",\n expectedBytes: HMAC_REST_LENGTH,\n });\n\n return null;\n } catch (error) {\n if (error instanceof ContactsValidationError) {\n return error;\n }\n throw error;\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2CAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EASO,yDAGP,MAAMC,EAAmB,oBAOlB,SAASH,EACdI,EACgC,CAChC,GAAI,CACF,mCAAuBA,EAAM,YAAa,CACxC,MAAO,cACP,aAAc,4BAChB,CAAC,KACD,0BAAuBA,EAAM,cAAe,CAC1C,MAAO,gBACP,aAAc,qBAChB,CAAC,KACD,0BAAuBA,EAAM,SAAU,CACrC,MAAO,WACP,aAAc,qBAChB,CAAC,KAED,6BAA0B,CACxB,iBAAkBA,EAAM,iBACxB,YAAa,CAAC,CAAE,MAAO,aAAc,MAAOA,EAAM,UAAW,CAAC,EAC9D,QAASA,EAAM,OACjB,CAAC,KAED,sBAAmBA,EAAM,YAAa,CACpC,MAAO,cACP,cAAe,mBACjB,CAAC,KACD,sBAAmBA,EAAM,UAAW,CAClC,MAAO,YACP,cAAe,mBACjB,CAAC,KACD,sBAAmBA,EAAM,SAAU,CACjC,MAAO,WACP,cAAeD,CACjB,CAAC,EAEM,IACT,OAASE,EAAO,CACd,GAAIA,aAAiB,0BACnB,OAAOA,EAET,MAAMA,CACR,CACF",
|
|
6
|
+
"names": ["validateEditExternalAddressScopeInput_exports", "__export", "validateEditExternalAddressScopeInput", "__toCommonJS", "import_contactsValidation", "HMAC_REST_LENGTH", "input", "error"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=require("../../../app-binder/model/contactsValidation"),t=require("./validateEditExternalAddressScopeInput");const r={contactName:"Alice",previousScope:"Eth main",newScope:"Eth cold",identifier:new Uint8Array(20).fill(17),blockchainFamily:"ethereum",chainId:1n,groupHandle:new Uint8Array(64).fill(204),hmacProof:new Uint8Array(32).fill(221),hmacRest:new Uint8Array(32).fill(170)};describe("validateEditExternalAddressScopeInput",()=>{it("returns null for a valid input",()=>{expect((0,t.validateEditExternalAddressScopeInput)(r)).toBeNull()}),it("rejects an empty contactName",()=>{const e=(0,t.validateEditExternalAddressScopeInput)({...r,contactName:""});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects a non-printable previousScope",()=>{const e=(0,t.validateEditExternalAddressScopeInput)({...r,previousScope:"caf\xE9"});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects a non-printable newScope",()=>{const e=(0,t.validateEditExternalAddressScopeInput)({...r,newScope:"caf\xE9"});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects an unsupported blockchain family",()=>{const e=(0,t.validateEditExternalAddressScopeInput)({...r,blockchainFamily:"dogecoin"});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects an identifier of the wrong length for Ethereum",()=>{const e=(0,t.validateEditExternalAddressScopeInput)({...r,identifier:new Uint8Array(19).fill(17)});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("requires chainId for the Ethereum family",()=>{const e=(0,t.validateEditExternalAddressScopeInput)({...r,chainId:void 0});expect(e).toBeInstanceOf(n.ContactsValidationError)}),describe("Solana",()=>{const e={...r,identifier:new Uint8Array(32).fill(17),blockchainFamily:"solana",chainId:void 0};it("accepts a 32-byte public key without chainId",()=>{expect((0,t.validateEditExternalAddressScopeInput)(e)).toBeNull()}),it("rejects an identifier that is not 32 bytes",()=>{expect((0,t.validateEditExternalAddressScopeInput)({...e,identifier:new Uint8Array(20)})).toBeInstanceOf(n.ContactsValidationError)}),it("rejects a chainId",()=>{expect((0,t.validateEditExternalAddressScopeInput)({...e,chainId:1n})).toBeInstanceOf(n.ContactsValidationError)})}),it("rejects a groupHandle of the wrong length",()=>{const e=(0,t.validateEditExternalAddressScopeInput)({...r,groupHandle:new Uint8Array(63).fill(204)});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects an hmacProof of the wrong length",()=>{const e=(0,t.validateEditExternalAddressScopeInput)({...r,hmacProof:new Uint8Array(31).fill(221)});expect(e).toBeInstanceOf(n.ContactsValidationError)}),it("rejects an hmacRest of the wrong length",()=>{const e=(0,t.validateEditExternalAddressScopeInput)({...r,hmacRest:new Uint8Array(33).fill(170)});expect(e).toBeInstanceOf(n.ContactsValidationError)})});
|
|
2
2
|
//# sourceMappingURL=validateEditExternalAddressScopeInput.test.js.map
|