parse 4.0.0-alpha.1 → 4.0.0-alpha.11

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.
Files changed (255) hide show
  1. package/LICENSE +167 -25
  2. package/NOTICE +10 -0
  3. package/README.md +6 -5
  4. package/dist/parse.js +12838 -21190
  5. package/dist/parse.min.js +7 -6
  6. package/dist/parse.weapp.js +7921 -17062
  7. package/dist/parse.weapp.min.js +7 -6
  8. package/lib/browser/Analytics.js +2 -27
  9. package/lib/browser/AnonymousUtils.js +6 -42
  10. package/lib/browser/Cloud.js +12 -77
  11. package/lib/browser/CloudCode.js +0 -3
  12. package/lib/browser/CoreManager.js +46 -191
  13. package/lib/browser/CryptoController.js +2 -16
  14. package/lib/browser/EventEmitter.js +1 -8
  15. package/lib/browser/EventuallyQueue.js +277 -824
  16. package/lib/browser/FacebookUtils.js +6 -42
  17. package/lib/browser/IndexedDBStorageController.js +3 -14
  18. package/lib/browser/InstallationController.js +2 -20
  19. package/lib/browser/LiveQueryClient.js +105 -213
  20. package/lib/browser/LiveQuerySubscription.js +10 -39
  21. package/lib/browser/LocalDatastore.js +451 -1081
  22. package/lib/browser/LocalDatastoreController.js +145 -602
  23. package/lib/browser/LocalDatastoreController.react-native.js +137 -573
  24. package/lib/browser/LocalDatastoreUtils.js +2 -19
  25. package/lib/browser/ObjectStateMutations.js +18 -121
  26. package/lib/browser/OfflineQuery.js +61 -222
  27. package/lib/browser/Parse.js +12 -115
  28. package/lib/browser/ParseACL.js +33 -148
  29. package/lib/browser/ParseCLP.js +96 -314
  30. package/lib/browser/ParseConfig.js +18 -95
  31. package/lib/browser/ParseError.js +63 -99
  32. package/lib/browser/ParseFile.js +128 -685
  33. package/lib/browser/ParseGeoPoint.js +23 -89
  34. package/lib/browser/ParseHooks.js +1 -34
  35. package/lib/browser/ParseInstallation.js +4 -32
  36. package/lib/browser/ParseLiveQuery.js +96 -505
  37. package/lib/browser/ParseObject.js +665 -1845
  38. package/lib/browser/ParseOp.js +41 -287
  39. package/lib/browser/ParsePolygon.js +13 -70
  40. package/lib/browser/ParseQuery.js +403 -1504
  41. package/lib/browser/ParseRelation.js +12 -68
  42. package/lib/browser/ParseRole.js +13 -75
  43. package/lib/browser/ParseSchema.js +49 -208
  44. package/lib/browser/ParseSession.js +11 -69
  45. package/lib/browser/ParseUser.js +274 -1127
  46. package/lib/browser/Push.js +7 -50
  47. package/lib/browser/RESTController.js +28 -157
  48. package/lib/browser/SingleInstanceStateController.js +19 -144
  49. package/lib/browser/Socket.weapp.js +0 -10
  50. package/lib/browser/Storage.js +10 -80
  51. package/lib/browser/StorageController.browser.js +4 -24
  52. package/lib/browser/StorageController.default.js +4 -24
  53. package/lib/browser/StorageController.react-native.js +6 -40
  54. package/lib/browser/StorageController.weapp.js +5 -23
  55. package/lib/browser/TaskQueue.js +1 -29
  56. package/lib/browser/UniqueInstanceStateController.js +19 -149
  57. package/lib/browser/Xhr.weapp.js +0 -17
  58. package/lib/browser/arrayContainsObject.js +2 -23
  59. package/lib/browser/canBeSerialized.js +3 -40
  60. package/lib/browser/decode.js +3 -40
  61. package/lib/browser/encode.js +9 -77
  62. package/lib/browser/equals.js +2 -34
  63. package/lib/browser/escape.js +1 -15
  64. package/lib/browser/isRevocableSession.js +2 -18
  65. package/lib/browser/parseDate.js +2 -20
  66. package/lib/browser/promiseUtils.js +3 -21
  67. package/lib/browser/unique.js +3 -24
  68. package/lib/browser/unsavedChildren.js +6 -57
  69. package/lib/browser/uuid.js +3 -1
  70. package/lib/node/Analytics.js +1 -25
  71. package/lib/node/AnonymousUtils.js +5 -44
  72. package/lib/node/Cloud.js +10 -73
  73. package/lib/node/CloudCode.js +0 -3
  74. package/lib/node/CoreManager.js +47 -227
  75. package/lib/node/CryptoController.js +2 -16
  76. package/lib/node/EventEmitter.js +1 -8
  77. package/lib/node/EventuallyQueue.js +16 -123
  78. package/lib/node/FacebookUtils.js +5 -44
  79. package/lib/node/IndexedDBStorageController.js +3 -19
  80. package/lib/node/InstallationController.js +2 -22
  81. package/lib/node/LiveQueryClient.js +72 -154
  82. package/lib/node/LiveQuerySubscription.js +7 -26
  83. package/lib/node/LocalDatastore.js +19 -182
  84. package/lib/node/LocalDatastoreController.js +6 -45
  85. package/lib/node/LocalDatastoreController.react-native.js +6 -52
  86. package/lib/node/LocalDatastoreUtils.js +1 -13
  87. package/lib/node/ObjectStateMutations.js +13 -100
  88. package/lib/node/OfflineQuery.js +27 -151
  89. package/lib/node/Parse.js +11 -108
  90. package/lib/node/ParseACL.js +32 -157
  91. package/lib/node/ParseCLP.js +69 -269
  92. package/lib/node/ParseConfig.js +16 -91
  93. package/lib/node/ParseError.js +61 -74
  94. package/lib/node/ParseFile.js +49 -212
  95. package/lib/node/ParseGeoPoint.js +21 -89
  96. package/lib/node/ParseHooks.js +0 -35
  97. package/lib/node/ParseInstallation.js +1 -17
  98. package/lib/node/ParseLiveQuery.js +10 -43
  99. package/lib/node/ParseObject.js +229 -964
  100. package/lib/node/ParseOp.js +31 -262
  101. package/lib/node/ParsePolygon.js +12 -69
  102. package/lib/node/ParseQuery.js +169 -888
  103. package/lib/node/ParseRelation.js +11 -68
  104. package/lib/node/ParseRole.js +10 -64
  105. package/lib/node/ParseSchema.js +46 -229
  106. package/lib/node/ParseSession.js +8 -57
  107. package/lib/node/ParseUser.js +107 -583
  108. package/lib/node/Push.js +4 -44
  109. package/lib/node/RESTController.js +18 -127
  110. package/lib/node/SingleInstanceStateController.js +17 -137
  111. package/lib/node/Socket.weapp.js +0 -7
  112. package/lib/node/Storage.js +10 -90
  113. package/lib/node/StorageController.browser.js +4 -30
  114. package/lib/node/StorageController.default.js +5 -28
  115. package/lib/node/StorageController.react-native.js +6 -47
  116. package/lib/node/StorageController.weapp.js +6 -28
  117. package/lib/node/TaskQueue.js +1 -24
  118. package/lib/node/UniqueInstanceStateController.js +16 -140
  119. package/lib/node/Xhr.weapp.js +0 -15
  120. package/lib/node/arrayContainsObject.js +1 -19
  121. package/lib/node/canBeSerialized.js +2 -35
  122. package/lib/node/decode.js +1 -33
  123. package/lib/node/encode.js +3 -61
  124. package/lib/node/equals.js +0 -27
  125. package/lib/node/escape.js +1 -13
  126. package/lib/node/isRevocableSession.js +1 -12
  127. package/lib/node/parseDate.js +1 -14
  128. package/lib/node/promiseUtils.js +2 -14
  129. package/lib/node/unique.js +1 -18
  130. package/lib/node/unsavedChildren.js +2 -45
  131. package/lib/node/uuid.js +6 -1
  132. package/lib/react-native/Analytics.js +0 -9
  133. package/lib/react-native/AnonymousUtils.js +0 -10
  134. package/lib/react-native/Cloud.js +0 -26
  135. package/lib/react-native/CoreManager.js +2 -6
  136. package/lib/react-native/CryptoController.js +0 -2
  137. package/lib/react-native/EventEmitter.js +0 -2
  138. package/lib/react-native/EventuallyQueue.js +156 -711
  139. package/lib/react-native/FacebookUtils.js +0 -22
  140. package/lib/react-native/IndexedDBStorageController.js +0 -1
  141. package/lib/react-native/InstallationController.js +0 -6
  142. package/lib/react-native/LiveQueryClient.js +46 -157
  143. package/lib/react-native/LiveQuerySubscription.js +3 -27
  144. package/lib/react-native/LocalDatastore.js +281 -948
  145. package/lib/react-native/LocalDatastoreController.js +71 -552
  146. package/lib/react-native/LocalDatastoreController.react-native.js +91 -526
  147. package/lib/react-native/LocalDatastoreUtils.js +0 -1
  148. package/lib/react-native/ObjectStateMutations.js +2 -65
  149. package/lib/react-native/OfflineQuery.js +25 -196
  150. package/lib/react-native/Parse.js +0 -65
  151. package/lib/react-native/ParseACL.js +0 -44
  152. package/lib/react-native/ParseCLP.js +23 -161
  153. package/lib/react-native/ParseConfig.js +0 -42
  154. package/lib/react-native/ParseError.js +1 -21
  155. package/lib/react-native/ParseFile.js +55 -529
  156. package/lib/react-native/ParseGeoPoint.js +0 -17
  157. package/lib/react-native/ParseHooks.js +0 -30
  158. package/lib/react-native/ParseInstallation.js +1 -23
  159. package/lib/react-native/ParseLiveQuery.js +55 -472
  160. package/lib/react-native/ParseObject.js +245 -1246
  161. package/lib/react-native/ParseOp.js +1 -138
  162. package/lib/react-native/ParsePolygon.js +0 -24
  163. package/lib/react-native/ParseQuery.js +182 -874
  164. package/lib/react-native/ParseRelation.js +0 -25
  165. package/lib/react-native/ParseRole.js +1 -36
  166. package/lib/react-native/ParseSchema.js +3 -54
  167. package/lib/react-native/ParseSession.js +1 -40
  168. package/lib/react-native/ParseUser.js +95 -773
  169. package/lib/react-native/Push.js +0 -16
  170. package/lib/react-native/RESTController.js +12 -109
  171. package/lib/react-native/SingleInstanceStateController.js +0 -44
  172. package/lib/react-native/Socket.weapp.js +0 -10
  173. package/lib/react-native/Storage.js +0 -24
  174. package/lib/react-native/StorageController.browser.js +0 -2
  175. package/lib/react-native/StorageController.default.js +0 -1
  176. package/lib/react-native/StorageController.react-native.js +0 -2
  177. package/lib/react-native/TaskQueue.js +0 -15
  178. package/lib/react-native/UniqueInstanceStateController.js +0 -47
  179. package/lib/react-native/Xhr.weapp.js +0 -16
  180. package/lib/react-native/arrayContainsObject.js +0 -5
  181. package/lib/react-native/canBeSerialized.js +0 -18
  182. package/lib/react-native/decode.js +0 -21
  183. package/lib/react-native/encode.js +0 -25
  184. package/lib/react-native/equals.js +0 -18
  185. package/lib/react-native/escape.js +0 -1
  186. package/lib/react-native/isRevocableSession.js +0 -1
  187. package/lib/react-native/parseDate.js +0 -3
  188. package/lib/react-native/promiseUtils.js +0 -13
  189. package/lib/react-native/unique.js +0 -4
  190. package/lib/react-native/unsavedChildren.js +0 -21
  191. package/lib/react-native/uuid.js +3 -1
  192. package/lib/weapp/Analytics.js +2 -27
  193. package/lib/weapp/AnonymousUtils.js +6 -42
  194. package/lib/weapp/Cloud.js +12 -77
  195. package/lib/weapp/CloudCode.js +0 -3
  196. package/lib/weapp/CoreManager.js +46 -191
  197. package/lib/weapp/CryptoController.js +2 -16
  198. package/lib/weapp/EventEmitter.js +1 -8
  199. package/lib/weapp/EventuallyQueue.js +277 -824
  200. package/lib/weapp/FacebookUtils.js +6 -42
  201. package/lib/weapp/IndexedDBStorageController.js +3 -14
  202. package/lib/weapp/InstallationController.js +2 -20
  203. package/lib/weapp/LiveQueryClient.js +105 -213
  204. package/lib/weapp/LiveQuerySubscription.js +10 -39
  205. package/lib/weapp/LocalDatastore.js +451 -1081
  206. package/lib/weapp/LocalDatastoreController.js +145 -602
  207. package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
  208. package/lib/weapp/LocalDatastoreUtils.js +2 -19
  209. package/lib/weapp/ObjectStateMutations.js +18 -121
  210. package/lib/weapp/OfflineQuery.js +61 -222
  211. package/lib/weapp/Parse.js +12 -115
  212. package/lib/weapp/ParseACL.js +33 -148
  213. package/lib/weapp/ParseCLP.js +96 -314
  214. package/lib/weapp/ParseConfig.js +18 -95
  215. package/lib/weapp/ParseError.js +63 -99
  216. package/lib/weapp/ParseFile.js +129 -686
  217. package/lib/weapp/ParseGeoPoint.js +23 -89
  218. package/lib/weapp/ParseHooks.js +1 -34
  219. package/lib/weapp/ParseInstallation.js +4 -32
  220. package/lib/weapp/ParseLiveQuery.js +96 -505
  221. package/lib/weapp/ParseObject.js +665 -1845
  222. package/lib/weapp/ParseOp.js +41 -287
  223. package/lib/weapp/ParsePolygon.js +13 -70
  224. package/lib/weapp/ParseQuery.js +403 -1504
  225. package/lib/weapp/ParseRelation.js +12 -68
  226. package/lib/weapp/ParseRole.js +13 -75
  227. package/lib/weapp/ParseSchema.js +49 -208
  228. package/lib/weapp/ParseSession.js +11 -69
  229. package/lib/weapp/ParseUser.js +274 -1127
  230. package/lib/weapp/Push.js +7 -50
  231. package/lib/weapp/RESTController.js +28 -157
  232. package/lib/weapp/SingleInstanceStateController.js +19 -144
  233. package/lib/weapp/Socket.weapp.js +0 -10
  234. package/lib/weapp/Storage.js +10 -80
  235. package/lib/weapp/StorageController.browser.js +4 -24
  236. package/lib/weapp/StorageController.default.js +4 -24
  237. package/lib/weapp/StorageController.react-native.js +6 -40
  238. package/lib/weapp/StorageController.weapp.js +5 -23
  239. package/lib/weapp/TaskQueue.js +1 -29
  240. package/lib/weapp/UniqueInstanceStateController.js +19 -149
  241. package/lib/weapp/Xhr.weapp.js +0 -17
  242. package/lib/weapp/arrayContainsObject.js +2 -23
  243. package/lib/weapp/canBeSerialized.js +3 -40
  244. package/lib/weapp/decode.js +3 -40
  245. package/lib/weapp/encode.js +9 -77
  246. package/lib/weapp/equals.js +2 -34
  247. package/lib/weapp/escape.js +1 -15
  248. package/lib/weapp/isRevocableSession.js +2 -18
  249. package/lib/weapp/parseDate.js +2 -20
  250. package/lib/weapp/promiseUtils.js +3 -21
  251. package/lib/weapp/unique.js +3 -24
  252. package/lib/weapp/unsavedChildren.js +6 -57
  253. package/lib/weapp/uuid.js +1 -6
  254. package/package.json +35 -31
  255. package/PATENTS +0 -37
