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:
f8d53797af/src/solid-auth-client.js (L83)
This commit is contained in:
Vincent 2020-02-12 18:48:29 +01:00 committed by GitHub
parent 4fe7e4448c
commit 65987f98bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -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 <https://github.com/Vinnl>
// James <https://github.com/durandj>
@ -25,7 +25,8 @@ interface LoginOptions {
export interface SolidAuthClient extends EventEmitter {
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
currentSession(storage?: AsyncStorage): Promise<Session | undefined>;
trackSession(callback: (session?: Session) => void): void;
trackSession(callback: (session?: Session) => void): Promise<void>;
stopTrackSession(callback: (session?: Session) => void): void;
login(identityProvider: string, options?: LoginOptions): Promise<void>;
logout(storage?: AsyncStorage): Promise<void>;
popupLogin(params?: LoginOptions): Promise<Session>;

View File

@ -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) {