@lwrjs/auth-middleware 0.12.0-alpha.7 → 0.12.0-alpha.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.
@@ -28,7 +28,6 @@ __export(exports, {
28
28
  stateMap: () => stateMap
29
29
  });
30
30
  var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
31
- var import_node_fetch = __toModule(require("node-fetch"));
32
31
  var import_utils = __toModule(require("./utils.cjs"));
33
32
  var stateMap = new Map();
34
33
  function platformWebServerAuthMiddleware(server, {proxyEndpoint = import_utils.PROXY_ENDPOINT} = {}) {
@@ -56,7 +55,7 @@ function platformWebServerAuthMiddleware(server, {proxyEndpoint = import_utils.P
56
55
  }
57
56
  stateMap.delete(state);
58
57
  const {appPath, loginServer, redirectUri} = loginState;
59
- const response = await (0, import_node_fetch.default)(`${loginServer}/services/oauth2/token`, {
58
+ const response = await fetch(`${loginServer}/services/oauth2/token`, {
60
59
  method: "POST",
61
60
  headers: {"Content-Type": "application/x-www-form-urlencoded", Accept: "application/json"},
62
61
  body: `grant_type=authorization_code&code=${code}&client_id=${clientKey}&client_secret=${clientSecret}&redirect_uri=${encodeURIComponent(redirectUri)}`
@@ -81,7 +80,7 @@ function platformWebServerAuthMiddleware(server, {proxyEndpoint = import_utils.P
81
80
  const oauthInfo = (0, import_utils.getOauthInfoFromCookie)(req);
82
81
  if (oauthInfo) {
83
82
  const {url, options} = (0, import_utils.buildProxyRequest)(req, oauthInfo, req.headers);
84
- const proxyRes = await (0, import_node_fetch.default)(url, options);
83
+ const proxyRes = await fetch(url, options);
85
84
  const contentType = proxyRes.headers.get("Content-Type") || "";
86
85
  const data = await (contentType.includes("application/json") ? proxyRes.json() : proxyRes.text());
87
86
  res.status(proxyRes.status).send(data);
@@ -96,7 +95,7 @@ function platformWebServerAuthMiddleware(server, {proxyEndpoint = import_utils.P
96
95
  if (oauthInfo) {
97
96
  const {access_token, instance_url} = oauthInfo;
98
97
  const url = `${instance_url}/services/oauth2/revoke?token=${access_token}`;
99
- const proxyRes = await (0, import_node_fetch.default)(url);
98
+ const proxyRes = await fetch(url);
100
99
  const contentType = proxyRes.headers.get("Content-Type") || "";
101
100
  const data = await (contentType.includes("application/json") ? proxyRes.json() : proxyRes.text());
102
101
  returnStatus = proxyRes.status;
@@ -1,4 +1,3 @@
1
- import type { RequestInit } from 'node-fetch';
2
1
  export interface PlatformWebServerInput {
3
2
  /** "Consumer Key" from the Connected App */
4
3
  clientKey: string;
@@ -1,5 +1,4 @@
1
1
  import { logger } from '@lwrjs/diagnostics';
2
- import fetch from 'node-fetch';
3
2
  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';
4
3
  export const stateMap = new Map();
5
4
  /**
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.12.0-alpha.7",
7
+ "version": "0.12.0-alpha.8",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -30,16 +30,14 @@
30
30
  "build/**/*.d.ts"
31
31
  ],
32
32
  "dependencies": {
33
- "@lwrjs/diagnostics": "0.12.0-alpha.7",
34
- "node-fetch": "^2.6.8"
33
+ "@lwrjs/diagnostics": "0.12.0-alpha.8"
35
34
  },
36
35
  "devDependencies": {
37
- "@lwrjs/server": "0.12.0-alpha.7",
38
- "@lwrjs/types": "0.12.0-alpha.7",
39
- "@types/node-fetch": "^2.5.12"
36
+ "@lwrjs/server": "0.12.0-alpha.8",
37
+ "@lwrjs/types": "0.12.0-alpha.8"
40
38
  },
41
39
  "engines": {
42
40
  "node": ">=18.0.0"
43
41
  },
44
- "gitHead": "c60963c89e621d2e8af3389b0e075ded2f4bc810"
42
+ "gitHead": "fa2d2189d7309adfb47f7b125616d26cb721ed6f"
45
43
  }