@anarchitects/auth-angular 0.5.1 → 0.6.1

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 (37) hide show
  1. package/README.md +40 -16
  2. package/data-access/README.md +6 -8
  3. package/data-access/jwt/README.md +23 -0
  4. package/feature/README.md +7 -5
  5. package/feature/jwt/README.md +27 -0
  6. package/fesm2022/anarchitects-auth-angular-config.mjs +20 -2
  7. package/fesm2022/anarchitects-auth-angular-config.mjs.map +1 -1
  8. package/fesm2022/anarchitects-auth-angular-data-access-jwt.mjs +201 -0
  9. package/fesm2022/anarchitects-auth-angular-data-access-jwt.mjs.map +1 -0
  10. package/fesm2022/anarchitects-auth-angular-data-access.mjs +5 -174
  11. package/fesm2022/anarchitects-auth-angular-data-access.mjs.map +1 -1
  12. package/fesm2022/anarchitects-auth-angular-feature-jwt.mjs +26 -0
  13. package/fesm2022/anarchitects-auth-angular-feature-jwt.mjs.map +1 -0
  14. package/fesm2022/anarchitects-auth-angular-feature.mjs +4 -75
  15. package/fesm2022/anarchitects-auth-angular-feature.mjs.map +1 -1
  16. package/fesm2022/anarchitects-auth-angular-state-jwt.mjs +66 -0
  17. package/fesm2022/anarchitects-auth-angular-state-jwt.mjs.map +1 -0
  18. package/fesm2022/anarchitects-auth-angular-state.mjs +6 -74
  19. package/fesm2022/anarchitects-auth-angular-state.mjs.map +1 -1
  20. package/fesm2022/anarchitects-auth-angular-ui-jwt.mjs +58 -0
  21. package/fesm2022/anarchitects-auth-angular-ui-jwt.mjs.map +1 -0
  22. package/fesm2022/anarchitects-auth-angular-ui.mjs +6 -77
  23. package/fesm2022/anarchitects-auth-angular-ui.mjs.map +1 -1
  24. package/package.json +20 -4
  25. package/state/README.md +3 -2
  26. package/state/jwt/README.md +22 -0
  27. package/types/anarchitects-auth-angular-config.d.ts +8 -1
  28. package/types/anarchitects-auth-angular-data-access-jwt.d.ts +45 -0
  29. package/types/anarchitects-auth-angular-data-access.d.ts +15 -31
  30. package/types/anarchitects-auth-angular-feature-jwt.d.ts +13 -0
  31. package/types/anarchitects-auth-angular-feature.d.ts +2 -13
  32. package/types/anarchitects-auth-angular-state-jwt.d.ts +19 -0
  33. package/types/anarchitects-auth-angular-state.d.ts +3 -10
  34. package/types/anarchitects-auth-angular-ui-jwt.d.ts +17 -0
  35. package/types/anarchitects-auth-angular-ui.d.ts +3 -18
  36. package/ui/README.md +2 -1
  37. package/ui/jwt/README.md +11 -0
@@ -0,0 +1,66 @@
1
+ import { JwtAuthApi, storeTokens } from '@anarchitects/auth-angular/data-access/jwt';
2
+ import { inject } from '@angular/core';
3
+ import { signalStore, withState, withProps, withMethods, patchState } from '@ngrx/signals';
4
+ import { firstValueFrom } from 'rxjs';
5
+
6
+ const initialState = {
7
+ loading: false,
8
+ error: null,
9
+ success: false,
10
+ };
11
+ const toErrorMessage = (error) => {
12
+ if (typeof error === 'string') {
13
+ return error;
14
+ }
15
+ if (error instanceof Error) {
16
+ return error.message;
17
+ }
18
+ if (error &&
19
+ typeof error === 'object' &&
20
+ 'message' in error &&
21
+ typeof error.message === 'string') {
22
+ return error.message;
23
+ }
24
+ return 'Request failed.';
25
+ };
26
+ const AuthJwtStore = signalStore(withState(initialState), withProps(() => ({
27
+ _jwtAuthApi: inject(JwtAuthApi),
28
+ })), withMethods((store) => ({
29
+ async refreshTokens(dto) {
30
+ if (!dto.refreshToken) {
31
+ return;
32
+ }
33
+ patchState(store, {
34
+ loading: true,
35
+ error: null,
36
+ success: false,
37
+ });
38
+ try {
39
+ const tokens = await firstValueFrom(store._jwtAuthApi.refreshTokens(dto));
40
+ storeTokens(tokens);
41
+ patchState(store, {
42
+ loading: false,
43
+ success: true,
44
+ });
45
+ }
46
+ catch (error) {
47
+ patchState(store, {
48
+ loading: false,
49
+ error: toErrorMessage(error),
50
+ success: false,
51
+ });
52
+ throw error;
53
+ }
54
+ },
55
+ })));
56
+
57
+ function provideAuthJwtState() {
58
+ return [AuthJwtStore];
59
+ }
60
+
61
+ /**
62
+ * Generated bundle index. Do not edit.
63
+ */
64
+
65
+ export { AuthJwtStore, provideAuthJwtState };
66
+ //# sourceMappingURL=anarchitects-auth-angular-state-jwt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anarchitects-auth-angular-state-jwt.mjs","sources":["../../../../../libs/auth/angular/state/jwt/src/auth-jwt.store.ts","../../../../../libs/auth/angular/state/jwt/src/auth-jwt-state.provider.ts","../../../../../libs/auth/angular/state/jwt/src/anarchitects-auth-angular-state-jwt.ts"],"sourcesContent":["import {\n JwtAuthApi,\n storeTokens,\n} from '@anarchitects/auth-angular/data-access/jwt';\nimport { RefreshTokenRequestDTO } from '@anarchitects/auth-ts/dtos/jwt';\nimport { inject } from '@angular/core';\nimport { patchState, signalStore, withMethods, withProps, withState } from '@ngrx/signals';\nimport { firstValueFrom } from 'rxjs';\n\ntype AuthJwtState = {\n loading: boolean;\n error: string | null;\n success: boolean;\n};\n\nconst initialState: AuthJwtState = {\n loading: false,\n error: null,\n success: false,\n};\n\nconst toErrorMessage = (error: unknown): string => {\n if (typeof error === 'string') {\n return error;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n if (\n error &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'\n ) {\n return error.message;\n }\n\n return 'Request failed.';\n};\n\nexport const AuthJwtStore = signalStore(\n withState(initialState),\n withProps(() => ({\n _jwtAuthApi: inject(JwtAuthApi),\n })),\n withMethods((store) => ({\n async refreshTokens(dto: RefreshTokenRequestDTO): Promise<void> {\n if (!dto.refreshToken) {\n return;\n }\n\n patchState(store, {\n loading: true,\n error: null,\n success: false,\n });\n\n try {\n const tokens = await firstValueFrom(store._jwtAuthApi.refreshTokens(dto));\n storeTokens(tokens);\n patchState(store, {\n loading: false,\n success: true,\n });\n } catch (error) {\n patchState(store, {\n loading: false,\n error: toErrorMessage(error),\n success: false,\n });\n throw error;\n }\n },\n })),\n);\n","import { Provider } from '@angular/core';\nimport { AuthJwtStore } from './auth-jwt.store';\n\nexport function provideAuthJwtState(): Provider[] {\n return [AuthJwtStore];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAeA,MAAM,YAAY,GAAiB;AACjC,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,OAAO,EAAE,KAAK;CACf;AAED,MAAM,cAAc,GAAG,CAAC,KAAc,KAAY;AAChD,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,OAAO,KAAK,CAAC,OAAO;IACtB;AAEA,IAAA,IACE,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;AACzB,QAAA,SAAS,IAAI,KAAK;AAClB,QAAA,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EACjC;QACA,OAAO,KAAK,CAAC,OAAO;IACtB;AAEA,IAAA,OAAO,iBAAiB;AAC1B,CAAC;AAEM,MAAM,YAAY,GAAG,WAAW,CACrC,SAAS,CAAC,YAAY,CAAC,EACvB,SAAS,CAAC,OAAO;AACf,IAAA,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC;CAChC,CAAC,CAAC,EACH,WAAW,CAAC,CAAC,KAAK,MAAM;IACtB,MAAM,aAAa,CAAC,GAA2B,EAAA;AAC7C,QAAA,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE;YACrB;QACF;QAEA,UAAU,CAAC,KAAK,EAAE;AAChB,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,OAAO,EAAE,KAAK;AACf,SAAA,CAAC;AAEF,QAAA,IAAI;AACF,YAAA,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YACzE,WAAW,CAAC,MAAM,CAAC;YACnB,UAAU,CAAC,KAAK,EAAE;AAChB,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,OAAO,EAAE,IAAI;AACd,aAAA,CAAC;QACJ;QAAE,OAAO,KAAK,EAAE;YACd,UAAU,CAAC,KAAK,EAAE;AAChB,gBAAA,OAAO,EAAE,KAAK;AACd,gBAAA,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;AAC5B,gBAAA,OAAO,EAAE,KAAK;AACf,aAAA,CAAC;AACF,YAAA,MAAM,KAAK;QACb;IACF,CAAC;CACF,CAAC,CAAC;;SCxEW,mBAAmB,GAAA;IACjC,OAAO,CAAC,YAAY,CAAC;AACvB;;ACLA;;AAEG;;;;"}
@@ -1,12 +1,12 @@
1
1
  import { InjectionToken, inject, computed, provideEnvironmentInitializer } from '@angular/core';
