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
This commit is contained in:
Vincent
2020-02-12 09:48:29 -08:00
committed by GitHub
parent 4fe7e4448c
commit 65987f98bf
2 changed files with 10 additions and 2 deletions
+3 -2
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>;
@@ -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) {