@descope/angular-sdk 0.0.0-next-a4c70ed4-20231227 → 0.0.0-next-a14bbb42-20231227

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.
Files changed (112) hide show
  1. package/README.md +13 -448
  2. package/environment.d.ts +3 -0
  3. package/esm2022/descope-angular-sdk.mjs +5 -0
  4. package/esm2022/environment.mjs +4 -0
  5. package/esm2022/lib/components/descope/descope.component.mjs +106 -0
  6. package/esm2022/lib/components/sign-in-flow/sign-in-flow.component.mjs +40 -0
  7. package/esm2022/lib/components/sign-up-flow/sign-up-flow.component.mjs +40 -0
  8. package/esm2022/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.mjs +40 -0
  9. package/esm2022/lib/descope-auth.module.mjs +52 -0
  10. package/esm2022/lib/services/descope-auth.guard.mjs +15 -0
  11. package/esm2022/lib/services/descope-auth.service.mjs +139 -0
  12. package/esm2022/lib/services/descope.interceptor.mjs +51 -0
  13. package/esm2022/lib/types/types.mjs +6 -0
  14. package/esm2022/lib/utils/constants.mjs +7 -0
  15. package/esm2022/lib/utils/helpers.mjs +27 -0
  16. package/esm2022/public-api.mjs +13 -0
  17. package/fesm2022/descope-angular-sdk.mjs +500 -0
  18. package/fesm2022/descope-angular-sdk.mjs.map +1 -0
  19. package/index.d.ts +5 -0
  20. package/lib/components/descope/descope.component.d.ts +32 -0
  21. package/lib/components/sign-in-flow/sign-in-flow.component.d.ts +24 -0
  22. package/lib/components/sign-up-flow/sign-up-flow.component.d.ts +24 -0
  23. package/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.d.ts +24 -0
  24. package/lib/descope-auth.module.d.ts +14 -0
  25. package/lib/services/descope-auth.guard.d.ts +2 -0
  26. package/lib/services/descope-auth.service.d.ts +38 -0
  27. package/lib/services/descope.interceptor.d.ts +2 -0
  28. package/lib/types/types.d.ts +8 -0
  29. package/lib/utils/constants.d.ts +5 -0
  30. package/lib/utils/helpers.d.ts +5 -0
  31. package/package.json +32 -66
  32. package/{projects/angular-sdk/src/public-api.ts → public-api.d.ts} +0 -4
  33. package/.editorconfig +0 -16
  34. package/.eslintrc.json +0 -40
  35. package/.github/workflows/ci.yml +0 -98
  36. package/.github/workflows/publish-next.yml +0 -40
  37. package/.github/workflows/publish.yml +0 -28
  38. package/.github/workflows/release.yml +0 -45
  39. package/.husky/pre-commit +0 -4
  40. package/.prettierrc +0 -8
  41. package/.vscode/extensions.json +0 -4
  42. package/.vscode/launch.json +0 -20
  43. package/.vscode/settings.json +0 -3
  44. package/.vscode/tasks.json +0 -42
  45. package/LICENSE +0 -21
  46. package/angular.json +0 -154
  47. package/jest.config.js +0 -17
  48. package/projects/angular-sdk/.eslintrc.json +0 -32
  49. package/projects/angular-sdk/README.md +0 -25
  50. package/projects/angular-sdk/ng-package.json +0 -8
  51. package/projects/angular-sdk/package.json +0 -20
  52. package/projects/angular-sdk/src/environment.ts +0 -3
  53. package/projects/angular-sdk/src/lib/components/descope/descope.component.spec.ts +0 -104
  54. package/projects/angular-sdk/src/lib/components/descope/descope.component.ts +0 -114
  55. package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.html +0 -15
  56. package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.spec.ts +0 -53
  57. package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.ts +0 -32
  58. package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.html +0 -15
  59. package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.spec.ts +0 -51
  60. package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.ts +0 -32
  61. package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.html +0 -15
  62. package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.spec.ts +0 -53
  63. package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.ts +0 -32
  64. package/projects/angular-sdk/src/lib/descope-auth.module.ts +0 -46
  65. package/projects/angular-sdk/src/lib/services/descope-auth.guard.spec.ts +0 -76
  66. package/projects/angular-sdk/src/lib/services/descope-auth.guard.ts +0 -16
  67. package/projects/angular-sdk/src/lib/services/descope-auth.service.spec.ts +0 -264
  68. package/projects/angular-sdk/src/lib/services/descope-auth.service.ts +0 -176
  69. package/projects/angular-sdk/src/lib/services/descope.interceptor.spec.ts +0 -102
  70. package/projects/angular-sdk/src/lib/services/descope.interceptor.ts +0 -76
  71. package/projects/angular-sdk/src/lib/types/types.ts +0 -10
  72. package/projects/angular-sdk/src/lib/utils/constants.ts +0 -8
  73. package/projects/angular-sdk/src/lib/utils/helpers.spec.ts +0 -103
  74. package/projects/angular-sdk/src/lib/utils/helpers.ts +0 -36
  75. package/projects/angular-sdk/tsconfig.lib.json +0 -12
  76. package/projects/angular-sdk/tsconfig.lib.prod.json +0 -10
  77. package/projects/angular-sdk/tsconfig.spec.json +0 -11
  78. package/projects/demo-app/.eslintrc.json +0 -31
  79. package/projects/demo-app/src/app/app-routing.module.ts +0 -23
  80. package/projects/demo-app/src/app/app.component.html +0 -3
  81. package/projects/demo-app/src/app/app.component.scss +0 -16
  82. package/projects/demo-app/src/app/app.component.spec.ts +0 -37
  83. package/projects/demo-app/src/app/app.component.ts +0 -8
  84. package/projects/demo-app/src/app/app.module.ts +0 -52
  85. package/projects/demo-app/src/app/home/home.component.html +0 -23
  86. package/projects/demo-app/src/app/home/home.component.scss +0 -15
  87. package/projects/demo-app/src/app/home/home.component.spec.ts +0 -44
  88. package/projects/demo-app/src/app/home/home.component.ts +0 -61
  89. package/projects/demo-app/src/app/interceptor/auth.interceptor.ts +0 -20
  90. package/projects/demo-app/src/app/login/login.component.html +0 -12
  91. package/projects/demo-app/src/app/login/login.component.spec.ts +0 -42
  92. package/projects/demo-app/src/app/login/login.component.ts +0 -35
  93. package/projects/demo-app/src/app/protected/protected.component.html +0 -18
  94. package/projects/demo-app/src/app/protected/protected.component.scss +0 -8
  95. package/projects/demo-app/src/app/protected/protected.component.spec.ts +0 -42
  96. package/projects/demo-app/src/app/protected/protected.component.ts +0 -40
  97. package/projects/demo-app/src/assets/.gitkeep +0 -0
  98. package/projects/demo-app/src/environments/conifg.ts +0 -13
  99. package/projects/demo-app/src/environments/environment.ts +0 -19
  100. package/projects/demo-app/src/favicon.ico +0 -0
  101. package/projects/demo-app/src/index.html +0 -17
  102. package/projects/demo-app/src/main.ts +0 -7
  103. package/projects/demo-app/src/styles.scss +0 -21
  104. package/projects/demo-app/tsconfig.app.json +0 -10
  105. package/projects/demo-app/tsconfig.spec.json +0 -10
  106. package/renovate.json +0 -4
  107. package/scripts/gitleaks/.gitleaks.toml +0 -653
  108. package/scripts/gitleaks/gitleaks.sh +0 -34
  109. package/scripts/setversion/setversion.js +0 -20
  110. package/setup-jest.ts +0 -1
  111. package/thirdPartyLicenseCollector_linux_amd64 +0 -0
  112. package/tsconfig.json +0 -35