2
- import { clearStoredTokens, AuthApi, storeTokens, resolveUserIdFromAccessToken, getStoredToken, ACCESS_TOKEN_STORAGE_KEY } from '@anarchitects/auth-angular/data-access';
2
+ import { AuthApi } from '@anarchitects/auth-angular/data-access';
3
3
  import { createAppAbility } from '@anarchitects/auth-angular/util';
4
4
  import { Router } from '@angular/router';
5
5
  import { tapResponse } from '@ngrx/operators';
6
6
  import { patchState, signalStore, withState, withProps, withComputed, withMethods, withHooks } from '@ngrx/signals';
7
7
  import { setAllEntities, removeAllEntities, withEntities } from '@ngrx/signals/entities';
8
8
  import { rxMethod } from '@ngrx/signals/rxjs-interop';
9
- import { pipe, tap, switchMap, EMPTY, catchError, throwError } from 'rxjs';
9
+ import { pipe, tap, switchMap, EMPTY } from 'rxjs';
10
10
 
11
11
  const DEFAULT_AUTH_STATE_OPTIONS = {
12
12
  restoreOnInit: true,
@@ -70,13 +70,6 @@ const redirectToLogin = (router) => {
70
70
  window.location.assign(LOGIN_REDIRECT_PATH);
71
71
  }
72
72
  };
