@descope/angular-sdk 0.5.11 → 0.5.12
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/package.json +17 -13
- package/.eslintrc.json +0 -41
- package/.prettierrc +0 -7
- package/CHANGELOG.md +0 -5
- package/angular.json +0 -154
- package/jest.config.js +0 -17
- package/project.json +0 -17
- package/projects/angular-sdk/.eslintrc.json +0 -32
- package/projects/angular-sdk/ng-package.json +0 -17
- package/projects/angular-sdk/package.json +0 -87
- package/projects/angular-sdk/src/environment.ts +0 -3
- package/projects/angular-sdk/src/lib/components/access-key-management/access-key-management.component.spec.ts +0 -84
- package/projects/angular-sdk/src/lib/components/access-key-management/access-key-management.component.ts +0 -63
- package/projects/angular-sdk/src/lib/components/audit-management/audit-management.component.spec.ts +0 -84
- package/projects/angular-sdk/src/lib/components/audit-management/audit-management.component.ts +0 -63
- package/projects/angular-sdk/src/lib/components/descope/descope.component.spec.ts +0 -142
- package/projects/angular-sdk/src/lib/components/descope/descope.component.ts +0 -171
- package/projects/angular-sdk/src/lib/components/role-management/role-management.component.spec.ts +0 -84
- package/projects/angular-sdk/src/lib/components/role-management/role-management.component.ts +0 -63
- package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.html +0 -17
- package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.spec.ts +0 -53
- package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.ts +0 -35
- package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.html +0 -17
- package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.spec.ts +0 -51
- package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.ts +0 -35
- package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.html +0 -17
- package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.spec.ts +0 -53
- package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.ts +0 -35
- package/projects/angular-sdk/src/lib/components/user-management/user-management.component.spec.ts +0 -84
- package/projects/angular-sdk/src/lib/components/user-management/user-management.component.ts +0 -64
- package/projects/angular-sdk/src/lib/components/user-profile/user-profile.component.spec.ts +0 -93
- package/projects/angular-sdk/src/lib/components/user-profile/user-profile.component.ts +0 -77
- package/projects/angular-sdk/src/lib/descope-auth.module.ts +0 -61
- package/projects/angular-sdk/src/lib/services/descope-auth.guard.spec.ts +0 -76
- package/projects/angular-sdk/src/lib/services/descope-auth.guard.ts +0 -16
- package/projects/angular-sdk/src/lib/services/descope-auth.service.spec.ts +0 -309
- package/projects/angular-sdk/src/lib/services/descope-auth.service.ts +0 -200
- package/projects/angular-sdk/src/lib/services/descope.interceptor.spec.ts +0 -102
- package/projects/angular-sdk/src/lib/services/descope.interceptor.ts +0 -76
- package/projects/angular-sdk/src/lib/types/types.ts +0 -15
- package/projects/angular-sdk/src/lib/utils/constants.ts +0 -8
- package/projects/angular-sdk/src/lib/utils/helpers.spec.ts +0 -103
- package/projects/angular-sdk/src/lib/utils/helpers.ts +0 -36
- package/projects/angular-sdk/src/public-api.ts +0 -18
- package/projects/angular-sdk/tsconfig.lib.json +0 -12
- package/projects/angular-sdk/tsconfig.lib.prod.json +0 -10
- package/projects/angular-sdk/tsconfig.spec.json +0 -11
- package/projects/demo-app/.eslintrc.json +0 -31
- package/projects/demo-app/src/app/app-routing.module.ts +0 -33
- package/projects/demo-app/src/app/app.component.html +0 -3
- package/projects/demo-app/src/app/app.component.scss +0 -18
- package/projects/demo-app/src/app/app.component.spec.ts +0 -37
- package/projects/demo-app/src/app/app.component.ts +0 -8
- package/projects/demo-app/src/app/app.module.ts +0 -63
- package/projects/demo-app/src/app/home/home.component.html +0 -32
- package/projects/demo-app/src/app/home/home.component.scss +0 -15
- package/projects/demo-app/src/app/home/home.component.spec.ts +0 -44
- package/projects/demo-app/src/app/home/home.component.ts +0 -85
- package/projects/demo-app/src/app/interceptor/auth.interceptor.ts +0 -20
- package/projects/demo-app/src/app/login/login.component.html +0 -20
- package/projects/demo-app/src/app/login/login.component.spec.ts +0 -42
- package/projects/demo-app/src/app/login/login.component.ts +0 -41
- package/projects/demo-app/src/app/manage-access-keys/manage-access-keys.component.html +0 -12
- package/projects/demo-app/src/app/manage-access-keys/manage-access-keys.component.spec.ts +0 -36
- package/projects/demo-app/src/app/manage-access-keys/manage-access-keys.component.ts +0 -15
- package/projects/demo-app/src/app/manage-audit/manage-audit.component.html +0 -6
- package/projects/demo-app/src/app/manage-audit/manage-audit.component.spec.ts +0 -36
- package/projects/demo-app/src/app/manage-audit/manage-audit.component.ts +0 -15
- package/projects/demo-app/src/app/manage-roles/manage-roles.component.html +0 -6
- package/projects/demo-app/src/app/manage-roles/manage-roles.component.spec.ts +0 -36
- package/projects/demo-app/src/app/manage-roles/manage-roles.component.ts +0 -15
- package/projects/demo-app/src/app/manage-users/manage-users.component.html +0 -6
- package/projects/demo-app/src/app/manage-users/manage-users.component.spec.ts +0 -36
- package/projects/demo-app/src/app/manage-users/manage-users.component.ts +0 -15
- package/projects/demo-app/src/app/my-user-profile/my-user-profile.component.html +0 -6
- package/projects/demo-app/src/app/my-user-profile/my-user-profile.component.spec.ts +0 -36
- package/projects/demo-app/src/app/my-user-profile/my-user-profile.component.ts +0 -20
- package/projects/demo-app/src/app/my-user-profile/my-user-profile.scss +0 -18
- package/projects/demo-app/src/app/protected/protected.component.html +0 -18
- package/projects/demo-app/src/app/protected/protected.component.scss +0 -8
- package/projects/demo-app/src/app/protected/protected.component.spec.ts +0 -42
- package/projects/demo-app/src/app/protected/protected.component.ts +0 -41
- package/projects/demo-app/src/assets/.gitkeep +0 -0
- package/projects/demo-app/src/environments/conifg.ts +0 -14
- package/projects/demo-app/src/environments/environment.ts +0 -20
- package/projects/demo-app/src/favicon.ico +0 -0
- package/projects/demo-app/src/index.html +0 -17
- package/projects/demo-app/src/main.ts +0 -7
- package/projects/demo-app/src/styles.scss +0 -21
- package/projects/demo-app/tsconfig.app.json +0 -11
- package/projects/demo-app/tsconfig.spec.json +0 -10
- package/scripts/setversion/setversion.js +0 -20
- package/setup-jest.ts +0 -1
- package/tsconfig.json +0 -36
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HttpHandlerFn,
|
|
3
|
-
HttpInterceptorFn,
|
|
4
|
-
HttpRequest
|
|
5
|
-
} from '@angular/common/http';
|
|
6
|
-
import { inject } from '@angular/core';
|
|
7
|
-
import { DescopeAuthService } from '../../../../angular-sdk/src/lib/services/descope-auth.service';
|
|
8
|
-
|
|
9
|
-
export const authenticationInterceptor: HttpInterceptorFn = (
|
|
10
|
-
req: HttpRequest<unknown>,
|
|
11
|
-
next: HttpHandlerFn
|
|
12
|
-
) => {
|
|
13
|
-
const authService = inject(DescopeAuthService);
|
|
14
|
-
const sessionToken = authService.getSessionToken();
|
|
15
|
-
const modifiedReq = req.clone({
|
|
16
|
-
headers: req.headers.set('Authorization', `Bearer ${sessionToken}`)
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return next(modifiedReq);
|
|
20
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<descope
|
|
2
|
-
(success)="onSuccess($event)"
|
|
3
|
-
(error)="onError($event)"
|
|
4
|
-
(ready)="onReady()"
|
|
5
|
-
[theme]="theme"
|
|
6
|
-
[flowId]="flowId"
|
|
7
|
-
[locale]="locale"
|
|
8
|
-
[redirectUrl]="redirectUrl"
|
|
9
|
-
[telemetryKey]="telemetryKey"
|
|
10
|
-
[tenant]="tenantId"
|
|
11
|
-
[debug]="debugMode"
|
|
12
|
-
[errorTransformer]="errorTransformer"
|
|
13
|
-
></descope>
|
|
14
|
-
<div
|
|
15
|
-
*ngIf="isLoading"
|
|
16
|
-
class="loading-indicator"
|
|
17
|
-
style="display: flex; justify-content: center; align-items: center"
|
|
18
|
-
>
|
|
19
|
-
Loading...
|
|
20
|
-
</div>
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { LoginComponent } from './login.component';
|
|
4
|
-
import createSdk from '@descope/web-js-sdk';
|
|
5
|
-
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
6
|
-
import { DescopeAuthConfig } from '../../../../angular-sdk/src/lib/types/types';
|
|
7
|
-
import mocked = jest.mocked;
|
|
8
|
-
|
|
9
|
-
jest.mock('@descope/web-js-sdk');
|
|
10
|
-
|
|
11
|
-
describe('LoginComponent', () => {
|
|
12
|
-
let component: LoginComponent;
|
|
13
|
-
let fixture: ComponentFixture<LoginComponent>;
|
|
14
|
-
|
|
15
|
-
let mockedCreateSdk: jest.Mock;
|
|
16
|
-
const onSessionTokenChangeSpy = jest.fn();
|
|
17
|
-
const onUserChangeSpy = jest.fn();
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
mockedCreateSdk = mocked(createSdk);
|
|
21
|
-
mockedCreateSdk.mockReturnValue({
|
|
22
|
-
onSessionTokenChange: onSessionTokenChangeSpy,
|
|
23
|
-
onUserChange: onUserChangeSpy
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
TestBed.configureTestingModule({
|
|
27
|
-
schemas: [NO_ERRORS_SCHEMA],
|
|
28
|
-
declarations: [LoginComponent],
|
|
29
|
-
providers: [
|
|
30
|
-
DescopeAuthConfig,
|
|
31
|
-
{ provide: DescopeAuthConfig, useValue: { projectId: 'test' } }
|
|
32
|
-
]
|
|
33
|
-
});
|
|
34
|
-
fixture = TestBed.createComponent(LoginComponent);
|
|
35
|
-
component = fixture.componentInstance;
|
|
36
|
-
fixture.detectChanges();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should create', () => {
|
|
40
|
-
expect(component).toBeTruthy();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
2
|
-
import { environment } from '../../environments/environment';
|
|
3
|
-
import { Router } from '@angular/router';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'app-login',
|
|
7
|
-
templateUrl: './login.component.html'
|
|
8
|
-
})
|
|
9
|
-
export class LoginComponent {
|
|
10
|
-
flowId = environment.descopeFlowId ?? 'sign-up-or-in';
|
|
11
|
-
theme = (environment.descopeTheme as 'light' | 'dark' | 'os') ?? 'os';
|
|
12
|
-
telemetryKey = environment.descopeTelemetryKey ?? '';
|
|
13
|
-
debugMode = environment.descopeDebugMode ?? false;
|
|
14
|
-
tenantId = environment.descopeTenantId ?? '';
|
|
15
|
-
locale = environment.descopeLocale ?? '';
|
|
16
|
-
redirectUrl = environment.descopeRedirectUrl ?? '';
|
|
17
|
-
|
|
18
|
-
isLoading = true;
|
|
19
|
-
|
|
20
|
-
constructor(private router: Router) {}
|
|
21
|
-
|
|
22
|
-
errorTransformer = (error: { text: string; type: string }): string => {
|
|
23
|
-
const translationMap: { [key: string]: string } = {
|
|
24
|
-
SAMLStartFailed: 'Failed to start SAML flow'
|
|
25
|
-
};
|
|
26
|
-
return translationMap[error.type] || error.text;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
onSuccess(e: CustomEvent) {
|
|
30
|
-
console.log('SUCCESSFULLY LOGGED IN FROM WEB COMPONENT', e.detail);
|
|
31
|
-
this.router.navigate(['/']).catch((err) => console.error(err));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
onError(e: CustomEvent) {
|
|
35
|
-
console.log('ERROR FROM LOG IN FLOW FROM WEB COMPONENT', e);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
onReady() {
|
|
39
|
-
this.isLoading = false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<access-key-management
|
|
2
|
-
[tenant]="tenant"
|
|
3
|
-
[theme]="theme"
|
|
4
|
-
[debug]="debugMode"
|
|
5
|
-
widgetId="access-key-management-widget"
|
|
6
|
-
/>
|
|
7
|
-
<access-key-management
|
|
8
|
-
[tenant]="tenant"
|
|
9
|
-
[theme]="theme"
|
|
10
|
-
[debug]="debugMode"
|
|
11
|
-
widgetId="user-access-key-management-widget"
|
|
12
|
-
/>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { ManageAccessKeysComponent } from './manage-access-keys.component';
|
|
3
|
-
import createSdk from '@descope/web-js-sdk';
|
|
4
|
-
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
5
|
-
import { DescopeAuthConfig } from '../../../../angular-sdk/src/lib/types/types';
|
|
6
|
-
import mocked = jest.mocked;
|
|
7
|
-
|
|
8
|
-
jest.mock('@descope/web-js-sdk');
|
|
9
|
-
|
|
10
|
-
describe('ManageAccessKeysComponent', () => {
|
|
11
|
-
let component: ManageAccessKeysComponent;
|
|
12
|
-
let fixture: ComponentFixture<ManageAccessKeysComponent>;
|
|
13
|
-
|
|
14
|
-
let mockedCreateSdk: jest.Mock;
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
mockedCreateSdk = mocked(createSdk);
|
|
18
|
-
mockedCreateSdk.mockReturnValue({});
|
|
19
|
-
|
|
20
|
-
TestBed.configureTestingModule({
|
|
21
|
-
schemas: [NO_ERRORS_SCHEMA],
|
|
22
|
-
declarations: [ManageAccessKeysComponent],
|
|
23
|
-
providers: [
|
|
24
|
-
DescopeAuthConfig,
|
|
25
|
-
{ provide: DescopeAuthConfig, useValue: { projectId: 'test' } }
|
|
26
|
-
]
|
|
27
|
-
});
|
|
28
|
-
fixture = TestBed.createComponent(ManageAccessKeysComponent);
|
|
29
|
-
component = fixture.componentInstance;
|
|
30
|
-
fixture.detectChanges();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should create', () => {
|
|
34
|
-
expect(component).toBeTruthy();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
2
|
-
import { environment } from '../../environments/environment';
|
|
3
|
-
import { Router } from '@angular/router';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'app-manage-access-keys',
|
|
7
|
-
templateUrl: './manage-access-keys.component.html'
|
|
8
|
-
})
|
|
9
|
-
export class ManageAccessKeysComponent {
|
|
10
|
-
theme = (environment.descopeTheme as 'light' | 'dark' | 'os') ?? 'os';
|
|
11
|
-
debugMode = environment.descopeDebugMode ?? false;
|
|
12
|
-
tenant = environment.descopeTenantId ?? '';
|
|
13
|
-
|
|
14
|
-
constructor(private _: Router) {}
|
|
15
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { ManageAuditComponent } from './manage-audit.component';
|
|
3
|
-
import createSdk from '@descope/web-js-sdk';
|
|
4
|
-
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
5
|
-
import { DescopeAuthConfig } from '../../../../angular-sdk/src/lib/types/types';
|
|
6
|
-
import mocked = jest.mocked;
|
|
7
|
-
|
|
8
|
-
jest.mock('@descope/web-js-sdk');
|
|
9
|
-
|
|
10
|
-
describe('ManageAuditComponent', () => {
|
|
11
|
-
let component: ManageAuditComponent;
|
|
12
|
-
let fixture: ComponentFixture<ManageAuditComponent>;
|
|
13
|
-
|
|
14
|
-
let mockedCreateSdk: jest.Mock;
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
mockedCreateSdk = mocked(createSdk);
|
|
18
|
-
mockedCreateSdk.mockReturnValue({});
|
|
19
|
-
|
|
20
|
-
TestBed.configureTestingModule({
|
|
21
|
-
schemas: [NO_ERRORS_SCHEMA],
|
|
22
|
-
declarations: [ManageAuditComponent],
|
|
23
|
-
providers: [
|
|
24
|
-
DescopeAuthConfig,
|
|
25
|
-
{ provide: DescopeAuthConfig, useValue: { projectId: 'test' } }
|
|
26
|
-
]
|
|
27
|
-
});
|
|
28
|
-
fixture = TestBed.createComponent(ManageAuditComponent);
|
|
29
|
-
component = fixture.componentInstance;
|
|
30
|
-
fixture.detectChanges();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should create', () => {
|
|
34
|
-
expect(component).toBeTruthy();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
2
|
-
import { environment } from '../../environments/environment';
|
|
3
|
-
import { Router } from '@angular/router';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'app-manage-audit',
|
|
7
|
-
templateUrl: './manage-audit.component.html'
|
|
8
|
-
})
|
|
9
|
-
export class ManageAuditComponent {
|
|
10
|
-
theme = (environment.descopeTheme as 'light' | 'dark' | 'os') ?? 'os';
|
|
11
|
-
debugMode = environment.descopeDebugMode ?? false;
|
|
12
|
-
tenant = environment.descopeTenantId ?? '';
|
|
13
|
-
|
|
14
|
-
constructor(private _: Router) {}
|
|
15
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { ManageRolesComponent } from './manage-roles.component';
|
|
3
|
-
import createSdk from '@descope/web-js-sdk';
|
|
4
|
-
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
5
|
-
import { DescopeAuthConfig } from '../../../../angular-sdk/src/lib/types/types';
|
|
6
|
-
import mocked = jest.mocked;
|
|
7
|
-
|
|
8
|
-
jest.mock('@descope/web-js-sdk');
|
|
9
|
-
|
|
10
|
-
describe('ManageRolesComponent', () => {
|
|
11
|
-
let component: ManageRolesComponent;
|
|
12
|
-
let fixture: ComponentFixture<ManageRolesComponent>;
|
|
13
|
-
|
|
14
|
-
let mockedCreateSdk: jest.Mock;
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
mockedCreateSdk = mocked(createSdk);
|
|
18
|
-
mockedCreateSdk.mockReturnValue({});
|
|
19
|
-
|
|
20
|
-
TestBed.configureTestingModule({
|
|
21
|
-
schemas: [NO_ERRORS_SCHEMA],
|
|
22
|
-
declarations: [ManageRolesComponent],
|
|
23
|
-
providers: [
|
|
24
|
-
DescopeAuthConfig,
|
|
25
|
-
{ provide: DescopeAuthConfig, useValue: { projectId: 'test' } }
|
|
26
|
-
]
|
|
27
|
-
});
|
|
28
|
-
fixture = TestBed.createComponent(ManageRolesComponent);
|
|
29
|
-
component = fixture.componentInstance;
|
|
30
|
-
fixture.detectChanges();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should create', () => {
|
|
34
|
-
expect(component).toBeTruthy();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
2
|
-
import { environment } from '../../environments/environment';
|
|
3
|
-
import { Router } from '@angular/router';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'app-manage-roles',
|
|
7
|
-
templateUrl: './manage-roles.component.html'
|
|
8
|
-
})
|
|
9
|
-
export class ManageRolesComponent {
|
|
10
|
-
theme = (environment.descopeTheme as 'light' | 'dark' | 'os') ?? 'os';
|
|
11
|
-
debugMode = environment.descopeDebugMode ?? false;
|
|
12
|
-
tenant = environment.descopeTenantId ?? '';
|
|
13
|
-
|
|
14
|
-
constructor(private _: Router) {}
|
|
15
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { ManageUsersComponent } from './manage-users.component';
|
|
3
|
-
import createSdk from '@descope/web-js-sdk';
|
|
4
|
-
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
5
|
-
import { DescopeAuthConfig } from '../../../../angular-sdk/src/lib/types/types';
|
|
6
|
-
import mocked = jest.mocked;
|
|
7
|
-
|
|
8
|
-
jest.mock('@descope/web-js-sdk');
|
|
9
|
-
|
|
10
|
-
describe('ManageUsersComponent', () => {
|
|
11
|
-
let component: ManageUsersComponent;
|
|
12
|
-
let fixture: ComponentFixture<ManageUsersComponent>;
|
|
13
|
-
|
|
14
|
-
let mockedCreateSdk: jest.Mock;
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
mockedCreateSdk = mocked(createSdk);
|
|
18
|
-
mockedCreateSdk.mockReturnValue({});
|
|
19
|
-
|
|
20
|
-
TestBed.configureTestingModule({
|
|
21
|
-
schemas: [NO_ERRORS_SCHEMA],
|
|
22
|
-
declarations: [ManageUsersComponent],
|
|
23
|
-
providers: [
|
|
24
|
-
DescopeAuthConfig,
|
|
25
|
-
{ provide: DescopeAuthConfig, useValue: { projectId: 'test' } }
|
|
26
|
-
]
|
|
27
|
-
});
|
|
28
|
-
fixture = TestBed.createComponent(ManageUsersComponent);
|
|
29
|
-
component = fixture.componentInstance;
|
|
30
|
-
fixture.detectChanges();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should create', () => {
|
|
34
|
-
expect(component).toBeTruthy();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
2
|
-
import { environment } from '../../environments/environment';
|
|
3
|
-
import { Router } from '@angular/router';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'app-manage-users',
|
|
7
|
-
templateUrl: './manage-users.component.html'
|
|
8
|
-
})
|
|
9
|
-
export class ManageUsersComponent {
|
|
10
|
-
theme = (environment.descopeTheme as 'light' | 'dark' | 'os') ?? 'os';
|
|
11
|
-
debugMode = environment.descopeDebugMode ?? false;
|
|
12
|
-
tenant = environment.descopeTenantId ?? '';
|
|
13
|
-
|
|
14
|
-
constructor(private _: Router) {}
|
|
15
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { MyUserProfileComponent } from './my-user-profile.component';
|
|
3
|
-
import createSdk from '@descope/web-js-sdk';
|
|
4
|
-
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
5
|
-
import { DescopeAuthConfig } from '../../../../angular-sdk/src/lib/types/types';
|
|
6
|
-
import mocked = jest.mocked;
|
|
7
|
-
|
|
8
|
-
jest.mock('@descope/web-js-sdk');
|
|
9
|
-
|
|
10
|
-
describe('MyUserProfileComponent', () => {
|
|
11
|
-
let component: MyUserProfileComponent;
|
|
12
|
-
let fixture: ComponentFixture<MyUserProfileComponent>;
|
|
13
|
-
|
|
14
|
-
let mockedCreateSdk: jest.Mock;
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
mockedCreateSdk = mocked(createSdk);
|
|
18
|
-
mockedCreateSdk.mockReturnValue({});
|
|
19
|
-
|
|
20
|
-
TestBed.configureTestingModule({
|
|
21
|
-
schemas: [NO_ERRORS_SCHEMA],
|
|
22
|
-
declarations: [MyUserProfileComponent],
|
|
23
|
-
providers: [
|
|
24
|
-
DescopeAuthConfig,
|
|
25
|
-
{ provide: DescopeAuthConfig, useValue: { projectId: 'test' } }
|
|
26
|
-
]
|
|
27
|
-
});
|
|
28
|
-
fixture = TestBed.createComponent(MyUserProfileComponent);
|
|
29
|
-
component = fixture.componentInstance;
|
|
30
|
-
fixture.detectChanges();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should create', () => {
|
|
34
|
-
expect(component).toBeTruthy();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
2
|
-
import { environment } from '../../environments/environment';
|
|
3
|
-
import { Router } from '@angular/router';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'app-my-user-profile',
|
|
7
|
-
templateUrl: './my-user-profile.component.html',
|
|
8
|
-
styleUrls: ['./my-user-profile.scss']
|
|
9
|
-
})
|
|
10
|
-
export class MyUserProfileComponent {
|
|
11
|
-
theme = (environment.descopeTheme as 'light' | 'dark' | 'os') ?? 'os';
|
|
12
|
-
debugMode = environment.descopeDebugMode ?? false;
|
|
13
|
-
|
|
14
|
-
onLogout(e: CustomEvent) {
|
|
15
|
-
console.log('SUCCESSFULLY LOGGED IN FROM WEB COMPONENT', e.detail);
|
|
16
|
-
this.router.navigate(['/login']).catch((err) => console.error(err));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
constructor(private router: Router) {}
|
|
20
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
height: 100vh;
|
|
3
|
-
position: relative;
|
|
4
|
-
}
|
|
5
|
-
main {
|
|
6
|
-
border-radius: 10px;
|
|
7
|
-
margin: auto;
|
|
8
|
-
border: 1px solid lightgray;
|
|
9
|
-
padding: 20px;
|
|
10
|
-
max-width: 700px;
|
|
11
|
-
box-shadow:
|
|
12
|
-
13px 13px 20px #cbced1,
|
|
13
|
-
-13px -13px 20px #fff;
|
|
14
|
-
background: #ecf0f3;
|
|
15
|
-
position: relative;
|
|
16
|
-
top: 50%;
|
|
17
|
-
transform: translateY(-50%);
|
|
18
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<descope
|
|
2
|
-
*ngIf="!stepUpSuccess"
|
|
3
|
-
(success)="onSuccess($event)"
|
|
4
|
-
(error)="onError($event)"
|
|
5
|
-
[theme]="theme"
|
|
6
|
-
[flowId]="flowId"
|
|
7
|
-
[locale]="locale"
|
|
8
|
-
[redirectUrl]="redirectUrl"
|
|
9
|
-
[telemetryKey]="telemetryKey"
|
|
10
|
-
[tenant]="tenantId"
|
|
11
|
-
[debug]="debugMode"
|
|
12
|
-
[errorTransformer]="errorTransformer"
|
|
13
|
-
></descope>
|
|
14
|
-
|
|
15
|
-
<ng-container *ngIf="stepUpSuccess">
|
|
16
|
-
<h2>STEP UP SUCCESS</h2>
|
|
17
|
-
<button (click)="goBack()">GO BACK</button>
|
|
18
|
-
</ng-container>
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { ProtectedComponent } from './protected.component';
|
|
4
|
-
import createSdk from '@descope/web-js-sdk';
|
|
5
|
-
import mocked = jest.mocked;
|
|
6
|
-
import { DescopeAuthConfig } from '../../../../angular-sdk/src/lib/types/types';
|
|
7
|
-
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
8
|
-
|
|
9
|
-
jest.mock('@descope/web-js-sdk');
|
|
10
|
-
|
|
11
|
-
describe('ProtectedComponent', () => {
|
|
12
|
-
let component: ProtectedComponent;
|
|
13
|
-
let fixture: ComponentFixture<ProtectedComponent>;
|
|
14
|
-
|
|
15
|
-
let mockedCreateSdk: jest.Mock;
|
|
16
|
-
const onSessionTokenChangeSpy = jest.fn();
|
|
17
|
-
const onUserChangeSpy = jest.fn();
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
mockedCreateSdk = mocked(createSdk);
|
|
21
|
-
mockedCreateSdk.mockReturnValue({
|
|
22
|
-
onSessionTokenChange: onSessionTokenChangeSpy,
|
|
23
|
-
onUserChange: onUserChangeSpy
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
TestBed.configureTestingModule({
|
|
27
|
-
declarations: [ProtectedComponent],
|
|
28
|
-
schemas: [NO_ERRORS_SCHEMA],
|
|
29
|
-
providers: [
|
|
30
|
-
DescopeAuthConfig,
|
|
31
|
-
{ provide: DescopeAuthConfig, useValue: { projectId: 'test' } }
|
|
32
|
-
]
|
|
33
|
-
});
|
|
34
|
-
fixture = TestBed.createComponent(ProtectedComponent);
|
|
35
|
-
component = fixture.componentInstance;
|
|
36
|
-
fixture.detectChanges();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should create', () => {
|
|
40
|
-
expect(component).toBeTruthy();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
2
|
-
import { Router } from '@angular/router';
|
|
3
|
-
import { environment } from '../../environments/environment';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'app-protected',
|
|
7
|
-
templateUrl: './protected.component.html',
|
|
8
|
-
styleUrls: ['./protected.component.scss']
|
|
9
|
-
})
|
|
10
|
-
export class ProtectedComponent {
|
|
11
|
-
flowId = environment.descopeStepUpFlowId ?? 'sign-up-or-in';
|
|
12
|
-
theme = (environment.descopeTheme as 'light' | 'dark' | 'os') ?? 'os';
|
|
13
|
-
telemetryKey = environment.descopeTelemetryKey ?? '';
|
|
14
|
-
debugMode = environment.descopeDebugMode ?? false;
|
|
15
|
-
tenantId = environment.descopeTenantId ?? '';
|
|
16
|
-
locale = environment.descopeLocale ?? '';
|
|
17
|
-
redirectUrl = environment.descopeRedirectUrl ?? '';
|
|
18
|
-
|
|
19
|
-
stepUpSuccess = false;
|
|
20
|
-
constructor(private router: Router) {}
|
|
21
|
-
|
|
22
|
-
errorTransformer = (error: { text: string; type: string }): string => {
|
|
23
|
-
const translationMap: { [key: string]: string } = {
|
|
24
|
-
SAMLStartFailed: 'Failed to start SAML flow'
|
|
25
|
-
};
|
|
26
|
-
return translationMap[error.type] || error.text;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
onSuccess(e: CustomEvent) {
|
|
30
|
-
console.log('SUCCESSFULLY DONE IN PROTECTED ROUTE FLOW', e.detail);
|
|
31
|
-
this.stepUpSuccess = true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
onError(e: CustomEvent) {
|
|
35
|
-
console.log('ERROR FROM PROTECTED ROUTE FLOW', e);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
goBack() {
|
|
39
|
-
this.router.navigate(['/']).catch((err) => console.error(err));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
File without changes
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface Env {
|
|
2
|
-
descopeProjectId: string;
|
|
3
|
-
descopeBaseUrl?: string;
|
|
4
|
-
descopeBaseStaticUrl?: string;
|
|
5
|
-
descopeFlowId?: string;
|
|
6
|
-
descopeDebugMode?: false;
|
|
7
|
-
descopeTheme?: string;
|
|
8
|
-
descopeLocale?: string;
|
|
9
|
-
descopeRedirectUrl?: string;
|
|
10
|
-
descopeTenantId?: string;
|
|
11
|
-
descopeTelemetryKey?: string;
|
|
12
|
-
descopeStepUpFlowId?: string;
|
|
13
|
-
backendUrl?: string;
|
|
14
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Env } from './conifg';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Create environment.development.ts file and copy content of this file to it.
|
|
5
|
-
* Fill the env vars according to your needs
|
|
6
|
-
*/
|
|
7
|
-
export const environment: Env = {
|
|
8
|
-
descopeProjectId: '',
|
|
9
|
-
descopeBaseUrl: '',
|
|
10
|
-
descopeBaseStaticUrl: '',
|
|
11
|
-
descopeFlowId: '',
|
|
12
|
-
descopeDebugMode: false,
|
|
13
|
-
descopeTheme: '',
|
|
14
|
-
descopeLocale: '',
|
|
15
|
-
descopeRedirectUrl: '',
|
|
16
|
-
descopeTenantId: '',
|
|
17
|
-
descopeTelemetryKey: '',
|
|
18
|
-
descopeStepUpFlowId: '',
|
|
19
|
-
backendUrl: ''
|
|
20
|
-
};
|
|
Binary file
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<title>DemoApp</title>
|
|
6
|
-
<base href="/" />
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
8
|
-
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
|
9
|
-
<link
|
|
10
|
-
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
|
|
11
|
-
rel="stylesheet"
|
|
12
|
-
/>
|
|
13
|
-
</head>
|
|
14
|
-
<body>
|
|
15
|
-
<app-root></app-root>
|
|
16
|
-
</body>
|
|
17
|
-
</html>
|