expensify-common 2.0.222 → 2.0.224
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/API.js +0 -26
- package/dist/ExpensiMark.js +12 -17
- package/dist/esm/API.js +0 -26
- package/dist/esm/ExpensiMark.js +12 -17
- package/package.json +1 -1
package/dist/API.js
CHANGED
|
@@ -410,32 +410,6 @@ function API(network, args) {
|
|
|
410
410
|
requireParameters(['email'], parameters, commandName);
|
|
411
411
|
return performPOSTRequest(commandName, parameters);
|
|
412
412
|
},
|
|
413
|
-
/**
|
|
414
|
-
* Resets the password for an account
|
|
415
|
-
* @param {Object} parameters
|
|
416
|
-
* @param {String} parameters.email
|
|
417
|
-
* @returns {ExpensifyAPIDeferred}
|
|
418
|
-
*/
|
|
419
|
-
resetPassword(parameters) {
|
|
420
|
-
const commandName = 'ResetPassword';
|
|
421
|
-
requireParameters(['email'], parameters, commandName);
|
|
422
|
-
const newParameters = Object.assign(Object.assign({}, parameters), { api_setCookie: false });
|
|
423
|
-
return performPOSTRequest(commandName, newParameters);
|
|
424
|
-
},
|
|
425
|
-
/**
|
|
426
|
-
* Sets the password for an account
|
|
427
|
-
*
|
|
428
|
-
* @param {Object} parameters
|
|
429
|
-
* @param {String} parameters.email
|
|
430
|
-
* @param {String} parameters.password
|
|
431
|
-
* @param {String} parameters.validateCode
|
|
432
|
-
* @returns {ExpensifyAPIDeferred}
|
|
433
|
-
*/
|
|
434
|
-
setPassword(parameters) {
|
|
435
|
-
const commandName = 'SetPassword';
|
|
436
|
-
requireParameters(['email', 'password', 'validateCode'], parameters, commandName);
|
|
437
|
-
return performPOSTRequest(commandName, parameters);
|
|
438
|
-
},
|
|
439
413
|
/**
|
|
440
414
|
* Validate a user
|
|
441
415
|
*
|
package/dist/ExpensiMark.js
CHANGED
|
@@ -269,14 +269,14 @@ function findKnownTldEnd(text, dotPosition) {
|
|
|
269
269
|
return undefined;
|
|
270
270
|
}
|
|
271
271
|
/**
|
|
272
|
-
* Validates a hostname and records a linkable prefix before a later
|
|
273
|
-
*
|
|
272
|
+
* Validates a hostname and records a linkable prefix before malformed punctuation in a later label.
|
|
273
|
+
* Rejects the whole hostname when a label or its complete length exceeds a DNS limit.
|
|
274
274
|
*
|
|
275
275
|
* @param text - Text containing the URL candidate.
|
|
276
276
|
* @param hostnameStart - Index of the hostname's first character.
|
|
277
277
|
* @param hostnameEnd - Index immediately after the hostname.
|
|
278
278
|
* @param hasProtocol - Whether the URL allows hostnames without a known TLD, including single-label hosts.
|
|
279
|
-
* @returns The hostname validity and any prefix that can be linked before
|
|
279
|
+
* @returns The hostname validity and any prefix that can be linked before malformed punctuation.
|
|
280
280
|
*/
|
|
281
281
|
function analyzeHostname(text, hostnameStart, hostnameEnd, hasProtocol) {
|
|
282
282
|
let hostnameContentEnd = hostnameEnd;
|
|
@@ -288,7 +288,6 @@ function analyzeHostname(text, hostnameStart, hostnameEnd, hasProtocol) {
|
|
|
288
288
|
}
|
|
289
289
|
let labelStart = hostnameStart;
|
|
290
290
|
let validHostnamePrefixEnd;
|
|
291
|
-
let validKnownTldPrefixEnd;
|
|
292
291
|
for (let index = hostnameStart; index <= hostnameContentEnd; index++) {
|
|
293
292
|
if (index !== hostnameContentEnd && text[index] !== '.') {
|
|
294
293
|
continue;
|
|
@@ -303,7 +302,7 @@ function analyzeHostname(text, hostnameStart, hostnameEnd, hasProtocol) {
|
|
|
303
302
|
labelContentEnd--;
|
|
304
303
|
}
|
|
305
304
|
if (labelContentEnd - labelStart > Constants.MAX_URL_HOSTNAME_LABEL_LENGTH || labelContentEnd - hostnameStart > Constants.MAX_URL_HOSTNAME_LENGTH) {
|
|
306
|
-
return { isValid: false
|
|
305
|
+
return { isValid: false };
|
|
307
306
|
}
|
|
308
307
|
// Protocol URLs can end at any valid label; bare URLs still need a known TLD.
|
|
309
308
|
if (hasProtocol) {
|
|
@@ -312,13 +311,10 @@ function analyzeHostname(text, hostnameStart, hostnameEnd, hasProtocol) {
|
|
|
312
311
|
if (validLabelEnd !== index) {
|
|
313
312
|
return { isValid: false, validHostnamePrefixEnd };
|
|
314
313
|
}
|
|
315
|
-
if (index !== hostnameContentEnd) {
|
|
314
|
+
if (!hasProtocol && index !== hostnameContentEnd) {
|
|
316
315
|
const tldEnd = findKnownTldEnd(text, index);
|
|
317
316
|
if (tldEnd !== undefined && tldEnd <= hostnameContentEnd && tldEnd - hostnameStart <= Constants.MAX_URL_HOSTNAME_LENGTH) {
|
|
318
|
-
|
|
319
|
-
if (!hasProtocol) {
|
|
320
|
-
validHostnamePrefixEnd = tldEnd;
|
|
321
|
-
}
|
|
317
|
+
validHostnamePrefixEnd = tldEnd;
|
|
322
318
|
}
|
|
323
319
|
}
|
|
324
320
|
labelStart = index + 1;
|
|
@@ -1782,21 +1778,20 @@ class ExpensiMark {
|
|
|
1782
1778
|
const invalidUrlRanges = shouldRejectPartialHostnameMatches ? findInvalidUrlRanges(textWithContext) : [];
|
|
1783
1779
|
const maskedText = invalidUrlRanges.length > 0 ? maskInvalidUrlRanges(textWithContext, invalidUrlRanges) : textWithContext;
|
|
1784
1780
|
const textToMatch = maskedText.slice(0, textToCheck.length);
|
|
1785
|
-
const contextRegex = followingText ? new RegExp(regex.source, regex.flags.replace('g', 'y')) : undefined;
|
|
1781
|
+
const contextRegex = followingText || invalidUrlRanges.length > 0 ? new RegExp(regex.source, regex.flags.replace('g', 'y')) : undefined;
|
|
1786
1782
|
let match = matchingRegex.exec(textToMatch);
|
|
1787
1783
|
let replacedText = '';
|
|
1788
1784
|
let startIndex = 0;
|
|
1789
1785
|
while (match !== null) {
|
|
1790
|
-
|
|
1791
|
-
|
|
1786
|
+
const matchEnd = match.index + match[0].length;
|
|
1787
|
+
if (contextRegex && (textWithContext[matchEnd] === '@' || (followingText.length > 0 && matchEnd === textToCheck.length))) {
|
|
1788
|
+
// Check the original context so masking cannot turn an email's local part into a URL.
|
|
1792
1789
|
contextRegex.lastIndex = match.index;
|
|
1793
|
-
const contextMatch = contextRegex.exec(
|
|
1794
|
-
if (contextMatch === null) {
|
|
1790
|
+
const contextMatch = contextRegex.exec(textWithContext);
|
|
1791
|
+
if (contextMatch === null || contextMatch[0].length < match[0].length) {
|
|
1795
1792
|
match = matchingRegex.exec(textToMatch);
|
|
1796
1793
|
continue;
|
|
1797
1794
|
}
|
|
1798
|
-
match = contextMatch;
|
|
1799
|
-
matchingRegex.lastIndex = contextRegex.lastIndex;
|
|
1800
1795
|
}
|
|
1801
1796
|
let url = match[2];
|
|
1802
1797
|
const urlEnd = findUrlEndBeforeUnmatchedParenthesis(url, 0, url.length);
|
package/dist/esm/API.js
CHANGED
|
@@ -371,32 +371,6 @@ export default function API(network, args) {
|
|
|
371
371
|
requireParameters(['email'], parameters, commandName);
|
|
372
372
|
return performPOSTRequest(commandName, parameters);
|
|
373
373
|
},
|
|
374
|
-
/**
|
|
375
|
-
* Resets the password for an account
|
|
376
|
-
* @param {Object} parameters
|
|
377
|
-
* @param {String} parameters.email
|
|
378
|
-
* @returns {ExpensifyAPIDeferred}
|
|
379
|
-
*/
|
|
380
|
-
resetPassword(parameters) {
|
|
381
|
-
const commandName = 'ResetPassword';
|
|
382
|
-
requireParameters(['email'], parameters, commandName);
|
|
383
|
-
const newParameters = Object.assign(Object.assign({}, parameters), { api_setCookie: false });
|
|
384
|
-
return performPOSTRequest(commandName, newParameters);
|
|
385
|
-
},
|
|
386
|
-
/**
|
|
387
|
-
* Sets the password for an account
|
|
388
|
-
*
|
|
389
|
-
* @param {Object} parameters
|
|
390
|
-
* @param {String} parameters.email
|
|
391
|
-
* @param {String} parameters.password
|
|
392
|
-
* @param {String} parameters.validateCode
|
|
393
|
-
* @returns {ExpensifyAPIDeferred}
|
|
394
|
-
*/
|
|
395
|
-
setPassword(parameters) {
|
|
396
|
-
const commandName = 'SetPassword';
|
|
397
|
-
requireParameters(['email', 'password', 'validateCode'], parameters, commandName);
|
|
398
|
-
return performPOSTRequest(commandName, parameters);
|
|
399
|
-
},
|
|
400
374
|
/**
|
|
401
375
|
* Validate a user
|
|
402
376
|
*
|
package/dist/esm/ExpensiMark.js
CHANGED
|
@@ -231,14 +231,14 @@ function findKnownTldEnd(text, dotPosition) {
|
|
|
231
231
|
return undefined;
|
|
232
232
|
}
|
|
233
233
|
/**
|
|
234
|
-
* Validates a hostname and records a linkable prefix before a later
|
|
235
|
-
*
|
|
234
|
+
* Validates a hostname and records a linkable prefix before malformed punctuation in a later label.
|
|
235
|
+
* Rejects the whole hostname when a label or its complete length exceeds a DNS limit.
|
|
236
236
|
*
|
|
237
237
|
* @param text - Text containing the URL candidate.
|
|
238
238
|
* @param hostnameStart - Index of the hostname's first character.
|
|
239
239
|
* @param hostnameEnd - Index immediately after the hostname.
|
|
240
240
|
* @param hasProtocol - Whether the URL allows hostnames without a known TLD, including single-label hosts.
|
|
241
|
-
* @returns The hostname validity and any prefix that can be linked before
|
|
241
|
+
* @returns The hostname validity and any prefix that can be linked before malformed punctuation.
|
|
242
242
|
*/
|
|
243
243
|
function analyzeHostname(text, hostnameStart, hostnameEnd, hasProtocol) {
|
|
244
244
|
let hostnameContentEnd = hostnameEnd;
|
|
@@ -250,7 +250,6 @@ function analyzeHostname(text, hostnameStart, hostnameEnd, hasProtocol) {
|
|
|
250
250
|
}
|
|
251
251
|
let labelStart = hostnameStart;
|
|
252
252
|
let validHostnamePrefixEnd;
|
|
253
|
-
let validKnownTldPrefixEnd;
|
|
254
253
|
for (let index = hostnameStart; index <= hostnameContentEnd; index++) {
|
|
255
254
|
if (index !== hostnameContentEnd && text[index] !== '.') {
|
|
256
255
|
continue;
|
|
@@ -265,7 +264,7 @@ function analyzeHostname(text, hostnameStart, hostnameEnd, hasProtocol) {
|
|
|
265
264
|
labelContentEnd--;
|
|
266
265
|
}
|
|
267
266
|
if (labelContentEnd - labelStart > Constants.MAX_URL_HOSTNAME_LABEL_LENGTH || labelContentEnd - hostnameStart > Constants.MAX_URL_HOSTNAME_LENGTH) {
|
|
268
|
-
return { isValid: false
|
|
267
|
+
return { isValid: false };
|
|
269
268
|
}
|
|
270
269
|
// Protocol URLs can end at any valid label; bare URLs still need a known TLD.
|
|
271
270
|
if (hasProtocol) {
|
|
@@ -274,13 +273,10 @@ function analyzeHostname(text, hostnameStart, hostnameEnd, hasProtocol) {
|
|
|
274
273
|
if (validLabelEnd !== index) {
|
|
275
274
|
return { isValid: false, validHostnamePrefixEnd };
|
|
276
275
|
}
|
|
277
|
-
if (index !== hostnameContentEnd) {
|
|
276
|
+
if (!hasProtocol && index !== hostnameContentEnd) {
|
|
278
277
|
const tldEnd = findKnownTldEnd(text, index);
|
|
279
278
|
if (tldEnd !== undefined && tldEnd <= hostnameContentEnd && tldEnd - hostnameStart <= Constants.MAX_URL_HOSTNAME_LENGTH) {
|
|
280
|
-
|
|
281
|
-
if (!hasProtocol) {
|
|
282
|
-
validHostnamePrefixEnd = tldEnd;
|
|
283
|
-
}
|
|
279
|
+
validHostnamePrefixEnd = tldEnd;
|
|
284
280
|
}
|
|
285
281
|
}
|
|
286
282
|
labelStart = index + 1;
|
|
@@ -1744,21 +1740,20 @@ class ExpensiMark {
|
|
|
1744
1740
|
const invalidUrlRanges = shouldRejectPartialHostnameMatches ? findInvalidUrlRanges(textWithContext) : [];
|
|
1745
1741
|
const maskedText = invalidUrlRanges.length > 0 ? maskInvalidUrlRanges(textWithContext, invalidUrlRanges) : textWithContext;
|
|
1746
1742
|
const textToMatch = maskedText.slice(0, textToCheck.length);
|
|
1747
|
-
const contextRegex = followingText ? new RegExp(regex.source, regex.flags.replace('g', 'y')) : undefined;
|
|
1743
|
+
const contextRegex = followingText || invalidUrlRanges.length > 0 ? new RegExp(regex.source, regex.flags.replace('g', 'y')) : undefined;
|
|
1748
1744
|
let match = matchingRegex.exec(textToMatch);
|
|
1749
1745
|
let replacedText = '';
|
|
1750
1746
|
let startIndex = 0;
|
|
1751
1747
|
while (match !== null) {
|
|
1752
|
-
|
|
1753
|
-
|
|
1748
|
+
const matchEnd = match.index + match[0].length;
|
|
1749
|
+
if (contextRegex && (textWithContext[matchEnd] === '@' || (followingText.length > 0 && matchEnd === textToCheck.length))) {
|
|
1750
|
+
// Check the original context so masking cannot turn an email's local part into a URL.
|
|
1754
1751
|
contextRegex.lastIndex = match.index;
|
|
1755
|
-
const contextMatch = contextRegex.exec(
|
|
1756
|
-
if (contextMatch === null) {
|
|
1752
|
+
const contextMatch = contextRegex.exec(textWithContext);
|
|
1753
|
+
if (contextMatch === null || contextMatch[0].length < match[0].length) {
|
|
1757
1754
|
match = matchingRegex.exec(textToMatch);
|
|
1758
1755
|
continue;
|
|
1759
1756
|
}
|
|
1760
|
-
match = contextMatch;
|
|
1761
|
-
matchingRegex.lastIndex = contextRegex.lastIndex;
|
|
1762
1757
|
}
|
|
1763
1758
|
let url = match[2];
|
|
1764
1759
|
const urlEnd = findUrlEndBeforeUnmatchedParenthesis(url, 0, url.length);
|