DefinitelyTyped/types/solid-auth-client/index.d.ts
Vincent 65987f98bf
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)
2020-02-12 09:48:29 -08:00

37 lines
1.3 KiB
TypeScript

// 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>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { EventEmitter } from 'events';
export interface Session {
webId: string;
}
export interface AsyncStorage {
getItem(key: string): Promise<undefined | string>;
setItem(key: string, value: string): Promise<void>;
removeItem(key: string): Promise<void>;
}
interface LoginOptions {
callbackUri?: string;
popupUri?: string;
storage?: Storage | AsyncStorage;
}
export interface SolidAuthClient extends EventEmitter {
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
currentSession(storage?: AsyncStorage): Promise<Session | undefined>;
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>;
}
declare const instantiated: SolidAuthClient;
export default instantiated;