@jjmhalew/angular-jwt 21.0.0 → 21.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+ ![Helper library for handling JWTs in Angular applications](https://cdn.auth0.com/website/sdks/banners/angular-jwt-banner.png)
2
+
3
+ ![Release](https://img.shields.io/github/v/release/jjmhalew/angular-jwt)
4
+ [![codecov](https://codecov.io/gh/jjmhalew/angular-jwt/branch/main/graph/badge.svg?token=wnauXldcdE)](https://codecov.io/gh/jjmhalew/angular-jwt)
5
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/auth0/angular2-jwt)
6
+ ![Downloads](https://img.shields.io/npm/dw/@jjmhalew/angular-jwt)
7
+ [![License](https://img.shields.io/:license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
8
+ [![CircleCI](https://img.shields.io/circleci/build/github/jjmhalew/angular-jwt)](https://circleci.com/gh/jjmhalew/angular-jwt)
9
+
10
+ :books: [Documentation](#documentation) - :rocket: [Getting Started](#getting-started) - :computer: [API Reference](#api-reference) - :speech_balloon: [Feedback](#feedback)
11
+
12
+ ## Documentation
13
+
14
+ - [Examples](https://github.com/jjmhalew/angular-jwt/blob/main/EXAMPLES.md) - code samples for common angular-jwt authentication scenario's.
15
+ - [Docs site](https://www.auth0.com/docs) - explore our docs site and learn more about Auth0.
16
+
17
+ This library provides an `HttpInterceptor` which automatically attaches a [JSON Web Token](https://jwt.io) to `HttpClient` requests.
18
+
19
+ 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.
20
+
21
+ ## Getting started
22
+ ### Requirements
23
+ This project only supports the [actively supported versions of Angular as stated in the Angular documentation](https://angular.io/guide/releases#actively-supported-versions). Whilst other versions might be compatible they are not actively supported
24
+
25
+ ### Installation
26
+
27
+ ```bash
28
+ # installation with npm
29
+ npm install @jjmhalew/angular-jwt
30
+
31
+ # installation with yarn
32
+ yarn add @jjmhalew/angular-jwt
33
+ ```
34
+
35
+ ## Configure the SDK
36
+
37
+ Import `provideJwtConfig` and add it to your imports list. Provide a `tokenGetter` function. You must also add any domains to the `allowedDomains`, that you want to make requests to by specifying an `allowedDomains` array.
38
+
39
+ Be sure to import the `HttpClientModule` as well.
40
+
41
+ ```ts
42
+ import { JwtModule } from "@jjmhalew/angular-jwt";
43
+ import { provideHttpClient, withInterceptorsFromDi } from "@angular/common/http";
44
+
45
+ export function tokenGetter() {
46
+ return localStorage.getItem("access_token");
47
+ }
48
+
49
+ export const appConfig: ApplicationConfig = {
50
+ providers: [
51
+ // ...
52
+ provideHttpClient(withInterceptorsFromDi()),
53
+ provideJwtConfig({
54
+ tokenGetter: tokenGetter,
55
+ allowedDomains: ["example.com"],
56
+ disallowedRoutes: ["http://example.com/examplebadroute/"],
57
+ }),
58
+ ],
59
+ };
60
+ ```
61
+
62
+ Any requests sent using Angular's `HttpClient` will automatically have a token attached as an `Authorization` header.
63
+
64
+ ```ts
65
+ import { HttpClient } from "@angular/common/http";
66
+ import { inject } from "@angular/core";
67
+
68
+ export class AppComponent {
69
+ public http = inject(HttpClient);
70
+
71
+ ping() {
72
+ this.http.get("http://example.com/api/things").subscribe(
73
+ (data) => console.log(data),
74
+ (err) => console.log(err)
75
+ );
76
+ }
77
+ }
78
+ ```
79
+ - In order to use the SDK's interceptor, `provideHttpClient` needs to be called with `withInterceptorsFromDi`.
80
+
81
+
82
+ ## API reference
83
+ Read [our API reference](https://github.com/jjmhalew/angular-jwt/blob/main/API.md) to get a better understanding on how to use this SDK.
84
+
85
+ ## Feedback
86
+
87
+ ### Contributing
88
+
89
+ We appreciate feedback and contribution to this repo! Before you get started, please see the following:
90
+
91
+ - [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
92
+ - [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
93
+ - [This repo's contribution guide](https://github.com/jjmhalew/angular-jwt/blob/main/CONTRIBUTING.md)
94
+ ### Raise an issue
95
+
96
+ To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/jjmhalew/angular-jwt/issues).
97
+
98
+ ### Vulnerability Reporting
99
+
100
+ Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/responsible-disclosure-policy) details the procedure for disclosing security issues.
101
+
102
+ ---
103
+
104
+ <p align="center">
105
+ <picture>
106
+ <source media="(prefers-color-scheme: light)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
107
+ <source media="(prefers-color-scheme: dark)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png" width="150">
108
+ <img alt="Auth0 Logo" src="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
109
+ </picture>
110
+ </p>
111
+ <p align="center">Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href="https://auth0.com/why-auth0">Why Auth0?</a></p>
112
+ <p align="center">
113
+ This project is licensed under the MIT license. See the <a href="https://github.com/jjmhalew/angular-jwt/blob/main/LICENSE"> LICENSE</a> file for more info.</p>
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@jjmhalew/angular-jwt",
3
- "version": "21.0.0",
3
+ "version": "21.0.1",
4
4
  "description": "JSON Web Token helper library for Angular",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/jjmhalew/angular-jwt.git"
8
+ "url": "git+https://github.com/jjmhalew/angular-jwt"
9
9
  },
10
10
  "author": "Jim Halewijn",
11
11
  "license": "MIT",
@@ -38,4 +38,4 @@
38
38
  }
39
39
  },
40
40
  "sideEffects": false
41
- }
41
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jjmhalew-angular-jwt.d.ts","sources":["../../../projects/angular-jwt/src/lib/jwthelper.service.ts","../../../projects/angular-jwt/src/lib/jwt.interceptor.ts","../../../projects/angular-jwt/src/lib/jwtoptions.token.ts","../../../projects/angular-jwt/src/lib/provide-jwt-config.ts"],"sourcesContent":[null,null,null,null],"names":[],"mappings":";;;;;AAKA,cAAA,gBAAA;;AAImC;AAI1B;AAsBP;AA8BA;;AAWO,gCAAA,OAAA,WAAA,OAAA;AACA,uCAAA,OAAA;AASP;AAqBO,2CAAA,IAAA;AACA,kCAAA,OAAA,WAAA,OAAA,CAAA,IAAA;;AAUP;AAcO,yEAAA,OAAA;AACA;AACA,0BAAA,OAAA,mCAAA,OAAA;AAYP;AAcO,8BAAA,QAAA,gCAAA,WAAA;;;AAOR;;ACxJD,cAAA,cAAA,YAAA,eAAA;AAesB;;;AAXpB,qCAAA,WAAA;AACA,oBAAA,KAAA,UAAA,MAAA;AACA,sBAAA,KAAA,UAAA,MAAA;;;;AAKO,eAAA,gBAAA;AAGgB,uCAAA,QAAA;;;;AAmFhB,uBAAA,WAAA,aAAA,WAAA,GAAA,UAAA,CAAA,SAAA;;;AAYR;;AC1HD,cAAA,WAAA,EAAA,cAAA;;;;;ACOE,sCAAA,WAAA;;;;;AAKD;;;;AAKA;AAED;;;;;;;AAOG;AACH,cAAA,gBAAA,WAAA,SAAA,KAAA,oBAAA;;;;"}