@aerogel/plugin-solid 0.0.1 → 0.1.0

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.
Files changed (39) hide show
  1. package/dist/InruptAuthenticator.lazy-BvpQLGoj.js +9 -0
  2. package/dist/InruptAuthenticator.lazy-BvpQLGoj.js.map +1 -0
  3. package/dist/LegacyAuthenticator.lazy-ChFFqP14.js +5 -0
  4. package/dist/LegacyAuthenticator.lazy-ChFFqP14.js.map +1 -0
  5. package/dist/aerogel-plugin-solid.d.ts +120 -92
  6. package/dist/aerogel-plugin-solid.js +724 -0
  7. package/dist/aerogel-plugin-solid.js.map +1 -0
  8. package/package.json +35 -28
  9. package/src/auth/Authenticator.ts +10 -8
  10. package/src/auth/authenticators/InruptAuthenticator.lazy.ts +1 -0
  11. package/src/auth/authenticators/InruptAuthenticator.ts +41 -12
  12. package/src/auth/authenticators/LegacyAuthenticator.lazy.ts +1 -0
  13. package/src/auth/authenticators/LegacyAuthenticator.ts +80 -0
  14. package/src/auth/index.ts +3 -1
  15. package/src/components/SolidAvatar.vue +35 -0
  16. package/src/components/SolidImage.vue +33 -0
  17. package/src/components/SolidLogin.vue +141 -0
  18. package/src/components/index.ts +3 -4
  19. package/src/errors/AuthenticationFailedError.ts +22 -0
  20. package/src/errors/index.ts +3 -4
  21. package/src/forms/validation.ts +11 -0
  22. package/src/index.css +1 -0
  23. package/src/index.test.ts +24 -0
  24. package/src/index.ts +65 -0
  25. package/src/services/Solid.state.ts +12 -16
  26. package/src/services/Solid.ts +317 -139
  27. package/src/testing/setup.ts +11 -0
  28. package/src/types/env.d.ts +1 -0
  29. package/src/types/solid-auth-client.d.ts +21 -0
  30. package/.eslintrc.js +0 -7
  31. package/dist/aerogel-plugin-solid.cjs.js +0 -2
  32. package/dist/aerogel-plugin-solid.cjs.js.map +0 -1
  33. package/dist/aerogel-plugin-solid.esm.js +0 -2
  34. package/dist/aerogel-plugin-solid.esm.js.map +0 -1
  35. package/noeldemartin.config.js +0 -2
  36. package/src/components/AGSolidStatus.ts +0 -5
  37. package/src/components/AGSolidStatus.vue +0 -60
  38. package/src/main.ts +0 -43
  39. package/tsconfig.json +0 -10
@@ -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,5 @@
1
+ import { default as l } from "solid-auth-client";
2
+ export {
3
+ l as SolidAuthClient
4
+ };
5
+ //# sourceMappingURL=LegacyAuthenticator.lazy-ChFFqP14.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegacyAuthenticator.lazy-ChFFqP14.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,44 +1,56 @@
1
- import { AllowedComponentProps } from 'vue';
2
- import type { Closure } from '@noeldemartin/utils';
3
- import { ComponentCustomProps } from 'vue';
1
+ import { Closure } from '@noeldemartin/utils';
4
2
  import { ComponentOptionsMixin } from 'vue';
5
- import { Constructor } from '@noeldemartin/utils';
3
+ import { ComponentProvideOptions } from 'vue';
6
4
  import { DefineComponent } from 'vue';
7
- import type { Engine } from 'soukai';
8
- import type { ErrorSource } from '@aerogel/core';
9
- import { ExtractPropTypes } from 'vue';
5
+ import { Engine } from 'soukai';
6
+ import { ErrorSource } from '@aerogel/core';
10
7
  import { Facade } from '@noeldemartin/utils';
11
- import type { Fetch } from 'soukai-solid';
12
- import type { Fetch as Fetch_2 } from '@noeldemartin/solid-utils';
13
- import type { GetClosureArgs } 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 { HTMLAttributes } from 'vue';
14
13
  import { JSError } from '@noeldemartin/utils';
15
- import type { JSErrorOptions } from '@noeldemartin/utils';
16
- import type { Plugin as Plugin_2 } from '@aerogel/core';
14
+ import { JSErrorOptions } from '@noeldemartin/utils';
15
+ import { NullablePartial } from '@noeldemartin/utils';
16
+ import { Plugin as Plugin_2 } from '@aerogel/core';
17
17
  import { PromisedValue } from '@noeldemartin/utils';
