@newskit-render/api 0.0.0-014af081
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 +61 -0
- package/dist/cjs/apolloClient/createApolloClient.d.ts +2 -0
- package/dist/cjs/apolloClient/createApolloClient.js +57 -0
- package/dist/cjs/apolloClient/createApolloClient.js.map +1 -0
- package/dist/cjs/apolloClient/createClient.d.ts +2 -0
- package/dist/cjs/apolloClient/createClient.js +83 -0
- package/dist/cjs/apolloClient/createClient.js.map +1 -0
- package/dist/cjs/apolloClient/index.d.ts +2 -0
- package/dist/cjs/apolloClient/index.js +19 -0
- package/dist/cjs/apolloClient/index.js.map +1 -0
- package/dist/cjs/apolloClient/types.d.ts +31 -0
- package/dist/cjs/apolloClient/types.js +22 -0
- package/dist/cjs/apolloClient/types.js.map +1 -0
- package/dist/cjs/config/index.d.ts +1 -0
- package/dist/cjs/config/index.js +15 -0
- package/dist/cjs/config/index.js.map +1 -0
- package/dist/cjs/fetchSessionCookie/fetchSessionCookie.d.ts +6 -0
- package/dist/cjs/fetchSessionCookie/fetchSessionCookie.js +99 -0
- package/dist/cjs/fetchSessionCookie/fetchSessionCookie.js.map +1 -0
- package/dist/cjs/fetchSessionCookie/index.d.ts +2 -0
- package/dist/cjs/fetchSessionCookie/index.js +19 -0
- package/dist/cjs/fetchSessionCookie/index.js.map +1 -0
- package/dist/cjs/fetchSessionCookie/types.d.ts +10 -0
- package/dist/cjs/fetchSessionCookie/types.js +10 -0
- package/dist/cjs/fetchSessionCookie/types.js.map +1 -0
- package/dist/cjs/helpers/externalLinks/index.d.ts +7 -0
- package/dist/cjs/helpers/externalLinks/index.js +83 -0
- package/dist/cjs/helpers/externalLinks/index.js.map +1 -0
- package/dist/cjs/helpers/getAccessToken/index.d.ts +9 -0
- package/dist/cjs/helpers/getAccessToken/index.js +114 -0
- package/dist/cjs/helpers/getAccessToken/index.js.map +1 -0
- package/dist/cjs/helpers/getAccessToken/types.d.ts +7 -0
- package/dist/cjs/helpers/getAccessToken/types.js +3 -0
- package/dist/cjs/helpers/getAccessToken/types.js.map +1 -0
- package/dist/cjs/helpers/index.d.ts +3 -0
- package/dist/cjs/helpers/index.js +20 -0
- package/dist/cjs/helpers/index.js.map +1 -0
- package/dist/cjs/helpers/session/index.d.ts +5 -0
- package/dist/cjs/helpers/session/index.js +26 -0
- package/dist/cjs/helpers/session/index.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/apolloClient/createApolloClient.d.ts +2 -0
- package/dist/esm/apolloClient/createApolloClient.js +53 -0
- package/dist/esm/apolloClient/createApolloClient.js.map +1 -0
- package/dist/esm/apolloClient/createClient.d.ts +2 -0
- package/dist/esm/apolloClient/createClient.js +76 -0
- package/dist/esm/apolloClient/createClient.js.map +1 -0
- package/dist/esm/apolloClient/index.d.ts +2 -0
- package/dist/esm/apolloClient/index.js +3 -0
- package/dist/esm/apolloClient/index.js.map +1 -0
- package/dist/esm/apolloClient/types.d.ts +31 -0
- package/dist/esm/apolloClient/types.js +19 -0
- package/dist/esm/apolloClient/types.js.map +1 -0
- package/dist/esm/config/index.d.ts +1 -0
- package/dist/esm/config/index.js +12 -0
- package/dist/esm/config/index.js.map +1 -0
- package/dist/esm/fetchSessionCookie/fetchSessionCookie.d.ts +6 -0
- package/dist/esm/fetchSessionCookie/fetchSessionCookie.js +91 -0
- package/dist/esm/fetchSessionCookie/fetchSessionCookie.js.map +1 -0
- package/dist/esm/fetchSessionCookie/index.d.ts +2 -0
- package/dist/esm/fetchSessionCookie/index.js +3 -0
- package/dist/esm/fetchSessionCookie/index.js.map +1 -0
- package/dist/esm/fetchSessionCookie/types.d.ts +10 -0
- package/dist/esm/fetchSessionCookie/types.js +7 -0
- package/dist/esm/fetchSessionCookie/types.js.map +1 -0
- package/dist/esm/helpers/externalLinks/index.d.ts +7 -0
- package/dist/esm/helpers/externalLinks/index.js +78 -0
- package/dist/esm/helpers/externalLinks/index.js.map +1 -0
- package/dist/esm/helpers/getAccessToken/index.d.ts +9 -0
- package/dist/esm/helpers/getAccessToken/index.js +106 -0
- package/dist/esm/helpers/getAccessToken/index.js.map +1 -0
- package/dist/esm/helpers/getAccessToken/types.d.ts +7 -0
- package/dist/esm/helpers/getAccessToken/types.js +2 -0
- package/dist/esm/helpers/getAccessToken/types.js.map +1 -0
- package/dist/esm/helpers/index.d.ts +3 -0
- package/dist/esm/helpers/index.js +4 -0
- package/dist/esm/helpers/index.js.map +1 -0
- package/dist/esm/helpers/session/index.d.ts +5 -0
- package/dist/esm/helpers/session/index.js +19 -0
- package/dist/esm/helpers/session/index.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
+
t[p] = s[p];
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
+
t[p[i]] = s[p[i]];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
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 () {
|
|
67
|
+
var data, parsedData, error_1;
|
|
68
|
+
var url = _a.url, bodyParams = __rest(_a, ["url"]);
|
|
69
|
+
return __generator(this, function (_b) {
|
|
70
|
+
switch (_b.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
_b.trys.push([0, 3, , 4]);
|
|
73
|
+
return [4 /*yield*/, (0, cross_fetch_1.default)(url, {
|
|
74
|
+
method: 'POST',
|
|
75
|
+
headers: {
|
|
76
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
77
|
+
},
|
|
78
|
+
body: new URLSearchParams(__assign(__assign({}, bodyParams), { grant_type: 'client_credentials' })),
|
|
79
|
+
})];
|
|
80
|
+
case 1:
|
|
81
|
+
data = _b.sent();
|
|
82
|
+
return [4 /*yield*/, (0, exports.getJSONResponse)(data)];
|
|
83
|
+
case 2:
|
|
84
|
+
parsedData = _b.sent();
|
|
85
|
+
return [2 /*return*/, parsedData];
|
|
86
|
+
case 3:
|
|
87
|
+
error_1 = _b.sent();
|
|
88
|
+
console.error(error_1);
|
|
89
|
+
return [3 /*break*/, 4];
|
|
90
|
+
case 4: return [2 /*return*/];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}); };
|
|
94
|
+
exports.getAccessToken = getAccessToken;
|
|
95
|
+
var getJSONResponse = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
|
+
var json, e_1;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
_a.trys.push([0, 2, , 3]);
|
|
101
|
+
return [4 /*yield*/, response.json()];
|
|
102
|
+
case 1:
|
|
103
|
+
json = _a.sent();
|
|
104
|
+
return [3 /*break*/, 3];
|
|
105
|
+
case 2:
|
|
106
|
+
e_1 = _a.sent();
|
|
107
|
+
console.error('Invalid JSON response', e_1);
|
|
108
|
+
return [3 /*break*/, 3];
|
|
109
|
+
case 3: return [2 /*return*/, json];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}); };
|
|
113
|
+
exports.getJSONResponse = getJSONResponse;
|
|
114
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/helpers/getAccessToken/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./getAccessToken"), exports);
|
|
18
|
+
__exportStar(require("./externalLinks"), exports);
|
|
19
|
+
__exportStar(require("./session"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,kDAA+B;AAC/B,4CAAyB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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.getAcsCookie = void 0;
|
|
7
|
+
var types_1 = require("./../../apolloClient/types");
|
|
8
|
+
var cookie_1 = __importDefault(require("cookie"));
|
|
9
|
+
var fetchSessionCookie_1 = require("../../fetchSessionCookie");
|
|
10
|
+
var getAcsCookie = function (client, cookieSession) {
|
|
11
|
+
if (cookieSession) {
|
|
12
|
+
var cookies = cookie_1.default.parse(cookieSession);
|
|
13
|
+
var cookieName = (0, fetchSessionCookie_1.findCookieName)(cookies);
|
|
14
|
+
var mainSessionCookie = cookies[cookieName];
|
|
15
|
+
if (mainSessionCookie) {
|
|
16
|
+
if (client === types_1.ClientTypes.main) {
|
|
17
|
+
return { Cookie: "".concat(cookieName, "=").concat(mainSessionCookie) };
|
|
18
|
+
}
|
|
19
|
+
// We want to send encoded URI to NKAPI
|
|
20
|
+
return encodeURIComponent(mainSessionCookie);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return '';
|
|
24
|
+
};
|
|
25
|
+
exports.getAcsCookie = getAcsCookie;
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/helpers/session/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAwD;AACxD,kDAA2B;AAC3B,+DAAyD;AAOlD,IAAM,YAAY,GAAG,UAC1B,MAAmB,EACnB,aAAsB;IAEtB,IAAI,aAAa,EAAE;QACjB,IAAM,OAAO,GAAG,gBAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAC3C,IAAM,UAAU,GAAG,IAAA,mCAAc,EAAC,OAAO,CAAC,CAAA;QAC1C,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,EAAE,UAAG,UAAU,cAAI,iBAAiB,CAAE,EAAE,CAAA;aACxD;YAED,uCAAuC;YACvC,OAAO,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;SAC7C;KACF;IACD,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAlBY,QAAA,YAAY,gBAkBxB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./apolloClient"), exports);
|
|
18
|
+
__exportStar(require("./helpers"), exports);
|
|
19
|
+
__exportStar(require("./fetchSessionCookie"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,4CAAyB;AACzB,uDAAoC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { createClient } from './createClient';
|
|
11
|
+
import { getAcsCookie, retryLink, errorLink, enableStepUpLink, stepUpMfaErrorLink, } from '../helpers';
|
|
12
|
+
import { ClientTypes } from './types';
|
|
13
|
+
import { acsSessionUrl, mainGraphqlUrl, accountProviderGraphqlUrl, newskitApiEnvUrl, newskitApiXApiKey, enableStepUpMfa, } from '../config';
|
|
14
|
+
export var createApolloClient = function (client, cookie, token, accountProviderCookieName, config, handleMfaError) {
|
|
15
|
+
if (client === ClientTypes.main) {
|
|
16
|
+
var headers = getAcsCookie(ClientTypes.main, cookie);
|
|
17
|
+
var links = [retryLink, errorLink];
|
|
18
|
+
if (!headers && acsSessionUrl) {
|
|
19
|
+
headers = {
|
|
20
|
+
Cookie: "".concat(accountProviderCookieName, "=").concat(token),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return createClient({
|
|
24
|
+
uri: accountProviderGraphqlUrl || mainGraphqlUrl,
|
|
25
|
+
links: !enableStepUpMfa
|
|
26
|
+
? links
|
|
27
|
+
: __spreadArray([
|
|
28
|
+
enableStepUpLink(headers, cookie),
|
|
29
|
+
stepUpMfaErrorLink(handleMfaError)
|
|
30
|
+
], links, true),
|
|
31
|
+
headers: headers,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (client === ClientTypes.nkapi) {
|
|
35
|
+
var apiXApiKey = config ? config.newskitApiXApiKey : newskitApiXApiKey;
|
|
36
|
+
var apiEnvUrl = config ? config.newskitApiEnvUrl : newskitApiEnvUrl;
|
|
37
|
+
return createClient({
|
|
38
|
+
uri: apiEnvUrl,
|
|
39
|
+
headers: cookie
|
|
40
|
+
? {
|
|
41
|
+
'X-API-KEY': apiXApiKey,
|
|
42
|
+
'newsuk-acs-cookie': getAcsCookie(ClientTypes.nkapi, cookie),
|
|
43
|
+
'platform-type': 'desktop',
|
|
44
|
+
}
|
|
45
|
+
: {
|
|
46
|
+
'X-API-KEY': apiXApiKey,
|
|
47
|
+
'platform-type': 'desktop',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return createClient(client);
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=createApolloClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createApolloClient.js","sourceRoot":"","sources":["../../../src/apolloClient/createApolloClient.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EACL,YAAY,EACZ,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAU,WAAW,EAAU,MAAM,SAAS,CAAA;AACrD,OAAO,EACL,aAAa,EACb,cAAc,EACd,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,MAAM,CAAC,IAAM,kBAAkB,GAAG,UAChC,MAAc,EACd,MAAe,EACf,KAAc,EACd,yBAAkC,EAClC,MAAe,EACf,cAA2B;IAE3B,IAAI,MAAM,KAAK,WAAW,CAAC,IAAI,EAAE;QAC/B,IAAI,OAAO,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QACpD,IAAM,KAAK,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAEpC,IAAI,CAAC,OAAO,IAAI,aAAa,EAAE;YAC7B,OAAO,GAAG;gBACR,MAAM,EAAE,UAAG,yBAAyB,cAAI,KAAK,CAAE;aAChD,CAAA;SACF;QAED,OAAO,YAAY,CAAC;YAClB,GAAG,EAAE,yBAAyB,IAAI,cAAc;YAChD,KAAK,EAAE,CAAC,eAAe;gBACrB,CAAC,CAAC,KAAK;gBACP,CAAC;oBACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC;oBACjC,kBAAkB,CAAC,cAAc,CAAC;mBAC/B,KAAK,OACT;YACL,OAAO,SAAA;SACR,CAAC,CAAA;KACH;IAED,IAAI,MAAM,KAAK,WAAW,CAAC,KAAK,EAAE;QAChC,IAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAA;QACxE,IAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAA;QAErE,OAAO,YAAY,CAAC;YAClB,GAAG,EAAE,SAAS;YACd,OAAO,EAAE,MAAM;gBACb,CAAC,CAAC;oBACE,WAAW,EAAE,UAAU;oBACvB,mBAAmB,EAAE,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC;oBAC5D,eAAe,EAAE,SAAS;iBAC3B;gBACH,CAAC,CAAC;oBACE,WAAW,EAAE,UAAU;oBACvB,eAAe,EAAE,SAAS;iBAC3B;SACN,CAAC,CAAA;KACH;IACD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAA;AAC7B,CAAC,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
46
|
+
import { ApolloClient, createHttpLink, InMemoryCache, from, } from '@apollo/client';
|
|
47
|
+
import fetch from 'cross-fetch';
|
|
48
|
+
export var createClient = function (_a) {
|
|
49
|
+
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
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
+
var linkObject;
|
|
52
|
+
return __generator(this, function (_d) {
|
|
53
|
+
linkObject = links
|
|
54
|
+
? from(__spreadArray(__spreadArray([], links, true), [
|
|
55
|
+
createHttpLink({
|
|
56
|
+
uri: uri,
|
|
57
|
+
headers: headers,
|
|
58
|
+
fetch: fetch,
|
|
59
|
+
}),
|
|
60
|
+
], false))
|
|
61
|
+
: createHttpLink({
|
|
62
|
+
uri: uri,
|
|
63
|
+
headers: headers,
|
|
64
|
+
fetch: fetch,
|
|
65
|
+
});
|
|
66
|
+
return [2 /*return*/, new ApolloClient({
|
|
67
|
+
ssrMode: true,
|
|
68
|
+
link: linkObject,
|
|
69
|
+
name: name || 'ncu-newskit-render',
|
|
70
|
+
version: '0.1.0',
|
|
71
|
+
cache: new InMemoryCache({ addTypename: addTypename }).restore(initialState),
|
|
72
|
+
})];
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=createClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createClient.js","sourceRoot":"","sources":["../../../src/apolloClient/createClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,IAAI,GACL,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,MAAM,aAAa,CAAA;AAI/B,MAAM,CAAC,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,IAAI,iCACC,KAAK;oBACR,cAAc,CAAC;wBACb,GAAG,KAAA;wBACH,OAAO,SAAA;wBACP,KAAK,OAAA;qBACN,CAAC;0BACF;gBACJ,CAAC,CAAC,cAAc,CAAC;oBACb,GAAG,KAAA;oBACH,OAAO,SAAA;oBACP,KAAK,OAAA;iBACN,CAAC,CAAA;YACN,sBAAO,IAAI,YAAY,CAAC;oBACtB,OAAO,EAAE,IAAI;oBACb,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,IAAI,IAAI,oBAAoB;oBAClC,OAAO,EAAE,OAAO;oBAChB,KAAK,EAAE,IAAI,aAAa,CAAC,EAAE,WAAW,aAAA,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;iBAChE,CAAC,EAAA;;;CACH,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/apolloClient/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ApolloClient, NormalizedCacheObject, ApolloLink, RequestHandler } from '@apollo/client';
|
|
2
|
+
export type ApolloHttpClient = ApolloClient<NormalizedCacheObject>;
|
|
3
|
+
export type Config = {
|
|
4
|
+
newskitApiEnvUrl: string;
|
|
5
|
+
newskitApiXApiKey: string;
|
|
6
|
+
};
|
|
7
|
+
export declare enum ClientTypes {
|
|
8
|
+
'main' = "main",
|
|
9
|
+
'nkapi' = "nkapi"
|
|
10
|
+
}
|
|
11
|
+
export declare enum Publisher {
|
|
12
|
+
SUN_UK = "SUN_UK",
|
|
13
|
+
SUN_US = "SUN_US",
|
|
14
|
+
SUN_IE = "SUN_IE",
|
|
15
|
+
SUN_SCT = "SUN_SCT",
|
|
16
|
+
TIMES = "TIMES",
|
|
17
|
+
VIRGIN = "VIRGIN",
|
|
18
|
+
TALK_SPORT = "TALK_SPORT",
|
|
19
|
+
TALK_RADIO = "TALK_RADIO",
|
|
20
|
+
TALK_TV = "TALK_TV",
|
|
21
|
+
DEMO = "DEMO"
|
|
22
|
+
}
|
|
23
|
+
export interface ClientObject {
|
|
24
|
+
initialState?: NormalizedCacheObject;
|
|
25
|
+
headers?: any;
|
|
26
|
+
uri?: string;
|
|
27
|
+
addTypename?: boolean;
|
|
28
|
+
links?: (ApolloLink | RequestHandler)[];
|
|
29
|
+
name?: string;
|
|
30
|
+
}
|
|
31
|
+
export type Client = ClientTypes | ClientObject;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var ClientTypes;
|
|
2
|
+
(function (ClientTypes) {
|
|
3
|
+
ClientTypes["main"] = "main";
|
|
4
|
+
ClientTypes["nkapi"] = "nkapi";
|
|
5
|
+
})(ClientTypes || (ClientTypes = {}));
|
|
6
|
+
export var Publisher;
|
|
7
|
+
(function (Publisher) {
|
|
8
|
+
Publisher["SUN_UK"] = "SUN_UK";
|
|
9
|
+
Publisher["SUN_US"] = "SUN_US";
|
|
10
|
+
Publisher["SUN_IE"] = "SUN_IE";
|
|
11
|
+
Publisher["SUN_SCT"] = "SUN_SCT";
|
|
12
|
+
Publisher["TIMES"] = "TIMES";
|
|
13
|
+
Publisher["VIRGIN"] = "VIRGIN";
|
|
14
|
+
Publisher["TALK_SPORT"] = "TALK_SPORT";
|
|
15
|
+
Publisher["TALK_RADIO"] = "TALK_RADIO";
|
|
16
|
+
Publisher["TALK_TV"] = "TALK_TV";
|
|
17
|
+
Publisher["DEMO"] = "DEMO";
|
|
18
|
+
})(Publisher || (Publisher = {}));
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/apolloClient/types.ts"],"names":[],"mappings":"AAcA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,4BAAe,CAAA;IACf,8BAAiB,CAAA;AACnB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AAED,MAAM,CAAN,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,gCAAmB,CAAA;IACnB,4BAAe,CAAA;IACf,8BAAiB,CAAA;IACjB,sCAAyB,CAAA;IACzB,sCAAyB,CAAA;IACzB,gCAAmB,CAAA;IACnB,0BAAa,CAAA;AACf,CAAC,EAXW,SAAS,KAAT,SAAS,QAWpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const acsTestPassword: string, acsTestAccount: string, newskitApiXApiKey: string, newskitApiEnvUrl: string, mainGraphqlUrl: string, accountProviderGraphqlUrl: string, acsSessionUrl: string, enableStepUpMfa: boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var config = {
|
|
2
|
+
acsTestPassword: process.env.ACS_TEST_PASSWORD,
|
|
3
|
+
acsTestAccount: process.env.ACS_TEST_ACCOUNT,
|
|
4
|
+
newskitApiXApiKey: process.env.NEWSKIT_API_X_API_KEY,
|
|
5
|
+
newskitApiEnvUrl: process.env.NEWSKIT_API_ENV_URL,
|
|
6
|
+
mainGraphqlUrl: process.env.MAIN_GRAPHQL_URL,
|
|
7
|
+
accountProviderGraphqlUrl: process.env.ACCOUNT_PROVIDER_GRAPHQL_URL,
|
|
8
|
+
acsSessionUrl: process.env.ACS_SESSION_URL,
|
|
9
|
+
enableStepUpMfa: process.env.ENABLE_STEPUP_MFA === 'true',
|
|
10
|
+
};
|
|
11
|
+
export var acsTestPassword = config.acsTestPassword, acsTestAccount = config.acsTestAccount, newskitApiXApiKey = config.newskitApiXApiKey, newskitApiEnvUrl = config.newskitApiEnvUrl, mainGraphqlUrl = config.mainGraphqlUrl, accountProviderGraphqlUrl = config.accountProviderGraphqlUrl, acsSessionUrl = config.acsSessionUrl, enableStepUpMfa = config.enableStepUpMfa;
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,IAAM,MAAM,GAAG;IACb,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,iBAA2B;IACxD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,gBAA0B;IACtD,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,qBAA+B;IAC9D,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,mBAA6B;IAC3D,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,gBAA0B;IACtD,yBAAyB,EAAE,OAAO,CAAC,GAAG,CAAC,4BAAsC;IAC7E,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,eAAyB;IACpD,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,MAAM;CAC1D,CAAA;AAED,MAAM,CACJ,IAAA,eAAe,GAQb,MAAM,gBARO,EACf,cAAc,GAOZ,MAAM,eAPM,EACd,iBAAiB,GAMf,MAAM,kBANS,EACjB,gBAAgB,GAKd,MAAM,iBALQ,EAChB,cAAc,GAIZ,MAAM,eAJM,EACd,yBAAyB,GAGvB,MAAM,0BAHiB,EACzB,aAAa,GAEX,MAAM,cAFK,EACb,eAAe,GACb,MAAM,gBADO,CACP"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { fetchSessionCookiesParams } from './types';
|
|
2
|
+
export declare const fetchSessionCookie: (config?: fetchSessionCookiesParams) => Promise<{
|
|
3
|
+
value?: string;
|
|
4
|
+
accountProviderCookieName: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const findCookieName: (cookie: Record<string, any> | undefined) => string | undefined;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import fetch from 'cross-fetch';
|
|
38
|
+
import { acsSessionUrl, acsTestAccount, acsTestPassword } from '../config';
|
|
39
|
+
import { CookieName } from './types';
|
|
40
|
+
export var fetchSessionCookie = function (config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var url, response, acsToken, _a, value, accountProviderCookieName, e_1;
|
|
42
|
+
return __generator(this, function (_b) {
|
|
43
|
+
switch (_b.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
url = (config === null || config === void 0 ? void 0 : config.tenantUrl) || acsSessionUrl;
|
|
46
|
+
return [4 /*yield*/, fetch(url, {
|
|
47
|
+
method: 'POST',
|
|
48
|
+
body: JSON.stringify({
|
|
49
|
+
rememberMe: true,
|
|
50
|
+
sso: false,
|
|
51
|
+
authCredentials: {
|
|
52
|
+
username: config ? config.username : acsTestAccount,
|
|
53
|
+
password: config ? config.password : acsTestPassword,
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
headers: {
|
|
57
|
+
'Content-Type': 'application/vnd.newsuk.acs.createsession-v1+json',
|
|
58
|
+
},
|
|
59
|
+
})];
|
|
60
|
+
case 1:
|
|
61
|
+
response = _b.sent();
|
|
62
|
+
_b.label = 2;
|
|
63
|
+
case 2:
|
|
64
|
+
_b.trys.push([2, 4, , 5]);
|
|
65
|
+
return [4 /*yield*/, response.json()];
|
|
66
|
+
case 3:
|
|
67
|
+
acsToken = _b.sent();
|
|
68
|
+
if (acsToken) {
|
|
69
|
+
_a = acsToken.acsCookies.cookies.find(function (cookie) { return cookie.name in CookieName; }), value = _a.value, accountProviderCookieName = _a.name;
|
|
70
|
+
return [2 /*return*/, { value: value, accountProviderCookieName: accountProviderCookieName }];
|
|
71
|
+
}
|
|
72
|
+
return [3 /*break*/, 5];
|
|
73
|
+
case 4:
|
|
74
|
+
e_1 = _b.sent();
|
|
75
|
+
/* istanbul ignore next */ console.error(e_1);
|
|
76
|
+
return [3 /*break*/, 5];
|
|
77
|
+
case 5: return [2 /*return*/, { accountProviderCookieName: CookieName.acs_ngn }];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}); };
|
|
81
|
+
export var findCookieName = function (cookie) {
|
|
82
|
+
if (cookie) {
|
|
83
|
+
for (var name_1 in cookie) {
|
|
84
|
+
if (name_1 in CookieName) {
|
|
85
|
+
return name_1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=fetchSessionCookie.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchSessionCookie.js","sourceRoot":"","sources":["../../../src/fetchSessionCookie/fetchSessionCookie.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,aAAa,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC1E,OAAO,EAAE,UAAU,EAA6B,MAAM,SAAS,CAAA;AAC/D,MAAM,CAAC,IAAM,kBAAkB,GAAG,UAChC,MAAkC;;;;;gBAK5B,GAAG,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,KAAK,aAAwB,CAAA;gBACzC,qBAAM,KAAK,CAAC,GAAG,EAAE;wBAChC,MAAM,EAAE,MAAM;wBACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;4BACnB,UAAU,EAAE,IAAI;4BAChB,GAAG,EAAE,KAAK;4BACV,eAAe,EAAE;gCACf,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc;gCACnD,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe;6BACrD;yBACF,CAAC;wBACF,OAAO,EAAE;4BACP,cAAc,EAAE,kDAAkD;yBACnE;qBACF,CAAC,EAAA;;gBAbI,QAAQ,GAAG,SAaf;;;;gBAGiB,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;gBAAhC,QAAQ,GAAG,SAAqB;gBACtC,IAAI,QAAQ,EAAE;oBACN,KACJ,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,CAAC,IAAI,IAAI,UAAU,EAAzB,CAAyB,CAAC,EADjE,KAAK,WAAA,EAAQ,yBAAyB,UAAA,CAC2B;oBACzE,sBAAO,EAAE,KAAK,OAAA,EAAE,yBAAyB,2BAAA,EAAE,EAAA;iBAC5C;;;;gBAED,0BAA0B,CAAC,OAAO,CAAC,KAAK,CAAC,GAAC,CAAC,CAAA;;oBAG7C,sBAAO,EAAE,yBAAyB,EAAE,UAAU,CAAC,OAAO,EAAE,EAAA;;;KACzD,CAAA;AAED,MAAM,CAAC,IAAM,cAAc,GAAG,UAC5B,MAAuC;IAEvC,IAAI,MAAM,EAAE;QACV,KAAK,IAAM,MAAI,IAAI,MAAM,EAAE;YACzB,IAAI,MAAI,IAAI,UAAU,EAAE;gBACtB,OAAO,MAAI,CAAA;aACZ;SACF;KACF;IACD,OAAM;AACR,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fetchSessionCookie/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/fetchSessionCookie/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;AACrB,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RetryLink } from '@apollo/client/link/retry';
|
|
2
|
+
import { ApolloLink } from '@apollo/client';
|
|
3
|
+
import { MainAcsCookie } from 'helpers/session';
|
|
4
|
+
export declare const retryLink: RetryLink;
|
|
5
|
+
export declare const errorLink: ApolloLink;
|
|
6
|
+
export declare const stepUpMfaErrorLink: (handleMfaError?: () => void) => ApolloLink;
|
|
7
|
+
export declare const enableStepUpLink: (requestHeaders: MainAcsCookie, cookie?: string) => ApolloLink;
|