@descope/angular-sdk 0.0.0-next-32627c0f-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.
Files changed (82) hide show
  1. package/.editorconfig +16 -0
  2. package/.eslintrc.json +40 -0
  3. package/.github/workflows/ci.yml +98 -0
  4. package/.github/workflows/publish-next.yml +43 -0
  5. package/.github/workflows/publish.yml +31 -0
  6. package/.github/workflows/release.yml +41 -0
  7. package/.husky/pre-commit +4 -0
  8. package/.prettierrc +8 -0
  9. package/.vscode/extensions.json +4 -0
  10. package/.vscode/launch.json +20 -0
  11. package/.vscode/settings.json +3 -0
  12. package/.vscode/tasks.json +42 -0
  13. package/LICENSE +21 -0
  14. package/README.md +448 -13
  15. package/angular.json +154 -0
  16. package/jest.config.js +17 -0
  17. package/package.json +77 -41
  18. package/projects/angular-sdk/.eslintrc.json +32 -0
  19. package/projects/angular-sdk/README.md +21 -0
  20. package/projects/angular-sdk/ng-package.json +8 -0
  21. package/projects/angular-sdk/src/environment.ts +3 -0
  22. package/projects/angular-sdk/src/lib/components/descope/descope.component.spec.ts +104 -0
  23. package/projects/angular-sdk/src/lib/components/descope/descope.component.ts +114 -0
  24. package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.html +15 -0
  25. package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.spec.ts +53 -0
  26. package/projects/angular-sdk/src/lib/components/sign-in-flow/sign-in-flow.component.ts +32 -0
  27. package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.html +15 -0
  28. package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.spec.ts +51 -0
  29. package/projects/angular-sdk/src/lib/components/sign-up-flow/sign-up-flow.component.ts +32 -0
  30. package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.html +15 -0
  31. package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.spec.ts +53 -0
  32. package/projects/angular-sdk/src/lib/components/sign-up-or-in-flow/sign-up-or-in-flow.component.ts +32 -0
  33. package/projects/angular-sdk/src/lib/descope-auth.module.ts +46 -0
  34. package/projects/angular-sdk/src/lib/services/descope-auth.guard.spec.ts +76 -0
  35. package/projects/angular-sdk/src/lib/services/descope-auth.guard.ts +16 -0
  36. package/projects/angular-sdk/src/lib/services/descope-auth.service.spec.ts +264 -0
  37. package/projects/angular-sdk/src/lib/services/descope-auth.service.ts +176 -0
  38. package/projects/angular-sdk/src/lib/services/descope.interceptor.spec.ts +102 -0
  39. package/projects/angular-sdk/src/lib/services/descope.interceptor.ts +76 -0
  40. package/projects/angular-sdk/src/lib/types/types.ts +10 -0
  41. package/projects/angular-sdk/src/lib/utils/constants.ts +8 -0
  42. package/projects/angular-sdk/src/lib/utils/helpers.spec.ts +103 -0
  43. package/projects/angular-sdk/src/lib/utils/helpers.ts +36 -0
  44. package/projects/angular-sdk/src/public-api.ts +13 -0
  45. package/projects/angular-sdk/tsconfig.lib.json +12 -0
  46. package/projects/angular-sdk/tsconfig.lib.prod.json +10 -0
  47. package/projects/angular-sdk/tsconfig.spec.json +11 -0
  48. package/projects/demo-app/.eslintrc.json +31 -0
  49. package/projects/demo-app/src/app/app-routing.module.ts +23 -0
  50. package/projects/demo-app/src/app/app.component.html +3 -0
  51. package/projects/demo-app/src/app/app.component.scss +16 -0
  52. package/projects/demo-app/src/app/app.component.spec.ts +37 -0
  53. package/projects/demo-app/src/app/app.component.ts +8 -0
  54. package/projects/demo-app/src/app/app.module.ts +52 -0
  55. package/projects/demo-app/src/app/home/home.component.html +23 -0
  56. package/projects/demo-app/src/app/home/home.component.scss +15 -0
  57. package/projects/demo-app/src/app/home/home.component.spec.ts +44 -0
  58. package/projects/demo-app/src/app/home/home.component.ts +61 -0
  59. package/projects/demo-app/src/app/interceptor/auth.interceptor.ts +20 -0
  60. package/projects/demo-app/src/app/login/login.component.html +12 -0
  61. package/projects/demo-app/src/app/login/login.component.spec.ts +42 -0
  62. package/projects/demo-app/src/app/login/login.component.ts +35 -0
  63. package/projects/demo-app/src/app/protected/protected.component.html +18 -0
  64. package/projects/demo-app/src/app/protected/protected.component.scss +8 -0
  65. package/projects/demo-app/src/app/protected/protected.component.spec.ts +42 -0
  66. package/projects/demo-app/src/app/protected/protected.component.ts +40 -0
  67. package/projects/demo-app/src/assets/.gitkeep +0 -0
  68. package/projects/demo-app/src/environments/conifg.ts +13 -0
  69. package/projects/demo-app/src/environments/environment.ts +19 -0
  70. package/projects/demo-app/src/favicon.ico +0 -0
  71. package/projects/demo-app/src/index.html +17 -0
  72. package/projects/demo-app/src/main.ts +7 -0
  73. package/projects/demo-app/src/styles.scss +21 -0
  74. package/projects/demo-app/tsconfig.app.json +10 -0
  75. package/projects/demo-app/tsconfig.spec.json +10 -0
  76. package/renovate.json +4 -0
  77. package/scripts/gitleaks/.gitleaks.toml +653 -0
  78. package/scripts/gitleaks/gitleaks.sh +34 -0
  79. package/scripts/setversion/setversion.js +20 -0
  80. package/setup-jest.ts +1 -0
  81. package/thirdPartyLicenseCollector_linux_amd64 +0 -0
  82. package/tsconfig.json +35 -0
