Skip to content

Commit

Permalink
fix(typescript): add types for 4.7.0 additions
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Apr 22, 2021
1 parent 01d0698 commit 2c1d2ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference types="node" />
/// <reference lib="dom"/>
// TypeScript Version: 3.6

/**
Expand Down Expand Up @@ -567,9 +568,14 @@ export class Client {
[key: string]: unknown;
}

interface DeviceFlowPollOptions {
signal?: AbortSignal,
}

export class DeviceFlowHandle<TClient extends Client> {
// tslint:disable-line:no-unnecessary-generics
poll(): Promise<TokenSet>;
poll(options?: DeviceFlowPollOptions): Promise<TokenSet>;
abort(): void;
expired(): boolean;
expires_at: number;
client: TClient;
Expand Down
8 changes: 7 additions & 1 deletion types/openid-client-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ async (req: IncomingMessage) => {
client.requestResource('https://rs.example.com/resource', 'token', { DPoP: jwk })

client.deviceAuthorization({}, { DPoP: keyobject })
client.deviceAuthorization({}, { DPoP: jwk })
const handle = await client.deviceAuthorization({}, { DPoP: jwk })

handle.abort();
handle.poll();

const ac = new AbortController();
handle.poll({ signal: ac.signal });

client.grant({ grant_type: 'client_credentials' }, { DPoP: keyobject })
client.grant({ grant_type: 'client_credentials' }, { DPoP: jwk })
Expand Down

0 comments on commit 2c1d2ab

Please sign in to comment.