Skip to content

Commit c9c25be

Browse files
authored
Merge pull request #1629 from near/fix_importing_issues_of_biometric_ed25519_package
fix: Fix importing issues of `@near-js/biometric-ed25519` package
2 parents 546d2d6 + b260e70 commit c9c25be

File tree

11 files changed

+692
-19
lines changed

11 files changed

+692
-19
lines changed

.changeset/big-apes-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@near-js/biometric-ed25519": patch
3+
---
4+
5+
Fix missing type definitions in editors caused by broken `index.d.ts`

.changeset/some-planets-exist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@near-js/biometric-ed25519": patch
3+
---
4+
5+
Fix error on package import by correcting `@hexagon/base64` import

e2e/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"license": "ISC",
1313
"dependencies": {
1414
"@near-js/accounts": "file:../packages/accounts",
15+
"@near-js/biometric-ed25519": "file:../packages/biometric-ed25519",
1516
"@near-js/crypto": "file:../packages/crypto",
1617
"@near-js/providers": "file:../packages/providers",
1718
"@near-js/signers": "file:../packages/signers",

e2e/pnpm-lock.yaml

Lines changed: 609 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {
2+
createKey,
3+
getKeys,
4+
isDeviceSupported,
5+
isPassKeyAvailable,
6+
} from "@near-js/biometric-ed25519";
7+
import { KeyPair } from "@near-js/crypto";
8+
import { expectTypeOf, test } from "vitest";
9+
10+
test(`exports "createKey" function with correct type`, async () => {
11+
type ExpectedFunction = (username: string) => Promise<KeyPair>;
12+
13+
expectTypeOf(createKey).toEqualTypeOf<ExpectedFunction>();
14+
});
15+
16+
test(`exports "getKeys" function with correct type`, async () => {
17+
type ExpectedFunction = (username: string) => Promise<[KeyPair, KeyPair]>;
18+
19+
expectTypeOf(getKeys).toEqualTypeOf<ExpectedFunction>();
20+
});
21+
22+
test(`exports "isDeviceSupported" function with correct type`, async () => {
23+
type ExpectedFunction = () => Promise<boolean>;
24+
25+
expectTypeOf(isDeviceSupported).toEqualTypeOf<ExpectedFunction>();
26+
});
27+
28+
test(`exports "isPassKeyAvailable" function with correct type`, async () => {
29+
type ExpectedFunction = () => Promise<boolean>;
30+
31+
expectTypeOf(isPassKeyAvailable).toEqualTypeOf<ExpectedFunction>();
32+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {
2+
createKey,
3+
getKeys,
4+
isDeviceSupported,
5+
isPassKeyAvailable,
6+
} from "@near-js/biometric-ed25519";
7+
import { expect, test } from "vitest";
8+
9+
test(`exports "createKey" function`, () => {
10+
expect(createKey).toBeDefined();
11+
});
12+
13+
test(`exports "getKeys" function`, () => {
14+
expect(getKeys).toBeDefined();
15+
});
16+
17+
test(`exports "isDeviceSupported" function`, () => {
18+
expect(isDeviceSupported).toBeDefined();
19+
});
20+
21+
test(`exports "isPassKeyAvailable" function`, () => {
22+
expect(isPassKeyAvailable).toBeDefined();
23+
});

packages/biometric-ed25519/src/fido2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import base64 from '@hexagon/base64';
1+
import { base64 } from '@hexagon/base64';
22
import { Fido2Lib } from 'fido2-lib';
33
import cbor from 'cbor-js';
44

packages/biometric-ed25519/src/index.d.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/biometric-ed25519/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import base64 from '@hexagon/base64';
1+
import { base64 } from '@hexagon/base64';
22
import { ed25519 } from '@noble/curves/ed25519';
33
import { sha256 } from '@noble/hashes/sha256';
44
import { Buffer } from 'buffer';
@@ -17,7 +17,7 @@ import {
1717
sanitizeGetKeyResponse
1818
} from './utils';
1919
import { Fido2 } from './fido2';
20-
import { AssertionResponse } from './index.d';
20+
import type { AssertionResponse } from './type';
2121
import { KeyPairString } from '@near-js/crypto';
2222

2323
const CHALLENGE_TIMEOUT_MS = 90 * 1000;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export type AssertionResponse = {
2+
authenticatorAttachment: 'platform' | 'cross-platform';
3+
getClientExtensionResults: () => any;
4+
id: string;
5+
rawId: string;
6+
response: {
7+
authenticatorData: string;
8+
clientDataJSON: string;
9+
signature: string;
10+
userHandle: string;
11+
};
12+
type: 'public-key';
13+
};

0 commit comments

Comments
 (0)