@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,47 @@
|
|
|
1
|
+
import type { SDKInitConfig, NativeFlowMessage, NativeParams, SessionData } from '@strivacity/sdk-core/types';
|
|
2
|
+
import type { initFlow } from '@strivacity/sdk-core';
|
|
3
|
+
import type { FallbackError } from '@strivacity/sdk-core/utils';
|
|
4
|
+
|
|
5
|
+
export * from '@strivacity/sdk-core/types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Configuration used to initialize the Strivacity SDK on the client (browser) side.
|
|
9
|
+
*/
|
|
10
|
+
export type AngularSDKInitConfig = SDKInitConfig;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The concrete SDK flow instance returned by `initFlow`, matching the configured `mode`.
|
|
14
|
+
*/
|
|
15
|
+
export type SDKInstance = ReturnType<typeof initFlow>;
|
|
16
|
+
|
|
17
|
+
export type NativeLoginOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Optional parameters to be passed to the login session request. These parameters will be sent to the `authorizationUri` endpoint.
|
|
20
|
+
*/
|
|
21
|
+
params?: NativeParams;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Called when the user successfully completes the login flow.
|
|
25
|
+
*/
|
|
26
|
+
onLogin?: (session: SessionData) => void | Promise<void>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Called when the fallback flow is triggered, typically due to an error or unsupported environment.
|
|
30
|
+
*/
|
|
31
|
+
onFallback?: (error: FallbackError) => void | Promise<void>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Called when the login flow is closed by the user.
|
|
35
|
+
*/
|
|
36
|
+
onClose?: () => void | Promise<void>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Called when an error occurs during the login session initialization or flow.
|
|
40
|
+
*/
|
|
41
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Called when a global message is received during the login flow.
|
|
45
|
+
*/
|
|
46
|
+
onGlobalMessage?: (message: NativeFlowMessage) => void | Promise<void>;
|
|
47
|
+
};
|
package/testing/setup.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import '@angular/compiler';
|
|
2
|
+
import { afterEach } from 'vitest';
|
|
3
|
+
import { getTestBed } from '@angular/core/testing';
|
|
4
|
+
import { BrowserTestingModule, platformBrowserTesting } from '@angular/platform-browser/testing';
|
|
5
|
+
|
|
6
|
+
getTestBed().initTestEnvironment(BrowserTestingModule, platformBrowserTesting());
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
getTestBed().resetTestingModule();
|
|
10
|
+
});
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type { RedirectFlow } from '../../src/types';
|
|
2
|
+
import { PLATFORM_ID, TransferState, inject } from '@angular/core';
|
|
3
|
+
import { TestBed } from '@angular/core/testing';
|
|
4
|
+
import { describe, test, expect, vi, beforeEach } from 'vitest';
|
|
5
|
+
import { initFlow } from '@strivacity/sdk-core';
|
|
6
|
+
import { StrivacityAuthService } from '../../src/lib/services/auth.service';
|
|
7
|
+
import { STRIVACITY_SDK } from '../../src/lib/utils';
|
|
8
|
+
import { SESSION_TRANSFER_KEY } from '../../src/server/session';
|
|
9
|
+
import { flushPromises } from '@strivacity/testing/mocks/common';
|
|
10
|
+
import { createMockFlow, createOptions } from '@strivacity/testing/mocks/sdk';
|
|
11
|
+
import { mountWithProviders } from '../utils/testbed';
|
|
12
|
+
|
|
13
|
+
vi.mock('@strivacity/sdk-core', async (importOriginal) => ({
|
|
14
|
+
...(await importOriginal<typeof import('@strivacity/sdk-core')>()),
|
|
15
|
+
initFlow: vi.fn(),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
function configure(flow: RedirectFlow, optionsOverrides: Record<string, unknown> = {}, extraProviders: Array<unknown> = []) {
|
|
19
|
+
vi.mocked(initFlow).mockReturnValue(flow as never);
|
|
20
|
+
|
|
21
|
+
const options = createOptions(optionsOverrides) as never;
|
|
22
|
+
|
|
23
|
+
TestBed.configureTestingModule({
|
|
24
|
+
providers: [{ provide: STRIVACITY_SDK, useValue: options }, StrivacityAuthService, ...(extraProviders as [])],
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return { authService: TestBed.inject(StrivacityAuthService), options };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
vi.mocked(initFlow).mockReset();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('StrivacityAuthService', () => {
|
|
35
|
+
test('initializes the underlying flow through core sdk initFlow with the config injected via STRIVACITY_SDK', () => {
|
|
36
|
+
const flow = createMockFlow<RedirectFlow>();
|
|
37
|
+
const { options } = configure(flow);
|
|
38
|
+
|
|
39
|
+
expect(initFlow).toHaveBeenCalledTimes(1);
|
|
40
|
+
expect(initFlow).toHaveBeenCalledWith(options);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('exposes signals seeded from the flow instance after the initial session update settles', async () => {
|
|
44
|
+
const flow = createMockFlow<RedirectFlow>({
|
|
45
|
+
isAuthenticated: Promise.resolve(true),
|
|
46
|
+
language: 'hu-HU',
|
|
47
|
+
idTokenClaims: { sub: 'user-1' },
|
|
48
|
+
accessToken: 'access-token',
|
|
49
|
+
refreshToken: 'refresh-token',
|
|
50
|
+
accessTokenExpired: false,
|
|
51
|
+
accessTokenExpirationDate: 1234,
|
|
52
|
+
});
|
|
53
|
+
const { authService } = configure(flow);
|
|
54
|
+
|
|
55
|
+
expect(authService.loading()).toBe(true);
|
|
56
|
+
|
|
57
|
+
await flushPromises();
|
|
58
|
+
|
|
59
|
+
expect(authService.loading()).toBe(false);
|
|
60
|
+
expect(authService.isAuthenticated()).toBe(true);
|
|
61
|
+
expect(authService.language()).toBe('hu-HU');
|
|
62
|
+
expect(authService.idTokenClaims()).toEqual({ sub: 'user-1' });
|
|
63
|
+
expect(authService.accessToken()).toBe('access-token');
|
|
64
|
+
expect(authService.refreshToken()).toBe('refresh-token');
|
|
65
|
+
expect(authService.accessTokenExpired()).toBe(false);
|
|
66
|
+
expect(authService.accessTokenExpirationDate()).toBe(1234);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('falls back null-ish flow values to the signals default (null) rather than storing them verbatim', async () => {
|
|
70
|
+
const flow = createMockFlow<RedirectFlow>({
|
|
71
|
+
idTokenClaims: undefined,
|
|
72
|
+
accessToken: undefined,
|
|
73
|
+
refreshToken: undefined,
|
|
74
|
+
accessTokenExpirationDate: undefined,
|
|
75
|
+
});
|
|
76
|
+
const { authService } = configure(flow);
|
|
77
|
+
|
|
78
|
+
await flushPromises();
|
|
79
|
+
|
|
80
|
+
expect(authService.idTokenClaims()).toBeNull();
|
|
81
|
+
expect(authService.accessToken()).toBeNull();
|
|
82
|
+
expect(authService.refreshToken()).toBeNull();
|
|
83
|
+
expect(authService.accessTokenExpirationDate()).toBeNull();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('updates signals when the flow emits an event through subscribeToAllEvents', async () => {
|
|
87
|
+
const subscribeToAllEvents = vi.fn().mockReturnValue({ dispose: vi.fn() });
|
|
88
|
+
const flow = createMockFlow<RedirectFlow>({ subscribeToAllEvents });
|
|
89
|
+
const { authService } = configure(flow);
|
|
90
|
+
await flushPromises();
|
|
91
|
+
|
|
92
|
+
const onEvent = subscribeToAllEvents.mock.calls[0][0] as () => Promise<void>;
|
|
93
|
+
const mutableFlow = flow as unknown as { language: string; accessToken: string | null; isAuthenticated: Promise<boolean> };
|
|
94
|
+
|
|
95
|
+
mutableFlow.language = 'de-DE';
|
|
96
|
+
mutableFlow.accessToken = 'new-token';
|
|
97
|
+
mutableFlow.isAuthenticated = Promise.resolve(true);
|
|
98
|
+
|
|
99
|
+
await onEvent();
|
|
100
|
+
await flushPromises();
|
|
101
|
+
|
|
102
|
+
expect(authService.language()).toBe('de-DE');
|
|
103
|
+
expect(authService.accessToken()).toBe('new-token');
|
|
104
|
+
expect(authService.isAuthenticated()).toBe(true);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('subscribeToAllEvents is subscribed to once on construction, wiring the internal signal-update callback', async () => {
|
|
108
|
+
const flow = createMockFlow<RedirectFlow>();
|
|
109
|
+
configure(flow);
|
|
110
|
+
await flushPromises();
|
|
111
|
+
|
|
112
|
+
expect(flow.subscribeToAllEvents).toHaveBeenCalledTimes(1);
|
|
113
|
+
expect(flow.subscribeToAllEvents).toHaveBeenCalledWith(expect.any(Function));
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('SSR session hydration via TransferState', () => {
|
|
117
|
+
test('does not touch TransferState when serverSessionUri is not configured', () => {
|
|
118
|
+
const flow = createMockFlow<RedirectFlow>({ session: null });
|
|
119
|
+
const { authService } = configure(flow, { serverSessionUri: false });
|
|
120
|
+
const transferState = TestBed.inject(TransferState);
|
|
121
|
+
|
|
122
|
+
expect(transferState.hasKey(SESSION_TRANSFER_KEY)).toBe(false);
|
|
123
|
+
expect(authService.sdk.session).toBeNull();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('leaves the flow untouched when serverSessionUri is configured but no session was transferred', () => {
|
|
127
|
+
const flow = createMockFlow<RedirectFlow>({ session: null });
|
|
128
|
+
const { authService } = configure(flow, { serverSessionUri: 'https://brandtegrity.io/session' }, [{ provide: PLATFORM_ID, useValue: 'browser' }]);
|
|
129
|
+
|
|
130
|
+
expect(authService.sdk.session).toBeNull();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('hydrates the flow session from TransferState and removes the key when running in the browser', () => {
|
|
134
|
+
const flow = createMockFlow<RedirectFlow>({ session: null });
|
|
135
|
+
const session = { access_token: 'transferred-token' };
|
|
136
|
+
|
|
137
|
+
vi.mocked(initFlow).mockReturnValue(flow as never);
|
|
138
|
+
TestBed.configureTestingModule({
|
|
139
|
+
providers: [
|
|
140
|
+
{ provide: STRIVACITY_SDK, useValue: createOptions({ serverSessionUri: 'https://brandtegrity.io/session' }) },
|
|
141
|
+
{ provide: PLATFORM_ID, useValue: 'browser' },
|
|
142
|
+
StrivacityAuthService,
|
|
143
|
+
],
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// setting the transferred value before the first inject() matters: StrivacityAuthService only reads it once, in its constructor
|
|
147
|
+
const transferState = TestBed.inject(TransferState);
|
|
148
|
+
transferState.set(SESSION_TRANSFER_KEY, session);
|
|
149
|
+
|
|
150
|
+
const authService = TestBed.inject(StrivacityAuthService);
|
|
151
|
+
|
|
152
|
+
expect(authService.sdk.session).toBe(session);
|
|
153
|
+
// the browser is done with the transferred value once hydrated - keeping it around would leak stale session data into TransferState's serialized snapshot
|
|
154
|
+
expect(transferState.hasKey(SESSION_TRANSFER_KEY)).toBe(false);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('hydrates the flow session from TransferState but keeps the key when running on the server', () => {
|
|
158
|
+
const flow = createMockFlow<RedirectFlow>({ session: null });
|
|
159
|
+
const session = { access_token: 'transferred-token' };
|
|
160
|
+
|
|
161
|
+
vi.mocked(initFlow).mockReturnValue(flow as never);
|
|
162
|
+
TestBed.configureTestingModule({
|
|
163
|
+
providers: [
|
|
164
|
+
{ provide: STRIVACITY_SDK, useValue: createOptions({ serverSessionUri: 'https://brandtegrity.io/session' }) },
|
|
165
|
+
{ provide: PLATFORM_ID, useValue: 'server' },
|
|
166
|
+
StrivacityAuthService,
|
|
167
|
+
],
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const transferState = TestBed.inject(TransferState);
|
|
171
|
+
transferState.set(SESSION_TRANSFER_KEY, session);
|
|
172
|
+
|
|
173
|
+
const authService = TestBed.inject(StrivacityAuthService);
|
|
174
|
+
|
|
175
|
+
expect(authService.sdk.session).toBe(session);
|
|
176
|
+
expect(transferState.hasKey(SESSION_TRANSFER_KEY)).toBe(true);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test('disposes the subscribeToAllEvents subscription when the owning injector is destroyed', () => {
|
|
181
|
+
const dispose = vi.fn();
|
|
182
|
+
const flow = createMockFlow<RedirectFlow>({ subscribeToAllEvents: vi.fn().mockReturnValue({ dispose }) });
|
|
183
|
+
|
|
184
|
+
vi.mocked(initFlow).mockReturnValue(flow as never);
|
|
185
|
+
TestBed.configureTestingModule({ providers: [{ provide: STRIVACITY_SDK, useValue: createOptions() }] });
|
|
186
|
+
|
|
187
|
+
// StrivacityAuthService must be provided at the component's own injector (not the TestBed module injector) for
|
|
188
|
+
// fixture.destroy() to actually tear down the injector that owns its DestroyRef - see mountWithProviders' docstring.
|
|
189
|
+
const { destroy } = mountWithProviders([StrivacityAuthService], () => inject(StrivacityAuthService));
|
|
190
|
+
|
|
191
|
+
expect(flow.subscribeToAllEvents).toHaveBeenCalledTimes(1);
|
|
192
|
+
expect(dispose).not.toHaveBeenCalled();
|
|
193
|
+
|
|
194
|
+
destroy();
|
|
195
|
+
|
|
196
|
+
expect(dispose).toHaveBeenCalledTimes(1);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test.each([
|
|
200
|
+
['init', []],
|
|
201
|
+
['subscribeToEvent', ['loggedIn', vi.fn()]],
|
|
202
|
+
['checkAuthentication', [{ autoRefresh: false }]],
|
|
203
|
+
['tokenExchange', [{ code: 'abc' }]],
|
|
204
|
+
['handleCallback', ['https://brandtegrity.io/callback?code=abc']],
|
|
205
|
+
['refresh', []],
|
|
206
|
+
['revoke', []],
|
|
207
|
+
['logout', [{ postLogoutRedirectUri: 'https://brandtegrity.io' }]],
|
|
208
|
+
['login', [{ scopes: ['openid'] }]],
|
|
209
|
+
['register', [{ scopes: ['openid'] }]],
|
|
210
|
+
['entry', ['https://brandtegrity.io/entry']],
|
|
211
|
+
] as const)('%s calls through to the underlying flow instance with the same arguments and return value', async (method, args) => {
|
|
212
|
+
const resolvedValue = { ok: true };
|
|
213
|
+
const flow = createMockFlow<RedirectFlow>({ [method]: vi.fn().mockResolvedValue(resolvedValue) });
|
|
214
|
+
const { authService } = configure(flow);
|
|
215
|
+
|
|
216
|
+
const result = await (authService[method as keyof StrivacityAuthService] as (...a: Array<unknown>) => unknown)(...(args as Array<unknown>));
|
|
217
|
+
|
|
218
|
+
expect(flow[method as keyof RedirectFlow]).toHaveBeenCalledWith(...args);
|
|
219
|
+
expect(result).toEqual(resolvedValue);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test('subscribeToAllEvents on the service calls through to the flow instance for the caller-facing subscription', async () => {
|
|
223
|
+
const callback = vi.fn();
|
|
224
|
+
const disposeResult = { dispose: vi.fn() };
|
|
225
|
+
const flow = createMockFlow<RedirectFlow>();
|
|
226
|
+
vi.mocked(flow.subscribeToAllEvents).mockReturnValue(disposeResult);
|
|
227
|
+
|
|
228
|
+
const { authService } = configure(flow);
|
|
229
|
+
await flushPromises();
|
|
230
|
+
|
|
231
|
+
const result = authService.subscribeToAllEvents(callback);
|
|
232
|
+
|
|
233
|
+
expect(flow.subscribeToAllEvents).toHaveBeenLastCalledWith(callback);
|
|
234
|
+
expect(result).toBe(disposeResult);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { describe, test, expect } from 'vitest';
|
|
2
|
+
import * as clientIndex from '../../src/index';
|
|
3
|
+
import * as serverIndex from '../../src/server/index';
|
|
4
|
+
|
|
5
|
+
describe('client', () => {
|
|
6
|
+
test('should export the correct things', () => {
|
|
7
|
+
const expectedExports = [
|
|
8
|
+
'createBaseFlow',
|
|
9
|
+
'createEmbeddedFlow',
|
|
10
|
+
'createNativeFlow',
|
|
11
|
+
'createPopupFlow',
|
|
12
|
+
'createRedirectFlow',
|
|
13
|
+
'popupCallbackHandler',
|
|
14
|
+
'popupUrlHandler',
|
|
15
|
+
'redirectCallbackHandler',
|
|
16
|
+
'redirectUrlHandler',
|
|
17
|
+
'BACKCHANNEL_LOGOUT_EVENT',
|
|
18
|
+
'ConfigurationError',
|
|
19
|
+
'DEFAULT_COOKIE_MAX_AGE',
|
|
20
|
+
'DISALLOWED_PROXY_HEADERS',
|
|
21
|
+
'FallbackError',
|
|
22
|
+
'InternalError',
|
|
23
|
+
'NetworkError',
|
|
24
|
+
'OidcError',
|
|
25
|
+
'PopupBlockedError',
|
|
26
|
+
'PopupClosedError',
|
|
27
|
+
'ProtocolError',
|
|
28
|
+
'RETURN_TO_COOKIE',
|
|
29
|
+
'ServerError',
|
|
30
|
+
'SessionExpiredError',
|
|
31
|
+
'UnsupportedFlowError',
|
|
32
|
+
'assertWebAuthnCredential',
|
|
33
|
+
'buildAuthorizationUrl',
|
|
34
|
+
'buildCookieString',
|
|
35
|
+
'buildEndSessionUrl',
|
|
36
|
+
'createDefaultLogging',
|
|
37
|
+
'createHttpClient',
|
|
38
|
+
'createSession',
|
|
39
|
+
'createState',
|
|
40
|
+
'createWebAuthnCredential',
|
|
41
|
+
'decodeBase64URL',
|
|
42
|
+
'decodeJwt',
|
|
43
|
+
'decryptString',
|
|
44
|
+
'defaultOptions',
|
|
45
|
+
'encodeBase64URL',
|
|
46
|
+
'encryptString',
|
|
47
|
+
'exchangeCode',
|
|
48
|
+
'fetchFlowEntry',
|
|
49
|
+
'finalizeLoginSession',
|
|
50
|
+
'flushSetCookies',
|
|
51
|
+
'generateCodeChallenge',
|
|
52
|
+
'generateCodeVerifier',
|
|
53
|
+
'generateJwt',
|
|
54
|
+
'generateRandomHex',
|
|
55
|
+
'getDefaultFlowState',
|
|
56
|
+
'getDiscoveryDocument',
|
|
57
|
+
'getSDKOptions',
|
|
58
|
+
'getServerSDKOptions',
|
|
59
|
+
'injectScript',
|
|
60
|
+
'isSessionExpired',
|
|
61
|
+
'loadSession',
|
|
62
|
+
'parseCookieHeader',
|
|
63
|
+
'parseState',
|
|
64
|
+
'proxyResponse',
|
|
65
|
+
'pushSetCookie',
|
|
66
|
+
'refreshToken',
|
|
67
|
+
'revokeToken',
|
|
68
|
+
'serializeCookie',
|
|
69
|
+
'serializeSession',
|
|
70
|
+
'serializeState',
|
|
71
|
+
'submitLoginForm',
|
|
72
|
+
'throwHttpError',
|
|
73
|
+
'throwTokenEndpointError',
|
|
74
|
+
'timestamp',
|
|
75
|
+
'toSafeRedirect',
|
|
76
|
+
'unflattenObject',
|
|
77
|
+
'verifyIdToken',
|
|
78
|
+
'verifyJwt',
|
|
79
|
+
'StrivacityAuthService',
|
|
80
|
+
'StrivacityNativeLoginService',
|
|
81
|
+
'COOKIE_CONTEXT',
|
|
82
|
+
'COOKIE_CHUNK_SIZE',
|
|
83
|
+
'createCacheAPIStorage',
|
|
84
|
+
'createIndexedDBStorage',
|
|
85
|
+
'createLocalStorage',
|
|
86
|
+
'createMemoryStorage',
|
|
87
|
+
'createServerMemoryStorage',
|
|
88
|
+
'createSessionStorage',
|
|
89
|
+
'createWorkerStorage',
|
|
90
|
+
'handleWorkerStorageRequests',
|
|
91
|
+
'STRIVACITY_SDK',
|
|
92
|
+
'provideStrivacity',
|
|
93
|
+
'StrivacityAuthModule',
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
expect(Object.keys(clientIndex)).toEqual(expectedExports);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('server', () => {
|
|
101
|
+
test('should export the correct things', () => {
|
|
102
|
+
const expectedExports = [
|
|
103
|
+
'ConfigurationError',
|
|
104
|
+
'FallbackError',
|
|
105
|
+
'InternalError',
|
|
106
|
+
'NetworkError',
|
|
107
|
+
'OidcError',
|
|
108
|
+
'PopupBlockedError',
|
|
109
|
+
'PopupClosedError',
|
|
110
|
+
'ProtocolError',
|
|
111
|
+
'ServerError',
|
|
112
|
+
'SessionExpiredError',
|
|
113
|
+
'UnsupportedFlowError',
|
|
114
|
+
'throwHttpError',
|
|
115
|
+
'throwTokenEndpointError',
|
|
116
|
+
'createServerSDK',
|
|
117
|
+
'SESSION_TRANSFER_KEY',
|
|
118
|
+
'provideStrivacityServerSession',
|
|
119
|
+
'createSessionIdCookieStorage',
|
|
120
|
+
'COOKIE_CHUNK_SIZE',
|
|
121
|
+
'COOKIE_CONTEXT',
|
|
122
|
+
'createCacheAPIStorage',
|
|
123
|
+
'createEncryptedCookieStorage',
|
|
124
|
+
'createIndexedDBStorage',
|
|
125
|
+
'createLocalStorage',
|
|
126
|
+
'createMemoryStorage',
|
|
127
|
+
'createServerMemoryStorage',
|
|
128
|
+
'createServerStateStorage',
|
|
129
|
+
'createSessionStorage',
|
|
130
|
+
'createWorkerStorage',
|
|
131
|
+
'handleWorkerStorageRequests',
|
|
132
|
+
'AlgorithmTypeList',
|
|
133
|
+
'GrantTypeList',
|
|
134
|
+
'ResponseModeList',
|
|
135
|
+
'ResponseTypeList',
|
|
136
|
+
'SubjectTypeList',
|
|
137
|
+
'TokenEndpointAuthMethodList',
|
|
138
|
+
'toWebRequest',
|
|
139
|
+
'applyResponse',
|
|
140
|
+
'BACKCHANNEL_LOGOUT_EVENT',
|
|
141
|
+
'DEFAULT_COOKIE_MAX_AGE',
|
|
142
|
+
'DISALLOWED_PROXY_HEADERS',
|
|
143
|
+
'RETURN_TO_COOKIE',
|
|
144
|
+
'assertWebAuthnCredential',
|
|
145
|
+
'buildAuthorizationUrl',
|
|
146
|
+
'buildCookieString',
|
|
147
|
+
'buildEndSessionUrl',
|
|
148
|
+
'createDefaultLogging',
|
|
149
|
+
'createHttpClient',
|
|
150
|
+
'createSession',
|
|
151
|
+
'createState',
|
|
152
|
+
'createWebAuthnCredential',
|
|
153
|
+
'decodeBase64URL',
|
|
154
|
+
'decodeJwt',
|
|
155
|
+
'decryptString',
|
|
156
|
+
'defaultOptions',
|
|
157
|
+
'encodeBase64URL',
|
|
158
|
+
'encryptString',
|
|
159
|
+
'exchangeCode',
|
|
160
|
+
'fetchFlowEntry',
|
|
161
|
+
'finalizeLoginSession',
|
|
162
|
+
'flushSetCookies',
|
|
163
|
+
'generateCodeChallenge',
|
|
164
|
+
'generateCodeVerifier',
|
|
165
|
+
'generateJwt',
|
|
166
|
+
'generateRandomHex',
|
|
167
|
+
'getDefaultFlowState',
|
|
168
|
+
'getDiscoveryDocument',
|
|
169
|
+
'getSDKOptions',
|
|
170
|
+
'getServerSDKOptions',
|
|
171
|
+
'injectScript',
|
|
172
|
+
'isSessionExpired',
|
|
173
|
+
'loadSession',
|
|
174
|
+
'parseCookieHeader',
|
|
175
|
+
'parseState',
|
|
176
|
+
'proxyResponse',
|
|
177
|
+
'pushSetCookie',
|
|
178
|
+
'refreshToken',
|
|
179
|
+
'revokeToken',
|
|
180
|
+
'serializeCookie',
|
|
181
|
+
'serializeSession',
|
|
182
|
+
'serializeState',
|
|
183
|
+
'submitLoginForm',
|
|
184
|
+
'timestamp',
|
|
185
|
+
'toSafeRedirect',
|
|
186
|
+
'unflattenObject',
|
|
187
|
+
'verifyIdToken',
|
|
188
|
+
'verifyJwt',
|
|
189
|
+
];
|
|
190
|
+
|
|
191
|
+
expect(Object.keys(serverIndex)).toEqual(expectedExports);
|
|
192
|
+
});
|
|
193
|
+
});
|