cozy-client 34.11.1 → 35.1.0

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.
@@ -2669,7 +2669,7 @@ var CozyClient = /*#__PURE__*/function () {
2669
2669
  CozyClient.hooks = CozyClient.hooks || {};
2670
2670
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2671
2671
 
2672
- CozyClient.version = "34.11.1";
2672
+ CozyClient.version = "35.1.0";
2673
2673
 
2674
2674
  _microee.default.mixin(CozyClient);
2675
2675
 
package/dist/index.js CHANGED
@@ -323,7 +323,7 @@ var _registry = _interopRequireDefault(require("./registry"));
323
323
 
324
324
  var _RealTimeQueries = _interopRequireDefault(require("./RealTimeQueries"));
325
325
 
326
- var manifest = _interopRequireWildcard(require("./manifest"));
326
+ var manifest = _interopRequireWildcard(require("./models/manifest"));
327
327
 
328
328
  exports.manifest = manifest;
329
329
 
@@ -221,7 +221,7 @@ var _store = require("./store");
221
221
 
222
222
  var _registry = _interopRequireDefault(require("./registry"));
223
223
 
224
- var manifest = _interopRequireWildcard(require("./manifest"));
224
+ var manifest = _interopRequireWildcard(require("./models/manifest"));
225
225
 
226
226
  exports.manifest = manifest;
227
227
 
@@ -5,41 +5,43 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.setContractSyncStatusInAccount = exports.getContractSyncStatusFromAccount = exports.muteError = exports.getMutedErrors = void 0;
8
+ exports.buildAccount = exports.getAccountName = exports.getAccountLogin = exports.setContractSyncStatusInAccount = exports.getContractSyncStatusFromAccount = exports.muteError = exports.getMutedErrors = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
12
- var _get = _interopRequireDefault(require("lodash/get"));
13
-
14
12
  var _merge = _interopRequireDefault(require("lodash/merge"));
15
13
 
16
14
  var _HasMany = require("../associations/HasMany");
17
15
 
16
+ var _manifest = require("./manifest");
17
+
18
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
19
+
20
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
+
22
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
23
+
18
24
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
19
25
 
20
26
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
27
 
22
- /**
23
- * @typedef {object} CozyAccount
24
- */
25
-
26
28
  /**
27
29
  * getMutedErrors - Returns the list of errors that have been muted for the given account
28
30
  *
29
- * @param {object} account io.cozy.accounts
31
+ * @param {import('../types').IOCozyAccount} account io.cozy.accounts
30
32
  *
31
33
  * @returns {Array} An array of errors with a `type` and `mutedAt` field
32
34
  */
33
35
  var getMutedErrors = function getMutedErrors(account) {
34
- return (0, _get.default)(account, 'mutedErrors', []);
36
+ return (account === null || account === void 0 ? void 0 : account.mutedErrors) || [];
35
37
  };
36
38
  /**
37
39
  * muteError - Adds an error to the list of muted errors for the given account
38
40
  *
39
- * @param {CozyAccount} account io.cozy.accounts
41
+ * @param {import('../types').IOCozyAccount} account io.cozy.accounts
40
42
  * @param {string} errorType The type of the error to mute
41
43
  *
42
- * @returns {CozyAccount} An updated io.cozy.accounts
44
+ * @returns {import('../types').IOCozyAccount} An updated io.cozy.accounts
43
45
  */
44
46
 
45
47
 
@@ -61,22 +63,29 @@ var DEFAULT_CONTRACT_SYNC_STATUS = true;
61
63
  /**
62
64
  * Returns whether a contract is synced from account relationship
63
65
  *
64
- * @param {CozyAccount} account - Cozy account
66
+ * @param {import('../types').IOCozyAccount} account - Cozy account
67
+ * @param {String} contractId - contract identifier
68
+ * @returns {Boolean} synchronisation status
65
69
  */
66
70
 
67
71
  var getContractSyncStatusFromAccount = function getContractSyncStatusFromAccount(account, contractId) {
72
+ var _relItem$metadata$imp, _relItem$metadata;
73
+
68
74
  var relItem = (0, _HasMany.getHasManyItem)(account, 'contracts', contractId);
69
75
 
70
76
  if (!relItem) {
71
77
  throw new Error("Cannot find contrat ".concat(contractId, " in account"));
72
78
  }
73
79
 
74
- return (0, _get.default)(relItem, 'metadata.imported', DEFAULT_CONTRACT_SYNC_STATUS);
80
+ return (_relItem$metadata$imp = relItem === null || relItem === void 0 ? void 0 : (_relItem$metadata = relItem.metadata) === null || _relItem$metadata === void 0 ? void 0 : _relItem$metadata.imported) !== null && _relItem$metadata$imp !== void 0 ? _relItem$metadata$imp : DEFAULT_CONTRACT_SYNC_STATUS;
75
81
  };
76
82
  /**
77
83
  * Sets contract sync status into account relationship
78
84
  *
79
- * @param {CozyAccount} account - Cozy account
85
+ * @param {import('../types').IOCozyAccount} account - Cozy account
86
+ * @param {String} contractId - contract identifier
87
+ * @param {String} syncStatus - synchronisation status
88
+ * @returns {import('../types').IOCozyAccount}
80
89
  */
81
90
 
82
91
 
@@ -95,5 +104,72 @@ var setContractSyncStatusInAccount = function setContractSyncStatusInAccount(acc
95
104
  });
