@lwrjs/auth-middleware 0.11.0-alpha.8 → 0.11.0

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.
@@ -1,9 +1,25 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
2
7
  var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
3
8
  var __export = (target, all) => {
4
9
  for (var name in all)
5
10
  __defProp(target, name, {get: all[name], enumerable: true});
6
11
  };
12
+ var __exportStar = (target, module2, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && key !== "default")
16
+ __defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
17
+ }
18
+ return target;
19
+ };
20
+ var __toModule = (module2) => {
21
+ return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
22
+ };
7
23
 
8
24
  // packages/@lwrjs/auth-middleware/src/utils.ts
9
25
  __markAsModule(exports);
@@ -22,6 +38,7 @@ __export(exports, {
22
38
  getPlatformWebServerEnvVars: () => getPlatformWebServerEnvVars,
23
39
  sanitizeAppPath: () => sanitizeAppPath
24
40
  });
41
+ var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
25
42
  var MESSAGE_PREFIX = "Web Server OAuth Middleware - ";
26
43
  var LOGIN_ENDPOINT = "/login";
27
44
  var REVOKE_ENDPOINT = "/revoke";
@@ -52,7 +69,7 @@ function generateStateString() {
52
69
  function sanitizeAppPath(app_path) {
53
70
  let appPath = app_path ? decodeURIComponent(app_path) : `/`;
54
71
  if (!appPath.startsWith("/")) {
55
- console.warn('The "app_path" parameter must be a relative path staring with "/". Defaulting to "app_path" = "/".');
72
+ import_diagnostics.logger.warn('The "app_path" parameter must be a relative path starting with "/". Defaulting to "app_path" = "/".');
56
73
  appPath = "/";
57
74
  }
58
75
  return appPath;
@@ -27,6 +27,7 @@ __export(exports, {
27
27
  platformWebServerAuthMiddleware: () => platformWebServerAuthMiddleware,
28
28
  stateMap: () => stateMap
29
29
  });
30
+ var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
30
31
  var import_node_fetch = __toModule(require("node-fetch"));
31
32
  var import_utils = __toModule(require("./utils.cjs"));
32
33
  var stateMap = new Map();
@@ -72,7 +73,7 @@ function platformWebServerAuthMiddleware(server, {proxyEndpoint = import_utils.P
72
73
  res.sendStatus(302);
73
74
  } else {
74
75
  const errorMsg = `${import_utils.MESSAGE_PREFIX}could not authenticate. Error body: ${JSON.stringify(data)}`;
75
- console.error(errorMsg, data);
76
+ import_diagnostics.logger.error(errorMsg, data);
76
77
  res.status(response.status).send(errorMsg);
77
78
  }
78
79
  });
package/build/es/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { logger } from '@lwrjs/diagnostics';
1
2
  export const MESSAGE_PREFIX = 'Web Server OAuth Middleware - ';
2
3
  export const LOGIN_ENDPOINT = '/login';
3
4
  export const REVOKE_ENDPOINT = '/revoke';
@@ -35,7 +36,7 @@ export function generateStateString() {
35
36
  export function sanitizeAppPath(app_path) {
36
37
  let appPath = app_path ? decodeURIComponent(app_path) : `/`;
37
38
  if (!appPath.startsWith('/')) {
38
- console.warn('The "app_path" parameter must be a relative path staring with "/". Defaulting to "app_path" = "/".');
39
+ logger.warn('The "app_path" parameter must be a relative path starting with "/". Defaulting to "app_path" = "/".');
39
40
  appPath = '/';
40
41
  }
41
42
  return appPath;
@@ -1,3 +1,4 @@
1
+ import { logger } from '@lwrjs/diagnostics';
1
2
  import fetch from 'node-fetch';
2
3
  import { COOKIE_NAME, DEFAULT_LOGIN_SERVER, LOGIN_ENDPOINT, MESSAGE_PREFIX, PROXY_ENDPOINT, REDIRECT_ENDPOINT, REVOKE_ENDPOINT, buildProxyRequest, buildRedirectUrl, generateStateString, sanitizeAppPath, getOauthInfoFromCookie, getPlatformWebServerEnvVars, } from './utils.js';
3
4
  export const stateMap = new Map();
@@ -72,7 +73,7 @@ export function platformWebServerAuthMiddleware(server, { proxyEndpoint = PROXY_
72
73
  else {
73
74
  // Print and forward the error JSON to the client
74
75
  const errorMsg = `${MESSAGE_PREFIX}could not authenticate. Error body: ${JSON.stringify(data)}`;
75
- console.error(errorMsg, data);
76
+ logger.error(errorMsg, data);
76
77
  res.status(response.status).send(errorMsg);
77
78
  }
78
79
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.11.0-alpha.8",
7
+ "version": "0.11.0",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -30,15 +30,16 @@
30
30
  "build/**/*.d.ts"
31
31
  ],
32
32
  "dependencies": {
33
+ "@lwrjs/diagnostics": "0.11.0",
33
34
  "node-fetch": "^2.6.8"
34
35
  },
35
36
  "devDependencies": {
36
- "@lwrjs/server": "0.11.0-alpha.8",
37
- "@lwrjs/types": "0.11.0-alpha.8",
37
+ "@lwrjs/server": "0.11.0",
38
+ "@lwrjs/types": "0.11.0",
38
39
  "@types/node-fetch": "^2.5.12"
39
40
  },
40
41
  "engines": {
41
42
  "node": ">=16.0.0"
42
43
  },
43
- "gitHead": "bba3cfa996e84ee702f287e7e7b6361b807434db"
44
+ "gitHead": "fbc883ea90a12672ce6f1adc2201144fda8762bd"
44
45
  }