Skip to content

Commit 5b893c3

Browse files
authored
Merge pull request #2 from chiru-labs/tea/allow-empty-param
Allow empty arg to be passed to getPublicKeysFromScan
2 parents bee13b2 + 3182886 commit 5b893c3

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ This package exposes 2 functions for each chip manufacturer:
5757

5858
### `getPublicKeysFromScan`
5959

60+
This function takes in a single object as the argument with the following parameters:
61+
6062
| Parameter | Type | Description | Required |
6163
| ------------- | ------------- | ------------- | ------------- |
6264
| rpId | string | string representing the domain the scan is being called on. For example a workflow hosted on azuki.com would pass in `azuki.com`. Defaults to `URL.hostname` | No |
@@ -77,6 +79,8 @@ Promise<{
7779

7880
### `getSignatureFromScan`
7981

82+
This function takes in a single object as the argument with the following parameters:
83+
8084
| Parameter | Type | Description | Required |
8185
| ------------- | ------------- | ------------- | ------------- |
8286
| rpId | string | string representing the domain the scan is being called on. For example a workflow hosted on azuki.com would pass in `azuki.com`. Defaults to `URL.hostname` | No |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pbt-chip-client",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "Javascript library to make it easy to integrate with PBT for browsers",
55
"scripts": {
66
"pre-commit": "lint-staged",

src/kong/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ export const getSignatureFromScan = async ({
234234
throw new Error("Error in signing, try again.");
235235
};
236236

237-
export const getPublicKeysFromScan = async ({ rpId }: { rpId?: string }) => {
237+
export const getPublicKeysFromScan = async ({
238+
rpId,
239+
}: { rpId?: string } = {}) => {
238240
if (!IS_BROWSER) {
239241
console.warn("This function is only available in a browser environment.");
240242

test/kong/index.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,19 @@ describe("Kong chip", () => {
5555
);
5656
}
5757
});
58+
59+
it("getPublicKeysFromScan without explicit rpId", async () => {
60+
const result = await getPublicKeysFromScan();
61+
62+
if (result) {
63+
const { primaryPublicKeyHash, primaryPublicKeyRaw } = result;
64+
65+
expect(primaryPublicKeyHash).toEqual(
66+
"0x844821a2bad46a9ed8f65761debc79af0c7f0cf4af0a4f81e97a12afe0affb0d"
67+
);
68+
expect(primaryPublicKeyRaw).toEqual(
69+
"786463333238333762323161626438396561343133616333646132303563343531663235346233363162623438353134"
70+
);
71+
}
72+
});
5873
});

0 commit comments

Comments
 (0)