Skip to content

Commit 9e1d55e

Browse files
committed
Add basic definitions for Flow.
1 parent ed0b26e commit 9e1d55e

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@
2323
"typescript": "^3.5.2"
2424
},
2525
"scripts": {
26-
"build": "rollup -c",
27-
"dev": "rollup -cw",
26+
"build": "npm run copy-flow && rollup -c",
27+
"dev": "npm run link-flow && rollup -cw",
2828
"clean": "rm -rf dist",
2929
"test": "jest && npm run lint",
3030
"setup": "npm install",
3131
"print-schemas": "npx ts-node script/print-schemas.ts",
3232
"lint": "tslint --fix --project . && tslint --fix rollup.config.js",
33-
"prepack": "npm run clean && npm run build"
33+
"prepack": "npm run clean && npm run build",
34+
"copy-flow": "mkdir -p dist/ && rm -f dist/index.js.flow && cp src/index.js.flow dist/",
35+
"link-flow": "mkdir -p dist/ && rm -f dist/index.js.flow && ln -s src/index.js.flow dist/"
3436
},
3537
"keywords": [
3638
"webauthn",

src/index.js.flow

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* @flow strict */
2+
3+
// For now, we only specify definitions to one layer in Flow.
4+
// With https://github.com/facebook/flow/issues/7480, it may be practical to mirror our TypeScript typings.
5+
6+
export interface CredentialCreationOptionsJSON {
7+
publicKey: {};
8+
signal?: AbortSignal;
9+
}
10+
11+
export interface PublicKeyCredentialWithAttestationJSON {
12+
type: "public-key";
13+
rawId: string; // base 64
14+
response: {};
15+
}
16+
17+
declare export function create(requestJSON: CredentialCreationOptionsJSON): Promise<PublicKeyCredentialWithAttestationJSON>;
18+
19+
export interface CredentialRequestOptionsJSON {
20+
unmediated?: boolean;
21+
mediation?: "silent" | "optional" | "required";
22+
publicKey: {};
23+
signal?: AbortSignal;
24+
}
25+
26+
export interface PublicKeyCredentialWithAssertionJSON {
27+
type: "public-key";
28+
id: string;
29+
rawId: string; // base 64
30+
response: {};
31+
}
32+
33+
declare export function get(requestJSON: CredentialRequestOptionsJSON): Promise<PublicKeyCredentialWithAssertionJSON>;

0 commit comments

Comments
 (0)