From 2c1d2ab71fe2daba2dad23af1f92f66c92305df5 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 22 Apr 2021 18:45:43 +0200 Subject: [PATCH] fix(typescript): add types for 4.7.0 additions --- types/index.d.ts | 8 +++++++- types/openid-client-tests.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index cb0760d7..1e26758c 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,4 +1,5 @@ /// +/// // TypeScript Version: 3.6 /** @@ -567,9 +568,14 @@ export class Client { [key: string]: unknown; } +interface DeviceFlowPollOptions { + signal?: AbortSignal, +} + export class DeviceFlowHandle { // tslint:disable-line:no-unnecessary-generics - poll(): Promise; + poll(options?: DeviceFlowPollOptions): Promise; + abort(): void; expired(): boolean; expires_at: number; client: TClient; diff --git a/types/openid-client-tests.ts b/types/openid-client-tests.ts index 944b0f9d..3fd504a8 100644 --- a/types/openid-client-tests.ts +++ b/types/openid-client-tests.ts @@ -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 })