From 65987f98bf046941283e5adbc5139cc6cc1a87f3 Mon Sep 17 00:00:00 2001 From: Vincent Date: Wed, 12 Feb 2020 18:48:29 +0100 Subject: [PATCH] Update solid-auth-client API for 2.4 release (#42309) * Update API for 2.4 release Specifically, it added the stopTrackSession() method. * Reflect that trackSession technically is async It's typically only used for the callback, but it _is_ an async function: https://github.com/solid/solid-auth-client/blob/f8d53797af61df5a25b70e2b126088041ba1e35a/src/solid-auth-client.js#L83 --- types/solid-auth-client/index.d.ts | 5 +++-- types/solid-auth-client/solid-auth-client-tests.ts | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/types/solid-auth-client/index.d.ts b/types/solid-auth-client/index.d.ts index 4c3e9bbaa1..2c2995c917 100644 --- a/types/solid-auth-client/index.d.ts +++ b/types/solid-auth-client/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for solid-auth-client 2.3 +// Type definitions for solid-auth-client 2.4 // Project: https://github.com/solid/solid-auth-client#readme // Definitions by: Vincent // James @@ -25,7 +25,8 @@ interface LoginOptions { export interface SolidAuthClient extends EventEmitter { fetch(input: RequestInfo, init?: RequestInit): Promise; currentSession(storage?: AsyncStorage): Promise; - trackSession(callback: (session?: Session) => void): void; + trackSession(callback: (session?: Session) => void): Promise; + stopTrackSession(callback: (session?: Session) => void): void; login(identityProvider: string, options?: LoginOptions): Promise; logout(storage?: AsyncStorage): Promise; popupLogin(params?: LoginOptions): Promise; diff --git a/types/solid-auth-client/solid-auth-client-tests.ts b/types/solid-auth-client/solid-auth-client-tests.ts index 8b813f0411..ee9f505217 100644 --- a/types/solid-auth-client/solid-auth-client-tests.ts +++ b/types/solid-auth-client/solid-auth-client-tests.ts @@ -7,6 +7,13 @@ auth.trackSession(session => { console.log(`The user is ${session.webId}`); }); +auth.stopTrackSession(session => { + if (!session) + console.log('The user is not logged in'); + else + console.log(`The user is ${session.webId}`); +}); + auth.fetch('https://timbl.com/timbl/Public/friends.ttl').then(console.log); async function login(idp: string) {