expensify-common 2.0.188 → 2.0.190
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/Logger.js +11 -1
- package/dist/esm/API.d.ts +11 -0
- package/dist/esm/API.js +786 -0
- package/dist/esm/APIDeferred.d.ts +7 -0
- package/dist/esm/APIDeferred.js +216 -0
- package/dist/esm/BrowserDetect.d.ts +19 -0
- package/dist/esm/BrowserDetect.js +105 -0
- package/dist/esm/CLI.js +37 -29
- package/dist/esm/CONST.d.ts +1727 -0
- package/dist/esm/CONST.js +1847 -0
- package/dist/esm/Cookie.d.ts +68 -0
- package/dist/esm/Cookie.js +159 -0
- package/dist/esm/CredentialsWrapper.d.ts +32 -0
- package/dist/esm/CredentialsWrapper.js +46 -0
- package/dist/esm/Device.d.ts +8 -0
- package/dist/esm/Device.js +24 -0
- package/dist/esm/ExpenseRule.d.ts +39 -0
- package/dist/esm/ExpenseRule.js +77 -0
- package/dist/esm/ExpensiMark.d.ts +197 -0
- package/dist/esm/ExpensiMark.js +1374 -0
- package/dist/esm/Func.d.ts +40 -0
- package/dist/esm/Func.js +69 -0
- package/dist/esm/Log.d.ts +3 -0
- package/dist/esm/Log.js +35 -0
- package/dist/esm/Logger.d.ts +82 -0
- package/dist/esm/Logger.js +148 -0
- package/dist/esm/Network.d.ts +6 -0
- package/dist/esm/Network.js +168 -0
- package/dist/esm/Num.d.ts +95 -0
- package/dist/esm/Num.js +190 -0
- package/dist/esm/PageEvent.d.ts +25 -0
- package/dist/esm/PageEvent.js +22 -0
- package/dist/esm/PubSub.d.ts +2 -0
- package/dist/esm/PubSub.js +111 -0
- package/dist/esm/ReportHistoryStore.d.ts +8 -0
- package/dist/esm/ReportHistoryStore.js +199 -0
- package/dist/esm/SafeString.js +2 -2
- package/dist/esm/Templates.d.ts +58 -0
- package/dist/esm/Templates.js +196 -0
- package/dist/esm/Url.d.ts +10 -0
- package/dist/esm/Url.js +15 -0
- package/dist/esm/components/CopyText.d.ts +45 -0
- package/dist/esm/components/CopyText.js +56 -0
- package/dist/esm/components/StepProgressBar.d.ts +26 -0
- package/dist/esm/components/StepProgressBar.js +40 -0
- package/dist/esm/components/form/element/combobox.d.ts +231 -0
- package/dist/esm/components/form/element/combobox.js +812 -0
- package/dist/esm/components/form/element/dropdown.d.ts +35 -0
- package/dist/esm/components/form/element/dropdown.js +61 -0
- package/dist/esm/components/form/element/dropdownItem.d.ts +55 -0
- package/dist/esm/components/form/element/dropdownItem.js +113 -0
- package/dist/esm/components/form/element/onOffSwitch.d.ts +94 -0
- package/dist/esm/components/form/element/onOffSwitch.js +167 -0
- package/dist/esm/components/form/element/switch.d.ts +58 -0
- package/dist/esm/components/form/element/switch.js +98 -0
- package/dist/esm/fastMerge.d.ts +9 -0
- package/dist/esm/fastMerge.js +58 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/jquery.expensifyIframify.d.ts +9 -0
- package/dist/esm/jquery.expensifyIframify.js +397 -0
- package/dist/esm/md5.d.ts +2 -0
- package/dist/esm/md5.js +170 -0
- package/dist/esm/mixins/PubSub.d.ts +20 -0
- package/dist/esm/mixins/PubSub.js +47 -0
- package/dist/esm/mixins/extraClasses.d.ts +8 -0
- package/dist/esm/mixins/extraClasses.js +37 -0
- package/dist/esm/mixins/validationClasses.d.ts +12 -0
- package/dist/esm/mixins/validationClasses.js +30 -0
- package/dist/esm/str.d.ts +604 -0
- package/dist/esm/str.js +1036 -0
- package/dist/esm/tlds.d.ts +2 -0
- package/dist/esm/tlds.js +2 -0
- package/dist/esm/utils.d.ts +30 -0
- package/dist/esm/utils.js +65 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -1
- package/package.json +221 -4
package/dist/esm/md5.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/* eslint-disable one-var, no-var, no-param-reassign, no-bitwise, eqeqeq, @typescript-eslint/no-unused-vars, no-shadow */
|
|
2
|
+
/**
|
|
3
|
+
* md5 hash implementation
|
|
4
|
+
* http://www.myersdaily.org/joseph/javascript/md5-text.html
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
function add32(a, b) {
|
|
8
|
+
return (a + b) & 0xffffffff;
|
|
9
|
+
}
|
|
10
|
+
function cmn(q, a, b, x, s, t) {
|
|
11
|
+
a = add32(add32(a, q), add32(x, t));
|
|
12
|
+
return add32((a << s) | (a >>> (32 - s)), b);
|
|
13
|
+
}
|
|
14
|
+
function ff(a, b, c, d, x, s, t) {
|
|
15
|
+
return cmn((b & c) | (~b & d), a, b, x, s, t);
|
|
16
|
+
}
|
|
17
|
+
function gg(a, b, c, d, x, s, t) {
|
|
18
|
+
return cmn((b & d) | (c & ~d), a, b, x, s, t);
|
|
19
|
+
}
|
|
20
|
+
function hh(a, b, c, d, x, s, t) {
|
|
21
|
+
return cmn(b ^ c ^ d, a, b, x, s, t);
|
|
22
|
+
}
|
|
23
|
+
function ii(a, b, c, d, x, s, t) {
|
|
24
|
+
return cmn(c ^ (b | ~d), a, b, x, s, t);
|
|
25
|
+
}
|
|
26
|
+
function md5blk(s) {
|
|
27
|
+
/* I figured global was faster. */
|
|
28
|
+
var md5blks = [], i; /* Andy King said do it this way. */
|
|
29
|
+
for (i = 0; i < 64; i += 4) {
|
|
30
|
+
md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24);
|
|
31
|
+
}
|
|
32
|
+
return md5blks;
|
|
33
|
+
}
|
|
34
|
+
function md5cycle(x, k) {
|
|
35
|
+
var a = x[0], b = x[1], c = x[2], d = x[3];
|
|
36
|
+
a = ff(a, b, c, d, k[0], 7, -680876936);
|
|
37
|
+
d = ff(d, a, b, c, k[1], 12, -389564586);
|
|
38
|
+
c = ff(c, d, a, b, k[2], 17, 606105819);
|
|
39
|
+
b = ff(b, c, d, a, k[3], 22, -1044525330);
|
|
40
|
+
a = ff(a, b, c, d, k[4], 7, -176418897);
|
|
41
|
+
d = ff(d, a, b, c, k[5], 12, 1200080426);
|
|
42
|
+
c = ff(c, d, a, b, k[6], 17, -1473231341);
|
|
43
|
+
b = ff(b, c, d, a, k[7], 22, -45705983);
|
|
44
|
+
a = ff(a, b, c, d, k[8], 7, 1770035416);
|
|
45
|
+
d = ff(d, a, b, c, k[9], 12, -1958414417);
|
|
46
|
+
c = ff(c, d, a, b, k[10], 17, -42063);
|
|
47
|
+
b = ff(b, c, d, a, k[11], 22, -1990404162);
|
|
48
|
+
a = ff(a, b, c, d, k[12], 7, 1804603682);
|
|
49
|
+
d = ff(d, a, b, c, k[13], 12, -40341101);
|
|
50
|
+
c = ff(c, d, a, b, k[14], 17, -1502002290);
|
|
51
|
+
b = ff(b, c, d, a, k[15], 22, 1236535329);
|
|
52
|
+
a = gg(a, b, c, d, k[1], 5, -165796510);
|
|
53
|
+
d = gg(d, a, b, c, k[6], 9, -1069501632);
|
|
54
|
+
c = gg(c, d, a, b, k[11], 14, 643717713);
|
|
55
|
+
b = gg(b, c, d, a, k[0], 20, -373897302);
|
|
56
|
+
a = gg(a, b, c, d, k[5], 5, -701558691);
|
|
57
|
+
d = gg(d, a, b, c, k[10], 9, 38016083);
|
|
58
|
+
c = gg(c, d, a, b, k[15], 14, -660478335);
|
|
59
|
+
b = gg(b, c, d, a, k[4], 20, -405537848);
|
|
60
|
+
a = gg(a, b, c, d, k[9], 5, 568446438);
|
|
61
|
+
d = gg(d, a, b, c, k[14], 9, -1019803690);
|
|
62
|
+
c = gg(c, d, a, b, k[3], 14, -187363961);
|
|
63
|
+
b = gg(b, c, d, a, k[8], 20, 1163531501);
|
|
64
|
+
a = gg(a, b, c, d, k[13], 5, -1444681467);
|
|
65
|
+
d = gg(d, a, b, c, k[2], 9, -51403784);
|
|
66
|
+
c = gg(c, d, a, b, k[7], 14, 1735328473);
|
|
67
|
+
b = gg(b, c, d, a, k[12], 20, -1926607734);
|
|
68
|
+
a = hh(a, b, c, d, k[5], 4, -378558);
|
|
69
|
+
d = hh(d, a, b, c, k[8], 11, -2022574463);
|
|
70
|
+
c = hh(c, d, a, b, k[11], 16, 1839030562);
|
|
71
|
+
b = hh(b, c, d, a, k[14], 23, -35309556);
|
|
72
|
+
a = hh(a, b, c, d, k[1], 4, -1530992060);
|
|
73
|
+
d = hh(d, a, b, c, k[4], 11, 1272893353);
|
|
74
|
+
c = hh(c, d, a, b, k[7], 16, -155497632);
|
|
75
|
+
b = hh(b, c, d, a, k[10], 23, -1094730640);
|
|
76
|
+
a = hh(a, b, c, d, k[13], 4, 681279174);
|
|
77
|
+
d = hh(d, a, b, c, k[0], 11, -358537222);
|
|
78
|
+
c = hh(c, d, a, b, k[3], 16, -722521979);
|
|
79
|
+
b = hh(b, c, d, a, k[6], 23, 76029189);
|
|
80
|
+
a = hh(a, b, c, d, k[9], 4, -640364487);
|
|
81
|
+
d = hh(d, a, b, c, k[12], 11, -421815835);
|
|
82
|
+
c = hh(c, d, a, b, k[15], 16, 530742520);
|
|
83
|
+
b = hh(b, c, d, a, k[2], 23, -995338651);
|
|
84
|
+
a = ii(a, b, c, d, k[0], 6, -198630844);
|
|
85
|
+
d = ii(d, a, b, c, k[7], 10, 1126891415);
|
|
86
|
+
c = ii(c, d, a, b, k[14], 15, -1416354905);
|
|
87
|
+
b = ii(b, c, d, a, k[5], 21, -57434055);
|
|
88
|
+
a = ii(a, b, c, d, k[12], 6, 1700485571);
|
|
89
|
+
d = ii(d, a, b, c, k[3], 10, -1894986606);
|
|
90
|
+
c = ii(c, d, a, b, k[10], 15, -1051523);
|
|
91
|
+
b = ii(b, c, d, a, k[1], 21, -2054922799);
|
|
92
|
+
a = ii(a, b, c, d, k[8], 6, 1873313359);
|
|
93
|
+
d = ii(d, a, b, c, k[15], 10, -30611744);
|
|
94
|
+
c = ii(c, d, a, b, k[6], 15, -1560198380);
|
|
95
|
+
b = ii(b, c, d, a, k[13], 21, 1309151649);
|
|
96
|
+
a = ii(a, b, c, d, k[4], 6, -145523070);
|
|
97
|
+
d = ii(d, a, b, c, k[11], 10, -1120210379);
|
|
98
|
+
c = ii(c, d, a, b, k[2], 15, 718787259);
|
|
99
|
+
b = ii(b, c, d, a, k[9], 21, -343485551);
|
|
100
|
+
x[0] = add32(a, x[0]);
|
|
101
|
+
x[1] = add32(b, x[1]);
|
|
102
|
+
x[2] = add32(c, x[2]);
|
|
103
|
+
x[3] = add32(d, x[3]);
|
|
104
|
+
}
|
|
105
|
+
function md51(s) {
|
|
106
|
+
var n = s.length, state = [1732584193, -271733879, -1732584194, 271733878], i;
|
|
107
|
+
for (i = 64; i <= s.length; i += 64) {
|
|
108
|
+
md5cycle(state, md5blk(s.substring(i - 64, i)));
|
|
109
|
+
}
|
|
110
|
+
s = s.substring(i - 64);
|
|
111
|
+
var tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
112
|
+
for (i = 0; i < s.length; i++) {
|
|
113
|
+
tail[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3);
|
|
114
|
+
}
|
|
115
|
+
tail[i >> 2] |= 0x80 << (i % 4 << 3);
|
|
116
|
+
if (i > 55) {
|
|
117
|
+
md5cycle(state, tail);
|
|
118
|
+
for (i = 0; i < 16; i++) {
|
|
119
|
+
tail[i] = 0;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
tail[14] = n * 8;
|
|
123
|
+
md5cycle(state, tail);
|
|
124
|
+
return state;
|
|
125
|
+
}
|
|
126
|
+
/* there needs to be support for Unicode here,
|
|
127
|
+
* unless we pretend that we can redefine the MD-5
|
|
128
|
+
* algorithm for multi-byte characters (perhaps
|
|
129
|
+
* by adding every four 16-bit characters and
|
|
130
|
+
* shortening the sum to 32 bits). Otherwise
|
|
131
|
+
* I suggest performing MD-5 as if every character
|
|
132
|
+
* was two bytes--e.g., 0040 0025 = @%--but then
|
|
133
|
+
* how will an ordinary MD-5 sum be matched?
|
|
134
|
+
* There is no way to standardize text to something
|
|
135
|
+
* like UTF-8 before transformation; speed cost is
|
|
136
|
+
* utterly prohibitive. The JavaScript standard
|
|
137
|
+
* itself needs to look at this: it should start
|
|
138
|
+
* providing access to strings as preformed UTF-8
|
|
139
|
+
* 8-bit unsigned value arrays.
|
|
140
|
+
*/
|
|
141
|
+
var hex_chr = '0123456789abcdef'.split('');
|
|
142
|
+
function rhex(n) {
|
|
143
|
+
var s = '', j = 0;
|
|
144
|
+
for (; j < 4; j++) {
|
|
145
|
+
const shift = j * 8;
|
|
146
|
+
s += hex_chr[(n >> (shift + 4)) & 0x0f] + hex_chr[(n >> shift) & 0x0f];
|
|
147
|
+
}
|
|
148
|
+
return s;
|
|
149
|
+
}
|
|
150
|
+
function hex(x) {
|
|
151
|
+
for (var i = 0; i < x.length; i++) {
|
|
152
|
+
x[i] = rhex(x[i]);
|
|
153
|
+
}
|
|
154
|
+
return x.join('');
|
|
155
|
+
}
|
|
156
|
+
function md5(s) {
|
|
157
|
+
return hex(md51(s));
|
|
158
|
+
}
|
|
159
|
+
/* this function is much faster,
|
|
160
|
+
so if possible we use it. Some IEs
|
|
161
|
+
are the only ones I know of that
|
|
162
|
+
need the idiotic second function,
|
|
163
|
+
generated by an if clause. */
|
|
164
|
+
if (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
|
|
165
|
+
function add32(x, y) {
|
|
166
|
+
var lsw = (x & 0xffff) + (y & 0xffff), msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
167
|
+
return (msw << 16) | (lsw & 0xffff);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export default md5;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default PubSubMixin;
|
|
2
|
+
declare namespace PubSubMixin {
|
|
3
|
+
function UNSAFE_componentWillMount(): void;
|
|
4
|
+
/**
|
|
5
|
+
* Registers an event listener for a PubSub event and keeps track of the event ID
|
|
6
|
+
* @param {String} name
|
|
7
|
+
* @param {Function} callback
|
|
8
|
+
*/
|
|
9
|
+
function subscribe(name: string, callback: Function): void;
|
|
10
|
+
/**
|
|
11
|
+
* Publish an event
|
|
12
|
+
* @param {String} name
|
|
13
|
+
* @param {Object} [data]
|
|
14
|
+
*/
|
|
15
|
+
function publish(name: string, data?: Object): void;
|
|
16
|
+
/**
|
|
17
|
+
* When the component is unmounted, we want to subscribe from all of our event IDs
|
|
18
|
+
*/
|
|
19
|
+
function componentWillUnmount(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import PubSubModule from '../PubSub';
|
|
2
|
+
import * as Utils from '../utils';
|
|
3
|
+
const PubSub = (Utils.isWindowAvailable() && window.PubSub) || PubSubModule;
|
|
4
|
+
/**
|
|
5
|
+
* This mixin sets up automatic PubSub bindings which will be removed when
|
|
6
|
+
* the component is unmounted.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* MyView = window.CreateClass({
|
|
10
|
+
* mixins: [React.m.PubSub],
|
|
11
|
+
* componentDidMount() {
|
|
12
|
+
* this.subscribe('event_name', () => {
|
|
13
|
+
* console.log('event was triggered');
|
|
14
|
+
* });
|
|
15
|
+
* }
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
const PubSubMixin = {
|
|
19
|
+
UNSAFE_componentWillMount() {
|
|
20
|
+
this.eventIds = [];
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* Registers an event listener for a PubSub event and keeps track of the event ID
|
|
24
|
+
* @param {String} name
|
|
25
|
+
* @param {Function} callback
|
|
26
|
+
*/
|
|
27
|
+
subscribe(name, callback) {
|
|
28
|
+
this.eventIds.push(PubSub.subscribe(name, callback, this));
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Publish an event
|
|
32
|
+
* @param {String} name
|
|
33
|
+
* @param {Object} [data]
|
|
34
|
+
*/
|
|
35
|
+
publish(name, data) {
|
|
36
|
+
PubSub.publish(name, data || {});
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* When the component is unmounted, we want to subscribe from all of our event IDs
|
|
40
|
+
*/
|
|
41
|
+
componentWillUnmount() {
|
|
42
|
+
for (const eventId of this.eventIds) {
|
|
43
|
+
PubSub.unsubscribe(eventId);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
export default PubSubMixin;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* global React */
|
|
2
|
+
/**
|
|
3
|
+
* This mixin adds the ability to specify an `extraClasses` property
|
|
4
|
+
* on a component that is added to any default classes that the component uses.
|
|
5
|
+
* It keeps these classes in the state so that they can be dynamically changed
|
|
6
|
+
* if needed.
|
|
7
|
+
*
|
|
8
|
+
* The `extraClasses` property should be an array containing elements
|
|
9
|
+
* for each class to add to the component.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* // Use the mixin in a component
|
|
13
|
+
* React.registerComponent(['div'], {
|
|
14
|
+
* mixins: [React.m.ExtraClasses)],
|
|
15
|
+
* render() { return <div className={this.state.classes} />; }
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Using that component
|
|
19
|
+
* render() {
|
|
20
|
+
* let Div = React.c(['div']);
|
|
21
|
+
* return <Div extraClasses={['large', 'primary']} />;
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
import * as Utils from '../utils';
|
|
25
|
+
export default {
|
|
26
|
+
propTypes: {
|
|
27
|
+
extraClasses: Utils.isWindowAvailable() && window.PropTypes.oneOfType([window.PropTypes.string, window.PropTypes.array, window.PropTypes.object]),
|
|
28
|
+
},
|
|
29
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
30
|
+
this.setState({ classes: React.classNames(this.defaultClasses || [], nextProps.extraClasses) });
|
|
31
|
+
},
|
|
32
|
+
getInitialState() {
|
|
33
|
+
return {
|
|
34
|
+
classes: React.classNames(this.defaultClasses || [], this.props.extraClasses),
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
/**
|
|
3
|
+
* Clear the error state of this element
|
|
4
|
+
*/
|
|
5
|
+
function clearError(): void;
|
|
6
|
+
function handleErrorStateUpdate(state: object): object;
|
|
7
|
+
/**
|
|
8
|
+
* Display the error state of this element
|
|
9
|
+
*/
|
|
10
|
+
function showError(): void;
|
|
11
|
+
}
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import * as CONST from '../CONST';
|
|
3
|
+
/**
|
|
4
|
+
* This mixin will add two methods to a component which are uses to add
|
|
5
|
+
* and remove the error class from the component. Used great with refs and
|
|
6
|
+
* form elements. You can see how it is used in component/list/item/formelement.jsx
|
|
7
|
+
*/
|
|
8
|
+
export default {
|
|
9
|
+
/**
|
|
10
|
+
* Clear the error state of this element
|
|
11
|
+
*/
|
|
12
|
+
clearError() {
|
|
13
|
+
this.setState(this.getInitialState());
|
|
14
|
+
},
|
|
15
|
+
/**
|
|
16
|
+
* Update the error state of this element
|
|
17
|
+
*
|
|
18
|
+
* @param {object} state - The current state of the component.
|
|
19
|
+
* @returns {object} The updated state with modified classes.
|
|
20
|
+
*/
|
|
21
|
+
handleErrorStateUpdate: (state) => ({
|
|
22
|
+
classes: cn(state.classes, CONST.UI.ERROR),
|
|
23
|
+
}),
|
|
24
|
+
/**
|
|
25
|
+
* Display the error state of this element
|
|
26
|
+
*/
|
|
27
|
+
showError() {
|
|
28
|
+
this.setState(this.handleErrorStateUpdate);
|
|
29
|
+
},
|
|
30
|
+
};
|