@lwrjs/auth-middleware 0.12.0-alpha.1 → 0.12.0-alpha.10
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 +1 -1
- package/build/cjs/web-server.cjs +3 -4
- package/build/es/types.d.ts +0 -1
- package/build/es/web-server.js +0 -1
- package/package.json +6 -8
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ platformWebServerAuthMiddleware(lwrApp.getServer()); // Pass in the generic LWR
|
|
|
27
27
|
|
|
28
28
|
Start the LWR server, and pass the [Connected App information](#variables) in using environment variables:
|
|
29
29
|
|
|
30
|
-
```
|
|
30
|
+
```bash
|
|
31
31
|
CLIENT_KEY=abc.123 CLIENT_SECRET=****** yarn start
|
|
32
32
|
```
|
|
33
33
|
|
package/build/cjs/web-server.cjs
CHANGED
|
@@ -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 (
|
|
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 (
|
|
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 (
|
|
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;
|
package/build/es/types.d.ts
CHANGED
package/build/es/web-server.js
CHANGED
|
@@ -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
|
+
"version": "0.12.0-alpha.10",
|
|
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.
|
|
34
|
-
"node-fetch": "^2.6.8"
|
|
33
|
+
"@lwrjs/diagnostics": "0.12.0-alpha.10"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
|
-
"@lwrjs/server": "0.12.0-alpha.
|
|
38
|
-
"@lwrjs/types": "0.12.0-alpha.
|
|
39
|
-
"@types/node-fetch": "^2.5.12"
|
|
36
|
+
"@lwrjs/server": "0.12.0-alpha.10",
|
|
37
|
+
"@lwrjs/types": "0.12.0-alpha.10"
|
|
40
38
|
},
|
|
41
39
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
40
|
+
"node": ">=18.0.0"
|
|
43
41
|
},
|
|
44
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "36759959f624aa40d371dc9ee698dd472813f19c"
|
|
45
43
|
}
|