@newskit-render/api 0.3.0 → 0.4.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 +44 -0
- package/README.md +1 -1
- package/dist/createApolloClient/createApolloClient.js +13 -9
- package/dist/createApolloClient/createApolloClient.js.map +1 -1
- package/dist/createApolloClient/createClient.js +17 -10
- package/dist/createApolloClient/createClient.js.map +1 -1
- package/dist/createApolloClient/index.js +14 -2
- package/dist/createApolloClient/index.js.map +1 -1
- package/dist/createApolloClient/types.js +5 -2
- package/dist/createApolloClient/types.js.map +1 -1
- package/dist/helpers/externalLinks/index.js +11 -8
- package/dist/helpers/externalLinks/index.js.map +1 -1
- package/dist/helpers/getAccessToken/index.js +13 -5
- package/dist/helpers/getAccessToken/index.js.map +1 -1
- package/dist/helpers/getAccessToken/types.js +2 -1
- package/dist/helpers/getHeaders/index.js +7 -3
- package/dist/helpers/getHeaders/index.js.map +1 -1
- package/dist/helpers/index.js +16 -4
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/session/index.js +12 -4
- package/dist/helpers/session/index.js.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,50 @@
|
|
|
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.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
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **PPDSR-0:** fix broken dependecy ([#521](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/521)) ([2690dd3](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/2690dd3bc6cf61a88740a0ff935adf461be02416))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.3.3](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/api@0.3.2...@newskit-render/api@0.3.3) (2021-11-18)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Reverts
|
|
21
|
+
|
|
22
|
+
* Revert "fix(PPDSR-541): switch packages to es modules (#512)" (#516) ([fd719ba](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/fd719badac7578473e2bb991530277bb09ec2057)), closes [#512](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/512) [#516](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/516)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [0.3.2](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/api@0.3.1...@newskit-render/api@0.3.2) (2021-11-18)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* **PPDSR-541:** switch packages to es modules ([#512](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/512)) ([937e57c](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/937e57cb891b366b8f3c2f73c6b88abffef0ea7a))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [0.3.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/api@0.3.0...@newskit-render/api@0.3.1) (2021-11-15)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
* **PPDSR-541:** change packages to get published ([#506](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/506)) ([4de773b](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/4de773b8e22663a2822f64255f347c32384532c0))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
6
50
|
# [0.3.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/api@0.2.2...@newskit-render/api@0.3.0) (2021-11-10)
|
|
7
51
|
|
|
8
52
|
|
package/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,39 +35,42 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.createApolloClient = void 0;
|
|
40
|
+
var createClient_1 = require("./createClient");
|
|
41
|
+
var helpers_1 = require("../helpers");
|
|
42
|
+
var createApolloClient = function (client, cookie) { return __awaiter(void 0, void 0, void 0, function () {
|
|
40
43
|
var _a;
|
|
41
44
|
var _b;
|
|
42
45
|
return __generator(this, function (_c) {
|
|
43
46
|
switch (_c.label) {
|
|
44
47
|
case 0:
|
|
45
48
|
if (!(client === 'main')) return [3 /*break*/, 2];
|
|
46
|
-
_a = createClient;
|
|
49
|
+
_a = createClient_1.createClient;
|
|
47
50
|
_b = {
|
|
48
51
|
uri: process.env.MAIN_GRAPHQL_URL
|
|
49
52
|
};
|
|
50
|
-
return [4 /*yield*/, getHeaders(sessionParser(getMainSession(cookie)))];
|
|
53
|
+
return [4 /*yield*/, (0, helpers_1.getHeaders)((0, helpers_1.sessionParser)((0, helpers_1.getMainSession)(cookie)))];
|
|
51
54
|
case 1: return [2 /*return*/, _a.apply(void 0, [(_b.headers = _c.sent(),
|
|
52
|
-
_b.links = [retryLink, errorLink],
|
|
55
|
+
_b.links = [helpers_1.retryLink, helpers_1.errorLink],
|
|
53
56
|
_b)])];
|
|
54
57
|
case 2:
|
|
55
58
|
if (client === 'nkapi') {
|
|
56
|
-
return [2 /*return*/, createClient({
|
|
59
|
+
return [2 /*return*/, (0, createClient_1.createClient)({
|
|
57
60
|
uri: process.env.NEWSKIT_API_ENV_URL,
|
|
58
61
|
headers: cookie
|
|
59
62
|
? {
|
|
60
63
|
'X-API-KEY': process.env.NEWSKIT_API_X_API_KEY,
|
|
61
|
-
'X-Main-Session': getMainSession(cookie),
|
|
64
|
+
'X-Main-Session': (0, helpers_1.getMainSession)(cookie),
|
|
62
65
|
}
|
|
63
66
|
: {
|
|
64
67
|
'X-API-KEY': process.env.NEWSKIT_API_X_API_KEY,
|
|
65
68
|
},
|
|
66
69
|
})];
|
|
67
70
|
}
|
|
68
|
-
return [2 /*return*/, createClient(client)];
|
|
71
|
+
return [2 /*return*/, (0, createClient_1.createClient)(client)];
|
|
69
72
|
}
|
|
70
73
|
});
|
|
71
74
|
}); };
|
|
75
|
+
exports.createApolloClient = createApolloClient;
|
|
72
76
|
//# sourceMappingURL=createApolloClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createApolloClient.js","sourceRoot":"","sources":["../../src/createApolloClient/createApolloClient.ts"],"names":[],"mappings":"
|
|
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,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -43,34 +44,40 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
43
44
|
}
|
|
44
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.createClient = void 0;
|
|
52
|
+
var client_1 = require("@apollo/client");
|
|
53
|
+
var cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
54
|
+
var createClient = function (_a) {
|
|
49
55
|
var _b = _a.initialState, initialState = _b === void 0 ? {} : _b, headers = _a.headers, uri = _a.uri, _c = _a.addTypename, addTypename = _c === void 0 ? true : _c, links = _a.links, name = _a.name;
|
|
50
56
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
51
57
|
var linkObject;
|
|
52
58
|
return __generator(this, function (_d) {
|
|
53
59
|
linkObject = links
|
|
54
|
-
? from(__spreadArray(__spreadArray([], links, true), [
|
|
55
|
-
createHttpLink({
|
|
60
|
+
? (0, client_1.from)(__spreadArray(__spreadArray([], links, true), [
|
|
61
|
+
(0, client_1.createHttpLink)({
|
|
56
62
|
uri: uri,
|
|
57
63
|
headers: headers,
|
|
58
|
-
fetch:
|
|
64
|
+
fetch: cross_fetch_1.default,
|
|
59
65
|
}),
|
|
60
66
|
], false))
|
|
61
|
-
: createHttpLink({
|
|
67
|
+
: (0, client_1.createHttpLink)({
|
|
62
68
|
uri: uri,
|
|
63
69
|
headers: headers,
|
|
64
|
-
fetch:
|
|
70
|
+
fetch: cross_fetch_1.default,
|
|
65
71
|
});
|
|
66
|
-
return [2 /*return*/, new ApolloClient({
|
|
72
|
+
return [2 /*return*/, new client_1.ApolloClient({
|
|
67
73
|
ssrMode: true,
|
|
68
74
|
link: linkObject,
|
|
69
75
|
name: name || process.env.PUBLISHER || 'ncu-newskit-render',
|
|
70
76
|
version: '0.1.0',
|
|
71
|
-
cache: new InMemoryCache({ addTypename: addTypename }).restore(initialState),
|
|
77
|
+
cache: new client_1.InMemoryCache({ addTypename: addTypename }).restore(initialState),
|
|
72
78
|
})];
|
|
73
79
|
});
|
|
74
80
|
});
|
|
75
81
|
};
|
|
82
|
+
exports.createClient = createClient;
|
|
76
83
|
//# sourceMappingURL=createClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","sourceRoot":"","sources":["../../src/createApolloClient/createClient.ts"],"names":[],"mappings":"
|
|
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,3 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./createApolloClient"), exports);
|
|
14
|
+
__exportStar(require("./types"), exports);
|
|
3
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/createApolloClient/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/createApolloClient/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAoC;AACpC,0CAAuB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientTypes = void 0;
|
|
4
|
+
var ClientTypes;
|
|
2
5
|
(function (ClientTypes) {
|
|
3
6
|
ClientTypes["main"] = "main";
|
|
4
7
|
ClientTypes["nkapi"] = "nkapi";
|
|
5
|
-
})(ClientTypes || (ClientTypes = {}));
|
|
8
|
+
})(ClientTypes = exports.ClientTypes || (exports.ClientTypes = {}));
|
|
6
9
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/createApolloClient/types.ts"],"names":[],"mappings":"AASA,
|
|
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,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorLink = exports.retryLink = void 0;
|
|
4
|
+
var retry_1 = require("@apollo/client/link/retry");
|
|
5
|
+
var error_1 = require("@apollo/client/link/error");
|
|
6
|
+
var client_1 = require("@apollo/client");
|
|
7
|
+
var getAccessToken_1 = require("../getAccessToken");
|
|
5
8
|
//Error handling for getting a new access token for GraphQL
|
|
6
|
-
|
|
9
|
+
exports.retryLink = new retry_1.RetryLink({
|
|
7
10
|
delay: {
|
|
8
11
|
initial: 100,
|
|
9
12
|
max: 2000,
|
|
@@ -19,7 +22,7 @@ var getAccessTokenParams = {
|
|
|
19
22
|
client_secret: process.env.MAIN_CLIENT_SECRET,
|
|
20
23
|
audience: process.env.MAIN_AUDIENCE,
|
|
21
24
|
};
|
|
22
|
-
|
|
25
|
+
exports.errorLink = (0, error_1.onError)(function (_a) {
|
|
23
26
|
var networkError = _a.networkError, operation = _a.operation, forward = _a.forward, graphQLErrors = _a.graphQLErrors;
|
|
24
27
|
if (graphQLErrors) {
|
|
25
28
|
console.error(graphQLErrors);
|
|
@@ -29,8 +32,8 @@ export var errorLink = onError(function (_a) {
|
|
|
29
32
|
networkError.response &&
|
|
30
33
|
networkError.response.statusText === 'Unauthorized' &&
|
|
31
34
|
process.env.MAIN_USER_ID) {
|
|
32
|
-
return new Observable(function (observer) {
|
|
33
|
-
getAccessToken(getAccessTokenParams)
|
|
35
|
+
return new client_1.Observable(function (observer) {
|
|
36
|
+
(0, getAccessToken_1.getAccessToken)(getAccessTokenParams)
|
|
34
37
|
.then(function (token) {
|
|
35
38
|
operation.setContext(function () { return ({
|
|
36
39
|
headers: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/externalLinks/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/externalLinks/index.ts"],"names":[],"mappings":";;;AAAA,mDAAqD;AACrD,mDAAmD;AACnD,yCAAoE;AACpE,oDAAwE;AAExE,2DAA2D;AAC9C,QAAA,SAAS,GAAG,IAAI,iBAAS,CAAC;IACrC,KAAK,EAAE;QACL,OAAO,EAAE,GAAG;QACZ,GAAG,EAAE,IAAI;QACT,MAAM,EAAE,IAAI;KACb;IACD,QAAQ,EAAE;QACR,GAAG,EAAE,CAAC;KACP;CACF,CAAC,CAAA;AAEF,IAAM,oBAAoB,GAAyB;IACjD,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,gBAA0B;IAC3C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,cAAwB;IAC/C,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,kBAA4B;IACvD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,aAAuB;CAC9C,CAAA;AAEY,QAAA,SAAS,GAAe,IAAA,eAAO,EAC1C,UAAC,EAAmD;QAAjD,YAAY,kBAAA,EAAE,SAAS,eAAA,EAAE,OAAO,aAAA,EAAE,aAAa,mBAAA;IAChD,IAAI,aAAa,EAAE;QACjB,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;KAC7B;IACD,+CAA+C;IAC/C,IACE,YAAY;QACX,YAA4B,CAAC,QAAQ;QACrC,YAA4B,CAAC,QAAQ,CAAC,UAAU,KAAK,cAAc;QACpE,OAAO,CAAC,GAAG,CAAC,YAAY,EACxB;QACA,OAAO,IAAI,mBAAU,CAAC,UAAC,QAAQ;YAC7B,IAAA,+BAAc,EAAC,oBAAoB,CAAC;iBACjC,IAAI,CAAC,UAAC,KAAK;gBACV,SAAS,CAAC,UAAU,CAAC,cAAM,OAAA,CAAC;oBAC1B,OAAO,EAAE;wBACP,aAAa,EAAE,YAAU,KAAK,CAAC,cAAc,CAAG,IAAI,IAAI;qBACzD;iBACF,CAAC,EAJyB,CAIzB,CAAC,CAAA;YACL,CAAC,CAAC;iBACD,IAAI,CAAC;gBACJ,IAAM,UAAU,GAAG;oBACjB,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;oBAClC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;oBACpC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;iBAC3C,CAAA;gBAED,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;YAC1C,CAAC,CAAC;iBACD,KAAK,CAAC,UAAC,KAAK;gBACX,+DAA+D;gBAC/D,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACvB,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;KACH;IACD,OAAM;AACR,CAAC,CACF,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __assign = (this && this.__assign) || function () {
|
|
2
3
|
__assign = Object.assign || function(t) {
|
|
3
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -56,15 +57,20 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
56
57
|
}
|
|
57
58
|
return t;
|
|
58
59
|
};
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
61
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
62
|
+
};
|
|
63
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
+
exports.getJSONResponse = exports.getAccessToken = void 0;
|
|
65
|
+
var cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
66
|
+
var getAccessToken = function (_a) { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
67
|
var data, parsedData, error_1;
|
|
62
68
|
var url = _a.url, bodyParams = __rest(_a, ["url"]);
|
|
63
69
|
return __generator(this, function (_b) {
|
|
64
70
|
switch (_b.label) {
|
|
65
71
|
case 0:
|
|
66
72
|
_b.trys.push([0, 3, , 4]);
|
|
67
|
-
return [4 /*yield*/,
|
|
73
|
+
return [4 /*yield*/, (0, cross_fetch_1.default)(url, {
|
|
68
74
|
method: 'POST',
|
|
69
75
|
headers: {
|
|
70
76
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -73,7 +79,7 @@ export var getAccessToken = function (_a) { return __awaiter(void 0, void 0, voi
|
|
|
73
79
|
})];
|
|
74
80
|
case 1:
|
|
75
81
|
data = _b.sent();
|
|
76
|
-
return [4 /*yield*/, getJSONResponse(data)];
|
|
82
|
+
return [4 /*yield*/, (0, exports.getJSONResponse)(data)];
|
|
77
83
|
case 2:
|
|
78
84
|
parsedData = _b.sent();
|
|
79
85
|
return [2 /*return*/, parsedData];
|
|
@@ -85,7 +91,8 @@ export var getAccessToken = function (_a) { return __awaiter(void 0, void 0, voi
|
|
|
85
91
|
}
|
|
86
92
|
});
|
|
87
93
|
}); };
|
|
88
|
-
|
|
94
|
+
exports.getAccessToken = getAccessToken;
|
|
95
|
+
var getJSONResponse = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
89
96
|
var json, e_1;
|
|
90
97
|
return __generator(this, function (_a) {
|
|
91
98
|
switch (_a.label) {
|
|
@@ -103,4 +110,5 @@ export var getJSONResponse = function (response) { return __awaiter(void 0, void
|
|
|
103
110
|
}
|
|
104
111
|
});
|
|
105
112
|
}); };
|
|
113
|
+
exports.getJSONResponse = getJSONResponse;
|
|
106
114
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/getAccessToken/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/getAccessToken/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA+B;AAUxB,IAAM,cAAc,GAAG,UAAO,EAGd;;IAFrB,IAAA,GAAG,SAAA,EACA,UAAU,cAFsB,OAGpC,CADc;;;;;gBAGE,qBAAM,IAAA,qBAAK,EAAC,GAAG,EAAE;wBAC5B,MAAM,EAAE,MAAM;wBACd,OAAO,EAAE;4BACP,cAAc,EAAE,mCAAmC;yBACpD;wBACD,IAAI,EAAE,IAAI,eAAe,uBACpB,UAAU,KACb,UAAU,EAAE,oBAAoB,IAChC;qBACH,CAAC,EAAA;;gBATI,IAAI,GAAG,SASX;gBACiB,qBAAM,IAAA,uBAAe,EAAa,IAAI,CAAC,EAAA;;gBAApD,UAAU,GAAG,SAAuC;gBAC1D,sBAAO,UAAU,EAAA;;;gBAEjB,OAAO,CAAC,KAAK,CAAC,OAAK,CAAC,CAAA;;;;;KAEvB,CAAA;AApBY,QAAA,cAAc,kBAoB1B;AAEM,IAAM,eAAe,GAAG,UAC7B,QAAkB;;;;;;gBAIT,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;gBAA5B,IAAI,GAAG,SAAqB,CAAA;;;;gBAE5B,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,GAAC,CAAC,CAAA;;oBAG3C,sBAAO,IAAY,EAAA;;;KACpB,CAAA;AAXY,QAAA,eAAe,mBAW3B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,9 +35,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getHeaders = void 0;
|
|
40
|
+
var getAccessToken_1 = require("../getAccessToken");
|
|
38
41
|
var CACHED_ACCESS_TOKEN;
|
|
39
|
-
|
|
42
|
+
var getHeaders = function (session) { return __awaiter(void 0, void 0, void 0, function () {
|
|
40
43
|
var getAccessTokenParams;
|
|
41
44
|
return __generator(this, function (_a) {
|
|
42
45
|
switch (_a.label) {
|
|
@@ -57,7 +60,7 @@ export var getHeaders = function (session) { return __awaiter(void 0, void 0, vo
|
|
|
57
60
|
client_secret: process.env.MAIN_CLIENT_SECRET,
|
|
58
61
|
audience: process.env.MAIN_AUDIENCE,
|
|
59
62
|
};
|
|
60
|
-
return [4 /*yield*/, getAccessToken(getAccessTokenParams)];
|
|
63
|
+
return [4 /*yield*/, (0, getAccessToken_1.getAccessToken)(getAccessTokenParams)];
|
|
61
64
|
case 1:
|
|
62
65
|
CACHED_ACCESS_TOKEN = _a.sent();
|
|
63
66
|
_a.label = 2;
|
|
@@ -68,4 +71,5 @@ export var getHeaders = function (session) { return __awaiter(void 0, void 0, vo
|
|
|
68
71
|
}
|
|
69
72
|
});
|
|
70
73
|
}); };
|
|
74
|
+
exports.getHeaders = getHeaders;
|
|
71
75
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/getHeaders/index.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./getAccessToken"), exports);
|
|
14
|
+
__exportStar(require("./externalLinks"), exports);
|
|
15
|
+
__exportStar(require("./getHeaders"), exports);
|
|
16
|
+
__exportStar(require("./session"), exports);
|
|
5
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAgC;AAChC,kDAA+B;AAC/B,+CAA4B;AAC5B,4CAAyB"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sessionParser = exports.getMainSession = void 0;
|
|
7
|
+
var cookie_1 = __importDefault(require("cookie"));
|
|
8
|
+
var getMainSession = function (cookieSession) {
|
|
3
9
|
if (cookieSession) {
|
|
4
|
-
var cookies =
|
|
10
|
+
var cookies = cookie_1.default.parse(cookieSession);
|
|
5
11
|
var mainSessionCookie = cookies['main_session'];
|
|
6
12
|
return mainSessionCookie;
|
|
7
13
|
}
|
|
8
14
|
return '';
|
|
9
15
|
};
|
|
16
|
+
exports.getMainSession = getMainSession;
|
|
10
17
|
//Parse session from browser in the form of a session_id
|
|
11
|
-
|
|
18
|
+
var sessionParser = function (cookieSession) {
|
|
12
19
|
if (cookieSession) {
|
|
13
20
|
var buff = Buffer.from(cookieSession, 'base64');
|
|
14
21
|
var decodedSession = buff.toString('ascii');
|
|
@@ -23,4 +30,5 @@ export var sessionParser = function (cookieSession) {
|
|
|
23
30
|
}
|
|
24
31
|
return '';
|
|
25
32
|
};
|
|
33
|
+
exports.sessionParser = sessionParser;
|
|
26
34
|
//# 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,kDAA2B;AAEpB,IAAM,cAAc,GAAG,UAAC,aAAsB;IACnD,IAAI,aAAa,EAAE;QACjB,IAAM,OAAO,GAAG,gBAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAC3C,IAAM,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;QACjD,OAAO,iBAAiB,CAAA;KACzB;IACD,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAPY,QAAA,cAAc,kBAO1B;AACD,wDAAwD;AACjD,IAAM,aAAa,GAAG,UAAC,aAAsB;IAClD,IAAI,aAAa,EAAE;QACjB,IAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;QACjD,IAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC7C,IAAI,cAAc,EAAE;YAClB,IAAI;gBACF,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,CAAA;aAChD;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,CAAC,CAAC,CAAA;aAC7C;SACF;KACF;IAED,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAdY,QAAA,aAAa,iBAczB"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./createApolloClient"), exports);
|
|
14
|
+
__exportStar(require("./helpers"), exports);
|
|
3
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,uDAAoC;AACpC,4CAAyB"}
|