18
- import { RendererElement } from 'vue';
19
- import { RendererNode } from 'vue';
20
- import { Service } from '@aerogel/core';
18
+ import { PublicProps } from 'vue';
19
+ import { ServiceWithState } from '@aerogel/core';
21
20
  import { SolidContainer } from 'soukai-solid';
22
- import type { SolidModelConstructor } from 'soukai-solid';
21
+ import { SolidEngine } from 'soukai-solid';
22
+ import { SolidModelConstructor } from 'soukai-solid';
23
+ import { SolidStore } from '@noeldemartin/solid-utils';
23
24
  import { SolidTypeIndex } from 'soukai-solid';
24
- import type { SolidUserProfile } from '@noeldemartin/solid-utils';
25
- import { VNode } from 'vue';
26
- import { VNodeProps } from 'vue';
25
+ import { SolidUserProfile } from '@noeldemartin/solid-utils';
27
26
 
28
- export declare const AGSolidStatus: DefineComponent< {}, (_ctx: any, _cache: any) => VNode<RendererNode, RendererElement, {
29
- [key: string]: any;
30
- }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes< {}>>, {}, {}>;
27
+ declare type __VLS_Props = {
28
+ src: string;
29
+ };
30
+
31
+ declare type __VLS_Props_2 = {
32
+ class?: HTMLAttributes['class'];
33
+ buttonClass?: HTMLAttributes['class'];
34
+ layout?: 'vertical' | 'horizontal';
35
+ noLoading?: boolean;
36
+ allowLegacyAuthenticator?: boolean;
37
+ };
31
38
 
32
39
  export declare class AuthenticationCancelledError extends JSError {
33
40
  }
34
41
 
