@ledgerhq/ledger-trust-service 0.3.14 → 0.3.15-nightly.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +15 -0
- package/lib/hedera.d.ts +8 -0
- package/lib/hedera.d.ts.map +1 -0
- package/lib/hedera.integ.test.d.ts +2 -0
- package/lib/hedera.integ.test.d.ts.map +1 -0
- package/lib/hedera.integ.test.js +15 -0
- package/lib/hedera.integ.test.js.map +1 -0
- package/lib/hedera.js +21 -0
- package/lib/hedera.js.map +1 -0
- package/lib/hedera.test.d.ts +2 -0
- package/lib/hedera.test.d.ts.map +1 -0
- package/lib/hedera.test.js +57 -0
- package/lib/hedera.test.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib-es/hedera.d.ts +8 -0
- package/lib-es/hedera.d.ts.map +1 -0
- package/lib-es/hedera.integ.test.d.ts +2 -0
- package/lib-es/hedera.integ.test.d.ts.map +1 -0
- package/lib-es/hedera.integ.test.js +13 -0
- package/lib-es/hedera.integ.test.js.map +1 -0
- package/lib-es/hedera.js +14 -0
- package/lib-es/hedera.js.map +1 -0
- package/lib-es/hedera.test.d.ts +2 -0
- package/lib-es/hedera.test.d.ts.map +1 -0
- package/lib-es/hedera.test.js +52 -0
- package/lib-es/hedera.test.js.map +1 -0
- package/lib-es/index.d.ts +4 -0
- package/lib-es/index.d.ts.map +1 -1
- package/lib-es/index.js +4 -0
- package/lib-es/index.js.map +1 -1
- package/package.json +3 -3
- package/src/hedera.integ.test.ts +16 -0
- package/src/hedera.test.ts +59 -0
- package/src/hedera.ts +35 -0
- package/src/index.ts +4 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/ledger-trust-service@0.3.
|
|
2
|
+
> @ledgerhq/ledger-trust-service@0.3.15-nightly.0 build /home/runner/work/ledger-live/ledger-live/libs/ledger-services/trust
|
|
3
3
|
> tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ledgerhq/ledger-trust-service
|
|
2
2
|
|
|
3
|
+
## 0.3.15-nightly.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @ledgerhq/live-network@2.0.20-nightly.1
|
|
9
|
+
|
|
10
|
+
## 0.3.15-nightly.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`f1f3845`](https://github.com/LedgerHQ/ledger-live/commit/f1f3845942e4cbce9c585dc65f6170ddbc319f19)]:
|
|
15
|
+
- @ledgerhq/live-env@2.19.0-nightly.0
|
|
16
|
+
- @ledgerhq/live-network@2.0.20-nightly.0
|
|
17
|
+
|
|
3
18
|
## 0.3.14
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/lib/hedera.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type PublicKeyInfo = {
|
|
2
|
+
accountId: string;
|
|
3
|
+
publicKey: string;
|
|
4
|
+
signedDescriptor: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function getPublicKey(accountId: string, challenge: string, env?: "prod" | "test"): Promise<PublicKeyInfo>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=hedera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.d.ts","sourceRoot":"","sources":["../src/hedera.ts"],"names":[],"mappings":"AAaA,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,GAAG,GAAE,MAAM,GAAG,MAAe,GAC5B,OAAO,CAAC,aAAa,CAAC,CAWxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.integ.test.d.ts","sourceRoot":"","sources":["../src/hedera.integ.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const hedera_1 = require("./hedera");
|
|
4
|
+
describe("getPublicKey", () => {
|
|
5
|
+
it("returns expected public key info", async () => {
|
|
6
|
+
// When
|
|
7
|
+
const result = await (0, hedera_1.getPublicKey)("0.0.751515", "1", "test");
|
|
8
|
+
// Then
|
|
9
|
+
expect(result).toEqual(expect.objectContaining({
|
|
10
|
+
account: "0.0.751515",
|
|
11
|
+
key: "0xe645c093bab64b4d076e82a85fd11bbfac24af0d827e7dafa8c49e04395970eb",
|
|
12
|
+
}));
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=hedera.integ.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.integ.test.js","sourceRoot":"","sources":["../src/hedera.integ.test.ts"],"names":[],"mappings":";;AAAA,qCAAwC;AAExC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,OAAO;QACP,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAY,EAAC,YAAY,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAE7D,OAAO;QACP,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CACpB,MAAM,CAAC,gBAAgB,CAAC;YACtB,OAAO,EAAE,YAAY;YACrB,GAAG,EAAE,oEAAoE;SAC1E,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/hedera.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPublicKey = void 0;
|
|
7
|
+
const live_network_1 = __importDefault(require("@ledgerhq/live-network"));
|
|
8
|
+
const common_1 = require("./common");
|
|
9
|
+
async function getPublicKey(accountId, challenge, env = "prod") {
|
|
10
|
+
const { data } = await (0, live_network_1.default)({
|
|
11
|
+
method: "GET",
|
|
12
|
+
url: `${(0, common_1.getTrustedDomain)(env)}/v2/hedera/pubkey/${accountId}?challenge=${challenge}`,
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
accountId: data.account,
|
|
16
|
+
publicKey: data.key,
|
|
17
|
+
signedDescriptor: data.signedDescriptor,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.getPublicKey = getPublicKey;
|
|
21
|
+
//# sourceMappingURL=hedera.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.js","sourceRoot":"","sources":["../src/hedera.ts"],"names":[],"mappings":";;;;;;AAAA,0EAA6C;AAC7C,qCAA4C;AAkBrC,KAAK,UAAU,YAAY,CAChC,SAAiB,EACjB,SAAiB,EACjB,MAAuB,MAAM;IAE7B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,sBAAO,EAAoB;QAChD,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,IAAA,yBAAgB,EAAC,GAAG,CAAC,qBAAqB,SAAS,cAAc,SAAS,EAAE;KACrF,CAAC,CAAC;IAEH,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,OAAO;QACvB,SAAS,EAAE,IAAI,CAAC,GAAG;QACnB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;KACxC,CAAC;AACJ,CAAC;AAfD,oCAeC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.test.d.ts","sourceRoot":"","sources":["../src/hedera.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const live_network_1 = __importDefault(require("@ledgerhq/live-network"));
|
|
7
|
+
const hedera_1 = require("./hedera");
|
|
8
|
+
jest.mock("@ledgerhq/live-network");
|
|
9
|
+
describe("hedera", () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
jest.resetModules();
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
});
|
|
14
|
+
describe("getPublicKey", () => {
|
|
15
|
+
it.each([
|
|
16
|
+
["prod", "https://nft.api.live.ledger.com"],
|
|
17
|
+
[undefined, "https://nft.api.live.ledger.com"],
|
|
18
|
+
["test", "https://nft.api.live.ledger-test.com"],
|
|
19
|
+
])("fetch the correct %s service environment", async (env, baseUrl) => {
|
|
20
|
+
// Given
|
|
21
|
+
const accountId = "HEDERA_ACCOUNT_ID";
|
|
22
|
+
const challenge = "WHATEVER_CHALLENGE";
|
|
23
|
+
const mockResponse = {};
|
|
24
|
+
live_network_1.default.mockResolvedValue({ data: mockResponse });
|
|
25
|
+
// When
|
|
26
|
+
await (0, hedera_1.getPublicKey)(accountId, challenge, env);
|
|
27
|
+
// Then
|
|
28
|
+
expect(live_network_1.default).toHaveBeenCalledWith({
|
|
29
|
+
method: "GET",
|
|
30
|
+
url: `${baseUrl}/v2/hedera/pubkey/${accountId}?challenge=${challenge}`,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
it("transforms data as expected", async () => {
|
|
34
|
+
// Given
|
|
35
|
+
const accountId = "HEDERA_ACCOUNT_ID";
|
|
36
|
+
const publicKey = "HEDERA_PUBLIC_KEY";
|
|
37
|
+
const challenge = "WHATEVER_CHALLENGE";
|
|
38
|
+
const mockResponse = {
|
|
39
|
+
descriptorType: "TrustedDomainName",
|
|
40
|
+
descriptorVersion: 3,
|
|
41
|
+
account: accountId,
|
|
42
|
+
key: publicKey,
|
|
43
|
+
signedDescriptor: "SIGNATURE",
|
|
44
|
+
};
|
|
45
|
+
live_network_1.default.mockResolvedValue({ data: mockResponse });
|
|
46
|
+
// When
|
|
47
|
+
const result = await (0, hedera_1.getPublicKey)(accountId, challenge);
|
|
48
|
+
// Then
|
|
49
|
+
expect(result).toEqual({
|
|
50
|
+
accountId,
|
|
51
|
+
publicKey,
|
|
52
|
+
signedDescriptor: "SIGNATURE",
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=hedera.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.test.js","sourceRoot":"","sources":["../src/hedera.test.ts"],"names":[],"mappings":";;;;;AAAA,0EAA6C;AAC7C,qCAAwC;AAExC,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;AAEpC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,IAAI,CAAC;YACN,CAAC,MAAM,EAAE,iCAAiC,CAAC;YAC3C,CAAC,SAAS,EAAE,iCAAiC,CAAC;YAC9C,CAAC,MAAM,EAAE,sCAAsC,CAAC;SACjD,CAAC,CAAC,0CAA0C,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EA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|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { getPublicKey } from "./hedera";
|
|
1
2
|
import { computedTokenAddress, getOwnerAddress } from "./solana";
|
|
2
3
|
declare const _default: {
|
|
3
4
|
computedTokenAddress: typeof computedTokenAddress;
|
|
4
5
|
getOwnerAddress: typeof getOwnerAddress;
|
|
6
|
+
hedera: {
|
|
7
|
+
getPublicKey: typeof getPublicKey;
|
|
8
|
+
};
|
|
5
9
|
};
|
|
6
10
|
export default _default;
|
|
7
11
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;;;;;;;;AAEjE,wBAME"}
|
package/lib/index.js
CHANGED
|
@@ -5,9 +5,13 @@
|
|
|
5
5
|
* Use only exposed methods below outside of this module.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const hedera_1 = require("./hedera");
|
|
8
9
|
const solana_1 = require("./solana");
|
|
9
10
|
exports.default = {
|
|
10
11
|
computedTokenAddress: solana_1.computedTokenAddress,
|
|
11
12
|
getOwnerAddress: solana_1.getOwnerAddress,
|
|
13
|
+
hedera: {
|
|
14
|
+
getPublicKey: hedera_1.getPublicKey,
|
|
15
|
+
},
|
|
12
16
|
};
|
|
13
17
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAEH,qCAAiE;AAEjE,kBAAe;IACb,oBAAoB,EAApB,6BAAoB;IACpB,eAAe,EAAf,wBAAe;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAEH,qCAAwC;AACxC,qCAAiE;AAEjE,kBAAe;IACb,oBAAoB,EAApB,6BAAoB;IACpB,eAAe,EAAf,wBAAe;IACf,MAAM,EAAE;QACN,YAAY,EAAZ,qBAAY;KACb;CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type PublicKeyInfo = {
|
|
2
|
+
accountId: string;
|
|
3
|
+
publicKey: string;
|
|
4
|
+
signedDescriptor: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function getPublicKey(accountId: string, challenge: string, env?: "prod" | "test"): Promise<PublicKeyInfo>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=hedera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.d.ts","sourceRoot":"","sources":["../src/hedera.ts"],"names":[],"mappings":"AAaA,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,GAAG,GAAE,MAAM,GAAG,MAAe,GAC5B,OAAO,CAAC,aAAa,CAAC,CAWxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.integ.test.d.ts","sourceRoot":"","sources":["../src/hedera.integ.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getPublicKey } from "./hedera";
|
|
2
|
+
describe("getPublicKey", () => {
|
|
3
|
+
it("returns expected public key info", async () => {
|
|
4
|
+
// When
|
|
5
|
+
const result = await getPublicKey("0.0.751515", "1", "test");
|
|
6
|
+
// Then
|
|
7
|
+
expect(result).toEqual(expect.objectContaining({
|
|
8
|
+
account: "0.0.751515",
|
|
9
|
+
key: "0xe645c093bab64b4d076e82a85fd11bbfac24af0d827e7dafa8c49e04395970eb",
|
|
10
|
+
}));
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=hedera.integ.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.integ.test.js","sourceRoot":"","sources":["../src/hedera.integ.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,OAAO;QACP,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,YAAY,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAE7D,OAAO;QACP,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CACpB,MAAM,CAAC,gBAAgB,CAAC;YACtB,OAAO,EAAE,YAAY;YACrB,GAAG,EAAE,oEAAoE;SAC1E,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib-es/hedera.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import network from "@ledgerhq/live-network";
|
|
2
|
+
import { getTrustedDomain } from "./common";
|
|
3
|
+
export async function getPublicKey(accountId, challenge, env = "prod") {
|
|
4
|
+
const { data } = await network({
|
|
5
|
+
method: "GET",
|
|
6
|
+
url: `${getTrustedDomain(env)}/v2/hedera/pubkey/${accountId}?challenge=${challenge}`,
|
|
7
|
+
});
|
|
8
|
+
return {
|
|
9
|
+
accountId: data.account,
|
|
10
|
+
publicKey: data.key,
|
|
11
|
+
signedDescriptor: data.signedDescriptor,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=hedera.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.js","sourceRoot":"","sources":["../src/hedera.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAkB5C,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,SAAiB,EACjB,SAAiB,EACjB,MAAuB,MAAM;IAE7B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAoB;QAChD,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,gBAAgB,CAAC,GAAG,CAAC,qBAAqB,SAAS,cAAc,SAAS,EAAE;KACrF,CAAC,CAAC;IAEH,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,OAAO;QACvB,SAAS,EAAE,IAAI,CAAC,GAAG;QACnB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;KACxC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.test.d.ts","sourceRoot":"","sources":["../src/hedera.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import network from "@ledgerhq/live-network";
|
|
2
|
+
import { getPublicKey } from "./hedera";
|
|
3
|
+
jest.mock("@ledgerhq/live-network");
|
|
4
|
+
describe("hedera", () => {
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
jest.resetModules();
|
|
7
|
+
jest.clearAllMocks();
|
|
8
|
+
});
|
|
9
|
+
describe("getPublicKey", () => {
|
|
10
|
+
it.each([
|
|
11
|
+
["prod", "https://nft.api.live.ledger.com"],
|
|
12
|
+
[undefined, "https://nft.api.live.ledger.com"],
|
|
13
|
+
["test", "https://nft.api.live.ledger-test.com"],
|
|
14
|
+
])("fetch the correct %s service environment", async (env, baseUrl) => {
|
|
15
|
+
// Given
|
|
16
|
+
const accountId = "HEDERA_ACCOUNT_ID";
|
|
17
|
+
const challenge = "WHATEVER_CHALLENGE";
|
|
18
|
+
const mockResponse = {};
|
|
19
|
+
network.mockResolvedValue({ data: mockResponse });
|
|
20
|
+
// When
|
|
21
|
+
await getPublicKey(accountId, challenge, env);
|
|
22
|
+
// Then
|
|
23
|
+
expect(network).toHaveBeenCalledWith({
|
|
24
|
+
method: "GET",
|
|
25
|
+
url: `${baseUrl}/v2/hedera/pubkey/${accountId}?challenge=${challenge}`,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
it("transforms data as expected", async () => {
|
|
29
|
+
// Given
|
|
30
|
+
const accountId = "HEDERA_ACCOUNT_ID";
|
|
31
|
+
const publicKey = "HEDERA_PUBLIC_KEY";
|
|
32
|
+
const challenge = "WHATEVER_CHALLENGE";
|
|
33
|
+
const mockResponse = {
|
|
34
|
+
descriptorType: "TrustedDomainName",
|
|
35
|
+
descriptorVersion: 3,
|
|
36
|
+
account: accountId,
|
|
37
|
+
key: publicKey,
|
|
38
|
+
signedDescriptor: "SIGNATURE",
|
|
39
|
+
};
|
|
40
|
+
network.mockResolvedValue({ data: mockResponse });
|
|
41
|
+
// When
|
|
42
|
+
const result = await getPublicKey(accountId, challenge);
|
|
43
|
+
// Then
|
|
44
|
+
expect(result).toEqual({
|
|
45
|
+
accountId,
|
|
46
|
+
publicKey,
|
|
47
|
+
signedDescriptor: "SIGNATURE",
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=hedera.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera.test.js","sourceRoot":"","sources":["../src/hedera.test.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC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BAAgB,EAAE,WAAW;aAC9B,CAAC;YACD,OAAqB,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;YAEjE,OAAO;YACP,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAExD,OAAO;YACP,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB,SAAS;gBACT,SAAS;gBACT,gBAAgB,EAAE,WAAW;aAC9B,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib-es/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { getPublicKey } from "./hedera";
|
|
1
2
|
import { computedTokenAddress, getOwnerAddress } from "./solana";
|
|
2
3
|
declare const _default: {
|
|
3
4
|
computedTokenAddress: typeof computedTokenAddress;
|
|
4
5
|
getOwnerAddress: typeof getOwnerAddress;
|
|
6
|
+
hedera: {
|
|
7
|
+
getPublicKey: typeof getPublicKey;
|
|
8
|
+
};
|
|
5
9
|
};
|
|
6
10
|
export default _default;
|
|
7
11
|
//# sourceMappingURL=index.d.ts.map
|
package/lib-es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;;;;;;;;AAEjE,wBAME"}
|
package/lib-es/index.js
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Use only exposed methods below outside of this module.
|
|
5
5
|
*/
|
|
6
|
+
import { getPublicKey } from "./hedera";
|
|
6
7
|
import { computedTokenAddress, getOwnerAddress } from "./solana";
|
|
7
8
|
export default {
|
|
8
9
|
computedTokenAddress,
|
|
9
10
|
getOwnerAddress,
|
|
11
|
+
hedera: {
|
|
12
|
+
getPublicKey,
|
|
13
|
+
},
|
|
10
14
|
};
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
package/lib-es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEjE,eAAe;IACb,oBAAoB;IACpB,eAAe;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEjE,eAAe;IACb,oBAAoB;IACpB,eAAe;IACf,MAAM,EAAE;QACN,YAAY;KACb;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/ledger-trust-service",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15-nightly.1",
|
|
4
4
|
"description": "Ledger Trust service client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
},
|
|
56
56
|
"license": "Apache-2.0",
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@ledgerhq/live-env": "2.
|
|
59
|
-
"@ledgerhq/live-network": "2.0.
|
|
58
|
+
"@ledgerhq/live-env": "2.19.0-nightly.0",
|
|
59
|
+
"@ledgerhq/live-network": "2.0.20-nightly.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/jest": "^29.5.10",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getPublicKey } from "./hedera";
|
|
2
|
+
|
|
3
|
+
describe("getPublicKey", () => {
|
|
4
|
+
it("returns expected public key info", async () => {
|
|
5
|
+
// When
|
|
6
|
+
const result = await getPublicKey("0.0.751515", "1", "test");
|
|
7
|
+
|
|
8
|
+
// Then
|
|
9
|
+
expect(result).toEqual(
|
|
10
|
+
expect.objectContaining({
|
|
11
|
+
account: "0.0.751515",
|
|
12
|
+
key: "0xe645c093bab64b4d076e82a85fd11bbfac24af0d827e7dafa8c49e04395970eb",
|
|
13
|
+
}),
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import network from "@ledgerhq/live-network";
|
|
2
|
+
import { getPublicKey } from "./hedera";
|
|
3
|
+
|
|
4
|
+
jest.mock("@ledgerhq/live-network");
|
|
5
|
+
|
|
6
|
+
describe("hedera", () => {
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
jest.resetModules();
|
|
9
|
+
jest.clearAllMocks();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe("getPublicKey", () => {
|
|
13
|
+
it.each([
|
|
14
|
+
["prod", "https://nft.api.live.ledger.com"],
|
|
15
|
+
[undefined, "https://nft.api.live.ledger.com"],
|
|
16
|
+
["test", "https://nft.api.live.ledger-test.com"],
|
|
17
|
+
])("fetch the correct %s service environment", async (env, baseUrl) => {
|
|
18
|
+
// Given
|
|
19
|
+
const accountId = "HEDERA_ACCOUNT_ID";
|
|
20
|
+
const challenge = "WHATEVER_CHALLENGE";
|
|
21
|
+
const mockResponse = {};
|
|
22
|
+
(network as jest.Mock).mockResolvedValue({ data: mockResponse });
|
|
23
|
+
|
|
24
|
+
// When
|
|
25
|
+
await getPublicKey(accountId, challenge, env as "prod" | "test");
|
|
26
|
+
|
|
27
|
+
// Then
|
|
28
|
+
expect(network).toHaveBeenCalledWith({
|
|
29
|
+
method: "GET",
|
|
30
|
+
url: `${baseUrl}/v2/hedera/pubkey/${accountId}?challenge=${challenge}`,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("transforms data as expected", async () => {
|
|
35
|
+
// Given
|
|
36
|
+
const accountId = "HEDERA_ACCOUNT_ID";
|
|
37
|
+
const publicKey = "HEDERA_PUBLIC_KEY";
|
|
38
|
+
const challenge = "WHATEVER_CHALLENGE";
|
|
39
|
+
const mockResponse = {
|
|
40
|
+
descriptorType: "TrustedDomainName",
|
|
41
|
+
descriptorVersion: 3,
|
|
42
|
+
account: accountId,
|
|
43
|
+
key: publicKey,
|
|
44
|
+
signedDescriptor: "SIGNATURE",
|
|
45
|
+
};
|
|
46
|
+
(network as jest.Mock).mockResolvedValue({ data: mockResponse });
|
|
47
|
+
|
|
48
|
+
// When
|
|
49
|
+
const result = await getPublicKey(accountId, challenge);
|
|
50
|
+
|
|
51
|
+
// Then
|
|
52
|
+
expect(result).toEqual({
|
|
53
|
+
accountId,
|
|
54
|
+
publicKey,
|
|
55
|
+
signedDescriptor: "SIGNATURE",
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
package/src/hedera.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import network from "@ledgerhq/live-network";
|
|
2
|
+
import { getTrustedDomain } from "./common";
|
|
3
|
+
|
|
4
|
+
type PublicKeyResponse = {
|
|
5
|
+
descriptorType: "TrustedDomainName";
|
|
6
|
+
descriptorVersion: number;
|
|
7
|
+
account: string;
|
|
8
|
+
key: string;
|
|
9
|
+
signedDescriptor: string;
|
|
10
|
+
keyId: "domain_metadata_key";
|
|
11
|
+
keyUsage: "trusted_name";
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type PublicKeyInfo = {
|
|
15
|
+
accountId: string;
|
|
16
|
+
publicKey: string;
|
|
17
|
+
signedDescriptor: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export async function getPublicKey(
|
|
21
|
+
accountId: string,
|
|
22
|
+
challenge: string,
|
|
23
|
+
env: "prod" | "test" = "prod",
|
|
24
|
+
): Promise<PublicKeyInfo> {
|
|
25
|
+
const { data } = await network<PublicKeyResponse>({
|
|
26
|
+
method: "GET",
|
|
27
|
+
url: `${getTrustedDomain(env)}/v2/hedera/pubkey/${accountId}?challenge=${challenge}`,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
accountId: data.account,
|
|
32
|
+
publicKey: data.key,
|
|
33
|
+
signedDescriptor: data.signedDescriptor,
|
|
34
|
+
};
|
|
35
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -4,9 +4,13 @@
|
|
|
4
4
|
* Use only exposed methods below outside of this module.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { getPublicKey } from "./hedera";
|
|
7
8
|
import { computedTokenAddress, getOwnerAddress } from "./solana";
|
|
8
9
|
|
|
9
10
|
export default {
|
|
10
11
|
computedTokenAddress,
|
|
11
12
|
getOwnerAddress,
|
|
13
|
+
hedera: {
|
|
14
|
+
getPublicKey,
|
|
15
|
+
},
|
|
12
16
|
};
|