@molecule/app-auth 1.8.1 → 2.0.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.
- package/README.md +253 -48
- package/dist/client.d.ts +22 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +26 -3
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +58 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +58 -6
- package/dist/index.js.map +1 -1
- package/dist/provider.d.ts +6 -3
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +4 -1
- package/dist/provider.js.map +1 -1
- package/dist/types.d.ts +238 -19
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities.d.ts +26 -4
- package/dist/utilities.d.ts.map +1 -1
- package/dist/utilities.js +24 -2
- package/dist/utilities.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -137,15 +137,18 @@
|
|
|
137
137
|
* const config: AuthClientConfig<MyUser> = {
|
|
138
138
|
* mapAuthResponse: (data) => {
|
|
139
139
|
* const { user: wire } = data as { user: { token: string } & Omit<MyUser, 'id'> }
|
|
140
|
+
* // The bearer stays OUT of the profile: the client caches `user` in Web
|
|
141
|
+
* // Storage, where a token copy is readable by any script on the origin.
|
|
142
|
+
* const { token, ...profile } = wire
|
|
140
143
|
* return {
|
|
141
|
-
* accessToken:
|
|
144
|
+
* accessToken: token,
|
|
142
145
|
* user: {
|
|
143
146
|
* // Every wire field the pages read (`username`, `image`, …) survives…
|
|
144
|
-
* ...
|
|
147
|
+
* ...profile,
|
|
145
148
|
* // …plus the base fields the client derives its identity from.
|
|
146
|
-
* id:
|
|
147
|
-
* name:
|
|
148
|
-
* avatar:
|
|
149
|
+
* id: profile.username,
|
|
150
|
+
* name: profile.name ?? profile.username,
|
|
151
|
+
* avatar: profile.image,
|
|
149
152
|
* },
|
|
150
153
|
* }
|
|
151
154
|
* },
|
|
@@ -155,6 +158,44 @@
|
|
|
155
158
|
* // React: `useAuth<MyUser>()` reads the same profile.
|
|
156
159
|
* ```
|
|
157
160
|
*
|
|
161
|
+
* A profile does not have to extend `UserProfile` and does not need an `id`: the client
|
|
162
|
+
* stores and returns the object it is given and reads no field of it. Name the API's own
|
|
163
|
+
* shape, pass it to the factory and the config, and have the mapper return it complete —
|
|
164
|
+
* every configuration adapter is typed by the same `T` (`mapAuthResponse`, the
|
|
165
|
+
* `profileEndpoint`/`profileUpdateMethod`/`profileRequestBody` write transport,
|
|
166
|
+
* `shouldRestoreUser`, and `setSession`):
|
|
167
|
+
*
|
|
168
|
+
* ```typescript
|
|
169
|
+
* import type { AuthClientConfig } from '@molecule/app-auth'
|
|
170
|
+
* import { createJWTAuthClient } from '@molecule/app-auth'
|
|
171
|
+
*
|
|
172
|
+
* interface SessionUser {
|
|
173
|
+
* username: string
|
|
174
|
+
* email: string
|
|
175
|
+
* bio: string
|
|
176
|
+
* image: string
|
|
177
|
+
* }
|
|
178
|
+
*
|
|
179
|
+
* const config: AuthClientConfig<SessionUser> = {
|
|
180
|
+
* mapAuthResponse: (data) => {
|
|
181
|
+
* const { user: wire } = data as { user: { token: string } & SessionUser }
|
|
182
|
+
* // The bearer stays OUT of the profile: the client caches `user` in Web
|
|
183
|
+
* // Storage, where a token copy is readable by any script on the origin.
|
|
184
|
+
* const { token, ...profile } = wire
|
|
185
|
+
* return { accessToken: token, user: profile }
|
|
186
|
+
* },
|
|
187
|
+
* profileEndpoint: (user) => '/people/' + encodeURIComponent(user.username),
|
|
188
|
+
* }
|
|
189
|
+
*
|
|
190
|
+
* const client = createJWTAuthClient<SessionUser>(config)
|
|
191
|
+
* // `client.getUser()` has `bio`/`image`; there is no `id` to fabricate.
|
|
192
|
+
* ```
|
|
193
|
+
*
|
|
194
|
+
* The profile is named at the factory, never inferred from the mapper: an untyped
|
|
195
|
+
* `createJWTAuthClient({ mapAuthResponse })` stays `UserProfile`, whose required
|
|
196
|
+
* `id: string` is the default configuration's contract. An array, a function or a
|
|
197
|
+
* `Date` is not a profile the client can persist — see `AuthProfileShape`.
|
|
198
|
+
*
|
|
158
199
|
* A username-derived `id` can change during a profile save. It is not an immutable
|
|
159
200
|
* session identifier: `getSessionRevision()` tracks session ownership independently
|
|
160
201
|
* of profile fields, remains unchanged for profile updates and same-session
|
|
@@ -227,7 +268,8 @@
|
|
|
227
268
|
* @remarks
|
|
228
269
|
* - **An API with its own auth envelope keeps this client.** `requestBody` wraps the
|
|
229
270
|
* login/register payload (`(kind, p) => ({ user: p })`), `mapAuthResponse` reads the
|
|
230
|
-
* token and user out of the answer
|
|
271
|
+
* token and user out of the answer — keeping the wire bearer OUT of the profile,
|
|
272
|
+
* because the client caches `user` in Web Storage (see the mapper example below) —
|
|
231
273
|
* and `authScheme: 'Token'` sends `Authorization: Token <jwt>`. `mapAuthResponse` is the
|
|
232
274
|
* ONE user-shape adapter: the client applies it to every answer that carries a user (login,
|
|
233
275
|
* register, `validateSession()`, the cookie restore, a token refresh, `updateProfile()`), so
|
|
@@ -248,6 +290,16 @@
|
|
|
248
290
|
* - Client-side auth state is UX only — the server enforces authorization on
|
|
249
291
|
* every request; hiding a screen is not protection.
|
|
250
292
|
*
|
|
293
|
+
* The mapper for such an envelope, with the wire token kept out of the cached
|
|
294
|
+
* profile (`d` is the parsed answer):
|
|
295
|
+
*
|
|
296
|
+
* ```typescript
|
|
297
|
+
* (d) => {
|
|
298
|
+
* const { token, ...user } = d.user
|
|
299
|
+
* return { accessToken: token, user }
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
251
303
|
* @example
|
|
252
304
|
* ```typescript
|
|
253
305
|
* import { createJWTAuthClient, setClient } from '@molecule/app-auth'
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgYG;AAEH,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -137,15 +137,18 @@
|
|
|
137
137
|
* const config: AuthClientConfig<MyUser> = {
|
|
138
138
|
* mapAuthResponse: (data) => {
|
|
139
139
|
* const { user: wire } = data as { user: { token: string } & Omit<MyUser, 'id'> }
|
|
140
|
+
* // The bearer stays OUT of the profile: the client caches `user` in Web
|
|
141
|
+
* // Storage, where a token copy is readable by any script on the origin.
|
|
142
|
+
* const { token, ...profile } = wire
|
|
140
143
|
* return {
|
|
141
|
-
* accessToken:
|
|
144
|
+
* accessToken: token,
|
|
142
145
|
* user: {
|
|
143
146
|
* // Every wire field the pages read (`username`, `image`, …) survives…
|
|
144
|
-
* ...
|
|
147
|
+
* ...profile,
|
|
145
148
|
* // …plus the base fields the client derives its identity from.
|
|
146
|
-
* id:
|
|
147
|
-
* name:
|
|
148
|
-
* avatar:
|
|
149
|
+
* id: profile.username,
|
|
150
|
+
* name: profile.name ?? profile.username,
|
|
151
|
+
* avatar: profile.image,
|
|
149
152
|
* },
|
|
150
153
|
* }
|
|
151
154
|
* },
|
|
@@ -155,6 +158,44 @@
|
|
|
155
158
|
* // React: `useAuth<MyUser>()` reads the same profile.
|
|
156
159
|
* ```
|
|
157
160
|
*
|
|
161
|
+
* A profile does not have to extend `UserProfile` and does not need an `id`: the client
|
|
162
|
+
* stores and returns the object it is given and reads no field of it. Name the API's own
|
|
163
|
+
* shape, pass it to the factory and the config, and have the mapper return it complete —
|
|
164
|
+
* every configuration adapter is typed by the same `T` (`mapAuthResponse`, the
|
|
165
|
+
* `profileEndpoint`/`profileUpdateMethod`/`profileRequestBody` write transport,
|
|
166
|
+
* `shouldRestoreUser`, and `setSession`):
|
|
167
|
+
*
|
|
168
|
+
* ```typescript
|
|
169
|
+
* import type { AuthClientConfig } from '@molecule/app-auth'
|
|
170
|
+
* import { createJWTAuthClient } from '@molecule/app-auth'
|
|
171
|
+
*
|
|
172
|
+
* interface SessionUser {
|
|
173
|
+
* username: string
|
|
174
|
+
* email: string
|
|
175
|
+
* bio: string
|
|
176
|
+
* image: string
|
|
177
|
+
* }
|
|
178
|
+
*
|
|
179
|
+
* const config: AuthClientConfig<SessionUser> = {
|
|
180
|
+
* mapAuthResponse: (data) => {
|
|
181
|
+
* const { user: wire } = data as { user: { token: string } & SessionUser }
|
|
182
|
+
* // The bearer stays OUT of the profile: the client caches `user` in Web
|
|
183
|
+
* // Storage, where a token copy is readable by any script on the origin.
|
|
184
|
+
* const { token, ...profile } = wire
|
|
185
|
+
* return { accessToken: token, user: profile }
|
|
186
|
+
* },
|
|
187
|
+
* profileEndpoint: (user) => '/people/' + encodeURIComponent(user.username),
|
|
188
|
+
* }
|
|
189
|
+
*
|
|
190
|
+
* const client = createJWTAuthClient<SessionUser>(config)
|
|
191
|
+
* // `client.getUser()` has `bio`/`image`; there is no `id` to fabricate.
|
|
192
|
+
* ```
|
|
193
|
+
*
|
|
194
|
+
* The profile is named at the factory, never inferred from the mapper: an untyped
|
|
195
|
+
* `createJWTAuthClient({ mapAuthResponse })` stays `UserProfile`, whose required
|
|
196
|
+
* `id: string` is the default configuration's contract. An array, a function or a
|
|
197
|
+
* `Date` is not a profile the client can persist — see `AuthProfileShape`.
|
|
198
|
+
*
|
|
158
199
|
* A username-derived `id` can change during a profile save. It is not an immutable
|
|
159
200
|
* session identifier: `getSessionRevision()` tracks session ownership independently
|
|
160
201
|
* of profile fields, remains unchanged for profile updates and same-session
|
|
@@ -227,7 +268,8 @@
|
|
|
227
268
|
* @remarks
|
|
228
269
|
* - **An API with its own auth envelope keeps this client.** `requestBody` wraps the
|
|
229
270
|
* login/register payload (`(kind, p) => ({ user: p })`), `mapAuthResponse` reads the
|
|
230
|
-
* token and user out of the answer
|
|
271
|
+
* token and user out of the answer — keeping the wire bearer OUT of the profile,
|
|
272
|
+
* because the client caches `user` in Web Storage (see the mapper example below) —
|
|
231
273
|
* and `authScheme: 'Token'` sends `Authorization: Token <jwt>`. `mapAuthResponse` is the
|
|
232
274
|
* ONE user-shape adapter: the client applies it to every answer that carries a user (login,
|
|
233
275
|
* register, `validateSession()`, the cookie restore, a token refresh, `updateProfile()`), so
|
|
@@ -248,6 +290,16 @@
|
|
|
248
290
|
* - Client-side auth state is UX only — the server enforces authorization on
|
|
249
291
|
* every request; hiding a screen is not protection.
|
|
250
292
|
*
|
|
293
|
+
* The mapper for such an envelope, with the wire token kept out of the cached
|
|
294
|
+
* profile (`d` is the parsed answer):
|
|
295
|
+
*
|
|
296
|
+
* ```typescript
|
|
297
|
+
* (d) => {
|
|
298
|
+
* const { token, ...user } = d.user
|
|
299
|
+
* return { accessToken: token, user }
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
251
303
|
* @example
|
|
252
304
|
* ```typescript
|
|
253
305
|
* import { createJWTAuthClient, setClient } from '@molecule/app-auth'
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgYG;AAEH,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
import type { AuthClient, RegisterExtraShape, UserProfile } from './types.js';
|
|
10
|
+
import type { AuthClient, AuthProfileConstraint, RegisterExtraShape, UserProfile } from './types.js';
|
|
11
11
|
/**
|
|
12
12
|
* Registers an auth client as the active singleton. Called by bond
|
|
13
13
|
* packages during application startup.
|
|
@@ -21,13 +21,16 @@ export declare const setClient: <T = UserProfile, TRegister extends RegisterExtr
|
|
|
21
21
|
/**
|
|
22
22
|
* Retrieves the bonded auth client, throwing if none is configured.
|
|
23
23
|
*
|
|
24
|
-
* @template T - The user profile the bonded client returns
|
|
24
|
+
* @template T - The user profile the bonded client returns: a JSON object type
|
|
25
|
+
* of named fields (see {@link AuthProfileConstraint}), including an app
|
|
26
|
+
* profile with no `id`. Name it at the call (`getClient<SessionUser>()`); it
|
|
27
|
+
* is never inferred from a config.
|
|
25
28
|
* @template TRegister - The app's own registration fields, at the top level
|
|
26
29
|
* of `register()` (see `RegisterData`).
|
|
27
30
|
* @returns The bonded auth client.
|
|
28
31
|
* @throws {Error} If no auth client has been bonded.
|
|
29
32
|
*/
|
|
30
|
-
export declare const getClient: <T extends
|
|
33
|
+
export declare const getClient: <T extends AuthProfileConstraint<T> = UserProfile, TRegister extends RegisterExtraShape<TRegister> = Record<never, never>>() => AuthClient<T, TRegister>;
|
|
31
34
|
/**
|
|
32
35
|
* Checks whether an auth client is currently bonded.
|
|
33
36
|
*
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAIpG;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GACpB,CAAC,GAAG,WAAW,EACf,SAAS,SAAS,kBAAkB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAEtE,QAAQ,UAAU,CAAC,CAAC,EAAE,SAAS,CAAC,KAC/B,IAEF,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GACpB,CAAC,SAAS,qBAAqB,CAAC,CAAC,CAAC,GAAG,WAAW,EAChD,SAAS,SAAS,kBAAkB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,OACnE,UAAU,CAAC,CAAC,EAAE,SAAS,CAE3B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,QAAO,OAE5B,CAAA"}
|
package/dist/provider.js
CHANGED
|
@@ -24,7 +24,10 @@ export const setClient = (client) => {
|
|
|
24
24
|
/**
|
|
25
25
|
* Retrieves the bonded auth client, throwing if none is configured.
|
|
26
26
|
*
|
|
27
|
-
* @template T - The user profile the bonded client returns
|
|
27
|
+
* @template T - The user profile the bonded client returns: a JSON object type
|
|
28
|
+
* of named fields (see {@link AuthProfileConstraint}), including an app
|
|
29
|
+
* profile with no `id`. Name it at the call (`getClient<SessionUser>()`); it
|
|
30
|
+
* is never inferred from a config.
|
|
28
31
|
* @template TRegister - The app's own registration fields, at the top level
|
|
29
32
|
* of `register()` (see `RegisterData`).
|
|
30
33
|
* @returns The bonded auth client.
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAI3E,MAAM,SAAS,GAAG,aAAa,CAAA;AAE/B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAIvB,MAAgC,EAC1B,EAAE;IACR,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AACzB,CAAC,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAI3E,MAAM,SAAS,GAAG,aAAa,CAAA;AAE/B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAIvB,MAAgC,EAC1B,EAAE;IACR,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AACzB,CAAC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAGK,EAAE;IAC9B,OAAO,WAAW,CAA2B,SAAS,CAAC,CAAA;AACzD,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAY,EAAE;IACrC,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAA;AAC5B,CAAC,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -33,6 +33,117 @@ export interface UserProfile {
|
|
|
33
33
|
*/
|
|
34
34
|
metadata?: Record<string, unknown>;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* The sentence every invalid profile type is rejected with.
|
|
38
|
+
*/
|
|
39
|
+
type AuthProfileRejection = 'An auth profile must be a JSON object type of named fields, not an array, a function or a Date';
|
|
40
|
+
/**
|
|
41
|
+
* The profile shapes the auth client accepts: a JSON object type of named
|
|
42
|
+
* fields, and nothing else.
|
|
43
|
+
*
|
|
44
|
+
* The client does not read a field of the profile, but it does persist it:
|
|
45
|
+
* `tokenStorage.setUser` writes it with `JSON.stringify` and `getUser` restores
|
|
46
|
+
* it with `JSON.parse`, and `updateProfile(data: Partial<T>)` patches it
|
|
47
|
+
* field-wise. An array has no named fields to read or patch, `JSON.stringify`
|
|
48
|
+
* drops a function entirely, and a `Date` comes back from `JSON.parse` as a
|
|
49
|
+
* string while still typed as a `Date` — so those three types are rejected on
|
|
50
|
+
* every entrypoint that takes a profile type (`createJWTAuthClient`,
|
|
51
|
+
* the default-auth factories, `AuthClientConfig`).
|
|
52
|
+
*
|
|
53
|
+
* The check is on the TOP-LEVEL shape only: a class instance, or a `Date` in a
|
|
54
|
+
* nested field, is the app's own persistence contract, not this validator's.
|
|
55
|
+
* A named `interface`, a type literal, an intersection and the empty object
|
|
56
|
+
* type all satisfy it — `{}` compiles because it is a JSON object that
|
|
57
|
+
* round-trips unchanged, not an invalid form.
|
|
58
|
+
*
|
|
59
|
+
* A union is checked member by member: `ExistingUser | ExistingUser[]` contains
|
|
60
|
+
* an array, so it is not an object-only profile either, and the shared
|
|
61
|
+
* rejection test (`AuthProfileIsRejected`, used by
|
|
62
|
+
* {@link AuthProfileConstraint} and {@link AuthProfileGuard}) rejects it as a
|
|
63
|
+
* whole.
|
|
64
|
+
*
|
|
65
|
+
* @template T - The candidate profile type.
|
|
66
|
+
*/
|
|
67
|
+
export type AuthProfileShape<T> = T extends readonly unknown[] | ((...args: never[]) => unknown) | Date ? AuthProfileRejection : object;
|
|
68
|
+
/**
|
|
69
|
+
* Whether `T` is, or is a union containing, a shape the client cannot persist —
|
|
70
|
+
* an array, a function or a `Date` ({@link AuthProfileShape}).
|
|
71
|
+
*
|
|
72
|
+
* This is the ONE decision {@link AuthProfileConstraint} and
|
|
73
|
+
* {@link AuthProfileGuard} share, so the entrypoints and `AuthClientConfig`
|
|
74
|
+
* cannot drift apart.
|
|
75
|
+
*
|
|
76
|
+
* Three TypeScript behaviors shape it:
|
|
77
|
+
*
|
|
78
|
+
* - **No distribution.** `AuthProfileShape<T>` already distributes, so a union
|
|
79
|
+
* `Good | Bad` yields `object | AuthProfileRejection`. Wrapping BOTH sides of
|
|
80
|
+
* the test in tuples compares those unions as a whole, so one invalid member
|
|
81
|
+
* rejects the whole union. The plain `AuthProfileShape<T> extends
|
|
82
|
+
* AuthProfileRejection` form instead asks whether the ENTIRE union is the
|
|
83
|
+
* rejection, which a valid sibling makes false — that is the union hole this
|
|
84
|
+
* closes.
|
|
85
|
+
* - **`any` is checked first.** `any` is the caller's explicit opt-out of
|
|
86
|
+
* profile typing, not an invalid member, but `AuthProfileShape<any>` resolves
|
|
87
|
+
* to `AuthProfileRejection | object`, which the tuple test reads as "contains
|
|
88
|
+
* a rejection". `0 extends 1 & T` detects `any` (and only `any` — `never`,
|
|
89
|
+
* `unknown` and `object` are all false) and takes the accepted branch.
|
|
90
|
+
* - **Deferred at the outer edge.** `[T] extends [unknown]` keeps the whole
|
|
91
|
+
* check deferred while `T` is an unresolved type parameter (it is always true
|
|
92
|
+
* for a concrete type, and does not distribute over a union). Without it,
|
|
93
|
+
* TypeScript resolves the inner `0 extends 1 & T` while checking a forwarder's
|
|
94
|
+
* constraint `T extends AuthProfileConstraint<T>` and reports TS2313 ("Type
|
|
95
|
+
* parameter 'T' has a circular constraint"); with it, the constraint checks at
|
|
96
|
+
* the call site.
|
|
97
|
+
*
|
|
98
|
+
* `never`, `unknown` and the primitives are not this helper's job: each
|
|
99
|
+
* entrypoint's `extends object` requirement rejects them, unchanged.
|
|
100
|
+
*
|
|
101
|
+
* @template T - The candidate profile type.
|
|
102
|
+
*/
|
|
103
|
+
type AuthProfileIsRejected<T> = [T] extends [unknown] ? 0 extends 1 & T ? false : [AuthProfileRejection] extends [AuthProfileShape<T>] ? true : false : never;
|
|
104
|
+
/**
|
|
105
|
+
* Requires a profile type to satisfy {@link AuthProfileShape}: an invalid
|
|
106
|
+
* profile makes {@link AuthClientConfig} impossible to populate, so the
|
|
107
|
+
* annotation itself is the error. It shares the entrypoints' rejection test,
|
|
108
|
+
* so a union with an invalid member is rejected here too.
|
|
109
|
+
*
|
|
110
|
+
* @template T - The candidate profile type.
|
|
111
|
+
*/
|
|
112
|
+
export type AuthProfileGuard<T> = AuthProfileIsRejected<T> extends true ? {
|
|
113
|
+
readonly [K in AuthProfileRejection]: never;
|
|
114
|
+
} : Record<never, never>;
|
|
115
|
+
/**
|
|
116
|
+
* The constraint every entrypoint puts on a profile type: a JSON object type of
|
|
117
|
+
* named fields ({@link AuthProfileShape}), and `object` for `any`.
|
|
118
|
+
*
|
|
119
|
+
* `any` is the caller's explicit opt-out of profile typing, not an invalid JSON
|
|
120
|
+
* shape: `createJWTAuthClient<any>()`, `getClient<any>()` and
|
|
121
|
+
* `AuthClientConfig<any>` name it deliberately. It is detected explicitly
|
|
122
|
+
* (`0 extends 1 & T`) and accepted. Every other type is measured against
|
|
123
|
+
* {@link AuthProfileShape}, member by member when it is a union: a union that
|
|
124
|
+
* holds an array, a function or a `Date` is rejected as a whole, so
|
|
125
|
+
* `createJWTAuthClient<ExistingUser | ExistingUser[]>()` is the same type error
|
|
126
|
+
* as `createJWTAuthClient<ExistingUser[]>()`.
|
|
127
|
+
*
|
|
128
|
+
* Forwarding a profile through your own generic copies this constraint, so the
|
|
129
|
+
* profile keeps being checked:
|
|
130
|
+
*
|
|
131
|
+
* ```typescript
|
|
132
|
+
* import type { AuthClientConfig, AuthProfileConstraint } from '@molecule/app-auth'
|
|
133
|
+
* import { createJWTAuthClient } from '@molecule/app-auth'
|
|
134
|
+
*
|
|
135
|
+
* export function makeAuth<T extends AuthProfileConstraint<T>>(config: AuthClientConfig<T>) {
|
|
136
|
+
* return createJWTAuthClient<T>(config)
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* `T extends object` is not enough: the factory rejects arrays, functions and
|
|
141
|
+
* `Date` at its own constraint, so a forwarder written that way does not
|
|
142
|
+
* compile. Copy this type instead.
|
|
143
|
+
*
|
|
144
|
+
* @template T - The candidate profile type.
|
|
145
|
+
*/
|
|
146
|
+
export type AuthProfileConstraint<T> = AuthProfileIsRejected<T> extends true ? never : object;
|
|
36
147
|
/**
|
|
37
148
|
* Email/password login credentials with optional "remember me" flag.
|
|
38
149
|
*/
|
|
@@ -223,15 +334,21 @@ export interface AuthState<T = UserProfile> {
|
|
|
223
334
|
}
|
|
224
335
|
/**
|
|
225
336
|
* Auth event types.
|
|
337
|
+
*
|
|
338
|
+
* A sign-in event carries the client's own profile type, so a listener on a
|
|
339
|
+
* client typed with the app's profile reads that profile — including one that
|
|
340
|
+
* does not extend {@link UserProfile}. The default is {@link UserProfile}.
|
|
341
|
+
*
|
|
342
|
+
* @template T - The user profile the API returns.
|
|
226
343
|
*/
|
|
227
|
-
export type AuthEvent = {
|
|
344
|
+
export type AuthEvent<T = UserProfile> = {
|
|
228
345
|
type: 'login';
|
|
229
|
-
user:
|
|
346
|
+
user: T;
|
|
230
347
|
} | {
|
|
231
348
|
type: 'logout';
|
|
232
349
|
} | {
|
|
233
350
|
type: 'register';
|
|
234
|
-
user:
|
|
351
|
+
user: T;
|
|
235
352
|
} | {
|
|
236
353
|
type: 'refresh';
|
|
237
354
|
} | {
|
|
@@ -240,8 +357,30 @@ export type AuthEvent = {
|
|
|
240
357
|
};
|
|
241
358
|
/**
|
|
242
359
|
* Callback invoked when an authentication event occurs (login, logout, etc.).
|
|
360
|
+
*
|
|
361
|
+
* A listener is typed by the client's profile: `AuthEventListener<MyUser>`
|
|
362
|
+
* receives `AuthEvent<MyUser>`, so a sign-in event's `user` is the app's own
|
|
363
|
+
* shape — including a profile that does not extend {@link UserProfile}. The
|
|
364
|
+
* default is {@link UserProfile}.
|
|
365
|
+
*
|
|
366
|
+
* An inline arrow is contextually typed, so its `event` parameter needs no
|
|
367
|
+
* annotation. Because listener parameters are contravariant, a client whose
|
|
368
|
+
* profile extends {@link UserProfile} also accepts a listener written against
|
|
369
|
+
* the default `AuthEventListener` (those events carry every `UserProfile`
|
|
370
|
+
* field). A client whose profile does NOT extend `UserProfile` — an API user
|
|
371
|
+
* with no `id` — accepts only `AuthEventListener<T>`: a default listener would
|
|
372
|
+
* read an `id` the runtime user does not have.
|
|
373
|
+
*
|
|
374
|
+
* **Migration to 2.0.** External providers that implement {@link AuthClient}
|
|
375
|
+
* declare their listener parameter as `AuthEventListener<T>`
|
|
376
|
+
* (`addEventListener(listener: AuthEventListener<T>): () => void`). The
|
|
377
|
+
* previous `addEventListener(listener: AuthEventListener)` declaration, which
|
|
378
|
+
* claimed every client's events carry a `UserProfile`, is no longer assignable
|
|
379
|
+
* once the client's profile is a custom one.
|
|
380
|
+
*
|
|
381
|
+
* @template T - The user profile the API returns.
|
|
243
382
|
*/
|
|
244
|
-
export type AuthEventListener = (event: AuthEvent) => void;
|
|
383
|
+
export type AuthEventListener<T = UserProfile> = (event: AuthEvent<T>) => void;
|
|
245
384
|
/**
|
|
246
385
|
* The error an auth client rejects with when the API answers a non-ok HTTP
|
|
247
386
|
* response. It is the {@link I18nError} the client throws — same `i18nKey`,
|
|
@@ -498,8 +637,22 @@ export interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShap
|
|
|
498
637
|
getToken?(): string | null;
|
|
499
638
|
/**
|
|
500
639
|
* Adds an auth event listener.
|
|
501
|
-
|
|
502
|
-
|
|
640
|
+
*
|
|
641
|
+
* The listener is typed by this client's profile: one signature,
|
|
642
|
+
* `AuthEventListener<T>`, so an inline arrow is contextually typed and `event`
|
|
643
|
+
* is never implicitly `any`. A client whose profile extends
|
|
644
|
+
* {@link UserProfile} also accepts a default {@link AuthEventListener}: when
|
|
645
|
+
* `T` extends `UserProfile`, `AuthEvent<T>` is assignable to
|
|
646
|
+
* `AuthEvent<UserProfile>`, so a listener that takes the wider default event
|
|
647
|
+
* accepts every event this client emits and keeps compiling. (`UserProfile`
|
|
648
|
+
* is the wider type here — it has fewer required fields — and the assignable
|
|
649
|
+
* direction runs from the client's `AuthEvent<T>` to the listener's
|
|
650
|
+
* `AuthEvent<UserProfile>`.) A profile that does not extend `UserProfile`
|
|
651
|
+
* (no `id`) rejects the default listener: an `AuthEvent<UserProfile>` would
|
|
652
|
+
* promise an `id` the runtime user does not have, and the narrower-typed
|
|
653
|
+
* event is not assignable to it.
|
|
654
|
+
*/
|
|
655
|
+
addEventListener(listener: AuthEventListener<T>): () => void;
|
|
503
656
|
/**
|
|
504
657
|
* Destroys the auth client.
|
|
505
658
|
*/
|
|
@@ -520,18 +673,63 @@ export interface StorageAdapter {
|
|
|
520
673
|
*
|
|
521
674
|
* Type it with the app's user — `AuthClientConfig<MyUser>` — the same type
|
|
522
675
|
* `createJWTAuthClient<MyUser>` returns and `useAuth<MyUser>()` reads. That
|
|
523
|
-
* makes {@link mapAuthResponse} return
|
|
524
|
-
* omits a required custom field is a type
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
* adapter.
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
676
|
+
* makes {@link AuthClientConfigOptions.mapAuthResponse} return
|
|
677
|
+
* `AuthResult<MyUser>`, so a mapper that omits a required custom field is a type
|
|
678
|
+
* error instead of a signed-in page reading `undefined`
|
|
679
|
+
* (xr-molecule-flash-m255). Keep every wire field the pages read (spread the
|
|
680
|
+
* wire user and add `id`/`name`/`avatar`); mapping a field to a different name
|
|
681
|
+
* does not preserve the original, and a `as unknown as MyUser` assertion hides
|
|
682
|
+
* the loss. See the module docs for the wire-preserving adapter.
|
|
683
|
+
*
|
|
684
|
+
* `T` is the app's OWN profile shape and need not extend {@link UserProfile}:
|
|
685
|
+
* the client stores and returns the object it is given and reads no field of
|
|
686
|
+
* it, so an API whose user has no `id` — `{ username, email, bio, image }` —
|
|
687
|
+
* is typed by its own `interface` directly, with no fabricated `id`. The
|
|
688
|
+
* default, {@link UserProfile}, still requires `id: string`. A primitive,
|
|
689
|
+
* `null`, an array, a function or a `Date` — or a union containing one — is
|
|
690
|
+
* rejected; see {@link AuthProfileShape} for the persistence contract behind
|
|
691
|
+
* that list.
|
|
692
|
+
*
|
|
693
|
+
* The type argument is NEVER inferred from the config: not from
|
|
694
|
+
* `mapAuthResponse`, `profileEndpoint`, `profileRequestBody` or
|
|
695
|
+
* `shouldRestoreUser`, and not from a config variable the caller annotated as
|
|
696
|
+
* `AuthClientConfig<MyUser>`. An untyped call stays typed `UserProfile`, so the
|
|
697
|
+
* default configuration keeps requiring `id: string`. Name the profile at the
|
|
698
|
+
* call (`createJWTAuthClient<MyUser>(config)`) — which also checks this config
|
|
699
|
+
* against `MyUser`.
|
|
700
|
+
*
|
|
701
|
+
* **Callers upgrading from 1.8 — three shapes now need the profile at the call.**
|
|
702
|
+
* Each was accepted by 1.8 and is a type error here; each has a one-line fix:
|
|
703
|
+
*
|
|
704
|
+
* 1. A mapper that supplied the profile
|
|
705
|
+
* (`createJWTAuthClient({ mapAuthResponse: (d): AuthResult<MyUser> => … })`)
|
|
706
|
+
* is now typed `UserProfile`. Name it on the factory:
|
|
707
|
+
* `createJWTAuthClient<MyUser>({ mapAuthResponse })`.
|
|
708
|
+
* 2. A config variable annotated `AuthClientConfig<MyUser>` with a profile that
|
|
709
|
+
* extends `UserProfile` used to supply the type argument. Pass it:
|
|
710
|
+
* `createJWTAuthClient<MyUser>(config)`. (A no-id profile was already
|
|
711
|
+
* rejected by 1.8's `T extends UserProfile`.)
|
|
712
|
+
* 3. Generic forwarding written `function make<T extends UserProfile>(config: AuthClientConfig<T>)`
|
|
713
|
+
* no longer satisfies the factory's constraint. Copy the named constraint:
|
|
714
|
+
* `function make<T extends AuthProfileConstraint<T>>(config: AuthClientConfig<T>)`.
|
|
715
|
+
*
|
|
716
|
+
* `any` is accepted at every entrypoint (`createJWTAuthClient<any>()`,
|
|
717
|
+
* `getClient<any>()`), so a caller that deliberately opted out keeps compiling.
|
|
718
|
+
*
|
|
719
|
+
* @template T - The user profile the API returns: a JSON object type of named
|
|
720
|
+
* fields. The default, {@link UserProfile}, keeps the untyped configuration
|
|
721
|
+
* working.
|
|
722
|
+
*/
|
|
723
|
+
export type AuthClientConfig<T extends object = UserProfile> = AuthClientConfigOptions<T> & AuthProfileGuard<T>;
|
|
724
|
+
/**
|
|
725
|
+
* Every option {@link AuthClientConfig} accepts, typed by the profile.
|
|
726
|
+
*
|
|
727
|
+
* Use `AuthClientConfig<T>` rather than this type: it adds the profile-shape
|
|
728
|
+
* check. This interface exists so each member's documentation is addressable.
|
|
729
|
+
*
|
|
730
|
+
* @template T - The user profile the API returns.
|
|
533
731
|
*/
|
|
534
|
-
export interface
|
|
732
|
+
export interface AuthClientConfigOptions<T extends object = UserProfile> {
|
|
535
733
|
/**
|
|
536
734
|
* API base URL.
|
|
537
735
|
*/
|
|
@@ -556,6 +754,8 @@ export interface AuthClientConfig<T extends UserProfile = UserProfile> {
|
|
|
556
754
|
* The write route used by `updateProfile`, independently of `currentUserEndpoint`.
|
|
557
755
|
* Defaults to `/auth/profile`. A resource route with an account id can resolve
|
|
558
756
|
* from the signed-in user, e.g. `(user) => '/accounts/' + encodeURIComponent(user.id)`.
|
|
757
|
+
* A profile with no `id` resolves from a field it does have, e.g.
|
|
758
|
+
* `(user) => '/people/' + encodeURIComponent(user.username)`.
|
|
559
759
|
* The resolver sees the current user before the patch, never caller-submitted identity.
|
|
560
760
|
*/
|
|
561
761
|
profileEndpoint?: string | ((user: Readonly<T>) => string);
|
|
@@ -634,7 +834,16 @@ export interface AuthClientConfig<T extends UserProfile = UserProfile> {
|
|
|
634
834
|
/**
|
|
635
835
|
* Turn an answer that carries a user into the client's
|
|
636
836
|
* `{ accessToken, refreshToken?, user }` (default: the answer as given).
|
|
637
|
-
* RealWorld, for example
|
|
837
|
+
* RealWorld, for example — keep the wire bearer OUT of the profile, because
|
|
838
|
+
* the client caches `user` in Web Storage where a token copy is readable by
|
|
839
|
+
* any script on the origin:
|
|
840
|
+
*
|
|
841
|
+
* ```typescript
|
|
842
|
+
* (data) => {
|
|
843
|
+
* const { token, ...user } = data.user
|
|
844
|
+
* return { accessToken: token, user }
|
|
845
|
+
* }
|
|
846
|
+
* ```
|
|
638
847
|
*
|
|
639
848
|
* It is the ONE user-shape adapter, and the client applies it on EVERY path
|
|
640
849
|
* that adopts a user from an API answer — `login()`, `register()`,
|
|
@@ -649,10 +858,19 @@ export interface AuthClientConfig<T extends UserProfile = UserProfile> {
|
|
|
649
858
|
* It is NOT applied to `setSession()` or `setUser()`: those receive a profile
|
|
650
859
|
* the caller already built in this client's shape, not a wire answer.
|
|
651
860
|
*
|
|
861
|
+
* The return type does NOT infer the profile: an untyped
|
|
862
|
+
* `createJWTAuthClient({ mapAuthResponse })` stays `UserProfile`, so a mapper
|
|
863
|
+
* that returns a no-id profile fails to compile there instead of silently
|
|
864
|
+
* replacing the default with whatever the mapper happened to return. The same
|
|
865
|
+
* rule holds for every config member below (`profileEndpoint`,
|
|
866
|
+
* `profileRequestBody`, `shouldRestoreUser`): none of them supplies the
|
|
867
|
+
* profile. Name the profile at the call
|
|
868
|
+
* (`createJWTAuthClient<MyUser>({ mapAuthResponse })`) to use a custom one.
|
|
869
|
+
*
|
|
652
870
|
* @param data - The parsed response body.
|
|
653
871
|
* @returns The auth result.
|
|
654
872
|
*/
|
|
655
|
-
mapAuthResponse?: (data: unknown) => AuthResult<T
|
|
873
|
+
mapAuthResponse?: (data: unknown) => AuthResult<NoInfer<T>>;
|
|
656
874
|
/**
|
|
657
875
|
* Where the access/refresh token and the cached user are kept — the field that
|
|
658
876
|
* decides whether a page reload keeps the user signed in.
|
|
@@ -760,4 +978,5 @@ export interface TokenStorage {
|
|
|
760
978
|
setUser<T = UserProfile>(user: T | null): void;
|
|
761
979
|
clear(): void;
|
|
762
980
|
}
|
|
981
|
+
export {};
|
|
763
982
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG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