96
105
  });
97
106
  };
107
+ /**
108
+ * Get the account login field value from a given account
109
+ *
110
+ * @param {import('../types').IOCozyAccount} account - the given cozy account
111
+ * @returns {String|null} - Account login
112
+ */
113
+
114
+
115
+ exports.setContractSyncStatusInAccount = setContractSyncStatusInAccount;
116
+
117
+ var getAccountLogin = function getAccountLogin(account) {
118
+ if (account && account.auth) {
119
+ var _iterator = _createForOfIteratorHelper(_manifest.legacyLoginFields),
120
+ _step;
121
+
122
+ try {
123
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
124
+ var fieldName = _step.value;
125
+ if (account.auth[fieldName]) return account.auth[fieldName];
126
+ }
127
+ } catch (err) {
128
+ _iterator.e(err);
129
+ } finally {
130
+ _iterator.f();
131
+ }
132
+ }
133
+
134
+ return null;
135
+ };
136
+ /**
137
+ * Get the account name from a given account
138
+ *
139
+ * @param {import('../types').IOCozyAccount} account - the given cozy account
140
+ * @returns {String|null} - Account name
141
+ */
142
+
143
+
144
+ exports.getAccountLogin = getAccountLogin;
145
+
146
+ var getAccountName = function getAccountName(account) {
147
+ if (!account) return null;
148
+
149
+ if (account.auth) {
150
+ return account.auth.accountName || getAccountLogin(account) || account._id;
151
+ } else {
152
+ return account._id;
153
+ }
154
+ };
155
+ /**
156
+ * Transforms account auth data to io.cozy.accounts document
157
+ *
158
+ * @param {import('../types').IOCozyKonnector} konnector Konnector related to account
159
+ * @param {object} authData Authentication data
160
+ * @returns {import('../types').IOCozyAccount} io.cozy.accounts attributes
161
+ */
162
+
163
+
164
+ exports.getAccountName = getAccountName;
165
+
166
+ var buildAccount = function buildAccount(konnector, authData) {
167
+ return {
168
+ auth: authData,
169
+ account_type: konnector.slug,
170
+ identifier: (0, _manifest.getIdentifier)(konnector.fields),
171
+ state: null
172
+ };
173
+ };
98
174
 
99
- exports.setContractSyncStatusInAccount = setContractSyncStatusInAccount;
175
+ exports.buildAccount = buildAccount;
@@ -3,7 +3,10 @@ import {
3
3
  setContractSyncStatusInAccount,
4
4
  getContractSyncStatusFromAccount,
5
5
  getMutedErrors,
6
- muteError
6
+ muteError,
7
+ getAccountLogin,
8
+ getAccountName,
9
+ buildAccount
7
10
  } from './account'
