@aerogel/plugin-solid 0.0.1-next.04142b2821eaa6e510478867fc4e63149b6ae8c9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/InruptAuthenticator.lazy-BvpQLGoj.js +9 -0
- package/dist/InruptAuthenticator.lazy-BvpQLGoj.js.map +1 -0
- package/dist/LegacyAuthenticator.lazy-ChFFqP14.js +5 -0
- package/dist/LegacyAuthenticator.lazy-ChFFqP14.js.map +1 -0
- package/dist/aerogel-plugin-solid.d.ts +269 -0
- package/dist/aerogel-plugin-solid.js +620 -0
- package/dist/aerogel-plugin-solid.js.map +1 -0
- package/package.json +49 -0
- package/src/auth/Authenticator.ts +123 -0
- package/src/auth/authenticators/InruptAuthenticator.lazy.ts +1 -0
- package/src/auth/authenticators/InruptAuthenticator.ts +103 -0
- package/src/auth/authenticators/LegacyAuthenticator.lazy.ts +1 -0
- package/src/auth/authenticators/LegacyAuthenticator.ts +80 -0
- package/src/auth/index.ts +40 -0
- package/src/components/SolidAvatar.vue +35 -0
- package/src/components/SolidImage.vue +33 -0
- package/src/components/SolidLogin.vue +31 -0
- package/src/components/index.ts +3 -0
- package/src/errors/AuthenticationCancelledError.ts +3 -0
- package/src/errors/AuthenticationFailedError.ts +22 -0
- package/src/errors/ContainerAlreadyInUse.ts +11 -0
- package/src/errors/index.ts +3 -0
- package/src/forms/validation.ts +11 -0
- package/src/index.css +1 -0
- package/src/index.test.ts +24 -0
- package/src/index.ts +65 -0
- package/src/services/Solid.state.ts +56 -0
- package/src/services/Solid.ts +549 -0
- package/src/testing/setup.ts +11 -0
- package/src/types/env.d.ts +1 -0
- package/src/types/shims.d.ts +7 -0
- package/src/types/solid-auth-client.d.ts +21 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { events as n, fetch as t, handleIncomingRedirect as c, login as g, logout as i } from "@inrupt/solid-client-authn-browser";
|
|
2
|
+
export {
|
|
3
|
+
n as events,
|
|
4
|
+
t as fetch,
|
|
5
|
+
c as handleIncomingRedirect,
|
|
6
|
+
g as login,
|
|
7
|
+
i as logout
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=InruptAuthenticator.lazy-BvpQLGoj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InruptAuthenticator.lazy-BvpQLGoj.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegacyAuthenticator.lazy-ChFFqP14.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { Closure } from '@noeldemartin/utils';
|
|
2
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
3
|
+
import { ComponentProvideOptions } from 'vue';
|
|
4
|
+
import { DefineComponent } from 'vue';
|
|
5
|
+
import { Engine } from 'soukai';
|
|
6
|
+
import { ErrorSource } from '@aerogel/core';
|
|
7
|
+
import { Facade } from '@noeldemartin/utils';
|
|
8
|
+
import { Fetch } from 'soukai-solid';
|
|
9
|
+
import { Fetch as Fetch_2 } from '@noeldemartin/solid-utils';
|
|
10
|
+
import { FluentArray } from '@noeldemartin/utils';
|
|
11
|
+
import { GetClosureArgs } from '@noeldemartin/utils';
|
|
12
|
+
import { JSError } from '@noeldemartin/utils';
|
|
13
|
+
import { JSErrorOptions } from '@noeldemartin/utils';
|
|
14
|
+
import { NullablePartial } from '@noeldemartin/utils';
|
|
15
|
+
import { Plugin as Plugin_2 } from '@aerogel/core';
|
|
16
|
+
import { PromisedValue } from '@noeldemartin/utils';
|
|
17
|
+
import { PublicProps } from 'vue';
|
|
18
|
+
import { ServiceWithState } from '@aerogel/core';
|
|
19
|
+
import { SolidContainer } from 'soukai-solid';
|
|
20
|
+
import { SolidEngine } from 'soukai-solid';
|
|
21
|
+
import { SolidModelConstructor } from 'soukai-solid';
|
|
22
|
+
import { SolidStore } from '@noeldemartin/solid-utils';
|
|
23
|
+
import { SolidTypeIndex } from 'soukai-solid';
|
|
24
|
+
import { SolidUserProfile } from '@noeldemartin/solid-utils';
|
|
25
|
+
|
|
26
|
+
declare type __VLS_Props = {
|
|
27
|
+
src: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export declare class AuthenticationCancelledError extends JSError {
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export declare class AuthenticationFailedError extends JSError {
|
|
34
|
+
readonly description?: string | null;
|
|
35
|
+
constructor(message: string, description?: string | null, options?: JSErrorOptions);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export declare abstract class Authenticator {
|
|
39
|
+
name: AuthenticatorName;
|
|
40
|
+
protected authenticatedFetch?: Fetch;
|
|
41
|
+
protected booted?: PromisedValue<void>;
|
|
42
|
+
protected listeners: FluentArray<AuthenticatorListener>;
|
|
43
|
+
protected _engine?: SolidEngine;
|
|
44
|
+
abstract login(loginUrl: string, user?: SolidUserProfile | null): Promise<AuthSession>;
|
|
45
|
+
abstract logout(): Promise<void>;
|
|
46
|
+
get engine(): Engine;
|
|
47
|
+
getAuthenticatedFetch(): Fetch | null;
|
|
48
|
+
requireAuthenticatedFetch(): Fetch;
|
|
49
|
+
addListener(listener: AuthenticatorListener): () => void;
|
|
50
|
+
removeListener(listener: AuthenticatorListener): void;
|
|
51
|
+
boot(): Promise<void>;
|
|
52
|
+
protected abstract restoreSession(): Promise<void>;
|
|
53
|
+
protected initAuthenticatedFetch(fetch: Fetch): Promise<void>;
|
|
54
|
+
protected startSession(sessionData: Omit<AuthSession, 'authenticator'>): Promise<AuthSession>;
|
|
55
|
+
protected failSession(loginUrl: string, error: ErrorSource): Promise<void>;
|
|
56
|
+
protected endSession(): Promise<void>;
|
|
57
|
+
protected notifyListeners<Event extends ListenerEvent>(event: Event, ...payload: ListenerEventPayload<Event>): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export declare interface AuthenticatorListener {
|
|
61
|
+
onSessionStarted?: (session: AuthSession) => Promise<void> | void;
|
|
62
|
+
onSessionFailed?: (loginUrl: string, error: ErrorSource) => Promise<void> | void;
|
|
63
|
+
onSessionEnded?: () => Promise<void> | void;
|
|
64
|
+
onAuthenticatedFetchReady?: (fetch: Fetch) => Promise<void> | void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export declare type AuthenticatorName = keyof Authenticators;
|
|
68
|
+
|
|
69
|
+
export declare interface Authenticators extends BaseAuthenticators {
|
|
70
|
+
default: Authenticator;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export declare const authenticators: {
|
|
74
|
+
inrupt: InruptAuthenticator;
|
|
75
|
+
legacy: LegacyAuthenticator;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export declare interface AuthSession {
|
|
79
|
+
user: SolidUserProfile;
|
|
80
|
+
loginUrl: string;
|
|
81
|
+
authenticator: Authenticator;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare type BaseAuthenticators = typeof authenticators;
|
|
85
|
+
|
|
86
|
+
export declare class ContainerAlreadyInUse extends JSError {
|
|
87
|
+
constructor(container: SolidContainer, options?: JSErrorOptions);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare const _default: ServiceWithState< {
|
|
91
|
+
autoReconnect: boolean;
|
|
92
|
+
dismissed: boolean;
|
|
93
|
+
ignorePreviousSessionError: boolean;
|
|
94
|
+
loginStartupError: ErrorSource | null;
|
|
95
|
+
loginOngoing: boolean;
|
|
96
|
+
preferredAuthenticator: AuthenticatorName | null;
|
|
97
|
+
previousSession: {
|
|
98
|
+
profile?: SolidUserProfile;
|
|
99
|
+
authenticator: AuthenticatorName;
|
|
100
|
+
loginUrl: string;
|
|
101
|
+
error: ErrorSource | null;
|
|
102
|
+
} | null;
|
|
103
|
+
profiles: Record<string, SolidUserProfile>;
|
|
104
|
+
session: AuthSession | null;
|
|
105
|
+
loginStale: boolean;
|
|
106
|
+
staleProfiles: string[];
|
|
107
|
+
}, {
|
|
108
|
+
user: SolidUserProfile | null;
|
|
109
|
+
authenticator: Authenticator | null;
|
|
110
|
+
fetch: Fetch_2;
|
|
111
|
+
error: unknown;
|
|
112
|
+
}, Partial<{
|
|
113
|
+
autoReconnect: boolean;
|
|
114
|
+
dismissed: boolean;
|
|
115
|
+
ignorePreviousSessionError: boolean;
|
|
116
|
+
loginStartupError: ErrorSource | null;
|
|
117
|
+
loginOngoing: boolean;
|
|
118
|
+
preferredAuthenticator: AuthenticatorName | null;
|
|
119
|
+
previousSession: {
|
|
120
|
+
profile?: SolidUserProfile;
|
|
121
|
+
authenticator: AuthenticatorName;
|
|
122
|
+
loginUrl: string;
|
|
123
|
+
error: ErrorSource | null;
|
|
124
|
+
} | null;
|
|
125
|
+
profiles: Record<string, SolidUserProfile>;
|
|
126
|
+
session: AuthSession | null;
|
|
127
|
+
loginStale: boolean;
|
|
128
|
+
staleProfiles: string[];
|
|
129
|
+
}>>;
|
|
130
|
+
|
|
131
|
+
export declare function getAuthenticator<T extends AuthenticatorName>(name: T): Authenticators[T];
|
|
132
|
+
|
|
133
|
+
declare class InruptAuthenticator extends Authenticator {
|
|
134
|
+
private _events;
|
|
135
|
+
private _fetch;
|
|
136
|
+
private _login;
|
|
137
|
+
private _logout;
|
|
138
|
+
private _handleIncomingRedirect;
|
|
139
|
+
login(loginUrl: string): Promise<AuthSession>;
|
|
140
|
+
logout(): Promise<void>;
|
|
141
|
+
protected restoreSession(): Promise<void>;
|
|
142
|
+
protected loginFromRedirect(): Promise<void>;
|
|
143
|
+
protected initSession(webId: string): Promise<void>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare class LegacyAuthenticator extends Authenticator {
|
|
147
|
+
private store;
|
|
148
|
+
constructor();
|
|
149
|
+
login(loginUrl: string, user?: SolidUserProfile | null): Promise<AuthSession>;
|
|
150
|
+
logout(): Promise<void>;
|
|
151
|
+
protected restoreSession(): Promise<void>;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
declare type ListenerEvent = keyof AuthenticatorListener;
|
|
155
|
+
|
|
156
|
+
declare type ListenerEventPayload<Event extends ListenerEvent, Callback = AuthenticatorListener[Event]> = Callback extends Closure ? GetClosureArgs<Callback> : never;
|
|
157
|
+
|
|
158
|
+
export declare type LoginOptions = NullablePartial<{
|
|
159
|
+
authenticator: AuthenticatorName;
|
|
160
|
+
onError(error: ErrorSource): unknown;
|
|
161
|
+
fallbackUrl: string;
|
|
162
|
+
loading: boolean;
|
|
163
|
+
}>;
|
|
164
|
+
|
|
165
|
+
export declare interface Options {
|
|
166
|
+
autoReconnect?: boolean;
|
|
167
|
+
authenticators?: Record<string, Authenticator>;
|
|
168
|
+
defaultAuthenticator?: AuthenticatorName;
|
|
169
|
+
onUserProfileLoaded?(user: SolidUserProfile, store: SolidStore): Promise<unknown> | unknown;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export declare type ReconnectOptions = Omit<LoginOptions, 'authenticator'> & {
|
|
173
|
+
force?: boolean;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export declare function registerAuthenticator<T extends AuthenticatorName>(name: T, authenticator: Authenticators[T]): void;
|
|
177
|
+
|
|
178
|
+
export declare function registerAuthenticators(customAuthenticators: Record<string, Authenticator>): void;
|
|
179
|
+
|
|
180
|
+
declare const services: {
|
|
181
|
+
$solid: Facade<SolidService>;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export declare function setDefaultAuthenticator(authenticator: Authenticator): void;
|
|
185
|
+
|
|
186
|
+
export declare const Solid: Facade<SolidService>;
|
|
187
|
+
|
|
188
|
+
declare function solid(options?: Options): Plugin_2;
|
|
189
|
+
export default solid;
|
|
190
|
+
|
|
191
|
+
export declare const SolidAvatar: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
192
|
+
|
|
193
|
+
export declare const SolidImage: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLImageElement>;
|
|
194
|
+
|
|
195
|
+
export declare const SolidLogin: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLFormElement>;
|
|
196
|
+
|
|
197
|
+
export declare class SolidService extends _default {
|
|
198
|
+
isLoggedIn(): this is {
|
|
199
|
+
session: AuthSession;
|
|
200
|
+
user: SolidUserProfile;
|
|
201
|
+
authenticator: Authenticator;
|
|
202
|
+
};
|
|
203
|
+
wasLoggedIn(): this is {
|
|
204
|
+
user: SolidUserProfile;
|
|
205
|
+
};
|
|
206
|
+
hasLoggedIn(): this is {
|
|
207
|
+
user: SolidUserProfile;
|
|
208
|
+
};
|
|
209
|
+
requireAuthenticator(): Authenticator;
|
|
210
|
+
requireUser(): SolidUserProfile;
|
|
211
|
+
requireUserProfile(url: string): Promise<SolidUserProfile>;
|
|
212
|
+
getUserProfile(url: string, options: Omit<UserProfileOptions, 'required'> & {
|
|
213
|
+
required: true;
|
|
214
|
+
}): Promise<SolidUserProfile>;
|
|
215
|
+
getUserProfile(url: string, options?: UserProfileOptions): Promise<SolidUserProfile | null>;
|
|
216
|
+
refreshUserProfile(): Promise<void>;
|
|
217
|
+
login(loginUrl: string, options?: LoginOptions): Promise<boolean>;
|
|
218
|
+
reconnect(options?: ReconnectOptions): Promise<void>;
|
|
219
|
+
logout(force?: boolean): Promise<void>;
|
|
220
|
+
whenLoggedIn<T>(callback: (session: AuthSession) => T): Promise<T>;
|
|
221
|
+
dismiss(): void;
|
|
222
|
+
findOrCreatePrivateTypeIndex(): Promise<SolidTypeIndex>;
|
|
223
|
+
findPrivateTypeIndex(): Promise<SolidTypeIndex | null>;
|
|
224
|
+
findOrCreatePublicTypeIndex(): Promise<SolidTypeIndex>;
|
|
225
|
+
findPublicTypeIndex(): Promise<SolidTypeIndex | null>;
|
|
226
|
+
createPrivateContainer(options: {
|
|
227
|
+
url: string;
|
|
228
|
+
name?: string;
|
|
229
|
+
registerFor?: SolidModelConstructor;
|
|
230
|
+
reuseExisting?: boolean;
|
|
231
|
+
}): Promise<SolidContainer>;
|
|
232
|
+
protected boot(): Promise<void>;
|
|
233
|
+
protected createPrivateTypeIndex(): Promise<SolidTypeIndex>;
|
|
234
|
+
createPublicTypeIndex(): Promise<SolidTypeIndex>;
|
|
235
|
+
protected attemptLogin(loginUrl: string, options: LoginOptions): Promise<boolean>;
|
|
236
|
+
private restorePreviousSession;
|
|
237
|
+
private startupReconnect;
|
|
238
|
+
private reconnectOnStartup;
|
|
239
|
+
private forcingReconnect;
|
|
240
|
+
private bootAuthenticator;
|
|
241
|
+
private rememberProfile;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export declare type SolidServices = typeof services;
|
|
245
|
+
|
|
246
|
+
export declare type UserProfileOptions = NullablePartial<{
|
|
247
|
+
required: boolean;
|
|
248
|
+
markStale: boolean;
|
|
249
|
+
}>;
|
|
250
|
+
|
|
251
|
+
export { }
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
declare module '@aerogel/core' {
|
|
255
|
+
interface Services extends SolidServices {
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
declare module '@aerogel/core' {
|
|
261
|
+
interface EventsPayload {
|
|
262
|
+
'auth:fetch-ready': Fetch;
|
|
263
|
+
'auth:before-login': void;
|
|
264
|
+
'auth:login': AuthSession;
|
|
265
|
+
'auth:logout': void;
|
|
266
|
+
'auth:after-logout': void;
|
|
267
|
+
'solid:user-profile-loaded': [SolidUserProfile, SolidStore];
|
|
268
|
+
}
|
|
269
|
+
}
|