@descope/angular-sdk 0.5.10 → 0.5.11
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/.eslintrc.json +41 -0
- package/.prettierrc +7 -0
- package/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +647 -11
- package/angular.json +154 -0
- package/{esm2022 → dist/esm2022}/lib/components/access-key-management/access-key-management.component.mjs +4 -4
- package/{esm2022 → dist/esm2022}/lib/components/audit-management/audit-management.component.mjs +4 -4
- package/dist/esm2022/lib/components/descope/descope.component.mjs +156 -0
- package/{esm2022 → dist/esm2022}/lib/components/role-management/role-management.component.mjs +4 -4
- package/dist/esm2022/lib/components/sign-in-flow/sign-in-flow.component.mjs +44 -0
- package/dist/esm2022/lib/components/sign-up-flow/sign-up-flow.component.mjs +44 -0
- package/dist/esm2022/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.mjs +44 -0
- package/{esm2022 → dist/esm2022}/lib/components/user-management/user-management.component.mjs +4 -4
- package/dist/esm2022/lib/components/user-profile/user-profile.component.mjs +66 -0
- package/{esm2022 → dist/esm2022}/lib/descope-auth.module.mjs +5 -5
- package/{esm2022 → dist/esm2022}/lib/services/descope-auth.guard.mjs +1 -1
- package/dist/esm2022/lib/services/descope-auth.service.mjs +154 -0
- package/dist/esm2022/lib/services/descope.interceptor.mjs +51 -0
- package/dist/esm2022/lib/types/types.mjs +6 -0
- package/{esm2022 → dist/esm2022}/lib/utils/constants.mjs +1 -1
- package/dist/esm2022/lib/utils/helpers.mjs +27 -0
- package/{fesm2022 → dist/fesm2022}/descope-angular-sdk.mjs +37 -37
- package/dist/fesm2022/descope-angular-sdk.mjs.map +1 -0
- package/{lib → dist/lib}/services/descope-auth.service.d.ts +3 -2
- package/jest.config.js +17 -0
- package/package.json +62 -19
- package/project.json +17 -0
- package/projects/angular-sdk/.eslintrc.json +32 -0
- package/projects/angular-sdk/ng-package.json +17 -0
- package/projects/angular-sdk/package.json +87 -0
- package/projects/angular-sdk/src/environment.ts +3 -0
- package/projects/angular-sdk/src/lib/components/access-key-management/access-key-management.component.spec.ts +84 -0
- package/projects/angular-sdk/src/lib/components/access-key-management/access-key-management.component.ts +63 -0
- package/projects/angular-sdk/src/lib/components/audit-management/audit-management.component.spec.ts +84 -0
- package/projects/angular-sdk/src/lib/components/audit-management/audit-management.component.ts +63 -0
- package/projects/angular-sdk/src/lib/components/descope/descope.component.spec.ts +142 -0
- package/projects/angular-sdk/src/lib/components/descope/descope.component.ts +171 -0
- package/projects/angular-sdk/src/lib/components/role-management/role-management.component.spec.ts +84 -0
- package/projects/angular-sdk/src/lib/components/role-management/role-management.component.ts +63 -0
- package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.html +17 -0
- package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.spec.ts +53 -0
- package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.ts +35 -0
- package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.html +17 -0
- package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.spec.ts +51 -0
- package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.ts +35 -0
- package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.html +17 -0
- package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.spec.ts +53 -0
- package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.ts +35 -0
- package/projects/angular-sdk/src/lib/components/user-management/user-management.component.spec.ts +84 -0
- package/projects/angular-sdk/src/lib/components/user-management/user-management.component.ts +64 -0
- package/projects/angular-sdk/src/lib/components/user-profile/user-profile.component.spec.ts +93 -0
- package/projects/angular-sdk/src/lib/components/user-profile/user-profile.component.ts +77 -0
- package/projects/angular-sdk/src/lib/descope-auth.module.ts +61 -0
- package/projects/angular-sdk/src/lib/services/descope-auth.guard.spec.ts +76 -0
- package/projects/angular-sdk/src/lib/services/descope-auth.guard.ts +16 -0
- package/projects/angular-sdk/src/lib/services/descope-auth.service.spec.ts +309 -0
- package/projects/angular-sdk/src/lib/services/descope-auth.service.ts +200 -0
- package/projects/angular-sdk/src/lib/services/descope.interceptor.spec.ts +102 -0
- package/projects/angular-sdk/src/lib/services/descope.interceptor.ts +76 -0
- package/projects/angular-sdk/src/lib/types/types.ts +15 -0
- package/projects/angular-sdk/src/lib/utils/constants.ts +8 -0
- package/projects/angular-sdk/src/lib/utils/helpers.spec.ts +103 -0
- package/projects/angular-sdk/src/lib/utils/helpers.ts +36 -0
- package/projects/angular-sdk/src/public-api.ts +18 -0
- package/projects/angular-sdk/tsconfig.lib.json +12 -0
- package/projects/angular-sdk/tsconfig.lib.prod.json +10 -0
- package/projects/angular-sdk/tsconfig.spec.json +11 -0
- package/projects/demo-app/.eslintrc.json +31 -0
- package/projects/demo-app/src/app/app-routing.module.ts +33 -0
- package/projects/demo-app/src/app/app.component.html +3 -0
- package/projects/demo-app/src/app/app.component.scss +18 -0
- package/projects/demo-app/src/app/app.component.spec.ts +37 -0
- package/projects/demo-app/src/app/app.component.ts +8 -0
- package/projects/demo-app/src/app/app.module.ts +63 -0
- package/projects/demo-app/src/app/home/home.component.html +32 -0
- package/projects/demo-app/src/app/home/home.component.scss +15 -0
- package/projects/demo-app/src/app/home/home.component.spec.ts +44 -0
- package/projects/demo-app/src/app/home/home.component.ts +85 -0
- package/projects/demo-app/src/app/interceptor/auth.interceptor.ts +20 -0
- package/projects/demo-app/src/app/login/login.component.html +20 -0
- package/projects/demo-app/src/app/login/login.component.spec.ts +42 -0
- package/projects/demo-app/src/app/login/login.component.ts +41 -0
- package/projects/demo-app/src/app/manage-access-keys/manage-access-keys.component.html +12 -0
- package/projects/demo-app/src/app/manage-access-keys/manage-access-keys.component.spec.ts +36 -0
- package/projects/demo-app/src/app/manage-access-keys/manage-access-keys.component.ts +15 -0
- package/projects/demo-app/src/app/manage-audit/manage-audit.component.html +6 -0
- package/projects/demo-app/src/app/manage-audit/manage-audit.component.spec.ts +36 -0
- package/projects/demo-app/src/app/manage-audit/manage-audit.component.ts +15 -0
- package/projects/demo-app/src/app/manage-roles/manage-roles.component.html +6 -0
- package/projects/demo-app/src/app/manage-roles/manage-roles.component.spec.ts +36 -0
- package/projects/demo-app/src/app/manage-roles/manage-roles.component.ts +15 -0
- package/projects/demo-app/src/app/manage-users/manage-users.component.html +6 -0
- package/projects/demo-app/src/app/manage-users/manage-users.component.spec.ts +36 -0
- package/projects/demo-app/src/app/manage-users/manage-users.component.ts +15 -0
- package/projects/demo-app/src/app/my-user-profile/my-user-profile.component.html +6 -0
- package/projects/demo-app/src/app/my-user-profile/my-user-profile.component.spec.ts +36 -0
- package/projects/demo-app/src/app/my-user-profile/my-user-profile.component.ts +20 -0
- package/projects/demo-app/src/app/my-user-profile/my-user-profile.scss +18 -0
- package/projects/demo-app/src/app/protected/protected.component.html +18 -0
- package/projects/demo-app/src/app/protected/protected.component.scss +8 -0
- package/projects/demo-app/src/app/protected/protected.component.spec.ts +42 -0
- package/projects/demo-app/src/app/protected/protected.component.ts +41 -0
- package/projects/demo-app/src/assets/.gitkeep +0 -0
- package/projects/demo-app/src/environments/conifg.ts +14 -0
- package/projects/demo-app/src/environments/environment.ts +20 -0
- package/projects/demo-app/src/favicon.ico +0 -0
- package/projects/demo-app/src/index.html +17 -0
- package/projects/demo-app/src/main.ts +7 -0
- package/projects/demo-app/src/styles.scss +21 -0
- package/projects/demo-app/tsconfig.app.json +11 -0
- package/projects/demo-app/tsconfig.spec.json +10 -0
- package/scripts/setversion/setversion.js +20 -0
- package/setup-jest.ts +1 -0
- package/tsconfig.json +36 -0
- package/esm2022/lib/components/descope/descope.component.mjs +0 -156
- package/esm2022/lib/components/sign-in-flow/sign-in-flow.component.mjs +0 -44
- package/esm2022/lib/components/sign-up-flow/sign-up-flow.component.mjs +0 -44
- package/esm2022/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.mjs +0 -44
- package/esm2022/lib/components/user-profile/user-profile.component.mjs +0 -66
- package/esm2022/lib/services/descope-auth.service.mjs +0 -154
- package/esm2022/lib/services/descope.interceptor.mjs +0 -51
- package/esm2022/lib/types/types.mjs +0 -6
- package/esm2022/lib/utils/helpers.mjs +0 -27
- package/fesm2022/descope-angular-sdk.mjs.map +0 -1
- /package/{environment.d.ts → dist/environment.d.ts} +0 -0
- /package/{esm2022 → dist/esm2022}/descope-angular-sdk.mjs +0 -0
- /package/{esm2022 → dist/esm2022}/environment.mjs +0 -0
- /package/{esm2022 → dist/esm2022}/public-api.mjs +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{lib → dist/lib}/components/access-key-management/access-key-management.component.d.ts +0 -0
- /package/{lib → dist/lib}/components/audit-management/audit-management.component.d.ts +0 -0
- /package/{lib → dist/lib}/components/descope/descope.component.d.ts +0 -0
- /package/{lib → dist/lib}/components/role-management/role-management.component.d.ts +0 -0
- /package/{lib → dist/lib}/components/sign-in-flow/sign-in-flow.component.d.ts +0 -0
- /package/{lib → dist/lib}/components/sign-up-flow/sign-up-flow.component.d.ts +0 -0
- /package/{lib → dist/lib}/components/sign-up-or-in-flow/sign-up-or-in-flow.component.d.ts +0 -0
- /package/{lib → dist/lib}/components/user-management/user-management.component.d.ts +0 -0
- /package/{lib → dist/lib}/components/user-profile/user-profile.component.d.ts +0 -0
- /package/{lib → dist/lib}/descope-auth.module.d.ts +0 -0
- /package/{lib → dist/lib}/services/descope-auth.guard.d.ts +0 -0
- /package/{lib → dist/lib}/services/descope.interceptor.d.ts +0 -0
- /package/{lib → dist/lib}/types/types.d.ts +0 -0
- /package/{lib → dist/lib}/utils/constants.d.ts +0 -0
- /package/{lib → dist/lib}/utils/helpers.d.ts +0 -0
- /package/{public-api.d.ts → dist/public-api.d.ts} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
/>
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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>
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
|
@@ -0,0 +1,17 @@
|
|
|
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>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* You can add global styles to this file, and also import other style files */
|
|
2
|
+
|
|
3
|
+
body {
|
|
4
|
+
height: 100vh;
|
|
5
|
+
width: 100vw;
|
|
6
|
+
margin: 0;
|
|
7
|
+
font-family: 'Roboto', sans-serif;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
button {
|
|
11
|
+
width: 200px;
|
|
12
|
+
height: 40px;
|
|
13
|
+
border: none;
|
|
14
|
+
background-color: #00ace1;
|
|
15
|
+
color: white;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
|
|
18
|
+
&:hover {
|
|
19
|
+
background-color: #047293;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
+
{
|
|
3
|
+
"extends": "../../tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "../../out-tsc/app",
|
|
6
|
+
"target": "ES2022",
|
|
7
|
+
"types": []
|
|
8
|
+
},
|
|
9
|
+
"files": ["src/main.ts"],
|
|
10
|
+
"include": ["src/**/*.d.ts"]
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
+
{
|
|
3
|
+
"extends": "../../tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "../../out-tsc/spec",
|
|
6
|
+
"types": ["jest"],
|
|
7
|
+
"module": "CommonJs"
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const { writeFile } = require('fs');
|
|
2
|
+
const { version } = require('./../../package.json');
|
|
3
|
+
const envFile = `export const environment = {
|
|
4
|
+
buildVersion: '${version}'
|
|
5
|
+
};
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
console.log(
|
|
9
|
+
`Writing version ${version} to projects/angular-sdk/src/environment.ts`
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
writeFile('./projects/angular-sdk/src/environment.ts', envFile, function (err) {
|
|
13
|
+
if (err) {
|
|
14
|
+
console.error(err);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
console.log(`Environment file updated with version: ${version}`);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
console.log('Writing version done!');
|
package/setup-jest.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'jest-preset-angular/setup-jest';
|