@strivacity/sdk-angular 4.0.0-beta.0 → 4.0.0-beta.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from '@strivacity/sdk-core/flows';
|
|
2
2
|
export * from '@strivacity/sdk-core/handlers';
|
|
3
|
-
import { unflattenObject } from '@strivacity/sdk-core/utils';
|
|
3
|
+
import { unflattenObject, isSessionExpired } from '@strivacity/sdk-core/utils';
|
|
4
4
|
export * from '@strivacity/sdk-core/utils';
|
|
5
5
|
import * as i0 from '@angular/core';
|
|
6
6
|
import { InjectionToken, CUSTOM_ELEMENTS_SCHEMA, NgModule, makeStateKey, provideAppInitializer, inject, REQUEST, TransferState, signal, PLATFORM_ID, DestroyRef, Injectable } from '@angular/core';
|
|
@@ -291,7 +291,7 @@ class StrivacityNativeLoginService {
|
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
async handleResponse(nextState) {
|
|
294
|
-
if (this.sdk.session) {
|
|
294
|
+
if (this.sdk.session && !isSessionExpired(this.sdk.session)) {
|
|
295
295
|
return await this.options.onLogin?.(this.sdk.session);
|
|
296
296
|
}
|
|
297
297
|
const currentState = this.stateSignal();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strivacity-sdk-angular.mjs","sources":["../../src/lib/utils.ts","../../src/server/session.ts","../../src/lib/services/auth.service.ts","../../src/lib/services/native-login.service.ts","../../src/strivacity-sdk-angular.ts"],"sourcesContent":["import type { Provider, ModuleWithProviders } from '@angular/core';\nimport type { AngularSDKInitConfig } from '../types';\nimport { CUSTOM_ELEMENTS_SCHEMA, NgModule, InjectionToken } from '@angular/core';\nimport { StrivacityAuthService } from './services/auth.service';\n\nexport const STRIVACITY_SDK = new InjectionToken<AngularSDKInitConfig>('strivacity-sdk');\n\n/**\n * Provides the Strivacity SDK configuration and the `StrivacityAuthService` as dependency injection providers.\n *\n * This function is used to supply the Strivacity SDK configuration to the application\n * by binding it to the `STRIVACITY_SDK` token, and to register `StrivacityAuthService` as an injectable.\n *\n * @param {AngularSDKInitConfig} config The SDK configuration options.\n * @returns {Provider[]} The providers to add to the application (or component) injector.\n */\nexport function provideStrivacity(config: AngularSDKInitConfig): Provider[] {\n\treturn [{ provide: STRIVACITY_SDK, useValue: config }, StrivacityAuthService];\n}\n\n@NgModule({\n\tschemas: [CUSTOM_ELEMENTS_SCHEMA],\n})\nexport class StrivacityAuthModule {\n\t/**\n\t * Registers the Strivacity SDK configuration and the `StrivacityAuthService` as dependency injection providers.\n\t *\n\t * This is the `NgModule`-based equivalent of `provideStrivacity()`, for applications that still bootstrap via `NgModule`.\n\t *\n\t * @param {AngularSDKInitConfig} options The SDK configuration options.\n\t * @returns {ModuleWithProviders<StrivacityAuthModule>} The module along with its providers, to be imported once at the root of the application.\n\t */\n\tstatic forRoot(options: AngularSDKInitConfig): ModuleWithProviders<StrivacityAuthModule> {\n\t\treturn {\n\t\t\tngModule: StrivacityAuthModule,\n\t\t\tproviders: [provideStrivacity(options)],\n\t\t};\n\t}\n}\n","import type { EnvironmentProviders } from '@angular/core';\nimport type { AngularServerSDK, SessionData } from './types';\nimport { REQUEST, TransferState, inject, makeStateKey, provideAppInitializer } from '@angular/core';\n\nexport const SESSION_TRANSFER_KEY = makeStateKey<SessionData | null>('sty.session');\n\n/**\n * Loads the current session from the encrypted cookie storage (using Angular's `REQUEST` token) before the app\n * renders, and hands it over to the client through `TransferState`, so `StrivacityAuthService` can hydrate without\n * an extra round-trip or a loading flash.\n *\n * Add this to the server-only `ApplicationConfig` (e.g. `app.config.server.ts`), alongside `provideServerRendering()`.\n *\n * @param {AngularServerSDK | undefined} serverSdk - The server SDK instance created via `createServerSDK()`, or `undefined` when server-side sessions aren't configured (a no-op in that case).\n * @returns {EnvironmentProviders} The providers to add to the server `ApplicationConfig`.\n */\nexport function provideStrivacityServerSession(serverSdk: AngularServerSDK | undefined): EnvironmentProviders {\n\treturn provideAppInitializer(async () => {\n\t\tconst request = inject(REQUEST);\n\n\t\tif (!request || !serverSdk) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transferState = inject(TransferState);\n\t\tconst session = await serverSdk.getSession(request);\n\n\t\ttransferState.set(SESSION_TRANSFER_KEY, session);\n\t});\n}\n","import type { IdTokenClaims, SDKInstance } from '../../types';\nimport { DestroyRef, Injectable, PLATFORM_ID, TransferState, inject, signal } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\nimport { initFlow } from '@strivacity/sdk-core';\nimport { STRIVACITY_SDK } from '../utils';\nimport { SESSION_TRANSFER_KEY } from '../../server/session';\n\n/**\n * Signal-based service exposing the Strivacity SDK state and actions to Angular components.\n *\n * Provided via `provideStrivacity()` (standalone) or `StrivacityAuthModule.forRoot()` (NgModule).\n */\n@Injectable()\nexport class StrivacityAuthService {\n\tprivate readonly loadingSignal = signal(true);\n\tprivate readonly languageSignal = signal(globalThis.navigator?.language ?? 'en-US');\n\tprivate readonly isAuthenticatedSignal = signal(false);\n\tprivate readonly idTokenClaimsSignal = signal<IdTokenClaims | null>(null);\n\tprivate readonly accessTokenSignal = signal<string | null>(null);\n\tprivate readonly refreshTokenSignal = signal<string | null>(null);\n\tprivate readonly accessTokenExpiredSignal = signal(true);\n\tprivate readonly accessTokenExpirationDateSignal = signal<number | null>(null);\n\n\treadonly options = inject(STRIVACITY_SDK);\n\treadonly sdk: SDKInstance = initFlow(this.options as never);\n\treadonly loading = this.loadingSignal.asReadonly();\n\treadonly language = this.languageSignal.asReadonly();\n\treadonly isAuthenticated = this.isAuthenticatedSignal.asReadonly();\n\treadonly idTokenClaims = this.idTokenClaimsSignal.asReadonly();\n\treadonly accessToken = this.accessTokenSignal.asReadonly();\n\treadonly refreshToken = this.refreshTokenSignal.asReadonly();\n\treadonly accessTokenExpired = this.accessTokenExpiredSignal.asReadonly();\n\treadonly accessTokenExpirationDate = this.accessTokenExpirationDateSignal.asReadonly();\n\n\tconstructor() {\n\t\tif (this.options.serverSessionUri) {\n\t\t\tconst transferState = inject(TransferState);\n\t\t\tconst hydratedSession = transferState.get(SESSION_TRANSFER_KEY, undefined);\n\n\t\t\tif (hydratedSession) {\n\t\t\t\tthis.sdk.session = hydratedSession;\n\n\t\t\t\tif (isPlatformBrowser(inject(PLATFORM_ID))) {\n\t\t\t\t\ttransferState.remove(SESSION_TRANSFER_KEY);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tvoid this.updateSession();\n\n\t\tconst subscription = this.sdk.subscribeToAllEvents(() => this.updateSession());\n\t\tinject(DestroyRef).onDestroy(() => subscription.dispose());\n\t}\n\n\tinit(...args: Parameters<typeof this.sdk.init>): ReturnType<typeof this.sdk.init> {\n\t\treturn this.sdk.init(...args);\n\t}\n\n\tsubscribeToEvent(...args: Parameters<typeof this.sdk.subscribeToEvent>): ReturnType<typeof this.sdk.subscribeToEvent> {\n\t\treturn this.sdk.subscribeToEvent(...args);\n\t}\n\n\tsubscribeToAllEvents(...args: Parameters<typeof this.sdk.subscribeToAllEvents>): ReturnType<typeof this.sdk.subscribeToAllEvents> {\n\t\treturn this.sdk.subscribeToAllEvents(...args);\n\t}\n\n\tcheckAuthentication(...args: Parameters<typeof this.sdk.checkAuthentication>): ReturnType<typeof this.sdk.checkAuthentication> {\n\t\treturn this.sdk.checkAuthentication(...args);\n\t}\n\n\ttokenExchange(...args: Parameters<typeof this.sdk.tokenExchange>): ReturnType<typeof this.sdk.tokenExchange> {\n\t\treturn this.sdk.tokenExchange(...args);\n\t}\n\n\thandleCallback(...args: Parameters<typeof this.sdk.handleCallback>): ReturnType<typeof this.sdk.handleCallback> {\n\t\treturn this.sdk.handleCallback(...args);\n\t}\n\n\trefresh(): ReturnType<typeof this.sdk.refresh> {\n\t\treturn this.sdk.refresh();\n\t}\n\n\trevoke(): ReturnType<typeof this.sdk.revoke> {\n\t\treturn this.sdk.revoke();\n\t}\n\n\tlogout(...args: Parameters<typeof this.sdk.logout>): ReturnType<typeof this.sdk.logout> {\n\t\treturn this.sdk.logout(...args);\n\t}\n\n\tlogin(...args: Parameters<typeof this.sdk.login>): ReturnType<typeof this.sdk.login> {\n\t\treturn this.sdk.login(...args);\n\t}\n\n\tregister(...args: Parameters<typeof this.sdk.register>): ReturnType<typeof this.sdk.register> {\n\t\treturn this.sdk.register(...args);\n\t}\n\n\tentry(...args: Parameters<typeof this.sdk.entry>): ReturnType<typeof this.sdk.entry> {\n\t\treturn this.sdk.entry(...args);\n\t}\n\n\tprivate async updateSession(): Promise<void> {\n\t\tconst authenticated = await this.sdk.isAuthenticated;\n\n\t\tif (this.loadingSignal()) {\n\t\t\tthis.loadingSignal.set(false);\n\t\t}\n\t\tif (this.sdk.language !== this.languageSignal()) {\n\t\t\tthis.languageSignal.set(this.sdk.language);\n\t\t}\n\t\tif (authenticated !== this.isAuthenticatedSignal()) {\n\t\t\tthis.isAuthenticatedSignal.set(authenticated);\n\t\t}\n\t\tif (this.sdk.idTokenClaims !== this.idTokenClaimsSignal()) {\n\t\t\tthis.idTokenClaimsSignal.set(this.sdk.idTokenClaims ?? null);\n\t\t}\n\t\tif (this.sdk.accessToken !== this.accessTokenSignal()) {\n\t\t\tthis.accessTokenSignal.set(this.sdk.accessToken ?? null);\n\t\t}\n\t\tif (this.sdk.refreshToken !== this.refreshTokenSignal()) {\n\t\t\tthis.refreshTokenSignal.set(this.sdk.refreshToken ?? null);\n\t\t}\n\t\tif (this.sdk.accessTokenExpired !== this.accessTokenExpiredSignal()) {\n\t\t\tthis.accessTokenExpiredSignal.set(this.sdk.accessTokenExpired);\n\t\t}\n\t\tif (this.sdk.accessTokenExpirationDate !== this.accessTokenExpirationDateSignal()) {\n\t\t\tthis.accessTokenExpirationDateSignal.set(this.sdk.accessTokenExpirationDate ?? null);\n\t\t}\n\t}\n}\n","import type { NativeFlowMessage, NativeFlowState, NativeParams, NativeLoginOptions } from '../../types';\nimport { DestroyRef, Injectable, inject, signal } from '@angular/core';\nimport { FallbackError } from '@strivacity/sdk-core/utils/errors';\nimport { unflattenObject } from '@strivacity/sdk-core/utils';\nimport { StrivacityAuthService } from './auth.service';\n\n@Injectable()\nexport class StrivacityNativeLoginService {\n\tprivate readonly authService = inject(StrivacityAuthService);\n\tprivate readonly sdk = this.authService.sdk;\n\tprivate readonly abortController = new AbortController();\n\tprivate options: NativeLoginOptions = {};\n\n\tprivate readonly loadingSignal = signal(true);\n\tprivate readonly formsSignal = signal<Record<string, Record<string, unknown>>>({});\n\tprivate readonly messagesSignal = signal<Record<string, Record<string, NativeFlowMessage>>>({});\n\tprivate readonly stateSignal = signal<Partial<NativeFlowState>>({});\n\n\treadonly loading = this.loadingSignal.asReadonly();\n\treadonly forms = this.formsSignal.asReadonly();\n\treadonly messages = this.messagesSignal.asReadonly();\n\treadonly state = this.stateSignal.asReadonly();\n\n\tconstructor() {\n\t\tinject(DestroyRef).onDestroy(() => this.abortController.abort());\n\t}\n\n\t/**\n\t * Starts a native login flow session. Should be called once, from the page component that owns this service.\n\t *\n\t * @param {NativeLoginOptions} [options] - Optional options for the login session.\n\t */\n\tasync start(options: NativeLoginOptions = {}): Promise<void> {\n\t\tthis.options = options;\n\n\t\tawait this.sdk.init();\n\n\t\ttry {\n\t\t\tawait this.startSession(options.params);\n\t\t} catch (error) {\n\t\t\tif (error instanceof DOMException && error.name === 'AbortError') {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.sdk.logging?.error('Error fetching authorization URI', error as Error);\n\t\t\tawait this.options.onError?.(error as Error);\n\t\t\tthis.loadingSignal.set(false);\n\t\t}\n\t}\n\n\tasync submitForm(formId: string, customBody?: Record<string, unknown>): Promise<void> {\n\t\ttry {\n\t\t\tthis.loadingSignal.set(true);\n\n\t\t\tconst nextState = await this.sdk.submitForm(formId, customBody ?? unflattenObject(this.formsSignal()[formId] ?? {}));\n\n\t\t\tif (nextState) {\n\t\t\t\tawait this.handleResponse(nextState);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof FallbackError) {\n\t\t\t\tthis.sdk.logging?.error('Fallback error occurred', error);\n\t\t\t\tawait this.options.onFallback?.(error);\n\t\t\t} else {\n\t\t\t\tthis.sdk.logging?.error('Error submitting form', error as Error);\n\t\t\t\tawait this.options.onError?.(error as Error);\n\t\t\t}\n\t\t}\n\t}\n\n\tsetFormValue(formId: string, widgetId: string, value: unknown): void {\n\t\tconst forms = { ...this.formsSignal() };\n\n\t\tforms[formId] = { ...(forms[formId] ?? {}), [widgetId]: value === '' ? null : value };\n\t\tthis.formsSignal.set(forms);\n\t}\n\n\tsetMessage(formId: string, widgetId: string, value: NativeFlowMessage): void {\n\t\tconst messages = { ...this.messagesSignal() };\n\n\t\tmessages[formId] = { ...(messages[formId] ?? {}), [widgetId]: value };\n\t\tthis.messagesSignal.set(messages);\n\t}\n\n\ttriggerFallback(message?: string): void {\n\t\tthis.sdk.logging?.warn(message ? `Triggering fallback due to: ${message}` : 'Triggering fallback');\n\n\t\tconst hostedUrl = this.stateSignal().hostedUrl;\n\n\t\tif (!hostedUrl) {\n\t\t\tconst error = new Error('No hosted URL provided');\n\t\t\tthis.sdk.logging?.error('Fallback error', error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tvoid this.options.onFallback?.(new FallbackError(new URL(hostedUrl)));\n\t}\n\n\ttriggerClose(): void {\n\t\tthis.sdk.logging?.debug('Triggering close');\n\t\tvoid this.options.onClose?.();\n\t}\n\n\tprivate async startSession(loginParams: NativeParams = {}): Promise<void> {\n\t\ttry {\n\t\t\tthis.loadingSignal.set(true);\n\n\t\t\tconst nextState = await this.sdk.startSession(loginParams);\n\n\t\t\tif (nextState) {\n\t\t\t\tawait this.handleResponse(nextState);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof FallbackError) {\n\t\t\t\tthis.sdk.logging?.error('Fallback error occurred', error);\n\t\t\t\tawait this.options.onFallback?.(error);\n\t\t\t} else {\n\t\t\t\tthis.sdk.logging?.error('Error starting session', error as Error);\n\t\t\t\tawait this.options.onError?.(error as Error);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async handleResponse(nextState: Partial<NativeFlowState>): Promise<void> {\n\t\tif (this.sdk.session) {\n\t\t\treturn await this.options.onLogin?.(this.sdk.session);\n\t\t}\n\n\t\tconst currentState = this.stateSignal();\n\t\tconst newState: NativeFlowState = {\n\t\t\thostedUrl: nextState.hostedUrl ?? currentState.hostedUrl,\n\t\t\tfinalizeUrl: nextState.finalizeUrl ?? currentState.finalizeUrl,\n\t\t\tscreen: nextState.screen ?? currentState.screen,\n\t\t\tforms: nextState.forms ?? currentState.forms,\n\t\t\tlayout: nextState.layout ?? currentState.layout,\n\t\t\tmessages: nextState.messages ?? {},\n\t\t\tbranding: nextState.branding ?? currentState.branding,\n\t\t};\n\n\t\tif (newState.screen !== currentState.screen) {\n\t\t\tconst nextForms: Record<string, Record<string, unknown>> = {};\n\t\t\tconst nextMessages: Record<string, Record<string, NativeFlowMessage>> = {};\n\n\t\t\tfor (const form of newState.forms ?? []) {\n\t\t\t\tnextForms[form.id] = {};\n\t\t\t\tnextMessages[form.id] = {};\n\t\t\t}\n\n\t\t\tthis.formsSignal.set(nextForms);\n\t\t\tthis.messagesSignal.set(nextMessages);\n\t\t} else {\n\t\t\tthis.sdk.logging?.info(`Updating screen: ${newState.screen}`);\n\t\t}\n\n\t\tconst nextMessageMap = { ...this.messagesSignal() };\n\n\t\tfor (const formId of Object.keys(newState.messages ?? {})) {\n\t\t\tif (formId === 'global') {\n\t\t\t\tawait this.options.onGlobalMessage?.(newState.messages!.global!);\n\t\t\t} else {\n\t\t\t\tnextMessageMap[formId] = newState.messages![formId] ?? {};\n\t\t\t}\n\t\t}\n\n\t\tthis.messagesSignal.set(nextMessageMap);\n\t\tthis.stateSignal.set(newState);\n\n\t\tif (!newState.finalizeUrl) {\n\t\t\tthis.loadingSignal.set(false);\n\t\t}\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;MAKa,cAAc,GA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AAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;QAC9B;IACD;8GAnKY,4BAA4B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;kHAA5B,4BAA4B,EAAA,CAAA,CAAA;;2FAA5B,4BAA4B,EAAA,UAAA,EAAA,CAAA;kBADxC;;;ACND;;AAEG;;"}
|
|
1
|
+
{"version":3,"file":"strivacity-sdk-angular.mjs","sources":["../../src/lib/utils.ts","../../src/server/session.ts","../../src/lib/services/auth.service.ts","../../src/lib/services/native-login.service.ts","../../src/strivacity-sdk-angular.ts"],"sourcesContent":["import type { Provider, ModuleWithProviders } from '@angular/core';\nimport type { AngularSDKInitConfig } from '../types';\nimport { CUSTOM_ELEMENTS_SCHEMA, NgModule, InjectionToken } from '@angular/core';\nimport { StrivacityAuthService } from './services/auth.service';\n\nexport const STRIVACITY_SDK = new InjectionToken<AngularSDKInitConfig>('strivacity-sdk');\n\n/**\n * Provides the Strivacity SDK configuration and the `StrivacityAuthService` as dependency injection providers.\n *\n * This function is used to supply the Strivacity SDK configuration to the application\n * by binding it to the `STRIVACITY_SDK` token, and to register `StrivacityAuthService` as an injectable.\n *\n * @param {AngularSDKInitConfig} config The SDK configuration options.\n * @returns {Provider[]} The providers to add to the application (or component) injector.\n */\nexport function provideStrivacity(config: AngularSDKInitConfig): Provider[] {\n\treturn [{ provide: STRIVACITY_SDK, useValue: config }, StrivacityAuthService];\n}\n\n@NgModule({\n\tschemas: [CUSTOM_ELEMENTS_SCHEMA],\n})\nexport class StrivacityAuthModule {\n\t/**\n\t * Registers the Strivacity SDK configuration and the `StrivacityAuthService` as dependency injection providers.\n\t *\n\t * This is the `NgModule`-based equivalent of `provideStrivacity()`, for applications that still bootstrap via `NgModule`.\n\t *\n\t * @param {AngularSDKInitConfig} options The SDK configuration options.\n\t * @returns {ModuleWithProviders<StrivacityAuthModule>} The module along with its providers, to be imported once at the root of the application.\n\t */\n\tstatic forRoot(options: AngularSDKInitConfig): ModuleWithProviders<StrivacityAuthModule> {\n\t\treturn {\n\t\t\tngModule: StrivacityAuthModule,\n\t\t\tproviders: [provideStrivacity(options)],\n\t\t};\n\t}\n}\n","import type { EnvironmentProviders } from '@angular/core';\nimport type { AngularServerSDK, SessionData } from './types';\nimport { REQUEST, TransferState, inject, makeStateKey, provideAppInitializer } from '@angular/core';\n\nexport const SESSION_TRANSFER_KEY = makeStateKey<SessionData | null>('sty.session');\n\n/**\n * Loads the current session from the encrypted cookie storage (using Angular's `REQUEST` token) before the app\n * renders, and hands it over to the client through `TransferState`, so `StrivacityAuthService` can hydrate without\n * an extra round-trip or a loading flash.\n *\n * Add this to the server-only `ApplicationConfig` (e.g. `app.config.server.ts`), alongside `provideServerRendering()`.\n *\n * @param {AngularServerSDK | undefined} serverSdk - The server SDK instance created via `createServerSDK()`, or `undefined` when server-side sessions aren't configured (a no-op in that case).\n * @returns {EnvironmentProviders} The providers to add to the server `ApplicationConfig`.\n */\nexport function provideStrivacityServerSession(serverSdk: AngularServerSDK | undefined): EnvironmentProviders {\n\treturn provideAppInitializer(async () => {\n\t\tconst request = inject(REQUEST);\n\n\t\tif (!request || !serverSdk) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transferState = inject(TransferState);\n\t\tconst session = await serverSdk.getSession(request);\n\n\t\ttransferState.set(SESSION_TRANSFER_KEY, session);\n\t});\n}\n","import type { IdTokenClaims, SDKInstance } from '../../types';\nimport { DestroyRef, Injectable, PLATFORM_ID, TransferState, inject, signal } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\nimport { initFlow } from '@strivacity/sdk-core';\nimport { STRIVACITY_SDK } from '../utils';\nimport { SESSION_TRANSFER_KEY } from '../../server/session';\n\n/**\n * Signal-based service exposing the Strivacity SDK state and actions to Angular components.\n *\n * Provided via `provideStrivacity()` (standalone) or `StrivacityAuthModule.forRoot()` (NgModule).\n */\n@Injectable()\nexport class StrivacityAuthService {\n\tprivate readonly loadingSignal = signal(true);\n\tprivate readonly languageSignal = signal(globalThis.navigator?.language ?? 'en-US');\n\tprivate readonly isAuthenticatedSignal = signal(false);\n\tprivate readonly idTokenClaimsSignal = signal<IdTokenClaims | null>(null);\n\tprivate readonly accessTokenSignal = signal<string | null>(null);\n\tprivate readonly refreshTokenSignal = signal<string | null>(null);\n\tprivate readonly accessTokenExpiredSignal = signal(true);\n\tprivate readonly accessTokenExpirationDateSignal = signal<number | null>(null);\n\n\treadonly options = inject(STRIVACITY_SDK);\n\treadonly sdk: SDKInstance = initFlow(this.options as never);\n\treadonly loading = this.loadingSignal.asReadonly();\n\treadonly language = this.languageSignal.asReadonly();\n\treadonly isAuthenticated = this.isAuthenticatedSignal.asReadonly();\n\treadonly idTokenClaims = this.idTokenClaimsSignal.asReadonly();\n\treadonly accessToken = this.accessTokenSignal.asReadonly();\n\treadonly refreshToken = this.refreshTokenSignal.asReadonly();\n\treadonly accessTokenExpired = this.accessTokenExpiredSignal.asReadonly();\n\treadonly accessTokenExpirationDate = this.accessTokenExpirationDateSignal.asReadonly();\n\n\tconstructor() {\n\t\tif (this.options.serverSessionUri) {\n\t\t\tconst transferState = inject(TransferState);\n\t\t\tconst hydratedSession = transferState.get(SESSION_TRANSFER_KEY, undefined);\n\n\t\t\tif (hydratedSession) {\n\t\t\t\tthis.sdk.session = hydratedSession;\n\n\t\t\t\tif (isPlatformBrowser(inject(PLATFORM_ID))) {\n\t\t\t\t\ttransferState.remove(SESSION_TRANSFER_KEY);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tvoid this.updateSession();\n\n\t\tconst subscription = this.sdk.subscribeToAllEvents(() => this.updateSession());\n\t\tinject(DestroyRef).onDestroy(() => subscription.dispose());\n\t}\n\n\tinit(...args: Parameters<typeof this.sdk.init>): ReturnType<typeof this.sdk.init> {\n\t\treturn this.sdk.init(...args);\n\t}\n\n\tsubscribeToEvent(...args: Parameters<typeof this.sdk.subscribeToEvent>): ReturnType<typeof this.sdk.subscribeToEvent> {\n\t\treturn this.sdk.subscribeToEvent(...args);\n\t}\n\n\tsubscribeToAllEvents(...args: Parameters<typeof this.sdk.subscribeToAllEvents>): ReturnType<typeof this.sdk.subscribeToAllEvents> {\n\t\treturn this.sdk.subscribeToAllEvents(...args);\n\t}\n\n\tcheckAuthentication(...args: Parameters<typeof this.sdk.checkAuthentication>): ReturnType<typeof this.sdk.checkAuthentication> {\n\t\treturn this.sdk.checkAuthentication(...args);\n\t}\n\n\ttokenExchange(...args: Parameters<typeof this.sdk.tokenExchange>): ReturnType<typeof this.sdk.tokenExchange> {\n\t\treturn this.sdk.tokenExchange(...args);\n\t}\n\n\thandleCallback(...args: Parameters<typeof this.sdk.handleCallback>): ReturnType<typeof this.sdk.handleCallback> {\n\t\treturn this.sdk.handleCallback(...args);\n\t}\n\n\trefresh(): ReturnType<typeof this.sdk.refresh> {\n\t\treturn this.sdk.refresh();\n\t}\n\n\trevoke(): ReturnType<typeof this.sdk.revoke> {\n\t\treturn this.sdk.revoke();\n\t}\n\n\tlogout(...args: Parameters<typeof this.sdk.logout>): ReturnType<typeof this.sdk.logout> {\n\t\treturn this.sdk.logout(...args);\n\t}\n\n\tlogin(...args: Parameters<typeof this.sdk.login>): ReturnType<typeof this.sdk.login> {\n\t\treturn this.sdk.login(...args);\n\t}\n\n\tregister(...args: Parameters<typeof this.sdk.register>): ReturnType<typeof this.sdk.register> {\n\t\treturn this.sdk.register(...args);\n\t}\n\n\tentry(...args: Parameters<typeof this.sdk.entry>): ReturnType<typeof this.sdk.entry> {\n\t\treturn this.sdk.entry(...args);\n\t}\n\n\tprivate async updateSession(): Promise<void> {\n\t\tconst authenticated = await this.sdk.isAuthenticated;\n\n\t\tif (this.loadingSignal()) {\n\t\t\tthis.loadingSignal.set(false);\n\t\t}\n\t\tif (this.sdk.language !== this.languageSignal()) {\n\t\t\tthis.languageSignal.set(this.sdk.language);\n\t\t}\n\t\tif (authenticated !== this.isAuthenticatedSignal()) {\n\t\t\tthis.isAuthenticatedSignal.set(authenticated);\n\t\t}\n\t\tif (this.sdk.idTokenClaims !== this.idTokenClaimsSignal()) {\n\t\t\tthis.idTokenClaimsSignal.set(this.sdk.idTokenClaims ?? null);\n\t\t}\n\t\tif (this.sdk.accessToken !== this.accessTokenSignal()) {\n\t\t\tthis.accessTokenSignal.set(this.sdk.accessToken ?? null);\n\t\t}\n\t\tif (this.sdk.refreshToken !== this.refreshTokenSignal()) {\n\t\t\tthis.refreshTokenSignal.set(this.sdk.refreshToken ?? null);\n\t\t}\n\t\tif (this.sdk.accessTokenExpired !== this.accessTokenExpiredSignal()) {\n\t\t\tthis.accessTokenExpiredSignal.set(this.sdk.accessTokenExpired);\n\t\t}\n\t\tif (this.sdk.accessTokenExpirationDate !== this.accessTokenExpirationDateSignal()) {\n\t\t\tthis.accessTokenExpirationDateSignal.set(this.sdk.accessTokenExpirationDate ?? null);\n\t\t}\n\t}\n}\n","import type { NativeFlowMessage, NativeFlowState, NativeParams, NativeLoginOptions } from '../../types';\nimport { DestroyRef, Injectable, inject, signal } from '@angular/core';\nimport { FallbackError } from '@strivacity/sdk-core/utils/errors';\nimport { isSessionExpired, unflattenObject } from '@strivacity/sdk-core/utils';\nimport { StrivacityAuthService } from './auth.service';\n\n@Injectable()\nexport class StrivacityNativeLoginService {\n\tprivate readonly authService = inject(StrivacityAuthService);\n\tprivate readonly sdk = this.authService.sdk;\n\tprivate readonly abortController = new AbortController();\n\tprivate options: NativeLoginOptions = {};\n\n\tprivate readonly loadingSignal = signal(true);\n\tprivate readonly formsSignal = signal<Record<string, Record<string, unknown>>>({});\n\tprivate readonly messagesSignal = signal<Record<string, Record<string, NativeFlowMessage>>>({});\n\tprivate readonly stateSignal = signal<Partial<NativeFlowState>>({});\n\n\treadonly loading = this.loadingSignal.asReadonly();\n\treadonly forms = this.formsSignal.asReadonly();\n\treadonly messages = this.messagesSignal.asReadonly();\n\treadonly state = this.stateSignal.asReadonly();\n\n\tconstructor() {\n\t\tinject(DestroyRef).onDestroy(() => this.abortController.abort());\n\t}\n\n\t/**\n\t * Starts a native login flow session. Should be called once, from the page component that owns this service.\n\t *\n\t * @param {NativeLoginOptions} [options] - Optional options for the login session.\n\t */\n\tasync start(options: NativeLoginOptions = {}): Promise<void> {\n\t\tthis.options = options;\n\n\t\tawait this.sdk.init();\n\n\t\ttry {\n\t\t\tawait this.startSession(options.params);\n\t\t} catch (error) {\n\t\t\tif (error instanceof DOMException && error.name === 'AbortError') {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.sdk.logging?.error('Error fetching authorization URI', error as Error);\n\t\t\tawait this.options.onError?.(error as Error);\n\t\t\tthis.loadingSignal.set(false);\n\t\t}\n\t}\n\n\tasync submitForm(formId: string, customBody?: Record<string, unknown>): Promise<void> {\n\t\ttry {\n\t\t\tthis.loadingSignal.set(true);\n\n\t\t\tconst nextState = await this.sdk.submitForm(formId, customBody ?? unflattenObject(this.formsSignal()[formId] ?? {}));\n\n\t\t\tif (nextState) {\n\t\t\t\tawait this.handleResponse(nextState);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof FallbackError) {\n\t\t\t\tthis.sdk.logging?.error('Fallback error occurred', error);\n\t\t\t\tawait this.options.onFallback?.(error);\n\t\t\t} else {\n\t\t\t\tthis.sdk.logging?.error('Error submitting form', error as Error);\n\t\t\t\tawait this.options.onError?.(error as Error);\n\t\t\t}\n\t\t}\n\t}\n\n\tsetFormValue(formId: string, widgetId: string, value: unknown): void {\n\t\tconst forms = { ...this.formsSignal() };\n\n\t\tforms[formId] = { ...(forms[formId] ?? {}), [widgetId]: value === '' ? null : value };\n\t\tthis.formsSignal.set(forms);\n\t}\n\n\tsetMessage(formId: string, widgetId: string, value: NativeFlowMessage): void {\n\t\tconst messages = { ...this.messagesSignal() };\n\n\t\tmessages[formId] = { ...(messages[formId] ?? {}), [widgetId]: value };\n\t\tthis.messagesSignal.set(messages);\n\t}\n\n\ttriggerFallback(message?: string): void {\n\t\tthis.sdk.logging?.warn(message ? `Triggering fallback due to: ${message}` : 'Triggering fallback');\n\n\t\tconst hostedUrl = this.stateSignal().hostedUrl;\n\n\t\tif (!hostedUrl) {\n\t\t\tconst error = new Error('No hosted URL provided');\n\t\t\tthis.sdk.logging?.error('Fallback error', error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tvoid this.options.onFallback?.(new FallbackError(new URL(hostedUrl)));\n\t}\n\n\ttriggerClose(): void {\n\t\tthis.sdk.logging?.debug('Triggering close');\n\t\tvoid this.options.onClose?.();\n\t}\n\n\tprivate async startSession(loginParams: NativeParams = {}): Promise<void> {\n\t\ttry {\n\t\t\tthis.loadingSignal.set(true);\n\n\t\t\tconst nextState = await this.sdk.startSession(loginParams);\n\n\t\t\tif (nextState) {\n\t\t\t\tawait this.handleResponse(nextState);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof FallbackError) {\n\t\t\t\tthis.sdk.logging?.error('Fallback error occurred', error);\n\t\t\t\tawait this.options.onFallback?.(error);\n\t\t\t} else {\n\t\t\t\tthis.sdk.logging?.error('Error starting session', error as Error);\n\t\t\t\tawait this.options.onError?.(error as Error);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async handleResponse(nextState: Partial<NativeFlowState>): Promise<void> {\n\t\tif (this.sdk.session && !isSessionExpired(this.sdk.session)) {\n\t\t\treturn await this.options.onLogin?.(this.sdk.session);\n\t\t}\n\n\t\tconst currentState = this.stateSignal();\n\t\tconst newState: NativeFlowState = {\n\t\t\thostedUrl: nextState.hostedUrl ?? currentState.hostedUrl,\n\t\t\tfinalizeUrl: nextState.finalizeUrl ?? currentState.finalizeUrl,\n\t\t\tscreen: nextState.screen ?? currentState.screen,\n\t\t\tforms: nextState.forms ?? currentState.forms,\n\t\t\tlayout: nextState.layout ?? currentState.layout,\n\t\t\tmessages: nextState.messages ?? {},\n\t\t\tbranding: nextState.branding ?? currentState.branding,\n\t\t};\n\n\t\tif (newState.screen !== currentState.screen) {\n\t\t\tconst nextForms: Record<string, Record<string, unknown>> = {};\n\t\t\tconst nextMessages: Record<string, Record<string, NativeFlowMessage>> = {};\n\n\t\t\tfor (const form of newState.forms ?? []) {\n\t\t\t\tnextForms[form.id] = {};\n\t\t\t\tnextMessages[form.id] = {};\n\t\t\t}\n\n\t\t\tthis.formsSignal.set(nextForms);\n\t\t\tthis.messagesSignal.set(nextMessages);\n\t\t} else {\n\t\t\tthis.sdk.logging?.info(`Updating screen: ${newState.screen}`);\n\t\t}\n\n\t\tconst nextMessageMap = { ...this.messagesSignal() };\n\n\t\tfor (const formId of Object.keys(newState.messages ?? {})) {\n\t\t\tif (formId === 'global') {\n\t\t\t\tawait this.options.onGlobalMessage?.(newState.messages!.global!);\n\t\t\t} else {\n\t\t\t\tnextMessageMap[formId] = newState.messages![formId] ?? {};\n\t\t\t}\n\t\t}\n\n\t\tthis.messagesSignal.set(nextMessageMap);\n\t\tthis.stateSignal.set(newState);\n\n\t\tif (!newState.finalizeUrl) {\n\t\t\tthis.loadingSignal.set(false);\n\t\t}\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;MAKa,cAAc,GAAG,IAAI,cAAc,CAAuB,gBAAgB;AAEvF;;;;;;;;AAQG;AACG,SAAU,iBAAiB,CAAC,MAA4B,EAAA;AAC7D,IAAA,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,qBAAqB,CAAC;AAC9E;MAKa,oBAAoB,CAAA;AAChC;;;;;;;AAOG;IACH,OAAO,OAAO,CAAC,OAA6B,EAAA;QAC3C,OAAO;AACN,YAAA,QAAQ,EAAE,oBAAoB;AAC9B,YAAA,SAAS,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;SACvC;IACF;8GAdY,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA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strivacity Angular SDK client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "strivacity <opensource@strivacity.com>",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@strivacity/sdk-core": "4.0.0-beta.
|
|
35
|
+
"@strivacity/sdk-core": "4.0.0-beta.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@angular/core": ">=20",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NativeFlowMessage, NativeFlowState, NativeParams, NativeLoginOptions } from '../../types';
|
|
2
2
|
import { DestroyRef, Injectable, inject, signal } from '@angular/core';
|
|
3
3
|
import { FallbackError } from '@strivacity/sdk-core/utils/errors';
|
|
4
|
-
import { unflattenObject } from '@strivacity/sdk-core/utils';
|
|
4
|
+
import { isSessionExpired, unflattenObject } from '@strivacity/sdk-core/utils';
|
|
5
5
|
import { StrivacityAuthService } from './auth.service';
|
|
6
6
|
|
|
7
7
|
@Injectable()
|
|
@@ -122,7 +122,7 @@ export class StrivacityNativeLoginService {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
private async handleResponse(nextState: Partial<NativeFlowState>): Promise<void> {
|
|
125
|
-
if (this.sdk.session) {
|
|
125
|
+
if (this.sdk.session && !isSessionExpired(this.sdk.session)) {
|
|
126
126
|
return await this.options.onLogin?.(this.sdk.session);
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -108,7 +108,7 @@ describe('StrivacityNativeLoginService', () => {
|
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
test('calls onLogin and leaves the tracked state untouched when the sdk already has a session', async () => {
|
|
111
|
-
const session = { access_token: 'access-token' } as unknown as SessionData;
|
|
111
|
+
const session = { access_token: 'access-token', expires_at: Math.floor(Date.now() / 1000) + 3600 } as unknown as SessionData;
|
|
112
112
|
const flow = createMockFlow<NativeFlow>({ session });
|
|
113
113
|
vi.mocked(flow.startSession).mockResolvedValue({ screen: 'identifier' });
|
|
114
114
|
const onLogin = vi.fn();
|