@strivacity/sdk-angular 3.0.3 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1991 -609
- package/dist/README.md +1991 -609
- package/dist/fesm2022/strivacity-sdk-angular-src-server.mjs +221 -0
- package/dist/fesm2022/strivacity-sdk-angular-src-server.mjs.map +1 -0
- package/dist/fesm2022/strivacity-sdk-angular-src-types.mjs +6 -0
- package/dist/fesm2022/strivacity-sdk-angular-src-types.mjs.map +1 -0
- package/dist/fesm2022/strivacity-sdk-angular.mjs +284 -498
- package/dist/fesm2022/strivacity-sdk-angular.mjs.map +1 -1
- package/dist/types/strivacity-sdk-angular-src-server.d.ts +82 -0
- package/dist/types/strivacity-sdk-angular-src-types.d.ts +41 -0
- package/dist/types/strivacity-sdk-angular.d.ts +147 -0
- package/eslint.config.mjs +31 -0
- package/ng-package.json +3 -3
- package/package.json +29 -11
- package/project.json +33 -0
- package/src/index.ts +8 -0
- package/src/lib/services/auth.service.ts +131 -0
- package/src/lib/services/index.ts +2 -0
- package/src/lib/services/native-login.service.ts +172 -0
- package/src/lib/storages.ts +12 -0
- package/src/lib/utils.ts +39 -0
- package/src/server/errors.ts +1 -0
- package/src/server/index.ts +6 -0
- package/src/server/ng-package.json +6 -0
- package/src/server/sdk.ts +113 -0
- package/src/server/session.ts +30 -0
- package/src/server/storages.ts +25 -0
- package/src/server/types.ts +32 -0
- package/src/server/utils.ts +74 -0
- package/src/types/index.ts +47 -0
- package/src/types/ng-package.json +6 -0
- package/testing/setup.ts +10 -0
- package/testing/tests/auth.service.spec.ts +236 -0
- package/testing/tests/index.spec.ts +193 -0
- package/testing/tests/native-login.service.spec.ts +311 -0
- package/testing/tests/server/errors.spec.ts +14 -0
- package/testing/tests/server/sdk.spec.ts +197 -0
- package/testing/tests/server/session.spec.ts +52 -0
- package/testing/tests/server/storages.spec.ts +58 -0
- package/testing/tests/server/utils.spec.ts +112 -0
- package/testing/tests/storages.spec.ts +31 -0
- package/testing/tests/utils.spec.ts +24 -0
- package/testing/utils/testbed.ts +26 -0
- package/tsconfig.lib.json +13 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +8 -0
- package/vite.config.mts +11 -0
- package/dist/index.d.ts +0 -5
- package/dist/lib/components/login-renderer.component.d.ts +0 -38
- package/dist/lib/components/widget-renderer.component.d.ts +0 -16
- package/dist/lib/services/auth.service.d.ts +0 -93
- package/dist/lib/services/widget.service.d.ts +0 -25
- package/dist/lib/strivacity-auth.module.d.ts +0 -10
- package/dist/lib/utils/helpers.d.ts +0 -16
- package/dist/lib/utils/types.d.ts +0 -41
- package/dist/public-api.d.ts +0 -16
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Request as ExpressRequest, Response as ExpressResponse } from 'express';
|
|
2
|
+
import { Readable, Writable } from 'node:stream';
|
|
3
|
+
import { describe, test, expect, vi } from 'vitest';
|
|
4
|
+
import { applyResponse, toWebRequest } from '../../../src/server/utils';
|
|
5
|
+
|
|
6
|
+
function fakeExpressRequest(overrides: Partial<ExpressRequest> = {}): ExpressRequest {
|
|
7
|
+
return {
|
|
8
|
+
originalUrl: '/callback?code=abc',
|
|
9
|
+
protocol: 'https',
|
|
10
|
+
method: 'GET',
|
|
11
|
+
headers: {},
|
|
12
|
+
get: (name: string) => (name.toLowerCase() === 'host' ? 'brandtegrity.io' : undefined),
|
|
13
|
+
...overrides,
|
|
14
|
+
} as ExpressRequest;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe('toWebRequest', () => {
|
|
18
|
+
test('returns a standard Request unchanged', () => {
|
|
19
|
+
const request = new Request('https://brandtegrity.io');
|
|
20
|
+
|
|
21
|
+
expect(toWebRequest(request)).toBe(request);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('converts an Express request into an equivalent standard Request', () => {
|
|
25
|
+
const req = fakeExpressRequest({ headers: { 'x-foo': 'bar', 'x-multi': ['a', 'b'], 'x-missing': undefined } });
|
|
26
|
+
|
|
27
|
+
const request = toWebRequest(req);
|
|
28
|
+
|
|
29
|
+
expect(request.url).toBe('https://brandtegrity.io/callback?code=abc');
|
|
30
|
+
expect(request.method).toBe('GET');
|
|
31
|
+
expect(request.headers.get('x-foo')).toBe('bar');
|
|
32
|
+
expect(request.headers.get('x-multi')).toBe('a, b');
|
|
33
|
+
expect(request.headers.has('x-missing')).toBe(false);
|
|
34
|
+
expect(request.body).toBeNull();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('does not attach a body for a HEAD request', () => {
|
|
38
|
+
const request = toWebRequest(fakeExpressRequest({ method: 'HEAD' }));
|
|
39
|
+
|
|
40
|
+
expect(request.body).toBeNull();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('streams the request body for non-GET/HEAD requests', async () => {
|
|
44
|
+
const req = Object.assign(Readable.from(['{"a":1}']), fakeExpressRequest({ method: 'POST' })) as unknown as ExpressRequest;
|
|
45
|
+
|
|
46
|
+
const request = toWebRequest(req);
|
|
47
|
+
|
|
48
|
+
expect(request.method).toBe('POST');
|
|
49
|
+
expect(request.body).not.toBeNull();
|
|
50
|
+
await expect(request.text()).resolves.toBe('{"a":1}');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('applyResponse', () => {
|
|
55
|
+
function fakeExpressResponse() {
|
|
56
|
+
const chunks: Array<Buffer> = [];
|
|
57
|
+
const stream = new Writable({
|
|
58
|
+
write(chunk, _encoding, callback) {
|
|
59
|
+
chunks.push(chunk as Buffer);
|
|
60
|
+
callback();
|
|
61
|
+
},
|
|
62
|
+
}) as Writable & ExpressResponse;
|
|
63
|
+
|
|
64
|
+
stream.status = vi.fn().mockReturnValue(stream) as never;
|
|
65
|
+
stream.setHeader = vi.fn().mockReturnValue(stream) as never;
|
|
66
|
+
stream.end = vi.fn(Writable.prototype.end.bind(stream)) as never;
|
|
67
|
+
|
|
68
|
+
return { res: stream, chunks };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
test('sets the status and copies headers other than set-cookie', async () => {
|
|
72
|
+
const response = new Response(null, { status: 204, headers: { 'x-foo': 'bar' } });
|
|
73
|
+
const { res } = fakeExpressResponse();
|
|
74
|
+
|
|
75
|
+
await applyResponse(response, res);
|
|
76
|
+
|
|
77
|
+
expect(res.status).toHaveBeenCalledWith(204);
|
|
78
|
+
expect(res.setHeader).toHaveBeenCalledWith('x-foo', 'bar');
|
|
79
|
+
expect(res.setHeader).not.toHaveBeenCalledWith('set-cookie', expect.anything());
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('collects multiple set-cookie headers onto a single set-cookie header', async () => {
|
|
83
|
+
// appended after construction rather than passed via the Response init - this test environment's fetch
|
|
84
|
+
// polyfill silently drops every header when a set-cookie entry is present in the constructor's `headers` init
|
|
85
|
+
const response = new Response(null, { status: 200 });
|
|
86
|
+
response.headers.append('set-cookie', 'a=1');
|
|
87
|
+
response.headers.append('set-cookie', 'b=2');
|
|
88
|
+
const { res } = fakeExpressResponse();
|
|
89
|
+
|
|
90
|
+
await applyResponse(response, res);
|
|
91
|
+
|
|
92
|
+
expect(res.setHeader).toHaveBeenCalledWith('set-cookie', ['a=1', 'b=2']);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('ends the response immediately when there is no body', async () => {
|
|
96
|
+
const response = new Response(null, { status: 204 });
|
|
97
|
+
const { res } = fakeExpressResponse();
|
|
98
|
+
|
|
99
|
+
await applyResponse(response, res);
|
|
100
|
+
|
|
101
|
+
expect(res.end).toHaveBeenCalledTimes(1);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('streams a present body onto the express response', async () => {
|
|
105
|
+
const response = new Response('hello world', { status: 200 });
|
|
106
|
+
const { res, chunks } = fakeExpressResponse();
|
|
107
|
+
|
|
108
|
+
await applyResponse(response, res);
|
|
109
|
+
|
|
110
|
+
expect(Buffer.concat(chunks).toString()).toBe('hello world');
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { test, expect } from 'vitest';
|
|
2
|
+
import * as angularStorages from '../../src/lib/storages';
|
|
3
|
+
import * as coreStorages from '@strivacity/sdk-core/storages';
|
|
4
|
+
|
|
5
|
+
test('re-exports the client-safe storages verbatim from the core sdk', () => {
|
|
6
|
+
const expectedExports = [
|
|
7
|
+
'COOKIE_CONTEXT',
|
|
8
|
+
'COOKIE_CHUNK_SIZE',
|
|
9
|
+
'createCacheAPIStorage',
|
|
10
|
+
'createIndexedDBStorage',
|
|
11
|
+
'createLocalStorage',
|
|
12
|
+
'createMemoryStorage',
|
|
13
|
+
'createServerMemoryStorage',
|
|
14
|
+
'createSessionStorage',
|
|
15
|
+
'createWorkerStorage',
|
|
16
|
+
'handleWorkerStorageRequests',
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
expect(Object.keys(angularStorages).sort()).toEqual([...expectedExports].sort());
|
|
20
|
+
|
|
21
|
+
for (const key of expectedExports) {
|
|
22
|
+
expect(angularStorages[key as keyof typeof angularStorages]).toBe(coreStorages[key as keyof typeof coreStorages]);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('deliberately omits the server-only storages that need a request/cookie adapter', () => {
|
|
27
|
+
// these live in @strivacity/sdk-angular/server instead, where a request adapter is available
|
|
28
|
+
expect(angularStorages).not.toHaveProperty('createEncryptedCookieStorage');
|
|
29
|
+
expect(angularStorages).not.toHaveProperty('createServerStateStorage');
|
|
30
|
+
expect(angularStorages).not.toHaveProperty('createSessionIdCookieStorage');
|
|
31
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AngularSDKInitConfig } from '../../src/types';
|
|
2
|
+
import { describe, test, expect } from 'vitest';
|
|
3
|
+
import { StrivacityAuthService } from '../../src/lib/services/auth.service';
|
|
4
|
+
import { STRIVACITY_SDK, provideStrivacity, StrivacityAuthModule } from '../../src/lib/utils';
|
|
5
|
+
import { createOptions } from '@strivacity/testing/mocks/sdk';
|
|
6
|
+
|
|
7
|
+
describe('provideStrivacity', () => {
|
|
8
|
+
test('provides the config under STRIVACITY_SDK and registers StrivacityAuthService', () => {
|
|
9
|
+
const config = createOptions() as AngularSDKInitConfig;
|
|
10
|
+
|
|
11
|
+
expect(provideStrivacity(config)).toEqual([{ provide: STRIVACITY_SDK, useValue: config }, StrivacityAuthService]);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('StrivacityAuthModule', () => {
|
|
16
|
+
test('forRoot wraps provideStrivacity into a ModuleWithProviders', () => {
|
|
17
|
+
const config = createOptions() as AngularSDKInitConfig;
|
|
18
|
+
|
|
19
|
+
expect(StrivacityAuthModule.forRoot(config)).toEqual({
|
|
20
|
+
ngModule: StrivacityAuthModule,
|
|
21
|
+
providers: [[{ provide: STRIVACITY_SDK, useValue: config }, StrivacityAuthService]],
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Provider } from '@angular/core';
|
|
2
|
+
import { Component } from '@angular/core';
|
|
3
|
+
import { TestBed } from '@angular/core/testing';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provides `providers` at a throwaway standalone component's own injector (not the TestBed module injector), and
|
|
7
|
+
* runs `read` synchronously during that component's construction, i.e. within its injection context - so `inject(...)`
|
|
8
|
+
* calls inside `read` resolve services scoped to that component. This is what makes `fixture.destroy()` actually fire
|
|
9
|
+
* `DestroyRef.onDestroy` callbacks registered by those services: a service provided at the TestBed module level lives
|
|
10
|
+
* in the root environment injector, which `fixture.destroy()` never tears down.
|
|
11
|
+
*/
|
|
12
|
+
export function mountWithProviders<T>(providers: Provider[], read: () => T): { value: T; destroy: () => void } {
|
|
13
|
+
let value!: T;
|
|
14
|
+
|
|
15
|
+
@Component({ selector: 'test-host', template: '', standalone: true, providers })
|
|
16
|
+
class TestHostComponent {
|
|
17
|
+
constructor() {
|
|
18
|
+
value = read();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const fixture = TestBed.createComponent(TestHostComponent);
|
|
23
|
+
fixture.detectChanges();
|
|
24
|
+
|
|
25
|
+
return { value, destroy: () => fixture.destroy() };
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noEmit": false,
|
|
5
|
+
"allowImportingTsExtensions": false,
|
|
6
|
+
"outDir": "./out-tsc/lib",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"types": []
|
|
10
|
+
},
|
|
11
|
+
"include": ["./src/**/*.ts"],
|
|
12
|
+
"exclude": ["./**/*.spec.ts"]
|
|
13
|
+
}
|
package/vite.config.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import { getVitestConfig } from '@strivacity/testing/vitest/config';
|
|
3
|
+
|
|
4
|
+
const vitestConfig = getVitestConfig('angular');
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
test: {
|
|
8
|
+
...vitestConfig,
|
|
9
|
+
setupFiles: [...vitestConfig.setupFiles!, './testing/setup.ts'],
|
|
10
|
+
},
|
|
11
|
+
});
|
package/dist/index.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { OnInit, OnDestroy } from '@angular/core';
|
|
2
|
-
import type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';
|
|
3
|
-
import type { IdTokenClaims, NativeParams, WidgetType, LoginFlowState } from '@strivacity/sdk-core';
|
|
4
|
-
import { EventEmitter, Type, ViewContainerRef } from '@angular/core';
|
|
5
|
-
import { FallbackError } from '@strivacity/sdk-core';
|
|
6
|
-
import { StrivacityAuthService } from '../services/auth.service';
|
|
7
|
-
import { StrivacityWidgetService } from '../services/widget.service';
|
|
8
|
-
import * as i0 from "@angular/core";
|
|
9
|
-
export declare class StyLoginRenderer implements OnInit, OnDestroy {
|
|
10
|
-
protected authService: StrivacityAuthService<NativeFlow>;
|
|
11
|
-
protected widgetService: StrivacityWidgetService;
|
|
12
|
-
private subscriptions;
|
|
13
|
-
private createdComponentRefs;
|
|
14
|
-
loginHandler: ReturnType<StrivacityAuthService<NativeFlow>['sdk']['login']>;
|
|
15
|
-
widgets: Record<WidgetType, Type<any>>;
|
|
16
|
-
sessionId?: string | null;
|
|
17
|
-
language?: string | null;
|
|
18
|
-
params: NativeParams;
|
|
19
|
-
readonly onLogin: EventEmitter<IdTokenClaims>;
|
|
20
|
-
readonly onFallback: EventEmitter<FallbackError>;
|
|
21
|
-
readonly onClose: EventEmitter<any>;
|
|
22
|
-
readonly onError: EventEmitter<any>;
|
|
23
|
-
readonly onGlobalMessage: EventEmitter<string>;
|
|
24
|
-
readonly onBlockReady: EventEmitter<{
|
|
25
|
-
previousState: LoginFlowState;
|
|
26
|
-
state: LoginFlowState;
|
|
27
|
-
}>;
|
|
28
|
-
readonly onLanguageChange: EventEmitter<string>;
|
|
29
|
-
readonly $containerRef: ViewContainerRef;
|
|
30
|
-
constructor(authService: StrivacityAuthService<NativeFlow>, widgetService: StrivacityWidgetService);
|
|
31
|
-
ngOnInit(): void;
|
|
32
|
-
ngOnDestroy(): void;
|
|
33
|
-
init(): Promise<void>;
|
|
34
|
-
private render;
|
|
35
|
-
private clearAndDestroyComponents;
|
|
36
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<StyLoginRenderer, never>;
|
|
37
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<StyLoginRenderer, "sty-login-renderer", never, { "widgets": { "alias": "widgets"; "required": true; }; "sessionId": { "alias": "sessionId"; "required": false; }; "language": { "alias": "language"; "required": false; }; "params": { "alias": "params"; "required": false; }; }, { "onLogin": "login"; "onFallback": "fallback"; "onClose": "close"; "onError": "error"; "onGlobalMessage": "globalMessage"; "onBlockReady": "blockReady"; "onLanguageChange": "languageChange"; }, never, never, true, never>;
|
|
38
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Type, SimpleChanges, OnChanges } from '@angular/core';
|
|
2
|
-
import type { WidgetType, LayoutWidget } from '@strivacity/sdk-core';
|
|
3
|
-
import { ViewContainerRef } from '@angular/core';
|
|
4
|
-
import { StrivacityWidgetService } from '../services/widget.service';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
export declare class StyWidgetRenderer implements OnChanges {
|
|
7
|
-
protected widgetService: StrivacityWidgetService;
|
|
8
|
-
items: LayoutWidget['items'];
|
|
9
|
-
widgets: Record<WidgetType, Type<any>>;
|
|
10
|
-
readonly $containerRef: ViewContainerRef;
|
|
11
|
-
constructor(widgetService: StrivacityWidgetService);
|
|
12
|
-
ngOnChanges(changes: SimpleChanges): void;
|
|
13
|
-
render(): void;
|
|
14
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<StyWidgetRenderer, never>;
|
|
15
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<StyWidgetRenderer, "sty-widget-renderer", never, { "items": { "alias": "items"; "required": false; }; "widgets": { "alias": "widgets"; "required": true; }; }, {}, never, never, true, never>;
|
|
16
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { type Observable } from 'rxjs';
|
|
2
|
-
import type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';
|
|
3
|
-
import type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';
|
|
4
|
-
import type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';
|
|
5
|
-
import { type SDKOptions } from '@strivacity/sdk-core';
|
|
6
|
-
import type { Session } from '../utils/types';
|
|
7
|
-
import * as i0 from "@angular/core";
|
|
8
|
-
/**
|
|
9
|
-
* Service that manages Strivacity authentication flows.
|
|
10
|
-
* Supports either PopupFlow or RedirectFlow types.
|
|
11
|
-
*
|
|
12
|
-
* @template Flow Type of authentication flow (PopupFlow or RedirectFlow).
|
|
13
|
-
* @template Options Type of SDK options (defaults to SDKOptions).
|
|
14
|
-
*/
|
|
15
|
-
export declare class StrivacityAuthService<Flow extends PopupFlow | RedirectFlow | NativeFlow = PopupFlow | RedirectFlow | NativeFlow, Options extends SDKOptions = SDKOptions> {
|
|
16
|
-
options: Options;
|
|
17
|
-
/**
|
|
18
|
-
* Instance of the authentication flow (PopupFlow or RedirectFlow).
|
|
19
|
-
*/
|
|
20
|
-
sdk: Flow;
|
|
21
|
-
/**
|
|
22
|
-
* BehaviorSubject that holds the current session state.
|
|
23
|
-
* @protected
|
|
24
|
-
* @readonly
|
|
25
|
-
*/
|
|
26
|
-
private readonly sessionSubject;
|
|
27
|
-
/**
|
|
28
|
-
* Observable that emits the session state changes.
|
|
29
|
-
* @readonly
|
|
30
|
-
*/
|
|
31
|
-
readonly session$: Observable<Session>;
|
|
32
|
-
/**
|
|
33
|
-
* Creates an instance of StrivacityAuthService.
|
|
34
|
-
*
|
|
35
|
-
* @param {Options} options SDK configuration options injected via STRIVACITY_SDK.
|
|
36
|
-
*/
|
|
37
|
-
constructor(options: Options);
|
|
38
|
-
/**
|
|
39
|
-
* Checks if the user is authenticated.
|
|
40
|
-
*
|
|
41
|
-
* @returns {Observable<boolean>} An observable that emits the authentication status.
|
|
42
|
-
*/
|
|
43
|
-
isAuthenticated(): Observable<boolean>;
|
|
44
|
-
/**
|
|
45
|
-
* Logs the user in using the specified options.
|
|
46
|
-
*
|
|
47
|
-
* @param {Parameters<Flow['login']>[0]} [options] Options to customize the login behavior.
|
|
48
|
-
* @returns {Observable<void>} An observable that completes when the login process is done.
|
|
49
|
-
*/
|
|
50
|
-
login(options?: Parameters<Flow['login']>[0]): import("@strivacity/sdk-core/dist/handlers/NativeFlowHandler").NativeFlowHandler | Observable<void>;
|
|
51
|
-
/**
|
|
52
|
-
* Initiates the entry process using the provided challenge.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} [url] Optional URL to use for the entry process. If not provided, the current window location will be used.
|
|
55
|
-
* @returns {Observable<void>} An observable that completes when the entry process is done.
|
|
56
|
-
*/
|
|
57
|
-
entry(url?: string): Observable<void | Record<string, string>>;
|
|
58
|
-
/**
|
|
59
|
-
* Registers a new user using the specified options.
|
|
60
|
-
*
|
|
61
|
-
* @param {Parameters<Flow['register']>[0]} [options] Options to customize the registration behavior.
|
|
62
|
-
* @returns {Observable<void>} An observable that completes when the registration process is done.
|
|
63
|
-
*/
|
|
64
|
-
register(options?: Parameters<Flow['register']>[0]): import("@strivacity/sdk-core/dist/handlers/NativeFlowHandler").NativeFlowHandler | Observable<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Refreshes the current authentication session.
|
|
67
|
-
*
|
|
68
|
-
* @returns {Observable<void>} An observable that completes when the session is refreshed.
|
|
69
|
-
*/
|
|
70
|
-
refresh(): Observable<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Revokes the current session tokens.
|
|
73
|
-
*
|
|
74
|
-
* @returns {Observable<void>} An observable that completes when the tokens are revoked.
|
|
75
|
-
*/
|
|
76
|
-
revoke(): Observable<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Logs the user out using the specified options.
|
|
79
|
-
*
|
|
80
|
-
* @param {Parameters<Flow['logout']>[0]} [options] Options to customize the logout behavior.
|
|
81
|
-
* @returns {Observable<void>} An observable that completes when the logout process is done.
|
|
82
|
-
*/
|
|
83
|
-
logout(options?: Parameters<Flow['logout']>[0]): Observable<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Handles the authentication callback (e.g., after a redirect or popup flow).
|
|
86
|
-
*
|
|
87
|
-
* @param {Parameters<Flow['handleCallback']>[0]} [url] The URL to handle for the callback.
|
|
88
|
-
* @returns {Observable<void>} An observable that completes when the callback is handled.
|
|
89
|
-
*/
|
|
90
|
-
handleCallback(url?: Parameters<Flow['handleCallback']>[0]): Observable<void>;
|
|
91
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<StrivacityAuthService<any, any>, never>;
|
|
92
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<StrivacityAuthService<any, any>>;
|
|
93
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { LoginFlowMessage, LoginFlowState } from '@strivacity/sdk-core';
|
|
2
|
-
import { BehaviorSubject } from 'rxjs';
|
|
3
|
-
import * as i0 from "@angular/core";
|
|
4
|
-
export interface NativeFlowState {
|
|
5
|
-
loading: boolean;
|
|
6
|
-
formContexts: Record<string, Record<string, unknown>>;
|
|
7
|
-
messageContexts: Record<string, Record<string, string | null>>;
|
|
8
|
-
state: LoginFlowState;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Service that manages Strivacity native widgets.
|
|
12
|
-
*/
|
|
13
|
-
export declare class StrivacityWidgetService {
|
|
14
|
-
readonly loading$: BehaviorSubject<boolean>;
|
|
15
|
-
readonly forms$: BehaviorSubject<Record<string, Record<string, unknown>>>;
|
|
16
|
-
readonly messages$: BehaviorSubject<Record<string, Record<string, LoginFlowMessage>>>;
|
|
17
|
-
readonly state$: BehaviorSubject<LoginFlowState>;
|
|
18
|
-
triggerFallback: (hostedUrl?: string, message?: string) => void;
|
|
19
|
-
triggerClose: () => void;
|
|
20
|
-
submitForm: (formId: string) => Promise<void>;
|
|
21
|
-
setFormValue(formId: string, widgetId: string, value: unknown): void;
|
|
22
|
-
setMessage(formId: string, widgetId: string, value: LoginFlowMessage): void;
|
|
23
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<StrivacityWidgetService, never>;
|
|
24
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<StrivacityWidgetService>;
|
|
25
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ModuleWithProviders } from '@angular/core';
|
|
2
|
-
import type { SDKOptions } from '@strivacity/sdk-core';
|
|
3
|
-
import * as i0 from "@angular/core";
|
|
4
|
-
import * as i1 from "./components/login-renderer.component";
|
|
5
|
-
export declare class StrivacityAuthModule {
|
|
6
|
-
static forRoot(options: SDKOptions): ModuleWithProviders<StrivacityAuthModule>;
|
|
7
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<StrivacityAuthModule, never>;
|
|
8
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<StrivacityAuthModule, never, [typeof i1.StyLoginRenderer], [typeof i1.StyLoginRenderer]>;
|
|
9
|
-
static ɵinj: i0.ɵɵInjectorDeclaration<StrivacityAuthModule>;
|
|
10
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import type { SDKOptions } from '@strivacity/sdk-core';
|
|
3
|
-
export declare const STRIVACITY_SDK: InjectionToken<SDKOptions>;
|
|
4
|
-
/**
|
|
5
|
-
* Provides the Strivacity SDK configuration as a dependency injection token.
|
|
6
|
-
*
|
|
7
|
-
* This function is used to supply the Strivacity SDK configuration to the application
|
|
8
|
-
* by binding it to the `STRIVACITY_SDK` token.
|
|
9
|
-
*
|
|
10
|
-
* @param {SDKOptions} config The SDK configuration options.
|
|
11
|
-
* @returns {{ provide: InjectionToken<SDKOptions>, useValue: SDKOptions }} An object that provides the SDK configuration using the `STRIVACITY_SDK` token.
|
|
12
|
-
*/
|
|
13
|
-
export declare function provideStrivacity(config: SDKOptions): {
|
|
14
|
-
provide: InjectionToken<SDKOptions>;
|
|
15
|
-
useValue: SDKOptions;
|
|
16
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { IdTokenClaims } from '@strivacity/sdk-core';
|
|
2
|
-
/**
|
|
3
|
-
* Represents the current authentication session state.
|
|
4
|
-
*/
|
|
5
|
-
export type Session = {
|
|
6
|
-
/**
|
|
7
|
-
* Reactive reference to the loading state of the session.
|
|
8
|
-
* `true` when the session is initializing, otherwise `false`.
|
|
9
|
-
*/
|
|
10
|
-
loading: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Reactive reference to the user's authentication status.
|
|
13
|
-
* `true` if the user is authenticated, otherwise `false`.
|
|
14
|
-
*/
|
|
15
|
-
isAuthenticated: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Reactive reference to the claims contained in the ID token.
|
|
18
|
-
* Contains user identity and other information, or `null` if not authenticated.
|
|
19
|
-
*/
|
|
20
|
-
idTokenClaims: IdTokenClaims | null;
|
|
21
|
-
/**
|
|
22
|
-
* Reactive reference to the current access token for API authorization.
|
|
23
|
-
* `null` if the user is not authenticated or the token is unavailable.
|
|
24
|
-
*/
|
|
25
|
-
accessToken: string | null;
|
|
26
|
-
/**
|
|
27
|
-
* Reactive reference to the refresh token, used to refresh the access token.
|
|
28
|
-
* `null` if the user is not authenticated or the refresh token is unavailable.
|
|
29
|
-
*/
|
|
30
|
-
refreshToken: string | null;
|
|
31
|
-
/**
|
|
32
|
-
* Reactive reference indicating if the access token has expired.
|
|
33
|
-
* `true` if expired, otherwise `false`.
|
|
34
|
-
*/
|
|
35
|
-
accessTokenExpired: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Reactive reference to the expiration date of the access token in Unix time (milliseconds).
|
|
38
|
-
* `null` if no token is available or the session is not authenticated.
|
|
39
|
-
*/
|
|
40
|
-
accessTokenExpirationDate: number | null;
|
|
41
|
-
};
|
package/dist/public-api.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { type SDKOptions, SDKStorage, type IdTokenClaims } from '@strivacity/sdk-core';
|
|
2
|
-
export type { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow';
|
|
3
|
-
export type { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow';
|
|
4
|
-
export type { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow';
|
|
5
|
-
export * from '@strivacity/sdk-core';
|
|
6
|
-
export type * from './lib/utils/types';
|
|
7
|
-
export { HttpClient } from '@strivacity/sdk-core/utils/HttpClient';
|
|
8
|
-
export { DefaultLogging } from '@strivacity/sdk-core/utils/Logging';
|
|
9
|
-
export { LocalStorage } from '@strivacity/sdk-core/storages/LocalStorage';
|
|
10
|
-
export { SessionStorage } from '@strivacity/sdk-core/storages/SessionStorage';
|
|
11
|
-
export { createCredential, getCredential } from '@strivacity/sdk-core/utils/credentials';
|
|
12
|
-
export { StyLoginRenderer } from './lib/components/login-renderer.component';
|
|
13
|
-
export { StrivacityAuthService } from './lib/services/auth.service';
|
|
14
|
-
export { StrivacityWidgetService } from './lib/services/widget.service';
|
|
15
|
-
export { STRIVACITY_SDK, provideStrivacity } from './lib/utils/helpers';
|
|
16
|
-
export { StrivacityAuthModule } from './lib/strivacity-auth.module';
|