UNPKG

2.66 kBTypeScriptView Raw
1import { Maybe } from './common/index';
2import { Permissions } from './ucan/permissions';
3import FileSystem from './fs/index';
4export declare enum Scenario {
5 NotAuthorised = "NOT_AUTHORISED",
6 AuthSucceeded = "AUTH_SUCCEEDED",
7 AuthCancelled = "AUTH_CANCELLED",
8 Continuation = "CONTINUATION"
9}
10export declare type State = NotAuthorised | AuthSucceeded | AuthCancelled | Continuation;
11export declare type NotAuthorised = {
12 scenario: Scenario.NotAuthorised;
13 permissions: Maybe<Permissions>;
14 authenticated: false;
15};
16export declare type AuthSucceeded = {
17 scenario: Scenario.AuthSucceeded;
18 permissions: Maybe<Permissions>;
19 authenticated: true;
20 newUser: boolean;
21 throughLobby: true;
22 username: string;
23 fs?: FileSystem;
24};
25export declare type AuthCancelled = {
26 scenario: Scenario.AuthCancelled;
27 permissions: Maybe<Permissions>;
28 authenticated: false;
29 cancellationReason: string;
30 throughLobby: true;
31};
32export declare type Continuation = {
33 scenario: Scenario.Continuation;
34 permissions: Maybe<Permissions>;
35 authenticated: true;
36 newUser: false;
37 throughLobby: false;
38 username: string;
39 fs?: FileSystem;
40};
41/**
42 * Initialisation error
43 */
44export declare enum InitialisationError {
45 InsecureContext = "INSECURE_CONTEXT",
46 UnsupportedBrowser = "UNSUPPORTED_BROWSER"
47}
48/**
49 * Check if we're authenticated, process any lobby query-parameters present in the URL,
50 * and initiate the user's file system if authenticated (can be disabled).
51 *
52 * See `loadFileSystem` if you want to load the user's file system yourself.
53 * NOTE: Only works on the main/ui thread, as it uses `window.location`.
54 */
55export declare function initialise(options: {
56 permissions?: Permissions;
57 autoRemoveUrlParams?: boolean;
58 loadFileSystem?: boolean;
59 rootKey?: string;
60}): Promise<State>;
61/**
62 * Alias for `initialise`.
63 */
64export { initialise as initialize };
65export declare function isSupported(): Promise<boolean>;
66export * from './auth';
67export * from './filesystem';
68export * from './common/version';
69export declare const fs: typeof FileSystem;
70export * as apps from './apps/index';
71export * as dataRoot from './data-root';
72export * as did from './did/index';
73export * as errors from './errors';
74export * as lobby from './lobby/index';
75export * as path from './path';
76export * as setup from './setup';
77export * as ucan from './ucan/index';
78export * as dns from './dns/index';
79export * as ipfs from './ipfs/index';
80export * as keystore from './keystore';
81export * as machinery from './common/index';
82export * as crypto from './crypto/index';
83export * as cbor from 'cborg';