package/README.md CHANGED
@@ -1,25 +1,460 @@
1
- # AngularSdk
1
+ # Descope SDK for Angular
2
2
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.2.0.
3
+ The Descope SDK for Angular provides convenient access to the Descope for an application written on top of Angular. You can read more on the [Descope Website](https://descope.com).
4
4
 
5
- ## Code scaffolding
5
+ ## Requirements
6
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`.
7
+ - The SDK supports Angular version 16 and above.
8
+ - A Descope `Project ID` is required for using the SDK. Find it on the [project page in the Descope Console](https://app.descope.com/settings/project).
8
9
 
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
+ ## Installing the SDK
10
11
 
11
- ## Build
12
+ Install the package with:
12
13
 
13
- Run `ng build angular-sdk` to build the project. The build artifacts will be stored in the `dist/` directory.
14
+ ```bash
15
+ npm i --save @descope/angular-sdk
16
+ ```
14
17
 
15
- ## Publishing
18
+ Add Descope type definitions to your `tsconfig.ts`
16
19
 
17
- After building your library with `ng build angular-sdk`, go to the dist folder `cd dist/angular-sdk` and run `npm publish`.
20
+ ```
21
+ "compilerOptions": {
22
+ "typeRoots": ["./node_modules/@descope"],
23
+ <other options>
24
+ }
25
+ ```
18
26
 
19
- ## Running unit tests
27
+ ## Usage
20
28
 
21
- Run `ng test angular-sdk` to execute the unit tests via [Karma](https://karma-runner.github.io).
29
+ ### NgModule - Import `DescopeAuthModule` to your application
22
30
 
23
- ## Further help
31
+ `app.module.ts`
24
32
 
25
- 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.
33
+ ```ts
34
+ import { NgModule } from '@angular/core';
35
+ import { BrowserModule } from '@angular/platform-browser';
36
+
37
+ import { AppComponent } from './app.component';
38
+ import { DescopeAuthModule } from '@descope/angular-sdk';
39
+
40
+ @NgModule({
41
+ declarations: [AppComponent],
42
+ imports: [
43
+ BrowserModule,
44
+ DescopeAuthModule.forRoot({
45
+ projectId: '<your_project_id>'
46
+ })
47
+ ],
48
+ bootstrap: [AppComponent]
49
+ })
50
+ export class AppModule {}
51
+ ```
52
+
53
+ ### Standalone Mode - Configure Descope SDK for your application
54
+
55
+ `main.ts`
56
+
57
+ ```ts
58
+ import { bootstrapApplication } from '@angular/platform-browser';
59
+ import { AppComponent } from './app/app.component';
60
+ import { DescopeAuthConfig } from '@descope/angular-sdk';
61
+
62
+ bootstrapApplication(AppComponent, {
63
+ providers: [
64
+ { provide: DescopeAuthConfig, useValue: { projectId: '<your_project_id>' } }
65
+ ]
66
+ }).catch((err) => console.error(err));
67
+ ```
68
+
69
+ ### Use Descope to render specific flow
70
+
71
+ You can use **default flows** or **provide flow id** directly to the descope component
72
+
73
+ #### 1. Default flows
74
+
75
+ `app.component.html`
76
+
77
+ ```angular2html
78
+ <descope-sign-in-flow
79
+ (success)="onSuccess()"
80
+ (error)="onError()"
81
+ ></descope-sign-in-flow>
82
+ ```
83
+
84
+ `app.component.ts`
85
+
86
+ ```ts
87
+ import { Component } from '@angular/core';
88
+
89
+ @Component({
90
+ selector: 'app-root',
91
+ templateUrl: './app.component.html'
92
+ })
93
+ export class AppComponent {
94
+ onSuccess() {
95
+ console.log('SUCCESSFULLY LOGGED IN FROM WEB COMPONENT');
96
+ }
97
+
98
+ onError() {
99
+ console.log('ERROR FROM LOG IN FLOW FROM WEB COMPONENT');
100
+ }
101
+ }
102
+ ```
103
+
104
+ #### 2. Provide flow id
105
+
106
+ ```angular2html
107
+ <descope
108
+ flowId="<your_flow_id>"
109
+ (success)="<your_success_function>"
110
+ (error)="<your_error_function>"
111
+ <!-- theme can be "light", "dark" or "os", which auto select a theme based on the OS theme. Default is "light"
112
+ theme="dark"
113
+
114
+ locale can be any supported locale which the flow's screen translated to, if not provided, the locale is taken from the browser's locale.
115
+ locale="en"
116
+
117
+ debug can be set to true to enable debug mode
118
+ debug="true"
119
+
120
+ tenant ID for SSO (SAML) login. If not provided, Descope will use the domain of available email to choose the tenant
121
+ tenant=<tenantId>
122
+
123
+ Redirect URL for OAuth and SSO (will be used when redirecting back from the OAuth provider / IdP), or for "Magic Link" and "Enchanted Link" (will be used as a link in the message sent to the the user)
124
+ redirectUrl=<redirectUrl>
125
+
126
+ telemetryKey=<telemtry_key>
127
+
128
+ autoFocus can be true, false or "skipFirstScreen". Default is true.
129
+ - true: automatically focus on the first input of each screen
130
+ - false: do not automatically focus on screen's inputs
131
+ - "skipFirstScreen": automatically focus on the first input of each screen, except first screen
132
+ autoFocus="skipFirstScreen"
133
+
134
+ errorTransformer is a function that receives an error object and returns a string. The returned string will be displayed to the user.
135
+ NOTE: errorTransformer is not required. If not provided, the error object will be displayed as is.
136
+ Example:
137
+ errorTransformer = (error: { text: string; type: string }): string => {
138
+ const translationMap: { [key: string]: string } = {
139
+ SAMLStartFailed: 'Failed to start SAML flow'
140
+ };
141
+ return translationMap[error.type] || error.text;
142
+ };
143
+ ...
144
+ errorTransformer={errorTransformer}
145
+
146
+ logger is an object describing how to log info, warn and errors.
147
+ NOTE: logger is not required. If not provided, the logs will be printed to the console.
148
+ Example:
149
+ const logger = {
150
+ info: (title: string, description: string, state: any) => {
151
+ console.log(title, description, JSON.stringify(state));
152
+ },
153
+ warn: (title: string, description: string) => {
154
+ console.warn(title);
155
+ },
156
+ error: (title: string, description: string) => {
157
+ console.error('OH NOO');
158
+ },
159
+ }
160
+ ...
161
+ logger={logger}-->
162
+ ></descope>
163
+ ```
164
+
165
+ #### Standalone Mode Note:
166
+
167
+ All components in the sdk are standalone, so you can use them by directly importing them to your components.
168
+
169
+ ### Use the `DescopeAuthService` and its exposed fields (`descopeSdk`, `session$`, `user$`) to access authentication state, user details and utilities
170
+
171
+ This can be helpful to implement application-specific logic. Examples:
172
+
173
+ - Render different components if current session is authenticated
174
+ - Render user's content
175
+ - Logout button
176
+
177
+ `app.component.html`
178
+
179
+ ```angular2html
180
+ <p *ngIf="!isAuthenticated"> You are not logged in</p>
181
+ <button *ngIf="isAuthenticated" (click)="logout()">LOGOUT</button>
182
+ <p>User: {{userName}}</p>
183
+ ```
184
+
185
+ `app.component.ts`
186
+
187
+ ```ts
188
+ import { Component, OnInit } from '@angular/core';
189
+ import { DescopeAuthService } from '@descope/angular-sdk';
190
+
191
+ @Component({
192
+ selector: 'app-home',
193
+ templateUrl: './app.component.html',
194
+ styleUrls: ['./app.component.scss']
195
+ })
196
+ export class AppComponent implements OnInit {
197
+ isAuthenticated: boolean = false;
198
+ userName: string = '';
199
+
200
+ constructor(private authService: DescopeAuthService) {}
201
+
202
+ ngOnInit() {
203
+ this.authService.session$.subscribe((session) => {
204
+ this.isAuthenticated = session.isAuthenticated;
205
+ });
206
+ this.authService.user$.subscribe((descopeUser) => {
207
+ if (descopeUser.user) {
208
+ this.userName = descopeUser.user.name ?? '';
209
+ }
210
+ });
211
+ }
212
+
213
+ logout() {
214
+ this.authService.descopeSdk.logout();
215
+ }
216
+ }
217
+ ```
218
+
219
+ ### Session Refresh
220
+
221
+ `DescopeAuthService` provides `refreshSession` and `refreshUser` methods that triggers a single request to the Descope backend to attempt to refresh the session or user. You can use them whenever you want to refresh the session/user. For example you can use `APP_INITIALIZER` provider to attempt to refresh session and user on each page refresh:
222
+
223
+ `app.module.ts`
224
+
225
+ ```ts
226
+ import { APP_INITIALIZER, NgModule } from '@angular/core';
227
+ import { BrowserModule } from '@angular/platform-browser';
228
+ import { AppComponent } from './app.component';
229
+ import { DescopeAuthModule, DescopeAuthService } from '@descope/angular-sdk';
230
+ import { zip } from 'rxjs';
231
+
232
+ export function initializeApp(authService: DescopeAuthService) {
233
+ return () => zip([authService.refreshSession(), authService.refreshUser()]);
234
+ }
235
+
236
+ @NgModule({
237
+ declarations: [AppComponent],
238
+ imports: [
239
+ BrowserModule,
240
+ DescopeAuthModule.forRoot({
241
+ projectId: '<your_project_id>'
242
+ })
243
+ ],
244
+ providers: [
245
+ {
246
+ provide: APP_INITIALIZER,
247
+ useFactory: initializeApp,
248
+ deps: [DescopeAuthService],
249
+ multi: true
250
+ }
251
+ ],
252
+ bootstrap: [AppComponent]
253
+ })
254
+ export class AppModule {}
255
+ ```
256
+
257
+ #### Standalone Mode Note:
258
+
259
+ You can use the same approach with `APP_INITIALIZER` in standalone mode, by adding it to `providers` array of the application.
260
+
261
+ ### Descope Interceptor
262
+
263
+ You can also use `DescopeInterceptor` to attempt to refresh session on each HTTP request that gets `401` or `403` response:
264
+
265
+ `app.module.ts`
266
+
267
+ ```ts
268
+ import { NgModule } from '@angular/core';
269
+ import { BrowserModule } from '@angular/platform-browser';
270
+ import { AppComponent } from './app.component';
271
+ import {
272
+ HttpClientModule,
273
+ provideHttpClient,
274
+ withInterceptors
275
+ } from '@angular/common/http';
276
+ import { DescopeAuthModule, descopeInterceptor } from '@descope/angular-sdk';
277
+
278
+ @NgModule({
279
+ declarations: [AppComponent],
280
+ imports: [
281
+ BrowserModule,
282
+ HttpClientModule,
283
+ DescopeAuthModule.forRoot({
284
+ projectId: '<your_project_id>',
285
+ pathsToIntercept: ['/protectedPath']
286
+ })
287
+ ],
288
+ providers: [provideHttpClient(withInterceptors([descopeInterceptor]))],
289
+ bootstrap: [AppComponent]
290
+ })
291
+ export class AppModule {}
292
+ ```
293
+
294
+ `DescopeInterceptor`:
295
+
296
+ - is configured for requests that urls contain one of `pathsToIntercept`. If not provided it will be used for all requests.
297
+ - attaches session token as `Authorization` header in `Bearer <token>` format
298
+ - if requests get response with `401` or `403` it automatically attempts to refresh session
299
+ - if refresh attempt is successful, it automatically retries original request, otherwise it fails with original error
300
+
301
+ **For more SDK usage examples refer to [docs](https://docs.descope.com/build/guides/client_sdks/)**
302
+
303
+ ### Session token server validation (pass session token to server API)
304
+
305
+ When developing a full-stack application, it is common to have private server API which requires a valid session token:
306
+
307
+ ![session-token-validation-diagram](https://docs.descope.com/static/SessionValidation-cf7b2d5d26594f96421d894273a713d8.png)
308
+
309
+ Note: Descope also provides server-side SDKs in various languages (NodeJS, Go, Python, etc). Descope's server SDKs have out-of-the-box session validation API that supports the options described bellow. To read more about session validation, Read [this section](https://docs.descope.com/build/guides/gettingstarted/#session-validation) in Descope documentation.
310
+
311
+ You can securely communicate with your backend either by using `DescopeInterceptor` or manually adding token to your requests (ie. by using `DescopeAuthService.getSessionToken()` helper function)
312
+
313
+ ### Helper Functions
314
+
315
+ You can also use the following helper methods on `DescopeAuthService` to assist with various actions managing your JWT.
316
+
317
+ - `getSessionToken()` - Get current session token.
318
+ - `getRefreshToken()` - Get current refresh token.
319
+ - `isAuthenticated()` - Returns boolean whether user is authenticated
320
+ - `refreshSession` - Force a refresh on current session token using an existing valid refresh token.
321
+ - `refreshUser` - Force a refresh on current user using an existing valid refresh token.
322
+ - `getJwtRoles(token = getSessionToken(), tenant = '')` - Get current roles from an existing session token. Provide tenant id for specific tenant roles.
323
+ - `getJwtPermissions(token = getSessionToken(), tenant = '')` - Fet current permissions from an existing session token. Provide tenant id for specific tenant permissions.
324
+
325
+ ### Refresh token lifecycle
326
+
327
+ Descope SDK is automatically refreshes the session token when it is about to expire. This is done in the background using the refresh token, without any additional configuration.
328
+
329
+ If the Descope project settings are configured to manage tokens in cookies.
330
+ you must also configure a custom domain, and set it as the `baseUrl` in `DescopeAuthModule`.
331
+
332
+ ### Descope Guard
333
+
334
+ `angular-sdk` provides a convenient route guard that prevents from accessing given route for users that are not authenticated:
335
+
336
+ ```ts
337
+ import { NgModule } from '@angular/core';
338
+ import { RouterModule, Routes } from '@angular/router';
339
+ import { HomeComponent } from './home/home.component';
340
+ import { ProtectedComponent } from './protected/protected.component';
341
+ import { descopeAuthGuard } from '@descope/angular-sdk';
342
+ import { LoginComponent } from './login/login.component';
343
+
344
+ const routes: Routes = [
345
+ {
346
+ path: 'step-up',
347
+ component: ProtectedComponent,
348
+ canActivate: [descopeAuthGuard],
349
+ data: { descopeFallbackUrl: '/' }
350
+ },
351
+ { path: 'login', component: LoginComponent },
352
+ { path: '**', component: HomeComponent }
353
+ ];
354
+
355
+ @NgModule({
356
+ imports: [RouterModule.forRoot(routes, { enableTracing: false })],
357
+ exports: [RouterModule]
358
+ })
359
+ export class AppRoutingModule {}
360
+ ```
361
+
362
+ If not authenticated user tries to access protected route they will be redirected to `descopeFallbackUrl`
363
+
364
+ ## Code Example
365
+
366
+ You can find an example angular app in the [examples folder](./projects/demo-app).
367
+
368
+ ### Setup
369
+
370
+ To run the examples, create `environment.development.ts` file in `environments` folder.
371
+
372
+ ```ts
373
+ import { Env } from './conifg';
374
+
375
+ export const environment: Env = {
376
+ descopeProjectId: '<your_project_id>'
377
+ };
378
+ ```
379
+
380
+ Find your Project ID in the [Descope console](https://app.descope.com/settings/project).
381
+
382
+ ### Run Example
383
+
384
+ Run the following command in the root of the project to build and run the example:
385
+
386
+ ```bash
387
+ npm i && npm start
388
+ ```
389
+
390
+ ### Example Optional Env Variables
391
+
392
+ See the following table for customization environment variables for the example app:
393
+
394
+ | Env Variable | Description | Default value |
395
+ | ------------------- | ------------------------------------------------------------------------------------------------------------- | ----------------- |
396
+ | descopeFlowId | Which flow ID to use in the login page | **sign-up-or-in** |
397
+ | descopeBaseUrl | Custom Descope base URL | None |
398
+ | descopeTheme | Flow theme | None |
399
+ | descopeLocale | Flow locale | Browser's locale |
400
+ | descopeRedirectUrl | Flow redirect URL for OAuth/SSO/Magic Link/Enchanted Link | None |
401
+ | descopeTenantId | Flow tenant ID for SSO/SAML | None |
402
+ | descopeDebugMode | **"true"** - Enable debugger</br>**"false"** - Disable flow debugger | None |
403
+ | descopeStepUpFlowId | Step up flow ID to show to logged in user (via button). e.g. "step-up". Button will be hidden if not provided | None |
404
+ | descopeTelemetryKey | **String** - Telemetry public key provided by Descope Inc | None |
405
+ | descopeBackendUrl | Url to your test backend app in case you want to test e2e | None |
406
+
407
+ Example `environment.development.ts` file:
408
+
409
+ ```ts
410
+ import { Env } from './conifg';
411
+
412
+ export const environment: Env = {
413
+ descopeProjectId: '<your_project_id>',
414
+ descopeBaseUrl: '<your_base_url>',
415
+ descopeFlowId: 'sign-in',
416
+ descopeDebugMode: false,
417
+ descopeTheme: 'os',
418
+ descopeLocale: 'en_US',
419
+ descopeRedirectUrl: '<your_redirect_url>',
420
+ descopeTelemetryKey: '<your_telemetry_key>',
421
+ descopeStepUpFlowId: 'step-up',
422
+ descopeBackendUrl: 'http://localhost:8080/protected'
423
+ };
424
+ ```
425
+
426
+ ## Troubleshooting
427
+
428
+ If you encounter warning during build of your application:
429
+
430
+ ```
431
+ ▲ [WARNING] Module 'lodash.get' used by 'node_modules/@descope/web-component/node_modules/@descope/core-js-sdk/dist/index.esm.js' is not ESM
432
+ ```
433
+
434
+ add `lodash.get` to allowed CommonJS dependencies in `angular.json`
435
+
436
+ ```json
437
+ "architect": {
438
+ "build": {
439
+ "builder": "@angular-devkit/build-angular:browser",
440
+ "options": {
441
+ "allowedCommonJsDependencies": ["lodash.get"],
442
+ <other_options>
443
+ }
444
+ <other_config>
445
+ }
446
+ <other_config>
447
+ }
448
+ ```
449
+
450
+ ## Learn More
451
+
452
+ To learn more please see the [Descope Documentation and API reference page](https://docs.descope.com/).
453
+
454
+ ## Contact Us
455
+
456
+ If you need help you can email [Descope Support](mailto:support@descope.com)
457
+
458
+ ## License
459
+
460
+ The Descope SDK for Angular is licensed for use under the terms and conditions of the [MIT license Agreement](./LICENSE).
package/angular.json ADDED
@@ -0,0 +1,154 @@
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 ADDED
@@ -0,0 +1,17 @@
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
+ };