73
- const failClosedHydration = (store, error, state = {}) => {
74
- clearStoredTokens();
75
- clearAuthenticatedSession(store, {
76
- error: toErrorMessage(error),
77
- ...state,
78
- });
79
- };
80
73
  const AuthStore = signalStore(withState(initialState), withEntities(), withProps(() => ({
81
74
  _authApi: inject(AuthApi),
82
75
  _authStateOptions: inject(AUTH_STATE_OPTIONS),
@@ -99,23 +92,6 @@ const AuthStore = signalStore(withState(initialState), withEntities(), withProps
99
92
  if (!store._authStateOptions.restoreOnInit || store.initialized()) {
100
93
  return EMPTY;
101
94
  }
102
- const accessToken = getStoredToken(ACCESS_TOKEN_STORAGE_KEY);
103
- if (!accessToken) {
104
- patchState(store, { initialized: true, restoring: false });
105
- return EMPTY;
106
- }
107
- if (!resolveUserIdFromAccessToken(accessToken)) {
108
- clearStoredTokens();
109
- clearAuthenticatedSession(store, {
110
- error: 'Invalid access token payload.',
111
- initialized: true,
112
- restoring: false,
113
- });
114
- if (store._authStateOptions.onRestoreFailure === 'redirectToLogin') {
115
- redirectToLogin(store._router);
116
- }
117
- return EMPTY;
118
- }
119
95
  return store._authApi
120
96
  .getLoggedInUserInfo({
121
97
  suppressAuthFailureRedirect: store._authStateOptions.onRestoreFailure === 'stayLoggedOut',
@@ -135,7 +111,6 @@ const AuthStore = signalStore(withState(initialState), withEntities(), withProps
135
111
  });
136
112
  },
137
113
  error: (error) => {
138
- clearStoredTokens();
139
114
  clearAuthenticatedSession(store, {
140
115
  error: toErrorMessage(error),
141
116
  initialized: true,
@@ -170,23 +145,13 @@ const AuthStore = signalStore(withState(initialState), withEntities(), withProps
170
145
  patchState(store, { loading: false });
171
146
  },
172
147
  }))))),
173
- login: rxMethod(pipe(tap(() => patchState(store, { loading: true, error: null })), switchMap((dto) => store._authApi.login(dto).pipe(switchMap(({ accessToken, refreshToken }) => {
174
- storeTokens({ accessToken, refreshToken });
175
- if (!resolveUserIdFromAccessToken(accessToken)) {
176
- clearStoredTokens();
177
- patchState(store, { error: 'Invalid access token payload.' });
178
- return EMPTY;
179
- }
180
- return store._authApi.getLoggedInUserInfo().pipe(catchError((error) => {
181
- failClosedHydration(store, error, { initialized: true });
182
- return throwError(() => error);
183
- }));
184
- }), tapResponse({
148
+ login: rxMethod(pipe(tap(() => patchState(store, { loading: true, error: null })), switchMap((dto) => store._authApi.login(dto).pipe(tapResponse({
185
149
  next: ({ user, rbac }) => {
150
+ const authenticatedUser = user;
186
151
  patchAuthenticatedSession(store, {
187
152
  user: {
188
- email: user.email,
189
- id: user.id,
153
+ email: authenticatedUser.email,
154
+ id: authenticatedUser.id,
190
155
  },
191
156
  rbac,
192
157
  });
@@ -204,7 +169,6 @@ const AuthStore = signalStore(withState(initialState), withEntities(), withProps
204
169
  }))))),
205
170
  logout: rxMethod(pipe(tap(() => {
206
171
  patchState(store, { error: null, loading: true, success: false });
207
- clearStoredTokens();
208
172
  clearAuthenticatedSession(store, { initialized: true });
209
173
  }), switchMap((dto) => store._authApi.logout(dto).pipe(tapResponse({
210
174
  next: ({ success }) => {
@@ -272,38 +236,6 @@ const AuthStore = signalStore(withState(initialState), withEntities(), withProps
272
236
  patchState(store, { loading: false });
273
237
  },
274
238
  }))))),
275
- refreshTokens: rxMethod(pipe(tap(() => patchState(store, { loading: true, error: null })), switchMap(({ userId, dto }) => store._authApi.refreshTokens(userId, dto).pipe(switchMap(({ accessToken, refreshToken }) => {
276
- storeTokens({ accessToken, refreshToken });
277
- if (!resolveUserIdFromAccessToken(accessToken)) {
278
- clearStoredTokens();
279
- patchState(store, { error: 'Invalid access token payload.' });
280
- return EMPTY;
281
- }
282
- return store._authApi.getLoggedInUserInfo().pipe(catchError((error) => {
283
- failClosedHydration(store, error, { initialized: true });
284
- return throwError(() => error);
285
- }));
286
- }), tapResponse({
287
- next: ({ user, rbac }) => {
288
- patchAuthenticatedSession(store, {
289
- user: {
290
- email: user.email,
291
- id: user.id,
292
- },
293
- rbac,
294
- });
295
- patchState(store, { initialized: true });
296
- },
297
- error: (error) => {
298
- patchState(store, {
299
- error: toErrorMessage(error),
300
- initialized: true,
301
- });
302
- },
303
- finalize: () => {
304
- patchState(store, { loading: false });
305
- },
306
- }))))),
307
239
  })), withHooks((store) => ({
308
240
  onInit() {
309
241
  store.restoreSession();
@@ -1 +1 @@
1
- {"version":3,"file":"anarchitects-auth-angular-state.mjs","sources":["../../../../../libs/auth/angular/state/src/auth-state.options.ts","../../../../../libs/auth/angular/state/src/auth.store.ts","../../../../../libs/auth/angular/state/src/auth-state.provider.ts","../../../../../libs/auth/angular/state/src/anarchitects-auth-angular-state.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport type AuthRestoreFailureBehavior =\n | 'stayLoggedOut'\n | 'redirectToLogin';\n\nexport type AuthStateOptions = {\n restoreOnInit?: boolean;\n onRestoreFailure?: AuthRestoreFailureBehavior;\n};\n\nexport const DEFAULT_AUTH_STATE_OPTIONS: Required<AuthStateOptions> = {\n restoreOnInit: true,\n onRestoreFailure: 'stayLoggedOut',\n};\n\nexport const AUTH_STATE_OPTIONS = new InjectionToken<\n Required<AuthStateOptions>\n>('AUTH_STATE_OPTIONS', {\n factory: () => DEFAULT_AUTH_STATE_OPTIONS,\n});\n\nexport const resolveAuthStateOptions = (\n options: AuthStateOptions = {},\n): Required<AuthStateOptions> => ({\n ...DEFAULT_AUTH_STATE_OPTIONS,\n ...options,\n});\n","import { AuthApi } from '@anarchitects/auth-angular/data-access';\nimport {\n ACCESS_TOKEN_STORAGE_KEY,\n clearStoredTokens,\n getStoredToken,\n resolveUserIdFromAccessToken,\n storeTokens,\n} from '@anarchitects/auth-angular/data-access';\nimport { createAppAbility } from '@anarchitects/auth-angular/util';\nimport {\n ActivateUserRequestDTO,\n ChangePasswordRequestDTO,\n ForgotPasswordRequestDTO,\n LoginRequestDTO,\n LogoutRequestDTO,\n RefreshTokenRequestDTO,\n RegisterRequestDTO,\n ResetPasswordRequestDTO,\n UpdateEmailRequestDTO,\n VerifyEmailRequestDTO,\n} from '@anarchitects/auth-ts/dtos';\nimport { PolicyRule, User } from '@anarchitects/auth-ts/models';\nimport { computed, inject } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { tapResponse } from '@ngrx/operators';\nimport {\n patchState,\n signalStore,\n withComputed,\n withHooks,\n withMethods,\n withProps,\n withState,\n} from '@ngrx/signals';\nimport {\n removeAllEntities,\n setAllEntities,\n withEntities,\n} from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { catchError, EMPTY, pipe, switchMap, tap, throwError } from 'rxjs';\nimport { AUTH_STATE_OPTIONS } from './auth-state.options';\n\ntype AuthState = {\n loading: boolean;\n error: string | null;\n success: boolean;\n ability: ReturnType<typeof createAppAbility> | undefined;\n rbac: PolicyRule[];\n initialized: boolean;\n restoring: boolean;\n};\n\ntype AuthUser = Pick<User, 'id' | 'email'>;\n\nconst LOGIN_REDIRECT_PATH = '/login';\n\nconst initialState: AuthState = {\n loading: false,\n error: null,\n success: false,\n ability: undefined,\n rbac: [],\n initialized: false,\n restoring: false,\n};\n\nconst toErrorMessage = (error: unknown): string => {\n if (typeof error === 'string') {\n return error;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n if (\n error &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'\n ) {\n return error.message;\n }\n\n return 'Request failed.';\n};\n\nconst patchAuthenticatedSession = (\n store: object,\n session: { user: AuthUser; rbac: PolicyRule[] },\n) => {\n patchState(\n store as never,\n setAllEntities([session.user]),\n {\n ability: createAppAbility(session.rbac),\n error: null,\n rbac: session.rbac,\n success: true,\n },\n );\n};\n\nconst clearAuthenticatedSession = (\n store: object,\n state: Partial<AuthState> = {},\n) => {\n patchState(\n store as never,\n removeAllEntities(),\n {\n ability: undefined,\n rbac: [],\n success: false,\n ...state,\n },\n );\n};\n\nconst redirectToLogin = (router: Router | null): void => {\n if (router) {\n void router.navigateByUrl(LOGIN_REDIRECT_PATH);\n return;\n }\n\n if (typeof window !== 'undefined') {\n window.location.assign(LOGIN_REDIRECT_PATH);\n }\n};\n\nconst failClosedHydration = (\n store: object,\n error: unknown,\n state: Partial<AuthState> = {},\n) => {\n clearStoredTokens();\n clearAuthenticatedSession(store, {\n error: toErrorMessage(error),\n ...state,\n });\n};\n\nexport const AuthStore = signalStore(\n withState(initialState),\n withEntities<AuthUser>(),\n withProps(() => ({\n _authApi: inject(AuthApi),\n _authStateOptions: inject(AUTH_STATE_OPTIONS),\n _router: inject(Router, { optional: true }),\n })),\n withComputed((store) => ({\n isLoggedIn: computed(() => !!store.entities().length),\n loggedInUser: computed(() => store.entities()[0]),\n })),\n withMethods((store) => ({\n restoreSession: rxMethod<void>(\n pipe(\n tap(() => {\n if (!store._authStateOptions.restoreOnInit || store.initialized()) {\n patchState(store, { initialized: true, restoring: false });\n return;\n }\n\n patchState(store, {\n error: null,\n restoring: true,\n success: false,\n });\n }),\n switchMap(() => {\n if (!store._authStateOptions.restoreOnInit || store.initialized()) {\n return EMPTY;\n }\n\n const accessToken = getStoredToken(ACCESS_TOKEN_STORAGE_KEY);\n\n if (!accessToken) {\n patchState(store, { initialized: true, restoring: false });\n return EMPTY;\n }\n\n if (!resolveUserIdFromAccessToken(accessToken)) {\n clearStoredTokens();\n clearAuthenticatedSession(store, {\n error: 'Invalid access token payload.',\n initialized: true,\n restoring: false,\n });\n\n if (store._authStateOptions.onRestoreFailure === 'redirectToLogin') {\n redirectToLogin(store._router);\n }\n\n return EMPTY;\n }\n\n return store._authApi\n .getLoggedInUserInfo({\n suppressAuthFailureRedirect:\n store._authStateOptions.onRestoreFailure === 'stayLoggedOut',\n })\n .pipe(\n tapResponse({\n next: ({ user, rbac }) => {\n patchAuthenticatedSession(store, {\n user: {\n email: user.email,\n id: user.id,\n },\n rbac,\n });\n patchState(store, {\n initialized: true,\n restoring: false,\n });\n },\n error: (error: unknown) => {\n clearStoredTokens();\n clearAuthenticatedSession(store, {\n error: toErrorMessage(error),\n initialized: true,\n restoring: false,\n });\n\n if (\n store._authStateOptions.onRestoreFailure ===\n 'redirectToLogin'\n ) {\n redirectToLogin(store._router);\n }\n },\n }),\n );\n }),\n ),\n ),\n registerUser: rxMethod<RegisterRequestDTO>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap((dto) =>\n store._authApi.registerUser(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n activateUser: rxMethod<ActivateUserRequestDTO>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap((dto) =>\n store._authApi.activateUser(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n login: rxMethod<LoginRequestDTO>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap((dto) =>\n store._authApi.login(dto).pipe(\n switchMap(({ accessToken, refreshToken }) => {\n storeTokens({ accessToken, refreshToken });\n\n if (!resolveUserIdFromAccessToken(accessToken)) {\n clearStoredTokens();\n patchState(store, { error: 'Invalid access token payload.' });\n return EMPTY;\n }\n\n return store._authApi.getLoggedInUserInfo().pipe(\n catchError((error: unknown) => {\n failClosedHydration(store, error, { initialized: true });\n return throwError(() => error);\n }),\n );\n }),\n tapResponse({\n next: ({ user, rbac }) => {\n patchAuthenticatedSession(store, {\n user: {\n email: user.email,\n id: user.id,\n },\n rbac,\n });\n patchState(store, { initialized: true });\n },\n error: (error: unknown) => {\n patchState(store, {\n error: toErrorMessage(error),\n initialized: true,\n });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n logout: rxMethod<LogoutRequestDTO>(\n pipe(\n tap(() => {\n patchState(store, { error: null, loading: true, success: false });\n clearStoredTokens();\n clearAuthenticatedSession(store, { initialized: true });\n }),\n switchMap((dto) =>\n store._authApi.logout(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n changePassword: rxMethod<{ userId: string; dto: ChangePasswordRequestDTO }>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap(({ userId, dto }) =>\n store._authApi.changePassword(userId, dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n forgotPassword: rxMethod<ForgotPasswordRequestDTO>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap((dto) =>\n store._authApi.forgotPassword(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n resetPassword: rxMethod<{ dto: ResetPasswordRequestDTO }>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap(({ dto }) =>\n store._authApi.resetPassword(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n verifyEmail: rxMethod<VerifyEmailRequestDTO>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap((dto) =>\n store._authApi.verifyEmail(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n updateEmail: rxMethod<{ userId: string; dto: UpdateEmailRequestDTO }>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap(({ userId, dto }) =>\n store._authApi.updateEmail(userId, dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n refreshTokens: rxMethod<{ userId: string; dto: RefreshTokenRequestDTO }>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap(({ userId, dto }) =>\n store._authApi.refreshTokens(userId, dto).pipe(\n switchMap(({ accessToken, refreshToken }) => {\n storeTokens({ accessToken, refreshToken });\n\n if (!resolveUserIdFromAccessToken(accessToken)) {\n clearStoredTokens();\n patchState(store, { error: 'Invalid access token payload.' });\n return EMPTY;\n }\n\n return store._authApi.getLoggedInUserInfo().pipe(\n catchError((error: unknown) => {\n failClosedHydration(store, error, { initialized: true });\n return throwError(() => error);\n }),\n );\n }),\n tapResponse({\n next: ({ user, rbac }) => {\n patchAuthenticatedSession(store, {\n user: {\n email: user.email,\n id: user.id,\n },\n rbac,\n });\n patchState(store, { initialized: true });\n },\n error: (error: unknown) => {\n patchState(store, {\n error: toErrorMessage(error),\n initialized: true,\n });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n })),\n withHooks((store) => ({\n onInit() {\n store.restoreSession();\n },\n })),\n);\n","import {\n EnvironmentProviders,\n inject,\n provideEnvironmentInitializer,\n Provider,\n} from '@angular/core';\nimport { AuthStore } from './auth.store';\nimport {\n AUTH_STATE_OPTIONS,\n AuthStateOptions,\n resolveAuthStateOptions,\n} from './auth-state.options';\n\nexport function provideAuthState(\n options: AuthStateOptions = {},\n): Array<Provider | EnvironmentProviders> {\n return [\n { provide: AUTH_STATE_OPTIONS, useValue: resolveAuthStateOptions(options) },\n AuthStore,\n provideEnvironmentInitializer(() => {\n inject(AuthStore);\n }),\n ];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;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E,uBAAuB,CAAC,OAAO,CAAC,EAAE;QAC3E,SAAS;QACT,6BAA6B,CAAC,MAAK;YACjC,MAAM,CAAC,SAAS,CAAC;AACnB,QAAA,CAAC,CAAC;KACH;AACH;;ACvBA;;AAEG;;;;"}
1
+ {"version":3,"file":"anarchitects-auth-angular-state.mjs","sources":["../../../../../libs/auth/angular/state/src/auth-state.options.ts","../../../../../libs/auth/angular/state/src/auth.store.ts","../../../../../libs/auth/angular/state/src/auth-state.provider.ts","../../../../../libs/auth/angular/state/src/anarchitects-auth-angular-state.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport type AuthRestoreFailureBehavior =\n | 'stayLoggedOut'\n | 'redirectToLogin';\n\nexport type AuthStateOptions = {\n restoreOnInit?: boolean;\n onRestoreFailure?: AuthRestoreFailureBehavior;\n};\n\nexport const DEFAULT_AUTH_STATE_OPTIONS: Required<AuthStateOptions> = {\n restoreOnInit: true,\n onRestoreFailure: 'stayLoggedOut',\n};\n\nexport const AUTH_STATE_OPTIONS = new InjectionToken<\n Required<AuthStateOptions>\n>('AUTH_STATE_OPTIONS', {\n factory: () => DEFAULT_AUTH_STATE_OPTIONS,\n});\n\nexport const resolveAuthStateOptions = (\n options: AuthStateOptions = {},\n): Required<AuthStateOptions> => ({\n ...DEFAULT_AUTH_STATE_OPTIONS,\n ...options,\n});\n","import { AuthApi } from '@anarchitects/auth-angular/data-access';\nimport { createAppAbility } from '@anarchitects/auth-angular/util';\nimport {\n ActivateUserRequestDTO,\n ChangePasswordRequestDTO,\n ForgotPasswordRequestDTO,\n LoginRequestDTO,\n LogoutRequestDTO,\n RegisterRequestDTO,\n ResetPasswordRequestDTO,\n UpdateEmailRequestDTO,\n VerifyEmailRequestDTO,\n} from '@anarchitects/auth-ts/dtos';\nimport { PolicyRule, User } from '@anarchitects/auth-ts/models';\nimport { computed, inject } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { tapResponse } from '@ngrx/operators';\nimport {\n patchState,\n signalStore,\n withComputed,\n withHooks,\n withMethods,\n withProps,\n withState,\n} from '@ngrx/signals';\nimport {\n removeAllEntities,\n setAllEntities,\n withEntities,\n} from '@ngrx/signals/entities';\nimport { rxMethod } from '@ngrx/signals/rxjs-interop';\nimport { EMPTY, pipe, switchMap, tap } from 'rxjs';\nimport { AUTH_STATE_OPTIONS } from './auth-state.options';\n\ntype AuthState = {\n loading: boolean;\n error: string | null;\n success: boolean;\n ability: ReturnType<typeof createAppAbility> | undefined;\n rbac: PolicyRule[];\n initialized: boolean;\n restoring: boolean;\n};\n\ntype AuthUser = Pick<User, 'id' | 'email'>;\n\nconst LOGIN_REDIRECT_PATH = '/login';\n\nconst initialState: AuthState = {\n loading: false,\n error: null,\n success: false,\n ability: undefined,\n rbac: [],\n initialized: false,\n restoring: false,\n};\n\nconst toErrorMessage = (error: unknown): string => {\n if (typeof error === 'string') {\n return error;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n if (\n error &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'\n ) {\n return error.message;\n }\n\n return 'Request failed.';\n};\n\nconst patchAuthenticatedSession = (\n store: object,\n session: { user: AuthUser; rbac: PolicyRule[] },\n) => {\n patchState(\n store as never,\n setAllEntities([session.user]),\n {\n ability: createAppAbility(session.rbac),\n error: null,\n rbac: session.rbac,\n success: true,\n },\n );\n};\n\nconst clearAuthenticatedSession = (\n store: object,\n state: Partial<AuthState> = {},\n) => {\n patchState(\n store as never,\n removeAllEntities(),\n {\n ability: undefined,\n rbac: [],\n success: false,\n ...state,\n },\n );\n};\n\nconst redirectToLogin = (router: Router | null): void => {\n if (router) {\n void router.navigateByUrl(LOGIN_REDIRECT_PATH);\n return;\n }\n\n if (typeof window !== 'undefined') {\n window.location.assign(LOGIN_REDIRECT_PATH);\n }\n};\n\nexport const AuthStore = signalStore(\n withState(initialState),\n withEntities<AuthUser>(),\n withProps(() => ({\n _authApi: inject(AuthApi),\n _authStateOptions: inject(AUTH_STATE_OPTIONS),\n _router: inject(Router, { optional: true }),\n })),\n withComputed((store) => ({\n isLoggedIn: computed(() => !!store.entities().length),\n loggedInUser: computed(() => store.entities()[0]),\n })),\n withMethods((store) => ({\n restoreSession: rxMethod<void>(\n pipe(\n tap(() => {\n if (!store._authStateOptions.restoreOnInit || store.initialized()) {\n patchState(store, { initialized: true, restoring: false });\n return;\n }\n\n patchState(store, {\n error: null,\n restoring: true,\n success: false,\n });\n }),\n switchMap(() => {\n if (!store._authStateOptions.restoreOnInit || store.initialized()) {\n return EMPTY;\n }\n\n return store._authApi\n .getLoggedInUserInfo({\n suppressAuthFailureRedirect:\n store._authStateOptions.onRestoreFailure === 'stayLoggedOut',\n })\n .pipe(\n tapResponse({\n next: ({ user, rbac }) => {\n patchAuthenticatedSession(store, {\n user: {\n email: user.email,\n id: user.id,\n },\n rbac,\n });\n patchState(store, {\n initialized: true,\n restoring: false,\n });\n },\n error: (error: unknown) => {\n clearAuthenticatedSession(store, {\n error: toErrorMessage(error),\n initialized: true,\n restoring: false,\n });\n\n if (\n store._authStateOptions.onRestoreFailure ===\n 'redirectToLogin'\n ) {\n redirectToLogin(store._router);\n }\n },\n }),\n );\n }),\n ),\n ),\n registerUser: rxMethod<RegisterRequestDTO>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap((dto) =>\n store._authApi.registerUser(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n activateUser: rxMethod<ActivateUserRequestDTO>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap((dto) =>\n store._authApi.activateUser(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n login: rxMethod<LoginRequestDTO>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap((dto) =>\n store._authApi.login(dto).pipe(\n tapResponse({\n next: ({ user, rbac }) => {\n const authenticatedUser = user as { email: string; id: string };\n patchAuthenticatedSession(store, {\n user: {\n email: authenticatedUser.email,\n id: authenticatedUser.id,\n },\n rbac,\n });\n patchState(store, { initialized: true });\n },\n error: (error: unknown) => {\n patchState(store, {\n error: toErrorMessage(error),\n initialized: true,\n });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n logout: rxMethod<LogoutRequestDTO>(\n pipe(\n tap(() => {\n patchState(store, { error: null, loading: true, success: false });\n clearAuthenticatedSession(store, { initialized: true });\n }),\n switchMap((dto) =>\n store._authApi.logout(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n changePassword: rxMethod<{ userId: string; dto: ChangePasswordRequestDTO }>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap(({ userId, dto }) =>\n store._authApi.changePassword(userId, dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n forgotPassword: rxMethod<ForgotPasswordRequestDTO>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap((dto) =>\n store._authApi.forgotPassword(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n resetPassword: rxMethod<{ dto: ResetPasswordRequestDTO }>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap(({ dto }) =>\n store._authApi.resetPassword(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n verifyEmail: rxMethod<VerifyEmailRequestDTO>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap((dto) =>\n store._authApi.verifyEmail(dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n updateEmail: rxMethod<{ userId: string; dto: UpdateEmailRequestDTO }>(\n pipe(\n tap(() => patchState(store, { loading: true, error: null })),\n switchMap(({ userId, dto }) =>\n store._authApi.updateEmail(userId, dto).pipe(\n tapResponse({\n next: ({ success }) => {\n patchState(store, { success });\n },\n error: (error: unknown) => {\n patchState(store, { error: toErrorMessage(error) });\n },\n finalize: () => {\n patchState(store, { loading: false });\n },\n }),\n ),\n ),\n ),\n ),\n })),\n withHooks((store) => ({\n onInit() {\n store.restoreSession();\n },\n })),\n);\n","import {\n EnvironmentProviders,\n inject,\n provideEnvironmentInitializer,\n Provider,\n} from '@angular/core';\nimport { AuthStore } from './auth.store';\nimport {\n AUTH_STATE_OPTIONS,\n AuthStateOptions,\n resolveAuthStateOptions,\n} from './auth-state.options';\n\nexport function provideAuthState(\n options: AuthStateOptions = {},\n): Array<Provider | EnvironmentProviders> {\n return [\n { provide: AUTH_STATE_OPTIONS, useValue: resolveAuthStateOptions(options) },\n AuthStore,\n provideEnvironmentInitializer(() => {\n inject(AuthStore);\n }),\n ];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAWO,MAAM,0BAA0B,GAA+B;AACpE,IAAA,aAAa,E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AAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAC1C,WAAW,CAAC;AACV,QAAA,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAI;AACpB,YAAA,UAAU,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC;QAChC,CAAC;AACD,QAAA,KAAK,EAAE,CAAC,KAAc,KAAI;AACxB,YAAA,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QACrD,CAAC;QACD,QAAQ,EAAE,MAAK;YACb,UAAU,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QACvC,CAAC;KACF,CAAC,CACH,CACF,CACF,CACF;CACF,CAAC,CAAC,EACH,SAAS,CAAC,CAAC,KAAK,MAAM;IACpB,MAAM,GAAA;QACJ,KAAK,CAAC,cAAc,EAAE;IACxB,CAAC;CACF,CAAC,CAAC;;AC5XC,SAAU,gBAAgB,CAC9B,OAAA,GAA4B,EAAE,EAAA;IAE9B,OAAO;QACL,EAAE,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,uBAAuB,CAAC,OAAO,CAAC,EAAE;QAC3E,SAAS;QACT,6BAA6B,CAAC,MAAK;YACjC,MAAM,CAAC,SAAS,CAAC;AACnB,QAAA,CAAC,CAAC;KACH;AACH;;ACvBA;;AAEG;;;;"}
@@ -0,0 +1,58 @@
1
+ import { AnarchitectsUiForm } from '@anarchitects/forms-angular/ui';
2
+ import * as i0 from '@angular/core';
3
+ import { input, output, computed, ChangeDetectionStrategy, Component } from '@angular/core';
4
+
5
+ const REFRESH_TOKENS_FORM_CONFIG = {
6
+ id: 'refresh-tokens',
7
+ version: 1,
8
+ fields: [
9
+ {
10
+ name: 'refreshToken',
11
+ kind: 'string',
12
+ required: false,
13
+ minLength: 1,
14
+ ui: { label: 'Refresh Token' },
15
+ },
16
+ ],
17
+ };
18
+ const readPayloadString = (input, key) => input.payload[key];
19
+ const readStoredString = (key) => localStorage.getItem(key) || undefined;
20
+ const refreshTokensFormBridge = {
21
+ resolveFormConfig: () => REFRESH_TOKENS_FORM_CONFIG,
22
+ mapSubmission: (input) => {
23
+ const refreshToken = readPayloadString(input, 'refreshToken') || readStoredString('refreshToken');
24
+ if (!refreshToken) {
25
+ return undefined;
26
+ }
27
+ return { refreshToken };
28
+ },
29
+ };
30
+
31
+ class AnarchitectsAuthJwtRefreshTokensForm {
32
+ layout = input(null, ...(ngDevMode ? [{ debugName: "layout" }] : []));
33
+ layoutOptions = input({}, ...(ngDevMode ? [{ debugName: "layoutOptions" }] : []));
34
+ submitted = output();
35
+ formConfig = computed(() => refreshTokensFormBridge.resolveFormConfig(), ...(ngDevMode ? [{ debugName: "formConfig" }] : []));
36
+ onSubmitted(input) {
37
+ const dto = refreshTokensFormBridge.mapSubmission(input);
38
+ if (dto) {
39
+ this.submitted.emit(dto);
40
+ }
41
+ }
42
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: AnarchitectsAuthJwtRefreshTokensForm, deps: [], target: i0.ɵɵFactoryTarget.Component });
43
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.1.6", type: AnarchitectsAuthJwtRefreshTokensForm, isStandalone: true, selector: "anarchitects-auth-jwt-refresh-tokens-form", inputs: { layout: { classPropertyName: "layout", publicName: "layout", isSignal: true, isRequired: false, transformFunction: null }, layoutOptions: { classPropertyName: "layoutOptions", publicName: "layoutOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { submitted: "submitted" }, host: { attributes: { "attr.data-anx-component": "\"auth-jwt-refresh-tokens-form\"" }, classAttribute: "anx-domain-component anx-auth-jwt-refresh-tokens-form anx-stack" }, ngImport: i0, template: "<anarchitects-forms-ui-form\n [config]=\"formConfig()\"\n [layout]=\"layout()\"\n [layoutOptions]=\"layoutOptions()\"\n (submitted)=\"onSubmitted($event)\"\n>\n <ng-content select=\"ng-template[anxTemplate]\"></ng-content>\n <ng-content select=\"[anxSlot]\"></ng-content>\n</anarchitects-forms-ui-form>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "component", type: AnarchitectsUiForm, selector: "anarchitects-forms-ui-form", inputs: ["config", "runtimeValidators", "layout", "layoutOptions"], outputs: ["submitted"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
44
+ }
45
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: AnarchitectsAuthJwtRefreshTokensForm, decorators: [{
46
+ type: Component,
47
+ args: [{ selector: 'anarchitects-auth-jwt-refresh-tokens-form', imports: [AnarchitectsUiForm], changeDetection: ChangeDetectionStrategy.OnPush, host: {
48
+ class: 'anx-domain-component anx-auth-jwt-refresh-tokens-form anx-stack',
49
+ 'attr.data-anx-component': '"auth-jwt-refresh-tokens-form"',
50
+ }, template: "<anarchitects-forms-ui-form\n [config]=\"formConfig()\"\n [layout]=\"layout()\"\n [layoutOptions]=\"layoutOptions()\"\n (submitted)=\"onSubmitted($event)\"\n>\n <ng-content select=\"ng-template[anxTemplate]\"></ng-content>\n <ng-content select=\"[anxSlot]\"></ng-content>\n</anarchitects-forms-ui-form>\n", styles: [":host{display:block}\n"] }]
51
+ }], propDecorators: { layout: [{ type: i0.Input, args: [{ isSignal: true, alias: "layout", required: false }] }], layoutOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "layoutOptions", required: false }] }], submitted: [{ type: i0.Output, args: ["submitted"] }] } });
52
+
53
+ /**
54
+ * Generated bundle index. Do not edit.
55
+ */
56
+
57
+ export { AnarchitectsAuthJwtRefreshTokensForm };
58
+ //# sourceMappingURL=anarchitects-auth-angular-ui-jwt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anarchitects-auth-angular-ui-jwt.mjs","sources":["../../../../../libs/auth/angular/ui/jwt/src/internal/refresh-tokens-form-bridge.ts","../../../../../libs/auth/angular/ui/jwt/src/components/refresh-tokens-form/refresh-tokens-form.ts","../../../../../libs/auth/angular/ui/jwt/src/components/refresh-tokens-form/refresh-tokens-form.html","../../../../../libs/auth/angular/ui/jwt/src/anarchitects-auth-angular-ui-jwt.ts"],"sourcesContent":["import { RefreshTokenRequestDTO } from '@anarchitects/auth-ts/dtos/jwt';\nimport { SubmissionRequestDTO } from '@anarchitects/forms-ts/dtos';\nimport { FormConfig } from '@anarchitects/forms-ts/models';\n\ntype RefreshTokensFormBridge = {\n resolveFormConfig(): FormConfig;\n mapSubmission(input: SubmissionRequestDTO): RefreshTokenRequestDTO | undefined;\n};\n\nconst REFRESH_TOKENS_FORM_CONFIG: FormConfig = {\n id: 'refresh-tokens',\n version: 1,\n fields: [\n {\n name: 'refreshToken',\n kind: 'string',\n required: false,\n minLength: 1,\n ui: { label: 'Refresh Token' },\n },\n ],\n};\n\nconst readPayloadString = (\n input: SubmissionRequestDTO,\n key: string,\n): string | undefined => input.payload[key] as string | undefined;\n\nconst readStoredString = (key: string): string | undefined =>\n localStorage.getItem(key) || undefined;\n\nexport const refreshTokensFormBridge: RefreshTokensFormBridge = {\n resolveFormConfig: () => REFRESH_TOKENS_FORM_CONFIG,\n mapSubmission: (input) => {\n const refreshToken =\n readPayloadString(input, 'refreshToken') || readStoredString('refreshToken');\n\n if (!refreshToken) {\n return undefined;\n }\n\n return { refreshToken };\n },\n};\n","import type { AnxLayoutId } from '@anarchitects/common-angular-ui-layouts/contracts';\nimport { RefreshTokenRequestDTO } from '@anarchitects/auth-ts/dtos/jwt';\nimport { AnarchitectsUiForm } from '@anarchitects/forms-angular/ui';\nimport { SubmissionRequestDTO } from '@anarchitects/forms-ts/dtos';\nimport {\n ChangeDetectionStrategy,\n Component,\n computed,\n input,\n output,\n} from '@angular/core';\nimport { refreshTokensFormBridge } from '../../internal/refresh-tokens-form-bridge';\n\n@Component({\n selector: 'anarchitects-auth-jwt-refresh-tokens-form',\n imports: [AnarchitectsUiForm],\n templateUrl: './refresh-tokens-form.html',\n styleUrl: './refresh-tokens-form.css',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'anx-domain-component anx-auth-jwt-refresh-tokens-form anx-stack',\n 'attr.data-anx-component': '\"auth-jwt-refresh-tokens-form\"',\n },\n})\nexport class AnarchitectsAuthJwtRefreshTokensForm {\n readonly layout = input<AnxLayoutId | null>(null);\n readonly layoutOptions = input<Readonly<Record<string, unknown>>>({});\n readonly submitted = output<RefreshTokenRequestDTO>();\n\n readonly formConfig = computed(() =>\n refreshTokensFormBridge.resolveFormConfig(),\n );\n\n onSubmitted(input: SubmissionRequestDTO): void {\n const dto = refreshTokensFormBridge.mapSubmission(input);\n if (dto) {\n this.submitted.emit(dto);\n }\n }\n}\n","<anarchitects-forms-ui-form\n [config]=\"formConfig()\"\n [layout]=\"layout()\"\n [layoutOptions]=\"layoutOptions()\"\n (submitted)=\"onSubmitted($event)\"\n>\n <ng-content select=\"ng-template[anxTemplate]\"></ng-content>\n <ng-content select=\"[anxSlot]\"></ng-content>\n</anarchitects-forms-ui-form>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AASA,MAAM,0BAA0B,GAAe;AAC7C,IAAA,EAAE,EAAE,gBAAgB;AACpB,IAAA,OAAO,EAAE,CAAC;AACV,IAAA,MAAM,EAAE;AACN,QAAA;AACE,YAAA,IAAI,EAAE,cAAc;AACpB,YAAA,IAAI,EAAE,QAAQ;AACd,YAAA,QAAQ,EAAE,KAAK;AACf,YAAA,SAAS,EAAE,CAAC;AACZ,YAAA,EAAE,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE;AAC/B,SAAA;AACF,KAAA;CACF;AAED,MAAM,iBAAiB,GAAG,CACxB,KAA2B,EAC3B,GAAW,KACY,KAAK,CAAC,OAAO,CAAC,GAAG,CAAuB;AAEjE,MAAM,gBAAgB,GAAG,CAAC,GAAW,KACnC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,SAAS;AAEjC,MAAM,uBAAuB,G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AAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,SAAA,EAAA,WAAA,EAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,yBAAA,EAAA,kCAAA,EAAA,EAAA,cAAA,EAAA,iEAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECxBjD,wTASA,EAAA,MAAA,EAAA,CAAA,wBAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EDMY,kBAAkB,EAAA,QAAA,EAAA,4BAAA,EAAA,MAAA,EAAA,CAAA,QAAA,EAAA,mBAAA,EAAA,QAAA,EAAA,eAAA,CAAA,EAAA,OAAA,EAAA,CAAA,WAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FASjB,oCAAoC,EAAA,UAAA,EAAA,CAAA;kBAXhD,SAAS;+BACE,2CAA2C,EAAA,OAAA,EAC5C,CAAC,kBAAkB,CAAC,mBAGZ,uBAAuB,CAAC,MAAM,EAAA,IAAA,EACzC;AACJ,wBAAA,KAAK,EAAE,iEAAiE;AACxE,wBAAA,yBAAyB,EAAE,gCAAgC;AAC5D,qBAAA,EAAA,QAAA,EAAA,wTAAA,EAAA,MAAA,EAAA,CAAA,wBAAA,CAAA,EAAA;;;AEtBH;;AAEG;;;;"}
@@ -3,7 +3,6 @@ import * as i0 from '@angular/core';
3
3
  import { input, output, computed, ChangeDetectionStrategy, Component } from '@angular/core';
4
4
 
5
5
  const readPayloadString = (input, key) => input.payload[key];
6
- const readStoredString = (key) => localStorage.getItem(key) || undefined;
7
6
  const matchFieldsRule = (sourceField, targetField) => ({
8
7
  kind: 'matchFields',
9
8
  sourceField,
@@ -36,9 +35,9 @@ const REGISTER_FORM_CONFIG = {
36
35
  version: 1,
37
36
  fields: [
38
37
  {
39
- name: 'userName',
38
+ name: 'name',
40
39
  kind: 'string',
41
- ui: { label: 'Username' },
40
+ ui: { label: 'Name' },
42
41
  required: false,
43
42
  },
44
43
  { name: 'email', kind: 'email', ui: { label: 'Email' }, required: true },
@@ -119,35 +118,7 @@ const UPDATE_EMAIL_FORM_CONFIG = {
119
118
  const LOGOUT_FORM_CONFIG = {
120
119
  id: 'logout',
121
120
  version: 1,
122
- fields: [
123
- {
124
- name: 'refreshToken',
125
- kind: 'string',
126
- required: false,
127
- minLength: 1,
128
- ui: { label: 'Refresh Token' },
129
- },
130
- {
131
- name: 'accessToken',
132
- kind: 'string',
133
- required: false,
134
- minLength: 1,
135
- ui: { label: 'Access Token (optional)' },
136
- },
137
- ],
138
- };
139
- const REFRESH_TOKENS_FORM_CONFIG = {
140
- id: 'refresh-tokens',
141
- version: 1,
142
- fields: [
143
- {
144
- name: 'refreshToken',
145
- kind: 'string',
146
- required: false,
147
- minLength: 1,
148
- ui: { label: 'Refresh Token' },
149
- },
150
- ],
121
+ fields: [],
151
122
  };
152
123
  const resolveToken = (input, fallbackToken) => readPayloadString(input, 'token') || fallbackToken;
153
124
  const loginFormBridge = {
@@ -160,7 +131,7 @@ const loginFormBridge = {
160
131
  const registerFormBridge = {
161
132
  resolveFormConfig: () => REGISTER_FORM_CONFIG,
162
133
  mapSubmission: (input) => ({
163
- userName: readPayloadString(input, 'userName'),
134
+ name: readPayloadString(input, 'name'),
164
135
  email: readPayloadString(input, 'email'),
165
136
  password: readPayloadString(input, 'password'),
166
137
  confirmPassword: readPayloadString(input, 'confirmPassword'),
@@ -274,27 +245,7 @@ const updateEmailFormBridge = {
274
245
  };
275
246
  const logoutFormBridge = {
276
247
  resolveFormConfig: () => LOGOUT_FORM_CONFIG,
277
- mapSubmission: (input) => {
278
- const refreshToken = readPayloadString(input, 'refreshToken') || readStoredString('refreshToken');
279
- const accessToken = readPayloadString(input, 'accessToken') || readStoredString('accessToken');
280
- if (!refreshToken) {
281
- return undefined;
282
- }
283
- return {
284
- refreshToken,
285
- ...(accessToken ? { accessToken } : {}),
286
- };
287
- },
288
- };
289
- const refreshTokensFormBridge = {
290
- resolveFormConfig: () => REFRESH_TOKENS_FORM_CONFIG,
291
- mapSubmission: (input) => {
292
- const refreshToken = readPayloadString(input, 'refreshToken') || readStoredString('refreshToken');
293
- if (!refreshToken) {
294
- return undefined;
295
- }
296
- return { refreshToken };
297
- },
248
+ mapSubmission: () => ({}),
298
249
  };
299
250
 
300
251
  class AnarchitectsAuthUiLoginForm {
@@ -504,31 +455,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
504
455
  }, template: "<anarchitects-forms-ui-form\n [config]=\"formConfig()\"\n [layout]=\"layout()\"\n [layoutOptions]=\"layoutOptions()\"\n (submitted)=\"onSubmitted($event)\"\n>\n <ng-content select=\"ng-template[anxTemplate]\"></ng-content>\n <ng-content select=\"[anxSlot]\"></ng-content>\n</anarchitects-forms-ui-form>\n", styles: [":host{display:block}\n"] }]
505
456
  }], propDecorators: { layout: [{ type: i0.Input, args: [{ isSignal: true, alias: "layout", required: false }] }], layoutOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "layoutOptions", required: false }] }], submitted: [{ type: i0.Output, args: ["submitted"] }] } });
506
457
 
507
- class AnarchitectsAuthUiRefreshTokensForm {
508
- layout = input(null, ...(ngDevMode ? [{ debugName: "layout" }] : []));
509
- layoutOptions = input({}, ...(ngDevMode ? [{ debugName: "layoutOptions" }] : []));
510
- submitted = output();
511
- formConfig = computed(() => refreshTokensFormBridge.resolveFormConfig(), ...(ngDevMode ? [{ debugName: "formConfig" }] : []));
512
- onSubmitted(input) {
513
- const dto = refreshTokensFormBridge.mapSubmission(input);
514
- if (dto) {
515
- this.submitted.emit(dto);
516
- }
517
- }
518
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: AnarchitectsAuthUiRefreshTokensForm, deps: [], target: i0.ɵɵFactoryTarget.Component });
519
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.1.6", type: AnarchitectsAuthUiRefreshTokensForm, isStandalone: true, selector: "anarchitects-auth-ui-refresh-tokens-form", inputs: { layout: { classPropertyName: "layout", publicName: "layout", isSignal: true, isRequired: false, transformFunction: null }, layoutOptions: { classPropertyName: "layoutOptions", publicName: "layoutOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { submitted: "submitted" }, host: { attributes: { "attr.data-anx-component": "\"auth-ui-refresh-tokens-form\"" }, classAttribute: "anx-domain-component anx-auth-ui-refresh-tokens-form anx-stack" }, ngImport: i0, template: "<anarchitects-forms-ui-form\n [config]=\"formConfig()\"\n [layout]=\"layout()\"\n [layoutOptions]=\"layoutOptions()\"\n (submitted)=\"onSubmitted($event)\"\n>\n <ng-content select=\"ng-template[anxTemplate]\"></ng-content>\n <ng-content select=\"[anxSlot]\"></ng-content>\n</anarchitects-forms-ui-form>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "component", type: AnarchitectsUiForm, selector: "anarchitects-forms-ui-form", inputs: ["config", "runtimeValidators", "layout", "layoutOptions"], outputs: ["submitted"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
520
- }
521
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: AnarchitectsAuthUiRefreshTokensForm, decorators: [{
522
- type: Component,
523
- args: [{ selector: 'anarchitects-auth-ui-refresh-tokens-form', imports: [AnarchitectsUiForm], changeDetection: ChangeDetectionStrategy.OnPush, host: {
524
- class: 'anx-domain-component anx-auth-ui-refresh-tokens-form anx-stack',
525
- 'attr.data-anx-component': '"auth-ui-refresh-tokens-form"',
526
- }, template: "<anarchitects-forms-ui-form\n [config]=\"formConfig()\"\n [layout]=\"layout()\"\n [layoutOptions]=\"layoutOptions()\"\n (submitted)=\"onSubmitted($event)\"\n>\n <ng-content select=\"ng-template[anxTemplate]\"></ng-content>\n <ng-content select=\"[anxSlot]\"></ng-content>\n</anarchitects-forms-ui-form>\n", styles: [":host{display:block}\n"] }]
527
- }], propDecorators: { layout: [{ type: i0.Input, args: [{ isSignal: true, alias: "layout", required: false }] }], layoutOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "layoutOptions", required: false }] }], submitted: [{ type: i0.Output, args: ["submitted"] }] } });
528
-
529
458
  /**
530
459
  * Generated bundle index. Do not edit.
531
460
  */
532
461
 
533
- export { AnarchitectsAuthUiActivateUserForm, AnarchitectsAuthUiChangePasswordForm, AnarchitectsAuthUiForgotPasswordForm, AnarchitectsAuthUiLoginForm, AnarchitectsAuthUiLogoutForm, AnarchitectsAuthUiRefreshTokensForm, AnarchitectsAuthUiRegisterForm, AnarchitectsAuthUiResetPasswordForm, AnarchitectsAuthUiUpdateEmailForm, AnarchitectsAuthUiVerifyEmailForm };
462
+ export { AnarchitectsAuthUiActivateUserForm, AnarchitectsAuthUiChangePasswordForm, AnarchitectsAuthUiForgotPasswordForm, AnarchitectsAuthUiLoginForm, AnarchitectsAuthUiLogoutForm, AnarchitectsAuthUiRegisterForm, AnarchitectsAuthUiResetPasswordForm, AnarchitectsAuthUiUpdateEmailForm, AnarchitectsAuthUiVerifyEmailForm };
534
463
  //# sourceMappingURL=anarchitects-auth-angular-ui.mjs.map