From 228228a89047b7c1b15779da2457dabd1f758c31 Mon Sep 17 00:00:00 2001 From: Tim Fabian Date: Fri, 20 Nov 2026 21:20:20 +0100 Subject: [PATCH] added auth invitations --- README.md | 2 +- package-lock.json | 8 +- package.json | 2 +- projects/ngx-auth/README.md | 20 +- .../accept-invitation-action-view.model.ts | 37 +++ .../accept-invitation-config-changes.model.ts | 12 + .../accept-invitation-config.model.ts | 84 ++++++ .../accept-invitation-config.provider.ts | 51 ++++ .../accept-invitation-password.component.html | 16 ++ .../accept-invitation-password.component.ts | 49 ++++ .../accept-invitation-state.type.ts | 7 + .../accept-invitation.component.html | 33 +++ .../accept-invitation.component.spec.ts | 175 ++++++++++++ .../accept-invitation.component.ts | 264 ++++++++++++++++++ .../accept-invitation.stories.ts | 104 +++++++ .../accept-invitation/ng-package.json | 5 + .../ngx-auth/accept-invitation/public-api.ts | 5 + .../ngx-auth/auth/auth-config.provider.ts | 5 +- projects/ngx-auth/auth/auth-paths.model.ts | 15 +- projects/ngx-auth/auth/auth.service.ts | 50 +++- projects/ngx-auth/package.json | 6 +- projects/ngx-change-sets/package.json | 4 +- projects/ngx-ecommerce/package.json | 4 +- projects/ngx-entity/package.json | 8 +- projects/ngx-error-handling/package.json | 4 +- projects/ngx-navigation/package.json | 4 +- projects/ngx-persistence-logger/package.json | 4 +- projects/ngx-pwa/package.json | 4 +- projects/ngx-tracking/package.json | 4 +- projects/ui/package.json | 2 +- 30 files changed, 956 insertions(+), 32 deletions(-) create mode 100644 projects/ngx-auth/accept-invitation/accept-invitation-action-view.model.ts create mode 100644 projects/ngx-auth/accept-invitation/accept-invitation-config-changes.model.ts create mode 100644 projects/ngx-auth/accept-invitation/accept-invitation-config.model.ts create mode 100644 projects/ngx-auth/accept-invitation/accept-invitation-config.provider.ts create mode 100644 projects/ngx-auth/accept-invitation/accept-invitation-password.component.html create mode 100644 projects/ngx-auth/accept-invitation/accept-invitation-password.component.ts create mode 100644 projects/ngx-auth/accept-invitation/accept-invitation-state.type.ts create mode 100644 projects/ngx-auth/accept-invitation/accept-invitation.component.html create mode 100644 projects/ngx-auth/accept-invitation/accept-invitation.component.spec.ts create mode 100644 projects/ngx-auth/accept-invitation/accept-invitation.component.ts create mode 100644 projects/ngx-auth/accept-invitation/accept-invitation.stories.ts create mode 100644 projects/ngx-auth/accept-invitation/ng-package.json create mode 100644 projects/ngx-auth/accept-invitation/public-api.ts diff --git a/README.md b/README.md index d8501b0..0a03aaa 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Each package documents itself in its README, which is also its page on npm. | Package | Does | |---|---| | [@service-soft/ui](./projects/ui/README.md) | The design system every other library builds on: the design tokens, theming, dark mode and the basic components, like buttons, inputs, dialogs and menus | -| [@service-soft/ngx-auth](./projects/ngx-auth/README.md) | Logs in at the auth routes of zibri with tokens or cookies, a second factor and password resets, protects routes by login and permission in a tenant, and has the pages for the login and passwords | +| [@service-soft/ngx-auth](./projects/ngx-auth/README.md) | Logs in at the auth routes of zibri with tokens or cookies, a second factor and password resets, protects routes by login and permission in a tenant, answers invitations, and has the pages for the login, passwords and invitations | | [@service-soft/ngx-change-sets](./projects/ngx-change-sets/README.md) | Shows the change sets of an entity as its history, like the ones zibri keeps, and lets the user undo them | | [@service-soft/ngx-ecommerce](./projects/ngx-ecommerce/README.md) | Lets the user add extras to a booking or order, like breakfast per day or a second bike, and sums up an order with its discounts, taxes and total, in the currency and language of the app | | [@service-soft/ngx-entity](./projects/ngx-entity/README.md) | Describes the entities of an app with decorators like zibri's and builds their forms from them, on a grid of 12 columns with rows and tabs, reads and writes them at the routes of zibri, and shows them in tables a page at a time, with the filters and orders the server allows, which create, edit and delete them in dialogs or on pages of their own, asking before changes are lost, and offline with ngx-pwa if you like | diff --git a/package-lock.json b/package-lock.json index 3144342..3a02545 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,7 +46,7 @@ "typescript": "~6.0.2", "uqr": "^0.1.3", "vitest": "^5.0.0", - "zibri-contract": "^3.1.0" + "zibri-contract": "^3.2.0" } }, "node_modules/@adobe/css-tools": { @@ -24400,9 +24400,9 @@ } }, "node_modules/zibri-contract": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/zibri-contract/-/zibri-contract-3.1.0.tgz", - "integrity": "sha512-+VxFw3y9Sk5C5G0X6GkRN2AzQOV5TitPYOEkqQuQEiqmB3/4zMpmYmp/Qiqn8btdHmp/ACgwDldDqJIaJnxAeA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/zibri-contract/-/zibri-contract-3.2.0.tgz", + "integrity": "sha512-ALk3+1oMUysq6pfhu0SLjYYGFsrV5SpuXUeXGoEjV9Vit0m6Byfee6GtMl04B4KK1B5uM6ETE6+FnkE6VQbgfg==", "dev": true, "license": "MIT" }, diff --git a/package.json b/package.json index 9f13d32..a52cce2 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,6 @@ "typescript": "~6.0.2", "uqr": "^0.1.3", "vitest": "^5.0.0", - "zibri-contract": "^3.1.0" + "zibri-contract": "^3.2.0" } } \ No newline at end of file diff --git a/projects/ngx-auth/README.md b/projects/ngx-auth/README.md index 8b6a691..6f8a31d 100644 --- a/projects/ngx-auth/README.md +++ b/projects/ngx-auth/README.md @@ -19,12 +19,13 @@ Everything works with server-side rendering: on the server nobody is logged in, - [Providers](#providers) - [Sessions and email](#sessions-and-email) - [Passwords](#passwords) +- [Invitations](#invitations) - [The pages](#the-pages) - [Moving from ngx-material-auth](#moving-from-ngx-material-auth) - [License](#license) # Requirements -Angular 22 with the router, and a backend with the `AuthController` of zibri 3.1 or later. What the routes answer and take, like `CurrentUserProfile`, `UserLogin` and `OtpRegistration`, comes from [zibri-contract](https://www.npmjs.com/package/zibri-contract), the package zibri declares it in. +Angular 22 with the router, and a backend with the `AuthController` of zibri 3.1 or later, 3.2 with `invitationRoutes: true` for [invitations](#invitations). What the routes answer and take, like `CurrentUserProfile`, `UserLogin` and `OtpRegistration`, comes from [zibri-contract](https://www.npmjs.com/package/zibri-contract), the package zibri declares it in. ```sh npm install @service-soft/ngx-auth zibri-contract @@ -239,6 +240,17 @@ The links of these emails open `ConfirmEmailComponent` of `@service-soft/ngx-aut # Passwords `requestPasswordReset(email)` mails a link, `verifyPasswordResetToken(token)` says whether its token still works, and `confirmPasswordReset(token, newPassword)` sets the new password. `changePassword(currentPassword, newPassword)` changes the password of the logged in user. +# Invitations +With `invitationRoutes: true` of the `AuthController` of zibri 3.2, zibri mails invitations to an app or to a tenant, whose link is answered here: + +| Method | Does | +|---|---| +| `verifyInvitationToken(token)` | Answers an `InvitationTokenValidity`: whether the link works, whether a new one was mailed for one that ran out, and for a link that works the invited email, its tenant, whether accepting needs a login (`requiresLogin`) and whether it may be declined (`declinable`) | +| `acceptInvitation(token, password?)` | Accepts with the password of the account the invitation creates, or, without one, as the logged in account of the invited email | +| `declineInvitation(token)` | Declines it, which needs no login | + +zibri finds an invitation by its token in every tenant, so the requests name none, and a link zibri refuses ends no login. The [`AcceptInvitationComponent`](#the-pages) does all of it. + # The pages Ready pages for these, built on [@service-soft/ui](https://www.npmjs.com/package/@service-soft/ui), each in its own entry point, so an app only loads the ones it uses: @@ -252,6 +264,11 @@ const routes: Routes = [ { path: 'reset-password/:token', loadComponent: () => import('@service-soft/ngx-auth/confirm-password-reset').then(m => m.ConfirmPasswordResetComponent) + }, + // no guard: accepting works logged out and logged in + { + path: 'accept-invitation/:token', + loadComponent: () => import('@service-soft/ngx-auth/accept-invitation').then(m => m.AcceptInvitationComponent) } ]; ``` @@ -262,6 +279,7 @@ const routes: Routes = [ | `RequestPasswordResetComponent` | Has zibri mail a link to reset the password | | `ConfirmPasswordResetComponent` | The page of that link: zibri adds the token to its `CONFIRM_PASSWORD_RESET_URL` as the last segment, so set that to the url of this route, like `https://app.example.com/reset-password`. Checks the link in the browser, and offers a new one when it doesn't work anymore | | `ChangePasswordComponent` | The current and a new password, for the page of the user's account, with a `h2` heading | +| `AcceptInvitationComponent` | The page of the link of an [invitation](#invitations): zibri adds the token to the `acceptInvitationUrl` of its `INVITATION_OPTIONS` as the last segment, so set that to the url of this route, like `https://app.example.com/accept-invitation`. Checks the link in the browser, and says when it doesn't work, and when a new one was mailed. An invitation that creates its account asks for its password, then links to the login. One to an email with an account links to the login while nobody is logged in, and back here once they are; offers logging out to another account; and accepts with one button as that account, which then acts in the tenant of the invitation. A decline button shows next to accepting when the invitation may be declined | A refused attempt shows the message of zibri, in the language of the request, and keeps what the user typed. Each page has a `provideXConfig`, like `provideLoginConfig`, for its texts and options. Values you leave out keep their defaults, so a translation can change single labels: diff --git a/projects/ngx-auth/accept-invitation/accept-invitation-action-view.model.ts b/projects/ngx-auth/accept-invitation/accept-invitation-action-view.model.ts new file mode 100644 index 0000000..aa23315 --- /dev/null +++ b/projects/ngx-auth/accept-invitation/accept-invitation-action-view.model.ts @@ -0,0 +1,37 @@ +import { ButtonVariant } from '@service-soft/ui/button'; + +/** + * A link or a button of the page of an invitation, ready to render. + */ +export type AcceptInvitationActionView = { + /** + * The text of the link or the button. + */ + label: string, + /** + * How it looks. + */ + variant: ButtonVariant +} & ({ + /** + * Says that it is a link. + */ + kind: 'link', + /** + * Where it goes. + */ + route: string, + /** + * The query of the route, like the returnUrl of the login. + */ + queryParams?: Record +} | { + /** + * Says that it is a button. + */ + kind: 'button', + /** + * What it does. + */ + run: () => Promise +}); \ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/accept-invitation-config-changes.model.ts b/projects/ngx-auth/accept-invitation/accept-invitation-config-changes.model.ts new file mode 100644 index 0000000..035f6c7 --- /dev/null +++ b/projects/ngx-auth/accept-invitation/accept-invitation-config-changes.model.ts @@ -0,0 +1,12 @@ +import { AcceptInvitationConfig, AcceptInvitationLabels } from './accept-invitation-config.model'; + +/** + * The values to change in the config of the page the link of an invitation opens. Everything is optional, including + * every single label. + */ +export type AcceptInvitationConfigChanges = Partial> & { + /** + * The labels to change. + */ + labels?: Partial +}; \ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/accept-invitation-config.model.ts b/projects/ngx-auth/accept-invitation/accept-invitation-config.model.ts new file mode 100644 index 0000000..c3a5cc7 --- /dev/null +++ b/projects/ngx-auth/accept-invitation/accept-invitation-config.model.ts @@ -0,0 +1,84 @@ +/** + * The texts of the page the link of an invitation opens. + */ +export type AcceptInvitationLabels = { + /** + * The heading of the page. + */ + title: string, + /** + * Shown before the invited email. + */ + invitedAs: string, + /** + * Shown when the link doesn't work, like when it was used, revoked or ran out. + */ + invalid: string, + /** + * Shown when the link ran out and zibri mailed a new one to the invited email. + */ + renewed: string, + /** + * The label of the input of the password of the account the invitation creates. + */ + password: string, + /** + * The button that accepts the invitation. + */ + accept: string, + /** + * The button that declines the invitation. + */ + decline: string, + /** + * Shown when accepting needs a login as the invited account, while nobody is logged in. + */ + loginRequired: string, + /** + * Shown while somebody else than the invited email is logged in. + */ + otherAccount: string, + /** + * The link to the login. + */ + login: string, + /** + * The button that logs out of another account. + */ + logout: string, + /** + * Shown once the invitation was accepted by a logged in account. + */ + accepted: string, + /** + * Shown once the invitation was accepted with the password of the account it created. + */ + acceptedWithPassword: string, + /** + * The link on into the app once the invitation was accepted by a logged in account. + */ + continue: string, + /** + * Shown once the invitation was declined. + */ + declined: string, + /** + * Shown when a request failed without a message of zibri, like without a connection. + */ + failed: string +}; + +/** + * How the page the link of an invitation opens looks and works. + */ +export type AcceptInvitationConfig = { + /** + * The texts of the page. + */ + labels: AcceptInvitationLabels, + /** + * The least number of characters of the password of the account an invitation creates, the minLength of the + * password policy of zibri. Without it, zibri says what is too short. + */ + newPasswordMinLength: number | undefined +}; \ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/accept-invitation-config.provider.ts b/projects/ngx-auth/accept-invitation/accept-invitation-config.provider.ts new file mode 100644 index 0000000..4e8e86a --- /dev/null +++ b/projects/ngx-auth/accept-invitation/accept-invitation-config.provider.ts @@ -0,0 +1,51 @@ +import { inject, InjectionToken, Provider } from '@angular/core'; + +import { AcceptInvitationConfigChanges } from './accept-invitation-config-changes.model'; +import { AcceptInvitationConfig } from './accept-invitation-config.model'; + +const DEFAULT_ACCEPT_INVITATION_CONFIG: AcceptInvitationConfig = { + labels: { + title: 'Invitation', + invitedAs: 'You are invited as', + invalid: 'This link doesn\'t work. It ran out, or was used or revoked already.', + renewed: 'This link ran out. A new one was mailed to the invited address.', + password: 'Password', + accept: 'Accept invitation', + decline: 'Decline', + loginRequired: 'Log in as the invited account to accept the invitation.', + otherAccount: 'You are logged in with another account. Log out, and log in as the invited one to accept the invitation.', + login: 'Log in', + logout: 'Log out', + accepted: 'The invitation was accepted.', + acceptedWithPassword: 'Your account is ready. Log in with your password.', + continue: 'Continue', + declined: 'The invitation was declined.', + failed: 'Something went wrong. Please try again.' + }, + newPasswordMinLength: undefined +}; + +/** + * How the page the link of an invitation opens looks and works. Change it with provideAcceptInvitationConfig. + */ +export const ACCEPT_INVITATION_CONFIG: InjectionToken = new InjectionToken( + 'ACCEPT_INVITATION_CONFIG', + { providedIn: 'root', factory: () => DEFAULT_ACCEPT_INVITATION_CONFIG } +); + +/** + * Changes how the page the link of an invitation opens looks and works, like its texts to translate them. Values you + * leave out keep the ones of the parent injector, including single labels. + * @param config - The values to change. + * @returns The provider for ACCEPT_INVITATION_CONFIG. + */ +export function provideAcceptInvitationConfig(config: AcceptInvitationConfigChanges): Provider { + return { + provide: ACCEPT_INVITATION_CONFIG, + useFactory: (): AcceptInvitationConfig => { + const parent: AcceptInvitationConfig = inject(ACCEPT_INVITATION_CONFIG, { skipSelf: true, optional: true }) + ?? DEFAULT_ACCEPT_INVITATION_CONFIG; + return { ...parent, ...config, labels: { ...parent.labels, ...config.labels } }; + } + }; +} \ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/accept-invitation-password.component.html b/projects/ngx-auth/accept-invitation/accept-invitation-password.component.html new file mode 100644 index 0000000..5fa02a2 --- /dev/null +++ b/projects/ngx-auth/accept-invitation/accept-invitation-password.component.html @@ -0,0 +1,16 @@ + + +
+ + @if (declinable()) { + + } +
+
\ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/accept-invitation-password.component.ts b/projects/ngx-auth/accept-invitation/accept-invitation-password.component.ts new file mode 100644 index 0000000..bc3c33f --- /dev/null +++ b/projects/ngx-auth/accept-invitation/accept-invitation-password.component.ts @@ -0,0 +1,49 @@ +import { Component, input, InputSignal, output, OutputEmitterRef, signal, WritableSignal } from '@angular/core'; +import { ButtonComponent } from '@service-soft/ui/button'; +import { FormComponent } from '@service-soft/ui/form'; +import { InputStringComponent } from '@service-soft/ui/input-string'; + +import { AcceptInvitationLabels } from './accept-invitation-config.model'; + +/** + * The form of the page of an invitation that creates its account, which asks for its password. + */ +@Component({ + selector: 'ngx-accept-invitation-password', + templateUrl: './accept-invitation-password.component.html', + imports: [FormComponent, InputStringComponent, ButtonComponent], + host: { + class: 'block' + } +}) +export class AcceptInvitationPasswordComponent { + /** + * The texts of the page. + */ + readonly labels: InputSignal = input.required(); + + /** + * The least number of characters of the password, or undefined to leave it to zibri. + */ + readonly minLength: InputSignal = input.required(); + + /** + * Whether the invitation may be declined, which a button next to accepting does. + */ + readonly declinable: InputSignal = input.required(); + + /** + * Emits the password once the user accepts with it. + */ + readonly accepted: OutputEmitterRef = output(); + + /** + * Emits once the user declines. + */ + readonly declined: OutputEmitterRef = output(); + + /** + * The password the user typed. + */ + protected readonly password: WritableSignal = signal(''); +} \ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/accept-invitation-state.type.ts b/projects/ngx-auth/accept-invitation/accept-invitation-state.type.ts new file mode 100644 index 0000000..808a145 --- /dev/null +++ b/projects/ngx-auth/accept-invitation/accept-invitation-state.type.ts @@ -0,0 +1,7 @@ +/** + * Where the page of an invitation stands: checking the link, refusing a link that doesn't work, asking for the + * password of the account it creates, asking to log in or to log out of another account, offering to accept, or + * done. + */ +export type AcceptInvitationState + = 'verifying' | 'invalid' | 'password' | 'loginRequired' | 'otherAccount' | 'accept' | 'accepted' | 'declined'; \ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/accept-invitation.component.html b/projects/ngx-auth/accept-invitation/accept-invitation.component.html new file mode 100644 index 0000000..a01c236 --- /dev/null +++ b/projects/ngx-auth/accept-invitation/accept-invitation.component.html @@ -0,0 +1,33 @@ + +

