@volontariapp/auth 3.3.6 → 3.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +56 -0
  3. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.3.8
4
+
5
+ ### Patch Changes
6
+
7
+ - README bump
8
+
9
+ - Updated dependencies []:
10
+ - @volontariapp/errors@0.6.1
11
+ - @volontariapp/errors-nest@0.13.1
12
+ - @volontariapp/logger@0.2.6
13
+ - @volontariapp/shared@0.8.1
14
+
15
+ ## 3.3.7
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies []:
20
+ - @volontariapp/shared@0.8.0
21
+
3
22
  ## 3.3.6
4
23
 
5
24
  ### Patch Changes
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # @volontariapp/auth
2
+
3
+ ## Overview
4
+ Package `auth` fournissant des utilitaires d'authentification agnostiques en pur Node.js/TypeScript.
5
+ Contrairement aux solutions fortement couplées, ce package est indépendant de tout framework (notamment NestJS). Cette agnosie permet d'embarquer des fonctions de vérification JWT dans des environnements d'exécution légers (Scripts, Workers sans NestJS, ou API Gateway).
6
+
7
+ ## Flux d'Authentification
8
+
9
+ ```mermaid
10
+ sequenceDiagram
11
+ participant Client
12
+ participant AuthPkg as @volontariapp/auth
13
+ participant Provider as IDP (ex: Cognito/Firebase)
14
+
15
+ Client->>AuthPkg: Fournit le Bearer Token JWT
16
+ AuthPkg->>AuthPkg: Parsing du Header et validation structurelle
17
+ AuthPkg->>Provider: Validation de la signature (JWKS)
18
+ alt Signature invalide ou Expiré
19
+ AuthPkg-->>Client: Throw UnauthorizedError
20
+ else Valide
21
+ AuthPkg-->>Client: Retourne le Payload décodé (ID, Roles)
22
+ end
23
+ ```
24
+
25
+ ## Key Features
26
+ - **Validation JWT** : Fonctions robustes d'analyse, de décodage et de vérification cryptographique des jetons d'accès.
27
+ - **Role-Based Access Control (RBAC)** : Utilitaires pour vérifier l'appartenance à un rôle dans les claims du token.
28
+ - **Agnostique** : Aucune dépendance à `@nestjs/common` ni au contexte d'exécution HTTP.
29
+
30
+ ## Exemple d'Utilisation
31
+
32
+ L'utilisation se fait de manière fonctionnelle ou via instanciation de service autonome.
33
+
34
+ ```typescript
35
+ import { JwtVerifier } from '@volontariapp/auth';
36
+
37
+ const verifier = new JwtVerifier({
38
+ jwksUri: 'https://idp.example.com/.well-known/jwks.json',
39
+ issuer: 'https://idp.example.com',
40
+ audience: 'volontariapp-api'
41
+ });
42
+
43
+ async function authenticateRequest(token: string) {
44
+ try {
45
+ const payload = await verifier.verify(token);
46
+
47
+ if (!payload.roles.includes('ADMIN')) {
48
+ throw new Error('Forbidden: Insufficient privileges');
49
+ }
50
+
51
+ return payload.userId;
52
+ } catch (error) {
53
+ throw new Error('Unauthorized');
54
+ }
55
+ }
56
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volontariapp/auth",
3
- "version": "3.3.6",
3
+ "version": "3.3.8",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -35,10 +35,10 @@
35
35
  "test:watch": "node --experimental-vm-modules $(yarn bin jest) --watch"
36
36
  },
37
37
  "dependencies": {
38
- "@volontariapp/errors": "0.6.0",
39
- "@volontariapp/errors-nest": "0.13.0",
40
- "@volontariapp/logger": "0.2.5",
41
- "@volontariapp/shared": "0.7.1",
38
+ "@volontariapp/errors": "0.6.1",
39
+ "@volontariapp/errors-nest": "0.13.1",
40
+ "@volontariapp/logger": "0.2.6",
41
+ "@volontariapp/shared": "0.8.1",
42
42
  "jose": "^6.2.2",
43
43
  "reflect-metadata": "^0.2.2",
44
44
  "rxjs": "^7.8.1"
@@ -62,7 +62,7 @@
62
62
  "@types/jest": "^30.0.0",
63
63
  "@types/node": "^24.1.0",
64
64
  "@types/supertest": "^7.2.0",
65
- "@volontariapp/testing": "1.0.1",
65
+ "@volontariapp/testing": "1.0.2",
66
66
  "jest": "^30.3.0",
67
67
  "supertest": "^7.2.2",
68
68
  "ts-jest": "^29.4.9",