summaryrefslogtreecommitdiffhomepage
path: root/packages/typescript-types
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-05-20 18:09:32 -0700
committerMatthew Miller <matthew@millerti.me>2020-05-20 18:09:32 -0700
commit17f71884ab151b521241bc5aad4b74cc65c73890 (patch)
tree708ff5fe4cc214e34d0b35dcfa2ea5f527745c80 /packages/typescript-types
parent2da0d899172553009633762c133590fabefc0185 (diff)
Rename “typings” package to “types”
Diffstat (limited to 'packages/typescript-types')
-rw-r--r--packages/typescript-types/README.md3
-rw-r--r--packages/typescript-types/package.json21
-rw-r--r--packages/typescript-types/src/index.ts155
-rw-r--r--packages/typescript-types/tsconfig.json7
4 files changed, 186 insertions, 0 deletions
diff --git a/packages/typescript-types/README.md b/packages/typescript-types/README.md
new file mode 100644
index 0000000..8a28115
--- /dev/null
+++ b/packages/typescript-types/README.md
@@ -0,0 +1,3 @@
+# @webauthntine/typescript-types
+
+TypeScript typings for [@webauthntine/server](../server/) and [@webauthntine/browser](../browser/)
diff --git a/packages/typescript-types/package.json b/packages/typescript-types/package.json
new file mode 100644
index 0000000..c9a1fe7
--- /dev/null
+++ b/packages/typescript-types/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "@webauthntine/typescript-types",
+ "version": "1.0.0",
+ "description": "TypeScript types used by the @webauthntine series of libraries",
+ "main": "dist/index.js",
+ "types": "dist/index.d.ts",
+ "author": "Matthew Miller <matthew@millerti.me>",
+ "license": "MIT",
+ "homepage": "",
+ "scripts": {
+ "build": "rimraf dist && tsc",
+ "prepare": "npm run build"
+ },
+ "keywords": [
+ "webauthn",
+ "typescript",
+ "types"
+ ],
+ "dependencies": {
+ }
+}
diff --git a/packages/typescript-types/src/index.ts b/packages/typescript-types/src/index.ts
new file mode 100644
index 0000000..58cc90c
--- /dev/null
+++ b/packages/typescript-types/src/index.ts
@@ -0,0 +1,155 @@
+/**
+ * An object that can be passed into navigator.credentials.create(...) in the browser
+ */
+export type AttestationCredentials = {
+ publicKey: PublicKeyCredentialCreationOptions,
+};
+
+/**
+ * An object that can be passed into navigator.credentials.get(...) in the browser
+ */
+export type AssertionCredentials = {
+ publicKey: PublicKeyCredentialRequestOptions,
+};
+
+/**
+ * A slightly-modified AuthenticatorAttestationResponse to simplify working with ArrayBuffers that
+ * are base64-encoded in the browser so that they can be sent as JSON to the server.
+ */
+export interface EncodedAuthenticatorAttestationResponse extends Omit<
+AuthenticatorAttestationResponse, 'clientDataJSON' | 'attestationObject'
+> {
+ base64ClientDataJSON: string,
+ base64AttestationObject: string;
+}
+
+/**
+ * A slightly-modified AuthenticatorAttestationResponse to simplify working with ArrayBuffers that
+ * are base64-encoded in the browser so that they can be sent as JSON to the server.
+ */
+export interface EncodedAuthenticatorAssertionResponse extends Omit<
+AuthenticatorAssertionResponse, 'clientDataJSON' | 'authenticatorData' | 'signature'
+> {
+ base64AuthenticatorData: string;
+ base64ClientDataJSON: string;
+ base64Signature: string;
+}
+
+export enum ATTESTATION_FORMATS {
+ FIDO_U2F = 'fido-u2f',
+ PACKED = 'packed',
+ ANDROID_SAFETYNET = 'android-safetynet',
+ NONE = 'none',
+}
+
+export type AttestationObject = {
+ fmt: ATTESTATION_FORMATS,
+ attStmt: {
+ sig?: Buffer,
+ x5c?: Buffer[],
+ ecdaaKeyId?: Buffer,
+ response?: Buffer,
+ },
+ authData: Buffer,
+};
+
+export type ParsedAttestationAuthData = {
+ rpIdHash: Buffer,
+ flagsBuf: Buffer,
+ flags: {
+ up: boolean,
+ uv: boolean,
+ at: boolean,
+ ed: boolean,
+ flagsInt: number,
+ },
+ counter: number,
+ counterBuf: Buffer,
+ aaguid?: Buffer,
+ credentialID?: Buffer,
+ COSEPublicKey?: Buffer,
+};
+
+export type ClientDataJSON = {
+ type: string,
+ challenge: string,
+ origin: string,
+};
+
+/**
+ * Result of attestation verification
+ */
+export type VerifiedAttestation = {
+ verified: boolean,
+ authenticatorInfo?: {
+ fmt: ATTESTATION_FORMATS,
+ counter: number,
+ base64PublicKey: string,
+ base64CredentialID: string,
+ },
+};
+
+/**
+ * Result of assertion verification
+ */
+export type VerifiedAssertion = {
+ verified: boolean;
+};
+
+export type CertificateInfo = {
+ subject: { [key: string]: string },
+ version: number,
+ basicConstraintsCA: boolean,
+};
+
+export enum COSEKEYS {
+ kty = 1,
+ alg = 3,
+ crv = -1,
+ x = -2,
+ y = -3,
+ n = -1,
+ e = -2,
+}
+
+export type COSEPublicKey = Map<COSEAlgorithmIdentifier, number | Buffer>;
+
+export type SafetyNetJWTHeader = {
+ alg: 'string',
+ x5c: string[],
+};
+
+export type SafetyNetJWTPayload = {
+ nonce: string,
+ timestampMs: number,
+ apkPackageName: string,
+ apkDigestSha256: string,
+ ctsProfileMatch: boolean,
+ apkCertificateDigestSha256: string[],
+ basicIntegrity: boolean,
+};
+
+export type SafetyNetJWTSignature = string;
+
+export type ParsedAssertionAuthData = {
+ rpIdHash: Buffer,
+ flagsBuf: Buffer,
+ flags: number,
+ counter: number,
+ counterBuf: Buffer,
+};
+
+/**
+ * U2F Presence constant
+ */
+export const U2F_USER_PRESENTED = 0x01;
+
+/**
+ * A WebAuthn-compatible device and the information needed to verify assertions by it
+ */
+export type AuthenticatorDevice = {
+ base64PublicKey: string,
+ base64CredentialID: string,
+ // Number of times this device is expected to have been used
+ counter: number,
+};
diff --git a/packages/typescript-types/tsconfig.json b/packages/typescript-types/tsconfig.json
new file mode 100644
index 0000000..9ddf207
--- /dev/null
+++ b/packages/typescript-types/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "baseUrl": "./src",
+ "outDir": "./dist",
+ }
+}