@magda/authentication-plugin-sdk 2.0.0-alpha.1 → 2.0.0-alpha.2
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 +6 -4
- package/dist/index.d.ts +7 -7
- package/dist/index.js +50 -28
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -81,12 +81,13 @@ export declare function createOrGetUserToken(
|
|
|
81
81
|
): Promise<UserToken>;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* Join `url` with `baseUrl` if `url` is not an absolute url
|
|
84
|
+
* Join `url` with `baseUrl` if `url` is not an absolute (full) url string
|
|
85
85
|
*
|
|
86
86
|
* @export
|
|
87
|
-
* @param {string} url
|
|
88
|
-
* @param {string} baseUrl
|
|
87
|
+
* @param {string} url A full url string or a url path string (/a/b/c).
|
|
88
|
+
* @param {string} baseUrl A baseUrl used to generate a full url when a url path string is supplied via the `url` parameter.
|
|
89
89
|
* @param {{ [key: string]: string }} [optionalQueries]
|
|
90
|
+
* @param {string[]} [allowedUrlHosts] Optional; when specify, the host of `url` parameter will only be used if it is included by this list.
|
|
90
91
|
* @returns
|
|
91
92
|
*/
|
|
92
93
|
export declare function getAbsoluteUrl(
|
|
@@ -94,7 +95,8 @@ export declare function getAbsoluteUrl(
|
|
|
94
95
|
baseUrl: string,
|
|
95
96
|
optionalQueries?: {
|
|
96
97
|
[key: string]: string;
|
|
97
|
-
}
|
|
98
|
+
},
|
|
99
|
+
allowedUrlHosts?: string[]
|
|
98
100
|
): string;
|
|
99
101
|
|
|
100
102
|
export declare function redirectOnSuccess(
|
package/dist/index.d.ts
CHANGED
|
@@ -129,18 +129,18 @@ export declare const destroySession: typeof destroySession_2;
|
|
|
129
129
|
declare function destroySession_2(req: express.Request): Promise<void>;
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
|
-
* Join `url` with `baseUrl` if `url` is not an absolute url
|
|
132
|
+
* Join `url` with `baseUrl` if `url` is not an absolute (full) url string
|
|
133
133
|
*
|
|
134
134
|
* @export
|
|
135
|
-
* @param {string} url
|
|
136
|
-
* @param {string} baseUrl
|
|
137
|
-
* @param {{ [key: string]:
|
|
138
|
-
*
|
|
135
|
+
* @param {string} url A full url string or a url path string (/a/b/c).
|
|
136
|
+
* @param {string} baseUrl A baseUrl used to generate a full url when a url path string is supplied via the `url` parameter.
|
|
137
|
+
* @param {{ [key: string]: string }} [optionalQueries]
|
|
138
|
+
* @param {string[]} [allowedUrlHosts] Optional; when specify, the host of `url` parameter will only be used if it is included by this list.
|
|
139
139
|
* @returns
|
|
140
140
|
*/
|
|
141
141
|
export declare function getAbsoluteUrl(url: string, baseUrl: string, optionalQueries?: {
|
|
142
|
-
[key: string]:
|
|
143
|
-
}): string;
|
|
142
|
+
[key: string]: string;
|
|
143
|
+
}, allowedUrlHosts?: string[]): string;
|
|
144
144
|
|
|
145
145
|
export declare function getSessionId(req: express.Request, secret?: string): string;
|
|
146
146
|
|
package/dist/index.js
CHANGED
|
@@ -9237,7 +9237,7 @@ function defineMethod(obj, name, fn) {
|
|
|
9237
9237
|
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
|
9238
9238
|
* URI.js - Mutating URLs
|
|
9239
9239
|
*
|
|
9240
|
-
* Version: 1.19.
|
|
9240
|
+
* Version: 1.19.11
|
|
9241
9241
|
*
|
|
9242
9242
|
* Author: Rodney Rehm
|
|
9243
9243
|
* Web: http://medialize.github.io/URI.js/
|
|
@@ -9317,7 +9317,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
9317
9317
|
return /^[0-9]+$/.test(value);
|
|
9318
9318
|
}
|
|
9319
9319
|
|
|
9320
|
-
URI.version = '1.19.
|
|
9320
|
+
URI.version = '1.19.11';
|
|
9321
9321
|
|
|
9322
9322
|
var p = URI.prototype;
|
|
9323
9323
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
@@ -9475,6 +9475,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
9475
9475
|
// balanced parens inclusion (), [], {}, <>
|
|
9476
9476
|
parens: /(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g,
|
|
9477
9477
|
};
|
|
9478
|
+
URI.leading_whitespace_expression = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/
|
|
9479
|
+
// https://infra.spec.whatwg.org/#ascii-tab-or-newline
|
|
9480
|
+
URI.ascii_tab_whitespace = /[\u0009\u000A\u000D]+/g
|
|
9478
9481
|
// http://www.iana.org/assignments/uri-schemes.html
|
|
9479
9482
|
// http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports
|
|
9480
9483
|
URI.defaultPorts = {
|
|
@@ -9730,6 +9733,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
9730
9733
|
preventInvalidHostname: URI.preventInvalidHostname
|
|
9731
9734
|
};
|
|
9732
9735
|
}
|
|
9736
|
+
|
|
9737
|
+
string = string.replace(URI.leading_whitespace_expression, '')
|
|
9738
|
+
// https://infra.spec.whatwg.org/#ascii-tab-or-newline
|
|
9739
|
+
string = string.replace(URI.ascii_tab_whitespace, '')
|
|
9740
|
+
|
|
9733
9741
|
// [protocol"://"[username[":"password]"@"]hostname[":"port]"/"?][path]["?"querystring]["#"fragment]
|
|
9734
9742
|
|
|
9735
9743
|
// extract fragment
|
|
@@ -9748,6 +9756,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
9748
9756
|
string = string.substring(0, pos);
|
|
9749
9757
|
}
|
|
9750
9758
|
|
|
9759
|
+
// slashes and backslashes have lost all meaning for the web protocols (https, http, wss, ws)
|
|
9760
|
+
string = string.replace(/^(https?|ftp|wss?)?:+[/\\]*/i, '$1://');
|
|
9761
|
+
// slashes and backslashes have lost all meaning for scheme relative URLs
|
|
9762
|
+
string = string.replace(/^[/\\]{2,}/i, '//');
|
|
9763
|
+
|
|
9751
9764
|
// extract protocol
|
|
9752
9765
|
if (string.substring(0, 2) === '//') {
|
|
9753
9766
|
// relative-scheme
|
|
@@ -9762,7 +9775,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
9762
9775
|
if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) {
|
|
9763
9776
|
// : may be within the path
|
|
9764
9777
|
parts.protocol = undefined;
|
|
9765
|
-
} else if (string.substring(pos + 1, pos + 3) === '//') {
|
|
9778
|
+
} else if (string.substring(pos + 1, pos + 3).replace(/\\/g, '/') === '//') {
|
|
9766
9779
|
string = string.substring(pos + 3);
|
|
9767
9780
|
|
|
9768
9781
|
// extract "user:pass@host:port"
|
|
@@ -9894,7 +9907,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
9894
9907
|
// no "=" is null according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#collect-url-parameters
|
|
9895
9908
|
value = v.length ? URI.decodeQuery(v.join('='), escapeQuerySpace) : null;
|
|
9896
9909
|
|
|
9897
|
-
if (
|
|
9910
|
+
if (name === '__proto__') {
|
|
9911
|
+
// ignore attempt at exploiting JavaScript internals
|
|
9912
|
+
continue;
|
|
9913
|
+
} else if (hasOwn.call(items, name)) {
|
|
9898
9914
|
if (typeof items[name] === 'string' || items[name] === null) {
|
|
9899
9915
|
items[name] = [items[name]];
|
|
9900
9916
|
}
|
|
@@ -9987,7 +10003,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
9987
10003
|
var t = '';
|
|
9988
10004
|
var unique, key, i, length;
|
|
9989
10005
|
for (key in data) {
|
|
9990
|
-
if (
|
|
10006
|
+
if (key === '__proto__') {
|
|
10007
|
+
// ignore attempt at exploiting JavaScript internals
|
|
10008
|
+
continue;
|
|
10009
|
+
} else if (hasOwn.call(data, key)) {
|
|
9991
10010
|
if (isArray(data[key])) {
|
|
9992
10011
|
unique = {};
|
|
9993
10012
|
for (i = 0, length = data[key].length; i < length; i++) {
|
|
@@ -12115,7 +12134,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
|
|
12115
12134
|
* URI.js - Mutating URLs
|
|
12116
12135
|
* IPv6 Support
|
|
12117
12136
|
*
|
|
12118
|
-
* Version: 1.19.
|
|
12137
|
+
* Version: 1.19.11
|
|
12119
12138
|
*
|
|
12120
12139
|
* Author: Rodney Rehm
|
|
12121
12140
|
* Web: http://medialize.github.io/URI.js/
|
|
@@ -12307,7 +12326,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
|
|
12307
12326
|
* URI.js - Mutating URLs
|
|
12308
12327
|
* Second Level Domain (SLD) Support
|
|
12309
12328
|
*
|
|
12310
|
-
* Version: 1.19.
|
|
12329
|
+
* Version: 1.19.11
|
|
12311
12330
|
*
|
|
12312
12331
|
* Author: Rodney Rehm
|
|
12313
12332
|
* Web: http://medialize.github.io/URI.js/
|
|
@@ -26628,32 +26647,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26628
26647
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26629
26648
|
const urijs_1 = __importDefault(__webpack_require__(61));
|
|
26630
26649
|
/**
|
|
26631
|
-
* Join `url` with `baseUrl` if `url` is not an absolute url
|
|
26650
|
+
* Join `url` with `baseUrl` if `url` is not an absolute (full) url string
|
|
26632
26651
|
*
|
|
26633
26652
|
* @export
|
|
26634
|
-
* @param {string} url
|
|
26635
|
-
* @param {string} baseUrl
|
|
26636
|
-
* @param {{ [key: string]:
|
|
26637
|
-
*
|
|
26653
|
+
* @param {string} url A full url string or a url path string (/a/b/c).
|
|
26654
|
+
* @param {string} baseUrl A baseUrl used to generate a full url when a url path string is supplied via the `url` parameter.
|
|
26655
|
+
* @param {{ [key: string]: string }} [optionalQueries]
|
|
26656
|
+
* @param {string[]} [allowedUrlHosts] Optional; when specify, the host of `url` parameter will only be used if it is included by this list.
|
|
26638
26657
|
* @returns
|
|
26639
26658
|
*/
|
|
26640
|
-
function getAbsoluteUrl(url, baseUrl, optionalQueries) {
|
|
26659
|
+
function getAbsoluteUrl(url, baseUrl, optionalQueries, allowedUrlHosts) {
|
|
26641
26660
|
const uri = urijs_1.default(url);
|
|
26642
|
-
|
|
26643
|
-
|
|
26644
|
-
return
|
|
26645
|
-
|
|
26646
|
-
|
|
26647
|
-
|
|
26648
|
-
|
|
26649
|
-
|
|
26650
|
-
|
|
26651
|
-
|
|
26652
|
-
|
|
26653
|
-
|
|
26654
|
-
|
|
26655
|
-
|
|
26656
|
-
|
|
26661
|
+
const urlHost = uri.host();
|
|
26662
|
+
if (urlHost) {
|
|
26663
|
+
// --- absolute url, return directly only if the urlHost is included by `allowedUrlHosts` (unless `allowedUrlHosts` is not supplied)
|
|
26664
|
+
if (!allowedUrlHosts ||
|
|
26665
|
+
allowedUrlHosts.findIndex((item) => item === urlHost) !== -1) {
|
|
26666
|
+
return url;
|
|
26667
|
+
}
|
|
26668
|
+
}
|
|
26669
|
+
// ignore url host of `host` if any and use `baseUrl` to create the final full url string
|
|
26670
|
+
if (typeof baseUrl !== "string") {
|
|
26671
|
+
baseUrl = "";
|
|
26672
|
+
}
|
|
26673
|
+
const baseUri = urijs_1.default(baseUrl);
|
|
26674
|
+
const query = uri.search(true);
|
|
26675
|
+
const mergedUri = baseUri.segmentCoded(baseUri.segmentCoded().concat(uri.segmentCoded()));
|
|
26676
|
+
return mergedUri
|
|
26677
|
+
.search(Object.assign(Object.assign({}, (query ? query : {})), (optionalQueries ? optionalQueries : {})))
|
|
26678
|
+
.toString();
|
|
26657
26679
|
}
|
|
26658
26680
|
exports.default = getAbsoluteUrl;
|
|
26659
26681
|
//# sourceMappingURL=getAbsoluteUrl.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magda/authentication-plugin-sdk",
|
|
3
3
|
"description": "MAGDA Authentication Plugin SDK",
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
4
|
+
"version": "2.0.0-alpha.2",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prebuild": "rimraf dist tsconfig.tsbuildinfo",
|
|
7
7
|
"build": "webpack && api-extractor run -l",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@magda/auth-api-client": "^2.0.0-alpha.
|
|
16
|
-
"@magda/typescript-common": "^2.0.0-alpha.
|
|
15
|
+
"@magda/auth-api-client": "^2.0.0-alpha.2",
|
|
16
|
+
"@magda/typescript-common": "^2.0.0-alpha.2",
|
|
17
17
|
"@types/express": "^4.17.6",
|
|
18
18
|
"@types/express-session": "^1.15.15",
|
|
19
19
|
"@types/lodash": "^4.14.74",
|
|
20
20
|
"@types/passport": "^1.0.3",
|
|
21
|
-
"@types/pg": "^
|
|
22
|
-
"@types/urijs": "1.19.
|
|
21
|
+
"@types/pg": "^7.14.4",
|
|
22
|
+
"@types/urijs": "^1.19.19",
|
|
23
23
|
"ts-loader": "^6.2.1",
|
|
24
24
|
"typescript": "^3.7.2",
|
|
25
25
|
"webpack": "^4.41.2",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"express": "^4.17.1",
|
|
32
32
|
"express-session": "^1.17.1",
|
|
33
33
|
"lodash": "^4.17.4",
|
|
34
|
-
"pg": "^
|
|
35
|
-
"urijs": "^1.19.
|
|
34
|
+
"pg": "^7.18.2",
|
|
35
|
+
"urijs": "^1.19.11"
|
|
36
36
|
},
|
|
37
37
|
"magda": {
|
|
38
38
|
"language": "typescript",
|