@@ -1,61 +0,0 @@
1
- import { Component, OnInit } from '@angular/core';
2
- import { DescopeAuthService } from '../../../../angular-sdk/src/lib/services/descope-auth.service';
3
- import { Router } from '@angular/router';
4
- import { environment } from '../../environments/environment';
5
- import { HttpClient } from '@angular/common/http';
6
-
7
- @Component({
8
- selector: 'app-home',
9
- templateUrl: './home.component.html',
10
- styleUrls: ['./home.component.scss']
11
- })
12
- export class HomeComponent implements OnInit {
13
- projectId: string = environment.descopeProjectId;
14
- isAuthenticated: boolean = false;
15
- roles: string[] = [];
16
- userName: string = '';
17
- stepUpConfigured = (environment.descopeStepUpFlowId ?? '').length > 0;
18
- backendUrl = environment.backendUrl ?? '';
19
-
20
- constructor(
21
- private router: Router,
22
- private httpClient: HttpClient,
23
- private authService: DescopeAuthService
24
- ) {}
25
-
26
- ngOnInit() {
27
- this.authService.session$.subscribe((session) => {
28
- this.isAuthenticated = session.isAuthenticated;
29
- if (session.sessionToken) {
30
- this.roles = this.authService.getJwtRoles(session.sessionToken);
31
- }
32
- });
33
- this.authService.user$.subscribe((descopeUser) => {
34
- if (descopeUser.user) {
35
- this.userName = descopeUser.user.name ?? '';
36
- }
37
- });
38
- }
39
-
40
- login() {
41
- this.router.navigate(['/login']).catch((err) => console.error(err));
42
- }
43
-
44
- logout() {
45
- this.authService.descopeSdk.logout();
46
- }
47
-
48
- fetchData() {
49
- if (this.backendUrl) {
50
- this.httpClient
51
- .get(this.backendUrl, { responseType: 'text' })
52
- .subscribe((data) => alert(data));
53
- } else {
54
- console.warn('Please setup backendUrl in your environment');
55
- }
56
- }
57
-
58
- stepUp() {
59
- this.router.navigate(['/step-up']).catch((err) => console.error(err));
60
- }
61
- }
@@ -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,12 +0,0 @@
1
- <descope
2
- (success)="onSuccess()"
3
- (error)="onError()"
4
- [theme]="theme"
5
- [flowId]="flowId"
6
- [locale]="locale"
7
- [redirectUrl]="redirectUrl"
8
- [telemetryKey]="telemetryKey"
9
- [tenant]="tenantId"
10
- [debug]="debugMode"
11
- [errorTransformer]="errorTransformer"
12
- ></descope>
@@ -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,35 +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
- constructor(private router: Router) {}
19
-
20
- errorTransformer = (error: { text: string; type: string }): string => {
21
- const translationMap: { [key: string]: string } = {
22
- SAMLStartFailed: 'Failed to start SAML flow'
23
- };
24
- return translationMap[error.type] || error.text;
25
- };
26
-
27
- onSuccess() {
28
- console.log('SUCCESSFULLY LOGGED IN FROM WEB COMPONENT');
29
- this.router.navigate(['/']).catch((err) => console.error(err));
30
- }
31
-
32
- onError() {
33
- console.log('ERROR FROM LOG IN FLOW FROM WEB COMPONENT');
34
- }
35
- }
@@ -1,18 +0,0 @@
1
- <descope
2
- *ngIf="!stepUpSuccess"
3
- (success)="onSuccess()"
4
- (error)="onError()"
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,8 +0,0 @@
1
- :host {
2
- height: 100%;
3
- display: flex;
4
- justify-content: center;
5
- align-items: center;
6
- flex-direction: column;
7
- gap: 20px;
8
- }
@@ -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,40 +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() {
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
@@ -1,13 +0,0 @@
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
- }
@@ -1,19 +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
- descopeFlowId: '',
11
- descopeDebugMode: false,
12
- descopeTheme: '',
13
- descopeLocale: '',
14
- descopeRedirectUrl: '',
15
- descopeTenantId: '',
16
- descopeTelemetryKey: '',
17
- descopeStepUpFlowId: '',
18
- backendUrl: ''
19
- };
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>
@@ -1,7 +0,0 @@
1
- import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2
-
3
- import { AppModule } from './app/app.module';
4
-
5
- platformBrowserDynamic()
6
- .bootstrapModule(AppModule)
7
- .catch((err) => console.error(err));
@@ -1,21 +0,0 @@
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
- }
@@ -1,10 +0,0 @@
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
- "types": []
7
- },
8
- "files": ["src/main.ts"],
9
- "include": ["src/**/*.d.ts"]
10
- }
@@ -1,10 +0,0 @@
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 DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": ["config:base"]
4
- }