@aerogel/plugin-solid 0.0.1-next.0d1cf82f9dfbe1d3e7ec5644f85f97a43c8c2334
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 +309 -0
- package/dist/aerogel-plugin-solid.js +683 -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/AGSolidImage.vue +33 -0
- package/src/components/AGSolidStatus.ts +5 -0
- package/src/components/AGSolidStatus.vue +68 -0
- package/src/components/AGSolidUserAvatar.vue +35 -0
- package/src/components/index.ts +4 -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.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,309 @@
|
|
|
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 { ExtractPropTypes } from 'vue';
|
|
8
|
+
import { Facade } from '@noeldemartin/utils';
|
|
9
|
+
import { Fetch } from 'soukai-solid';
|
|
10
|
+
import { Fetch as Fetch_2 } from '@noeldemartin/solid-utils';
|
|
11
|
+
import { FluentArray } from '@noeldemartin/utils';
|
|
12
|
+
import { GetClosureArgs } from '@noeldemartin/utils';
|
|
13
|
+
import { JSError } from '@noeldemartin/utils';
|
|
14
|
+
import { JSErrorOptions } from '@noeldemartin/utils';
|
|
15
|
+
import { NullablePartial } from '@noeldemartin/utils';
|
|
16
|
+
import { Plugin as Plugin_2 } from '@aerogel/core';
|
|
17
|
+
import { PromisedValue } from '@noeldemartin/utils';
|
|
18
|
+
import { PropType } from 'vue';
|
|
19
|
+
import { PublicProps } from 'vue';
|
|
20
|
+
import { ServiceWithState } from '@aerogel/core';
|
|
21
|
+
import { SolidContainer } from 'soukai-solid';
|
|
22
|
+
import { SolidEngine } from 'soukai-solid';
|
|
23
|
+
import { SolidModelConstructor } from 'soukai-solid';
|
|
24
|
+
import { SolidStore } from '@noeldemartin/solid-utils';
|
|
25
|
+
import { SolidTypeIndex } from 'soukai-solid';
|
|
26
|
+
import { SolidUserProfile } from '@noeldemartin/solid-utils';
|
|
27
|
+
|
|
28
|
+
declare const __VLS_component: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
29
|
+
|
|
30
|
+
declare function __VLS_template(): {
|
|
31
|
+
attrs: Partial<{}>;
|
|
32
|
+
slots: {
|
|
33
|
+
'login-stale'?(_: {}): any;
|
|
34
|
+
'login-ongoing'?(_: {}): any;
|
|
35
|
+
'logged-in'?(_: {
|
|
36
|
+
session: AuthSession;
|
|
37
|
+
}): any;
|
|
38
|
+
'logged-out'?(_: {}): any;
|
|
39
|
+
};
|
|
40
|
+
refs: {};
|
|
41
|
+
rootEl: HTMLDivElement;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
45
|
+
|
|
46
|
+
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
47
|
+
new (): {
|
|
48
|
+
$slots: S;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export declare const AGSolidImage: DefineComponent<ExtractPropTypes< {
|
|
53
|
+
src: {
|
|
54
|
+
type?: PropType<string> | undefined;
|
|
55
|
+
validator?(value: unknown): boolean;
|
|
56
|
+
} & {
|
|
57
|
+
required: true;
|
|
58
|
+
};
|
|
59
|
+
}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {
|
|
60
|
+
src: {
|
|
61
|
+
type?: PropType<string> | undefined;
|
|
62
|
+
validator?(value: unknown): boolean;
|
|
63
|
+
} & {
|
|
64
|
+
required: true;
|
|
65
|
+
};
|
|
66
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLImageElement>;
|
|
67
|
+
|
|
68
|
+
export declare const AGSolidStatus: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
69
|
+
|
|
70
|
+
export declare const AGSolidUserAvatar: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
71
|
+
|
|
72
|
+
export declare class AuthenticationCancelledError extends JSError {
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export declare class AuthenticationFailedError extends JSError {
|
|
76
|
+
readonly description?: string | null;
|
|
77
|
+
constructor(message: string, description?: string | null, options?: JSErrorOptions);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export declare abstract class Authenticator {
|
|
81
|
+
name: AuthenticatorName;
|
|
82
|
+
protected authenticatedFetch?: Fetch;
|
|
83
|
+
protected booted?: PromisedValue<void>;
|
|
84
|
+
protected listeners: FluentArray<AuthenticatorListener>;
|
|
85
|
+
protected _engine?: SolidEngine;
|
|
86
|
+
abstract login(loginUrl: string, user?: SolidUserProfile | null): Promise<AuthSession>;
|
|
87
|
+
abstract logout(): Promise<void>;
|
|
88
|
+
get engine(): Engine;
|
|
89
|
+
getAuthenticatedFetch(): Fetch | null;
|
|
90
|
+
requireAuthenticatedFetch(): Fetch;
|
|
91
|
+
addListener(listener: AuthenticatorListener): () => void;
|
|
92
|
+
removeListener(listener: AuthenticatorListener): void;
|
|
93
|
+
boot(): Promise<void>;
|
|
94
|
+
protected abstract restoreSession(): Promise<void>;
|
|
95
|
+
protected initAuthenticatedFetch(fetch: Fetch): Promise<void>;
|
|
96
|
+
protected startSession(sessionData: Omit<AuthSession, 'authenticator'>): Promise<AuthSession>;
|
|
97
|
+
protected failSession(loginUrl: string, error: ErrorSource): Promise<void>;
|
|
98
|
+
protected endSession(): Promise<void>;
|
|
99
|
+
protected notifyListeners<Event extends ListenerEvent>(event: Event, ...payload: ListenerEventPayload<Event>): Promise<void>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export declare interface AuthenticatorListener {
|
|
103
|
+
onSessionStarted?: (session: AuthSession) => Promise<void> | void;
|
|
104
|
+
onSessionFailed?: (loginUrl: string, error: ErrorSource) => Promise<void> | void;
|
|
105
|
+
onSessionEnded?: () => Promise<void> | void;
|
|
106
|
+
onAuthenticatedFetchReady?: (fetch: Fetch) => Promise<void> | void;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export declare type AuthenticatorName = keyof Authenticators;
|
|
110
|
+
|
|
111
|
+
export declare interface Authenticators extends BaseAuthenticators {
|
|
112
|
+
default: Authenticator;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export declare const authenticators: {
|
|
116
|
+
inrupt: InruptAuthenticator;
|
|
117
|
+
legacy: LegacyAuthenticator;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export declare interface AuthSession {
|
|
121
|
+
user: SolidUserProfile;
|
|
122
|
+
loginUrl: string;
|
|
123
|
+
authenticator: Authenticator;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare type BaseAuthenticators = typeof authenticators;
|
|
127
|
+
|
|
128
|
+
export declare class ContainerAlreadyInUse extends JSError {
|
|
129
|
+
constructor(container: SolidContainer, options?: JSErrorOptions);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
declare const _default: ServiceWithState< {
|
|
133
|
+
autoReconnect: boolean;
|
|
134
|
+
dismissed: boolean;
|
|
135
|
+
ignorePreviousSessionError: boolean;
|
|
136
|
+
loginStartupError: ErrorSource | null;
|
|
137
|
+
loginOngoing: boolean;
|
|
138
|
+
preferredAuthenticator: AuthenticatorName | null;
|
|
139
|
+
previousSession: {
|
|
140
|
+
profile?: SolidUserProfile;
|
|
141
|
+
authenticator: AuthenticatorName;
|
|
142
|
+
loginUrl: string;
|
|
143
|
+
error: ErrorSource | null;
|
|
144
|
+
} | null;
|
|
145
|
+
profiles: Record<string, SolidUserProfile>;
|
|
146
|
+
session: AuthSession | null;
|
|
147
|
+
loginStale: boolean;
|
|
148
|
+
staleProfiles: string[];
|
|
149
|
+
}, {
|
|
150
|
+
user: SolidUserProfile | null;
|
|
151
|
+
authenticator: Authenticator | null;
|
|
152
|
+
fetch: Fetch_2;
|
|
153
|
+
error: unknown;
|
|
154
|
+
}, Partial<{
|
|
155
|
+
autoReconnect: boolean;
|
|
156
|
+
dismissed: boolean;
|
|
157
|
+
ignorePreviousSessionError: boolean;
|
|
158
|
+
loginStartupError: ErrorSource | null;
|
|
159
|
+
loginOngoing: boolean;
|
|
160
|
+
preferredAuthenticator: AuthenticatorName | null;
|
|
161
|
+
previousSession: {
|
|
162
|
+
profile?: SolidUserProfile;
|
|
163
|
+
authenticator: AuthenticatorName;
|
|
164
|
+
loginUrl: string;
|
|
165
|
+
error: ErrorSource | null;
|
|
166
|
+
} | null;
|
|
167
|
+
profiles: Record<string, SolidUserProfile>;
|
|
168
|
+
session: AuthSession | null;
|
|
169
|
+
loginStale: boolean;
|
|
170
|
+
staleProfiles: string[];
|
|
171
|
+
}>>;
|
|
172
|
+
|
|
173
|
+
export declare function getAuthenticator<T extends AuthenticatorName>(name: T): Authenticators[T];
|
|
174
|
+
|
|
175
|
+
export declare interface IAGSolidStatusLoggedInSlotProps {
|
|
176
|
+
session: AuthSession;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare class InruptAuthenticator extends Authenticator {
|
|
180
|
+
private _events;
|
|
181
|
+
private _fetch;
|
|
182
|
+
private _login;
|
|
183
|
+
private _logout;
|
|
184
|
+
private _handleIncomingRedirect;
|
|
185
|
+
login(loginUrl: string): Promise<AuthSession>;
|
|
186
|
+
logout(): Promise<void>;
|
|
187
|
+
protected restoreSession(): Promise<void>;
|
|
188
|
+
protected loginFromRedirect(): Promise<void>;
|
|
189
|
+
protected initSession(webId: string): Promise<void>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare class LegacyAuthenticator extends Authenticator {
|
|
193
|
+
private store;
|
|
194
|
+
constructor();
|
|
195
|
+
login(loginUrl: string, user?: SolidUserProfile | null): Promise<AuthSession>;
|
|
196
|
+
logout(): Promise<void>;
|
|
197
|
+
protected restoreSession(): Promise<void>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
declare type ListenerEvent = keyof AuthenticatorListener;
|
|
201
|
+
|
|
202
|
+
declare type ListenerEventPayload<Event extends ListenerEvent, Callback = AuthenticatorListener[Event]> = Callback extends Closure ? GetClosureArgs<Callback> : never;
|
|
203
|
+
|
|
204
|
+
export declare type LoginOptions = NullablePartial<{
|
|
205
|
+
authenticator: AuthenticatorName;
|
|
206
|
+
onError(error: ErrorSource): unknown;
|
|
207
|
+
fallbackUrl: string;
|
|
208
|
+
loading: boolean;
|
|
209
|
+
}>;
|
|
210
|
+
|
|
211
|
+
export declare interface Options {
|
|
212
|
+
autoReconnect?: boolean;
|
|
213
|
+
authenticators?: Record<string, Authenticator>;
|
|
214
|
+
defaultAuthenticator?: AuthenticatorName;
|
|
215
|
+
onUserProfileLoaded?(user: SolidUserProfile, store: SolidStore): Promise<unknown> | unknown;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export declare type ReconnectOptions = Omit<LoginOptions, 'authenticator'> & {
|
|
219
|
+
force?: boolean;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export declare function registerAuthenticator<T extends AuthenticatorName>(name: T, authenticator: Authenticators[T]): void;
|
|
223
|
+
|
|
224
|
+
export declare function registerAuthenticators(customAuthenticators: Record<string, Authenticator>): void;
|
|
225
|
+
|
|
226
|
+
declare const services: {
|
|
227
|
+
$solid: Facade<SolidService>;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export declare function setDefaultAuthenticator(authenticator: Authenticator): void;
|
|
231
|
+
|
|
232
|
+
export declare const Solid: Facade<SolidService>;
|
|
233
|
+
|
|
234
|
+
declare function solid(options?: Options): Plugin_2;
|
|
235
|
+
export default solid;
|
|
236
|
+
|
|
237
|
+
export declare class SolidService extends _default {
|
|
238
|
+
isLoggedIn(): this is {
|
|
239
|
+
session: AuthSession;
|
|
240
|
+
user: SolidUserProfile;
|
|
241
|
+
authenticator: Authenticator;
|
|
242
|
+
};
|
|
243
|
+
wasLoggedIn(): this is {
|
|
244
|
+
user: SolidUserProfile;
|
|
245
|
+
};
|
|
246
|
+
hasLoggedIn(): this is {
|
|
247
|
+
user: SolidUserProfile;
|
|
248
|
+
};
|
|
249
|
+
requireAuthenticator(): Authenticator;
|
|
250
|
+
requireUser(): SolidUserProfile;
|
|
251
|
+
requireUserProfile(url: string): Promise<SolidUserProfile>;
|
|
252
|
+
getUserProfile(url: string, options: Omit<UserProfileOptions, 'required'> & {
|
|
253
|
+
required: true;
|
|
254
|
+
}): Promise<SolidUserProfile>;
|
|
255
|
+
getUserProfile(url: string, options?: UserProfileOptions): Promise<SolidUserProfile | null>;
|
|
256
|
+
refreshUserProfile(): Promise<void>;
|
|
257
|
+
login(loginUrl: string, options?: LoginOptions): Promise<boolean>;
|
|
258
|
+
reconnect(options?: ReconnectOptions): Promise<void>;
|
|
259
|
+
logout(force?: boolean): Promise<void>;
|
|
260
|
+
whenLoggedIn<T>(callback: (session: AuthSession) => T): Promise<T>;
|
|
261
|
+
dismiss(): void;
|
|
262
|
+
findOrCreatePrivateTypeIndex(): Promise<SolidTypeIndex>;
|
|
263
|
+
findPrivateTypeIndex(): Promise<SolidTypeIndex | null>;
|
|
264
|
+
findOrCreatePublicTypeIndex(): Promise<SolidTypeIndex>;
|
|
265
|
+
findPublicTypeIndex(): Promise<SolidTypeIndex | null>;
|
|
266
|
+
createPrivateContainer(options: {
|
|
267
|
+
url: string;
|
|
268
|
+
name?: string;
|
|
269
|
+
registerFor?: SolidModelConstructor;
|
|
270
|
+
reuseExisting?: boolean;
|
|
271
|
+
}): Promise<SolidContainer>;
|
|
272
|
+
protected boot(): Promise<void>;
|
|
273
|
+
protected createPrivateTypeIndex(): Promise<SolidTypeIndex>;
|
|
274
|
+
createPublicTypeIndex(): Promise<SolidTypeIndex>;
|
|
275
|
+
protected attemptLogin(loginUrl: string, options: LoginOptions): Promise<boolean>;
|
|
276
|
+
private restorePreviousSession;
|
|
277
|
+
private startupReconnect;
|
|
278
|
+
private reconnectOnStartup;
|
|
279
|
+
private forcingReconnect;
|
|
280
|
+
private bootAuthenticator;
|
|
281
|
+
private rememberProfile;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export declare type SolidServices = typeof services;
|
|
285
|
+
|
|
286
|
+
export declare type UserProfileOptions = NullablePartial<{
|
|
287
|
+
required: boolean;
|
|
288
|
+
markStale: boolean;
|
|
289
|
+
}>;
|
|
290
|
+
|
|
291
|
+
export { }
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
declare module '@aerogel/core' {
|
|
295
|
+
interface Services extends SolidServices {
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
declare module '@aerogel/core' {
|
|
301
|
+
interface EventsPayload {
|
|
302
|
+
'auth:fetch-ready': Fetch;
|
|
303
|
+
'auth:before-login': void;
|
|
304
|
+
'auth:login': AuthSession;
|
|
305
|
+
'auth:logout': void;
|
|
306
|
+
'auth:after-logout': void;
|
|
307
|
+
'solid:user-profile-loaded': [SolidUserProfile, SolidStore];
|
|
308
|
+
}
|
|
309
|
+
}
|