@descope/angular-sdk 0.0.0-next-cc7eda17-20231228 → 0.0.0-next-7122eda6-20231231

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 (111) hide show
  1. package/README.md +11 -450
  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 +38 -77
  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 -43
  37. package/.github/workflows/publish.yml +0 -31
  38. package/.github/workflows/release.yml +0 -41
  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 -21
  50. package/projects/angular-sdk/ng-package.json +0 -8
  51. package/projects/angular-sdk/src/environment.ts +0 -3
  52. package/projects/angular-sdk/src/lib/components/descope/descope.component.spec.ts +0 -104
  53. package/projects/angular-sdk/src/lib/components/descope/descope.component.ts +0 -114
  54. package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.html +0 -15
  55. package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.spec.ts +0 -53
  56. package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.ts +0 -32
  57. package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.html +0 -15
  58. package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.spec.ts +0 -51
  59. package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.ts +0 -32
  60. package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.html +0 -15
  61. package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.spec.ts +0 -53
  62. package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.ts +0 -32
  63. package/projects/angular-sdk/src/lib/descope-auth.module.ts +0 -46
  64. package/projects/angular-sdk/src/lib/services/descope-auth.guard.spec.ts +0 -76
  65. package/projects/angular-sdk/src/lib/services/descope-auth.guard.ts +0 -16
  66. package/projects/angular-sdk/src/lib/services/descope-auth.service.spec.ts +0 -264
  67. package/projects/angular-sdk/src/lib/services/descope-auth.service.ts +0 -176
  68. package/projects/angular-sdk/src/lib/services/descope.interceptor.spec.ts +0 -102
  69. package/projects/angular-sdk/src/lib/services/descope.interceptor.ts +0 -76
  70. package/projects/angular-sdk/src/lib/types/types.ts +0 -10
  71. package/projects/angular-sdk/src/lib/utils/constants.ts +0 -8
  72. package/projects/angular-sdk/src/lib/utils/helpers.spec.ts +0 -103
  73. package/projects/angular-sdk/src/lib/utils/helpers.ts +0 -36
  74. package/projects/angular-sdk/tsconfig.lib.json +0 -12
  75. package/projects/angular-sdk/tsconfig.lib.prod.json +0 -10
  76. package/projects/angular-sdk/tsconfig.spec.json +0 -11
  77. package/projects/demo-app/.eslintrc.json +0 -31
  78. package/projects/demo-app/src/app/app-routing.module.ts +0 -23
  79. package/projects/demo-app/src/app/app.component.html +0 -3
  80. package/projects/demo-app/src/app/app.component.scss +0 -16
  81. package/projects/demo-app/src/app/app.component.spec.ts +0 -37
  82. package/projects/demo-app/src/app/app.component.ts +0 -8
  83. package/projects/demo-app/src/app/app.module.ts +0 -52
  84. package/projects/demo-app/src/app/home/home.component.html +0 -23
  85. package/projects/demo-app/src/app/home/home.component.scss +0 -15
  86. package/projects/demo-app/src/app/home/home.component.spec.ts +0 -44
  87. package/projects/demo-app/src/app/home/home.component.ts +0 -61
  88. package/projects/demo-app/src/app/interceptor/auth.interceptor.ts +0 -20
  89. package/projects/demo-app/src/app/login/login.component.html +0 -12
  90. package/projects/demo-app/src/app/login/login.component.spec.ts +0 -42
  91. package/projects/demo-app/src/app/login/login.component.ts +0 -35
  92. package/projects/demo-app/src/app/protected/protected.component.html +0 -18
  93. package/projects/demo-app/src/app/protected/protected.component.scss +0 -8
  94. package/projects/demo-app/src/app/protected/protected.component.spec.ts +0 -42
  95. package/projects/demo-app/src/app/protected/protected.component.ts +0 -40
  96. package/projects/demo-app/src/assets/.gitkeep +0 -0
  97. package/projects/demo-app/src/environments/conifg.ts +0 -13
  98. package/projects/demo-app/src/environments/environment.ts +0 -19
  99. package/projects/demo-app/src/favicon.ico +0 -0
  100. package/projects/demo-app/src/index.html +0 -17
  101. package/projects/demo-app/src/main.ts +0 -7
  102. package/projects/demo-app/src/styles.scss +0 -21
  103. package/projects/demo-app/tsconfig.app.json +0 -10
  104. package/projects/demo-app/tsconfig.spec.json +0 -10
  105. package/renovate.json +0 -4
  106. package/scripts/gitleaks/.gitleaks.toml +0 -653
  107. package/scripts/gitleaks/gitleaks.sh +0 -34
  108. package/scripts/setversion/setversion.js +0 -20
  109. package/setup-jest.ts +0 -1
  110. package/thirdPartyLicenseCollector_linux_amd64 +0 -0
  111. package/tsconfig.json +0 -35