8
11
 
9
12
  const fixtures = {
@@ -176,4 +179,82 @@ describe('account model', () => {
176
179
  ).toThrow('Cannot find contrat non-existing-contract-id in account')
177
180
  })
178
181
  })
182
+
183
+ describe('getAccountLogin', () => {
184
+ it('should get the login value according to legacyLoginFields order', () => {
185
+ expect(
186
+ getAccountLogin({
187
+ auth: { test: 'testvalue', login: 'loginvalue', email: 'emailvalue' }
188
+ })
189
+ ).toStrictEqual('loginvalue')
190
+
191
+ expect(
192
+ getAccountLogin({
193
+ auth: { test: 'testvalue', email: 'emailvalue' }
194
+ })
195
+ ).toStrictEqual('emailvalue')
196
+
197
+ expect(
198
+ getAccountLogin({
199
+ auth: { test: 'testvalue', email: 'emailvalue', login: 'loginvalue' }
200
+ })
201
+ ).toStrictEqual('loginvalue')
202
+
203
+ expect(
204
+ getAccountLogin({
205
+ auth: { test: 'testvalue' }
206
+ })
207
+ ).toStrictEqual(null)
208
+ })
209
+ })
210
+
211
+ describe('getAccountName', () => {
212
+ it('should return auth.accountName in priority', () => {
213
+ expect(
214
+ getAccountName({
215
+ _id: 'idvalue',
216
+ auth: { _id: 'idvalue', login: 'loginvalue' }
217
+ })
218
+ ).toStrictEqual('loginvalue')
219
+
220
+ expect(
221
+ getAccountName({
222
+ _id: 'idvalue',
223
+ auth: {
224
+ accountName: 'accountNameValue',
225
+ login: 'loginvalue'
226
+ }
227
+ })
228
+ ).toStrictEqual('accountNameValue')
229
+ })
230
+ it('should return account _id by default', () => {
231
+ expect(
232
+ getAccountName({
233
+ _id: 'idvalue',
234
+ auth: {}
235
+ })
236
+ ).toStrictEqual('idvalue')
237
+
238
+ expect(
239
+ getAccountName({
240
+ _id: 'idvalue'
241
+ })
242
+ ).toStrictEqual('idvalue')
243
+ })
244
+ })
245
+ describe('buildAccount', () => {
246
+ it('should build an account', () => {
247
+ expect(
248
+ buildAccount(
249
+ { slug: 'slugvalue', fields: { loginfield: { role: 'identifier' } } },
250
+ { loginfield: 'loginfieldvalue' }
251
+ )
252
+ ).toStrictEqual({
253
+ auth: { loginfield: 'loginfieldvalue' },
254
+ account_type: 'slugvalue',
255
+ identifier: 'loginfield',
256
+ state: null
257
+ })
258
+ })
259
+ })
179
260
  })
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.sanitizeCategories = sanitizeCategories;
9
+ exports.areTermsValid = areTermsValid;
10
+ exports.isPartnershipValid = isPartnershipValid;
11
+ exports.sanitize = sanitize;
12
+ exports.getIdentifier = exports.sanitizeIdentifier = exports.legacyLoginFields = exports.ROLE_IDENTIFIER = void 0;
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
16
+ var _flow2 = _interopRequireDefault(require("lodash/flow"));
17
+
18
+ var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
19
+
20
+ var _findKey = _interopRequireDefault(require("lodash/findKey"));
21
+
22
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
23
+
24
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
+
26
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
27
+
28
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
29
+
30
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
31
+
32
+ var ROLE_IDENTIFIER = 'identifier';
33
+ /**
34
+ * Legacy login fields declared by some konnectors
35
+ */
36
+
37
+ exports.ROLE_IDENTIFIER = ROLE_IDENTIFIER;
38
+ var legacyLoginFields = ['login', 'identifier', 'new_identifier', 'email'];
39
+ exports.legacyLoginFields = legacyLoginFields;
40
+ var legacyEncryptedFields = ['secret', 'dob', 'code', 'answer', 'access_token', 'refresh_token', 'appSecret'];
41
+ var APP_CATEGORIES = ['banking', 'cozy', 'energy', 'health', 'host_provider', 'insurance', 'isp', 'mes_infos', 'online_services', 'others', 'partners', 'press', 'productivity', 'ptnb', 'public_service', 'shopping', 'social', 'telecom', 'transport'];
42
+ /**
43
+ * Filters unauthorized categories. Defaults to ['others'] if no suitable category.
44
+ *
45
+ * @param {Array<Object>} categories - Array of categories
46
+ * @returns {Array<Object>} sanitized categories
47
+ */
48
+
49
+ function sanitizeCategories(categories) {
50
+ if (!categories) return ['others'];
51
+ var filteredList = categories.filter(function (c) {
52
+ return APP_CATEGORIES.includes(c);
53
+ });
54
+ if (!filteredList.length) return ['others'];
55
+ return filteredList;
56
+ }
57
+
58
+ function areTermsValid(terms) {
59
+ return Boolean(terms && terms.id && terms.url && terms.version);
60
+ }
61
+
62
+ function isPartnershipValid(partnership) {
63
+ return Boolean(partnership && partnership.description);
64
+ }
65
+ /**
66
+ * Normalize app manifest, retro-compatibility for old manifests
67
+ *
68
+ * @param {import('../types').Manifest} manifest - app manifest to normalize
69
+ * @returns {import('../types').SanitizedManifest}
70
+ */
71
+
72
+
73
+ function sanitize(manifest) {
74
+ var sanitized = _objectSpread({}, manifest); // Make categories an array and delete category attribute if it exists
75
+
76
+
77
+ if (!manifest.categories && manifest.category && typeof manifest.category === 'string') {
78
+ sanitized.categories = [manifest.category];
79
+ delete sanitized.category;
80
+ }
81
+
82
+ sanitized.categories = sanitizeCategories(sanitized.categories); // manifest name is not an object
83
+
84
+ if (typeof manifest.name === 'object') sanitized.name = manifest.name.en; // Fix camelCase from cozy-stack
85
+
86
+ if (manifest.available_version) {
87
+ sanitized.availableVersion = manifest.available_version;
88
+ delete sanitized.available_version;
89
+ } // Fix camelCase from cozy-stack
90
+
91
+
92
+ if (manifest.latest_version) {
93
+ sanitized.latestVersion = manifest.latestVersion;
94
+ delete sanitized.latest_version;
95
+ } // Remove invalid terms
96
+
97
+
98
+ if (sanitized.terms && !areTermsValid(sanitized.terms)) {
99
+ delete sanitized.terms;
100
+ } // Remove invalid partnership
101
+
102
+
103
+ if (sanitized.partnership && !isPartnershipValid(sanitized.partnership)) {
104
+ delete sanitized.partnership;
105
+ }
106
+
107
+ if (sanitized.fields) {
108
+ sanitized.fields = sanitizeFields(manifest.fields);
109
+ }
110
+
111
+ return sanitized;
112
+ }
113
+ /**
114
+ * Ensures that fields has at least one field with the role 'identifier'
115
+ *
116
+ * @param {import('../types').ManifestFields} fields - Manifest fields
117
+ * @returns {import('../types').ManifestFields} - Sanitized manifest fields
118
+ */
119
+
120
+
121
+ var sanitizeIdentifier = function sanitizeIdentifier(fields) {
122
+ var sanitized = (0, _cloneDeep2.default)(fields);
123
+ var hasIdentifier = false;
124
+
125
+ for (var fieldName in sanitized) {
126
+ if (sanitized[fieldName].role === ROLE_IDENTIFIER) {
127
+ if (hasIdentifier) delete sanitized[fieldName].role;else hasIdentifier = true;
128
+ }
129
+ }
130
+
131
+ if (hasIdentifier) return sanitized;
132
+
133
+ var _iterator = _createForOfIteratorHelper(legacyLoginFields),
134
+ _step;
135
+
136
+ try {
137
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
138
+ var name = _step.value;
139
+
140
+ if (sanitized[name]) {
141
+ sanitized[name].role = ROLE_IDENTIFIER;
142
+ return sanitized;
143
+ }
144
+ }
145
+ } catch (err) {
146
+ _iterator.e(err);
147
+ } finally {
148
+ _iterator.f();
149
+ }
150
+
151
+ for (var _fieldName in sanitized) {
152
+ if (sanitized[_fieldName].type !== 'password') {
153
+ sanitized[_fieldName].role = ROLE_IDENTIFIER;
154
+ return sanitized;
155
+ }
156
+ }
157
+
158
+ return sanitized;
159
+ };
160
+ /**
161
+ * Returns the key for the field having the role=identifier attribute
162
+ *
163
+ * @param {import('../types').ManifestFields} fields Konnector fields
164
+ * @returns {String|null} The key for the identifier field, example 'login'
165
+ */
166
+
167
+
168
+ exports.sanitizeIdentifier = sanitizeIdentifier;
169
+
170
+ var getIdentifier = function getIdentifier() {
171
+ var fields = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
172
+ return (0, _findKey.default)(sanitizeIdentifier(fields), function (field) {
173
+ return field.role === ROLE_IDENTIFIER;
174
+ }) || null;
175
+ };
176
+ /**
177
+ * Ensures old fields are removed
178
+ *
179
+ * @param {Object} fields Manifest fields
180
+ * @returns {Object} Sanitized manifest fields
181
+ */
182
+
183
+
184
+ exports.getIdentifier = getIdentifier;
185
+
186
+ var removeOldFields = function removeOldFields(fields) {
187
+ var sanitized = (0, _cloneDeep2.default)(fields);
188
+ delete sanitized.advancedFields;
189
+ return sanitized;
190
+ };
191
+ /**
192
+ * Ensures every field not explicitely tagged as not required is required
193
+ *
194
+ * @param {import('../types').ManifestFields} [fields={}] Manifest fields
195
+ * @returns {import('../types').ManifestFields} Sanitized manifest fields
196
+ */
197
+
198
+
199
+ var sanitizeRequired = function sanitizeRequired(fields) {
200
+ var sanitized = (0, _cloneDeep2.default)(fields);
201
+
202
+ for (var fieldName in sanitized) {
203
+ var field = sanitized[fieldName]; // Ensure legacy for field isRequired
204
+
205
+ var required = typeof field.required === 'undefined' ? field.isRequired : field.required;
206
+ sanitized[fieldName].required = typeof required === 'boolean' ? required : true;
207
+ }
208
+
209
+ return sanitized;
210
+ };
211
+ /**
212
+ * Ensures:
213
+ * * any field flagged as encrypted keeps its flag
214
+ * * any legacy encrypted field is tagged as encrypted
215
+ *
216
+ * @param {import('../types').ManifestFields} [fields={}] Manifest fields
217
+ * @returns {import('../types').ManifestFields} Sanitized Manifest fields
218
+ */
219
+
220
+
221
+ var sanitizeEncrypted = function sanitizeEncrypted(fields) {
222
+ var sanitized = (0, _cloneDeep2.default)(fields);
223
+
224
+ for (var fieldName in sanitized) {
225
+ var field = sanitized[fieldName];
226
+ if (typeof field.encrypted !== 'boolean') field.encrypted = field.type === 'password' || legacyEncryptedFields.includes(fieldName);
227
+ }
228
+
229
+ return sanitized;
230
+ };
231
+ /**
232
+ * Sanitizes manifest fields with multiple rules
233
+ *
234
+ * @param {import('../types').ManifestFields} [fields={}] Manifest fields
235
+ * @returns {import('../types').ManifestFields} Sanitized manifest fields
236
+ */
237
+
238
+
239
+ var sanitizeFields = (0, _flow2.default)([removeOldFields, sanitizeIdentifier, sanitizeRequired, sanitizeEncrypted]);