@@ -1,408 +1,39 @@
1
1
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
3
  value: true
5
4
  });
6
5
  exports.default = void 0;
7
-
6
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
7
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
-
10
8
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
-
12
9
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
13
-
14
10
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
-
16
11
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
-
18
12
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
-
20
13
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
21
-
22
14
  var _isRevocableSession = _interopRequireDefault(require("./isRevocableSession"));
23
-
24
15
  var _ParseError = _interopRequireDefault(require("./ParseError"));
25
-
26
16
  var _ParseObject2 = _interopRequireDefault(require("./ParseObject"));
27
-
28
17
  var _ParseSession = _interopRequireDefault(require("./ParseSession"));
29
-
30
18
  var _Storage = _interopRequireDefault(require("./Storage"));
31
-
32
- function _regeneratorRuntime() {
33
- "use strict";
34
-
35
- _regeneratorRuntime = function () {
36
- return exports;
37
- };
38
-
39
- var exports = {},
40
- Op = Object.prototype,
41
- hasOwn = Op.hasOwnProperty,
42
- $Symbol = "function" == typeof Symbol ? Symbol : {},
43
- iteratorSymbol = $Symbol.iterator || "@@iterator",
44
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
45
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
46
-
47
- function define(obj, key, value) {
48
- return Object.defineProperty(obj, key, {
49
- value: value,
50
- enumerable: !0,
51
- configurable: !0,
52
- writable: !0
53
- }), obj[key];
54
- }
55
-
56
- try {
57
- define({}, "");
58
- } catch (err) {
59
- define = function (obj, key, value) {
60
- return obj[key] = value;
61
- };
62
- }
63
-
64
- function wrap(innerFn, outerFn, self, tryLocsList) {
65
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
66
- generator = Object.create(protoGenerator.prototype),
67
- context = new Context(tryLocsList || []);
68
- return generator._invoke = function (innerFn, self, context) {
69
- var state = "suspendedStart";
70
- return function (method, arg) {
71
- if ("executing" === state) throw new Error("Generator is already running");
72
-
73
- if ("completed" === state) {
74
- if ("throw" === method) throw arg;
75
- return doneResult();
76
- }
77
-
78
- for (context.method = method, context.arg = arg;;) {
79
- var delegate = context.delegate;
80
-
81
- if (delegate) {
82
- var delegateResult = maybeInvokeDelegate(delegate, context);
83
-
84
- if (delegateResult) {
85
- if (delegateResult === ContinueSentinel) continue;
86
- return delegateResult;
87
- }
88
- }
89
-
90
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
91
- if ("suspendedStart" === state) throw state = "completed", context.arg;
92
- context.dispatchException(context.arg);
93
- } else "return" === context.method && context.abrupt("return", context.arg);
94
- state = "executing";
95
- var record = tryCatch(innerFn, self, context);
96
-
97
- if ("normal" === record.type) {
98
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
99
- return {
100
- value: record.arg,
101
- done: context.done
102
- };
103
- }
104
-
105
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
106
- }
107
- };
108
- }(innerFn, self, context), generator;
109
- }
110
-
111
- function tryCatch(fn, obj, arg) {
112
- try {
113
- return {
114
- type: "normal",
115
- arg: fn.call(obj, arg)
116
- };
117
- } catch (err) {
118
- return {
119
- type: "throw",
120
- arg: err
121
- };
122
- }
123
- }
124
-
125
- exports.wrap = wrap;
126
- var ContinueSentinel = {};
127
-
128
- function Generator() {}
129
-
130
- function GeneratorFunction() {}
131
-
132
- function GeneratorFunctionPrototype() {}
133
-
134
- var IteratorPrototype = {};
135
- define(IteratorPrototype, iteratorSymbol, function () {
136
- return this;
137
- });
138
- var getProto = Object.getPrototypeOf,
139
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
140
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
141
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
142
-
143
- function defineIteratorMethods(prototype) {
144
- ["next", "throw", "return"].forEach(function (method) {
145
- define(prototype, method, function (arg) {
146
- return this._invoke(method, arg);
147
- });
148
- });
149
- }
150
-
151
- function AsyncIterator(generator, PromiseImpl) {
152
- function invoke(method, arg, resolve, reject) {
153
- var record = tryCatch(generator[method], generator, arg);
154
-
155
- if ("throw" !== record.type) {
156
- var result = record.arg,
157
- value = result.value;
158
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
159
- invoke("next", value, resolve, reject);
160
- }, function (err) {
161
- invoke("throw", err, resolve, reject);
162
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
163
- result.value = unwrapped, resolve(result);
164
- }, function (error) {
165
- return invoke("throw", error, resolve, reject);
166
- });
167
- }
168
-
169
- reject(record.arg);
170
- }
171
-
172
- var previousPromise;
173
-
174
- this._invoke = function (method, arg) {
175
- function callInvokeWithMethodAndArg() {
176
- return new PromiseImpl(function (resolve, reject) {
177
- invoke(method, arg, resolve, reject);
178
- });
179
- }
180
-
181
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
182
- };
183
- }
184
-
185
- function maybeInvokeDelegate(delegate, context) {
186
- var method = delegate.iterator[context.method];
187
-
188
- if (undefined === method) {
189
- if (context.delegate = null, "throw" === context.method) {
190
- if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
191
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
192
- }
193
-
194
- return ContinueSentinel;
195
- }
196
-
197
- var record = tryCatch(method, delegate.iterator, context.arg);
198
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
199
- var info = record.arg;
200
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
201
- }
202
-
203
- function pushTryEntry(locs) {
204
- var entry = {
205
- tryLoc: locs[0]
206
- };
207
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
208
- }
209
-
210
- function resetTryEntry(entry) {
211
- var record = entry.completion || {};
212
- record.type = "normal", delete record.arg, entry.completion = record;
213
- }
214
-
215
- function Context(tryLocsList) {
216
- this.tryEntries = [{
217
- tryLoc: "root"
218
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
219
- }
220
-
221
- function values(iterable) {
222
- if (iterable) {
223
- var iteratorMethod = iterable[iteratorSymbol];
224
- if (iteratorMethod) return iteratorMethod.call(iterable);
225
- if ("function" == typeof iterable.next) return iterable;
226
-
227
- if (!isNaN(iterable.length)) {
228
- var i = -1,
229
- next = function next() {
230
- for (; ++i < iterable.length;) {
231
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
232
- }
233
-
234
- return next.value = undefined, next.done = !0, next;
235
- };
236
-
237
- return next.next = next;
238
- }
239
- }
240
-
241
- return {
242
- next: doneResult
243
- };
244
- }
245
-
246
- function doneResult() {
247
- return {
248
- value: undefined,
249
- done: !0
250
- };
251
- }
252
-
253
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
254
- var ctor = "function" == typeof genFun && genFun.constructor;
255
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
256
- }, exports.mark = function (genFun) {
257
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
258
- }, exports.awrap = function (arg) {
259
- return {
260
- __await: arg
261
- };
262
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
263
- return this;
264
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
265
- void 0 === PromiseImpl && (PromiseImpl = Promise);
266
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
267
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
268
- return result.done ? result.value : iter.next();
269
- });
270
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
271
- return this;
272
- }), define(Gp, "toString", function () {
273
- return "[object Generator]";
274
- }), exports.keys = function (object) {
275
- var keys = [];
276
-
277
- for (var key in object) {
278
- keys.push(key);
279
- }
280
-
281
- return keys.reverse(), function next() {
282
- for (; keys.length;) {
283
- var key = keys.pop();
284
- if (key in object) return next.value = key, next.done = !1, next;
285
- }
286
-
287
- return next.done = !0, next;
288
- };
289
- }, exports.values = values, Context.prototype = {
290
- constructor: Context,
291
- reset: function (skipTempReset) {
292
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
293
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
294
- }
295
- },
296
- stop: function () {
297
- this.done = !0;
298
- var rootRecord = this.tryEntries[0].completion;
299
- if ("throw" === rootRecord.type) throw rootRecord.arg;
300
- return this.rval;
301
- },
302
- dispatchException: function (exception) {
303
- if (this.done) throw exception;
304
- var context = this;
305
-
306
- function handle(loc, caught) {
307
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
308
- }
309
-
310
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
311
- var entry = this.tryEntries[i],
312
- record = entry.completion;
313
- if ("root" === entry.tryLoc) return handle("end");
314
-
315
- if (entry.tryLoc <= this.prev) {
316
- var hasCatch = hasOwn.call(entry, "catchLoc"),
317
- hasFinally = hasOwn.call(entry, "finallyLoc");
318
-
319
- if (hasCatch && hasFinally) {
320
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
321
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
322
- } else if (hasCatch) {
323
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
324
- } else {
325
- if (!hasFinally) throw new Error("try statement without catch or finally");
326
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
327
- }
328
- }
329
- }
330
- },
331
- abrupt: function (type, arg) {
332
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
333
- var entry = this.tryEntries[i];
334
-
335
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
336
- var finallyEntry = entry;
337
- break;
338
- }
339
- }
340
-
341
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
342
- var record = finallyEntry ? finallyEntry.completion : {};
343
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
344
- },
345
- complete: function (record, afterLoc) {
346
- if ("throw" === record.type) throw record.arg;
347
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
348
- },
349
- finish: function (finallyLoc) {
350
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
351
- var entry = this.tryEntries[i];
352
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
353
- }
354
- },
355
- catch: function (tryLoc) {
356
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
357
- var entry = this.tryEntries[i];
358
-
359
- if (entry.tryLoc === tryLoc) {
360
- var record = entry.completion;
361
-
362
- if ("throw" === record.type) {
363
- var thrown = record.arg;
364
- resetTryEntry(entry);
365
- }
366
-
367
- return thrown;
368
- }
369
- }
370
-
371
- throw new Error("illegal catch attempt");
372
- },
373
- delegateYield: function (iterable, resultName, nextLoc) {
374
- return this.delegate = {
375
- iterator: values(iterable),
376
- resultName: resultName,
377
- nextLoc: nextLoc
378
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
379
- }
380
- }, exports;
381
- }
382
-
383
19
  function _createSuper(Derived) {
384
20
  var hasNativeReflectConstruct = _isNativeReflectConstruct();
385
-
386
21
  return function () {
387
22
  var Super = (0, _getPrototypeOf2.default)(Derived),
388
- result;
389
-
23
+ result;
390
24
  if (hasNativeReflectConstruct) {
391
25
  var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
392
26
  result = Reflect.construct(Super, arguments, NewTarget);
393
27
  } else {
394
28
  result = Super.apply(this, arguments);
395
29
  }
396
-
397
30
  return (0, _possibleConstructorReturn2.default)(this, result);
398
31
  };
399
32
  }
