@descope/angular-sdk 0.0.0-next-a6b67f6a-20231228 → 0.0.0-next-cc7eda17-20231228
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/.editorconfig +16 -0
- package/.eslintrc.json +40 -0
- package/.github/workflows/ci.yml +98 -0
- package/.github/workflows/publish-next.yml +43 -0
- package/.github/workflows/publish.yml +31 -0
- package/.github/workflows/release.yml +41 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc +8 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +20 -0
- package/.vscode/settings.json +3 -0
- package/.vscode/tasks.json +42 -0
- package/angular.json +154 -0
- package/jest.config.js +17 -0
- package/package.json +1 -4
- package/projects/angular-sdk/.eslintrc.json +32 -0
- package/projects/angular-sdk/ng-package.json +8 -0
- package/projects/angular-sdk/src/environment.ts +3 -0
- package/projects/angular-sdk/src/lib/components/descope/descope.component.spec.ts +104 -0
- package/projects/angular-sdk/src/lib/components/descope/descope.component.ts +114 -0
- package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.html +15 -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 +32 -0
- package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.html +15 -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 +32 -0
- package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.html +15 -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 +32 -0
- package/projects/angular-sdk/src/lib/descope-auth.module.ts +46 -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 +264 -0
- package/projects/angular-sdk/src/lib/services/descope-auth.service.ts +176 -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 +10 -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/{dist/public-api.d.ts → projects/angular-sdk/src/public-api.ts} +4 -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 +23 -0
- package/projects/demo-app/src/app/app.component.html +3 -0
- package/projects/demo-app/src/app/app.component.scss +16 -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 +52 -0
- package/projects/demo-app/src/app/home/home.component.html +23 -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 +61 -0
- package/projects/demo-app/src/app/interceptor/auth.interceptor.ts +20 -0
- package/projects/demo-app/src/app/login/login.component.html +12 -0
- package/projects/demo-app/src/app/login/login.component.spec.ts +42 -0
- package/projects/demo-app/src/app/login/login.component.ts +35 -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 +40 -0
- package/projects/demo-app/src/assets/.gitkeep +0 -0
- package/projects/demo-app/src/environments/conifg.ts +13 -0
- package/projects/demo-app/src/environments/environment.ts +19 -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 +10 -0
- package/projects/demo-app/tsconfig.spec.json +10 -0
- package/renovate.json +4 -0
- package/scripts/gitleaks/.gitleaks.toml +653 -0
- package/scripts/gitleaks/gitleaks.sh +34 -0
- package/scripts/setversion/setversion.js +20 -0
- package/setup-jest.ts +1 -0
- package/thirdPartyLicenseCollector_linux_amd64 +0 -0
- package/tsconfig.json +35 -0
- package/dist/environment.d.ts +0 -3
- package/dist/esm2022/descope-angular-sdk.mjs +0 -5
- package/dist/esm2022/environment.mjs +0 -4
- package/dist/esm2022/lib/components/descope/descope.component.mjs +0 -106
- package/dist/esm2022/lib/components/sign-in-flow/sign-in-flow.component.mjs +0 -40
- package/dist/esm2022/lib/components/sign-up-flow/sign-up-flow.component.mjs +0 -40
- package/dist/esm2022/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.mjs +0 -40
- package/dist/esm2022/lib/descope-auth.module.mjs +0 -52
- package/dist/esm2022/lib/services/descope-auth.guard.mjs +0 -15
- package/dist/esm2022/lib/services/descope-auth.service.mjs +0 -139
- package/dist/esm2022/lib/services/descope.interceptor.mjs +0 -51
- package/dist/esm2022/lib/types/types.mjs +0 -6
- package/dist/esm2022/lib/utils/constants.mjs +0 -7
- package/dist/esm2022/lib/utils/helpers.mjs +0 -27
- package/dist/esm2022/public-api.mjs +0 -13
- package/dist/fesm2022/descope-angular-sdk.mjs +0 -500
- package/dist/fesm2022/descope-angular-sdk.mjs.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/lib/components/descope/descope.component.d.ts +0 -32
- package/dist/lib/components/sign-in-flow/sign-in-flow.component.d.ts +0 -24
- package/dist/lib/components/sign-up-flow/sign-up-flow.component.d.ts +0 -24
- package/dist/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.d.ts +0 -24
- package/dist/lib/descope-auth.module.d.ts +0 -14
- package/dist/lib/services/descope-auth.guard.d.ts +0 -2
- package/dist/lib/services/descope-auth.service.d.ts +0 -38
- package/dist/lib/services/descope.interceptor.d.ts +0 -2
- package/dist/lib/types/types.d.ts +0 -8
- package/dist/lib/utils/constants.d.ts +0 -5
- package/dist/lib/utils/helpers.d.ts +0 -5
- package/dist/package.json +0 -42
- /package/{dist → projects/angular-sdk}/README.md +0 -0
|
@@ -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,40 @@
|
|
|
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() {
|
|
30
|
+
this.stepUpSuccess = true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
onError() {
|
|
34
|
+
console.log('ERROR FROM LOG IN FLOW FROM WEB COMPONENT');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
goBack() {
|
|
38
|
+
this.router.navigate(['/']).catch((err) => console.error(err));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Env {
|
|
2
|
+
descopeProjectId: string;
|
|
3
|
+
descopeBaseUrl?: string;
|
|
4
|
+
descopeFlowId?: string;
|
|
5
|
+
descopeDebugMode?: false;
|
|
6
|
+
descopeTheme?: string;
|
|
7
|
+
descopeLocale?: string;
|
|
8
|
+
descopeRedirectUrl?: string;
|
|
9
|
+
descopeTenantId?: string;
|
|
10
|
+
descopeTelemetryKey?: string;
|
|
11
|
+
descopeStepUpFlowId?: string;
|
|
12
|
+
backendUrl?: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
descopeFlowId: '',
|
|
11
|
+
descopeDebugMode: false,
|
|
12
|
+
descopeTheme: '',
|
|
13
|
+
descopeLocale: '',
|
|
14
|
+
descopeRedirectUrl: '',
|
|
15
|
+
descopeTenantId: '',
|
|
16
|
+
descopeTelemetryKey: '',
|
|
17
|
+
descopeStepUpFlowId: '',
|
|
18
|
+
backendUrl: ''
|
|
19
|
+
};
|
|
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,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
|
+
}
|
package/renovate.json
ADDED