Dom fixes 2019 07 11 (#36837)

* Jquery, webappsec-credential-mangment, webgl2

1. `$(window)` will have a different type in TS 3.6,
`JQuery<Window & typeof globalThis>`, so ExpectType
assertions won't work anymore. I weakened the test to test
assignability:

```ts
const jqw: JQuery<Window> = $(window);
```

2. webappsec-credential-management needs to avoid conflicts with the DOM
version that 3.6 will include in order to keep compiling. I copied
interfaces and inlined type aliases where needed.

Inlining type aliases is not the ideal solution, but they don't merge,
so I couldn't copy them like interfaces. And they are (1) used only once
or twice (2) self-explanatory literal unions, so I think it's fine for a
package that will see reduced use once 3.6 is released.

3. webgl2 is also now in the DOM, so the polyfill types need to match
exactly. I deleted an extra property. Again, I expect this package to
stop being used as much once 3.6 is released.

* Rename CredentialData instead of deleting it

* Re-add CredentialData, CredentialBase->Credential

CredentialBase becomes an interface too, which more closely matches the
code in TS 3.6.

* Bump version of webappsec-credential-management
This commit is contained in:
Nathan Shively-Sanders 2019-07-11 14:14:34 -07:00 committed by GitHub
parent dd813f10a9
commit fc1a495675
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 49 deletions

View File

@ -190,9 +190,6 @@ function JQueryStatic() {
target;
});
const myDocForced: JQuery<Document> = $(document);
const myWindow = $(window);
// $ExpectType JQuery<Window>
myWindow;
const myWindowForced: JQuery<Window> = $(window);
// $ExpectType JQuery<Window>
myWindowForced;

View File

@ -1,5 +1,4 @@
import jq = require('jquery/dist/jquery.slim');
const $window = jq(window);
// $ExpectType JQuery<Window>
$window;
const forced: JQuery<Window> = $window;

View File

@ -1,5 +1,4 @@
import jq = require('jquery');
const $window = jq(window);
// $ExpectType JQuery<Window>
$window;
const forced: JQuery<Window> = $window;

View File

