@mostajs/auth 2.5.0 → 2.5.2

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.
@@ -42,10 +42,10 @@
42
42
  * et seules les infos sanitisées {id, email, name, role} reviennent.
43
43
  */
44
44
  export function createRemoteCredentialsProvider(config) {
45
- if (!config.apiKey) {
46
- throw new Error('@mostajs/auth/createRemoteCredentialsProvider: `apiKey` is required. ' +
47
- 'Octonet is M2M every caller (Octocloud, NetClient app, etc.) must identify with its own apikey.');
48
- }
45
+ // Validation lazy : on ne throw PAS au module-load (next build appelle
46
+ // chaque route.js pour collecter les metadata sans avoir les env vars
47
+ // de runtime). On valide au moment du authorize() runtime fail fast
48
+ // avec un message clair, build clean.
49
49
  if (!config.verifyEndpoint) {
50
50
  throw new Error('@mostajs/auth/createRemoteCredentialsProvider: `verifyEndpoint` is required.');
51
51
  }
@@ -61,6 +61,13 @@ export function createRemoteCredentialsProvider(config) {
61
61
  async authorize(credentials) {
62
62
  if (!credentials?.email || !credentials?.password)
63
63
  return null;
64
+ if (!config.apiKey) {
65
+ // Vérification au runtime, après le build. Aucune session ne peut
66
+ // être ouverte sans apikey — Octonet est M2M.
67
+ console.error('@mostajs/auth/createRemoteCredentialsProvider: `apiKey` is missing at runtime. ' +
68
+ 'Set OCTONET_PORTAL_API_KEY (or equivalent) in env.');
69
+ return null;
70
+ }
64
71
  const headers = {
65
72
  'Content-Type': 'application/json',
66
73
  'X-API-Key': config.apiKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostajs/auth",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "description": "Authentication — NextAuth, password hashing, session management",
5
5
  "author": "Dr Hamid MADANI <drmdh@msn.com>",
6
6
  "license": "AGPL-3.0-or-later",
@@ -88,6 +88,16 @@
88
88
  "import": "./dist/lib/credentials-provider.js",
89
89
  "default": "./dist/lib/credentials-provider.js"
90
90
  },
91
+ "./lib/credentials-verify": {
92
+ "types": "./dist/lib/credentials-verify.d.ts",
93
+ "import": "./dist/lib/credentials-verify.js",
94
+ "default": "./dist/lib/credentials-verify.js"
95
+ },
96
+ "./lib/remote-credentials-provider": {
97
+ "types": "./dist/lib/remote-credentials-provider.d.ts",
98
+ "import": "./dist/lib/remote-credentials-provider.js",
99
+ "default": "./dist/lib/remote-credentials-provider.js"
100
+ },
91
101
  "./lib/check-request": {
92
102
  "types": "./dist/lib/check-request.d.ts",
93
103
  "import": "./dist/lib/check-request.js",