@openstax/ts-utils 1.1.32 → 1.1.33
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/dist/cjs/services/authProvider/decryption.d.ts +1 -1
- package/dist/cjs/services/authProvider/index.d.ts +3 -3
- package/dist/cjs/services/authProvider/index.js +5 -5
- package/dist/cjs/tsconfig.withoutspecs.cjs.tsbuildinfo +1 -1
- package/dist/esm/services/authProvider/decryption.d.ts +1 -1
- package/dist/esm/services/authProvider/index.d.ts +3 -3
- package/dist/esm/services/authProvider/index.js +2 -2
- package/dist/esm/tsconfig.withoutspecs.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FetchConfig } from '../../fetch';
|
|
2
|
-
import { Track } from '../../profile';
|
|
3
|
-
import { HttpHeaders } from '../../routing';
|
|
1
|
+
import type { FetchConfig } from '../../fetch';
|
|
2
|
+
import type { Track } from '../../profile';
|
|
3
|
+
import type { HttpHeaders } from '../../routing';
|
|
4
4
|
export interface User {
|
|
5
5
|
id: number;
|
|
6
6
|
name: string;
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getAuthTokenOrCookie = exports.stubAuthProvider = void 0;
|
|
7
7
|
const cookie_1 = __importDefault(require("cookie"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const helpers_1 = require("../../misc/helpers");
|
|
9
|
+
const helpers_2 = require("../../routing/helpers");
|
|
10
10
|
const stubAuthProvider = (user) => ({
|
|
11
11
|
getUser: () => Promise.resolve(user),
|
|
12
12
|
getAuthorizedFetchConfig: () => Promise.resolve(user ? { headers: { Authorization: user.uuid } } : {})
|
|
@@ -14,10 +14,10 @@ const stubAuthProvider = (user) => ({
|
|
|
14
14
|
exports.stubAuthProvider = stubAuthProvider;
|
|
15
15
|
const getAuthTokenOrCookie = (request, cookieName) => {
|
|
16
16
|
var _a;
|
|
17
|
-
const authHeader = (0,
|
|
17
|
+
const authHeader = (0, helpers_2.getHeader)(request.headers, 'authorization');
|
|
18
18
|
const cookieValue = cookie_1.default.parse(((_a = request.cookies) === null || _a === void 0 ? void 0 : _a.join('; ')) || '')[cookieName];
|
|
19
19
|
return authHeader && authHeader.length >= 8 && authHeader.startsWith('Bearer ')
|
|
20
|
-
? (0,
|
|
21
|
-
: (0,
|
|
20
|
+
? (0, helpers_1.tuple)(authHeader.slice(7), { Authorization: authHeader })
|
|
21
|
+
: (0, helpers_1.tuple)(cookieValue, { cookie: cookie_1.default.serialize(cookieName, cookieValue) });
|
|
22
22
|
};
|
|
23
23
|
exports.getAuthTokenOrCookie = getAuthTokenOrCookie;
|