From cdbbd8087ff3cb22c6be4552fcd0f47c28f79757 Mon Sep 17 00:00:00 2001 From: mendhak Date: Sun, 3 Nov 2019 17:32:55 +0000 Subject: [PATCH 001/262] Copy build output to login-demo directory expected by npm server --- 02-Calling-an-API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02-Calling-an-API/Dockerfile b/02-Calling-an-API/Dockerfile index 07e05d00..1b1f4e36 100644 --- a/02-Calling-an-API/Dockerfile +++ b/02-Calling-an-API/Dockerfile @@ -26,7 +26,7 @@ COPY package.json . RUN npm install --production -COPY --from=build ./app/dist/login-demo ./dist +COPY --from=build ./app/dist/login-demo ./dist/login-demo/ COPY ./server.js . COPY ./auth_config.json . From e01f899bf74b86a45a4c58051b39b2e9262a46c9 Mon Sep 17 00:00:00 2001 From: Chris Rowe Date: Thu, 9 Apr 2020 09:10:58 +0100 Subject: [PATCH 002/262] Fix broken redirects When the target contains route parameters and we use the `navigate` method of the Angular router the route parameters get encoded which will result in an invalid url. We should use `navigateByUrl` here instead. --- 01-Login/src/app/auth/auth.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-Login/src/app/auth/auth.service.ts b/01-Login/src/app/auth/auth.service.ts index 600671ec..85e27044 100644 --- a/01-Login/src/app/auth/auth.service.ts +++ b/01-Login/src/app/auth/auth.service.ts @@ -108,7 +108,7 @@ export class AuthService { // Response will be an array of user and login status authComplete$.subscribe(([user, loggedIn]) => { // Redirect to target route after callback processing - this.router.navigate([targetRoute]); + this.router.navigateByUrl(targetRoute); }); } } From f012dfba2b05895231902a7653d94584fec1ee07 Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Wed, 12 Aug 2020 14:24:56 +0100 Subject: [PATCH 003/262] Remove old 01-Login folder --- 01-Login/.dockerignore | 21 --- 01-Login/.editorconfig | 13 -- 01-Login/.gitignore | 46 ------ 01-Login/Dockerfile | 33 ----- 01-Login/README.md | 72 ---------- 01-Login/angular.json | 121 ---------------- 01-Login/auth_config.json.example | 4 - 01-Login/browserslist | 12 -- 01-Login/e2e/protractor.conf.js | 32 ----- 01-Login/e2e/src/app.e2e-spec.ts | 23 --- 01-Login/e2e/src/app.po.ts | 11 -- 01-Login/e2e/tsconfig.json | 13 -- 01-Login/exec.ps1 | 3 - 01-Login/exec.sh | 3 - 01-Login/karma.conf.js | 32 ----- 01-Login/package.json | 54 ------- 01-Login/src/app/app-routing.module.ts | 24 ---- 01-Login/src/app/app.component.css | 0 01-Login/src/app/app.component.html | 9 -- 01-Login/src/app/app.component.spec.ts | 35 ----- 01-Login/src/app/app.component.ts | 10 -- 01-Login/src/app/app.module.ts | 45 ------ 01-Login/src/app/auth/auth.guard.spec.ts | 15 -- 01-Login/src/app/auth/auth.guard.ts | 32 ----- 01-Login/src/app/auth/auth.service.spec.ts | 12 -- 01-Login/src/app/auth/auth.service.ts | 127 ----------------- .../components/footer/footer.component.css | 0 .../components/footer/footer.component.html | 7 - .../footer/footer.component.spec.ts | 25 ---- .../app/components/footer/footer.component.ts | 15 -- .../app/components/hero/hero.component.css | 3 - .../app/components/hero/hero.component.html | 11 -- .../components/hero/hero.component.spec.ts | 25 ---- .../src/app/components/hero/hero.component.ts | 15 -- .../home-content/home-content.component.css | 0 .../home-content/home-content.component.html | 64 --------- .../home-content.component.spec.ts | 25 ---- .../home-content/home-content.component.ts | 17 --- .../components/loading/loading.component.css | 6 - .../components/loading/loading.component.html | 3 - .../loading/loading.component.spec.ts | 25 ---- .../components/loading/loading.component.ts | 15 -- .../components/nav-bar/nav-bar.component.css | 0 .../components/nav-bar/nav-bar.component.html | 132 ------------------ .../nav-bar/nav-bar.component.spec.ts | 25 ---- .../components/nav-bar/nav-bar.component.ts | 20 --- .../src/app/pages/home/home.component.css | 0 .../src/app/pages/home/home.component.html | 4 - .../src/app/pages/home/home.component.spec.ts | 25 ---- 01-Login/src/app/pages/home/home.component.ts | 16 --- .../app/pages/profile/profile.component.css | 7 - .../app/pages/profile/profile.component.html | 20 --- .../pages/profile/profile.component.spec.ts | 30 ---- .../app/pages/profile/profile.component.ts | 20 --- 01-Login/src/assets/.gitkeep | 0 01-Login/src/assets/loading.svg | 1 - 01-Login/src/assets/logo.png | Bin 2385 -> 0 bytes 01-Login/src/environments/environment.prod.ts | 3 - 01-Login/src/environments/environment.ts | 16 --- 01-Login/src/favicon.ico | Bin 5430 -> 0 bytes 01-Login/src/index.html | 22 --- 01-Login/src/main.ts | 12 -- 01-Login/src/polyfills.ts | 63 --------- 01-Login/src/styles.css | 1 - 01-Login/src/test.ts | 20 --- 01-Login/tsconfig.app.json | 14 -- 01-Login/tsconfig.json | 28 ---- 01-Login/tsconfig.spec.json | 18 --- 01-Login/tslint.json | 92 ------------ 69 files changed, 1647 deletions(-) delete mode 100644 01-Login/.dockerignore delete mode 100644 01-Login/.editorconfig delete mode 100644 01-Login/.gitignore delete mode 100644 01-Login/Dockerfile delete mode 100644 01-Login/README.md delete mode 100644 01-Login/angular.json delete mode 100644 01-Login/auth_config.json.example delete mode 100644 01-Login/browserslist delete mode 100644 01-Login/e2e/protractor.conf.js delete mode 100644 01-Login/e2e/src/app.e2e-spec.ts delete mode 100644 01-Login/e2e/src/app.po.ts delete mode 100644 01-Login/e2e/tsconfig.json delete mode 100644 01-Login/exec.ps1 delete mode 100644 01-Login/exec.sh delete mode 100644 01-Login/karma.conf.js delete mode 100644 01-Login/package.json delete mode 100644 01-Login/src/app/app-routing.module.ts delete mode 100644 01-Login/src/app/app.component.css delete mode 100644 01-Login/src/app/app.component.html delete mode 100644 01-Login/src/app/app.component.spec.ts delete mode 100644 01-Login/src/app/app.component.ts delete mode 100644 01-Login/src/app/app.module.ts delete mode 100644 01-Login/src/app/auth/auth.guard.spec.ts delete mode 100644 01-Login/src/app/auth/auth.guard.ts delete mode 100644 01-Login/src/app/auth/auth.service.spec.ts delete mode 100644 01-Login/src/app/auth/auth.service.ts delete mode 100644 01-Login/src/app/components/footer/footer.component.css delete mode 100644 01-Login/src/app/components/footer/footer.component.html delete mode 100644 01-Login/src/app/components/footer/footer.component.spec.ts delete mode 100644 01-Login/src/app/components/footer/footer.component.ts delete mode 100644 01-Login/src/app/components/hero/hero.component.css delete mode 100644 01-Login/src/app/components/hero/hero.component.html delete mode 100644 01-Login/src/app/components/hero/hero.component.spec.ts delete mode 100644 01-Login/src/app/components/hero/hero.component.ts delete mode 100644 01-Login/src/app/components/home-content/home-content.component.css delete mode 100644 01-Login/src/app/components/home-content/home-content.component.html delete mode 100644 01-Login/src/app/components/home-content/home-content.component.spec.ts delete mode 100644 01-Login/src/app/components/home-content/home-content.component.ts delete mode 100644 01-Login/src/app/components/loading/loading.component.css delete mode 100644 01-Login/src/app/components/loading/loading.component.html delete mode 100644 01-Login/src/app/components/loading/loading.component.spec.ts delete mode 100644 01-Login/src/app/components/loading/loading.component.ts delete mode 100644 01-Login/src/app/components/nav-bar/nav-bar.component.css delete mode 100644 01-Login/src/app/components/nav-bar/nav-bar.component.html delete mode 100644 01-Login/src/app/components/nav-bar/nav-bar.component.spec.ts delete mode 100644 01-Login/src/app/components/nav-bar/nav-bar.component.ts delete mode 100644 01-Login/src/app/pages/home/home.component.css delete mode 100644 01-Login/src/app/pages/home/home.component.html delete mode 100644 01-Login/src/app/pages/home/home.component.spec.ts delete mode 100644 01-Login/src/app/pages/home/home.component.ts delete mode 100644 01-Login/src/app/pages/profile/profile.component.css delete mode 100644 01-Login/src/app/pages/profile/profile.component.html delete mode 100644 01-Login/src/app/pages/profile/profile.component.spec.ts delete mode 100644 01-Login/src/app/pages/profile/profile.component.ts delete mode 100644 01-Login/src/assets/.gitkeep delete mode 100644 01-Login/src/assets/loading.svg delete mode 100644 01-Login/src/assets/logo.png delete mode 100644 01-Login/src/environments/environment.prod.ts delete mode 100644 01-Login/src/environments/environment.ts delete mode 100644 01-Login/src/favicon.ico delete mode 100644 01-Login/src/index.html delete mode 100644 01-Login/src/main.ts delete mode 100644 01-Login/src/polyfills.ts delete mode 100644 01-Login/src/styles.css delete mode 100644 01-Login/src/test.ts delete mode 100644 01-Login/tsconfig.app.json delete mode 100644 01-Login/tsconfig.json delete mode 100644 01-Login/tsconfig.spec.json delete mode 100644 01-Login/tslint.json diff --git a/01-Login/.dockerignore b/01-Login/.dockerignore deleted file mode 100644 index 4882c7b6..00000000 --- a/01-Login/.dockerignore +++ /dev/null @@ -1,21 +0,0 @@ - -dist/ -node_modules/ -exec.* -npm-debug.log* -yarn-error.log -README.md - -# testing -/coverage - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log*% diff --git a/01-Login/.editorconfig b/01-Login/.editorconfig deleted file mode 100644 index e89330a6..00000000 --- a/01-Login/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -# Editor configuration, see https://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -max_line_length = off -trim_trailing_whitespace = false diff --git a/01-Login/.gitignore b/01-Login/.gitignore deleted file mode 100644 index e1478b06..00000000 --- a/01-Login/.gitignore +++ /dev/null @@ -1,46 +0,0 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. -auth_config.json - -# compiled output -/dist -/tmp -/out-tsc -# Only exists if Bazel was run -/bazel-out - -# dependencies -/node_modules - -# profiling files -chrome-profiler-events.json -speed-measure-plugin.json - -# IDEs and editors -/.idea -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# IDE - VSCode -.vscode/* -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -.history/* - -# misc -/.sass-cache -/connect.lock -/coverage -/libpeerconnection.log -npm-debug.log -yarn-error.log -testem.log -/typings - -# System Files -.DS_Store -Thumbs.db diff --git a/01-Login/Dockerfile b/01-Login/Dockerfile deleted file mode 100644 index 8d86c0d9..00000000 --- a/01-Login/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM node:10-alpine AS build - -RUN apk update && apk add git - -RUN mkdir -p /app - -WORKDIR /app - -COPY package.json . - -RUN npm install - -COPY . . - -RUN npm run build - -# ----------------- - -FROM node:10-alpine - -RUN mkdir -p /app - -WORKDIR /app - -COPY --from=build ./app/dist/login-demo . - -RUN npm install -g live-server - -ENV NODE_ENV=production - -EXPOSE 3000 - -CMD ["live-server", "--port=3000", "--host=0.0.0.0", "--no-browser", "--entry-file=index.html"] diff --git a/01-Login/README.md b/01-Login/README.md deleted file mode 100644 index 688e83d1..00000000 --- a/01-Login/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# Sample 01 - Login - -This sample app demonstrates how to log in, log out, and view profile information of the logged-in user. It uses [auth0-spa-js](https://github.com/auth0/auth0-spa-js). - -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.1.2. - -## Configuration - -The sample needs to be configured with your Auth0 domain and client ID in order to work. In the root of the sample, copy `auth_config.json.example` and rename it to `auth_config.json`. Open the file and replace the values with those from your Auth0 tenant: - -```json -{ - "domain": "", - "clientId": "" -} -``` - -## Development server - -Run `npm start` for a dev server. Navigate to `http://localhost:3000`. The app will automatically reload if you change any of the source files. - -## Build - -Run `npm run build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. - -## Run Using Docker - -You can build and run the sample in a Docker container by using the provided scripts: - -```bash -# In Linux / MacOS -sh exec.sh - -# Windows Powershell -./exec.ps1 -``` - -## Further help - -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). - -## Frequently Asked Questions - -We are compiling a list of questions and answers regarding the new JavaScript SDK - if you're having issues running the sample applications, [check the FAQ](https://github.com/auth0/auth0-spa-js/blob/master/FAQ.md)! - -# What is Auth0? - -Auth0 helps you to: - -- Add authentication with [multiple authentication sources](https://docs.auth0.com/identityproviders), either social like **Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, among others**, or enterprise identity systems like **Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider**. -- Add authentication through more traditional **[username/password databases](https://docs.auth0.com/mysql-connection-tutorial)**. -- Add support for **[linking different user accounts](https://docs.auth0.com/link-accounts)** with the same user. -- Support for generating signed [Json Web Tokens](https://docs.auth0.com/jwt) to call your APIs and **flow the user identity** securely. -- Analytics of how, when and where users are logging in. -- Pull data from other sources and add it to the user profile, through [JavaScript rules](https://docs.auth0.com/rules). - -## Create a Free Auth0 Account - -1. Go to [Auth0](https://auth0.com/signup) and click Sign Up. -2. Use Google, GitHub or Microsoft Account to login. - -## Issue Reporting - -If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues. - -## Author - -[Auth0](https://auth0.com) - -## License - -This project is licensed under the MIT license. See the [LICENSE](../LICENSE) file for more info. diff --git a/01-Login/angular.json b/01-Login/angular.json deleted file mode 100644 index 41a9e8b3..00000000 --- a/01-Login/angular.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "version": 1, - "newProjectRoot": "projects", - "projects": { - "login-demo": { - "projectType": "application", - "schematics": {}, - "root": "", - "sourceRoot": "src", - "prefix": "app", - "architect": { - "build": { - "builder": "@angular-devkit/build-angular:browser", - "options": { - "outputPath": "dist/login-demo", - "index": "src/index.html", - "main": "src/main.ts", - "polyfills": "src/polyfills.ts", - "tsConfig": "tsconfig.app.json", - "aot": false, - "assets": [ - "src/favicon.ico", - "src/assets" - ], - "styles": [ - "src/styles.css", - "node_modules/highlight.js/styles/monokai-sublime.css" - ], - "scripts": [] - }, - "configurations": { - "production": { - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.prod.ts" - } - ], - "optimization": true, - "outputHashing": "all", - "sourceMap": false, - "extractCss": true, - "namedChunks": false, - "aot": true, - "extractLicenses": true, - "vendorChunk": false, - "buildOptimizer": true, - "budgets": [ - { - "type": "initial", - "maximumWarning": "2mb", - "maximumError": "5mb" - } - ] - } - } - }, - "serve": { - "builder": "@angular-devkit/build-angular:dev-server", - "options": { - "browserTarget": "login-demo:build" - }, - "configurations": { - "production": { - "browserTarget": "login-demo:build:production" - } - } - }, - "extract-i18n": { - "builder": "@angular-devkit/build-angular:extract-i18n", - "options": { - "browserTarget": "login-demo:build" - } - }, - "test": { - "builder": "@angular-devkit/build-angular:karma", - "options": { - "main": "src/test.ts", - "polyfills": "src/polyfills.ts", - "tsConfig": "tsconfig.spec.json", - "karmaConfig": "karma.conf.js", - "assets": [ - "src/favicon.ico", - "src/assets" - ], - "styles": [ - "src/styles.css" - ], - "scripts": [] - } - }, - "lint": { - "builder": "@angular-devkit/build-angular:tslint", - "options": { - "tsConfig": [ - "tsconfig.app.json", - "tsconfig.spec.json", - "e2e/tsconfig.json" - ], - "exclude": [ - "**/node_modules/**" - ] - } - }, - "e2e": { - "builder": "@angular-devkit/build-angular:protractor", - "options": { - "protractorConfig": "e2e/protractor.conf.js", - "devServerTarget": "login-demo:serve" - }, - "configurations": { - "production": { - "devServerTarget": "login-demo:serve:production" - } - } - } - } - }}, - "defaultProject": "login-demo" -} diff --git a/01-Login/auth_config.json.example b/01-Login/auth_config.json.example deleted file mode 100644 index d02a9dcc..00000000 --- a/01-Login/auth_config.json.example +++ /dev/null @@ -1,4 +0,0 @@ -{ - "clientId": "{CLIENT_ID}", - "domain": "{DOMAIN}" -} diff --git a/01-Login/browserslist b/01-Login/browserslist deleted file mode 100644 index 80848532..00000000 --- a/01-Login/browserslist +++ /dev/null @@ -1,12 +0,0 @@ -# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. -# For additional information regarding the format and rule options, please see: -# https://github.com/browserslist/browserslist#queries - -# You can see what browsers were selected by your queries by running: -# npx browserslist - -> 0.5% -last 2 versions -Firefox ESR -not dead -not IE 9-11 # For IE 9-11 support, remove 'not'. \ No newline at end of file diff --git a/01-Login/e2e/protractor.conf.js b/01-Login/e2e/protractor.conf.js deleted file mode 100644 index 73e4e680..00000000 --- a/01-Login/e2e/protractor.conf.js +++ /dev/null @@ -1,32 +0,0 @@ -// @ts-check -// Protractor configuration file, see link for more information -// https://github.com/angular/protractor/blob/master/lib/config.ts - -const { SpecReporter } = require('jasmine-spec-reporter'); - -/** - * @type { import("protractor").Config } - */ -exports.config = { - allScriptsTimeout: 11000, - specs: [ - './src/**/*.e2e-spec.ts' - ], - capabilities: { - 'browserName': 'chrome' - }, - directConnect: true, - baseUrl: 'http://localhost:4200/', - framework: 'jasmine', - jasmineNodeOpts: { - showColors: true, - defaultTimeoutInterval: 30000, - print: function() {} - }, - onPrepare() { - require('ts-node').register({ - project: require('path').join(__dirname, './tsconfig.json') - }); - jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); - } -}; \ No newline at end of file diff --git a/01-Login/e2e/src/app.e2e-spec.ts b/01-Login/e2e/src/app.e2e-spec.ts deleted file mode 100644 index 4d5a1ce6..00000000 --- a/01-Login/e2e/src/app.e2e-spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { AppPage } from './app.po'; -import { browser, logging } from 'protractor'; - -describe('workspace-project App', () => { - let page: AppPage; - - beforeEach(() => { - page = new AppPage(); - }); - - it('should display welcome message', () => { - page.navigateTo(); - expect(page.getTitleText()).toEqual('Welcome to login-demo!'); - }); - - afterEach(async () => { - // Assert that there are no errors emitted from the browser - const logs = await browser.manage().logs().get(logging.Type.BROWSER); - expect(logs).not.toContain(jasmine.objectContaining({ - level: logging.Level.SEVERE, - } as logging.Entry)); - }); -}); diff --git a/01-Login/e2e/src/app.po.ts b/01-Login/e2e/src/app.po.ts deleted file mode 100644 index 5776aa9e..00000000 --- a/01-Login/e2e/src/app.po.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { browser, by, element } from 'protractor'; - -export class AppPage { - navigateTo() { - return browser.get(browser.baseUrl) as Promise; - } - - getTitleText() { - return element(by.css('app-root h1')).getText() as Promise; - } -} diff --git a/01-Login/e2e/tsconfig.json b/01-Login/e2e/tsconfig.json deleted file mode 100644 index 39b800f7..00000000 --- a/01-Login/e2e/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "../out-tsc/e2e", - "module": "commonjs", - "target": "es5", - "types": [ - "jasmine", - "jasminewd2", - "node" - ] - } -} diff --git a/01-Login/exec.ps1 b/01-Login/exec.ps1 deleted file mode 100644 index 98bd488b..00000000 --- a/01-Login/exec.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -docker build -t auth0-angular-01-login . -docker run --init -p 3000:3000 -it auth0-angular-01-login diff --git a/01-Login/exec.sh b/01-Login/exec.sh deleted file mode 100644 index 98bd488b..00000000 --- a/01-Login/exec.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -docker build -t auth0-angular-01-login . -docker run --init -p 3000:3000 -it auth0-angular-01-login diff --git a/01-Login/karma.conf.js b/01-Login/karma.conf.js deleted file mode 100644 index 08c7b5ed..00000000 --- a/01-Login/karma.conf.js +++ /dev/null @@ -1,32 +0,0 @@ -// Karma configuration file, see link for more information -// https://karma-runner.github.io/1.0/config/configuration-file.html - -module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', '@angular-devkit/build-angular'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage-istanbul-reporter'), - require('@angular-devkit/build-angular/plugins/karma') - ], - client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - coverageIstanbulReporter: { - dir: require('path').join(__dirname, './coverage/login-demo'), - reports: ['html', 'lcovonly', 'text-summary'], - fixWebpackSourcePaths: true - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false, - restartOnFileChange: true - }); -}; diff --git a/01-Login/package.json b/01-Login/package.json deleted file mode 100644 index 9ffe0e51..00000000 --- a/01-Login/package.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "name": "login-demo", - "version": "0.0.0", - "scripts": { - "ng": "ng", - "start": "ng serve --port 3000", - "build": "ng build", - "test": "ng test", - "lint": "ng lint", - "e2e": "ng e2e" - }, - "private": true, - "dependencies": { - "@angular/animations": "~8.2.9", - "@angular/common": "~8.2.9", - "@angular/compiler": "~8.2.9", - "@angular/core": "~8.2.9", - "@angular/forms": "~8.2.9", - "@angular/platform-browser": "~8.2.9", - "@angular/platform-browser-dynamic": "~8.2.9", - "@angular/router": "~8.2.9", - "@auth0/auth0-spa-js": "^1.2.4", - "@fortawesome/angular-fontawesome": "^0.4.0", - "@fortawesome/fontawesome-svg-core": "^1.2.19", - "@fortawesome/free-solid-svg-icons": "^5.9.0", - "ngx-highlightjs": "^3.0.3", - "rxjs": "~6.5.3", - "tslib": "^1.9.0", - "zone.js": "~0.9.1" - }, - "devDependencies": { - "@angular-devkit/build-angular": "~0.803.8", - "@angular/cli": "~8.3.8", - "@angular/compiler-cli": "~8.2.9", - "@angular/language-service": "~8.2.9", - "@ng-bootstrap/ng-bootstrap": "^5.1.1", - "@types/jasmine": "~3.3.8", - "@types/jasminewd2": "~2.0.3", - "@types/node": "~8.9.4", - "codelyzer": "^5.0.0", - "highlight.js": "^9.15.8", - "jasmine-core": "~3.4.0", - "jasmine-spec-reporter": "~4.2.1", - "karma": "~4.1.0", - "karma-chrome-launcher": "~2.2.0", - "karma-coverage-istanbul-reporter": "~2.0.1", - "karma-jasmine": "~2.0.1", - "karma-jasmine-html-reporter": "^1.4.0", - "protractor": "~5.4.0", - "ts-node": "~7.0.0", - "tslint": "~5.15.0", - "typescript": "~3.5.3" - } -} diff --git a/01-Login/src/app/app-routing.module.ts b/01-Login/src/app/app-routing.module.ts deleted file mode 100644 index 5b6129bd..00000000 --- a/01-Login/src/app/app-routing.module.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; -import { HomeComponent } from './pages/home/home.component'; -import { AuthGuard } from './auth/auth.guard'; -import { ProfileComponent } from './pages/profile/profile.component'; - -const routes: Routes = [ - { - path: 'profile', - component: ProfileComponent, - canActivate: [AuthGuard] - }, - { - path: '', - component: HomeComponent, - pathMatch: 'full' - } -]; - -@NgModule({ - imports: [RouterModule.forRoot(routes)], - exports: [RouterModule] -}) -export class AppRoutingModule { } diff --git a/01-Login/src/app/app.component.css b/01-Login/src/app/app.component.css deleted file mode 100644 index e69de29b..00000000 diff --git a/01-Login/src/app/app.component.html b/01-Login/src/app/app.component.html deleted file mode 100644 index a3be3181..00000000 --- a/01-Login/src/app/app.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
- - -
- -
- - -
diff --git a/01-Login/src/app/app.component.spec.ts b/01-Login/src/app/app.component.spec.ts deleted file mode 100644 index e058ebfb..00000000 --- a/01-Login/src/app/app.component.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ - RouterTestingModule - ], - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app).toBeTruthy(); - }); - - it(`should have as title 'login-demo'`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app.title).toEqual('login-demo'); - }); - - it('should render title in a h1 tag', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to login-demo!'); - }); -}); diff --git a/01-Login/src/app/app.component.ts b/01-Login/src/app/app.component.ts deleted file mode 100644 index 7dff7a54..00000000 --- a/01-Login/src/app/app.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-root', - templateUrl: './app.component.html', - styleUrls: ['./app.component.css'] -}) -export class AppComponent { - constructor() {} -} diff --git a/01-Login/src/app/app.module.ts b/01-Login/src/app/app.module.ts deleted file mode 100644 index 5fccbff3..00000000 --- a/01-Login/src/app/app.module.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { BrowserModule } from '@angular/platform-browser'; -import { NgModule } from '@angular/core'; -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import { HighlightModule } from 'ngx-highlightjs'; -import json from 'highlight.js/lib/languages/json'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; - -import { AppRoutingModule } from './app-routing.module'; -import { AppComponent } from './app.component'; -import { HomeComponent } from './pages/home/home.component'; -import { ProfileComponent } from './pages/profile/profile.component'; -import { NavBarComponent } from './components/nav-bar/nav-bar.component'; -import { FooterComponent } from './components/footer/footer.component'; -import { HeroComponent } from './components/hero/hero.component'; -import { HomeContentComponent } from './components/home-content/home-content.component'; -import { LoadingComponent } from './components/loading/loading.component'; - -export function hljsLanguages() { - return [{ name: 'json', func: json }]; -} - -@NgModule({ - declarations: [ - AppComponent, - HomeComponent, - ProfileComponent, - NavBarComponent, - FooterComponent, - HeroComponent, - HomeContentComponent, - LoadingComponent - ], - imports: [ - BrowserModule, - AppRoutingModule, - NgbModule, - HighlightModule.forRoot({ - languages: hljsLanguages - }), - FontAwesomeModule - ], - providers: [], - bootstrap: [AppComponent] -}) -export class AppModule { } diff --git a/01-Login/src/app/auth/auth.guard.spec.ts b/01-Login/src/app/auth/auth.guard.spec.ts deleted file mode 100644 index 7ed05ee8..00000000 --- a/01-Login/src/app/auth/auth.guard.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, async, inject } from '@angular/core/testing'; - -import { AuthGuard } from './auth.guard'; - -describe('AuthGuard', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [AuthGuard] - }); - }); - - it('should ...', inject([AuthGuard], (guard: AuthGuard) => { - expect(guard).toBeTruthy(); - })); -}); diff --git a/01-Login/src/app/auth/auth.guard.ts b/01-Login/src/app/auth/auth.guard.ts deleted file mode 100644 index 440ef415..00000000 --- a/01-Login/src/app/auth/auth.guard.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Injectable } from '@angular/core'; -import { - ActivatedRouteSnapshot, - RouterStateSnapshot, - UrlTree, - CanActivate -} from '@angular/router'; -import { Observable } from 'rxjs'; -import { AuthService } from './auth.service'; -import { tap } from 'rxjs/operators'; - -@Injectable({ - providedIn: 'root' -}) -export class AuthGuard implements CanActivate { - - constructor(private auth: AuthService) {} - - canActivate( - next: ActivatedRouteSnapshot, - state: RouterStateSnapshot - ): Observable | Promise | boolean { - return this.auth.isAuthenticated$.pipe( - tap(loggedIn => { - if (!loggedIn) { - this.auth.login(state.url); - } - }) - ); - } - -} diff --git a/01-Login/src/app/auth/auth.service.spec.ts b/01-Login/src/app/auth/auth.service.spec.ts deleted file mode 100644 index f3d964d2..00000000 --- a/01-Login/src/app/auth/auth.service.spec.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { AuthService } from './auth.service'; - -describe('AuthService', () => { - beforeEach(() => TestBed.configureTestingModule({})); - - it('should be created', () => { - const service: AuthService = TestBed.get(AuthService); - expect(service).toBeTruthy(); - }); -}); diff --git a/01-Login/src/app/auth/auth.service.ts b/01-Login/src/app/auth/auth.service.ts deleted file mode 100644 index 85e27044..00000000 --- a/01-Login/src/app/auth/auth.service.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { Injectable } from '@angular/core'; -import createAuth0Client from '@auth0/auth0-spa-js'; -import Auth0Client from '@auth0/auth0-spa-js/dist/typings/Auth0Client'; -import * as config from '../../../auth_config.json'; -import { from, of, Observable, BehaviorSubject, combineLatest, throwError } from 'rxjs'; -import { tap, catchError, concatMap, shareReplay } from 'rxjs/operators'; -import { Router } from '@angular/router'; - -@Injectable({ - providedIn: 'root' -}) -export class AuthService { - // Create an observable of Auth0 instance of client - auth0Client$ = (from( - createAuth0Client({ - domain: config.domain, - client_id: config.clientId, - redirect_uri: `${window.location.origin}` - }) - ) as Observable).pipe( - shareReplay(1), // Every subscription receives the same shared value - catchError(err => throwError(err)) - ); - // Define observables for SDK methods that return promises by default - // For each Auth0 SDK method, first ensure the client instance is ready - // concatMap: Using the client instance, call SDK method; SDK returns a promise - // from: Convert that resulting promise into an observable - isAuthenticated$ = this.auth0Client$.pipe( - concatMap((client: Auth0Client) => from(client.isAuthenticated())), - tap(res => this.loggedIn = res) - ); - handleRedirectCallback$ = this.auth0Client$.pipe( - concatMap((client: Auth0Client) => from(client.handleRedirectCallback())) - ); - // Create subject and public observable of user profile data - private userProfileSubject$ = new BehaviorSubject(null); - userProfile$ = this.userProfileSubject$.asObservable(); - // Create a local property for login status - loggedIn: boolean = null; - - constructor(private router: Router) { - // On initial load, check authentication state with authorization server - // Set up local auth streams if user is already authenticated - this.localAuthSetup(); - // Handle redirect from Auth0 login - this.handleAuthCallback(); - } - - // When calling, options can be passed if desired - // https://auth0.github.io/auth0-spa-js/classes/auth0client.html#getuser - getUser$(options?): Observable { - return this.auth0Client$.pipe( - concatMap((client: Auth0Client) => from(client.getUser(options))), - tap(user => this.userProfileSubject$.next(user)) - ); - } - - private localAuthSetup() { - // This should only be called on app initialization - // Set up local authentication streams - const checkAuth$ = this.isAuthenticated$.pipe( - concatMap((loggedIn: boolean) => { - if (loggedIn) { - // If authenticated, get user and set in app - // NOTE: you could pass options here if needed - return this.getUser$(); - } - // If not authenticated, return stream that emits 'false' - return of(loggedIn); - }) - ); - checkAuth$.subscribe(); - } - - login(redirectPath: string = '/') { - // A desired redirect path can be passed to login method - // (e.g., from a route guard) - // Ensure Auth0 client instance exists - this.auth0Client$.subscribe((client: Auth0Client) => { - // Call method to log in - client.loginWithRedirect({ - redirect_uri: `${window.location.origin}`, - appState: { target: redirectPath } - }); - }); - } - - private handleAuthCallback() { - // Call when app reloads after user logs in with Auth0 - const params = window.location.search; - if (params.includes('code=') && params.includes('state=')) { - let targetRoute: string; // Path to redirect to after login processsed - const authComplete$ = this.handleRedirectCallback$.pipe( - // Have client, now call method to handle auth callback redirect - tap(cbRes => { - // Get and set target redirect route from callback results - targetRoute = cbRes.appState && cbRes.appState.target ? cbRes.appState.target : '/'; - }), - concatMap(() => { - // Redirect callback complete; get user and login status - return combineLatest([ - this.getUser$(), - this.isAuthenticated$ - ]); - }) - ); - // Subscribe to authentication completion observable - // Response will be an array of user and login status - authComplete$.subscribe(([user, loggedIn]) => { - // Redirect to target route after callback processing - this.router.navigateByUrl(targetRoute); - }); - } - } - - logout() { - // Ensure Auth0 client instance exists - this.auth0Client$.subscribe((client: Auth0Client) => { - // Call method to log out - client.logout({ - client_id: config.clientId, - returnTo: window.location.origin - }); - }); - } - -} diff --git a/01-Login/src/app/components/footer/footer.component.css b/01-Login/src/app/components/footer/footer.component.css deleted file mode 100644 index e69de29b..00000000 diff --git a/01-Login/src/app/components/footer/footer.component.html b/01-Login/src/app/components/footer/footer.component.html deleted file mode 100644 index c668fbce..00000000 --- a/01-Login/src/app/components/footer/footer.component.html +++ /dev/null @@ -1,7 +0,0 @@ -
- -

- Sample project provided by - Auth0 -

-
diff --git a/01-Login/src/app/components/footer/footer.component.spec.ts b/01-Login/src/app/components/footer/footer.component.spec.ts deleted file mode 100644 index 2ca6c454..00000000 --- a/01-Login/src/app/components/footer/footer.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { FooterComponent } from './footer.component'; - -describe('FooterComponent', () => { - let component: FooterComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ FooterComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(FooterComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/01-Login/src/app/components/footer/footer.component.ts b/01-Login/src/app/components/footer/footer.component.ts deleted file mode 100644 index 67f13785..00000000 --- a/01-Login/src/app/components/footer/footer.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-footer', - templateUrl: './footer.component.html', - styleUrls: ['./footer.component.css'] -}) -export class FooterComponent implements OnInit { - - constructor() { } - - ngOnInit() { - } - -} diff --git a/01-Login/src/app/components/hero/hero.component.css b/01-Login/src/app/components/hero/hero.component.css deleted file mode 100644 index 11f42791..00000000 --- a/01-Login/src/app/components/hero/hero.component.css +++ /dev/null @@ -1,3 +0,0 @@ -.hero .app-logo { - max-width: 10.5rem; -} diff --git a/01-Login/src/app/components/hero/hero.component.html b/01-Login/src/app/components/hero/hero.component.html deleted file mode 100644 index f971a42f..00000000 --- a/01-Login/src/app/components/hero/hero.component.html +++ /dev/null @@ -1,11 +0,0 @@ -
- -

Angular Sample Project

- -

- This is a sample application that demonstrates an authentication flow for an - SPA, using - Angular -

-
- diff --git a/01-Login/src/app/components/hero/hero.component.spec.ts b/01-Login/src/app/components/hero/hero.component.spec.ts deleted file mode 100644 index 11a77079..00000000 --- a/01-Login/src/app/components/hero/hero.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HeroComponent } from './hero.component'; - -describe('HeroComponent', () => { - let component: HeroComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HeroComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HeroComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/01-Login/src/app/components/hero/hero.component.ts b/01-Login/src/app/components/hero/hero.component.ts deleted file mode 100644 index 47860c8c..00000000 --- a/01-Login/src/app/components/hero/hero.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-hero', - templateUrl: './hero.component.html', - styleUrls: ['./hero.component.css'] -}) -export class HeroComponent implements OnInit { - - constructor() { } - - ngOnInit() { - } - -} diff --git a/01-Login/src/app/components/home-content/home-content.component.css b/01-Login/src/app/components/home-content/home-content.component.css deleted file mode 100644 index e69de29b..00000000 diff --git a/01-Login/src/app/components/home-content/home-content.component.html b/01-Login/src/app/components/home-content/home-content.component.html deleted file mode 100644 index a9da5252..00000000 --- a/01-Login/src/app/components/home-content/home-content.component.html +++ /dev/null @@ -1,64 +0,0 @@ -
-

What can I do next?

- -
-
-
- - Configure other identity providers - -
-

- Auth0 supports social providers as Facebook, Twitter, Instagram and - 100+, Enterprise providers as Microsoft Office 365, Google Apps, Azure, - and more. You can also use any OAuth2 Authorization Server. -

-
- -
- -
-
- - Enable Multifactor Authentication - -
-

- Add an extra layer of security by enabling Multi-factor Authentication, - requiring your users to provide more than one piece of identifying - information. Push notifications, authenticator apps, SMS, and DUO - Security are supported. -

-
-
- -
-
-
- - Anomaly Detection - -
-

- Auth0 can detect anomalies and stop malicious attempts to access your - application. Anomaly detection can alert you and your users of - suspicious activity, as well as block further login attempts. -

-
- -
- -
-
- - Learn About Rules - -
-

- Rules are JavaScript functions that execute when a user authenticates to - your application. They run once the authentication process is complete, - and you can use them to customize and extend Auth0's capabilities. -

-
-
-
diff --git a/01-Login/src/app/components/home-content/home-content.component.spec.ts b/01-Login/src/app/components/home-content/home-content.component.spec.ts deleted file mode 100644 index e2990cad..00000000 --- a/01-Login/src/app/components/home-content/home-content.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HomeContentComponent } from './home-content.component'; - -describe('HomeContentComponent', () => { - let component: HomeContentComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HomeContentComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HomeContentComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/01-Login/src/app/components/home-content/home-content.component.ts b/01-Login/src/app/components/home-content/home-content.component.ts deleted file mode 100644 index 58501563..00000000 --- a/01-Login/src/app/components/home-content/home-content.component.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { faLink } from '@fortawesome/free-solid-svg-icons'; - -@Component({ - selector: 'app-home-content', - templateUrl: './home-content.component.html', - styleUrls: ['./home-content.component.css'] -}) -export class HomeContentComponent implements OnInit { - faLink = faLink; - - constructor() { } - - ngOnInit() { - } - -} diff --git a/01-Login/src/app/components/loading/loading.component.css b/01-Login/src/app/components/loading/loading.component.css deleted file mode 100644 index caabdde6..00000000 --- a/01-Login/src/app/components/loading/loading.component.css +++ /dev/null @@ -1,6 +0,0 @@ -.loading { - display: flex; - min-height: 500px; - align-items: center; - justify-content: center; -} diff --git a/01-Login/src/app/components/loading/loading.component.html b/01-Login/src/app/components/loading/loading.component.html deleted file mode 100644 index 14eeaab7..00000000 --- a/01-Login/src/app/components/loading/loading.component.html +++ /dev/null @@ -1,3 +0,0 @@ -
- Loading... -
diff --git a/01-Login/src/app/components/loading/loading.component.spec.ts b/01-Login/src/app/components/loading/loading.component.spec.ts deleted file mode 100644 index e4d1cd4e..00000000 --- a/01-Login/src/app/components/loading/loading.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { LoadingComponent } from './loading.component'; - -describe('LoadingComponent', () => { - let component: LoadingComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ LoadingComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(LoadingComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/01-Login/src/app/components/loading/loading.component.ts b/01-Login/src/app/components/loading/loading.component.ts deleted file mode 100644 index cf71e631..00000000 --- a/01-Login/src/app/components/loading/loading.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-loading', - templateUrl: './loading.component.html', - styleUrls: ['./loading.component.css'] -}) -export class LoadingComponent implements OnInit { - - constructor() { } - - ngOnInit() { - } - -} diff --git a/01-Login/src/app/components/nav-bar/nav-bar.component.css b/01-Login/src/app/components/nav-bar/nav-bar.component.css deleted file mode 100644 index e69de29b..00000000 diff --git a/01-Login/src/app/components/nav-bar/nav-bar.component.html b/01-Login/src/app/components/nav-bar/nav-bar.component.html deleted file mode 100644 index 219b9f43..00000000 --- a/01-Login/src/app/components/nav-bar/nav-bar.component.html +++ /dev/null @@ -1,132 +0,0 @@ - diff --git a/01-Login/src/app/components/nav-bar/nav-bar.component.spec.ts b/01-Login/src/app/components/nav-bar/nav-bar.component.spec.ts deleted file mode 100644 index 0d21a39e..00000000 --- a/01-Login/src/app/components/nav-bar/nav-bar.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { NavBarComponent } from './nav-bar.component'; - -describe('NavBarComponent', () => { - let component: NavBarComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ NavBarComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(NavBarComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/01-Login/src/app/components/nav-bar/nav-bar.component.ts b/01-Login/src/app/components/nav-bar/nav-bar.component.ts deleted file mode 100644 index 1c2b2860..00000000 --- a/01-Login/src/app/components/nav-bar/nav-bar.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { faUser, faPowerOff } from '@fortawesome/free-solid-svg-icons'; -import { AuthService } from 'src/app/auth/auth.service'; - -@Component({ - selector: 'app-nav-bar', - templateUrl: './nav-bar.component.html', - styleUrls: ['./nav-bar.component.css'] -}) -export class NavBarComponent implements OnInit { - isCollapsed = true; - faUser = faUser; - faPowerOff = faPowerOff; - - constructor(public auth: AuthService) { } - - ngOnInit() { - } - -} diff --git a/01-Login/src/app/pages/home/home.component.css b/01-Login/src/app/pages/home/home.component.css deleted file mode 100644 index e69de29b..00000000 diff --git a/01-Login/src/app/pages/home/home.component.html b/01-Login/src/app/pages/home/home.component.html deleted file mode 100644 index 17607eaf..00000000 --- a/01-Login/src/app/pages/home/home.component.html +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
diff --git a/01-Login/src/app/pages/home/home.component.spec.ts b/01-Login/src/app/pages/home/home.component.spec.ts deleted file mode 100644 index 490e81bd..00000000 --- a/01-Login/src/app/pages/home/home.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HomeComponent } from './home.component'; - -describe('HomeComponent', () => { - let component: HomeComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ HomeComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HomeComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/01-Login/src/app/pages/home/home.component.ts b/01-Login/src/app/pages/home/home.component.ts deleted file mode 100644 index 3a521308..00000000 --- a/01-Login/src/app/pages/home/home.component.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { AuthService } from 'src/app/auth/auth.service'; - -@Component({ - selector: 'app-home', - templateUrl: './home.component.html', - styleUrls: ['./home.component.css'] -}) -export class HomeComponent implements OnInit { - - constructor(public auth: AuthService) {} - - ngOnInit() { - } - -} diff --git a/01-Login/src/app/pages/profile/profile.component.css b/01-Login/src/app/pages/profile/profile.component.css deleted file mode 100644 index 00dd5de1..00000000 --- a/01-Login/src/app/pages/profile/profile.component.css +++ /dev/null @@ -1,7 +0,0 @@ -.userImg { - border-radius: 100px; - display: block; - height: 100px; - margin: 0 auto; - width: 100px; -} diff --git a/01-Login/src/app/pages/profile/profile.component.html b/01-Login/src/app/pages/profile/profile.component.html deleted file mode 100644 index 4f55e8d0..00000000 --- a/01-Login/src/app/pages/profile/profile.component.html +++ /dev/null @@ -1,20 +0,0 @@ -
-
-
- -
-
-

{{ profile.name }}

-

{{ profile.email }}

-
-
- -
-
-
-
diff --git a/01-Login/src/app/pages/profile/profile.component.spec.ts b/01-Login/src/app/pages/profile/profile.component.spec.ts deleted file mode 100644 index 170394c3..00000000 --- a/01-Login/src/app/pages/profile/profile.component.spec.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { HighlightModule } from 'ngx-highlightjs'; -import { hljsLanguages } from 'src/app/app.module'; - -import { ProfileComponent } from './profile.component'; - -describe('ProfileComponent', () => { - let component: ProfileComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ProfileComponent], - imports: [ - HighlightModule.forRoot({ - languages: hljsLanguages - }) - ] - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ProfileComponent); - component = fixture.componentInstance; - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/01-Login/src/app/pages/profile/profile.component.ts b/01-Login/src/app/pages/profile/profile.component.ts deleted file mode 100644 index a0d48f31..00000000 --- a/01-Login/src/app/pages/profile/profile.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { AuthService } from 'src/app/auth/auth.service'; - -@Component({ - selector: 'app-profile', - templateUrl: './profile.component.html', - styleUrls: ['./profile.component.css'] -}) -export class ProfileComponent implements OnInit { - profileJson: string = null; - - constructor(public auth: AuthService) { } - - ngOnInit() { - this.auth.userProfile$.subscribe( - profile => this.profileJson = JSON.stringify(profile, null, 2) - ); - } - -} diff --git a/01-Login/src/assets/.gitkeep b/01-Login/src/assets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/01-Login/src/assets/loading.svg b/01-Login/src/assets/loading.svg deleted file mode 100644 index 6bffb805..00000000 --- a/01-Login/src/assets/loading.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/01-Login/src/assets/logo.png b/01-Login/src/assets/logo.png deleted file mode 100644 index c5102939182281314e8f79f1d7f7cd2145cd81f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2385 zcma)7Yg7{07RIs3%FxPQR!&yqtJ0hZ5q!V36s>HM!9+u$2FwSRhKg2B<&>E{G!#O# zwA6e=j)|gO?V+h4plBtal?v$qDI=3vgaK)w- z0000O;O~7%hw3kTnZE99-CJR-15QX_sE-c&4ED4e*$MUSznU)mkNyA5Kl8u(I!A2c z^2*FfcJ9u|rGiEI)VyNq({Ykkt9^SSZGL!kc4TzSGn%*mxawJ#qP=Tm$NsL}{!{ci z>HRw0XkGb-y+_$jMHy)#GgHe@3YgxRlDsIzilq0|Sw&Y(Mu@wkSyKF}g2KfF85E0efvcWi^e-(3c~#)b>`TQ2)>6zHAmrMd-Stf-V=Oj zU|bgI<@i-s9DGM~8e77!JU&BVo2CnzGbOe#tP;Vul%}y2h;}~u-%*q<+MSR8BC3L7 z8XSt4URzS*4V`AssYpj|Vzz9q78l55t9WVHt=T2?Gut}JIRsIh z1%d!9ZTJz0B;Ds&fZx58g;kJ+7Y{6mdr%8A^3Vy)yS)| zsbKXMQWg=wJBnuq3Ta7hXa)wz;|x+dHDw#{0*dc&FU3?ws*lXV1bG|vkTrJc?lHjN zxV+q;QM+`wt7km|b_ZnGa6omy8ka&`>FSU(Au&;`u4v~q>eRrPTlEkZxaSP+X!}zh z6N!0pnRbDHC4JX!?2S_{tb*eRhOZP-d-2#)A`^8SoC@*u8x4$*m2wC>aof*q=r%;( zmNzNY*S9Ky_l(sSQ#xn(hSs>Z_KQE=1bH>kWPX7H=X26Js;1gbJRzO;(y*u^y40Wj zaWqDG)+ibnjM@fe#20WE*K`(wgRBxQx1!**kM4qD<>d}Cy@?|8^A>n3FYDA^i2&%{ zJq|%w`VNpzg;y{@>$8Vq`_*}j%^zd6LAyr^4t$aoy!<>Yi?--az z<(m^N4e1+Zs#fz#YbgQY%Y@}o2$PfR^Fc-SYQbHwr}|Mb#im`NE9?#4bFoai`C7OS z*kl*k}6{1T5!RH3W5Y$66%T7aX^xOg+9-zpuWmVZpO|{MrF-usr&Ys6i zc*u*CfGr-Xhud&(J=JJ0Hh!a8a2*_+r5se)NN&(Mz^w(ca4>6fz?QI5xZwh`r>3w) zJ#_cjpv1__V{MBY2(%$D)L#CVn0F(Ed=1PK@&C1~<@p)aI19Qs-VZhFOeJ2=fw%BE zeD@;Mv2wA42gDf$Z|yGe?&rm-E3O@ib%OKfFGcD%-)uc~D|u=lX9})i9u#E{^z=J@ zW;PP7!XToi!*f#X&k&K07^%;&u@{jD4b}2*X(> zHAR)l?@tr{f;XS4{zoHs$fb(Uae=f|%+IzkH>wDm1X93VnR*{`#WYgXrDQ*3x*D+Y)Ihu{Q7!rfGMwO?^v ljI?SQ9hwt}{Ftxy#)W*NndmOdGy3wQ2l&9ft34yn{|yqu>aG9) diff --git a/01-Login/src/environments/environment.prod.ts b/01-Login/src/environments/environment.prod.ts deleted file mode 100644 index 3612073b..00000000 --- a/01-Login/src/environments/environment.prod.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const environment = { - production: true -}; diff --git a/01-Login/src/environments/environment.ts b/01-Login/src/environments/environment.ts deleted file mode 100644 index 7b4f817a..00000000 --- a/01-Login/src/environments/environment.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file can be replaced during build by using the `fileReplacements` array. -// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. -// The list of file replacements can be found in `angular.json`. - -export const environment = { - production: false -}; - -/* - * For easier debugging in development mode, you can import the following file - * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. - * - * This import should be commented out in production mode because it will have a negative impact - * on performance if an error is thrown. - */ -// import 'zone.js/dist/zone-error'; // Included with Angular CLI. diff --git a/01-Login/src/favicon.ico b/01-Login/src/favicon.ico deleted file mode 100644 index 8081c7ceaf2be08bf59010158c586170d9d2d517..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5430 zcmc(je{54#6vvCoAI3i*G5%$U7!sA3wtMZ$fH6V9C`=eXGJb@R1%(I_{vnZtpD{6n z5Pl{DmxzBDbrB>}`90e12m8T*36WoeDLA&SD_hw{H^wM!cl_RWcVA!I+x87ee975; z@4kD^=bYPn&pmG@(+JZ`rqQEKxW<}RzhW}I!|ulN=fmjVi@x{p$cC`)5$a!)X&U+blKNvN5tg=uLvuLnuqRM;Yc*swiexsoh#XPNu{9F#c`G zQLe{yWA(Y6(;>y|-efAy11k<09(@Oo1B2@0`PtZSkqK&${ zgEY}`W@t{%?9u5rF?}Y7OL{338l*JY#P!%MVQY@oqnItpZ}?s z!r?*kwuR{A@jg2Chlf0^{q*>8n5Ir~YWf*wmsh7B5&EpHfd5@xVaj&gqsdui^spyL zB|kUoblGoO7G(MuKTfa9?pGH0@QP^b#!lM1yHWLh*2iq#`C1TdrnO-d#?Oh@XV2HK zKA{`eo{--^K&MW66Lgsktfvn#cCAc*(}qsfhrvOjMGLE?`dHVipu1J3Kgr%g?cNa8 z)pkmC8DGH~fG+dlrp(5^-QBeEvkOvv#q7MBVLtm2oD^$lJZx--_=K&Ttd=-krx(Bb zcEoKJda@S!%%@`P-##$>*u%T*mh+QjV@)Qa=Mk1?#zLk+M4tIt%}wagT{5J%!tXAE;r{@=bb%nNVxvI+C+$t?!VJ@0d@HIyMJTI{vEw0Ul ze(ha!e&qANbTL1ZneNl45t=#Ot??C0MHjjgY8%*mGisN|S6%g3;Hlx#fMNcL<87MW zZ>6moo1YD?P!fJ#Jb(4)_cc50X5n0KoDYfdPoL^iV`k&o{LPyaoqMqk92wVM#_O0l z09$(A-D+gVIlq4TA&{1T@BsUH`Bm=r#l$Z51J-U&F32+hfUP-iLo=jg7Xmy+WLq6_tWv&`wDlz#`&)Jp~iQf zZP)tu>}pIIJKuw+$&t}GQuqMd%Z>0?t%&BM&Wo^4P^Y z)c6h^f2R>X8*}q|bblAF?@;%?2>$y+cMQbN{X$)^R>vtNq_5AB|0N5U*d^T?X9{xQnJYeU{ zoZL#obI;~Pp95f1`%X3D$Mh*4^?O?IT~7HqlWguezmg?Ybq|7>qQ(@pPHbE9V?f|( z+0xo!#m@Np9PljsyxBY-UA*{U*la#8Wz2sO|48_-5t8%_!n?S$zlGe+NA%?vmxjS- zHE5O3ZarU=X}$7>;Okp(UWXJxI%G_J-@IH;%5#Rt$(WUX?6*Ux!IRd$dLP6+SmPn= z8zjm4jGjN772R{FGkXwcNv8GBcZI#@Y2m{RNF_w8(Z%^A*!bS*!}s6sh*NnURytky humW;*g7R+&|Ledvc- - - - - Angular Sample Project - - - - - - - - - - - diff --git a/01-Login/src/main.ts b/01-Login/src/main.ts deleted file mode 100644 index c7b673cf..00000000 --- a/01-Login/src/main.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { enableProdMode } from '@angular/core'; -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; - -import { AppModule } from './app/app.module'; -import { environment } from './environments/environment'; - -if (environment.production) { - enableProdMode(); -} - -platformBrowserDynamic().bootstrapModule(AppModule) - .catch(err => console.error(err)); diff --git a/01-Login/src/polyfills.ts b/01-Login/src/polyfills.ts deleted file mode 100644 index aa665d6b..00000000 --- a/01-Login/src/polyfills.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * This file includes polyfills needed by Angular and is loaded before the app. - * You can add your own extra polyfills to this file. - * - * This file is divided into 2 sections: - * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. - * 2. Application imports. Files imported after ZoneJS that should be loaded before your main - * file. - * - * The current setup is for so-called "evergreen" browsers; the last versions of browsers that - * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), - * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. - * - * Learn more in https://angular.io/guide/browser-support - */ - -/*************************************************************************************************** - * BROWSER POLYFILLS - */ - -/** IE10 and IE11 requires the following for NgClass support on SVG elements */ -// import 'classlist.js'; // Run `npm install --save classlist.js`. - -/** - * Web Animations `@angular/platform-browser/animations` - * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. - * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). - */ -// import 'web-animations-js'; // Run `npm install --save web-animations-js`. - -/** - * By default, zone.js will patch all possible macroTask and DomEvents - * user can disable parts of macroTask/DomEvents patch by setting following flags - * because those flags need to be set before `zone.js` being loaded, and webpack - * will put import in the top of bundle, so user need to create a separate file - * in this directory (for example: zone-flags.ts), and put the following flags - * into that file, and then add the following code before importing zone.js. - * import './zone-flags.ts'; - * - * The flags allowed in zone-flags.ts are listed here. - * - * The following flags will work for all browsers. - * - * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame - * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick - * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames - * - * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js - * with the following flag, it will bypass `zone.js` patch for IE/Edge - * - * (window as any).__Zone_enable_cross_context_check = true; - * - */ - -/*************************************************************************************************** - * Zone JS is required by default for Angular itself. - */ -import 'zone.js/dist/zone'; // Included with Angular CLI. - - -/*************************************************************************************************** - * APPLICATION IMPORTS - */ diff --git a/01-Login/src/styles.css b/01-Login/src/styles.css deleted file mode 100644 index 90d4ee00..00000000 --- a/01-Login/src/styles.css +++ /dev/null @@ -1 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ diff --git a/01-Login/src/test.ts b/01-Login/src/test.ts deleted file mode 100644 index 16317897..00000000 --- a/01-Login/src/test.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file is required by karma.conf.js and loads recursively all the .spec and framework files - -import 'zone.js/dist/zone-testing'; -import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; - -declare const require: any; - -// First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); -// Then we find all the tests. -const context = require.context('./', true, /\.spec\.ts$/); -// And load the modules. -context.keys().map(context); diff --git a/01-Login/tsconfig.app.json b/01-Login/tsconfig.app.json deleted file mode 100644 index 31f8397a..00000000 --- a/01-Login/tsconfig.app.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/app", - "types": [] - }, - "include": [ - "src/**/*.ts" - ], - "exclude": [ - "src/test.ts", - "src/**/*.spec.ts" - ] -} diff --git a/01-Login/tsconfig.json b/01-Login/tsconfig.json deleted file mode 100644 index 5cadd072..00000000 --- a/01-Login/tsconfig.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist/out-tsc", - "sourceMap": true, - "declaration": false, - "downlevelIteration": true, - "experimentalDecorators": true, - "module": "esnext", - "moduleResolution": "node", - "importHelpers": true, - "target": "es2015", - "typeRoots": [ - "node_modules/@types" - ], - "lib": [ - "es2018", - "dom" - ], - "resolveJsonModule": true, - "esModuleInterop": true - }, - "angularCompilerOptions": { - "fullTemplateTypeCheck": true, - "strictInjectionParameters": true - } -} diff --git a/01-Login/tsconfig.spec.json b/01-Login/tsconfig.spec.json deleted file mode 100644 index 6400fde7..00000000 --- a/01-Login/tsconfig.spec.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/spec", - "types": [ - "jasmine", - "node" - ] - }, - "files": [ - "src/test.ts", - "src/polyfills.ts" - ], - "include": [ - "src/**/*.spec.ts", - "src/**/*.d.ts" - ] -} diff --git a/01-Login/tslint.json b/01-Login/tslint.json deleted file mode 100644 index f0adae98..00000000 --- a/01-Login/tslint.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "extends": "tslint:recommended", - "rules": { - "array-type": false, - "arrow-parens": false, - "deprecation": { - "severity": "warning" - }, - "component-class-suffix": true, - "contextual-lifecycle": true, - "directive-class-suffix": true, - "directive-selector": [ - true, - "attribute", - "app", - "camelCase" - ], - "component-selector": [ - true, - "element", - "app", - "kebab-case" - ], - "import-blacklist": [ - true, - "rxjs/Rx" - ], - "interface-name": false, - "max-classes-per-file": false, - "max-line-length": [ - true, - 140 - ], - "member-access": false, - "member-ordering": [ - true, - { - "order": [ - "static-field", - "instance-field", - "static-method", - "instance-method" - ] - } - ], - "no-consecutive-blank-lines": false, - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], - "no-empty": false, - "no-inferrable-types": [ - true, - "ignore-params" - ], - "no-non-null-assertion": true, - "no-redundant-jsdoc": true, - "no-switch-case-fall-through": true, - "no-use-before-declare": true, - "no-var-requires": false, - "object-literal-key-quotes": [ - true, - "as-needed" - ], - "object-literal-sort-keys": false, - "ordered-imports": false, - "quotemark": [ - true, - "single" - ], - "trailing-comma": false, - "no-conflicting-lifecycle": true, - "no-host-metadata-property": true, - "no-input-rename": true, - "no-inputs-metadata-property": true, - "no-output-native": true, - "no-output-on-prefix": true, - "no-output-rename": true, - "no-outputs-metadata-property": true, - "template-banana-in-box": true, - "template-no-negated-async": true, - "use-lifecycle-interface": true, - "use-pipe-transform-interface": true - }, - "rulesDirectory": [ - "codelyzer" - ] -} \ No newline at end of file From 3d3f3571af63320dbd6d0db903e9c7f81454b26b Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Wed, 12 Aug 2020 14:31:25 +0100 Subject: [PATCH 004/262] Rename 02-Calling-an-API to Sample-01 --- .circleci/config.yml | 109 +++++++++--------- 02-Calling-an-API/auth_config.json.example | 5 - .../.dockerignore | 0 .../.editorconfig | 0 {02-Calling-an-API => Sample-01}/.gitignore | 0 {02-Calling-an-API => Sample-01}/Dockerfile | 0 {02-Calling-an-API => Sample-01}/README.md | 0 {02-Calling-an-API => Sample-01}/angular.json | 0 {02-Calling-an-API => Sample-01}/browserslist | 0 .../e2e/protractor.conf.js | 0 .../e2e/src/app.e2e-spec.ts | 0 .../e2e/src/app.po.ts | 0 .../e2e/tsconfig.json | 0 {02-Calling-an-API => Sample-01}/exec.ps1 | 0 {02-Calling-an-API => Sample-01}/exec.sh | 0 .../karma.conf.js | 0 {02-Calling-an-API => Sample-01}/package.json | 0 .../proxy.conf.json | 0 {02-Calling-an-API => Sample-01}/server.js | 0 .../src/app/api.service.spec.ts | 0 .../src/app/api.service.ts | 0 .../src/app/app-routing.module.ts | 0 .../src/app/app.component.css | 0 .../src/app/app.component.html | 0 .../src/app/app.component.spec.ts | 0 .../src/app/app.component.ts | 0 .../src/app/app.module.ts | 0 .../src/app/auth/auth.guard.spec.ts | 0 .../src/app/auth/auth.guard.ts | 0 .../src/app/auth/auth.service.spec.ts | 0 .../src/app/auth/auth.service.ts | 0 .../src/app/auth/interceptor.service.spec.ts | 0 .../src/app/auth/interceptor.service.ts | 0 .../components/footer/footer.component.css | 0 .../components/footer/footer.component.html | 0 .../footer/footer.component.spec.ts | 0 .../app/components/footer/footer.component.ts | 0 .../app/components/hero/hero.component.css | 0 .../app/components/hero/hero.component.html | 0 .../components/hero/hero.component.spec.ts | 0 .../src/app/components/hero/hero.component.ts | 0 .../home-content/home-content.component.css | 0 .../home-content/home-content.component.html | 0 .../home-content.component.spec.ts | 0 .../home-content/home-content.component.ts | 0 .../components/loading/loading.component.css | 0 .../components/loading/loading.component.html | 0 .../loading/loading.component.spec.ts | 0 .../components/loading/loading.component.ts | 0 .../components/nav-bar/nav-bar.component.css | 0 .../components/nav-bar/nav-bar.component.html | 0 .../nav-bar/nav-bar.component.spec.ts | 0 .../components/nav-bar/nav-bar.component.ts | 0 .../external-api/external-api.component.css | 0 .../external-api/external-api.component.html | 0 .../external-api.component.spec.ts | 0 .../external-api/external-api.component.ts | 0 .../src/app/pages/home/home.component.css | 0 .../src/app/pages/home/home.component.html | 0 .../src/app/pages/home/home.component.spec.ts | 0 .../src/app/pages/home/home.component.ts | 0 .../app/pages/profile/profile.component.css | 0 .../app/pages/profile/profile.component.html | 0 .../pages/profile/profile.component.spec.ts | 0 .../app/pages/profile/profile.component.ts | 0 .../src/assets/.gitkeep | 0 .../src/assets/loading.svg | 0 .../src/assets/logo.png | Bin .../src/environments/environment.prod.ts | 0 .../src/environments/environment.ts | 0 .../src/favicon.ico | Bin .../src/index.html | 0 {02-Calling-an-API => Sample-01}/src/main.ts | 0 .../src/polyfills.ts | 0 .../src/styles.css | 0 {02-Calling-an-API => Sample-01}/src/test.ts | 0 .../tsconfig.app.json | 0 .../tsconfig.json | 0 .../tsconfig.spec.json | 0 {02-Calling-an-API => Sample-01}/tslint.json | 0 80 files changed, 52 insertions(+), 62 deletions(-) delete mode 100644 02-Calling-an-API/auth_config.json.example rename {02-Calling-an-API => Sample-01}/.dockerignore (100%) rename {02-Calling-an-API => Sample-01}/.editorconfig (100%) rename {02-Calling-an-API => Sample-01}/.gitignore (100%) rename {02-Calling-an-API => Sample-01}/Dockerfile (100%) rename {02-Calling-an-API => Sample-01}/README.md (100%) rename {02-Calling-an-API => Sample-01}/angular.json (100%) rename {02-Calling-an-API => Sample-01}/browserslist (100%) rename {02-Calling-an-API => Sample-01}/e2e/protractor.conf.js (100%) rename {02-Calling-an-API => Sample-01}/e2e/src/app.e2e-spec.ts (100%) rename {02-Calling-an-API => Sample-01}/e2e/src/app.po.ts (100%) rename {02-Calling-an-API => Sample-01}/e2e/tsconfig.json (100%) rename {02-Calling-an-API => Sample-01}/exec.ps1 (100%) rename {02-Calling-an-API => Sample-01}/exec.sh (100%) rename {02-Calling-an-API => Sample-01}/karma.conf.js (100%) rename {02-Calling-an-API => Sample-01}/package.json (100%) rename {02-Calling-an-API => Sample-01}/proxy.conf.json (100%) rename {02-Calling-an-API => Sample-01}/server.js (100%) rename {02-Calling-an-API => Sample-01}/src/app/api.service.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/api.service.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/app-routing.module.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/app.component.css (100%) rename {02-Calling-an-API => Sample-01}/src/app/app.component.html (100%) rename {02-Calling-an-API => Sample-01}/src/app/app.component.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/app.component.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/app.module.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/auth/auth.guard.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/auth/auth.guard.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/auth/auth.service.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/auth/auth.service.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/auth/interceptor.service.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/auth/interceptor.service.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/footer/footer.component.css (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/footer/footer.component.html (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/footer/footer.component.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/footer/footer.component.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/hero/hero.component.css (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/hero/hero.component.html (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/hero/hero.component.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/hero/hero.component.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/home-content/home-content.component.css (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/home-content/home-content.component.html (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/home-content/home-content.component.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/home-content/home-content.component.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/loading/loading.component.css (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/loading/loading.component.html (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/loading/loading.component.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/loading/loading.component.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/nav-bar/nav-bar.component.css (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/nav-bar/nav-bar.component.html (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/nav-bar/nav-bar.component.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/components/nav-bar/nav-bar.component.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/external-api/external-api.component.css (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/external-api/external-api.component.html (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/external-api/external-api.component.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/external-api/external-api.component.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/home/home.component.css (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/home/home.component.html (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/home/home.component.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/home/home.component.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/profile/profile.component.css (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/profile/profile.component.html (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/profile/profile.component.spec.ts (100%) rename {02-Calling-an-API => Sample-01}/src/app/pages/profile/profile.component.ts (100%) rename {02-Calling-an-API => Sample-01}/src/assets/.gitkeep (100%) rename {02-Calling-an-API => Sample-01}/src/assets/loading.svg (100%) rename {02-Calling-an-API => Sample-01}/src/assets/logo.png (100%) rename {02-Calling-an-API => Sample-01}/src/environments/environment.prod.ts (100%) rename {02-Calling-an-API => Sample-01}/src/environments/environment.ts (100%) rename {02-Calling-an-API => Sample-01}/src/favicon.ico (100%) rename {02-Calling-an-API => Sample-01}/src/index.html (100%) rename {02-Calling-an-API => Sample-01}/src/main.ts (100%) rename {02-Calling-an-API => Sample-01}/src/polyfills.ts (100%) rename {02-Calling-an-API => Sample-01}/src/styles.css (100%) rename {02-Calling-an-API => Sample-01}/src/test.ts (100%) rename {02-Calling-an-API => Sample-01}/tsconfig.app.json (100%) rename {02-Calling-an-API => Sample-01}/tsconfig.json (100%) rename {02-Calling-an-API => Sample-01}/tsconfig.spec.json (100%) rename {02-Calling-an-API => Sample-01}/tslint.json (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index eeb3481d..ba5e293d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,50 +1,12 @@ # Environment variables to be defined in the build configuration: # AUTH0_TEST_CLIENT_ID = Client id to use in test # AUTH0_TEST_DOMAIN = Domain to use in test -# AUTH0_TEST_API_IDENTIFIER = API Audience to use in test - -# Common logic -defaults: &defaults - steps: - - attach_workspace: - at: ~/ - - run: - name: Replace Auth0 test credentials - command: | - mv $AUTH0_CFG.example $AUTH0_CFG - sed -i 's/{CLIENT_ID}/'$AUTH0_TEST_CLIENT_ID'/g' $AUTH0_CFG - sed -i 's/{DOMAIN}/'$AUTH0_TEST_DOMAIN'/g' $AUTH0_CFG - sed -i 's/{API_IDENTIFIER}/'$AUTH0_TEST_API_IDENTIFIER'/g' $AUTH0_CFG - - run: - name: Build pull request - command: | - docker build -t $CIRCLE_JOB ./$SAMPLE_PATH - docker run -d -p 3000:3000 --name $CIRCLE_SHA1 -e AUTH0_DOMAIN=$AUTH0_TEST_DOMAIN -e AUTH0_AUDIENCE=$AUTH0_TEST_API_IDENTIFIER $CIRCLE_JOB - - run: - name: Wait for app to be available - command: | - sleep 10 - docker run --network host --rm appropriate/curl --retry 8 --retry-connrefused -v localhost:3000 - - run: - name: Run tests - command: | - docker create --network host --name tester codeception/codeceptjs codeceptjs run-multiple --all --steps - docker cp $(pwd)/lock_login_spa_test.js tester:/tests/lock_login_test.js - docker cp $(pwd)/codecept.conf.js tester:/tests/codecept.conf.js - docker start -i tester - working_directory: scripts - - run: - name: Copy app container logs - command: | - mkdir -p /tmp/out - docker logs $CIRCLE_SHA1 > /tmp/out/app_logs.log - docker cp tester:/tests/out /tmp/ - when: on_fail - - store_artifacts: - path: /tmp/out +# AUTH0_TEST_AUDIENCE = API Audience to use in test # Jobs and Workflows -version: 2 +version: 2.1 +orbs: + node: circleci/node@3.0.0 jobs: checkout: machine: true @@ -56,19 +18,56 @@ jobs: paths: - project - scripts - 01-login: + sample-01: machine: true environment: - - AUTH0_CFG: 01-Login/auth_config.json - - SAMPLE_PATH: 01-Login - <<: *defaults + - AUTH0_CFG: Sample-01/src/environments/environment.ts + - SAMPLE_PATH: Sample-01 + steps: + - node/install: + node-version: latest + - attach_workspace: + at: ~/ + - run: + name: Replace Auth0 test credentials + command: | + echo "{ \"domain\": \"$AUTH0_TEST_DOMAIN\", \"clientId\": \"$AUTH0_TEST_CLIENT_ID\", \"audience\": \"$AUTH0_TEST_API_IDENTIFIER\" }" > $AUTH0_CFG - 02-calling-an-api: - machine: true - environment: - - AUTH0_CFG: 02-Calling-an-API/auth_config.json - - SAMPLE_PATH: 02-Calling-an-API - <<: *defaults + - run: + name: Build pull request + command: | + docker build -t $CIRCLE_JOB ./$SAMPLE_PATH + docker run -d -p 3000:4200 --name $CIRCLE_SHA1 $CIRCLE_JOB + - run: + name: Wait for app to be available + command: | + sleep 10 + docker run --network host --rm appropriate/curl --retry 8 --retry-connrefused -v localhost:3000 + - node/install-packages: + pkg-manager: yarn + app-dir: Sample-01 + - run: + name: Run unit tests + command: | + cd Sample-01 + yarn test + - run: + name: Run integration tests + command: | + docker create --network host --name tester codeception/codeceptjs codeceptjs run-multiple --all --steps --verbose + docker cp $(pwd)/lock_login_spa_test.js tester:/tests/lock_login_test.js + docker cp $(pwd)/codecept.conf.js tester:/tests/codecept.conf.js + docker start -i tester + working_directory: scripts + - run: + name: Copy app container logs + command: | + mkdir -p /tmp/out + docker logs $CIRCLE_SHA1 > /tmp/out/app_logs.log + docker cp tester:/tests/out /tmp/ + when: on_fail + - store_artifacts: + path: /tmp/out workflows: version: 2 @@ -76,11 +75,7 @@ workflows: jobs: - checkout: context: Quickstart SPA Test - - 01-login: - context: Quickstart SPA Test - requires: - - checkout - - 02-calling-an-api: + - sample-01: context: Quickstart SPA Test requires: - checkout diff --git a/02-Calling-an-API/auth_config.json.example b/02-Calling-an-API/auth_config.json.example deleted file mode 100644 index dc75eb72..00000000 --- a/02-Calling-an-API/auth_config.json.example +++ /dev/null @@ -1,5 +0,0 @@ -{ - "clientId": "{CLIENT_ID}", - "domain": "{DOMAIN}", - "audience": "{API_IDENTIFIER}" -} diff --git a/02-Calling-an-API/.dockerignore b/Sample-01/.dockerignore similarity index 100% rename from 02-Calling-an-API/.dockerignore rename to Sample-01/.dockerignore diff --git a/02-Calling-an-API/.editorconfig b/Sample-01/.editorconfig similarity index 100% rename from 02-Calling-an-API/.editorconfig rename to Sample-01/.editorconfig diff --git a/02-Calling-an-API/.gitignore b/Sample-01/.gitignore similarity index 100% rename from 02-Calling-an-API/.gitignore rename to Sample-01/.gitignore diff --git a/02-Calling-an-API/Dockerfile b/Sample-01/Dockerfile similarity index 100% rename from 02-Calling-an-API/Dockerfile rename to Sample-01/Dockerfile diff --git a/02-Calling-an-API/README.md b/Sample-01/README.md similarity index 100% rename from 02-Calling-an-API/README.md rename to Sample-01/README.md diff --git a/02-Calling-an-API/angular.json b/Sample-01/angular.json similarity index 100% rename from 02-Calling-an-API/angular.json rename to Sample-01/angular.json diff --git a/02-Calling-an-API/browserslist b/Sample-01/browserslist similarity index 100% rename from 02-Calling-an-API/browserslist rename to Sample-01/browserslist diff --git a/02-Calling-an-API/e2e/protractor.conf.js b/Sample-01/e2e/protractor.conf.js similarity index 100% rename from 02-Calling-an-API/e2e/protractor.conf.js rename to Sample-01/e2e/protractor.conf.js diff --git a/02-Calling-an-API/e2e/src/app.e2e-spec.ts b/Sample-01/e2e/src/app.e2e-spec.ts similarity index 100% rename from 02-Calling-an-API/e2e/src/app.e2e-spec.ts rename to Sample-01/e2e/src/app.e2e-spec.ts diff --git a/02-Calling-an-API/e2e/src/app.po.ts b/Sample-01/e2e/src/app.po.ts similarity index 100% rename from 02-Calling-an-API/e2e/src/app.po.ts rename to Sample-01/e2e/src/app.po.ts diff --git a/02-Calling-an-API/e2e/tsconfig.json b/Sample-01/e2e/tsconfig.json similarity index 100% rename from 02-Calling-an-API/e2e/tsconfig.json rename to Sample-01/e2e/tsconfig.json diff --git a/02-Calling-an-API/exec.ps1 b/Sample-01/exec.ps1 similarity index 100% rename from 02-Calling-an-API/exec.ps1 rename to Sample-01/exec.ps1 diff --git a/02-Calling-an-API/exec.sh b/Sample-01/exec.sh similarity index 100% rename from 02-Calling-an-API/exec.sh rename to Sample-01/exec.sh diff --git a/02-Calling-an-API/karma.conf.js b/Sample-01/karma.conf.js similarity index 100% rename from 02-Calling-an-API/karma.conf.js rename to Sample-01/karma.conf.js diff --git a/02-Calling-an-API/package.json b/Sample-01/package.json similarity index 100% rename from 02-Calling-an-API/package.json rename to Sample-01/package.json diff --git a/02-Calling-an-API/proxy.conf.json b/Sample-01/proxy.conf.json similarity index 100% rename from 02-Calling-an-API/proxy.conf.json rename to Sample-01/proxy.conf.json diff --git a/02-Calling-an-API/server.js b/Sample-01/server.js similarity index 100% rename from 02-Calling-an-API/server.js rename to Sample-01/server.js diff --git a/02-Calling-an-API/src/app/api.service.spec.ts b/Sample-01/src/app/api.service.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/api.service.spec.ts rename to Sample-01/src/app/api.service.spec.ts diff --git a/02-Calling-an-API/src/app/api.service.ts b/Sample-01/src/app/api.service.ts similarity index 100% rename from 02-Calling-an-API/src/app/api.service.ts rename to Sample-01/src/app/api.service.ts diff --git a/02-Calling-an-API/src/app/app-routing.module.ts b/Sample-01/src/app/app-routing.module.ts similarity index 100% rename from 02-Calling-an-API/src/app/app-routing.module.ts rename to Sample-01/src/app/app-routing.module.ts diff --git a/02-Calling-an-API/src/app/app.component.css b/Sample-01/src/app/app.component.css similarity index 100% rename from 02-Calling-an-API/src/app/app.component.css rename to Sample-01/src/app/app.component.css diff --git a/02-Calling-an-API/src/app/app.component.html b/Sample-01/src/app/app.component.html similarity index 100% rename from 02-Calling-an-API/src/app/app.component.html rename to Sample-01/src/app/app.component.html diff --git a/02-Calling-an-API/src/app/app.component.spec.ts b/Sample-01/src/app/app.component.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/app.component.spec.ts rename to Sample-01/src/app/app.component.spec.ts diff --git a/02-Calling-an-API/src/app/app.component.ts b/Sample-01/src/app/app.component.ts similarity index 100% rename from 02-Calling-an-API/src/app/app.component.ts rename to Sample-01/src/app/app.component.ts diff --git a/02-Calling-an-API/src/app/app.module.ts b/Sample-01/src/app/app.module.ts similarity index 100% rename from 02-Calling-an-API/src/app/app.module.ts rename to Sample-01/src/app/app.module.ts diff --git a/02-Calling-an-API/src/app/auth/auth.guard.spec.ts b/Sample-01/src/app/auth/auth.guard.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/auth/auth.guard.spec.ts rename to Sample-01/src/app/auth/auth.guard.spec.ts diff --git a/02-Calling-an-API/src/app/auth/auth.guard.ts b/Sample-01/src/app/auth/auth.guard.ts similarity index 100% rename from 02-Calling-an-API/src/app/auth/auth.guard.ts rename to Sample-01/src/app/auth/auth.guard.ts diff --git a/02-Calling-an-API/src/app/auth/auth.service.spec.ts b/Sample-01/src/app/auth/auth.service.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/auth/auth.service.spec.ts rename to Sample-01/src/app/auth/auth.service.spec.ts diff --git a/02-Calling-an-API/src/app/auth/auth.service.ts b/Sample-01/src/app/auth/auth.service.ts similarity index 100% rename from 02-Calling-an-API/src/app/auth/auth.service.ts rename to Sample-01/src/app/auth/auth.service.ts diff --git a/02-Calling-an-API/src/app/auth/interceptor.service.spec.ts b/Sample-01/src/app/auth/interceptor.service.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/auth/interceptor.service.spec.ts rename to Sample-01/src/app/auth/interceptor.service.spec.ts diff --git a/02-Calling-an-API/src/app/auth/interceptor.service.ts b/Sample-01/src/app/auth/interceptor.service.ts similarity index 100% rename from 02-Calling-an-API/src/app/auth/interceptor.service.ts rename to Sample-01/src/app/auth/interceptor.service.ts diff --git a/02-Calling-an-API/src/app/components/footer/footer.component.css b/Sample-01/src/app/components/footer/footer.component.css similarity index 100% rename from 02-Calling-an-API/src/app/components/footer/footer.component.css rename to Sample-01/src/app/components/footer/footer.component.css diff --git a/02-Calling-an-API/src/app/components/footer/footer.component.html b/Sample-01/src/app/components/footer/footer.component.html similarity index 100% rename from 02-Calling-an-API/src/app/components/footer/footer.component.html rename to Sample-01/src/app/components/footer/footer.component.html diff --git a/02-Calling-an-API/src/app/components/footer/footer.component.spec.ts b/Sample-01/src/app/components/footer/footer.component.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/components/footer/footer.component.spec.ts rename to Sample-01/src/app/components/footer/footer.component.spec.ts diff --git a/02-Calling-an-API/src/app/components/footer/footer.component.ts b/Sample-01/src/app/components/footer/footer.component.ts similarity index 100% rename from 02-Calling-an-API/src/app/components/footer/footer.component.ts rename to Sample-01/src/app/components/footer/footer.component.ts diff --git a/02-Calling-an-API/src/app/components/hero/hero.component.css b/Sample-01/src/app/components/hero/hero.component.css similarity index 100% rename from 02-Calling-an-API/src/app/components/hero/hero.component.css rename to Sample-01/src/app/components/hero/hero.component.css diff --git a/02-Calling-an-API/src/app/components/hero/hero.component.html b/Sample-01/src/app/components/hero/hero.component.html similarity index 100% rename from 02-Calling-an-API/src/app/components/hero/hero.component.html rename to Sample-01/src/app/components/hero/hero.component.html diff --git a/02-Calling-an-API/src/app/components/hero/hero.component.spec.ts b/Sample-01/src/app/components/hero/hero.component.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/components/hero/hero.component.spec.ts rename to Sample-01/src/app/components/hero/hero.component.spec.ts diff --git a/02-Calling-an-API/src/app/components/hero/hero.component.ts b/Sample-01/src/app/components/hero/hero.component.ts similarity index 100% rename from 02-Calling-an-API/src/app/components/hero/hero.component.ts rename to Sample-01/src/app/components/hero/hero.component.ts diff --git a/02-Calling-an-API/src/app/components/home-content/home-content.component.css b/Sample-01/src/app/components/home-content/home-content.component.css similarity index 100% rename from 02-Calling-an-API/src/app/components/home-content/home-content.component.css rename to Sample-01/src/app/components/home-content/home-content.component.css diff --git a/02-Calling-an-API/src/app/components/home-content/home-content.component.html b/Sample-01/src/app/components/home-content/home-content.component.html similarity index 100% rename from 02-Calling-an-API/src/app/components/home-content/home-content.component.html rename to Sample-01/src/app/components/home-content/home-content.component.html diff --git a/02-Calling-an-API/src/app/components/home-content/home-content.component.spec.ts b/Sample-01/src/app/components/home-content/home-content.component.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/components/home-content/home-content.component.spec.ts rename to Sample-01/src/app/components/home-content/home-content.component.spec.ts diff --git a/02-Calling-an-API/src/app/components/home-content/home-content.component.ts b/Sample-01/src/app/components/home-content/home-content.component.ts similarity index 100% rename from 02-Calling-an-API/src/app/components/home-content/home-content.component.ts rename to Sample-01/src/app/components/home-content/home-content.component.ts diff --git a/02-Calling-an-API/src/app/components/loading/loading.component.css b/Sample-01/src/app/components/loading/loading.component.css similarity index 100% rename from 02-Calling-an-API/src/app/components/loading/loading.component.css rename to Sample-01/src/app/components/loading/loading.component.css diff --git a/02-Calling-an-API/src/app/components/loading/loading.component.html b/Sample-01/src/app/components/loading/loading.component.html similarity index 100% rename from 02-Calling-an-API/src/app/components/loading/loading.component.html rename to Sample-01/src/app/components/loading/loading.component.html diff --git a/02-Calling-an-API/src/app/components/loading/loading.component.spec.ts b/Sample-01/src/app/components/loading/loading.component.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/components/loading/loading.component.spec.ts rename to Sample-01/src/app/components/loading/loading.component.spec.ts diff --git a/02-Calling-an-API/src/app/components/loading/loading.component.ts b/Sample-01/src/app/components/loading/loading.component.ts similarity index 100% rename from 02-Calling-an-API/src/app/components/loading/loading.component.ts rename to Sample-01/src/app/components/loading/loading.component.ts diff --git a/02-Calling-an-API/src/app/components/nav-bar/nav-bar.component.css b/Sample-01/src/app/components/nav-bar/nav-bar.component.css similarity index 100% rename from 02-Calling-an-API/src/app/components/nav-bar/nav-bar.component.css rename to Sample-01/src/app/components/nav-bar/nav-bar.component.css diff --git a/02-Calling-an-API/src/app/components/nav-bar/nav-bar.component.html b/Sample-01/src/app/components/nav-bar/nav-bar.component.html similarity index 100% rename from 02-Calling-an-API/src/app/components/nav-bar/nav-bar.component.html rename to Sample-01/src/app/components/nav-bar/nav-bar.component.html diff --git a/02-Calling-an-API/src/app/components/nav-bar/nav-bar.component.spec.ts b/Sample-01/src/app/components/nav-bar/nav-bar.component.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/components/nav-bar/nav-bar.component.spec.ts rename to Sample-01/src/app/components/nav-bar/nav-bar.component.spec.ts diff --git a/02-Calling-an-API/src/app/components/nav-bar/nav-bar.component.ts b/Sample-01/src/app/components/nav-bar/nav-bar.component.ts similarity index 100% rename from 02-Calling-an-API/src/app/components/nav-bar/nav-bar.component.ts rename to Sample-01/src/app/components/nav-bar/nav-bar.component.ts diff --git a/02-Calling-an-API/src/app/pages/external-api/external-api.component.css b/Sample-01/src/app/pages/external-api/external-api.component.css similarity index 100% rename from 02-Calling-an-API/src/app/pages/external-api/external-api.component.css rename to Sample-01/src/app/pages/external-api/external-api.component.css diff --git a/02-Calling-an-API/src/app/pages/external-api/external-api.component.html b/Sample-01/src/app/pages/external-api/external-api.component.html similarity index 100% rename from 02-Calling-an-API/src/app/pages/external-api/external-api.component.html rename to Sample-01/src/app/pages/external-api/external-api.component.html diff --git a/02-Calling-an-API/src/app/pages/external-api/external-api.component.spec.ts b/Sample-01/src/app/pages/external-api/external-api.component.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/pages/external-api/external-api.component.spec.ts rename to Sample-01/src/app/pages/external-api/external-api.component.spec.ts diff --git a/02-Calling-an-API/src/app/pages/external-api/external-api.component.ts b/Sample-01/src/app/pages/external-api/external-api.component.ts similarity index 100% rename from 02-Calling-an-API/src/app/pages/external-api/external-api.component.ts rename to Sample-01/src/app/pages/external-api/external-api.component.ts diff --git a/02-Calling-an-API/src/app/pages/home/home.component.css b/Sample-01/src/app/pages/home/home.component.css similarity index 100% rename from 02-Calling-an-API/src/app/pages/home/home.component.css rename to Sample-01/src/app/pages/home/home.component.css diff --git a/02-Calling-an-API/src/app/pages/home/home.component.html b/Sample-01/src/app/pages/home/home.component.html similarity index 100% rename from 02-Calling-an-API/src/app/pages/home/home.component.html rename to Sample-01/src/app/pages/home/home.component.html diff --git a/02-Calling-an-API/src/app/pages/home/home.component.spec.ts b/Sample-01/src/app/pages/home/home.component.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/pages/home/home.component.spec.ts rename to Sample-01/src/app/pages/home/home.component.spec.ts diff --git a/02-Calling-an-API/src/app/pages/home/home.component.ts b/Sample-01/src/app/pages/home/home.component.ts similarity index 100% rename from 02-Calling-an-API/src/app/pages/home/home.component.ts rename to Sample-01/src/app/pages/home/home.component.ts diff --git a/02-Calling-an-API/src/app/pages/profile/profile.component.css b/Sample-01/src/app/pages/profile/profile.component.css similarity index 100% rename from 02-Calling-an-API/src/app/pages/profile/profile.component.css rename to Sample-01/src/app/pages/profile/profile.component.css diff --git a/02-Calling-an-API/src/app/pages/profile/profile.component.html b/Sample-01/src/app/pages/profile/profile.component.html similarity index 100% rename from 02-Calling-an-API/src/app/pages/profile/profile.component.html rename to Sample-01/src/app/pages/profile/profile.component.html diff --git a/02-Calling-an-API/src/app/pages/profile/profile.component.spec.ts b/Sample-01/src/app/pages/profile/profile.component.spec.ts similarity index 100% rename from 02-Calling-an-API/src/app/pages/profile/profile.component.spec.ts rename to Sample-01/src/app/pages/profile/profile.component.spec.ts diff --git a/02-Calling-an-API/src/app/pages/profile/profile.component.ts b/Sample-01/src/app/pages/profile/profile.component.ts similarity index 100% rename from 02-Calling-an-API/src/app/pages/profile/profile.component.ts rename to Sample-01/src/app/pages/profile/profile.component.ts diff --git a/02-Calling-an-API/src/assets/.gitkeep b/Sample-01/src/assets/.gitkeep similarity index 100% rename from 02-Calling-an-API/src/assets/.gitkeep rename to Sample-01/src/assets/.gitkeep diff --git a/02-Calling-an-API/src/assets/loading.svg b/Sample-01/src/assets/loading.svg similarity index 100% rename from 02-Calling-an-API/src/assets/loading.svg rename to Sample-01/src/assets/loading.svg diff --git a/02-Calling-an-API/src/assets/logo.png b/Sample-01/src/assets/logo.png similarity index 100% rename from 02-Calling-an-API/src/assets/logo.png rename to Sample-01/src/assets/logo.png diff --git a/02-Calling-an-API/src/environments/environment.prod.ts b/Sample-01/src/environments/environment.prod.ts similarity index 100% rename from 02-Calling-an-API/src/environments/environment.prod.ts rename to Sample-01/src/environments/environment.prod.ts diff --git a/02-Calling-an-API/src/environments/environment.ts b/Sample-01/src/environments/environment.ts similarity index 100% rename from 02-Calling-an-API/src/environments/environment.ts rename to Sample-01/src/environments/environment.ts diff --git a/02-Calling-an-API/src/favicon.ico b/Sample-01/src/favicon.ico similarity index 100% rename from 02-Calling-an-API/src/favicon.ico rename to Sample-01/src/favicon.ico diff --git a/02-Calling-an-API/src/index.html b/Sample-01/src/index.html similarity index 100% rename from 02-Calling-an-API/src/index.html rename to Sample-01/src/index.html diff --git a/02-Calling-an-API/src/main.ts b/Sample-01/src/main.ts similarity index 100% rename from 02-Calling-an-API/src/main.ts rename to Sample-01/src/main.ts diff --git a/02-Calling-an-API/src/polyfills.ts b/Sample-01/src/polyfills.ts similarity index 100% rename from 02-Calling-an-API/src/polyfills.ts rename to Sample-01/src/polyfills.ts diff --git a/02-Calling-an-API/src/styles.css b/Sample-01/src/styles.css similarity index 100% rename from 02-Calling-an-API/src/styles.css rename to Sample-01/src/styles.css diff --git a/02-Calling-an-API/src/test.ts b/Sample-01/src/test.ts similarity index 100% rename from 02-Calling-an-API/src/test.ts rename to Sample-01/src/test.ts diff --git a/02-Calling-an-API/tsconfig.app.json b/Sample-01/tsconfig.app.json similarity index 100% rename from 02-Calling-an-API/tsconfig.app.json rename to Sample-01/tsconfig.app.json diff --git a/02-Calling-an-API/tsconfig.json b/Sample-01/tsconfig.json similarity index 100% rename from 02-Calling-an-API/tsconfig.json rename to Sample-01/tsconfig.json diff --git a/02-Calling-an-API/tsconfig.spec.json b/Sample-01/tsconfig.spec.json similarity index 100% rename from 02-Calling-an-API/tsconfig.spec.json rename to Sample-01/tsconfig.spec.json diff --git a/02-Calling-an-API/tslint.json b/Sample-01/tslint.json similarity index 100% rename from 02-Calling-an-API/tslint.json rename to Sample-01/tslint.json From b1746e744bbb8e6956462f376080cc3d09128bfb Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Wed, 12 Aug 2020 14:35:57 +0100 Subject: [PATCH 005/262] Update to latest Angular core and cli to 8 --- Sample-01/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sample-01/package.json b/Sample-01/package.json index 3a4aaac3..099f0c1d 100644 --- a/Sample-01/package.json +++ b/Sample-01/package.json @@ -38,8 +38,8 @@ "zone.js": "^0.9.1" }, "devDependencies": { - "@angular-devkit/build-angular": "~0.803.8", - "@angular/cli": "~8.3.8", + "@angular-devkit/build-angular": "~0.803.29", + "@angular/cli": "~8.3.29", "@angular/compiler-cli": "~8.2.9", "@angular/language-service": "~8.2.9", "@ng-bootstrap/ng-bootstrap": "^5.1.1", From 1b93fa796e41d2af33d987721d8618d7b32f5c2e Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Wed, 12 Aug 2020 14:38:07 +0100 Subject: [PATCH 006/262] Update to Angular 9 --- Sample-01/angular.json | 7 +++++-- Sample-01/package.json | 32 ++++++++++++++++---------------- Sample-01/tsconfig.app.json | 10 +++++----- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Sample-01/angular.json b/Sample-01/angular.json index 830c9849..f8337991 100644 --- a/Sample-01/angular.json +++ b/Sample-01/angular.json @@ -18,7 +18,7 @@ "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.app.json", - "aot": false, + "aot": true, "assets": [ "src/favicon.ico", "src/assets" @@ -42,7 +42,6 @@ "sourceMap": false, "extractCss": true, "namedChunks": false, - "aot": true, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true, @@ -51,6 +50,10 @@ "type": "initial", "maximumWarning": "2mb", "maximumError": "5mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "6kb" } ] } diff --git a/Sample-01/package.json b/Sample-01/package.json index 099f0c1d..4e0bf966 100644 --- a/Sample-01/package.json +++ b/Sample-01/package.json @@ -14,14 +14,14 @@ }, "private": true, "dependencies": { - "@angular/animations": "~8.2.9", - "@angular/common": "~8.2.9", - "@angular/compiler": "~8.2.9", - "@angular/core": "~8.2.9", - "@angular/forms": "~8.2.9", - "@angular/platform-browser": "~8.2.9", - "@angular/platform-browser-dynamic": "~8.2.9", - "@angular/router": "~8.2.9", + "@angular/animations": "~9.1.12", + "@angular/common": "~9.1.12", + "@angular/compiler": "~9.1.12", + "@angular/core": "~9.1.12", + "@angular/forms": "~9.1.12", + "@angular/platform-browser": "~9.1.12", + "@angular/platform-browser-dynamic": "~9.1.12", + "@angular/router": "~9.1.12", "@auth0/auth0-spa-js": "^1.2.4", "@fortawesome/angular-fontawesome": "^0.4.0", "@fortawesome/fontawesome-svg-core": "^1.2.19", @@ -34,18 +34,18 @@ "ngx-highlightjs": "^3.0.3", "npm-run-all": "^4.1.5", "rxjs": "~6.5.3", - "tslib": "^1.9.0", - "zone.js": "^0.9.1" + "tslib": "^1.10.0", + "zone.js": "~0.10.2" }, "devDependencies": { - "@angular-devkit/build-angular": "~0.803.29", - "@angular/cli": "~8.3.29", - "@angular/compiler-cli": "~8.2.9", - "@angular/language-service": "~8.2.9", + "@angular-devkit/build-angular": "~0.901.12", + "@angular/cli": "~9.1.12", + "@angular/compiler-cli": "~9.1.12", + "@angular/language-service": "~9.1.12", "@ng-bootstrap/ng-bootstrap": "^5.1.1", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", - "@types/node": "~8.9.4", + "@types/node": "^12.11.1", "codelyzer": "^5.1.2", "highlight.js": "^9.15.8", "jasmine-core": "~3.4.0", @@ -58,6 +58,6 @@ "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", - "typescript": "~3.5.3" + "typescript": "~3.8.3" } } diff --git a/Sample-01/tsconfig.app.json b/Sample-01/tsconfig.app.json index 31f8397a..f758d982 100644 --- a/Sample-01/tsconfig.app.json +++ b/Sample-01/tsconfig.app.json @@ -4,11 +4,11 @@ "outDir": "./out-tsc/app", "types": [] }, - "include": [ - "src/**/*.ts" + "files": [ + "src/main.ts", + "src/polyfills.ts" ], - "exclude": [ - "src/test.ts", - "src/**/*.spec.ts" + "include": [ + "src/**/*.d.ts" ] } From 3ab021914b46403e56ad0b8b47a96194a90588e7 Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Wed, 12 Aug 2020 14:41:59 +0100 Subject: [PATCH 007/262] Updated ng-bootstrap --- Sample-01/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sample-01/package.json b/Sample-01/package.json index 4e0bf966..2e0fa1d9 100644 --- a/Sample-01/package.json +++ b/Sample-01/package.json @@ -42,7 +42,7 @@ "@angular/cli": "~9.1.12", "@angular/compiler-cli": "~9.1.12", "@angular/language-service": "~9.1.12", - "@ng-bootstrap/ng-bootstrap": "^5.1.1", + "@ng-bootstrap/ng-bootstrap": "^7.0.0", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "@types/node": "^12.11.1", From 67a9b0484e21ea23f5846c7625cf60f523437ed4 Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Wed, 12 Aug 2020 14:44:07 +0100 Subject: [PATCH 008/262] Update FontAwesome --- Sample-01/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sample-01/package.json b/Sample-01/package.json index 2e0fa1d9..785a1896 100644 --- a/Sample-01/package.json +++ b/Sample-01/package.json @@ -23,7 +23,7 @@ "@angular/platform-browser-dynamic": "~9.1.12", "@angular/router": "~9.1.12", "@auth0/auth0-spa-js": "^1.2.4", - "@fortawesome/angular-fontawesome": "^0.4.0", + "@fortawesome/angular-fontawesome": "^0.7.0", "@fortawesome/fontawesome-svg-core": "^1.2.19", "@fortawesome/free-solid-svg-icons": "^5.9.0", "express": "^4.17.1", From 833f498e88c41f50b40ba2e7e12868d21c7973b6 Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Wed, 12 Aug 2020 14:45:56 +0100 Subject: [PATCH 009/262] Update to Angular 10 --- Sample-01/{browserslist => .browserslistrc} | 0 Sample-01/e2e/tsconfig.json | 4 +- Sample-01/package.json | 48 +++++++-------- Sample-01/tsconfig.app.json | 2 +- Sample-01/tsconfig.base.json | 28 +++++++++ Sample-01/tsconfig.json | 43 +++++-------- Sample-01/tsconfig.spec.json | 2 +- Sample-01/tslint.json | 67 ++++++++++++++++++++- 8 files changed, 137 insertions(+), 57 deletions(-) rename Sample-01/{browserslist => .browserslistrc} (100%) create mode 100644 Sample-01/tsconfig.base.json diff --git a/Sample-01/browserslist b/Sample-01/.browserslistrc similarity index 100% rename from Sample-01/browserslist rename to Sample-01/.browserslistrc diff --git a/Sample-01/e2e/tsconfig.json b/Sample-01/e2e/tsconfig.json index 39b800f7..6b87cc42 100644 --- a/Sample-01/e2e/tsconfig.json +++ b/Sample-01/e2e/tsconfig.json @@ -1,9 +1,9 @@ { - "extends": "../tsconfig.json", + "extends": "../tsconfig.base.json", "compilerOptions": { "outDir": "../out-tsc/e2e", "module": "commonjs", - "target": "es5", + "target": "es2018", "types": [ "jasmine", "jasminewd2", diff --git a/Sample-01/package.json b/Sample-01/package.json index 785a1896..3cb083c7 100644 --- a/Sample-01/package.json +++ b/Sample-01/package.json @@ -14,14 +14,14 @@ }, "private": true, "dependencies": { - "@angular/animations": "~9.1.12", - "@angular/common": "~9.1.12", - "@angular/compiler": "~9.1.12", - "@angular/core": "~9.1.12", - "@angular/forms": "~9.1.12", - "@angular/platform-browser": "~9.1.12", - "@angular/platform-browser-dynamic": "~9.1.12", - "@angular/router": "~9.1.12", + "@angular/animations": "~10.0.8", + "@angular/common": "~10.0.8", + "@angular/compiler": "~10.0.8", + "@angular/core": "~10.0.8", + "@angular/forms": "~10.0.8", + "@angular/platform-browser": "~10.0.8", + "@angular/platform-browser-dynamic": "~10.0.8", + "@angular/router": "~10.0.8", "@auth0/auth0-spa-js": "^1.2.4", "@fortawesome/angular-fontawesome": "^0.7.0", "@fortawesome/fontawesome-svg-core": "^1.2.19", @@ -34,30 +34,30 @@ "ngx-highlightjs": "^3.0.3", "npm-run-all": "^4.1.5", "rxjs": "~6.5.3", - "tslib": "^1.10.0", + "tslib": "^2.0.0", "zone.js": "~0.10.2" }, "devDependencies": { - "@angular-devkit/build-angular": "~0.901.12", - "@angular/cli": "~9.1.12", - "@angular/compiler-cli": "~9.1.12", - "@angular/language-service": "~9.1.12", + "@angular-devkit/build-angular": "~0.1000.5", + "@angular/cli": "~10.0.5", + "@angular/compiler-cli": "~10.0.8", + "@angular/language-service": "~10.0.8", "@ng-bootstrap/ng-bootstrap": "^7.0.0", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "@types/node": "^12.11.1", - "codelyzer": "^5.1.2", + "codelyzer": "^6.0.0", "highlight.js": "^9.15.8", - "jasmine-core": "~3.4.0", - "jasmine-spec-reporter": "~4.2.1", - "karma": "~4.1.0", - "karma-chrome-launcher": "~2.2.0", - "karma-coverage-istanbul-reporter": "~2.0.1", - "karma-jasmine": "~2.0.1", - "karma-jasmine-html-reporter": "^1.4.0", - "protractor": "~5.4.0", + "jasmine-core": "~3.5.0", + "jasmine-spec-reporter": "~5.0.0", + "karma": "~5.0.0", + "karma-chrome-launcher": "~3.1.0", + "karma-coverage-istanbul-reporter": "~3.0.2", + "karma-jasmine": "~3.3.0", + "karma-jasmine-html-reporter": "^1.5.0", + "protractor": "~7.0.0", "ts-node": "~7.0.0", - "tslint": "~5.15.0", - "typescript": "~3.8.3" + "tslint": "~6.1.0", + "typescript": "~3.9.7" } } diff --git a/Sample-01/tsconfig.app.json b/Sample-01/tsconfig.app.json index f758d982..44795bd5 100644 --- a/Sample-01/tsconfig.app.json +++ b/Sample-01/tsconfig.app.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig.json", + "extends": "./tsconfig.base.json", "compilerOptions": { "outDir": "./out-tsc/app", "types": [] diff --git a/Sample-01/tsconfig.base.json b/Sample-01/tsconfig.base.json new file mode 100644 index 00000000..ac735876 --- /dev/null +++ b/Sample-01/tsconfig.base.json @@ -0,0 +1,28 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "downlevelIteration": true, + "experimentalDecorators": true, + "module": "es2020", + "moduleResolution": "node", + "importHelpers": true, + "target": "es2015", + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "es2018", + "dom" + ], + "resolveJsonModule": true, + "esModuleInterop": true + }, + "angularCompilerOptions": { + "fullTemplateTypeCheck": true, + "strictInjectionParameters": true + } +} diff --git a/Sample-01/tsconfig.json b/Sample-01/tsconfig.json index 5cadd072..7e00e707 100644 --- a/Sample-01/tsconfig.json +++ b/Sample-01/tsconfig.json @@ -1,28 +1,17 @@ +/* + This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience. + It is not intended to be used to perform a compilation. + + To learn more about this file see: https://angular.io/config/solution-tsconfig. +*/ { - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist/out-tsc", - "sourceMap": true, - "declaration": false, - "downlevelIteration": true, - "experimentalDecorators": true, - "module": "esnext", - "moduleResolution": "node", - "importHelpers": true, - "target": "es2015", - "typeRoots": [ - "node_modules/@types" - ], - "lib": [ - "es2018", - "dom" - ], - "resolveJsonModule": true, - "esModuleInterop": true - }, - "angularCompilerOptions": { - "fullTemplateTypeCheck": true, - "strictInjectionParameters": true - } -} + "files": [], + "references": [ + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} \ No newline at end of file diff --git a/Sample-01/tsconfig.spec.json b/Sample-01/tsconfig.spec.json index 6400fde7..1db2e6ee 100644 --- a/Sample-01/tsconfig.spec.json +++ b/Sample-01/tsconfig.spec.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig.json", + "extends": "./tsconfig.base.json", "compilerOptions": { "outDir": "./out-tsc/spec", "types": [ diff --git a/Sample-01/tslint.json b/Sample-01/tslint.json index f0adae98..58a97b08 100644 --- a/Sample-01/tslint.json +++ b/Sample-01/tslint.json @@ -1,8 +1,16 @@ { "extends": "tslint:recommended", "rules": { + "align": { + "options": [ + "parameters", + "statements" + ] + }, "array-type": false, "arrow-parens": false, + "arrow-return-shorthand": true, + "curly": true, "deprecation": { "severity": "warning" }, @@ -21,10 +29,17 @@ "app", "kebab-case" ], + "eofline": true, "import-blacklist": [ true, "rxjs/Rx" ], + "import-spacing": true, + "indent": { + "options": [ + "spaces" + ] + }, "interface-name": false, "max-classes-per-file": false, "max-line-length": [ @@ -60,7 +75,6 @@ "no-non-null-assertion": true, "no-redundant-jsdoc": true, "no-switch-case-fall-through": true, - "no-use-before-declare": true, "no-var-requires": false, "object-literal-key-quotes": [ true, @@ -72,6 +86,20 @@ true, "single" ], + "semicolon": { + "options": [ + "always" + ] + }, + "space-before-function-paren": { + "options": { + "anonymous": "never", + "asyncArrow": "always", + "constructor": "never", + "method": "never", + "named": "never" + } + }, "trailing-comma": false, "no-conflicting-lifecycle": true, "no-host-metadata-property": true, @@ -83,9 +111,44 @@ "no-outputs-metadata-property": true, "template-banana-in-box": true, "template-no-negated-async": true, + "typedef-whitespace": { + "options": [ + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, + { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + } + ] + }, "use-lifecycle-interface": true, "use-pipe-transform-interface": true - }, + , "variable-name": { + "options": [ + "ban-keywords", + "check-format", + "allow-pascal-case" + ] + }, + "whitespace": { + "options": [ + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type", + "check-typecast" + ] + } +}, "rulesDirectory": [ "codelyzer" ] From eec1fd4850aec00aa6000afd2387096ddde32a76 Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Wed, 12 Aug 2020 15:44:36 +0100 Subject: [PATCH 010/262] Update the sample to use auth0-angular --- Sample-01/auth_config.json.example | 6 + Sample-01/package.json | 8 +- Sample-01/server.js | 8 +- Sample-01/src/app/app-routing.module.ts | 21 +-- Sample-01/src/app/app.module.ts | 28 +++- Sample-01/src/app/auth/auth.guard.spec.ts | 15 -- Sample-01/src/app/auth/auth.guard.ts | 32 ----- Sample-01/src/app/auth/auth.service.spec.ts | 12 -- Sample-01/src/app/auth/auth.service.ts | 136 ------------------ .../src/app/auth/interceptor.service.spec.ts | 12 -- Sample-01/src/app/auth/interceptor.service.ts | 33 ----- .../components/nav-bar/nav-bar.component.html | 90 ++++++------ .../components/nav-bar/nav-bar.component.ts | 14 +- .../src/app/pages/home/home.component.html | 8 +- .../src/app/pages/home/home.component.ts | 9 +- .../app/pages/profile/profile.component.html | 12 +- .../app/pages/profile/profile.component.ts | 11 +- Sample-01/src/environments/environment.ts | 12 +- Sample-01/src/polyfills.ts | 4 + 19 files changed, 137 insertions(+), 334 deletions(-) create mode 100644 Sample-01/auth_config.json.example delete mode 100644 Sample-01/src/app/auth/auth.guard.spec.ts delete mode 100644 Sample-01/src/app/auth/auth.guard.ts delete mode 100644 Sample-01/src/app/auth/auth.service.spec.ts delete mode 100644 Sample-01/src/app/auth/auth.service.ts delete mode 100644 Sample-01/src/app/auth/interceptor.service.spec.ts delete mode 100644 Sample-01/src/app/auth/interceptor.service.ts diff --git a/Sample-01/auth_config.json.example b/Sample-01/auth_config.json.example new file mode 100644 index 00000000..f13d84bc --- /dev/null +++ b/Sample-01/auth_config.json.example @@ -0,0 +1,6 @@ +{ + "domain": "AUTH0_DOMAIN", + "clientId": "AUTH0_CLIENT_ID", + "audience": "AUTH0_API_IDENTIFIER", + "apiUri": "http://localhost:3001 +} \ No newline at end of file diff --git a/Sample-01/package.json b/Sample-01/package.json index 3cb083c7..bd5dc412 100644 --- a/Sample-01/package.json +++ b/Sample-01/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "scripts": { "ng": "ng", - "start": "ng serve --port 3000", + "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", @@ -19,10 +19,11 @@ "@angular/compiler": "~10.0.8", "@angular/core": "~10.0.8", "@angular/forms": "~10.0.8", + "@angular/localize": "^10.0.8", "@angular/platform-browser": "~10.0.8", "@angular/platform-browser-dynamic": "~10.0.8", "@angular/router": "~10.0.8", - "@auth0/auth0-spa-js": "^1.2.4", + "@auth0/auth0-angular": "file:../../../../auth0-auth0-angular-0.1.0.tgz", "@fortawesome/angular-fontawesome": "^0.7.0", "@fortawesome/fontawesome-svg-core": "^1.2.19", "@fortawesome/free-solid-svg-icons": "^5.9.0", @@ -59,5 +60,8 @@ "ts-node": "~7.0.0", "tslint": "~6.1.0", "typescript": "~3.9.7" + }, + "prettier": { + "singleQuote": true } } diff --git a/Sample-01/server.js b/Sample-01/server.js index d31bcce3..c7bc1866 100644 --- a/Sample-01/server.js +++ b/Sample-01/server.js @@ -20,17 +20,17 @@ const checkJwt = jwt({ cache: true, rateLimit: true, jwksRequestsPerMinute: 5, - jwksUri: `https://${authConfig.domain}/.well-known/jwks.json` + jwksUri: `https://${authConfig.domain}/.well-known/jwks.json`, }), audience: authConfig.audience, issuer: `https://${authConfig.domain}/`, - algorithm: ['RS256'] + algorithm: ['RS256'], }); app.get('/api/external', checkJwt, (req, res) => { res.send({ - msg: 'Your access token was successfully validated!' + msg: 'Your access token was successfully validated!', }); }); @@ -42,6 +42,6 @@ if (process.env.NODE_ENV === 'production') { }); } -const port = process.env.NODE_ENV === 'production' ? 3000 : 3001; +const port = process.env.NODE_ENV === 'production' ? 4200 : 3001; app.listen(port, () => console.log(`Server started on port ${port}`)); diff --git a/Sample-01/src/app/app-routing.module.ts b/Sample-01/src/app/app-routing.module.ts index 3cfcfa2b..661c72e7 100644 --- a/Sample-01/src/app/app-routing.module.ts +++ b/Sample-01/src/app/app-routing.module.ts @@ -1,39 +1,30 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { HomeComponent } from './pages/home/home.component'; -import { AuthGuard } from './auth/auth.guard'; import { ProfileComponent } from './pages/profile/profile.component'; import { ExternalApiComponent } from './pages/external-api/external-api.component'; -import { HTTP_INTERCEPTORS } from '@angular/common/http'; -import { InterceptorService } from './auth/interceptor.service'; +import { AuthGuard } from '@auth0/auth0-angular'; const routes: Routes = [ { path: 'profile', component: ProfileComponent, - canActivate: [AuthGuard] + canActivate: [AuthGuard], }, { path: 'external-api', component: ExternalApiComponent, - canActivate: [AuthGuard] + canActivate: [AuthGuard], }, { path: '', component: HomeComponent, - pathMatch: 'full' - } + pathMatch: 'full', + }, ]; @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule], - providers: [ - { - provide: HTTP_INTERCEPTORS, - useClass: InterceptorService, - multi: true - } - ] }) -export class AppRoutingModule { } +export class AppRoutingModule {} diff --git a/Sample-01/src/app/app.module.ts b/Sample-01/src/app/app.module.ts index c611fd53..fe2e2455 100644 --- a/Sample-01/src/app/app.module.ts +++ b/Sample-01/src/app/app.module.ts @@ -15,7 +15,9 @@ import { HeroComponent } from './components/hero/hero.component'; import { HomeContentComponent } from './components/home-content/home-content.component'; import { LoadingComponent } from './components/loading/loading.component'; import { ExternalApiComponent } from './pages/external-api/external-api.component'; -import { HttpClientModule } from '@angular/common/http'; +import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; +import { AuthHttpInterceptor, AuthModule } from '@auth0/auth0-angular'; +import { environment as env } from '../environments/environment'; export function hljsLanguages() { return [{ name: 'json', func: json }]; @@ -31,7 +33,7 @@ export function hljsLanguages() { HeroComponent, HomeContentComponent, LoadingComponent, - ExternalApiComponent + ExternalApiComponent, ], imports: [ BrowserModule, @@ -39,11 +41,23 @@ export function hljsLanguages() { HttpClientModule, NgbModule, HighlightModule.forRoot({ - languages: hljsLanguages + languages: hljsLanguages, }), - FontAwesomeModule + FontAwesomeModule, + AuthModule.forRoot({ + ...env.auth, + httpInterceptor: { + ...env.httpInterceptor, + }, + }), + ], + providers: [ + { + provide: HTTP_INTERCEPTORS, + useClass: AuthHttpInterceptor, + multi: true, + }, ], - providers: [], - bootstrap: [AppComponent] + bootstrap: [AppComponent], }) -export class AppModule { } +export class AppModule {} diff --git a/Sample-01/src/app/auth/auth.guard.spec.ts b/Sample-01/src/app/auth/auth.guard.spec.ts deleted file mode 100644 index 7ed05ee8..00000000 --- a/Sample-01/src/app/auth/auth.guard.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, async, inject } from '@angular/core/testing'; - -import { AuthGuard } from './auth.guard'; - -describe('AuthGuard', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [AuthGuard] - }); - }); - - it('should ...', inject([AuthGuard], (guard: AuthGuard) => { - expect(guard).toBeTruthy(); - })); -}); diff --git a/Sample-01/src/app/auth/auth.guard.ts b/Sample-01/src/app/auth/auth.guard.ts deleted file mode 100644 index 440ef415..00000000 --- a/Sample-01/src/app/auth/auth.guard.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Injectable } from '@angular/core'; -import { - ActivatedRouteSnapshot, - RouterStateSnapshot, - UrlTree, - CanActivate -} from '@angular/router'; -import { Observable } from 'rxjs'; -import { AuthService } from './auth.service'; -import { tap } from 'rxjs/operators'; - -@Injectable({ - providedIn: 'root' -}) -export class AuthGuard implements CanActivate { - - constructor(private auth: AuthService) {} - - canActivate( - next: ActivatedRouteSnapshot, - state: RouterStateSnapshot - ): Observable | Promise | boolean { - return this.auth.isAuthenticated$.pipe( - tap(loggedIn => { - if (!loggedIn) { - this.auth.login(state.url); - } - }) - ); - } - -} diff --git a/Sample-01/src/app/auth/auth.service.spec.ts b/Sample-01/src/app/auth/auth.service.spec.ts deleted file mode 100644 index f3d964d2..00000000 --- a/Sample-01/src/app/auth/auth.service.spec.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { AuthService } from './auth.service'; - -describe('AuthService', () => { - beforeEach(() => TestBed.configureTestingModule({})); - - it('should be created', () => { - const service: AuthService = TestBed.get(AuthService); - expect(service).toBeTruthy(); - }); -}); diff --git a/Sample-01/src/app/auth/auth.service.ts b/Sample-01/src/app/auth/auth.service.ts deleted file mode 100644 index f9088478..00000000 --- a/Sample-01/src/app/auth/auth.service.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { Injectable } from '@angular/core'; -import createAuth0Client from '@auth0/auth0-spa-js'; -import Auth0Client from '@auth0/auth0-spa-js/dist/typings/Auth0Client'; -import * as config from '../../../auth_config.json'; -import { from, of, Observable, BehaviorSubject, combineLatest, throwError } from 'rxjs'; -import { tap, catchError, concatMap, shareReplay } from 'rxjs/operators'; -import { Router } from '@angular/router'; - -@Injectable({ - providedIn: 'root' -}) -export class AuthService { - // Create an observable of Auth0 instance of client - auth0Client$ = (from( - createAuth0Client({ - domain: config.domain, - client_id: config.clientId, - redirect_uri: `${window.location.origin}`, - audience: config.audience - }) - ) as Observable).pipe( - shareReplay(1), // Every subscription receives the same shared value - catchError(err => throwError(err)) - ); - // Define observables for SDK methods that return promises by default - // For each Auth0 SDK method, first ensure the client instance is ready - // concatMap: Using the client instance, call SDK method; SDK returns a promise - // from: Convert that resulting promise into an observable - isAuthenticated$ = this.auth0Client$.pipe( - concatMap((client: Auth0Client) => from(client.isAuthenticated())), - tap(res => this.loggedIn = res) - ); - handleRedirectCallback$ = this.auth0Client$.pipe( - concatMap((client: Auth0Client) => from(client.handleRedirectCallback())) - ); - // Create subject and public observable of user profile data - private userProfileSubject$ = new BehaviorSubject(null); - userProfile$ = this.userProfileSubject$.asObservable(); - // Create a local property for login status - loggedIn: boolean = null; - - constructor(private router: Router) { - // On initial load, check authentication state with authorization server - // Set up local auth streams if user is already authenticated - this.localAuthSetup(); - // Handle redirect from Auth0 login - this.handleAuthCallback(); - } - - // When calling, options can be passed if desired - // https://auth0.github.io/auth0-spa-js/classes/auth0client.html#getuser - getUser$(options?): Observable { - return this.auth0Client$.pipe( - concatMap((client: Auth0Client) => from(client.getUser(options))), - tap(user => this.userProfileSubject$.next(user)) - ); - } - - // When calling, options can be passed if desired - // https://auth0.github.io/auth0-spa-js/classes/auth0client.html#gettokensilently - getTokenSilently$(options?): Observable { - return this.auth0Client$.pipe( - concatMap((client: Auth0Client) => from(client.getTokenSilently(options))) - ); - } - - private localAuthSetup() { - // This should only be called on app initialization - // Set up local authentication streams - const checkAuth$ = this.isAuthenticated$.pipe( - concatMap((loggedIn: boolean) => { - if (loggedIn) { - // If authenticated, get user and set in app - // NOTE: you could pass options here if needed - return this.getUser$(); - } - // If not authenticated, return stream that emits 'false' - return of(loggedIn); - }) - ); - checkAuth$.subscribe(); - } - - login(redirectPath: string = '/') { - // A desired redirect path can be passed to login method - // (e.g., from a route guard) - // Ensure Auth0 client instance exists - this.auth0Client$.subscribe((client: Auth0Client) => { - // Call method to log in - client.loginWithRedirect({ - redirect_uri: `${window.location.origin}`, - appState: { target: redirectPath } - }); - }); - } - - private handleAuthCallback() { - // Call when app reloads after user logs in with Auth0 - const params = window.location.search; - if (params.includes('code=') && params.includes('state=')) { - let targetRoute: string; // Path to redirect to after login processsed - const authComplete$ = this.handleRedirectCallback$.pipe( - // Have client, now call method to handle auth callback redirect - tap(cbRes => { - // Get and set target redirect route from callback results - targetRoute = cbRes.appState && cbRes.appState.target ? cbRes.appState.target : '/'; - }), - concatMap(() => { - // Redirect callback complete; get user and login status - return combineLatest([ - this.getUser$(), - this.isAuthenticated$ - ]); - }) - ); - // Subscribe to authentication completion observable - // Response will be an array of user and login status - authComplete$.subscribe(([user, loggedIn]) => { - // Redirect to target route after callback processing - this.router.navigate([targetRoute]); - }); - } - } - - logout() { - // Ensure Auth0 client instance exists - this.auth0Client$.subscribe((client: Auth0Client) => { - // Call method to log out - client.logout({ - client_id: config.clientId, - returnTo: window.location.origin - }); - }); - } - -} diff --git a/Sample-01/src/app/auth/interceptor.service.spec.ts b/Sample-01/src/app/auth/interceptor.service.spec.ts deleted file mode 100644 index d3ef2c51..00000000 --- a/Sample-01/src/app/auth/interceptor.service.spec.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { InterceptorService } from './interceptor.service'; - -describe('InterceptorService', () => { - beforeEach(() => TestBed.configureTestingModule({})); - - it('should be created', () => { - const service: InterceptorService = TestBed.get(InterceptorService); - expect(service).toBeTruthy(); - }); -}); diff --git a/Sample-01/src/app/auth/interceptor.service.ts b/Sample-01/src/app/auth/interceptor.service.ts deleted file mode 100644 index e49cf4f3..00000000 --- a/Sample-01/src/app/auth/interceptor.service.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Injectable } from '@angular/core'; -import { - HttpRequest, - HttpHandler, - HttpEvent, - HttpInterceptor -} from '@angular/common/http'; -import { AuthService } from './auth.service'; -import { Observable, throwError } from 'rxjs'; -import { mergeMap, catchError } from 'rxjs/operators'; - -@Injectable({ - providedIn: 'root' -}) -export class InterceptorService implements HttpInterceptor { - - constructor(private auth: AuthService) { } - - intercept( - req: HttpRequest, - next: HttpHandler - ): Observable> { - return this.auth.getTokenSilently$().pipe( - mergeMap(token => { - const tokenReq = req.clone({ - setHeaders: { Authorization: `Bearer ${token}` } - }); - return next.handle(tokenReq); - }), - catchError(err => throwError(err)) - ); - } -} diff --git a/Sample-01/src/app/components/nav-bar/nav-bar.component.html b/Sample-01/src/app/components/nav-bar/nav-bar.component.html index aed1241e..a0099552 100644 --- a/Sample-01/src/app/components/nav-bar/nav-bar.component.html +++ b/Sample-01/src/app/components/nav-bar/nav-bar.component.html @@ -24,26 +24,33 @@ - -