400
-
401
33
  function _isNativeReflectConstruct() {
402
34
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
403
35
  if (Reflect.construct.sham) return false;
404
36
  if (typeof Proxy === "function") return true;
405
-
406
37
  try {
407
38
  Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
408
39
  return true;
@@ -410,59 +41,45 @@ function _isNativeReflectConstruct() {
410
41
  return false;
411
42
  }
412
43
  }
413
-
414
44
  var CURRENT_USER_KEY = 'currentUser';
415
45
  var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
416
46
  var currentUserCacheMatchesDisk = false;
417
47
  var currentUserCache = null;
418
48
  var authProviders = {};
419
-
420
49
  var ParseUser = function (_ParseObject) {
421
50
  (0, _inherits2.default)(ParseUser, _ParseObject);
422
-
423
51
  var _super = _createSuper(ParseUser);
424
-
425
52
  function ParseUser(attributes) {
426
53
  var _this;
427
-
428
54
  (0, _classCallCheck2.default)(this, ParseUser);
429
55
  _this = _super.call(this, '_User');
430
-
431
56
  if (attributes && typeof attributes === 'object') {
432
57
  if (!_this.set(attributes || {})) {
433
58
  throw new Error("Can't create an invalid Parse User");
434
59
  }
435
60
  }
436
-
437
61
  return _this;
438
62
  }
439
-
440
63
  (0, _createClass2.default)(ParseUser, [{
441
64
  key: "_upgradeToRevocableSession",
442
65
  value: function (options) {
443
66
  options = options || {};
444
67
  var upgradeOptions = {};
445
-
446
68
  if (options.hasOwnProperty('useMasterKey')) {
447
69
  upgradeOptions.useMasterKey = options.useMasterKey;
448
70
  }
449
-
450
71
  var controller = _CoreManager.default.getUserController();
451
-
452
72
  return controller.upgradeToRevocableSession(this, upgradeOptions);
453
73
  }
454
74
  }, {
455
75
  key: "linkWith",
456
76
  value: function (provider, options) {
457
77
  var _this2 = this;
458
-
459
78
  var saveOpts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
460
79
  saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
461
80
  var authType;
462
-
463
81
  if (typeof provider === 'string') {
464
82
  authType = provider;
465
-
466
83
  if (authProviders[provider]) {
467
84
  provider = authProviders[provider];
468
85
  } else {
@@ -480,18 +97,13 @@ var ParseUser = function (_ParseObject) {
480
97
  } else {
481
98
  authType = provider.getAuthType();
482
99
  }
483
-
484
100
  if (options && options.hasOwnProperty('authData')) {
485
101
  var authData = this.get('authData') || {};
486
-
487
102
  if (typeof authData !== 'object') {
488
103
  throw new Error('Invalid type: authData field should be an object');
489
104
  }
490
-
491
105
  authData[authType] = options.authData;
492
-
493
106
  var controller = _CoreManager.default.getUserController();
494
-
495
107
  return controller.linkWith(this, authData, saveOpts);
496
108
  } else {
497
109
  return new Promise(function (resolve, reject) {
@@ -499,7 +111,6 @@ var ParseUser = function (_ParseObject) {
499
111
  success: function (provider, result) {
500
112
  var opts = {};
501
113
  opts.authData = result;
502
-
503
114
  _this2.linkWith(provider, opts, saveOpts).then(function () {
504
115
  resolve(_this2);
505
116
  }, function (error) {
@@ -525,24 +136,18 @@ var ParseUser = function (_ParseObject) {
525
136
  if (!this.isCurrent() || !provider) {
526
137
  return;
527
138
  }
528
-
529
139
  var authType;
530
-
531
140
  if (typeof provider === 'string') {
532
141
  authType = provider;
533
142
  provider = authProviders[authType];
534
143
  } else {
535
144
  authType = provider.getAuthType();
536
145
  }
537
-
538
146
  var authData = this.get('authData');
539
-
540
147
  if (!provider || !authData || typeof authData !== 'object') {
541
148
  return;
542
149
  }
543
-
544
150
  var success = provider.restoreAuthentication(authData[authType]);
545
-
546
151
  if (!success) {
547
152
  this._unlinkFrom(provider);
548
153
  }
@@ -551,11 +156,9 @@ var ParseUser = function (_ParseObject) {
551
156
  key: "_synchronizeAllAuthData",
552
157
  value: function () {
553
158
  var authData = this.get('authData');
554
-
555
159
  if (typeof authData !== 'object') {
556
160
  return;
557
161
  }
558
-
559
162
  for (var _key in authData) {
560
163
  this._synchronizeAuthData(_key);
561
164
  }
@@ -566,13 +169,10 @@ var ParseUser = function (_ParseObject) {
566
169
  if (!this.isCurrent()) {
567
170
  return;
568
171
  }
569
-
570
172
  var authData = this.get('authData');
571
-
572
173
  if (typeof authData !== 'object') {
573
174
  return;
574
175
  }
575
-
576
176
  for (var _key2 in authData) {
577
177
  if (!authData[_key2]) {
578
178
  delete authData[_key2];
@@ -583,12 +183,10 @@ var ParseUser = function (_ParseObject) {
583
183
  key: "_unlinkFrom",
584
184
  value: function (provider, options) {
585
185
  var _this3 = this;
586
-
587
186
  return this.linkWith(provider, {
588
187
  authData: null
589
188
  }, options).then(function () {
590
189
  _this3._synchronizeAuthData(provider);
591
-
592
190
  return Promise.resolve(_this3);
593
191
  });
594
192
  }
@@ -596,30 +194,24 @@ var ParseUser = function (_ParseObject) {
596
194
  key: "_isLinked",
597
195
  value: function (provider) {
598
196
  var authType;
599
-
600
197
  if (typeof provider === 'string') {
601
198
  authType = provider;
602
199
  } else {
603
200
  authType = provider.getAuthType();
604
201
  }
605
-
606
202
  var authData = this.get('authData') || {};
607
-
608
203
  if (typeof authData !== 'object') {
609
204
  return false;
610
205
  }
611
-
612
206
  return !!authData[authType];
613
207
  }
614
208
  }, {
615
209
  key: "_logOutWithAll",
616
210
  value: function () {
617
211
  var authData = this.get('authData');
618
-
619
212
  if (typeof authData !== 'object') {
620
213
  return;
621
214
  }
622
-
623
215
  for (var _key3 in authData) {
624
216
  this._logOutWith(_key3);
625
217
  }
@@ -630,11 +222,9 @@ var ParseUser = function (_ParseObject) {
630
222
  if (!this.isCurrent()) {
631
223
  return;
632
224
  }
633
-
634
225
  if (typeof provider === 'string') {
635
226
  provider = authProviders[provider];
636
227
  }
637
-
638
228
  if (provider && provider.deauthenticate) {
639
229
  provider.deauthenticate();
640
230
  }
@@ -655,45 +245,31 @@ var ParseUser = function (_ParseObject) {
655
245
  }, {
656
246
  key: "isCurrentAsync",
657
247
  value: function () {
658
- var current;
659
- return _regeneratorRuntime().async(function (_context) {
660
- while (1) {
661
- switch (_context.prev = _context.next) {
662
- case 0:
663
- _context.next = 2;
664
- return _regeneratorRuntime().awrap(ParseUser.currentAsync());
665
-
666
- case 2:
667
- current = _context.sent;
668
- return _context.abrupt("return", !!current && current.id === this.id);
669
-
670
- case 4:
671
- case "end":
672
- return _context.stop();
673
- }
674
- }
675
- }, null, this, null, Promise);
676
- }
248
+ var _isCurrentAsync = (0, _asyncToGenerator2.default)(function* () {
249
+ var current = yield ParseUser.currentAsync();
250
+ return !!current && current.id === this.id;
251
+ });
252
+ function isCurrentAsync() {
253
+ return _isCurrentAsync.apply(this, arguments);
254
+ }
255
+ return isCurrentAsync;
256
+ }()
677
257
  }, {
678
258
  key: "getUsername",
679
259
  value: function () {
680
260
  var username = this.get('username');
681
-
682
261
  if (username == null || typeof username === 'string') {
683
262
  return username;
684
263
  }
685
-
686
264
  return '';
687
265
  }
688
266
  }, {
689
267
  key: "setUsername",
690
268
  value: function (username) {
691
269
  var authData = this.get('authData');
692
-
693
270
  if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
694
271
  authData.anonymous = null;
695
272
  }
696
-
697
273
  this.set('username', username);
698
274
  }
699
275
  }, {
@@ -705,11 +281,9 @@ var ParseUser = function (_ParseObject) {
705
281
  key: "getEmail",
706
282
  value: function () {
707
283
  var email = this.get('email');
708
-
709
284
  if (email == null || typeof email === 'string') {
710
285
  return email;
711
286
  }
712
-
713
287
  return '';
714
288
  }
715
289
  }, {
@@ -721,11 +295,9 @@ var ParseUser = function (_ParseObject) {
721
295
  key: "getSessionToken",
722
296
  value: function () {
723
297
  var token = this.get('sessionToken');
724
-
725
298
  if (token == null || typeof token === 'string') {
726
299
  return token;
727
300
  }
728
-
729
301
  return '';
730
302
  }
731
303
  }, {
@@ -739,21 +311,16 @@ var ParseUser = function (_ParseObject) {
739
311
  value: function (attrs, options) {
740
312
  options = options || {};
741
313
  var signupOptions = {};
742
-
743
314
  if (options.hasOwnProperty('useMasterKey')) {
744
315
  signupOptions.useMasterKey = options.useMasterKey;
745
316
  }
746
-
747
317
  if (options.hasOwnProperty('installationId')) {
748
318
  signupOptions.installationId = options.installationId;
749
319
  }
750
-
751
320
  if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
752
321
  signupOptions.context = options.context;
753
322
  }
754
-
755
323
  var controller = _CoreManager.default.getUserController();
756
-
757
324
  return controller.signUp(this, attrs, signupOptions);
758
325
  }
759
326
  }, {
@@ -763,199 +330,94 @@ var ParseUser = function (_ParseObject) {
763
330
  var loginOptions = {
764
331
  usePost: true
765
332
  };
766
-
767
333
  if (options.hasOwnProperty('useMasterKey')) {
768
334
  loginOptions.useMasterKey = options.useMasterKey;
769
335
  }
770
-
771
336
  if (options.hasOwnProperty('installationId')) {
772
337
  loginOptions.installationId = options.installationId;
773
338
  }
774
-
775
339
  if (options.hasOwnProperty('usePost')) {
776
340
  loginOptions.usePost = options.usePost;
777
341
  }
778
-
779
342
  var controller = _CoreManager.default.getUserController();
780
-
781
343
  return controller.logIn(this, loginOptions);
782
344
  }
783
345
  }, {
784
346
  key: "save",
785
347
  value: function () {
786
- var _len,
787
- args,
788
- _key4,
789
- current,
790
- _args2 = arguments;
791
-
792
- return _regeneratorRuntime().async(function (_context2) {
793
- while (1) {
794
- switch (_context2.prev = _context2.next) {
795
- case 0:
796
- for (_len = _args2.length, args = new Array(_len), _key4 = 0; _key4 < _len; _key4++) {
797
- args[_key4] = _args2[_key4];
798
- }
799
-
800
- _context2.next = 3;
801
- return _regeneratorRuntime().awrap((0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "save", this).apply(this, args));
802
-
803
- case 3:
804
- _context2.next = 5;
805
- return _regeneratorRuntime().awrap(this.isCurrentAsync());
806
-
807
- case 5:
808
- current = _context2.sent;
809
-
810
- if (!current) {
811
- _context2.next = 8;
812
- break;
813
- }
814
-
815
- return _context2.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
816
-
817
- case 8:
818
- return _context2.abrupt("return", this);
819
-
820
- case 9:
821
- case "end":
822
- return _context2.stop();
823
- }
348
+ var _save = (0, _asyncToGenerator2.default)(function* () {
349
+ for (var _len = arguments.length, args = new Array(_len), _key4 = 0; _key4 < _len; _key4++) {
350
+ args[_key4] = arguments[_key4];
824
351
  }
825
- }, null, this, null, Promise);
826
- }
352
+ yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "save", this).apply(this, args);
353
+ var current = yield this.isCurrentAsync();
354
+ if (current) {
355
+ return _CoreManager.default.getUserController().updateUserOnDisk(this);
356
+ }
357
+ return this;
358
+ });
359
+ function save() {
360
+ return _save.apply(this, arguments);
361
+ }
362
+ return save;
363
+ }()
827
364
  }, {
828
365
  key: "destroy",
829
366
  value: function () {
830
- var _len2,
831
- args,
832
- _key5,
833
- current,
834
- _args3 = arguments;
835
-
836
- return _regeneratorRuntime().async(function (_context3) {
837
- while (1) {
838
- switch (_context3.prev = _context3.next) {
839
- case 0:
840
- for (_len2 = _args3.length, args = new Array(_len2), _key5 = 0; _key5 < _len2; _key5++) {
841
- args[_key5] = _args3[_key5];
842
- }
843
-
844
- _context3.next = 3;
845
- return _regeneratorRuntime().awrap((0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "destroy", this).apply(this, args));
846
-
847
- case 3:
848
- _context3.next = 5;
849
- return _regeneratorRuntime().awrap(this.isCurrentAsync());
850
-
851
- case 5:
852
- current = _context3.sent;
853
-
854
- if (!current) {
855
- _context3.next = 8;
856
- break;
857
- }
858
-
859
- return _context3.abrupt("return", _CoreManager.default.getUserController().removeUserFromDisk());
860
-
861
- case 8:
862
- return _context3.abrupt("return", this);
863
-
864
- case 9:
865
- case "end":
866
- return _context3.stop();
867
- }
367
+ var _destroy = (0, _asyncToGenerator2.default)(function* () {
368
+ for (var _len2 = arguments.length, args = new Array(_len2), _key5 = 0; _key5 < _len2; _key5++) {
369
+ args[_key5] = arguments[_key5];
868
370
  }
869
- }, null, this, null, Promise);
870
- }
371
+ yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "destroy", this).apply(this, args);
372
+ var current = yield this.isCurrentAsync();
373
+ if (current) {
374
+ return _CoreManager.default.getUserController().removeUserFromDisk();
375
+ }
376
+ return this;
377
+ });
378
+ function destroy() {
379
+ return _destroy.apply(this, arguments);
380
+ }
381
+ return destroy;
382
+ }()
871
383
  }, {
872
384
  key: "fetch",
873
385
  value: function () {
874
- var _len3,
875
- args,
876
- _key6,
877
- current,
878
- _args4 = arguments;
879
-
880
- return _regeneratorRuntime().async(function (_context4) {
881
- while (1) {
882
- switch (_context4.prev = _context4.next) {
883
- case 0:
884
- for (_len3 = _args4.length, args = new Array(_len3), _key6 = 0; _key6 < _len3; _key6++) {
885
- args[_key6] = _args4[_key6];
886
- }
887
-
888
- _context4.next = 3;
889
- return _regeneratorRuntime().awrap((0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetch", this).apply(this, args));
890
-
891
- case 3:
892
- _context4.next = 5;
893
- return _regeneratorRuntime().awrap(this.isCurrentAsync());
894
-
895
- case 5:
896
- current = _context4.sent;
897
-
898
- if (!current) {
899
- _context4.next = 8;
900
- break;
901
- }
902
-
903
- return _context4.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
904
-
905
- case 8:
906
- return _context4.abrupt("return", this);
907
-
908
- case 9:
909
- case "end":
910
- return _context4.stop();
911
- }
386
+ var _fetch = (0, _asyncToGenerator2.default)(function* () {
387
+ for (var _len3 = arguments.length, args = new Array(_len3), _key6 = 0; _key6 < _len3; _key6++) {
388
+ args[_key6] = arguments[_key6];
912
389
  }
913
- }, null, this, null, Promise);
914
- }
390
+ yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetch", this).apply(this, args);
391
+ var current = yield this.isCurrentAsync();
392
+ if (current) {
393
+ return _CoreManager.default.getUserController().updateUserOnDisk(this);
394
+ }
395
+ return this;
396
+ });
397
+ function fetch() {
398
+ return _fetch.apply(this, arguments);
399
+ }
400
+ return fetch;
401
+ }()
915
402
  }, {
916
403
  key: "fetchWithInclude",
917
404
  value: function () {
918
- var _len4,
919
- args,
920
- _key7,
921
- current,
922
- _args5 = arguments;
923
-
924
- return _regeneratorRuntime().async(function (_context5) {
925
- while (1) {
926
- switch (_context5.prev = _context5.next) {
927
- case 0:
928
- for (_len4 = _args5.length, args = new Array(_len4), _key7 = 0; _key7 < _len4; _key7++) {
929
- args[_key7] = _args5[_key7];
930
- }
931
-
932
- _context5.next = 3;
933
- return _regeneratorRuntime().awrap((0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetchWithInclude", this).apply(this, args));
934
-
935
- case 3:
936
- _context5.next = 5;
937
- return _regeneratorRuntime().awrap(this.isCurrentAsync());
938
-
939
- case 5:
940
- current = _context5.sent;
941
-
942
- if (!current) {
943
- _context5.next = 8;
944
- break;
945
- }
946
-
947
- return _context5.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
948
-
949
- case 8:
950
- return _context5.abrupt("return", this);
951
-
952
- case 9:
953
- case "end":
954
- return _context5.stop();
955
- }
405
+ var _fetchWithInclude = (0, _asyncToGenerator2.default)(function* () {
406
+ for (var _len4 = arguments.length, args = new Array(_len4), _key7 = 0; _key7 < _len4; _key7++) {
407
+ args[_key7] = arguments[_key7];
956
408
  }
957
- }, null, this, null, Promise);
958
- }
409
+ yield (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetchWithInclude", this).apply(this, args);
410
+ var current = yield this.isCurrentAsync();
411
+ if (current) {
412
+ return _CoreManager.default.getUserController().updateUserOnDisk(this);
413
+ }
414
+ return this;
415
+ });
416
+ function fetchWithInclude() {
417
+ return _fetchWithInclude.apply(this, arguments);
418
+ }
419
+ return fetchWithInclude;
420
+ }()
959
421
  }, {
960
422
  key: "verifyPassword",
961
423
  value: function (password, options) {
@@ -982,7 +444,6 @@ var ParseUser = function (_ParseObject) {
982
444
  }
983
445
  }
984
446
  }
985
-
986
447
  if (classProps) {
987
448
  for (var _prop2 in classProps) {
988
449
  if (_prop2 !== 'className') {
@@ -995,7 +456,6 @@ var ParseUser = function (_ParseObject) {
995
456
  }
996
457
  }
997
458
  }
998
-
999
459
  return ParseUser;
1000
460
  }
1001
461
  }, {
@@ -1004,9 +464,7 @@ var ParseUser = function (_ParseObject) {
1004
464
  if (!canUseCurrentUser) {
1005
465
  return null;
1006
466
  }
1007
-
1008
467
  var controller = _CoreManager.default.getUserController();
1009
-
1010
468
  return controller.currentUser();
1011
469
  }
1012
470
  }, {
@@ -1015,9 +473,7 @@ var ParseUser = function (_ParseObject) {
1015
473
  if (!canUseCurrentUser) {
1016
474
  return Promise.resolve(null);
1017
475
  }
1018
-
1019
476
  var controller = _CoreManager.default.getUserController();
1020
-
1021
477
  return controller.currentUserAsync();
1022
478
  }
1023
479
  }, {
@@ -1037,14 +493,11 @@ var ParseUser = function (_ParseObject) {
1037
493
  } else if (typeof password !== 'string') {
1038
494
  return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
1039
495
  }
1040
-
1041
496
  var user = new this();
1042
-
1043
497
  user._finishFetch({
1044
498
  username: username,
1045
499
  password: password
1046
500
  });
1047
-
1048
501
  return user.logIn(options);
1049
502
  }
1050
503
  }, {
@@ -1053,18 +506,14 @@ var ParseUser = function (_ParseObject) {
1053
506
  if (!canUseCurrentUser) {
1054
507
  throw new Error('It is not memory-safe to become a user in a server environment');
1055
508
  }
1056
-
1057
509
  options = options || {};
1058
510
  var becomeOptions = {
1059
511
  sessionToken: sessionToken
1060
512
  };
1061
-
1062
513
  if (options.hasOwnProperty('useMasterKey')) {
1063
514
  becomeOptions.useMasterKey = options.useMasterKey;
1064
515
  }
1065
-
1066
516
  var controller = _CoreManager.default.getUserController();
1067
-
1068
517
  var user = new this();
1069
518
  return controller.become(user, becomeOptions);
1070
519
  }
@@ -1072,17 +521,13 @@ var ParseUser = function (_ParseObject) {
1072
521
  key: "me",
1073
522
  value: function (sessionToken) {
1074
523
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1075
-
1076
524
  var controller = _CoreManager.default.getUserController();
1077
-
1078
525
  var meOptions = {
1079
526
  sessionToken: sessionToken
1080
527
  };
1081
-
1082
528
  if (options.useMasterKey) {
1083
529
  meOptions.useMasterKey = options.useMasterKey;
1084
530
  }
1085
-
1086
531
  var user = new this();
1087
532
  return controller.me(user, meOptions);
1088
533
  }
@@ -1090,7 +535,6 @@ var ParseUser = function (_ParseObject) {
1090
535
  key: "hydrate",
1091
536
  value: function (userJSON) {
1092
537
  var controller = _CoreManager.default.getUserController();
1093
-
1094
538
  var user = new this();
1095
539
  return controller.hydrate(user, userJSON);
1096
540
  }
@@ -1104,9 +548,7 @@ var ParseUser = function (_ParseObject) {
1104
548
  key: "logOut",
1105
549
  value: function () {
1106
550
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1107
-
1108
551
  var controller = _CoreManager.default.getUserController();
1109
-
1110
552
  return controller.logOut(options);
1111
553
  }
1112
554
  }, {
@@ -1114,13 +556,10 @@ var ParseUser = function (_ParseObject) {
1114
556
  value: function (email, options) {
1115
557
  options = options || {};
1116
558
  var requestOptions = {};
1117
-
1118
559
  if (options.hasOwnProperty('useMasterKey')) {
1119
560
  requestOptions.useMasterKey = options.useMasterKey;
1120
561
  }
1121
-
1122
562
  var controller = _CoreManager.default.getUserController();
1123
-
1124
563
  return controller.requestPasswordReset(email, requestOptions);
1125
564
  }
1126
565
  }, {
@@ -1128,13 +567,10 @@ var ParseUser = function (_ParseObject) {
1128
567
  value: function (email, options) {
1129
568
  options = options || {};
1130
569
  var requestOptions = {};
1131
-
1132
570
  if (options.hasOwnProperty('useMasterKey')) {
1133
571
  requestOptions.useMasterKey = options.useMasterKey;
1134
572
  }
1135
-
1136
573
  var controller = _CoreManager.default.getUserController();
1137
-
1138
574
  return controller.requestEmailVerification(email, requestOptions);
1139
575
  }
1140
576
  }, {
@@ -1143,20 +579,15 @@ var ParseUser = function (_ParseObject) {
1143
579
  if (typeof username !== 'string') {
1144
580
  return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
1145
581
  }
1146
-
1147
582
  if (typeof password !== 'string') {
1148
583
  return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
1149
584
  }
1150
-
1151
585
  options = options || {};
1152
586
  var verificationOption = {};
1153
-
1154
587
  if (options.hasOwnProperty('useMasterKey')) {
1155
588
  verificationOption.useMasterKey = options.useMasterKey;
1156
589
  }
1157
-
1158
590
  var controller = _CoreManager.default.getUserController();
1159
-
1160
591
  return controller.verifyPassword(username, password, verificationOption);
1161
592
  }
1162
593
  }, {
@@ -1168,17 +599,13 @@ var ParseUser = function (_ParseObject) {
1168
599
  key: "enableRevocableSession",
1169
600
  value: function (options) {
1170
601
  options = options || {};
1171
-
1172
602
  _CoreManager.default.set('FORCE_REVOCABLE_SESSION', true);
1173
-
1174
603
  if (canUseCurrentUser) {
1175
604
  var current = ParseUser.current();
1176
-
1177
605
  if (current) {
1178
606
  return current._upgradeToRevocableSession(options);
1179
607
  }
1180
608
  }
1181
-
1182
609
  return Promise.resolve();
1183
610
  }
1184
611
  }, {
@@ -1221,221 +648,162 @@ var ParseUser = function (_ParseObject) {
1221
648
  }]);
1222
649
  return ParseUser;
1223
650
  }(_ParseObject2.default);
1224
-
1225
651
  _ParseObject2.default.registerSubclass('_User', ParseUser);
1226
-
1227
652
  var DefaultController = {
1228
653
  updateUserOnDisk: function (user) {
1229
654
  var path = _Storage.default.generatePath(CURRENT_USER_KEY);
1230
-
1231
655
  var json = user.toJSON();
1232
656
  delete json.password;
1233
657
  json.className = '_User';
1234
658
  var userData = JSON.stringify(json);
1235
-
1236
659
  if (_CoreManager.default.get('ENCRYPTED_USER')) {
1237
660
  var crypto = _CoreManager.default.getCryptoController();
1238
-
1239
661
  userData = crypto.encrypt(json, _CoreManager.default.get('ENCRYPTED_KEY'));
1240
662
  }
1241
-
1242
663
  return _Storage.default.setItemAsync(path, userData).then(function () {
1243
664
  return user;
1244
665
  });
1245
666
  },
1246
667
  removeUserFromDisk: function () {
1247
668
  var path = _Storage.default.generatePath(CURRENT_USER_KEY);
1248
-
1249
669
  currentUserCacheMatchesDisk = true;
1250
670
  currentUserCache = null;
1251
671
  return _Storage.default.removeItemAsync(path);
1252
672
  },
1253
673
  setCurrentUser: function (user) {
1254
674
  currentUserCache = user;
1255
-
1256
675
  user._cleanupAuthData();
1257
-
1258
676
  user._synchronizeAllAuthData();
1259
-
1260
677
  return DefaultController.updateUserOnDisk(user);
1261
678
  },
1262
679
  currentUser: function () {
1263
680
  if (currentUserCache) {
1264
681
  return currentUserCache;
1265
682
  }
1266
-
1267
683
  if (currentUserCacheMatchesDisk) {
1268
684
  return null;
1269
685
  }
1270
-
1271
686
  if (_Storage.default.async()) {
1272
687
  throw new Error('Cannot call currentUser() when using a platform with an async ' + 'storage system. Call currentUserAsync() instead.');
1273
688
  }
1274
-
1275
689
  var path = _Storage.default.generatePath(CURRENT_USER_KEY);
1276
-
1277
690
  var userData = _Storage.default.getItem(path);
1278
-
1279
691
  currentUserCacheMatchesDisk = true;
1280
-
1281
692
  if (!userData) {
1282
693
  currentUserCache = null;
1283
694
  return null;
1284
695
  }
1285
-
1286
696
  if (_CoreManager.default.get('ENCRYPTED_USER')) {
1287
697
  var crypto = _CoreManager.default.getCryptoController();
1288
-
1289
698
  userData = crypto.decrypt(userData, _CoreManager.default.get('ENCRYPTED_KEY'));
1290
699
  }
1291
-
1292
700
  userData = JSON.parse(userData);
1293
-
1294
701
  if (!userData.className) {
1295
702
  userData.className = '_User';
1296
703
  }
1297
-
1298
704
  if (userData._id) {
1299
705
  if (userData.objectId !== userData._id) {
1300
706
  userData.objectId = userData._id;
1301
707
  }
1302
-
1303
708
  delete userData._id;
1304
709
  }
1305
-
1306
710
  if (userData._sessionToken) {
1307
711
  userData.sessionToken = userData._sessionToken;
1308
712
  delete userData._sessionToken;
1309
713
  }
1310
-
1311
714
  var current = _ParseObject2.default.fromJSON(userData);
1312
-
1313
715
  currentUserCache = current;
1314
-
1315
716
  current._synchronizeAllAuthData();
1316
-
1317
717
  return current;
1318
718
  },
1319
719
  currentUserAsync: function () {
1320
720
  if (currentUserCache) {
1321
721
  return Promise.resolve(currentUserCache);
1322
722
  }
1323
-
1324
723
  if (currentUserCacheMatchesDisk) {
1325
724
  return Promise.resolve(null);
1326
725
  }
1327
-
1328
726
  var path = _Storage.default.generatePath(CURRENT_USER_KEY);
1329
-
1330
727
  return _Storage.default.getItemAsync(path).then(function (userData) {
1331
728
  currentUserCacheMatchesDisk = true;
1332
-
1333
729
  if (!userData) {
1334
730
  currentUserCache = null;
1335
731
  return Promise.resolve(null);
1336
732
  }
1337
-
1338
733
  if (_CoreManager.default.get('ENCRYPTED_USER')) {
1339
734
  var crypto = _CoreManager.default.getCryptoController();
1340
-
1341
735
  userData = crypto.decrypt(userData.toString(), _CoreManager.default.get('ENCRYPTED_KEY'));
1342
736
  }
1343
-
1344
737
  userData = JSON.parse(userData);
1345
-
1346
738
  if (!userData.className) {
1347
739
  userData.className = '_User';
1348
740
  }
1349
-
1350
741
  if (userData._id) {
1351
742
  if (userData.objectId !== userData._id) {
1352
743
  userData.objectId = userData._id;
1353
744
  }
1354
-
1355
745
  delete userData._id;
1356
746
  }
1357
-
1358
747
  if (userData._sessionToken) {
1359
748
  userData.sessionToken = userData._sessionToken;
1360
749
  delete userData._sessionToken;
1361
750
  }
1362
-
1363
751
  var current = _ParseObject2.default.fromJSON(userData);
1364
-
1365
752
  currentUserCache = current;
1366
-
1367
753
  current._synchronizeAllAuthData();
1368
-
1369
754
  return Promise.resolve(current);
1370
755
  });
1371
756
  },
1372
757
  signUp: function (user, attrs, options) {
1373
758
  var username = attrs && attrs.username || user.get('username');
1374
759
  var password = attrs && attrs.password || user.get('password');
1375
-
1376
760
  if (!username || !username.length) {
1377
761
  return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty username.'));
1378
762
  }
1379
-
1380
763
  if (!password || !password.length) {
1381
764
  return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty password.'));
1382
765
  }
1383
-
1384
766
  return user.save(attrs, options).then(function () {
1385
767
  user._finishFetch({
1386
768
  password: undefined
1387
769
  });
1388
-
1389
770
  if (canUseCurrentUser) {
1390
771
  return DefaultController.setCurrentUser(user);
1391
772
  }
1392
-
1393
773
  return user;
1394
774
  });
1395
775
  },
1396
776
  logIn: function (user, options) {
1397
777
  var RESTController = _CoreManager.default.getRESTController();
1398
-
1399
778
  var stateController = _CoreManager.default.getObjectStateController();
1400
-
1401
779
  var auth = {
1402
780
  username: user.get('username'),
1403
781
  password: user.get('password')
1404
782
  };
1405
783
  return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(function (response) {
1406
784
  user._migrateId(response.objectId);
1407
-
1408
785
  user._setExisted(true);
1409
-
1410
786
  stateController.setPendingOp(user._getStateIdentifier(), 'username', undefined);
1411
787
  stateController.setPendingOp(user._getStateIdentifier(), 'password', undefined);
1412
788
  response.password = undefined;
1413
-
1414
789
  user._finishFetch(response);
1415
-
1416
790
  if (!canUseCurrentUser) {
1417
791
  return Promise.resolve(user);
1418
792
  }
1419
-
1420
793
  return DefaultController.setCurrentUser(user);
1421
794
  });
1422
795
  },
1423
796
  become: function (user, options) {
1424
797
  var RESTController = _CoreManager.default.getRESTController();
1425
-
1426
798
  return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
1427
799
  user._finishFetch(response);
1428
-
1429
800
  user._setExisted(true);
1430
-
1431
801
  return DefaultController.setCurrentUser(user);
1432
802
  });
1433
803
  },
1434
804
  hydrate: function (user, userJSON) {
1435
805
  user._finishFetch(userJSON);
1436
-
1437
806
  user._setExisted(true);
1438
-
1439
807
  if (userJSON.sessionToken && canUseCurrentUser) {
1440
808
  return DefaultController.setCurrentUser(user);
1441
809
  } else {
@@ -1444,30 +812,22 @@ var DefaultController = {
1444
812
  },
1445
813
  me: function (user, options) {
1446
814
  var RESTController = _CoreManager.default.getRESTController();
1447
-
1448
815
  return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
1449
816
  user._finishFetch(response);
1450
-
1451
817
  user._setExisted(true);
1452
-
1453
818
  return user;
1454
819
  });
1455
820
  },
1456
821
  logOut: function (options) {
1457
822
  var RESTController = _CoreManager.default.getRESTController();
1458
-
1459
823
  if (options.sessionToken) {
1460
824
  return RESTController.request('POST', 'logout', {}, options);
1461
825
  }
1462
-
1463
826
  return DefaultController.currentUserAsync().then(function (currentUser) {
1464
827
  var path = _Storage.default.generatePath(CURRENT_USER_KEY);
1465
-
1466
828
  var promise = _Storage.default.removeItemAsync(path);
1467
-
1468
829
  if (currentUser !== null) {
1469
830
  var currentSession = currentUser.getSessionToken();
1470
-
1471
831
  if (currentSession && (0, _isRevocableSession.default)(currentSession)) {
1472
832
  promise = promise.then(function () {
1473
833
  return RESTController.request('POST', 'logout', {}, {
@@ -1475,14 +835,11 @@ var DefaultController = {
1475
835
  });
1476
836
  });
1477
837
  }
1478
-
1479
838
  currentUser._logOutWithAll();
1480
-
1481
839
  currentUser._finishFetch({
1482
840
  sessionToken: undefined
1483
841
  });
1484
842
  }
1485
-
1486
843
  currentUserCacheMatchesDisk = true;
1487
844
  currentUserCache = null;
1488
845
  return promise;
@@ -1490,65 +847,35 @@ var DefaultController = {
1490
847
  },
1491
848
  requestPasswordReset: function (email, options) {
1492
849
  var RESTController = _CoreManager.default.getRESTController();
1493
-
1494
850
  return RESTController.request('POST', 'requestPasswordReset', {
1495
851
  email: email
1496
852
  }, options);
1497
853
  },
1498
- upgradeToRevocableSession: function (user, options) {
1499
- var token, RESTController, result, session, current;
1500
- return _regeneratorRuntime().async(function (_context6) {
1501
- while (1) {
1502
- switch (_context6.prev = _context6.next) {
1503
- case 0:
1504
- token = user.getSessionToken();
1505
-
1506
- if (token) {
1507
- _context6.next = 3;
1508
- break;
1509
- }
1510
-
1511
- return _context6.abrupt("return", Promise.reject(new _ParseError.default(_ParseError.default.SESSION_MISSING, 'Cannot upgrade a user with no session token')));
1512
-
1513
- case 3:
1514
- options.sessionToken = token;
1515
- RESTController = _CoreManager.default.getRESTController();
1516
- _context6.next = 7;
1517
- return _regeneratorRuntime().awrap(RESTController.request('POST', 'upgradeToRevocableSession', {}, options));
1518
-
1519
- case 7:
1520
- result = _context6.sent;
1521
- session = new _ParseSession.default();
1522
-
1523
- session._finishFetch(result);
1524
-
1525
- user._finishFetch({
1526
- sessionToken: session.getSessionToken()
1527
- });
1528
-
1529
- _context6.next = 13;
1530
- return _regeneratorRuntime().awrap(user.isCurrentAsync());
1531
-
1532
- case 13:
1533
- current = _context6.sent;
1534
-
1535
- if (!current) {
1536
- _context6.next = 16;
1537
- break;
1538
- }
1539
-
1540
- return _context6.abrupt("return", DefaultController.setCurrentUser(user));
1541
-
1542
- case 16:
1543
- return _context6.abrupt("return", Promise.resolve(user));
1544
-
1545
- case 17:
1546
- case "end":
1547
- return _context6.stop();
1548
- }
854
+ upgradeToRevocableSession: function () {
855
+ var _upgradeToRevocableSession2 = (0, _asyncToGenerator2.default)(function* (user, options) {
856
+ var token = user.getSessionToken();
857
+ if (!token) {
858
+ return Promise.reject(new _ParseError.default(_ParseError.default.SESSION_MISSING, 'Cannot upgrade a user with no session token'));
859
+ }
860
+ options.sessionToken = token;
861
+ var RESTController = _CoreManager.default.getRESTController();
862
+ var result = yield RESTController.request('POST', 'upgradeToRevocableSession', {}, options);
863
+ var session = new _ParseSession.default();
864
+ session._finishFetch(result);
865
+ user._finishFetch({
866
+ sessionToken: session.getSessionToken()
867
+ });
868
+ var current = yield user.isCurrentAsync();
869
+ if (current) {
870
+ return DefaultController.setCurrentUser(user);
1549
871
  }
1550
- }, null, null, null, Promise);
1551
- },
872
+ return Promise.resolve(user);
873
+ });
874
+ function upgradeToRevocableSession() {
875
+ return _upgradeToRevocableSession2.apply(this, arguments);
876
+ }
877
+ return upgradeToRevocableSession;
878
+ }(),
1552
879
  linkWith: function (user, authData, options) {
1553
880
  return user.save({
1554
881
  authData: authData
@@ -1556,13 +883,11 @@ var DefaultController = {
1556
883
  if (canUseCurrentUser) {
1557
884
  return DefaultController.setCurrentUser(user);
1558
885
  }
1559
-
1560
886
  return user;
1561
887
  });
1562
888
  },
1563
889
  verifyPassword: function (username, password, options) {
1564
890
  var RESTController = _CoreManager.default.getRESTController();
1565
-
1566
891
  return RESTController.request('GET', 'verifyPassword', {
1567
892
  username: username,
1568
893
  password: password
@@ -1570,14 +895,11 @@ var DefaultController = {
1570
895
  },
1571
896
  requestEmailVerification: function (email, options) {
1572
897
  var RESTController = _CoreManager.default.getRESTController();
1573
-
1574
898
  return RESTController.request('POST', 'verificationEmailRequest', {
1575
899
  email: email
1576
900
  }, options);
1577
901
  }
1578
902
  };
1579
-
1580
903
  _CoreManager.default.setUserController(DefaultController);
1581
-
1582
904
  var _default = ParseUser;
1583
905
  exports.default = _default;