@newskit-render/api 0.4.0 → 0.6.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.
- package/CHANGELOG.md +38 -0
- package/dist/{createApolloClient → apolloClient}/createApolloClient.d.ts +0 -0
- package/dist/{createApolloClient → apolloClient}/createApolloClient.js +15 -15
- package/dist/apolloClient/createApolloClient.js.map +1 -0
- package/dist/{createApolloClient → apolloClient}/createClient.d.ts +0 -0
- package/dist/{createApolloClient → apolloClient}/createClient.js +0 -0
- package/dist/apolloClient/createClient.js.map +1 -0
- package/dist/{createApolloClient → apolloClient}/index.d.ts +0 -0
- package/dist/{createApolloClient → apolloClient}/index.js +0 -0
- package/dist/apolloClient/index.js.map +1 -0
- package/dist/{createApolloClient → apolloClient}/types.d.ts +0 -0
- package/dist/{createApolloClient → apolloClient}/types.js +0 -0
- package/dist/apolloClient/types.js.map +1 -0
- package/dist/helpers/index.d.ts +0 -1
- package/dist/helpers/index.js +0 -1
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/session/index.d.ts +5 -2
- package/dist/helpers/session/index.js +10 -20
- package/dist/helpers/session/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/createApolloClient/createApolloClient.js.map +0 -1
- package/dist/createApolloClient/createClient.js.map +0 -1
- package/dist/createApolloClient/index.js.map +0 -1
- package/dist/createApolloClient/types.js.map +0 -1
- package/dist/helpers/getHeaders/index.d.ts +0 -1
- package/dist/helpers/getHeaders/index.js +0 -75
- package/dist/helpers/getHeaders/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,44 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.6.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/api@0.5.0...@newskit-render/api@0.6.0) (2022-01-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **PPDSR-594:** Add themes to account package ([#538](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/538)) ([e34a53a](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/e34a53a944ae8d1420c27459f1ef5ca3ba4160d0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [0.5.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/api@0.4.2...@newskit-render/api@0.5.0) (2021-12-21)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **PPDSR-559:** Replace go MAIN with newest version ([#536](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/536)) ([ba9a571](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/ba9a571f8c6ce27c93d6d7ad9e35df6f61d627eb))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [0.4.2](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/api@0.4.1...@newskit-render/api@0.4.2) (2021-12-14)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @newskit-render/api
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [0.4.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/api@0.4.0...@newskit-render/api@0.4.1) (2021-11-26)
|
|
37
|
+
|
|
38
|
+
**Note:** Version bump only for package @newskit-render/api
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
6
44
|
# [0.4.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/api@0.3.3...@newskit-render/api@0.4.0) (2021-11-22)
|
|
7
45
|
|
|
8
46
|
|
|
File without changes
|
|
@@ -39,29 +39,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.createApolloClient = void 0;
|
|
40
40
|
var createClient_1 = require("./createClient");
|
|
41
41
|
var helpers_1 = require("../helpers");
|
|
42
|
+
var types_1 = require("./types");
|
|
42
43
|
var createApolloClient = function (client, cookie) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
switch (_c.label) {
|
|
44
|
+
var headers;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
47
|
case 0:
|
|
48
|
-
if (!(client ===
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
if (!(client === types_1.ClientTypes.main)) return [3 /*break*/, 2];
|
|
49
|
+
return [4 /*yield*/, (0, helpers_1.getAcsCookie)(types_1.ClientTypes.main, cookie)];
|
|
50
|
+
case 1:
|
|
51
|
+
headers = _a.sent();
|
|
52
|
+
return [2 /*return*/, (0, createClient_1.createClient)({
|
|
53
|
+
uri: process.env.MAIN_GRAPHQL_URL,
|
|
54
|
+
links: [helpers_1.retryLink, helpers_1.errorLink],
|
|
55
|
+
headers: headers,
|
|
56
|
+
})];
|
|
57
57
|
case 2:
|
|
58
|
-
if (client ===
|
|
58
|
+
if (client === types_1.ClientTypes.nkapi) {
|
|
59
59
|
return [2 /*return*/, (0, createClient_1.createClient)({
|
|
60
60
|
uri: process.env.NEWSKIT_API_ENV_URL,
|
|
61
61
|
headers: cookie
|
|
62
62
|
? {
|
|
63
63
|
'X-API-KEY': process.env.NEWSKIT_API_X_API_KEY,
|
|
64
|
-
'
|
|
64
|
+
'newsuk-acs-cookie': (0, helpers_1.getAcsCookie)(types_1.ClientTypes.nkapi, cookie),
|
|
65
65
|
}
|
|
66
66
|
: {
|
|
67
67
|
'X-API-KEY': process.env.NEWSKIT_API_X_API_KEY,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createApolloClient.js","sourceRoot":"","sources":["../../src/apolloClient/createApolloClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA6C;AAC7C,sCAA+D;AAE/D,iCAA+D;AAExD,IAAM,kBAAkB,GAAG,UAChC,MAAc,EACd,MAAe;;;;;qBAEX,CAAA,MAAM,KAAK,mBAAW,CAAC,IAAI,CAAA,EAA3B,wBAA2B;gBACb,qBAAM,IAAA,sBAAY,EAAC,mBAAW,CAAC,IAAI,EAAE,MAAM,CAAC,EAAA;;gBAAtD,OAAO,GAAG,SAA4C;gBAC5D,sBAAO,IAAA,2BAAY,EAAC;wBAClB,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,gBAA0B;wBAC3C,KAAK,EAAE,CAAC,mBAAS,EAAE,mBAAS,CAAC;wBAC7B,OAAO,SAAA;qBACR,CAAC,EAAA;;gBAEJ,IAAI,MAAM,KAAK,mBAAW,CAAC,KAAK,EAAE;oBAChC,sBAAO,IAAA,2BAAY,EAAC;4BAClB,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAA6B;4BAC9C,OAAO,EAAE,MAAM;gCACb,CAAC,CAAC;oCACE,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;oCAC9C,mBAAmB,EAAE,IAAA,sBAAY,EAAC,mBAAW,CAAC,KAAK,EAAE,MAAM,CAAC;iCAC7D;gCACH,CAAC,CAAC;oCACE,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;iCAC/C;yBACN,CAAC,EAAA;iBACH;gBACD,sBAAO,IAAA,2BAAY,EAAC,MAAM,CAAC,EAAA;;;KAC5B,CAAA;AA1BY,QAAA,kBAAkB,sBA0B9B"}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createClient.js","sourceRoot":"","sources":["../../src/apolloClient/createClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAKuB;AACvB,4DAA+B;AAIxB,IAAM,YAAY,GAAG,UAAO,EAOpB;QANb,oBAAiB,EAAjB,YAAY,mBAAG,EAAE,KAAA,EACjB,OAAO,aAAA,EACP,GAAG,SAAA,EACH,mBAAkB,EAAlB,WAAW,mBAAG,IAAI,KAAA,EAClB,KAAK,WAAA,EACL,IAAI,UAAA;;;;YAEE,UAAU,GAAG,KAAK;gBACtB,CAAC,CAAC,IAAA,aAAI,kCACC,KAAK;oBACR,IAAA,uBAAc,EAAC;wBACb,GAAG,KAAA;wBACH,OAAO,SAAA;wBACP,KAAK,uBAAA;qBACN,CAAC;0BACF;gBACJ,CAAC,CAAC,IAAA,uBAAc,EAAC;oBACb,GAAG,KAAA;oBACH,OAAO,SAAA;oBACP,KAAK,uBAAA;iBACN,CAAC,CAAA;YACN,sBAAO,IAAI,qBAAY,CAAC;oBACtB,OAAO,EAAE,IAAI;oBACb,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,oBAAoB;oBAC3D,OAAO,EAAE,OAAO;oBAChB,KAAK,EAAE,IAAI,sBAAa,CAAC,EAAE,WAAW,aAAA,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;iBAChE,CAAC,EAAA;;;CACH,CAAA;AA7BY,QAAA,YAAY,gBA6BxB"}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/apolloClient/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAoC;AACpC,0CAAuB"}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/apolloClient/types.ts"],"names":[],"mappings":";;;AASA,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,4BAAe,CAAA;IACf,8BAAiB,CAAA;AACnB,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB"}
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
|
@@ -12,6 +12,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./getAccessToken"), exports);
|
|
14
14
|
__exportStar(require("./externalLinks"), exports);
|
|
15
|
-
__exportStar(require("./getHeaders"), exports);
|
|
16
15
|
__exportStar(require("./session"), exports);
|
|
17
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAgC;AAChC,kDAA+B;AAC/B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAgC;AAChC,kDAA+B;AAC/B,4CAAyB"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
1
|
+
import { ClientTypes } from './../../apolloClient/types';
|
|
2
|
+
export declare type MainAcsCookie = {
|
|
3
|
+
Cookie: string;
|
|
4
|
+
} | string;
|
|
5
|
+
export declare const getAcsCookie: (client: ClientTypes, cookieSession?: string | undefined) => MainAcsCookie;
|
|
@@ -3,32 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getAcsCookie = void 0;
|
|
7
|
+
var types_1 = require("./../../apolloClient/types");
|
|
7
8
|
var cookie_1 = __importDefault(require("cookie"));
|
|
8
|
-
var
|
|
9
|
+
var getAcsCookie = function (client, cookieSession) {
|
|
10
|
+
var cookieName = process.env.MAIN_COOKIE_NAME;
|
|
9
11
|
if (cookieSession) {
|
|
10
12
|
var cookies = cookie_1.default.parse(cookieSession);
|
|
11
|
-
var mainSessionCookie = cookies[
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
exports.getMainSession = getMainSession;
|
|
17
|
-
//Parse session from browser in the form of a session_id
|
|
18
|
-
var sessionParser = function (cookieSession) {
|
|
19
|
-
if (cookieSession) {
|
|
20
|
-
var buff = Buffer.from(cookieSession, 'base64');
|
|
21
|
-
var decodedSession = buff.toString('ascii');
|
|
22
|
-
if (decodedSession) {
|
|
23
|
-
try {
|
|
24
|
-
return JSON.parse(decodedSession)['session_id'];
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
console.error('Session cannot be parsed', e);
|
|
13
|
+
var mainSessionCookie = cookies[cookieName];
|
|
14
|
+
if (mainSessionCookie) {
|
|
15
|
+
if (client === types_1.ClientTypes.main) {
|
|
16
|
+
return { Cookie: cookieName + "=" + mainSessionCookie };
|
|
28
17
|
}
|
|
18
|
+
return mainSessionCookie;
|
|
29
19
|
}
|
|
30
20
|
}
|
|
31
21
|
return '';
|
|
32
22
|
};
|
|
33
|
-
exports.
|
|
23
|
+
exports.getAcsCookie = getAcsCookie;
|
|
34
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/session/index.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/session/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAwD;AACxD,kDAA2B;AAOpB,IAAM,YAAY,GAAG,UAC1B,MAAmB,EACnB,aAAsB;IAEtB,IAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAA;IAC/C,IAAI,aAAa,EAAE;QACjB,IAAM,OAAO,GAAG,gBAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAC3C,IAAM,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;QAC7C,IAAI,iBAAiB,EAAE;YACrB,IAAI,MAAM,KAAK,mBAAW,CAAC,IAAI,EAAE;gBAC/B,OAAO,EAAE,MAAM,EAAK,UAAU,SAAI,iBAAmB,EAAE,CAAA;aACxD;YAED,OAAO,iBAAiB,CAAA;SACzB;KACF;IACD,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAjBY,QAAA,YAAY,gBAiBxB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './apolloClient';
|
|
2
2
|
export * from './helpers';
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
13
|
+
__exportStar(require("./apolloClient"), exports);
|
|
14
14
|
__exportStar(require("./helpers"), exports);
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA8B;AAC9B,4CAAyB"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createApolloClient.js","sourceRoot":"","sources":["../../src/createApolloClient/createApolloClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA6C;AAC7C,sCAMmB;AAIZ,IAAM,kBAAkB,GAAG,UAChC,MAAc,EACd,MAAe;;;;;;qBAEX,CAAA,MAAM,KAAK,MAAM,CAAA,EAAjB,wBAAiB;gBACZ,KAAA,2BAAY,CAAA;;oBACjB,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,gBAA0B;;gBAClC,qBAAM,IAAA,oBAAU,EAAC,IAAA,uBAAa,EAAC,IAAA,wBAAc,EAAC,MAAM,CAAC,CAAC,CAAC,EAAA;oBAFlE,sBAAO,mBAEL,UAAO,GAAE,SAAuD;wBAChE,QAAK,GAAE,CAAC,mBAAS,EAAE,mBAAS,CAAC;6BAC7B,EAAA;;gBAEJ,IAAI,MAAM,KAAK,OAAO,EAAE;oBACtB,sBAAO,IAAA,2BAAY,EAAC;4BAClB,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAA6B;4BAC9C,OAAO,EAAE,MAAM;gCACb,CAAC,CAAC;oCACE,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;oCAC9C,gBAAgB,EAAE,IAAA,wBAAc,EAAC,MAAM,CAAC;iCACzC;gCACH,CAAC,CAAC;oCACE,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;iCAC/C;yBACN,CAAC,EAAA;iBACH;gBACD,sBAAO,IAAA,2BAAY,EAAC,MAAM,CAAC,EAAA;;;KAC5B,CAAA;AAzBY,QAAA,kBAAkB,sBAyB9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","sourceRoot":"","sources":["../../src/createApolloClient/createClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAKuB;AACvB,4DAA+B;AAIxB,IAAM,YAAY,GAAG,UAAO,EAOpB;QANb,oBAAiB,EAAjB,YAAY,mBAAG,EAAE,KAAA,EACjB,OAAO,aAAA,EACP,GAAG,SAAA,EACH,mBAAkB,EAAlB,WAAW,mBAAG,IAAI,KAAA,EAClB,KAAK,WAAA,EACL,IAAI,UAAA;;;;YAEE,UAAU,GAAG,KAAK;gBACtB,CAAC,CAAC,IAAA,aAAI,kCACC,KAAK;oBACR,IAAA,uBAAc,EAAC;wBACb,GAAG,KAAA;wBACH,OAAO,SAAA;wBACP,KAAK,uBAAA;qBACN,CAAC;0BACF;gBACJ,CAAC,CAAC,IAAA,uBAAc,EAAC;oBACb,GAAG,KAAA;oBACH,OAAO,SAAA;oBACP,KAAK,uBAAA;iBACN,CAAC,CAAA;YACN,sBAAO,IAAI,qBAAY,CAAC;oBACtB,OAAO,EAAE,IAAI;oBACb,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,oBAAoB;oBAC3D,OAAO,EAAE,OAAO;oBAChB,KAAK,EAAE,IAAI,sBAAa,CAAC,EAAE,WAAW,aAAA,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;iBAChE,CAAC,EAAA;;;CACH,CAAA;AA7BY,QAAA,YAAY,gBA6BxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/createApolloClient/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAoC;AACpC,0CAAuB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/createApolloClient/types.ts"],"names":[],"mappings":";;;AASA,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,4BAAe,CAAA;IACf,8BAAiB,CAAA;AACnB,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getHeaders: (session?: string | undefined) => Promise<Record<string, string | undefined>>;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getHeaders = void 0;
|
|
40
|
-
var getAccessToken_1 = require("../getAccessToken");
|
|
41
|
-
var CACHED_ACCESS_TOKEN;
|
|
42
|
-
var getHeaders = function (session) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
-
var getAccessTokenParams;
|
|
44
|
-
return __generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
if ((session && process.env.MAIN_API_KEY) ||
|
|
48
|
-
(process.env.MAIN_API_KEY && process.env.MAIN_SESSION)) {
|
|
49
|
-
return [2 /*return*/, {
|
|
50
|
-
'X-Main-Service-Origin': 'internal',
|
|
51
|
-
'X-Main-Session': session || process.env.MAIN_SESSION,
|
|
52
|
-
'X-Api-Key': process.env.MAIN_API_KEY,
|
|
53
|
-
}];
|
|
54
|
-
}
|
|
55
|
-
if (!process.env.MAIN_USER_ID) return [3 /*break*/, 3];
|
|
56
|
-
if (!!CACHED_ACCESS_TOKEN) return [3 /*break*/, 2];
|
|
57
|
-
getAccessTokenParams = {
|
|
58
|
-
url: process.env.MAIN_OAUTH_TOKEN,
|
|
59
|
-
client_id: process.env.MAIN_CLIENT_ID,
|
|
60
|
-
client_secret: process.env.MAIN_CLIENT_SECRET,
|
|
61
|
-
audience: process.env.MAIN_AUDIENCE,
|
|
62
|
-
};
|
|
63
|
-
return [4 /*yield*/, (0, getAccessToken_1.getAccessToken)(getAccessTokenParams)];
|
|
64
|
-
case 1:
|
|
65
|
-
CACHED_ACCESS_TOKEN = _a.sent();
|
|
66
|
-
_a.label = 2;
|
|
67
|
-
case 2: return [2 /*return*/, {
|
|
68
|
-
Authorization: "Bearer " + CACHED_ACCESS_TOKEN,
|
|
69
|
-
}];
|
|
70
|
-
case 3: return [2 /*return*/, {}];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}); };
|
|
74
|
-
exports.getHeaders = getHeaders;
|
|
75
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/getHeaders/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAwE;AAExE,IAAI,mBAAmB,CAAA;AAEhB,IAAM,UAAU,GAAG,UACxB,OAAgB;;;;;gBAEhB,IACE,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;oBACrC,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EACtD;oBACA,sBAAO;4BACL,uBAAuB,EAAE,UAAU;4BACnC,gBAAgB,EAAE,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY;4BACrD,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;yBACtC,EAAA;iBACF;qBAEG,OAAO,CAAC,GAAG,CAAC,YAAY,EAAxB,wBAAwB;qBACtB,CAAC,mBAAmB,EAApB,wBAAoB;gBAChB,oBAAoB,GAAyB;oBACjD,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,gBAA0B;oBAC3C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,cAAwB;oBAC/C,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,kBAA4B;oBACvD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,aAAuB;iBAC9C,CAAA;gBAEqB,qBAAM,IAAA,+BAAc,EAAC,oBAAoB,CAAC,EAAA;;gBAAhE,mBAAmB,GAAG,SAA0C,CAAA;;oBAGlE,sBAAO;oBACL,aAAa,EAAE,YAAU,mBAAqB;iBAC/C,EAAA;oBAGH,sBAAO,EAAE,EAAA;;;KACV,CAAA;AAhCY,QAAA,UAAU,cAgCtB"}
|