From aea16f1bd93e0c42d15b39caf9126c719efeb128 Mon Sep 17 00:00:00 2001 From: Vatsaev Aslan Date: Fri, 7 Feb 2020 17:59:03 +0100 Subject: [PATCH] fix: restore documents --- .github/ISSUE_TEMPLATE.md | 12 +++++ .github/PULL_REQUEST_TEMPLATE.md | 2 + CHANGELOG.md | 5 -- CONTRIBUTING.md | 4 ++ LICENSE | 2 +- README.md | 56 ++++++++++++++++----- package.json | 2 +- projects/angular-jwt/tsconfig.lib.prod.json | 6 +++ 8 files changed, 69 insertions(+), 20 deletions(-) create mode 100644 projects/angular-jwt/tsconfig.lib.prod.json diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 64facbfb..1c40513f 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,5 +1,7 @@ In order to efficiently and accurately address your issue or feature request, please read through the template below and answer all relevant questions. Your additional work here is greatly appreciated and will help us respond as quickly as possible. Please delete any sections or questions below that do not pertain to this request. +For general support or usage questions, please use the [Auth0 Community](https://community.auth0.com/) or [Auth0 Support](https://support.auth0.com). + ### Description Description of the bug or feature request and why it's a problem. Consider including: @@ -7,6 +9,16 @@ Description of the bug or feature request and why it's a problem. Consider inclu - The use case or overall problem you're trying to solve - Information about when the problem started +### Prerequisites + +- [ ] I have checked the [README documentation](https://github.com/auth0/angular2-jwt/blob/master/README.md). +- [ ] I have checked the [Auth0 Community](https://community.auth0.com/) for related posts. +- [ ] I have checked for related or duplicate [Issues](https://github.com/auth0/angular2-jwt +/issues) and [PRs](https://github.com/auth0/angular2-jwt +/pulls). +- [ ] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md). +- [ ] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md). +- [ ] I am reporting this to the correct repository. ### Environment diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 65de1b64..c55436fe 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -19,5 +19,7 @@ Please include relevant links supporting this change such as a: ### Checklist +- [ ] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md) +- [ ] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md) - [ ] All code quality tools/guidelines in the [CONTRIBUTING documentation](../CONTRIBUTING.md) have been run/followed - [ ] All relevant assets have been compiled as directed in the [CONTRIBUTING documentation](../CONTRIBUTING.md), if applicable diff --git a/CHANGELOG.md b/CHANGELOG.md index a5d04444..66886749 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,5 @@ # Change log -## Version [4.0.3](https://github.com/auth0/avatsaev/tags/v4.0.3) (2020-02-70) - -- Angular 9 compatibility -- Angular Ivy compatibility - ## Version [3.0.1](https://github.com/auth0/angular2-jwt/tags/v3.0.1) (2019-10-28) [Full Changelog](https://github.com/auth0/angular2-jwt/compare/3.0.0..3.0.1) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6329defb..47049f27 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,9 +1,13 @@ +# Contribution + +Please read [Auth0's contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md). ## Documentation - PR for docs site update, if needed - Code-level documentation expectations - 100% documentation coverage for PRs + - Include links to relevant Auth0 doc pages ## Code quality tools diff --git a/LICENSE b/LICENSE index 6e25d968..6e4df099 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020 Aslan Vatsaev +Copyright (c) 2017 Auth0 Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 73d9a80d..f14becd9 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,25 @@ -# @avatsaev/angular-jwt +# @auth0/angular-jwt -[![npm version](https://badge.fury.io/js/%40avatsaev%2Fangular-jwt.svg)](https://badge.fury.io/js/%40avatsaev%2Fangular-jwt) +[![npm version](https://badge.fury.io/js/%40auth0%2Fangular-jwt.svg)](https://badge.fury.io/js/%40auth0%2Fangular-jwt) + +### **NOTE:** This library is now at version 3 and is published on npm as `@auth0/angular-jwt`. If you're looking for the pre-v1.0 version of this library, it can be found in the `pre-v1.0` branch and on npm as `angular2-jwt`. + +**@auth0/angular-jwt v3 is to be used with Angular v6+ and RxJS v6+. For Angular v4.3 to v5+, use @auth0/angular-jwt v1** + +This library provides an `HttpInterceptor` which automatically attaches a [JSON Web Token](https://jwt.io) to `HttpClient` requests. + +This library does not have any functionality for (or opinion about) implementing user authentication and retrieving JWTs to begin with. Those details will vary depending on your setup, but in most cases, you will use a regular HTTP request to authenticate your users and then save their JWTs in local storage or in a cookie if successful. + +> **Note:** This library can only be used with Angular 4.3 and higher because it relies on an `HttpInterceptor` from Angular's `HttpClient`. This feature is not available on lower versions. ## Installation ```bash # installation with npm -npm install @avatsaev/angular-jwt +npm install @auth0/angular-jwt # installation with yarn -yarn add @avatsaev/angular-jwt +yarn add @auth0/angular-jwt ``` ## Usage: Standalone @@ -19,7 +29,7 @@ injectable features, you can simply create an instance of the utility and use it directly: ```ts -import { JwtHelperService } from "@avatsaev/angular-jwt"; +import { JwtHelperService } from "@auth0/angular-jwt"; const helper = new JwtHelperService(); @@ -35,7 +45,7 @@ Import the `JwtModule` module and add it to your imports list. Call the `forRoot Be sure to import the `HttpClientModule` as well. ```ts -import { JwtModule } from "@avatsaev/angular-jwt"; +import { JwtModule } from "@auth0/angular-jwt"; import { HttpClientModule } from "@angular/common/http"; export function tokenGetter() { @@ -97,7 +107,7 @@ JwtModule.forRoot({ Authenticated requests should only be sent to domains you know and trust. Many applications make requests to APIs from multiple domains, some of which are not controlled by the developer. Since there is no way to know what the API being called will do with the information contained in the request, it is best to not send the user's token to all APIs in a blind fashion. -List any domains you wish to allow authenticated requests to be sent to by specifying them in the the `whitelistedDomains` array. **Note that standard http port 80 and https port 443 requests don't require a port to be specified. A port is only required in the whitelisted host name if you are authenticating against a non-standard port e.g. localhost:3001** +List any domains you wish to allow authenticated requests to be sent to by specifying them in the `whitelistedDomains` array. **Note that standard http port 80 and https port 443 requests don't require a port to be specified. A port is only required in the whitelisted host name if you are authenticating against a non-standard port e.g. localhost:3001** ```ts // ... @@ -212,7 +222,7 @@ Import the `JWT_OPTIONS` `InjectionToken` so that you can instruct it to use you Create a factory function and specify the options as you normally would if you were using `JwtModule.forRoot` directly. If you need to use a service in the function, list it as a parameter in the function and pass it in the `deps` array when you provide the function. ```ts -import { JwtModule, JWT_OPTIONS } from '@avatsaev/angular-jwt'; +import { JwtModule, JWT_OPTIONS } from '@auth0/angular-jwt'; import { TokenService } from './app.tokenservice'; // ... @@ -249,7 +259,7 @@ NOTE: If a `jwtOptionsFactory` is defined, then `config` is ignored. _Both confi The custom factory function approach described above can be used to get a token asynchronously with Ionic's `Storage`. ```ts -import { JwtModule, JWT_OPTIONS } from '@avatsaev/angular-jwt'; +import { JwtModule, JWT_OPTIONS } from '@auth0/angular-jwt'; import { Storage } from '@ionic/storage'; export function jwtOptionsFactory(storage) { @@ -285,7 +295,7 @@ This service contains helper functions: ## isTokenExpired (old tokenNotExpired function) ``` -import { JwtHelperService } from '@avatsaev/angular-jwt'; +import { JwtHelperService } from '@auth0/angular-jwt'; // ... constructor(public jwtHelper: JwtHelperService) {} @@ -297,7 +307,7 @@ console.log(this.jwtHelper.isTokenExpired()); // true or false ## getTokenExpirationDate ``` -import { JwtHelperService } from '@avatsaev/angular-jwt'; +import { JwtHelperService } from '@auth0/angular-jwt'; // ... constructor(public jwtHelper: JwtHelperService) {} @@ -309,7 +319,7 @@ console.log(this.jwtHelper.getTokenExpirationDate()); // date ## decodeToken ``` -import { JwtHelperService } from '@avatsaev/angular-jwt'; +import { JwtHelperService } from '@auth0/angular-jwt'; // ... constructor(public jwtHelper: JwtHelperService) {} @@ -318,9 +328,29 @@ console.log(this.jwtHelper.decodeToken(token)); // token } ``` +## What is Auth0? + +Auth0 helps you to: + +- Add authentication with [multiple authentication sources](https://auth0.com/docs/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://auth0.com/docs/connections/database/custom-db)**. +- Add support for **[linking different user accounts](https://auth0.com/docs/link-accounts)** with the same user. +- Support for generating signed [Json Web Tokens](https://auth0.com/docs/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://auth0.com/docs/rules/current). + +## 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 -[Aslan Vatsaev](https://github.com/avatsaev) +[Auth0](auth0.com) ## License diff --git a/package.json b/package.json index aaacaeb3..0d005361 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "scripts": { "ng": "ng", "start": "ng serve", - "build": "ng build angular-jwt", + "build": "ng build angular-jwt --prod", "postbuild": "cp ./README.md ./CHANGELOG.md ./LICENSE ./dist/angular-jwt/", "test": "ng test", "lint": "ng lint", diff --git a/projects/angular-jwt/tsconfig.lib.prod.json b/projects/angular-jwt/tsconfig.lib.prod.json new file mode 100644 index 00000000..cbae7942 --- /dev/null +++ b/projects/angular-jwt/tsconfig.lib.prod.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.lib.json", + "angularCompilerOptions": { + "enableIvy": false + } +}