@ -1,4 +1,4 @@
// Type definitions for non-npm package W3C (WebAppSec) Credential Management API Level 1, 0.4
// Type definitions for non-npm package W3C (WebAppSec) Credential Management API Level 1, 0.5
// Project: https://github.com/w3c/webappsec-credential-management
// Definitions by: Iain McGinniss <https://github.com/iainmcgin>
// Joao Peixoto <https://github.com/Hartimer>
@ -124,7 +124,7 @@ interface CredentialData {
* The credentials identifier. This might be a GUID, username, or email
* address, for instance.
*/
id: string;
readonly id: string;
}
type CredentialType = PasswordCredential|FederatedCredential|PublicKeyCredential;
@ -134,13 +134,12 @@ type CredentialType = PasswordCredential|FederatedCredential|PublicKeyCredential
* will inherit.
* @see {@link https://www.w3.org/TR/credential-management-1/#credential}
*/
declare abstract class CredentialBase {
interface Credential {
/**
* The credentials identifier. This might be a GUID, username, or email
* address, for instance.
*/
readonly id: string;
/**
* The credentials type.
*/
@ -170,7 +169,9 @@ interface SiteBoundCredentialData extends CredentialData {
* agents credential
* store.
*/
declare abstract class SiteBoundCredential extends CredentialBase {
// tslint:disable-next-line no-empty-interface
interface SiteBoundCredential extends Credential { }
declare abstract class SiteBoundCredential {
/**
* A name associated with the credential, intended as a human-understandable
* public name.
@ -372,16 +373,21 @@ interface FederatedCredentialRequestOptions {
// Type definitions for webauthn
// Spec: https://w3c.github.io/webauthn/
interface txAuthGenericArg {
content: ArrayBuffer;
contentType: string;
}
/**
* @see {@link https://w3c.github.io/webauthn/#enumdef-publickeycredentialtype}
*/
type PublicKeyCredentialType = "public-key";
/**
* @see {@link https://w3c.github.io/webauthn/#enumdef-userverificationrequirement}
*/
type UserVerificationRequirement = "required" | "preferred" | "discouraged";
interface AuthenticationExtensionsClientInputs {
appid?: string;
authnSel?: Array<ArrayBufferView | ArrayBuffer>;
exts?: boolean;
loc?: boolean;
txAuthGeneric?: txAuthGenericArg;
txAuthSimple?: string;
uvi?: boolean;
uvm?: boolean;
}
/**
* @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialrequestoptions}
@ -391,8 +397,8 @@ interface PublicKeyCredentialRequestOptions {
timeout?: number;
rpId?: string;
allowCredentials?: PublicKeyCredentialDescriptor[];
userVerification?: UserVerificationRequirement;
extensions?: any;
userVerification?: "required" | "preferred" | "discouraged";
extensions?: AuthenticationExtensionsClientInputs;
}
/**
@ -416,43 +422,28 @@ interface PublicKeyCredentialUserEntity {
* @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialparameters}
*/
interface PublicKeyCredentialParameters {
type: PublicKeyCredentialType;
type: "public-key";
alg: number;
}
/**
* @see {@link https://w3c.github.io/webauthn/#transport}
*/
type AuthenticatorTransport = "usb" | "nfc" | "ble" | "internal";
/**
* @see {@link https://w3c.github.io/webauthn/#dictdef-publickeycredentialdescriptor}
*/
interface PublicKeyCredentialDescriptor {
type: PublicKeyCredentialType;
type: "public-key";
id: BufferSource;
transports?: AuthenticatorTransport[];
transports?: Array<"usb" | "nfc" | "ble" | "internal">;
}
/**
* @see {@link https://w3c.github.io/webauthn/#attachment}
*/
type AuthenticatorAttachment = "platform" | "cross-platform";
/**
* @see {@link https://w3c.github.io/webauthn/#dictdef-authenticatorselectioncriteria}
*/
interface AuthenticatorSelectionCriteria {
authenticatorAttachment?: AuthenticatorAttachment;
authenticatorAttachment?: "platform" | "cross-platform";
requireResidentKey?: boolean;
userVerification?: UserVerificationRequirement;
userVerification?: "required" | "preferred" | "discouraged";
}
/**
* @see {@link https://w3c.github.io/webauthn/#attestation-convey}
*/
type AttestationConveyancePreference = "none" | "indirect" | "direct";
/**
* @see {@link https://w3c.github.io/webauthn/#dictdef-makepublickeycredentialoptions}
*/
@ -466,8 +457,8 @@ interface PublicKeyCredentialCreationOptions {
timeout?: number;
excludeCredentials?: PublicKeyCredentialDescriptor[];
authenticatorSelection?: AuthenticatorSelectionCriteria;
attestation?: AttestationConveyancePreference;
extensions?: any;
attestation?: "none" | "indirect" | "direct";
extensions?: AuthenticationExtensionsClientInputs;
}
/**
@ -496,8 +487,8 @@ interface AuthenticatorAssertionResponse extends AuthenticatorResponse {
/**
* @see {@link https://w3c.github.io/webauthn/#publickeycredential}
*/
interface PublicKeyCredential extends CredentialData {
readonly type: PublicKeyCredentialType;
interface PublicKeyCredential extends Credential {
readonly type: "public-key";
readonly rawId: ArrayBuffer;
readonly response: AuthenticatorAttestationResponse|AuthenticatorAssertionResponse;
readonly response: AuthenticatorResponse;
}

View File

@ -798,7 +798,6 @@ declare var WebGL2RenderingContext: {
readonly STENCIL_CLEAR_VALUE: number;
readonly STENCIL_FAIL: number;
readonly STENCIL_FUNC: number;
readonly STENCIL_INDEX: number;
readonly STENCIL_INDEX8: number;
readonly STENCIL_PASS_DEPTH_FAIL: number;
readonly STENCIL_PASS_DEPTH_PASS: number;