package/angular.json DELETED
@@ -1,154 +0,0 @@
1
- {
2
- "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
- "version": 1,
4
- "newProjectRoot": "projects",
5
- "projects": {
6
- "angular-sdk": {
7
- "projectType": "library",
8
- "root": "projects/angular-sdk",
9
- "sourceRoot": "projects/angular-sdk/src",
10
- "prefix": "lib",
11
- "architect": {
12
- "build": {
13
- "builder": "@angular-devkit/build-angular:ng-packagr",
14
- "options": {
15
- "project": "projects/angular-sdk/ng-package.json"
16
- },
17
- "configurations": {
18
- "production": {
19
- "tsConfig": "projects/angular-sdk/tsconfig.lib.prod.json"
20
- },
21
- "development": {
22
- "tsConfig": "projects/angular-sdk/tsconfig.lib.json"
23
- }
24
- },
25
- "defaultConfiguration": "production"
26
- },
27
- "test": {
28
- "builder": "@angular-devkit/build-angular:karma",
29
- "options": {
30
- "tsConfig": "projects/angular-sdk/tsconfig.spec.json",
31
- "polyfills": ["zone.js", "zone.js/testing"]
32
- }
33
- },
34
- "lint": {
35
- "builder": "@angular-eslint/builder:lint",
36
- "options": {
37
- "lintFilePatterns": [
38
- "projects/angular-sdk/**/*.ts",
39
- "projects/angular-sdk/**/*.html"
40
- ]
41
- }
42
- }
43
- }
44
- },
45
- "demo-app": {
46
- "projectType": "application",
47
- "schematics": {
48
- "@schematics/angular:component": {
49
- "style": "scss"
50
- }
51
- },
52
- "root": "projects/demo-app",
53
- "sourceRoot": "projects/demo-app/src",
54
- "prefix": "app",
55
- "architect": {
56
- "build": {
57
- "builder": "@angular-devkit/build-angular:browser",
58
- "options": {
59
- "allowedCommonJsDependencies": ["lodash.get"],
60
- "outputPath": "dist/demo-app",
61
- "index": "projects/demo-app/src/index.html",
62
- "main": "projects/demo-app/src/main.ts",
63
- "polyfills": ["zone.js"],
64
- "tsConfig": "projects/demo-app/tsconfig.app.json",
65
- "inlineStyleLanguage": "scss",
66
- "assets": [
67
- "projects/demo-app/src/favicon.ico",
68
- "projects/demo-app/src/assets"
69
- ],
70
- "styles": ["projects/demo-app/src/styles.scss"],
71
- "scripts": []
72
- },
73
- "configurations": {
74
- "production": {
75
- "budgets": [
76
- {
77
- "type": "initial",
78
- "maximumWarning": "500kb",
79
- "maximumError": "1mb"
80
- },
81
- {
82
- "type": "anyComponentStyle",
83
- "maximumWarning": "2kb",
84
- "maximumError": "4kb"
85
- }
86
- ],
87
- "outputHashing": "all"
88
- },
89
- "development": {
90
- "buildOptimizer": false,
91
- "optimization": false,
92
- "vendorChunk": true,
93
- "extractLicenses": false,
94
- "sourceMap": true,
95
- "namedChunks": true,
96
- "fileReplacements": [
97
- {
98
- "replace": "projects/demo-app/src/environments/environment.ts",
99
- "with": "projects/demo-app/src/environments/environment.development.ts"
100
- }
101
- ]
102
- }
103
- },
104
- "defaultConfiguration": "production"
105
- },
106
- "serve": {
107
- "builder": "@angular-devkit/build-angular:dev-server",
108
- "configurations": {
109
- "production": {
110
- "browserTarget": "demo-app:build:production"
111
- },
112
- "development": {
113
- "browserTarget": "demo-app:build:development"
114
- }
115
- },
116
- "defaultConfiguration": "development"
117
- },
118
- "extract-i18n": {
119
- "builder": "@angular-devkit/build-angular:extract-i18n",
120
- "options": {
121
- "browserTarget": "demo-app:build"
122
- }
123
- },
124
- "test": {
125
- "builder": "@angular-devkit/build-angular:karma",
126
- "options": {
127
- "polyfills": ["zone.js", "zone.js/testing"],
128
- "tsConfig": "projects/demo-app/tsconfig.spec.json",
129
- "inlineStyleLanguage": "scss",
130
- "assets": [
131
- "projects/demo-app/src/favicon.ico",
132
- "projects/demo-app/src/assets"
133
- ],
134
- "styles": ["projects/demo-app/src/styles.scss"],
135
- "scripts": []
136
- }
137
- },
138
- "lint": {
139
- "builder": "@angular-eslint/builder:lint",
140
- "options": {
141
- "lintFilePatterns": [
142
- "projects/demo-app/**/*.ts",
143
- "projects/demo-app/**/*.html"
144
- ]
145
- }
146
- }
147
- }
148
- }
149
- },
150
- "cli": {
151
- "schematicCollections": ["@angular-eslint/schematics"],
152
- "analytics": false
153
- }
154
- }
package/jest.config.js DELETED
@@ -1,17 +0,0 @@
1
- module.exports = {
2
- preset: 'jest-preset-angular',
3
- setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
4
- roots: ['<rootDir>/projects/angular-sdk', '<rootDir>/projects/demo-app'],
5
- collectCoverage: true,
6
- coverageDirectory: 'coverage',
7
- collectCoverageFrom: ['projects/**/*.{js,ts}'],
8
- transform: {
9
- '^.+\\.(ts|js|html)$': [
10
- 'jest-preset-angular',
11
- {
12
- tsconfig: './projects/angular-sdk/tsconfig.spec.json',
13
- stringifyContentPathRegex: '\\.(html|svg)$'
14
- }
15
- ]
16
- }
17
- };
@@ -1,32 +0,0 @@
1
- {
2
- "extends": "../../.eslintrc.json",
3
- "ignorePatterns": ["!**/*"],
4
- "overrides": [
5
- {
6
- "files": ["*.ts"],
7
- "rules": {
8
- "@angular-eslint/directive-selector": [
9
- "error",
10
- {
11
- "type": "attribute",
12
- "prefix": "lib",
13
- "style": "camelCase"
14
- }
15
- ],
16
- "@angular-eslint/component-selector": [
17
- "error",
18
- {
19
- "type": "element",
20
- "prefix": "",
21
- "style": "kebab-case"
22
- }
23
- ],
24
- "@angular-eslint/no-output-native": "off"
25
- }
26
- },
27
- {
28
- "files": ["*.html"],
29
- "rules": {}
30
- }
31
- ]
32
- }
@@ -1,21 +0,0 @@
1
- # AngularSdk
2
-
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.2.0.
4
-
5
- ## Code scaffolding
6
-
7
- Run `ng generate component component-name --project angular-sdk` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project angular-sdk`.
8
-
9
- > Note: Don't forget to add `--project angular-sdk` or else it will be added to the default project in your `angular.json` file.
10
-
11
- ## Build
12
-
13
- Run `ng build angular-sdk` to build the project. The build artifacts will be stored in the `dist/` directory.
14
-
15
- ## Running unit tests
16
-
17
- Run `ng test angular-sdk` to execute the unit tests via [Karma](https://karma-runner.github.io).
18
-
19
- ## Further help
20
-
21
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
@@ -1,8 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist",
4
- "lib": {
5
- "entryFile": "src/public-api.ts"
6
- },
7
- "allowedNonPeerDependencies": ["@descope/web-component"]
8
- }
@@ -1,3 +0,0 @@
1
- export const environment = {
2
- buildVersion: '0.0.0-next-cc7eda17-20231228'
3
- };
@@ -1,104 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { DescopeComponent } from './descope.component';
4
- import createSdk from '@descope/web-js-sdk';
5
- import { DescopeAuthConfig } from '../../types/types';
6
- import { CUSTOM_ELEMENTS_SCHEMA, EventEmitter } from '@angular/core';
7
- import mocked = jest.mocked;
8
-
9
- jest.mock('@descope/web-js-sdk');
10
- //Mock DescopeWebComponent
11
- jest.mock('@descope/web-component', () => {
12
- return jest.fn(() => {
13
- // Create a mock DOM element
14
- return document.createElement('descope-wc');
15
- });
16
- });
17
-
18
- describe('DescopeComponent', () => {
19
- let component: DescopeComponent;
20
- let fixture: ComponentFixture<DescopeComponent>;
21
- let mockedCreateSdk: jest.Mock;
22
- const onSessionTokenChangeSpy = jest.fn();
23
- const onUserChangeSpy = jest.fn();
24
- const afterRequestHooksSpy = jest.fn();
25
- const mockConfig: DescopeAuthConfig = {
26
- projectId: 'someProject'
27
- };
28
-
29
- beforeEach(() => {
30
- mockedCreateSdk = mocked(createSdk);
31
-
32
- mockedCreateSdk.mockReturnValue({
33
- onSessionTokenChange: onSessionTokenChangeSpy,
34
- onUserChange: onUserChangeSpy,
35
- httpClient: {
36
- hooks: {
37
- afterRequest: afterRequestHooksSpy
38
- }
39
- }
40
- });
41
-
42
- TestBed.configureTestingModule({
43
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
44
- providers: [
45
- DescopeAuthConfig,
46
- { provide: DescopeAuthConfig, useValue: mockConfig }
47
- ]
48
- });
49
-
50
- fixture = TestBed.createComponent(DescopeComponent);
51
- component = fixture.componentInstance;
52
- component.projectId = '123';
53
- component.flowId = 'sign-in';
54
- component.locale = 'en-US';
55
- component.success = new EventEmitter<void>();
56
- component.error = new EventEmitter<void>();
57
- component.logger = { info: jest.fn(), error: jest.fn(), warn: jest.fn() };
58
- component.errorTransformer = jest.fn();
59
- fixture.detectChanges();
60
- });
61
-
62
- it('should create', () => {
63
- expect(component).toBeTruthy();
64
- const html: HTMLElement = fixture.nativeElement;
65
- const webComponentHtml = html.querySelector('descope-wc');
66
- expect(webComponentHtml).toBeDefined();
67
- });
68
-
69
- it('should correctly setup attributes based on inputs', () => {
70
- const html: HTMLElement = fixture.nativeElement;
71
- const webComponentHtml = html.querySelector('descope-wc')!;
72
- expect(webComponentHtml.getAttribute('project-id')).toStrictEqual('123');
73
- expect(webComponentHtml.getAttribute('flow-id')).toStrictEqual('sign-in');
74
- expect(webComponentHtml.getAttribute('locale')).toStrictEqual('en-US');
75
- expect(webComponentHtml.getAttribute('logger')).toBeDefined();
76
- expect(webComponentHtml.getAttribute('error-transformer')).toBeDefined();
77
- expect(webComponentHtml.getAttribute('redirect-url')).toBeNull();
78
- });
79
-
80
- it('should emit success when web component emits success', () => {
81
- const html: HTMLElement = fixture.nativeElement;
82
- const webComponentHtml = html.querySelector('descope-wc')!;
83
-
84
- component.success.subscribe(() => {
85
- expect(true).toBeTruthy();
86
- expect(afterRequestHooksSpy).toHaveBeenCalled();
87
- });
88
- webComponentHtml.dispatchEvent(
89
- new CustomEvent('success', {
90
- detail: { user: { name: 'user1' }, sessionJwt: 'session1' }
91
- })
92
- );
93
- });
94
-
95
- it('should emit error when web component emits error', () => {
96
- const html: HTMLElement = fixture.nativeElement;
97
- const webComponentHtml = html.querySelector('descope-wc')!;
98
-
99
- component.error.subscribe(() => {
100
- expect(true).toBeTruthy();
101
- });
102
- webComponentHtml.dispatchEvent(new CustomEvent('error'));
103
- });
104
- });
@@ -1,114 +0,0 @@
1
- import {
2
- Component,
3
- ElementRef,
4
- EventEmitter,
5
- Input,
6
- OnChanges,
7
- OnInit,
8
- Output
9
- } from '@angular/core';
10
- import DescopeWebComponent from '@descope/web-component';
11
- import DescopeWc, { ILogger } from '@descope/web-component';
12
- import { DescopeAuthService } from '../../services/descope-auth.service';
13
- import { from } from 'rxjs';
14
- import { baseHeaders } from '../../utils/constants';
15
- import { DescopeAuthConfig } from '../../types/types';
16
-
17
- @Component({
18
- selector: 'descope[flowId]',
19
- standalone: true,
20
- template: ''
21
- })
22
- export class DescopeComponent implements OnInit, OnChanges {
23
- projectId: string;
24
- @Input() flowId: string;
25
-
26
- @Input() locale: string;
27
- @Input() theme: 'light' | 'dark' | 'os';
28
- @Input() tenant: string;
29
- @Input() telemetryKey: string;
30
- @Input() redirectUrl: string;
31
- @Input() autoFocus: true | false | 'skipFirstScreen';
32
-
33
- @Input() debug: boolean;
34
- @Input() errorTransformer: (error: { text: string; type: string }) => string;
35
- @Input() logger: ILogger;
36
-
37
- @Output() success: EventEmitter<void> = new EventEmitter<void>();
38
- @Output() error: EventEmitter<void> = new EventEmitter<void>();
39
-
40
- private readonly webComponent: DescopeWebComponent =
41
- new DescopeWebComponent();
42
-
43
- constructor(
44
- private elementRef: ElementRef,
45
- private authService: DescopeAuthService,
46
- descopeConfig: DescopeAuthConfig
47
- ) {
48
- this.projectId = descopeConfig.projectId;
49
- }
50
-
51
- ngOnInit() {
52
- DescopeWc.sdkConfigOverrides = { baseHeaders };
53
- this.setupWebComponent();
54
- this.elementRef.nativeElement.appendChild(this.webComponent);
55
- }
56
-
57
- ngOnChanges(): void {
58
- this.setupWebComponent();
59
- }
60
-
61
- private setupWebComponent() {
62
- this.webComponent.setAttribute('project-id', this.projectId);
63
- this.webComponent.setAttribute('flow-id', this.flowId);
64
- if (this.locale) {
65
- this.webComponent.setAttribute('locale', this.locale);
66
- }
67
- if (this.theme) {
68
- this.webComponent.setAttribute('theme', this.theme);
69
- }
70
- if (this.tenant) {
71
- this.webComponent.setAttribute('tenant', this.tenant);
72
- }
73
- if (this.telemetryKey) {
74
- this.webComponent.setAttribute('telemetryKey', this.telemetryKey);
75
- }
76
- if (this.redirectUrl) {
77
- this.webComponent.setAttribute('redirect-url', this.redirectUrl);
78
- }
79
- if (this.autoFocus) {
80
- this.webComponent.setAttribute('auto-focus', this.autoFocus.toString());
81
- }
82
- if (this.debug) {
83
- this.webComponent.setAttribute('debug', this.debug.toString());
84
- }
85
-
86
- if (this.errorTransformer) {
87
- this.webComponent.errorTransformer = this.errorTransformer;
88
- }
89
-
90
- if (this.logger) {
91
- this.webComponent.logger = this.logger;
92
- }
93
-
94
- if (this.success) {
95
- this.webComponent.addEventListener('success', (e: Event) => {
96
- from(
97
- this.authService.descopeSdk.httpClient.hooks?.afterRequest!(
98
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
- {} as any,
100
- new Response(JSON.stringify((e as CustomEvent).detail))
101
- ) as Promise<unknown>
102
- ).subscribe(() => {
103
- this.success?.emit();
104
- });
105
- });
106
- }
107
-
108
- if (this.error) {
109
- this.webComponent.addEventListener('error', () => {
110
- this.error?.emit();
111
- });
112
- }
113
- }
114
- }
@@ -1,15 +0,0 @@
1
- <descope
2
- (success)="success.emit()"
3
- (error)="error.emit()"
4
- flowId="sign-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
- [logger]="logger"
14
- >
15
- </descope>
@@ -1,53 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { SignInFlowComponent } from './sign-in-flow.component';
3
- import { ngMocks } from 'ng-mocks';
4
- import { DescopeComponent } from '../descope/descope.component';
5
- import { DescopeAuthConfig } from '../../types/types';
6
- import createSdk from '@descope/web-js-sdk';
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
-
17
- describe('SignInFlowComponent', () => {
18
- let component: SignInFlowComponent;
19
- let fixture: ComponentFixture<SignInFlowComponent>;
20
- let mockedCreateSdk: jest.Mock;
21
-
22
- beforeEach(() => {
23
- mockedCreateSdk = mocked(createSdk);
24
-
25
- mockedCreateSdk.mockReturnValue({
26
- onSessionTokenChange: jest.fn(),
27
- onUserChange: jest.fn()
28
- });
29
-
30
- TestBed.configureTestingModule({
31
- providers: [
32
- DescopeAuthConfig,
33
- {
34
- provide: DescopeAuthConfig,
35
- useValue: {
36
- projectId: 'someProject'
37
- }
38
- }
39
- ]
40
- });
41
-
42
- fixture = TestBed.createComponent(SignInFlowComponent);
43
- component = fixture.componentInstance;
44
- fixture.detectChanges();
45
- });
46
-
47
- it('should create and be correctly configured', () => {
48
- expect(component).toBeTruthy();
49
- const mockComponent =
50
- ngMocks.find<DescopeComponent>('[flowId=sign-in]').componentInstance;
51
- expect(mockComponent.flowId).toStrictEqual('sign-in');
52
- });
53
- });
@@ -1,32 +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() logger: ILogger;
25
-
26
- @Output() success: EventEmitter<void> = new EventEmitter<void>();
27
- @Output() error: EventEmitter<void> = new EventEmitter<void>();
28
-
29
- constructor(descopeConfig: DescopeAuthConfig) {
30
- this.projectId = descopeConfig.projectId;
31
- }
32
- }
@@ -1,15 +0,0 @@
1
- <descope
2
- (success)="success.emit()"
3
- (error)="error.emit()"
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
- [logger]="logger"
14
- >
15
- </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,32 +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() logger: ILogger;
25
-
26
- @Output() success: EventEmitter<void> = new EventEmitter<void>();
27
- @Output() error: EventEmitter<void> = new EventEmitter<void>();
28
-
29
- constructor(descopeConfig: DescopeAuthConfig) {
30
- this.projectId = descopeConfig.projectId;
31
- }
32
- }
@@ -1,15 +0,0 @@
1
- <descope
2
- (success)="success.emit()"
3
- (error)="error.emit()"
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
- [logger]="logger"
14
- >
15
- </descope>