@descope/angular-sdk 0.5.11 → 0.5.13
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/dist/lib/services/descope-auth.service.d.ts +0 -1
- package/package.json +21 -17
- 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,35 +0,0 @@
|
|
|
1
|
-
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
2
|
-
import { ILogger } from '@descope/web-component';
|
|
3
|
-
import { DescopeComponent } from '../descope/descope.component';
|
|
4
|
-
import { DescopeAuthConfig } from '../../types/types';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'descope-sign-in-flow',
|
|
8
|
-
standalone: true,
|
|
9
|
-
imports: [DescopeComponent],
|
|
10
|
-
templateUrl: './sign-in-flow.component.html'
|
|
11
|
-
})
|
|
12
|
-
export class SignInFlowComponent {
|
|
13
|
-
projectId: string;
|
|
14
|
-
|
|
15
|
-
@Input() locale: string;
|
|
16
|
-
@Input() theme: 'light' | 'dark' | 'os';
|
|
17
|
-
@Input() tenant: string;
|
|
18
|
-
@Input() telemetryKey: string;
|
|
19
|
-
@Input() redirectUrl: string;
|
|
20
|
-
@Input() autoFocus: true | false | 'skipFirstScreen';
|
|
21
|
-
|
|
22
|
-
@Input() debug: boolean;
|
|
23
|
-
@Input() errorTransformer: (error: { text: string; type: string }) => string;
|
|
24
|
-
@Input() client: Record<string, any>;
|
|
25
|
-
@Input() form: Record<string, any>;
|
|
26
|
-
@Input() logger: ILogger;
|
|
27
|
-
|
|
28
|
-
@Output() success: EventEmitter<CustomEvent> =
|
|
29
|
-
new EventEmitter<CustomEvent>();
|
|
30
|
-
@Output() error: EventEmitter<CustomEvent> = new EventEmitter<CustomEvent>();
|
|
31
|
-
|
|
32
|
-
constructor(descopeConfig: DescopeAuthConfig) {
|
|
33
|
-
this.projectId = descopeConfig.projectId;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<descope
|
|
2
|
-
(success)="success.emit($event)"
|
|
3
|
-
(error)="error.emit($event)"
|
|
4
|
-
flowId="sign-up"
|
|
5
|
-
[locale]="locale"
|
|
6
|
-
[theme]="theme"
|
|
7
|
-
[tenant]="tenant"
|
|
8
|
-
[telemetryKey]="telemetryKey"
|
|
9
|
-
[redirectUrl]="redirectUrl"
|
|
10
|
-
[autoFocus]="autoFocus"
|
|
11
|
-
[debug]="debug"
|
|
12
|
-
[errorTransformer]="errorTransformer"
|
|
13
|
-
[client]="client"
|
|
14
|
-
[form]="form"
|
|
15
|
-
[logger]="logger"
|
|
16
|
-
>
|
|
17
|
-
</descope>
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { SignUpFlowComponent } from './sign-up-flow.component';
|
|
3
|
-
import { DescopeComponent } from '../descope/descope.component';
|
|
4
|
-
import { ngMocks } from 'ng-mocks';
|
|
5
|
-
import createSdk from '@descope/web-js-sdk';
|
|
6
|
-
import { DescopeAuthConfig } from '../../types/types';
|
|
7
|
-
import mocked = jest.mocked;
|
|
8
|
-
|
|
9
|
-
jest.mock('@descope/web-js-sdk');
|
|
10
|
-
jest.mock('@descope/web-component', () => {
|
|
11
|
-
return jest.fn(() => {
|
|
12
|
-
// Create a mock DOM element
|
|
13
|
-
return document.createElement('descope-wc');
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
describe('SignUpFlowComponent', () => {
|
|
17
|
-
let component: SignUpFlowComponent;
|
|
18
|
-
let fixture: ComponentFixture<SignUpFlowComponent>;
|
|
19
|
-
let mockedCreateSdk: jest.Mock;
|
|
20
|
-
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
mockedCreateSdk = mocked(createSdk);
|
|
23
|
-
|
|
24
|
-
mockedCreateSdk.mockReturnValue({
|
|
25
|
-
onSessionTokenChange: jest.fn(),
|
|
26
|
-
onUserChange: jest.fn()
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
TestBed.configureTestingModule({
|
|
30
|
-
providers: [
|
|
31
|
-
DescopeAuthConfig,
|
|
32
|
-
{
|
|
33
|
-
provide: DescopeAuthConfig,
|
|
34
|
-
useValue: {
|
|
35
|
-
projectId: 'someProject'
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
]
|
|
39
|
-
});
|
|
40
|
-
fixture = TestBed.createComponent(SignUpFlowComponent);
|
|
41
|
-
component = fixture.componentInstance;
|
|
42
|
-
fixture.detectChanges();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should create and be correctly configured', () => {
|
|
46
|
-
expect(component).toBeTruthy();
|
|
47
|
-
const mockComponent =
|
|
48
|
-
ngMocks.find<DescopeComponent>('[flowId=sign-up]').componentInstance;
|
|
49
|
-
expect(mockComponent.flowId).toStrictEqual('sign-up');
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
2
|
-
import { ILogger } from '@descope/web-component';
|
|
3
|
-
import { DescopeComponent } from '../descope/descope.component';
|
|
4
|
-
import { DescopeAuthConfig } from '../../types/types';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'descope-sign-up-flow',
|
|
8
|
-
standalone: true,
|
|
9
|
-
imports: [DescopeComponent],
|
|
10
|
-
templateUrl: './sign-up-flow.component.html'
|
|
11
|
-
})
|
|
12
|
-
export class SignUpFlowComponent {
|
|
13
|
-
projectId: string;
|
|
14
|
-
|
|
15
|
-
@Input() locale: string;
|
|
16
|
-
@Input() theme: 'light' | 'dark' | 'os';
|
|
17
|
-
@Input() tenant: string;
|
|
18
|
-
@Input() telemetryKey: string;
|
|
19
|
-
@Input() redirectUrl: string;
|
|
20
|
-
@Input() autoFocus: true | false | 'skipFirstScreen';
|
|
21
|
-
|
|
22
|
-
@Input() debug: boolean;
|
|
23
|
-
@Input() errorTransformer: (error: { text: string; type: string }) => string;
|
|
24
|
-
@Input() client: Record<string, any>;
|
|
25
|
-
@Input() form: Record<string, any>;
|
|
26
|
-
@Input() logger: ILogger;
|
|
27
|
-
|
|
28
|
-
@Output() success: EventEmitter<CustomEvent> =
|
|
29
|
-
new EventEmitter<CustomEvent>();
|
|
30
|
-
@Output() error: EventEmitter<CustomEvent> = new EventEmitter<CustomEvent>();
|
|
31
|
-
|
|
32
|
-
constructor(descopeConfig: DescopeAuthConfig) {
|
|
33
|
-
this.projectId = descopeConfig.projectId;
|
|
34
|
-
}
|
|
35
|
-
}
|
package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.html
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<descope
|
|
2
|
-
(success)="success.emit($event)"
|
|
3
|
-
(error)="error.emit($event)"
|
|
4
|
-
flowId="sign-up-or-in"
|
|
5
|
-
[locale]="locale"
|
|
6
|
-
[theme]="theme"
|
|
7
|
-
[tenant]="tenant"
|
|
8
|
-
[telemetryKey]="telemetryKey"
|
|
9
|
-
[redirectUrl]="redirectUrl"
|
|
10
|
-
[autoFocus]="autoFocus"
|
|
11
|
-
[debug]="debug"
|
|
12
|
-
[errorTransformer]="errorTransformer"
|
|
13
|
-
[client]="client"
|
|
14
|
-
[form]="form"
|
|
15
|
-
[logger]="logger"
|
|
16
|
-
>
|
|
17
|
-
</descope>
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { SignUpOrInFlowComponent } from './sign-up-or-in-flow.component';
|
|
3
|
-
import { DescopeComponent } from '../descope/descope.component';
|
|
4
|
-
import { ngMocks } from 'ng-mocks';
|
|
5
|
-
import createSdk from '@descope/web-js-sdk';
|
|
6
|
-
import { DescopeAuthConfig } from '../../types/types';
|
|
7
|
-
import mocked = jest.mocked;
|
|
8
|
-
|
|
9
|
-
jest.mock('@descope/web-js-sdk');
|
|
10
|
-
jest.mock('@descope/web-component', () => {
|
|
11
|
-
return jest.fn(() => {
|
|
12
|
-
// Create a mock DOM element
|
|
13
|
-
return document.createElement('descope-wc');
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
describe('SignUpOrInFlowComponent', () => {
|
|
17
|
-
let component: SignUpOrInFlowComponent;
|
|
18
|
-
let fixture: ComponentFixture<SignUpOrInFlowComponent>;
|
|
19
|
-
let mockedCreateSdk: jest.Mock;
|
|
20
|
-
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
mockedCreateSdk = mocked(createSdk);
|
|
23
|
-
|
|
24
|
-
mockedCreateSdk.mockReturnValue({
|
|
25
|
-
onSessionTokenChange: jest.fn(),
|
|
26
|
-
onUserChange: jest.fn()
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
TestBed.configureTestingModule({
|
|
30
|
-
providers: [
|
|
31
|
-
DescopeAuthConfig,
|
|
32
|
-
{
|
|
33
|
-
provide: DescopeAuthConfig,
|
|
34
|
-
useValue: {
|
|
35
|
-
projectId: 'someProject'
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
]
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
fixture = TestBed.createComponent(SignUpOrInFlowComponent);
|
|
42
|
-
component = fixture.componentInstance;
|
|
43
|
-
fixture.detectChanges();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should create and be correctly configured', () => {
|
|
47
|
-
expect(component).toBeTruthy();
|
|
48
|
-
const mockComponent = ngMocks.find<DescopeComponent>(
|
|
49
|
-
'[flowId=sign-up-or-in]'
|
|
50
|
-
).componentInstance;
|
|
51
|
-
expect(mockComponent.flowId).toStrictEqual('sign-up-or-in');
|
|
52
|
-
});
|
|
53
|
-
});
|
package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
2
|
-
import { ILogger } from '@descope/web-component';
|
|
3
|
-
import { DescopeComponent } from '../descope/descope.component';
|
|
4
|
-
import { DescopeAuthConfig } from '../../types/types';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'descope-sign-up-or-in-flow',
|
|
8
|
-
standalone: true,
|
|
9
|
-
imports: [DescopeComponent],
|
|
10
|
-
templateUrl: './sign-up-or-in-flow.component.html'
|
|
11
|
-
})
|
|
12
|
-
export class SignUpOrInFlowComponent {
|
|
13
|
-
projectId: string;
|
|
14
|
-
|
|
15
|
-
@Input() locale: string;
|
|
16
|
-
@Input() theme: 'light' | 'dark' | 'os';
|
|
17
|
-
@Input() tenant: string;
|
|
18
|
-
@Input() telemetryKey: string;
|
|
19
|
-
@Input() redirectUrl: string;
|
|
20
|
-
@Input() autoFocus: true | false | 'skipFirstScreen';
|
|
21
|
-
|
|
22
|
-
@Input() debug: boolean;
|
|
23
|
-
@Input() errorTransformer: (error: { text: string; type: string }) => string;
|
|
24
|
-
@Input() client: Record<string, any>;
|
|
25
|
-
@Input() form: Record<string, any>;
|
|
26
|
-
@Input() logger: ILogger;
|
|
27
|
-
|
|
28
|
-
@Output() success: EventEmitter<CustomEvent> =
|
|
29
|
-
new EventEmitter<CustomEvent>();
|
|
30
|
-
@Output() error: EventEmitter<CustomEvent> = new EventEmitter<CustomEvent>();
|
|
31
|
-
|
|
32
|
-
constructor(descopeConfig: DescopeAuthConfig) {
|
|
33
|
-
this.projectId = descopeConfig.projectId;
|
|
34
|
-
}
|
|
35
|
-
}
|
package/projects/angular-sdk/src/lib/components/user-management/user-management.component.spec.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { UserManagementComponent } from './user-management.component';
|
|
3
|
-
import createSdk from '@descope/web-js-sdk';
|
|
4
|
-
import { DescopeAuthConfig } from '../../types/types';
|
|
5
|
-
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
6
|
-
import mocked = jest.mocked;
|
|
7
|
-
|
|
8
|
-
jest.mock('@descope/web-js-sdk');
|
|
9
|
-
//Mock DescopeUserManagementWidget
|
|
10
|
-
jest.mock('@descope/user-management-widget', () => {
|
|
11
|
-
return jest.fn(() => {
|
|
12
|
-
// Create a mock DOM element
|
|
13
|
-
return document.createElement('descope-user-management-widget');
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe('DescopeUserManagementComponent', () => {
|
|
18
|
-
let component: UserManagementComponent;
|
|
19
|
-
let fixture: ComponentFixture<UserManagementComponent>;
|
|
20
|
-
let mockedCreateSdk: jest.Mock;
|
|
21
|
-
const onSessionTokenChangeSpy = jest.fn();
|
|
22
|
-
const onUserChangeSpy = jest.fn();
|
|
23
|
-
const afterRequestHooksSpy = jest.fn();
|
|
24
|
-
const mockConfig: DescopeAuthConfig = {
|
|
25
|
-
projectId: 'someProject'
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
mockedCreateSdk = mocked(createSdk);
|
|
30
|
-
|
|
31
|
-
mockedCreateSdk.mockReturnValue({
|
|
32
|
-
onSessionTokenChange: onSessionTokenChangeSpy,
|
|
33
|
-
onUserChange: onUserChangeSpy,
|
|
34
|
-
httpClient: {
|
|
35
|
-
hooks: {
|
|
36
|
-
afterRequest: afterRequestHooksSpy
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
TestBed.configureTestingModule({
|
|
42
|
-
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
43
|
-
providers: [
|
|
44
|
-
DescopeAuthConfig,
|
|
45
|
-
{ provide: DescopeAuthConfig, useValue: mockConfig }
|
|
46
|
-
]
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
fixture = TestBed.createComponent(UserManagementComponent);
|
|
50
|
-
component = fixture.componentInstance;
|
|
51
|
-
component.projectId = '123';
|
|
52
|
-
component.tenant = 'tenant-1';
|
|
53
|
-
component.widgetId = 'widget-1';
|
|
54
|
-
component.logger = {
|
|
55
|
-
info: jest.fn(),
|
|
56
|
-
error: jest.fn(),
|
|
57
|
-
warn: jest.fn(),
|
|
58
|
-
debug: jest.fn()
|
|
59
|
-
};
|
|
60
|
-
fixture.detectChanges();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should create', () => {
|
|
64
|
-
expect(component).toBeTruthy();
|
|
65
|
-
const html: HTMLElement = fixture.nativeElement;
|
|
66
|
-
const webComponentHtml = html.querySelector(
|
|
67
|
-
'descope-user-management-widget'
|
|
68
|
-
);
|
|
69
|
-
expect(webComponentHtml).toBeDefined();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should correctly setup attributes based on inputs', () => {
|
|
73
|
-
const html: HTMLElement = fixture.nativeElement;
|
|
74
|
-
const webComponentHtml = html.querySelector(
|
|
75
|
-
'descope-user-management-widget'
|
|
76
|
-
)!;
|
|
77
|
-
expect(webComponentHtml.getAttribute('project-id')).toStrictEqual('123');
|
|
78
|
-
expect(webComponentHtml.getAttribute('tenant')).toStrictEqual('tenant-1');
|
|
79
|
-
expect(webComponentHtml.getAttribute('widget-id')).toStrictEqual(
|
|
80
|
-
'widget-1'
|
|
81
|
-
);
|
|
82
|
-
expect(webComponentHtml.getAttribute('logger')).toBeDefined();
|
|
83
|
-
});
|
|
84
|
-
});
|
package/projects/angular-sdk/src/lib/components/user-management/user-management.component.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Component, ElementRef, Input, OnChanges, OnInit } from '@angular/core';
|
|
2
|
-
import DescopeUserManagementWidget from '@descope/user-management-widget';
|
|
3
|
-
import { ILogger } from '@descope/web-component';
|
|
4
|
-
import { DescopeAuthConfig } from '../../types/types';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'user-management[tenant]',
|
|
8
|
-
standalone: true,
|
|
9
|
-
template: ''
|
|
10
|
-
})
|
|
11
|
-
export class UserManagementComponent implements OnInit, OnChanges {
|
|
12
|
-
projectId: string;
|
|
13
|
-
baseUrl?: string;
|
|
14
|
-
baseStaticUrl?: string;
|
|
15
|
-
@Input() tenant: string;
|
|
16
|
-
@Input() widgetId: string;
|
|
17
|
-
|
|
18
|
-
@Input() theme: 'light' | 'dark' | 'os';
|
|
19
|
-
@Input() debug: boolean;
|
|
20
|
-
@Input() logger: ILogger;
|
|
21
|
-
|
|
22
|
-
private readonly webComponent = new DescopeUserManagementWidget();
|
|
23
|
-
|
|
24
|
-
constructor(
|
|
25
|
-
private elementRef: ElementRef,
|
|
26
|
-
descopeConfig: DescopeAuthConfig
|
|
27
|
-
) {
|
|
28
|
-
this.projectId = descopeConfig.projectId;
|
|
29
|
-
this.baseUrl = descopeConfig.baseUrl;
|
|
30
|
-
this.baseStaticUrl = descopeConfig.baseStaticUrl;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
ngOnInit() {
|
|
34
|
-
this.setupWebComponent();
|
|
35
|
-
this.elementRef.nativeElement.appendChild(this.webComponent);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
ngOnChanges(): void {
|
|
39
|
-
this.setupWebComponent();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private setupWebComponent() {
|
|
43
|
-
this.webComponent.setAttribute('project-id', this.projectId);
|
|
44
|
-
this.webComponent.setAttribute('tenant', this.tenant);
|
|
45
|
-
this.webComponent.setAttribute('widget-id', this.widgetId);
|
|
46
|
-
|
|
47
|
-
if (this.baseUrl) {
|
|
48
|
-
this.webComponent.setAttribute('base-url', this.baseUrl);
|
|
49
|
-
}
|
|
50
|
-
if (this.baseStaticUrl) {
|
|
51
|
-
this.webComponent.setAttribute('base-static-url', this.baseStaticUrl);
|
|
52
|
-
}
|
|
53
|
-
if (this.theme) {
|
|
54
|
-
this.webComponent.setAttribute('theme', this.theme);
|
|
55
|
-
}
|
|
56
|
-
if (this.debug) {
|
|
57
|
-
this.webComponent.setAttribute('debug', this.debug.toString());
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (this.logger) {
|
|
61
|
-
(this.webComponent as any).logger = this.logger;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { UserProfileComponent } from './user-profile.component';
|
|
3
|
-
import createSdk from '@descope/web-js-sdk';
|
|
4
|
-
import { DescopeAuthConfig } from '../../types/types';
|
|
5
|
-
import { CUSTOM_ELEMENTS_SCHEMA, EventEmitter } from '@angular/core';
|
|
6
|
-
import mocked = jest.mocked;
|
|
7
|
-
|
|
8
|
-
jest.mock('@descope/web-js-sdk');
|
|
9
|
-
//Mock DescopeUserProfileWidget
|
|
10
|
-
jest.mock('@descope/user-profile-widget', () => {
|
|
11
|
-
return jest.fn(() => {
|
|
12
|
-
// Create a mock DOM element
|
|
13
|
-
return document.createElement('descope-user-profile-widget');
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe('DescopeUserProfileComponent', () => {
|
|
18
|
-
let component: UserProfileComponent;
|
|
19
|
-
let fixture: ComponentFixture<UserProfileComponent>;
|
|
20
|
-
let mockedCreateSdk: jest.Mock;
|
|
21
|
-
const onSessionTokenChangeSpy = jest.fn();
|
|
22
|
-
const onAuditChangeSpy = jest.fn();
|
|
23
|
-
const afterRequestHooksSpy = jest.fn();
|
|
24
|
-
const mockConfig: DescopeAuthConfig = {
|
|
25
|
-
projectId: 'someProject'
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
mockedCreateSdk = mocked(createSdk);
|
|
30
|
-
|
|
31
|
-
mockedCreateSdk.mockReturnValue({
|
|
32
|
-
onSessionTokenChange: onSessionTokenChangeSpy,
|
|
33
|
-
onAuditChange: onAuditChangeSpy,
|
|
34
|
-
httpClient: {
|
|
35
|
-
hooks: {
|
|
36
|
-
afterRequest: afterRequestHooksSpy
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
TestBed.configureTestingModule({
|
|
42
|
-
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
43
|
-
providers: [
|
|
44
|
-
DescopeAuthConfig,
|
|
45
|
-
{ provide: DescopeAuthConfig, useValue: mockConfig }
|
|
46
|
-
]
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
fixture = TestBed.createComponent(UserProfileComponent);
|
|
50
|
-
component = fixture.componentInstance;
|
|
51
|
-
component.projectId = '123';
|
|
52
|
-
component.widgetId = 'widget-1';
|
|
53
|
-
component.logout = new EventEmitter<CustomEvent>();
|
|
54
|
-
component.logger = {
|
|
55
|
-
info: jest.fn(),
|
|
56
|
-
error: jest.fn(),
|
|
57
|
-
warn: jest.fn(),
|
|
58
|
-
debug: jest.fn()
|
|
59
|
-
};
|
|
60
|
-
fixture.detectChanges();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should create', () => {
|
|
64
|
-
expect(component).toBeTruthy();
|
|
65
|
-
const html: HTMLElement = fixture.nativeElement;
|
|
66
|
-
const webComponentHtml = html.querySelector('descope-user-profile-widget');
|
|
67
|
-
expect(webComponentHtml).toBeDefined();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should correctly setup attributes based on inputs', () => {
|
|
71
|
-
const html: HTMLElement = fixture.nativeElement;
|
|
72
|
-
const webComponentHtml = html.querySelector('descope-user-profile-widget')!;
|
|
73
|
-
expect(webComponentHtml.getAttribute('project-id')).toStrictEqual('123');
|
|
74
|
-
expect(webComponentHtml.getAttribute('widget-id')).toStrictEqual(
|
|
75
|
-
'widget-1'
|
|
76
|
-
);
|
|
77
|
-
expect(webComponentHtml.getAttribute('logger')).toBeDefined();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('should emit logout when web component emits logout', () => {
|
|
81
|
-
const html: HTMLElement = fixture.nativeElement;
|
|
82
|
-
const webComponentHtml = html.querySelector('descope-user-profile-widget')!;
|
|
83
|
-
|
|
84
|
-
const event = {
|
|
85
|
-
detail: 'logout'
|
|
86
|
-
};
|
|
87
|
-
component.logout.subscribe((e) => {
|
|
88
|
-
expect(afterRequestHooksSpy).toHaveBeenCalled();
|
|
89
|
-
expect(e.detail).toHaveBeenCalledWith(event.detail);
|
|
90
|
-
});
|
|
91
|
-
webComponentHtml.dispatchEvent(new CustomEvent('logout', event));
|
|
92
|
-
});
|
|
93
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
ElementRef,
|
|
4
|
-
EventEmitter,
|
|
5
|
-
Input,
|
|
6
|
-
OnChanges,
|
|
7
|
-
OnInit,
|
|
8
|
-
Output
|
|
9
|
-
} from '@angular/core';
|
|
10
|
-
import DescopeUserProfileWidget from '@descope/user-profile-widget';
|
|
11
|
-
import { ILogger } from '@descope/web-component';
|
|
12
|
-
import { DescopeAuthConfig } from '../../types/types';
|
|
13
|
-
|
|
14
|
-
@Component({
|
|
15
|
-
selector: 'user-profile',
|
|
16
|
-
standalone: true,
|
|
17
|
-
template: ''
|
|
18
|
-
})
|
|
19
|
-
export class UserProfileComponent implements OnInit, OnChanges {
|
|
20
|
-
projectId: string;
|
|
21
|
-
baseUrl?: string;
|
|
22
|
-
baseStaticUrl?: string;
|
|
23
|
-
@Input() widgetId: string;
|
|
24
|
-
|
|
25
|
-
@Input() theme: 'light' | 'dark' | 'os';
|
|
26
|
-
@Input() debug: boolean;
|
|
27
|
-
@Input() logger: ILogger;
|
|
28
|
-
|
|
29
|
-
@Output() logout: EventEmitter<CustomEvent> = new EventEmitter<CustomEvent>();
|
|
30
|
-
|
|
31
|
-
private readonly webComponent = new DescopeUserProfileWidget();
|
|
32
|
-
|
|
33
|
-
constructor(
|
|
34
|
-
private elementRef: ElementRef,
|
|
35
|
-
descopeConfig: DescopeAuthConfig
|
|
36
|
-
) {
|
|
37
|
-
this.projectId = descopeConfig.projectId;
|
|
38
|
-
this.baseUrl = descopeConfig.baseUrl;
|
|
39
|
-
this.baseStaticUrl = descopeConfig.baseStaticUrl;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
ngOnInit() {
|
|
43
|
-
this.setupWebComponent();
|
|
44
|
-
this.elementRef.nativeElement.appendChild(this.webComponent);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
ngOnChanges(): void {
|
|
48
|
-
this.setupWebComponent();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private setupWebComponent() {
|
|
52
|
-
this.webComponent.setAttribute('project-id', this.projectId);
|
|
53
|
-
this.webComponent.setAttribute('widget-id', this.widgetId);
|
|
54
|
-
if (this.baseUrl) {
|
|
55
|
-
this.webComponent.setAttribute('base-url', this.baseUrl);
|
|
56
|
-
}
|
|
57
|
-
if (this.baseStaticUrl) {
|
|
58
|
-
this.webComponent.setAttribute('base-static-url', this.baseStaticUrl);
|
|
59
|
-
}
|
|
60
|
-
if (this.theme) {
|
|
61
|
-
this.webComponent.setAttribute('theme', this.theme);
|
|
62
|
-
}
|
|
63
|
-
if (this.debug) {
|
|
64
|
-
this.webComponent.setAttribute('debug', this.debug.toString());
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (this.logger) {
|
|
68
|
-
(this.webComponent as any).logger = this.logger;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (this.logout) {
|
|
72
|
-
this.webComponent.addEventListener('logout', (e: Event) => {
|
|
73
|
-
this.logout?.emit(e as CustomEvent);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CUSTOM_ELEMENTS_SCHEMA,
|
|
3
|
-
ModuleWithProviders,
|
|
4
|
-
NgModule,
|
|
5
|
-
Optional,
|
|
6
|
-
SkipSelf
|
|
7
|
-
} from '@angular/core';
|
|
8
|
-
import { DescopeComponent } from './components/descope/descope.component';
|
|
9
|
-
import { SignInFlowComponent } from './components/sign-in-flow/sign-in-flow.component';
|
|
10
|
-
import { SignUpFlowComponent } from './components/sign-up-flow/sign-up-flow.component';
|
|
11
|
-
import { SignUpOrInFlowComponent } from './components/sign-up-or-in-flow/sign-up-or-in-flow.component';
|
|
12
|
-
import { UserManagementComponent } from './components/user-management/user-management.component';
|
|
13
|
-
import { RoleManagementComponent } from './components/role-management/role-management.component';
|
|
14
|
-
import { AccessKeyManagementComponent } from './components/access-key-management/access-key-management.component';
|
|
15
|
-
import { AuditManagementComponent } from './components/audit-management/audit-management.component';
|
|
16
|
-
import { UserProfileComponent } from './components/user-profile/user-profile.component';
|
|
17
|
-
import { DescopeAuthConfig } from './types/types';
|
|
18
|
-
|
|
19
|
-
@NgModule({
|
|
20
|
-
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
21
|
-
imports: [
|
|
22
|
-
DescopeComponent,
|
|
23
|
-
SignInFlowComponent,
|
|
24
|
-
SignUpFlowComponent,
|
|
25
|
-
SignUpOrInFlowComponent,
|
|
26
|
-
UserManagementComponent,
|
|
27
|
-
RoleManagementComponent,
|
|
28
|
-
AccessKeyManagementComponent,
|
|
29
|
-
AuditManagementComponent,
|
|
30
|
-
UserProfileComponent
|
|
31
|
-
],
|
|
32
|
-
exports: [
|
|
33
|
-
DescopeComponent,
|
|
34
|
-
SignInFlowComponent,
|
|
35
|
-
SignUpFlowComponent,
|
|
36
|
-
SignUpOrInFlowComponent,
|
|
37
|
-
UserManagementComponent,
|
|
38
|
-
RoleManagementComponent,
|
|
39
|
-
AccessKeyManagementComponent,
|
|
40
|
-
AuditManagementComponent,
|
|
41
|
-
UserProfileComponent
|
|
42
|
-
]
|
|
43
|
-
})
|
|
44
|
-
export class DescopeAuthModule {
|
|
45
|
-
constructor(@Optional() @SkipSelf() parentModule?: DescopeAuthModule) {
|
|
46
|
-
if (parentModule) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
'DescopeAuthModule is already loaded. Import it only once'
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
static forRoot(
|
|
54
|
-
config?: DescopeAuthConfig
|
|
55
|
-
): ModuleWithProviders<DescopeAuthModule> {
|
|
56
|
-
return {
|
|
57
|
-
ngModule: DescopeAuthModule,
|
|
58
|
-
providers: [{ provide: DescopeAuthConfig, useValue: config }]
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|