bruce-models 7.1.117 → 7.1.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bruce-models.es5.js +60 -1
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +60 -1
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/util/url-utils.js +59 -0
- package/dist/lib/util/url-utils.js.map +1 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/util/url-utils.d.ts +21 -0
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -23997,6 +23997,8 @@
|
|
|
23997
23997
|
})(exports.EncryptUtils || (exports.EncryptUtils = {}));
|
|
23998
23998
|
|
|
23999
23999
|
(function (UrlUtils) {
|
|
24000
|
+
// The "S:{expires}.{signature}/" segment the API puts in the path of URLs it signs.
|
|
24001
|
+
const SIGNED_SEGMENT = /\/S:(\d+)\.[A-Za-z0-9_-]+\//;
|
|
24000
24002
|
/**
|
|
24001
24003
|
* Returns a url-safe string that is human readable.
|
|
24002
24004
|
* Eg: 'My Project View!' into 'My-Project-View'.
|
|
@@ -24026,6 +24028,52 @@
|
|
|
24026
24028
|
return urlObj.toString();
|
|
24027
24029
|
}
|
|
24028
24030
|
UrlUtils.AddQueryParam = AddQueryParam;
|
|
24031
|
+
/**
|
|
24032
|
+
* Removes every occurrence of a query parameter from a url.
|
|
24033
|
+
* Eg: RemoveQueryParam('http://example.com/?key=value&other=1', 'key') => 'http://example.com/?other=1'
|
|
24034
|
+
* @param url absolute or relative url.
|
|
24035
|
+
* @param key decoded name of the parameter to remove.
|
|
24036
|
+
* @returns
|
|
24037
|
+
*/
|
|
24038
|
+
function RemoveQueryParam(url, key) {
|
|
24039
|
+
if (!url) {
|
|
24040
|
+
return url;
|
|
24041
|
+
}
|
|
24042
|
+
const hashStart = url.indexOf("#");
|
|
24043
|
+
const hash = hashStart === -1 ? "" : url.substring(hashStart);
|
|
24044
|
+
const beforeHash = hashStart === -1 ? url : url.substring(0, hashStart);
|
|
24045
|
+
const queryStart = beforeHash.indexOf("?");
|
|
24046
|
+
if (queryStart === -1) {
|
|
24047
|
+
return url;
|
|
24048
|
+
}
|
|
24049
|
+
// Works on the raw string so the parameters that stay keep their exact encoding, which a signed query depends on.
|
|
24050
|
+
const kept = beforeHash.substring(queryStart + 1).split("&").filter(pair => {
|
|
24051
|
+
return decodeQueryName(pair.split("=")[0]) !== key;
|
|
24052
|
+
});
|
|
24053
|
+
const query = kept.length ? "?" + kept.join("&") : "";
|
|
24054
|
+
return beforeHash.substring(0, queryStart) + query + hash;
|
|
24055
|
+
}
|
|
24056
|
+
UrlUtils.RemoveQueryParam = RemoveQueryParam;
|
|
24057
|
+
/**
|
|
24058
|
+
* Returns true when the url carries an API signature that has not expired, so it authorises itself.
|
|
24059
|
+
* @param url
|
|
24060
|
+
* @returns
|
|
24061
|
+
*/
|
|
24062
|
+
function IsSignedUrl(url) {
|
|
24063
|
+
const match = url === null || url === void 0 ? void 0 : url.match(SIGNED_SEGMENT);
|
|
24064
|
+
return !!match && Number(match[1]) * 1000 > Date.now();
|
|
24065
|
+
}
|
|
24066
|
+
UrlUtils.IsSignedUrl = IsSignedUrl;
|
|
24067
|
+
/**
|
|
24068
|
+
* Removes the API signature from a url.
|
|
24069
|
+
* Eg: comparing two urls for the same file that were signed at different times, or a link leaving the app that should grant no more than the reader's own access.
|
|
24070
|
+
* @param url
|
|
24071
|
+
* @returns
|
|
24072
|
+
*/
|
|
24073
|
+
function RemoveSignature(url) {
|
|
24074
|
+
return url ? url.replace(SIGNED_SEGMENT, "/") : url;
|
|
24075
|
+
}
|
|
24076
|
+
UrlUtils.RemoveSignature = RemoveSignature;
|
|
24029
24077
|
/**
|
|
24030
24078
|
* Returns a url with the provided url appended to the provided existing url.
|
|
24031
24079
|
* @param params
|
|
@@ -24078,6 +24126,17 @@
|
|
|
24078
24126
|
return full;
|
|
24079
24127
|
}
|
|
24080
24128
|
UrlUtils.ConstructUrl = ConstructUrl;
|
|
24129
|
+
/**
|
|
24130
|
+
* Decodes a query parameter name the way URLSearchParams does, keeping the raw name when it is malformed.
|
|
24131
|
+
*/
|
|
24132
|
+
function decodeQueryName(name) {
|
|
24133
|
+
try {
|
|
24134
|
+
return decodeURIComponent(name.replace(/\+/g, " "));
|
|
24135
|
+
}
|
|
24136
|
+
catch (_a) {
|
|
24137
|
+
return name;
|
|
24138
|
+
}
|
|
24139
|
+
}
|
|
24081
24140
|
})(exports.UrlUtils || (exports.UrlUtils = {}));
|
|
24082
24141
|
|
|
24083
24142
|
(function (WorkflowItem) {
|
|
@@ -24909,7 +24968,7 @@
|
|
|
24909
24968
|
}
|
|
24910
24969
|
|
|
24911
24970
|
// This is updated with the package.json version on build.
|
|
24912
|
-
const VERSION = "7.1.
|
|
24971
|
+
const VERSION = "7.1.118";
|
|
24913
24972
|
|
|
24914
24973
|
exports.VERSION = VERSION;
|
|
24915
24974
|
exports.AbstractApi = AbstractApi;
|