{{ labels.title }}

+@for (paragraph of paragraphs(); track $index) { +

{{ paragraph }}

+} +@if (state() === 'password') { + +} +
+ @for (action of actions(); track action.label) { + @if (action.kind === 'link') { + {{ action.label }} + } + @else { + + } + } +
+ + +

{{ status() }}

\ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/accept-invitation.component.spec.ts b/projects/ngx-auth/accept-invitation/accept-invitation.component.spec.ts new file mode 100644 index 0000000..9b82301 --- /dev/null +++ b/projects/ngx-auth/accept-invitation/accept-invitation.component.spec.ts @@ -0,0 +1,175 @@ +import { provideHttpClient, withInterceptors } from '@angular/common/http'; +import { HttpTestingController, provideHttpClientTesting, TestRequest } from '@angular/common/http/testing'; +import { Component, Service } from '@angular/core'; +import { TestBed } from '@angular/core/testing'; +import { provideRouter, Router } from '@angular/router'; +import { RouterTestingHarness } from '@angular/router/testing'; +import { AuthData, authInterceptor, AuthService, provideAuth } from '@service-soft/ngx-auth/auth'; +import { FormTestingUtilities } from 'testing/form'; +import { afterEach, describe, expect, test, vi } from 'vitest'; +import { CurrentUserProfile, InvitationTokenValidity } from 'zibri-contract'; + +import { AcceptInvitationComponent } from './accept-invitation.component'; + +const API: string = 'https://api.example.com/auth'; +const HOUR: number = 3_600_000; + +@Service() +class AppAuthService extends AuthService {} + +@Component({ selector: 'ngx-page', template: '' }) +class PageComponent {} + +// a link of an invitation that works, to tenant-b. +const VALID: InvitationTokenValidity = { isValid: true, renewed: false, email: 'ada@example.com', tenantId: 'tenant-b', requiresLogin: true, declinable: true }; + +const ADA: CurrentUserProfile = { id: 'user-1', email: 'Ada@example.com', memberships: [{ tenantId: 'tenant-a', permissions: [] }], platformPermissions: [] }; + +// a jwt login of another visit, which the AuthService finds in the browser. +function storeLogin(user: CurrentUserProfile): void { + const expirationDate: string = new Date(Date.now() + HOUR).toISOString(); + const login: AuthData = { + strategy: 'jwt', + userId: user.id, + roles: ['user'], + expiresAt: expirationDate, + user, + activeTenantId: 'tenant-a', + accessToken: { value: 'access-1', expirationDate }, + refreshToken: { value: 'refresh-1', expirationDate } + }; + localStorage.setItem('authData', JSON.stringify(login)); +} + +// opens the link of the email, which zibri ends with the token. +async function open(validity: InvitationTokenValidity): Promise<[HTMLElement, RouterTestingHarness, HttpTestingController]> { + TestBed.configureTestingModule({ + providers: [ + provideRouter([ + { path: 'accept-invitation/:token', component: AcceptInvitationComponent }, + { path: '**', component: PageComponent } + ]), + provideHttpClient(withInterceptors([authInterceptor])), + provideHttpClientTesting(), + provideAuth(AppAuthService, { apiUrl: API, strategy: 'jwt' }) + ] + }); + const harness: RouterTestingHarness = await RouterTestingHarness.create('/accept-invitation/invitation-1'); + const backend: HttpTestingController = TestBed.inject(HttpTestingController); + const verify: TestRequest = await expectRequest(backend, 'verify-invitation-token'); + expect(verify.request.body).toEqual({ token: 'invitation-1' }); + // zibri finds the invitation in every tenant, so the link names none, and needs no login + expect(verify.request.headers.has('x-tenant-id')).toBe(false); + expect(verify.request.headers.has('Authorization')).toBe(false); + verify.flush(validity); + await harness.fixture.whenStable(); + return [harness.fixture.nativeElement as HTMLElement, harness, backend]; +} + +async function expectRequest(backend: HttpTestingController, path: string): Promise { + return await vi.waitFor(() => backend.expectOne({ method: 'POST', url: `${API}/${path}` })); +} + +describe('AcceptInvitationComponent', () => { + afterEach(() => { + localStorage.clear(); + TestBed.inject(HttpTestingController).verify(); + }); + + test('accepts with the password of the account the invitation creates, and leads on to the login', async () => { + const [root, harness, backend] = await open({ ...VALID, requiresLogin: false }); + await vi.waitFor(() => expect(root.textContent).toContain('You are invited as ada@example.com')); + + await vi.waitFor(() => expect(FormTestingUtilities.findInput(root, 'password')).not.toBeNull()); + FormTestingUtilities.type(root, 'password', 'correct horse battery staple'); + await harness.fixture.whenStable(); + FormTestingUtilities.click(root, 'Accept invitation'); + const accept: TestRequest = await expectRequest(backend, 'accept-invitation'); + expect(accept.request.body).toEqual({ token: 'invitation-1', password: 'correct horse battery staple' }); + accept.flush('', { status: 204, statusText: 'No Content' }); + + await vi.waitFor(() => expect(FormTestingUtilities.getText(root, '[role="status"]')).toBe('Your account is ready. Log in with your password.')); + expect(FormTestingUtilities.findInput(root, 'password')).toBeNull(); + // the button the user pressed is gone, so the focus moves on to the login + await vi.waitFor(() => expect(document.activeElement?.getAttribute('href')).toBe('/login')); + }); + + test('says that a link doesn\'t work, and that a new one was mailed when it was renewed', async () => { + const [invalid] = await open({ isValid: false, renewed: false, requiresLogin: false, declinable: false }); + await vi.waitFor(() => expect(invalid.textContent).toContain('This link doesn\'t work.')); + expect(invalid.querySelector('button')).toBeNull(); + + TestBed.resetTestingModule(); + const [renewed] = await open({ isValid: false, renewed: true, requiresLogin: false, declinable: false }); + await vi.waitFor(() => expect(renewed.textContent).toContain('A new one was mailed to the invited address.')); + }); + + test('leads to the login and back while nobody is logged in, and declines without a login', async () => { + const [root, harness, backend] = await open(VALID); + + await vi.waitFor(() => expect(root.textContent).toContain('Log in as the invited account to accept the invitation.')); + const login: HTMLAnchorElement | null = root.querySelector('a'); + expect(decodeURIComponent(login?.getAttribute('href') ?? '')).toBe('/login?returnUrl=/accept-invitation/invitation-1'); + + FormTestingUtilities.click(root, 'Decline'); + const decline: TestRequest = await expectRequest(backend, 'decline-invitation'); + expect(decline.request.body).toEqual({ token: 'invitation-1' }); + decline.flush('', { status: 204, statusText: 'No Content' }); + await vi.waitFor(() => expect(FormTestingUtilities.getText(root, '[role="status"]')).toBe('The invitation was declined.')); + await harness.fixture.whenStable(); + // nothing to go on with, so the focus goes to the heading + await vi.waitFor(() => expect(document.activeElement?.tagName).toBe('H1')); + }); + + test('accepts with one button as the invited account, which then acts in the tenant of the invitation', async () => { + storeLogin(ADA); + const [root, harness, backend] = await open({ ...VALID, declinable: false }); + await vi.waitFor(() => expect(root.textContent).toContain('Accept invitation')); + expect(root.textContent).not.toContain('Decline'); + + FormTestingUtilities.click(root, 'Accept invitation'); + const accept: TestRequest = await expectRequest(backend, 'accept-invitation'); + expect(accept.request.body).toEqual({ token: 'invitation-1' }); + // with the login, but without the active tenant + expect(accept.request.headers.get('Authorization')).toBe('Bearer access-1'); + expect(accept.request.headers.has('x-tenant-id')).toBe(false); + accept.flush('', { status: 204, statusText: 'No Content' }); + const member: CurrentUserProfile = { ...ADA, memberships: [...ADA.memberships, { tenantId: 'tenant-b', permissions: ['invoices.read'] }] }; + (await vi.waitFor(() => backend.expectOne(`${API}/me`))).flush(member); + + await vi.waitFor(() => expect(FormTestingUtilities.getText(root, '[role="status"]')).toBe('The invitation was accepted.')); + const authService: AppAuthService = TestBed.inject(AppAuthService); + expect(authService.activeTenantId()).toBe('tenant-b'); + expect(authService.hasPermission('invoices.read')).toBe(true); + await harness.fixture.whenStable(); + await vi.waitFor(() => expect(document.activeElement?.getAttribute('href')).toBe('/')); + }); + + test('shows what zibri refused accepting for, and keeps the login', async () => { + storeLogin(ADA); + const [root, , backend] = await open(VALID); + + await vi.waitFor(() => expect(root.textContent).toContain('Accept invitation')); + FormTestingUtilities.click(root, 'Accept invitation'); + (await expectRequest(backend, 'accept-invitation')).flush( + { status: 401, name: 'UnauthorizedError', message: 'Link expired', paragraphs: ['Link expired'] }, + { status: 401, statusText: 'Unauthorized' } + ); + + await vi.waitFor(() => expect(FormTestingUtilities.getText(root, '[role="alert"]')).toBe('Link expired')); + expect(TestBed.inject(AppAuthService).loggedIn()).toBe(true); + }); + + test('offers logging out to an account of another email, and leads to the login and back', async () => { + storeLogin({ ...ADA, email: 'grace@example.com' }); + const [root, , backend] = await open(VALID); + await vi.waitFor(() => expect(root.textContent).toContain('You are logged in with another account.')); + expect(root.textContent).not.toContain('Accept invitation'); + + FormTestingUtilities.click(root, 'Log out'); + (await expectRequest(backend, 'logout?strategy=jwt')).flush({}); + + await vi.waitFor(() => expect(decodeURIComponent(TestBed.inject(Router).url)).toBe('/login?returnUrl=/accept-invitation/invitation-1')); + expect(TestBed.inject(AppAuthService).loggedIn()).toBe(false); + }); +}); \ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/accept-invitation.component.ts b/projects/ngx-auth/accept-invitation/accept-invitation.component.ts new file mode 100644 index 0000000..4ba1ec8 --- /dev/null +++ b/projects/ngx-auth/accept-invitation/accept-invitation.component.ts @@ -0,0 +1,264 @@ +import { afterNextRender, Component, computed, ElementRef, inject, Injector, Signal, signal, viewChild, viewChildren, WritableSignal } from '@angular/core'; +import { ActivatedRoute, Router, RouterLink } from '@angular/router'; +import { AUTH_CONFIG, AuthConfig, AuthErrorUtilities, AuthService } from '@service-soft/ngx-auth/auth'; +import { ButtonComponent } from '@service-soft/ui/button'; +import { InvitationTokenValidity } from 'zibri-contract'; + +import { AcceptInvitationActionView } from './accept-invitation-action-view.model'; +import { AcceptInvitationConfig, AcceptInvitationLabels } from './accept-invitation-config.model'; +import { ACCEPT_INVITATION_CONFIG } from './accept-invitation-config.provider'; +import { AcceptInvitationPasswordComponent } from './accept-invitation-password.component'; +import { AcceptInvitationState } from './accept-invitation-state.type'; + +/** + * The page the link of an invitation opens, which accepts or declines it. Zibri adds the token to the + * acceptInvitationUrl of its INVITATION_OPTIONS as the last segment, so its route reads it as the parameter token, + * without a guard, as accepting works logged out and logged in: + * `{ path: 'accept-invitation/:token', component: AcceptInvitationComponent }`. It checks the link once it shows in the + * browser. An invitation that creates its account asks for its password, and leads on to the login. One to an email + * with an account asks to log in as it, and accepts with one button, after which the user acts in the tenant of the + * invitation. Its texts come from provideAcceptInvitationConfig. + */ +@Component({ + selector: 'ngx-accept-invitation', + templateUrl: './accept-invitation.component.html', + imports: [AcceptInvitationPasswordComponent, ButtonComponent, RouterLink], + host: { + class: 'block' + } +}) +export class AcceptInvitationComponent { + private readonly authService: AuthService = inject(AuthService); + + private readonly router: Router = inject(Router); + + private readonly injector: Injector = inject(Injector); + + // the elements, not the button components on them + private readonly actionLinks: Signal[]> + = viewChildren('actionLink', { read: ElementRef }); + + private readonly heading: Signal> = viewChild.required>('heading'); + + private readonly token: string | null = inject(ActivatedRoute).snapshot.paramMap.get('token'); + + // the outcome of a request, once it was answered: until then the link decides where the page stands. + private readonly outcome: WritableSignal<'accepted' | 'declined' | undefined> = signal(undefined); + + // a second click while a request is on its way would spend the token twice. + private sending: boolean = false; + + /** + * How the page looks and works. + */ + protected readonly config: AcceptInvitationConfig = inject(ACCEPT_INVITATION_CONFIG); + + /** + * The texts of the page. + */ + protected readonly labels: AcceptInvitationLabels = this.config.labels; + + /** + * What zibri answered about the link, undefined until it did. + */ + protected readonly validity: WritableSignal = signal(undefined); + + /** + * Where the page stands. It follows the login, like a logout in another tab. + */ + protected readonly state: Signal = computed(() => { + const validity: InvitationTokenValidity | undefined = this.validity(); + const outcome: 'accepted' | 'declined' | undefined = this.outcome(); + if (outcome != undefined) { + return outcome; + } + if (validity == undefined) { + return 'verifying'; + } + if (!validity.isValid) { + return 'invalid'; + } + if (!validity.requiresLogin) { + return 'password'; + } + if (!this.authService.loggedIn()) { + return 'loginRequired'; + } + // while GET /me didn't answer, zibri tells whether the login is the one of the email + const email: string | undefined = this.authService.currentUser()?.email; + return email == undefined || email.toLowerCase() === validity.email?.toLowerCase() ? 'accept' : 'otherAccount'; + }); + + /** + * Whether the invitation may be declined. + */ + protected readonly declinable: Signal = computed(() => this.validity()?.declinable === true); + + /** + * What the page says: who is invited, and what stands in the way of accepting. + */ + protected readonly paragraphs: Signal = computed(() => { + const email: string | undefined = this.validity()?.email; + const invitedAs: string[] = email == undefined ? [] : [`${this.labels.invitedAs} ${email}`]; + const message: string | undefined = this.resolveMessage(this.state()); + return message == undefined ? invitedAs : [...invitedAs, message]; + }); + + /** + * The links and buttons of where the page stands. + */ + protected readonly actions: Signal = computed(() => this.resolveActions(this.state())); + + /** + * What zibri answered a refused request with, empty while nothing was refused. + */ + protected readonly errorParagraphs: WritableSignal = signal([]); + + /** + * What the last request did, which screen readers announce. + */ + protected readonly status: WritableSignal = signal(''); + + private readonly routes: AuthConfig['routes'] = inject(AUTH_CONFIG).routes; + + constructor() { + // only in the browser: a server render would check the token, and show a page the browser checks again + afterNextRender(() => void this.verify()); + } + + /** + * Accepts the invitation: with the password of the account it creates, or as the logged in account, which then + * acts in its tenant. + * @param password - The password, for an invitation whose validity requires no login. + */ + protected async accept(password?: string): Promise { + const validity: InvitationTokenValidity | undefined = this.validity(); + const token: string | null = this.token; + if (validity == undefined || token == undefined) { + return; + } + await this.send(async () => { + if (password != undefined) { + await this.authService.acceptInvitation(token, password); + return this.labels.acceptedWithPassword; + } + await this.authService.acceptInvitation(token); + // the new membership counts once GET /me answers it + await this.authService.reloadCurrentUser(); + if (validity.tenantId != undefined) { + this.authService.setActiveTenant(validity.tenantId); + } + return this.labels.accepted; + }, 'accepted'); + } + + /** + * Declines the invitation. + */ + protected async decline(): Promise { + const token: string | null = this.token; + if (token == undefined) { + return; + } + await this.send(async () => { + await this.authService.declineInvitation(token); + return this.labels.declined; + }, 'declined'); + } + + private resolveMessage(state: AcceptInvitationState): string | undefined { + switch (state) { + case 'invalid': { + return this.validity()?.renewed === true ? this.labels.renewed : this.labels.invalid; + } + case 'loginRequired': { + return this.labels.loginRequired; + } + case 'otherAccount': { + return this.labels.otherAccount; + } + case 'verifying': + case 'password': + case 'accept': + case 'accepted': + case 'declined': { + return undefined; + } + } + } + + private resolveActions(state: AcceptInvitationState): AcceptInvitationActionView[] { + const decline: AcceptInvitationActionView[] = this.declinable() + ? [{ kind: 'button', label: this.labels.decline, variant: 'outlined', run: async () => await this.decline() }] + : []; + switch (state) { + case 'loginRequired': { + // read once the link was checked: in the constructor, the router may not have the url of this page yet + const queryParams: Record = { returnUrl: this.router.url }; + return [{ kind: 'link', label: this.labels.login, variant: 'filled', route: this.routes.login, queryParams }, ...decline]; + } + case 'otherAccount': { + return [{ kind: 'button', label: this.labels.logout, variant: 'filled', run: async () => await this.logout() }]; + } + case 'accept': { + return [{ kind: 'button', label: this.labels.accept, variant: 'filled', run: async () => await this.accept() }, ...decline]; + } + case 'accepted': { + // an account with its new password logs in first, a logged in one goes on into the app + const next: AcceptInvitationActionView = this.validity()?.requiresLogin === false + ? { kind: 'link', label: this.labels.login, variant: 'filled', route: this.routes.login } + : { kind: 'link', label: this.labels.continue, variant: 'filled', route: this.routes.afterLogin }; + return [next]; + } + case 'verifying': + case 'invalid': + case 'password': + case 'declined': { + return []; + } + } + } + + // logs out of the other account, and leads on to the login, which comes back to this page. + private async logout(): Promise { + const returnUrl: string = this.router.url; + await this.authService.logout(); + // beforeLogout of the config may keep the user logged in + if (!this.authService.loggedIn()) { + await this.router.navigate([this.routes.login], { queryParams: { returnUrl } }); + } + } + + private async send(request: () => Promise, outcome: 'accepted' | 'declined'): Promise { + if (this.sending) { + return; + } + this.sending = true; + this.errorParagraphs.set([]); + try { + this.status.set(await request()); + this.outcome.set(outcome); + // the button the user pressed is gone, and the focus with it: to the link on, or to the heading + afterNextRender(() => (this.actionLinks().at(0) ?? this.heading()).nativeElement.focus(), { injector: this.injector }); + } + catch (error) { + this.errorParagraphs.set(AuthErrorUtilities.findErrorParagraphs(error) ?? [this.labels.failed]); + } + finally { + this.sending = false; + } + } + + private async verify(): Promise { + if (this.token == undefined) { + this.validity.set({ isValid: false, renewed: false, requiresLogin: false, declinable: false }); + return; + } + try { + this.validity.set(await this.authService.verifyInvitationToken(this.token)); + } + catch (error) { + this.errorParagraphs.set(AuthErrorUtilities.findErrorParagraphs(error) ?? [this.labels.failed]); + } + } +} \ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/accept-invitation.stories.ts b/projects/ngx-auth/accept-invitation/accept-invitation.stories.ts new file mode 100644 index 0000000..c59fa6b --- /dev/null +++ b/projects/ngx-auth/accept-invitation/accept-invitation.stories.ts @@ -0,0 +1,104 @@ +import { provideHttpClient, withInterceptors } from '@angular/common/http'; +import { Component, EnvironmentProviders, inject, OnInit, Provider, Service } from '@angular/core'; +import { provideRouter, Router, RouterOutlet, withDisabledInitialNavigation } from '@angular/router'; +import { AuthData, authInterceptor, AuthService, provideAuth } from '@service-soft/ngx-auth/auth'; +import { applicationConfig, Meta, StoryObj } from '@storybook/angular'; +import { HttpTestingUtilities } from 'testing/http'; +import { InvitationTokenValidity } from 'zibri-contract'; + +import { AcceptInvitationComponent } from './accept-invitation.component'; + +@Service() +class StoryAuthService extends AuthService {} + +// an invitation to a tenant that works, of an email with an account, which may be declined. +const VALID: InvitationTokenValidity = { + isValid: true, + renewed: false, + email: 'ada@example.com', + tenantId: 'tenant-b', + requiresLogin: true, + declinable: true +}; + +// zibri, as far as the page gets: the link of the story and what it answers about it. +function answerWith(validity: InvitationTokenValidity): (Provider | EnvironmentProviders)[] { + return [ + // the page reads the token from its route, which the story opens itself instead of the url of storybook + provideRouter([{ path: 'accept-invitation/:token', component: AcceptInvitationComponent }], withDisabledInitialNavigation()), + provideHttpClient(withInterceptors([ + authInterceptor, + HttpTestingUtilities.answerWith({ + 'POST /api/auth/verify-invitation-token': { status: 200, body: validity }, + 'POST /api/auth/accept-invitation': { status: 204 }, + 'POST /api/auth/decline-invitation': { status: 204 } + }) + ])), + provideAuth(StoryAuthService, { apiUrl: '/api/auth', strategy: 'cookie' }) + ]; +} + +// a login of another visit, which the AuthService finds in the browser when the app starts, or none. +function startLoggedInAs(email: string | undefined): () => Promise { + return async () => { + localStorage.removeItem('authData'); + if (email != undefined) { + const login: AuthData = { + strategy: 'cookie', + userId: 'user-1', + roles: ['user'], + expiresAt: new Date(Date.now() + 3_600_000).toISOString(), + user: { id: 'user-1', email, memberships: [], platformPermissions: [] } + }; + localStorage.setItem('authData', JSON.stringify(login)); + } + return await Promise.resolve({}); + }; +} + +// opens the link of the email. +@Component({ + selector: 'ngx-invitation-link', + template: '', + imports: [RouterOutlet] +}) +class InvitationLinkComponent implements OnInit { + private readonly router: Router = inject(Router); + + ngOnInit(): void { + void this.router.navigateByUrl('/accept-invitation/story-token', { skipLocationChange: true }); + } +} + +const meta: Meta = { + title: 'Auth/Accept invitation', + component: InvitationLinkComponent, + loaders: [startLoggedInAs(undefined)], + decorators: [applicationConfig({ providers: answerWith(VALID) })] +}; +export default meta; + +type Story = StoryObj; + +// an invitation that creates its account, which asks for its password. +export const NewAccount: Story = { + decorators: [applicationConfig({ providers: answerWith({ ...VALID, requiresLogin: false }) })] +}; + +export const LoginRequired: Story = {}; + +export const LoggedInAsInvited: Story = { + loaders: [startLoggedInAs('ada@example.com')] +}; + +export const LoggedInAsSomebodyElse: Story = { + loaders: [startLoggedInAs('grace@example.com')] +}; + +export const LinkDoesNotWork: Story = { + decorators: [applicationConfig({ providers: answerWith({ isValid: false, renewed: false, requiresLogin: false, declinable: false }) })] +}; + +export const LinkRenewed: Story = { + decorators: [applicationConfig({ providers: answerWith({ isValid: false, renewed: true, requiresLogin: false, declinable: false }) })] +}; \ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/ng-package.json b/projects/ngx-auth/accept-invitation/ng-package.json new file mode 100644 index 0000000..70e0a80 --- /dev/null +++ b/projects/ngx-auth/accept-invitation/ng-package.json @@ -0,0 +1,5 @@ +{ + "lib": { + "entryFile": "public-api.ts" + } +} \ No newline at end of file diff --git a/projects/ngx-auth/accept-invitation/public-api.ts b/projects/ngx-auth/accept-invitation/public-api.ts new file mode 100644 index 0000000..86f4299 --- /dev/null +++ b/projects/ngx-auth/accept-invitation/public-api.ts @@ -0,0 +1,5 @@ +export * from './accept-invitation-config-changes.model'; +export * from './accept-invitation-config.model'; +export * from './accept-invitation-config.provider'; +export * from './accept-invitation-state.type'; +export * from './accept-invitation.component'; \ No newline at end of file diff --git a/projects/ngx-auth/auth/auth-config.provider.ts b/projects/ngx-auth/auth/auth-config.provider.ts index 912fe83..849d585 100644 --- a/projects/ngx-auth/auth/auth-config.provider.ts +++ b/projects/ngx-auth/auth/auth-config.provider.ts @@ -38,7 +38,10 @@ const DEFAULT_PATHS: AuthPaths = { requestPasswordReset: '/request-password-reset', verifyPasswordResetToken: '/verify-password-reset-token', confirmPasswordReset: '/confirm-password-reset', - changePassword: '/change-password' + changePassword: '/change-password', + verifyInvitationToken: '/verify-invitation-token', + acceptInvitation: '/accept-invitation', + declineInvitation: '/decline-invitation' }; // the defaults of zibri's ZIBRI_DI_TOKENS, which an app can rename. diff --git a/projects/ngx-auth/auth/auth-paths.model.ts b/projects/ngx-auth/auth/auth-paths.model.ts index 7e84805..3d8fb86 100644 --- a/projects/ngx-auth/auth/auth-paths.model.ts +++ b/projects/ngx-auth/auth/auth-paths.model.ts @@ -125,5 +125,18 @@ export type AuthPaths = { /** * Changes the password of the logged in user. */ - changePassword: string + changePassword: string, + /** + * Whether the token of the link of an invitation still works, and how it is accepted. With `invitationRoutes` of + * the AuthController. + */ + verifyInvitationToken: string, + /** + * Accepts an invitation with the token of its link. + */ + acceptInvitation: string, + /** + * Declines an invitation with the token of its link. + */ + declineInvitation: string }; \ No newline at end of file diff --git a/projects/ngx-auth/auth/auth.service.ts b/projects/ngx-auth/auth/auth.service.ts index fd67852..824adb9 100644 --- a/projects/ngx-auth/auth/auth.service.ts +++ b/projects/ngx-auth/auth/auth.service.ts @@ -3,7 +3,7 @@ import { HttpClient, HttpContext, HttpHeaders } from '@angular/common/http'; import { computed, DestroyRef, inject, Injector, PLATFORM_ID, runInInjectionContext, Signal, signal, Type, WritableSignal } from '@angular/core'; import { ActivatedRouteSnapshot, Router } from '@angular/router'; import { firstValueFrom, Observable } from 'rxjs'; -import { CookieAuthData, CsrfToken, CurrentUserProfile, EmailConfirmation, FederatedLinkIdentityStart, JwtAuthData, LogoutResult, PasskeyTicketCredentials, PasswordResetTokenValidity, TwoFactorRegistrations, UserLogin } from 'zibri-contract'; +import { AcceptInvitationInput, CookieAuthData, CsrfToken, CurrentUserProfile, EmailConfirmation, FederatedLinkIdentityStart, InvitationTokenValidity, JwtAuthData, LogoutResult, PasskeyTicketCredentials, PasswordResetTokenValidity, TwoFactorRegistrations, UserLogin } from 'zibri-contract'; import { AnyLevelPermission } from './any-level-permission.model'; import { AuthConfig } from './auth-config.model'; @@ -362,6 +362,43 @@ export abstract class AuthService< )); } + /** + * Resolves whether the token of the link of an invitation still works, and how the invitation is accepted. Zibri + * finds the invitation by its token in every tenant, so the request names none. + * @param token - The token of the link. + * @returns Whether it works, whether a new link was mailed for an expired one, and for a link that works the invited + * email, its tenant, whether accepting needs a login and whether it may be declined. + */ + async verifyInvitationToken(token: string): Promise { + return await firstValueFrom(this.http.post( + this.resolveUrl('verifyInvitationToken'), + { token }, + this.resolveOwnOptions() + )); + } + + /** + * Accepts an invitation with the token of its link: with the password of the account it creates, or, for an email + * with an account already, with the login of that account, which has to be logged in. + * @param token - The token of the link. + * @param password - The password of the account the invitation creates, when its validity doesn't require a login. + */ + async acceptInvitation(token: string, password?: string): Promise { + const input: AcceptInvitationInput = { token, password }; + // past the interceptor like every request of an invitation's link: it names no tenant, and a link zibri refuses + // with a 401 ends no login. Accepting as an account of its own reads the login, which is added here instead. + const headers: Record = password == undefined ? await this.resolveLoginHeaders() : {}; + await firstValueFrom(this.http.post(this.resolveUrl('acceptInvitation'), input, this.resolveOwnOptions(headers))); + } + + /** + * Declines an invitation with the token of its link, when its validity says it may be declined. + * @param token - The token of the link. + */ + async declineInvitation(token: string): Promise { + await firstValueFrom(this.http.post(this.resolveUrl('declineInvitation'), { token }, this.resolveOwnOptions())); + } + /** * Changes the password of the logged in user. Ends every other login of the user. * @param currentPassword - The password the user has. @@ -1019,6 +1056,17 @@ export abstract class AuthService< return search ? `${url}?${search}` : url; } + // what the interceptor adds of the login, for a request past it: the access token with the scheme of the login, or + // the csrf token of the cookies, which every request that changes something sends. None while nobody is logged in. + private async resolveLoginHeaders(): Promise> { + const accessToken: string | undefined = await this.resolveAccessToken(); + if (accessToken != undefined) { + return { Authorization: `${this.config.dpop ? 'DPoP' : 'Bearer'} ${accessToken}` }; + } + const csrfToken: string | undefined = await this.resolveCsrfToken(); + return csrfToken == undefined ? {} : { [this.config.headers.csrfToken]: csrfToken }; + } + private resolveOwnOptions(headers: Record = {}): OwnRequestOptions { return { context: new HttpContext().set(SKIP_AUTH, true), withCredentials: this.config.strategy === 'cookie', headers }; } diff --git a/projects/ngx-auth/package.json b/projects/ngx-auth/package.json index 1119b05..9d9f832 100644 --- a/projects/ngx-auth/package.json +++ b/projects/ngx-auth/package.json @@ -1,6 +1,6 @@ { "name": "@service-soft/ngx-auth", - "version": "22.1.0", + "version": "22.2.0", "license": "MIT", "repository": { "type": "git", @@ -23,10 +23,10 @@ "@angular/core": "^22.2.0", "@angular/router": "^22.2.0", "@fortawesome/free-solid-svg-icons": "^7.3.1", - "@service-soft/ui": "^22.1.0", + "@service-soft/ui": "^22.2.0", "tailwindcss": "^4.3.3", "uqr": "^0.1.3", - "zibri-contract": "^3.1.0" + "zibri-contract": "^3.2.0" }, "peerDependenciesMeta": { "@fortawesome/free-solid-svg-icons": { diff --git a/projects/ngx-change-sets/package.json b/projects/ngx-change-sets/package.json index 89a0009..2361b43 100644 --- a/projects/ngx-change-sets/package.json +++ b/projects/ngx-change-sets/package.json @@ -1,6 +1,6 @@ { "name": "@service-soft/ngx-change-sets", - "version": "22.1.0", + "version": "22.2.0", "license": "MIT", "repository": { "type": "git", @@ -22,7 +22,7 @@ "@angular/common": "^22.2.0", "@angular/core": "^22.2.0", "@fortawesome/free-solid-svg-icons": "^7.3.1", - "@service-soft/ui": "^22.1.0", + "@service-soft/ui": "^22.2.0", "tailwindcss": "^4.3.3", "zibri-contract": "^3.1.0" }, diff --git a/projects/ngx-ecommerce/package.json b/projects/ngx-ecommerce/package.json index 313c3e7..133f28f 100644 --- a/projects/ngx-ecommerce/package.json +++ b/projects/ngx-ecommerce/package.json @@ -1,6 +1,6 @@ { "name": "@service-soft/ngx-ecommerce", - "version": "22.1.0", + "version": "22.2.0", "license": "MIT", "repository": { "type": "git", @@ -22,7 +22,7 @@ "@angular/common": "^22.2.0", "@angular/core": "^22.2.0", "@fortawesome/free-solid-svg-icons": "^7.3.1", - "@service-soft/ui": "^22.1.0", + "@service-soft/ui": "^22.2.0", "tailwindcss": "^4.3.3" }, "sideEffects": false diff --git a/projects/ngx-entity/package.json b/projects/ngx-entity/package.json index c0e83e9..4b46d4b 100644 --- a/projects/ngx-entity/package.json +++ b/projects/ngx-entity/package.json @@ -1,6 +1,6 @@ { "name": "@service-soft/ngx-entity", - "version": "22.1.0", + "version": "22.2.0", "license": "MIT", "repository": { "type": "git", @@ -22,9 +22,9 @@ "@angular/common": "^22.2.0", "@angular/core": "^22.2.0", "@angular/router": "^22.2.0", - "@service-soft/ngx-error-handling": "^22.1.0", - "@service-soft/ngx-pwa": "^22.1.0", - "@service-soft/ui": "^22.1.0", + "@service-soft/ngx-error-handling": "^22.2.0", + "@service-soft/ngx-pwa": "^22.2.0", + "@service-soft/ui": "^22.2.0", "tailwindcss": "^4.3.3", "zibri-contract": "^3.1.0" }, diff --git a/projects/ngx-error-handling/package.json b/projects/ngx-error-handling/package.json index 580db90..7c04da3 100644 --- a/projects/ngx-error-handling/package.json +++ b/projects/ngx-error-handling/package.json @@ -1,6 +1,6 @@ { "name": "@service-soft/ngx-error-handling", - "version": "22.1.0", + "version": "22.2.0", "license": "MIT", "repository": { "type": "git", @@ -21,7 +21,7 @@ "peerDependencies": { "@angular/common": "^22.2.0", "@angular/core": "^22.2.0", - "@service-soft/ui": "^22.1.0", + "@service-soft/ui": "^22.2.0", "tailwindcss": "^4.3.3", "zibri-contract": "^3.1.0" }, diff --git a/projects/ngx-navigation/package.json b/projects/ngx-navigation/package.json index 927c279..3ca244a 100644 --- a/projects/ngx-navigation/package.json +++ b/projects/ngx-navigation/package.json @@ -1,6 +1,6 @@ { "name": "@service-soft/ngx-navigation", - "version": "22.1.0", + "version": "22.2.0", "license": "MIT", "repository": { "type": "git", @@ -24,7 +24,7 @@ "@angular/platform-browser": "^22.2.0", "@angular/router": "^22.2.0", "@fortawesome/free-solid-svg-icons": "^7.3.1", - "@service-soft/ui": "^22.1.0", + "@service-soft/ui": "^22.2.0", "tailwindcss": "^4.3.3" }, "sideEffects": false diff --git a/projects/ngx-persistence-logger/package.json b/projects/ngx-persistence-logger/package.json index 014b2c2..79606a1 100644 --- a/projects/ngx-persistence-logger/package.json +++ b/projects/ngx-persistence-logger/package.json @@ -1,6 +1,6 @@ { "name": "@service-soft/ngx-persistence-logger", - "version": "22.1.0", + "version": "22.2.0", "license": "MIT", "repository": { "type": "git", @@ -22,7 +22,7 @@ "@angular/common": "^22.2.0", "@angular/core": "^22.2.0", "@fortawesome/free-solid-svg-icons": "^7.3.1", - "@service-soft/ui": "^22.1.0", + "@service-soft/ui": "^22.2.0", "tailwindcss": "^4.3.3", "zibri-contract": "^3.1.0" }, diff --git a/projects/ngx-pwa/package.json b/projects/ngx-pwa/package.json index 5f4f14f..e067062 100644 --- a/projects/ngx-pwa/package.json +++ b/projects/ngx-pwa/package.json @@ -1,6 +1,6 @@ { "name": "@service-soft/ngx-pwa", - "version": "22.1.0", + "version": "22.2.0", "license": "MIT", "repository": { "type": "git", @@ -23,7 +23,7 @@ "@angular/core": "^22.2.0", "@angular/service-worker": "^22.2.0", "@fortawesome/free-solid-svg-icons": "^7.3.1", - "@service-soft/ui": "^22.1.0", + "@service-soft/ui": "^22.2.0", "tailwindcss": "^4.3.3" }, "peerDependenciesMeta": { diff --git a/projects/ngx-tracking/package.json b/projects/ngx-tracking/package.json index dfe9e9d..7302058 100644 --- a/projects/ngx-tracking/package.json +++ b/projects/ngx-tracking/package.json @@ -1,6 +1,6 @@ { "name": "@service-soft/ngx-tracking", - "version": "22.1.0", + "version": "22.2.0", "license": "MIT", "repository": { "type": "git", @@ -23,7 +23,7 @@ "@angular/core": "^22.2.0", "@angular/router": "^22.2.0", "@fortawesome/free-solid-svg-icons": "^7.3.1", - "@service-soft/ui": "^22.1.0", + "@service-soft/ui": "^22.2.0", "tailwindcss": "^4.3.3" }, "peerDependenciesMeta": { diff --git a/projects/ui/package.json b/projects/ui/package.json index 7e5ca05..438c005 100644 --- a/projects/ui/package.json +++ b/projects/ui/package.json @@ -1,6 +1,6 @@ { "name": "@service-soft/ui", - "version": "22.1.0", + "version": "22.2.0", "license": "MIT", "repository": { "type": "git",