@fern-api/venus-api-sdk 0.0.20-2-gc6b8e16 → 0.0.20-3-g18f7cfd
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/core/auth/BasicAuth.js +7 -5
- package/package.json +1 -4
package/core/auth/BasicAuth.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BasicAuth = void 0;
|
|
4
|
-
const basic_auth_1 = require("basic-auth");
|
|
5
4
|
const js_base64_1 = require("js-base64");
|
|
5
|
+
const BASIC_AUTH_HEADER_PREFIX = /^Basic /i;
|
|
6
6
|
exports.BasicAuth = {
|
|
7
7
|
toAuthorizationHeader: (basicAuth) => {
|
|
8
8
|
if (basicAuth == null) {
|
|
@@ -12,13 +12,15 @@ exports.BasicAuth = {
|
|
|
12
12
|
return `Basic ${token}`;
|
|
13
13
|
},
|
|
14
14
|
fromAuthorizationHeader: (header) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, "");
|
|
16
|
+
const decoded = js_base64_1.Base64.decode(credentials);
|
|
17
|
+
const [username, password] = decoded.split(":", 2);
|
|
18
|
+
if (username == null || password == null) {
|
|
17
19
|
throw new Error("Invalid basic auth");
|
|
18
20
|
}
|
|
19
21
|
return {
|
|
20
|
-
username
|
|
21
|
-
password
|
|
22
|
+
username,
|
|
23
|
+
password,
|
|
22
24
|
};
|
|
23
25
|
},
|
|
24
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fern-api/venus-api-sdk",
|
|
3
|
-
"version": "0.0.20-
|
|
3
|
+
"version": "0.0.20-3-g18f7cfd",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"Client.d.ts",
|
|
@@ -21,10 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"url-join": "4.0.1",
|
|
23
23
|
"@types/url-join": "4.0.1",
|
|
24
|
-
"basic-auth": "2.0.1",
|
|
25
|
-
"@types/basic-auth": "1.1.3",
|
|
26
24
|
"js-base64": "3.7.2",
|
|
27
|
-
"buffer": "6.0.3",
|
|
28
25
|
"axios": "0.27.2"
|
|
29
26
|
},
|
|
30
27
|
"devDependencies": {
|