@simplewebauthn/typescript-types
Advanced tools
Comparing version 6.3.0-alpha.1 to 7.0.0
@@ -10,8 +10,11 @@ /** Available only in secure contexts. */ | ||
readonly attestationObject: ArrayBuffer; | ||
getAuthenticatorData(): ArrayBuffer; | ||
getPublicKey(): ArrayBuffer | null; | ||
getPublicKeyAlgorithm(): COSEAlgorithmIdentifier; | ||
getTransports(): string[]; | ||
} | ||
export interface AuthenticationExtensionsClientInputs { | ||
appid?: string; | ||
appidExclude?: string; | ||
credProps?: boolean; | ||
uvm?: boolean; | ||
hmacCreateSecret?: boolean; | ||
} | ||
@@ -21,3 +24,3 @@ export interface AuthenticationExtensionsClientOutputs { | ||
credProps?: CredentialPropertiesOutput; | ||
uvm?: UvmEntries; | ||
hmacCreateSecret?: boolean; | ||
} | ||
@@ -30,4 +33,13 @@ export interface AuthenticatorSelectionCriteria { | ||
} | ||
/** Basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives. */ | ||
export interface Crypto { | ||
/** Available only in secure contexts. */ | ||
readonly subtle: SubtleCrypto; | ||
getRandomValues<T extends ArrayBufferView | null>(array: T): T; | ||
/** Available only in secure contexts. */ | ||
randomUUID(): string; | ||
} | ||
/** Available only in secure contexts. */ | ||
export interface PublicKeyCredential extends Credential { | ||
readonly authenticatorAttachment: string | null; | ||
readonly rawId: ArrayBuffer; | ||
@@ -76,2 +88,24 @@ readonly response: AuthenticatorResponse; | ||
} | ||
/** | ||
* This Web Crypto API interface provides a number of low-level cryptographic functions. It is accessed via the Crypto.subtle properties available in a window context (via Window.crypto). | ||
* Available only in secure contexts. | ||
*/ | ||
export interface SubtleCrypto { | ||
decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>; | ||
deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>; | ||
deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>; | ||
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>; | ||
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>; | ||
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>; | ||
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>; | ||
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>; | ||
generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>; | ||
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair | CryptoKey>; | ||
importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>; | ||
importKey(format: Exclude<KeyFormat, "jwk">, keyData: BufferSource, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>; | ||
sign(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>; | ||
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>; | ||
verify(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>; | ||
wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams): Promise<ArrayBuffer>; | ||
} | ||
/** Available only in secure contexts. */ | ||
@@ -88,11 +122,128 @@ export interface Credential { | ||
} | ||
export declare type AttestationConveyancePreference = "direct" | "enterprise" | "indirect" | "none"; | ||
export declare type AuthenticatorTransport = "ble" | "internal" | "nfc" | "usb"; | ||
export declare type COSEAlgorithmIdentifier = number; | ||
export declare type UserVerificationRequirement = "discouraged" | "preferred" | "required"; | ||
export declare type UvmEntries = UvmEntry[]; | ||
export declare type AuthenticatorAttachment = "cross-platform" | "platform"; | ||
export declare type ResidentKeyRequirement = "discouraged" | "preferred" | "required"; | ||
export declare type BufferSource = ArrayBufferView | ArrayBuffer; | ||
export declare type PublicKeyCredentialType = "public-key"; | ||
export declare type UvmEntry = number[]; | ||
export interface RsaOaepParams extends Algorithm { | ||
label?: BufferSource; | ||
} | ||
export interface AesCtrParams extends Algorithm { | ||
counter: BufferSource; | ||
length: number; | ||
} | ||
export interface AesCbcParams extends Algorithm { | ||
iv: BufferSource; | ||
} | ||
export interface AesGcmParams extends Algorithm { | ||
additionalData?: BufferSource; | ||
iv: BufferSource; | ||
tagLength?: number; | ||
} | ||
/** | ||
* The CryptoKey dictionary of the Web Crypto API represents a cryptographic key. | ||
* Available only in secure contexts. | ||
*/ | ||
export interface CryptoKey { | ||
readonly algorithm: KeyAlgorithm; | ||
readonly extractable: boolean; | ||
readonly type: KeyType; | ||
readonly usages: KeyUsage[]; | ||
} | ||
export interface EcdhKeyDeriveParams extends Algorithm { | ||
public: CryptoKey; | ||
} | ||
export interface HkdfParams extends Algorithm { | ||
hash: HashAlgorithmIdentifier; | ||
info: BufferSource; | ||
salt: BufferSource; | ||
} | ||
export interface Pbkdf2Params extends Algorithm { | ||
hash: HashAlgorithmIdentifier; | ||
iterations: number; | ||
salt: BufferSource; | ||
} | ||
export interface AesDerivedKeyParams extends Algorithm { | ||
length: number; | ||
} | ||
export interface HmacImportParams extends Algorithm { | ||
hash: HashAlgorithmIdentifier; | ||
length?: number; | ||
} | ||
export interface JsonWebKey { | ||
alg?: string; | ||
crv?: string; | ||
d?: string; | ||
dp?: string; | ||
dq?: string; | ||
e?: string; | ||
ext?: boolean; | ||
k?: string; | ||
key_ops?: string[]; | ||
kty?: string; | ||
n?: string; | ||
oth?: RsaOtherPrimesInfo[]; | ||
p?: string; | ||
q?: string; | ||
qi?: string; | ||
use?: string; | ||
x?: string; | ||
y?: string; | ||
} | ||
export interface RsaHashedKeyGenParams extends RsaKeyGenParams { | ||
hash: HashAlgorithmIdentifier; | ||
} | ||
export interface EcKeyGenParams extends Algorithm { | ||
namedCurve: NamedCurve; | ||
} | ||
export interface CryptoKeyPair { | ||
privateKey: CryptoKey; | ||
publicKey: CryptoKey; | ||
} | ||
export interface AesKeyGenParams extends Algorithm { | ||
length: number; | ||
} | ||
export interface HmacKeyGenParams extends Algorithm { | ||
hash: HashAlgorithmIdentifier; | ||
length?: number; | ||
} | ||
export interface RsaHashedImportParams extends Algorithm { | ||
hash: HashAlgorithmIdentifier; | ||
} | ||
export interface EcKeyImportParams extends Algorithm { | ||
namedCurve: NamedCurve; | ||
} | ||
export interface AesKeyAlgorithm extends KeyAlgorithm { | ||
length: number; | ||
} | ||
export interface RsaPssParams extends Algorithm { | ||
saltLength: number; | ||
} | ||
export interface EcdsaParams extends Algorithm { | ||
hash: HashAlgorithmIdentifier; | ||
} | ||
export interface Algorithm { | ||
name: string; | ||
} | ||
export interface KeyAlgorithm { | ||
name: string; | ||
} | ||
export interface RsaOtherPrimesInfo { | ||
d?: string; | ||
r?: string; | ||
t?: string; | ||
} | ||
export interface RsaKeyGenParams extends Algorithm { | ||
modulusLength: number; | ||
publicExponent: BigInteger; | ||
} | ||
export type AttestationConveyancePreference = "direct" | "enterprise" | "indirect" | "none"; | ||
export type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb"; | ||
export type COSEAlgorithmIdentifier = number; | ||
export type UserVerificationRequirement = "discouraged" | "preferred" | "required"; | ||
export type AuthenticatorAttachment = "cross-platform" | "platform"; | ||
export type ResidentKeyRequirement = "discouraged" | "preferred" | "required"; | ||
export type BufferSource = ArrayBufferView | ArrayBuffer; | ||
export type PublicKeyCredentialType = "public-key"; | ||
export type AlgorithmIdentifier = Algorithm | string; | ||
export type KeyUsage = "decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey"; | ||
export type KeyFormat = "jwk" | "pkcs8" | "raw" | "spki"; | ||
export type KeyType = "private" | "public" | "secret"; | ||
export type HashAlgorithmIdentifier = AlgorithmIdentifier; | ||
export type NamedCurve = string; | ||
export type BigInteger = Uint8Array; |
@@ -5,4 +5,3 @@ /** | ||
*/ | ||
/// <reference types="node" /> | ||
import type { AuthenticatorAssertionResponse, AuthenticatorAttestationResponse, COSEAlgorithmIdentifier, PublicKeyCredential, PublicKeyCredentialCreationOptions, PublicKeyCredentialDescriptor, PublicKeyCredentialRequestOptions, PublicKeyCredentialUserEntity, AuthenticationExtensionsClientInputs, AuthenticationExtensionsClientOutputs, AuthenticatorAttachment, AttestationConveyancePreference } from './dom'; | ||
import type { AuthenticatorAssertionResponse, AuthenticatorAttestationResponse, PublicKeyCredential, PublicKeyCredentialDescriptor, AuthenticationExtensionsClientInputs, AuthenticationExtensionsClientOutputs, PublicKeyCredentialRpEntity, PublicKeyCredentialType, PublicKeyCredentialParameters, AuthenticatorSelectionCriteria, AttestationConveyancePreference, UserVerificationRequirement, AuthenticatorAttachment, PublicKeyCredentialCreationOptions, PublicKeyCredentialRequestOptions } from './dom'; | ||
export * from './dom'; | ||
@@ -12,8 +11,18 @@ /** | ||
* (eventually) get passed into navigator.credentials.create(...) in the browser. | ||
* | ||
* This should eventually get replaced with official TypeScript DOM types when WebAuthn L3 types | ||
* eventually make it into the language: | ||
* | ||
* https://w3c.github.io/webauthn/#dictdef-publickeycredentialcreationoptionsjson | ||
*/ | ||
export interface PublicKeyCredentialCreationOptionsJSON extends Omit<PublicKeyCredentialCreationOptions, 'challenge' | 'user' | 'excludeCredentials'> { | ||
export interface PublicKeyCredentialCreationOptionsJSON { | ||
rp: PublicKeyCredentialRpEntity; | ||
user: PublicKeyCredentialUserEntityJSON; | ||
challenge: Base64URLString; | ||
excludeCredentials: PublicKeyCredentialDescriptorJSON[]; | ||
extensions?: AuthenticationExtensionsClientInputsFuture; | ||
pubKeyCredParams: PublicKeyCredentialParameters[]; | ||
timeout?: number; | ||
excludeCredentials?: PublicKeyCredentialDescriptorJSON[]; | ||
authenticatorSelection?: AuthenticatorSelectionCriteria; | ||
attestation?: AttestationConveyancePreference; | ||
extensions?: AuthenticationExtensionsClientInputs; | ||
} | ||
@@ -24,13 +33,25 @@ /** | ||
*/ | ||
export interface PublicKeyCredentialRequestOptionsJSON extends Omit<PublicKeyCredentialRequestOptions, 'challenge' | 'allowCredentials'> { | ||
export interface PublicKeyCredentialRequestOptionsJSON { | ||
challenge: Base64URLString; | ||
timeout?: number; | ||
rpId?: string; | ||
allowCredentials?: PublicKeyCredentialDescriptorJSON[]; | ||
extensions?: AuthenticationExtensionsClientInputsFuture; | ||
userVerification?: UserVerificationRequirement; | ||
extensions?: AuthenticationExtensionsClientInputs; | ||
} | ||
export interface PublicKeyCredentialDescriptorJSON extends Omit<PublicKeyCredentialDescriptorFuture, 'id' | 'transports'> { | ||
/** | ||
* https://w3c.github.io/webauthn/#dictdef-publickeycredentialdescriptorjson | ||
*/ | ||
export interface PublicKeyCredentialDescriptorJSON { | ||
id: Base64URLString; | ||
type: PublicKeyCredentialType; | ||
transports?: AuthenticatorTransportFuture[]; | ||
} | ||
export interface PublicKeyCredentialUserEntityJSON extends Omit<PublicKeyCredentialUserEntity, 'id'> { | ||
/** | ||
* https://w3c.github.io/webauthn/#dictdef-publickeycredentialuserentityjson | ||
*/ | ||
export interface PublicKeyCredentialUserEntityJSON { | ||
id: string; | ||
name: string; | ||
displayName: string; | ||
} | ||
@@ -46,8 +67,12 @@ /** | ||
* are Base64URL-encoded in the browser so that they can be sent as JSON to the server. | ||
* | ||
* https://w3c.github.io/webauthn/#dictdef-registrationresponsejson | ||
*/ | ||
export interface RegistrationCredentialJSON extends Omit<RegistrationCredential, 'response' | 'rawId' | 'getClientExtensionResults'> { | ||
export interface RegistrationResponseJSON { | ||
id: Base64URLString; | ||
rawId: Base64URLString; | ||
response: AuthenticatorAttestationResponseJSON; | ||
clientExtensionResults: AuthenticationExtensionsClientOutputsJSON; | ||
transports?: AuthenticatorTransportFuture[]; | ||
authenticatorAttachment?: AuthenticatorAttachment; | ||
clientExtensionResults: AuthenticationExtensionsClientOutputs; | ||
type: PublicKeyCredentialType; | ||
} | ||
@@ -63,46 +88,23 @@ /** | ||
* are Base64URL-encoded in the browser so that they can be sent as JSON to the server. | ||
* | ||
* https://w3c.github.io/webauthn/#dictdef-authenticationresponsejson | ||
*/ | ||
export interface AuthenticationCredentialJSON extends Omit<AuthenticationCredential, 'response' | 'rawId' | 'getClientExtensionResults'> { | ||
export interface AuthenticationResponseJSON { | ||
id: Base64URLString; | ||
rawId: Base64URLString; | ||
response: AuthenticatorAssertionResponseJSON; | ||
clientExtensionResults: AuthenticationExtensionsClientOutputsJSON; | ||
authenticatorAttachment?: AuthenticatorAttachment; | ||
clientExtensionResults: AuthenticationExtensionsClientOutputs; | ||
type: PublicKeyCredentialType; | ||
} | ||
export declare type AttestationFormat = 'fido-u2f' | 'packed' | 'android-safetynet' | 'android-key' | 'tpm' | 'apple' | 'none'; | ||
export declare type AttestationStatement = { | ||
sig?: Buffer; | ||
x5c?: Buffer[]; | ||
response?: Buffer; | ||
alg?: number; | ||
ver?: string; | ||
certInfo?: Buffer; | ||
pubArea?: Buffer; | ||
}; | ||
export interface AuthenticationExtensionsDevicePublicKeyInputs { | ||
attestation?: AttestationConveyancePreference; | ||
attestationFormats?: AttestationFormat[]; | ||
} | ||
export interface AuthenticationExtensionsClientInputsFuture extends AuthenticationExtensionsClientInputs { | ||
devicePubKey?: AuthenticationExtensionsDevicePublicKeyInputs; | ||
} | ||
export interface AuthenticationExtensionsDevicePublicKeyOutputs { | ||
authenticatorOutput: Buffer; | ||
signature: Buffer; | ||
} | ||
export interface AuthenticationExtensionsDevicePublicKeyOutputsJSON { | ||
authenticatorOutput: Base64URLString; | ||
signature: Base64URLString; | ||
} | ||
export interface AuthenticationExtensionsClientOutputsFuture extends AuthenticationExtensionsClientOutputs { | ||
devicePubKey?: AuthenticationExtensionsDevicePublicKeyOutputs; | ||
} | ||
export interface AuthenticationExtensionsClientOutputsJSON extends AuthenticationExtensionsClientOutputs { | ||
devicePubKey?: AuthenticationExtensionsDevicePublicKeyOutputsJSON; | ||
} | ||
/** | ||
* A slightly-modified AuthenticatorAttestationResponse to simplify working with ArrayBuffers that | ||
* are Base64URL-encoded in the browser so that they can be sent as JSON to the server. | ||
* | ||
* https://w3c.github.io/webauthn/#dictdef-authenticatorattestationresponsejson | ||
*/ | ||
export interface AuthenticatorAttestationResponseJSON extends Omit<AuthenticatorAttestationResponseFuture, 'clientDataJSON' | 'attestationObject'> { | ||
export interface AuthenticatorAttestationResponseJSON { | ||
clientDataJSON: Base64URLString; | ||
attestationObject: Base64URLString; | ||
transports?: AuthenticatorTransportFuture[]; | ||
} | ||
@@ -112,6 +114,8 @@ /** | ||
* are Base64URL-encoded in the browser so that they can be sent as JSON to the server. | ||
* | ||
* https://w3c.github.io/webauthn/#dictdef-authenticatorassertionresponsejson | ||
*/ | ||
export interface AuthenticatorAssertionResponseJSON extends Omit<AuthenticatorAssertionResponse, 'authenticatorData' | 'clientDataJSON' | 'signature' | 'userHandle'> { | ||
export interface AuthenticatorAssertionResponseJSON { | ||
clientDataJSON: Base64URLString; | ||
authenticatorData: Base64URLString; | ||
clientDataJSON: Base64URLString; | ||
signature: Base64URLString; | ||
@@ -123,5 +127,5 @@ userHandle?: string; | ||
*/ | ||
export declare type AuthenticatorDevice = { | ||
credentialPublicKey: Buffer; | ||
credentialID: Buffer; | ||
export type AuthenticatorDevice = { | ||
credentialPublicKey: Uint8Array; | ||
credentialID: Uint8Array; | ||
counter: number; | ||
@@ -133,3 +137,3 @@ transports?: AuthenticatorTransportFuture[]; | ||
*/ | ||
export declare type Base64URLString = string; | ||
export type Base64URLString = string; | ||
/** | ||
@@ -145,6 +149,3 @@ * AuthenticatorAttestationResponse in TypeScript's DOM lib is outdated (up through v3.9.7). | ||
export interface AuthenticatorAttestationResponseFuture extends AuthenticatorAttestationResponse { | ||
getTransports?: () => AuthenticatorTransportFuture[]; | ||
getAuthenticatorData?: () => ArrayBuffer; | ||
getPublicKey?: () => ArrayBuffer; | ||
getPublicKeyAlgorithm?: () => COSEAlgorithmIdentifier[]; | ||
getTransports(): AuthenticatorTransportFuture[]; | ||
} | ||
@@ -156,3 +157,3 @@ /** | ||
*/ | ||
export declare type AuthenticatorTransportFuture = 'ble' | 'internal' | 'nfc' | 'usb' | 'cable' | 'hybrid'; | ||
export type AuthenticatorTransportFuture = 'ble' | 'internal' | 'nfc' | 'usb' | 'cable' | 'hybrid'; | ||
/** | ||
@@ -167,7 +168,14 @@ * A super class of TypeScript's `PublicKeyCredentialDescriptor` that knows about the latest | ||
/** | ||
* A super class of TypeScript's `PublicKeyCredential` that knows about upcoming WebAuthn methods | ||
* | ||
*/ | ||
export type PublicKeyCredentialJSON = RegistrationResponseJSON | AuthenticationResponseJSON; | ||
/** | ||
* A super class of TypeScript's `PublicKeyCredential` that knows about upcoming WebAuthn features | ||
*/ | ||
export interface PublicKeyCredentialFuture extends PublicKeyCredential { | ||
type: PublicKeyCredentialType; | ||
isConditionalMediationAvailable?(): Promise<boolean>; | ||
authenticatorAttachment?: AuthenticatorAttachment; | ||
parseCreationOptionsFromJSON?(options: PublicKeyCredentialCreationOptionsJSON): PublicKeyCredentialCreationOptions; | ||
parseRequestOptionsFromJSON?(options: PublicKeyCredentialRequestOptionsJSON): PublicKeyCredentialRequestOptions; | ||
toJSON?(): PublicKeyCredentialJSON; | ||
} | ||
@@ -179,2 +187,2 @@ /** | ||
*/ | ||
export declare type CredentialDeviceType = 'singleDevice' | 'multiDevice'; | ||
export type CredentialDeviceType = 'singleDevice' | 'multiDevice'; |
@@ -28,2 +28,3 @@ // n.b. ts-morph is a sibling devDependency of typescript, so that the module | ||
'COSEAlgorithmIdentifier', | ||
'Crypto', | ||
'PublicKeyCredential', | ||
@@ -30,0 +31,0 @@ 'PublicKeyCredentialCreationOptions', |
{ | ||
"name": "@simplewebauthn/typescript-types", | ||
"version": "6.3.0-alpha.1", | ||
"version": "7.0.0", | ||
"description": "TypeScript types used by the @simplewebauthn series of libraries", | ||
@@ -30,3 +30,3 @@ "main": "dist/index.js", | ||
], | ||
"gitHead": "cffd994e0fc757c58b15f3e130f50b6b927915a7" | ||
"gitHead": "b4a3c2a17e003f245b53d3c1ce5c231ec551457d" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
23493
501
1