42
+ export declare class AuthenticationFailedError extends JSError {
43
+ readonly description?: string | null;
44
+ constructor(message: string, description?: string | null, options?: JSErrorOptions);
45
+ }
46
+
35
47
  export declare abstract class Authenticator {
36
48
  name: AuthenticatorName;
37
- private authenticatedFetch?;
38
- private booted?;
39
- private listeners;
40
- private _engine?;
41
- abstract login(loginUrl: string, user?: SolidUserProfile): Promise<AuthSession>;
49
+ protected authenticatedFetch?: Fetch;
50
+ protected booted?: PromisedValue<void>;
51
+ protected listeners: FluentArray<AuthenticatorListener>;
52
+ protected _engine?: SolidEngine;
53
+ abstract login(loginUrl: string, user?: SolidUserProfile | null): Promise<AuthSession>;
42
54
  abstract logout(): Promise<void>;
43
55
  get engine(): Engine;
44
56
  getAuthenticatedFetch(): Fetch | null;
@@ -69,6 +81,7 @@ export declare interface Authenticators extends BaseAuthenticators {
69
81
 
70
82
  export declare const authenticators: {
71
83
  inrupt: InruptAuthenticator;
84
+ legacy: LegacyAuthenticator;
72
85
  };
73
86
 
74
87
  export declare interface AuthSession {
@@ -83,43 +96,17 @@ export declare class ContainerAlreadyInUse extends JSError {
83
96
  constructor(container: SolidContainer, options?: JSErrorOptions);
84
97
  }
85
98
 
86
- declare const _default: Constructor< {
87
- autoReconnect: boolean;
88
- dismissed: boolean;
89
- ignorePreviousSessionError: boolean;
90
- loginError: unknown;
91
- loginOngoing: boolean;
92
- preferredAuthenticator: keyof Authenticators | null;
93
- previousSession: {
94
- authenticator: AuthenticatorName;
95
- loginUrl: string;
96
- avatarUrl?: string | undefined;
97
- error: ErrorSource | null;
98
- } | null;
99
- profiles: Record<string, SolidUserProfile>;
100
- session: AuthSession | null;
101
- loginStale: boolean;
102
- staleProfiles: string[];
103
- }> & Constructor< {
104
- loggedIn: boolean;
105
- user: SolidUserProfile | null;
106
- userAvatarUrl: string | null;
107
- wasLoggedIn: boolean;
108
- authenticator: Authenticator | null;
109
- hasLoggedIn: boolean;
110
- fetch: Fetch_2;
111
- error: {} | null;
112
- }> & Constructor<Service< {
99
+ declare const _default: ServiceWithState< {
113
100
  autoReconnect: boolean;
114
101
  dismissed: boolean;
115
102
  ignorePreviousSessionError: boolean;
116
- loginError: unknown;
103
+ loginStartupError: ErrorSource | null;
117
104
  loginOngoing: boolean;
118
- preferredAuthenticator: keyof Authenticators | null;
105
+ preferredAuthenticator: AuthenticatorName | null;
119
106
  previousSession: {
107
+ profile?: SolidUserProfile;
120
108
  authenticator: AuthenticatorName;
121
109
  loginUrl: string;
122
- avatarUrl?: string | undefined;
123
110
  error: ErrorSource | null;
124
111
  } | null;
125
112
  profiles: Record<string, SolidUserProfile>;
@@ -127,40 +114,33 @@ session: AuthSession | null;
127
114
  loginStale: boolean;
128
115
  staleProfiles: string[];
129
116
  }, {
130
- loggedIn: boolean;
131
117
  user: SolidUserProfile | null;
132
- userAvatarUrl: string | null;
133
- wasLoggedIn: boolean;
134
118
  authenticator: Authenticator | null;
135
- hasLoggedIn: boolean;
136
119
  fetch: Fetch_2;
137
- error: {} | null;
120
+ error: unknown;
138
121
  }, Partial<{
139
122
  autoReconnect: boolean;
140
123
  dismissed: boolean;
141
124
  ignorePreviousSessionError: boolean;
142
- loginError: unknown;
125
+ loginStartupError: ErrorSource | null;
143
126
  loginOngoing: boolean;
144
- preferredAuthenticator: keyof Authenticators | null;
127
+ preferredAuthenticator: AuthenticatorName | null;
145
128
  previousSession: {
129
+ profile?: SolidUserProfile;
146
130
  authenticator: AuthenticatorName;
147
131
  loginUrl: string;
148
- avatarUrl?: string | undefined;
149
132
  error: ErrorSource | null;
150
133
  } | null;
151
134
  profiles: Record<string, SolidUserProfile>;
152
135
  session: AuthSession | null;
153
136
  loginStale: boolean;
154
137
  staleProfiles: string[];
155
- }>>>;
138
+ }>>;
156
139
 
157
140
  export declare function getAuthenticator<T extends AuthenticatorName>(name: T): Authenticators[T];
158
141
 
159
- export declare interface IAGSolidStatusLoggedInSlotProps {
160
- session: AuthSession;
161
- }
162
-
163
142
  declare class InruptAuthenticator extends Authenticator {
143
+ private _events;
164
144
  private _fetch;
165
145
  private _login;
166
146
  private _logout;
@@ -172,83 +152,131 @@ declare class InruptAuthenticator extends Authenticator {
172
152
  protected initSession(webId: string): Promise<void>;
173
153
  }
174
154
 
155
+ declare class LegacyAuthenticator extends Authenticator {
156
+ private store;
157
+ constructor();
158
+ login(loginUrl: string, user?: SolidUserProfile | null): Promise<AuthSession>;
159
+ logout(): Promise<void>;
160
+ protected restoreSession(): Promise<void>;
161
+ }
162
+
175
163
  declare type ListenerEvent = keyof AuthenticatorListener;
176
164
 
177
165
  declare type ListenerEventPayload<Event extends ListenerEvent, Callback = AuthenticatorListener[Event]> = Callback extends Closure ? GetClosureArgs<Callback> : never;
178
166
 
167
+ export declare type LoginOptions = NullablePartial<{
168
+ authenticator: AuthenticatorName;
169
+ onError(error: ErrorSource): unknown;
170
+ fallbackUrl: string;
171
+ loading: boolean;
172
+ }>;
173
+
179
174
  export declare interface Options {
175
+ autoReconnect?: boolean;
180
176
  authenticators?: Record<string, Authenticator>;
181
177
  defaultAuthenticator?: AuthenticatorName;
178
+ onUserProfileLoaded?(user: SolidUserProfile, store: SolidStore): Promise<unknown> | unknown;
182
179
  }
183
180
 
181
+ export declare type ReconnectOptions = Omit<LoginOptions, 'authenticator'> & {
182
+ force?: boolean;
183
+ };
184
+
184
185
  export declare function registerAuthenticator<T extends AuthenticatorName>(name: T, authenticator: Authenticators[T]): void;
185
186
 
186
187
  export declare function registerAuthenticators(customAuthenticators: Record<string, Authenticator>): void;
187
188
 
188
189
  declare const services: {
189
- $solid: Facade<SolidService, Constructor<SolidService>>;
190
+ $solid: Facade<SolidService>;
190
191
  };
191
192
 
192
193
  export declare function setDefaultAuthenticator(authenticator: Authenticator): void;
193
194
 
194
- export declare const Solid: Facade<SolidService, Constructor<SolidService>>;
195
+ export declare const Solid: Facade<SolidService>;
195
196
 
196
197
  declare function solid(options?: Options): Plugin_2;
197
198
  export default solid;
198
199
 
199
- declare class SolidService extends _default {
200
- protected publicTypeIndexes: Record<string, PromisedValue<SolidTypeIndex>>;
201
- protected privateTypeIndexes: Record<string, PromisedValue<SolidTypeIndex>>;
200
+ export declare const SolidAvatar: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
201
+
202
+ export declare const SolidImage: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLImageElement>;
203
+
204
+ export declare const SolidLogin: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLFormElement>;
205
+
206
+ export declare class SolidService extends _default {
202
207
  isLoggedIn(): this is {
203
208
  session: AuthSession;
204
209
  user: SolidUserProfile;
205
210
  authenticator: Authenticator;
206
211
  };
212
+ wasLoggedIn(): this is {
213
+ user: SolidUserProfile;
214
+ };
215
+ hasLoggedIn(): this is {
216
+ user: SolidUserProfile;
217
+ };
207
218
  requireAuthenticator(): Authenticator;
208
219
  requireUser(): SolidUserProfile;
209
220
  requireUserProfile(url: string): Promise<SolidUserProfile>;
210
- getUserProfile(url: string, required: true): Promise<SolidUserProfile>;
211
- getUserProfile(url: string, required?: false): Promise<SolidUserProfile | null>;
221
+ getUserProfile(url: string, options: Omit<UserProfileOptions, 'required'> & {
222
+ required: true;
223
+ }): Promise<SolidUserProfile>;
224
+ getUserProfile(url: string, options?: UserProfileOptions): Promise<SolidUserProfile | null>;
212
225
  refreshUserProfile(): Promise<void>;
213
- login(loginUrl: string, authenticatorName?: AuthenticatorName): Promise<boolean>;
214
- reconnect(force?: boolean): Promise<void>;
226
+ login(loginUrl: string, options?: LoginOptions): Promise<boolean>;
227
+ reconnect(options?: ReconnectOptions): Promise<void>;
215
228
  logout(force?: boolean): Promise<void>;
229
+ whenLoggedIn<T>(callback: (session: AuthSession) => T): Promise<T>;
216
230
  dismiss(): void;
217
231
  findOrCreatePrivateTypeIndex(): Promise<SolidTypeIndex>;
232
+ findPrivateTypeIndex(options?: {
233
+ fresh?: boolean;
234
+ }): Promise<SolidTypeIndex | null>;
218
235
  findOrCreatePublicTypeIndex(): Promise<SolidTypeIndex>;
236
+ findPublicTypeIndex(options?: {
237
+ fresh?: boolean;
238
+ }): Promise<SolidTypeIndex | null>;
219
239
  createPrivateContainer(options: {
220
240
  url: string;
221
- name: string;
222
- register?: {
223
- typeIndex: SolidTypeIndex;
224
- modelClass: SolidModelConstructor;
225
- };
241
+ name?: string;
242
+ registerFor?: SolidModelConstructor;
226
243
  reuseExisting?: boolean;
227
244
  }): Promise<SolidContainer>;
228
245
  protected boot(): Promise<void>;
229
- protected findPrivateTypeIndex(): Promise<SolidTypeIndex | null>;
230
246
  protected createPrivateTypeIndex(): Promise<SolidTypeIndex>;
231
- protected findPublicTypeIndex(): Promise<SolidTypeIndex | null>;
232
247
  createPublicTypeIndex(): Promise<SolidTypeIndex>;
248
+ protected attemptLogin(loginUrl: string, options: LoginOptions): Promise<boolean>;
233
249
  private restorePreviousSession;
234
250
  private startupReconnect;
235
251
  private reconnectOnStartup;
252
+ private forcingReconnect;
236
253
  private bootAuthenticator;
237
254
  private rememberProfile;
238
255
  }
239
256
 
240
257
  export declare type SolidServices = typeof services;
241
258
 
259
+ export declare type UserProfileOptions = NullablePartial<{
260
+ required: boolean;
261
+ markStale: boolean;
262
+ }>;
263
+
242
264
  export { }
243
265
 
244
- declare module '@vue/runtime-core' {
245
- interface ComponentCustomProperties extends SolidServices {}
266
+
267
+ declare module '@aerogel/core' {
268
+ interface Services extends SolidServices {
269
+ }
246
270
  }
247
271
 
272
+
248
273
  declare module '@aerogel/core' {
249
- export interface EventsPayload {
250
- 'authenticated-fetch-ready': Fetch;
251
- login: AuthSession;
252
- logout: void;
274
+ interface EventsPayload {
275
+ 'auth:fetch-ready': Fetch;
276
+ 'auth:before-login': void;
277
+ 'auth:login': AuthSession;
278
+ 'auth:logout': void;
279
+ 'auth:after-logout': void;
280
+ 'solid:user-profile-loaded': [SolidUserProfile, SolidStore];
253
281
  }
254
282
  }