cozy-client 27.10.0 → 27.13.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,48 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [27.13.0](https://github.com/cozy/cozy-client/compare/v27.12.0...v27.13.0) (2022-01-24)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add fetchBlobFileById function ([eb37b1a](https://github.com/cozy/cozy-client/commit/eb37b1af091d3e95372a0540ad0f14ba59e74a4c))
12
+
13
+
14
+
15
+
16
+
17
+ # [27.12.0](https://github.com/cozy/cozy-client/compare/v27.11.1...v27.12.0) (2022-01-14)
18
+
19
+
20
+ ### Features
21
+
22
+ * Use lib alias for safetynet ([f937db5](https://github.com/cozy/cozy-client/commit/f937db5eaedf4d41e88f7380ffbe79867941af59))
23
+
24
+
25
+
26
+
27
+
28
+ ## [27.11.1](https://github.com/cozy/cozy-client/compare/v27.11.0...v27.11.1) (2022-01-14)
29
+
30
+ **Note:** Version bump only for package cozy-client
31
+
32
+
33
+
34
+
35
+
36
+ # [27.11.0](https://github.com/cozy/cozy-client/compare/v27.10.0...v27.11.0) (2022-01-13)
37
+
38
+
39
+ ### Features
40
+
41
+ * Change other_identity_document translations ([aebb1bf](https://github.com/cozy/cozy-client/commit/aebb1bff1721f17baf12b79c92440467b4549257))
42
+ * Move other_revenue in finance theme ([dcb54fa](https://github.com/cozy/cozy-client/commit/dcb54fa11eced184524d6c6c713636e8b7e2f06f))
43
+
44
+
45
+
46
+
47
+
6
48
  # [27.10.0](https://github.com/cozy/cozy-client/compare/v27.9.0...v27.10.0) (2022-01-12)
7
49
 
8
50
 
@@ -2463,7 +2463,7 @@ var CozyClient = /*#__PURE__*/function () {
2463
2463
  CozyClient.hooks = CozyClient.hooks || {};
2464
2464
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2465
2465
 
2466
- CozyClient.version = "27.10.0";
2466
+ CozyClient.version = "27.13.0";
2467
2467
 
2468
2468
  _microee.default.mixin(CozyClient);
2469
2469
 
@@ -50,13 +50,13 @@ The `attestation`'s content is described in the `AppAttest`'s documentation: htt
50
50
 
51
51
  ## Client's configuration
52
52
 
53
- In order to configure `flagship` certification on an app, the OAuth property of `cozy-client` must contain `shouldRequireFlagshipPermissions` property set to `true` and `certificationConfig` property filled with required API keys.
53
+ In order to configure `flagship` certification on an app, the OAuth property of `cozy-client` must contain `shouldRequireFlagshipPermissions` property set to `true` and `certificationConfig` property filled with required API keys. In that case, the OAuth client can claims "*" as scope
54
54
 
55
55
  Example of `cozy-client` configuration:
56
56
  ```js
57
57
  const client = await initClient(uri, {
58
58
  scope: [
59
- 'io.cozy.apps'
59
+ '*'
60
60
  ],
61
61
  oauth: {
62
62
  redirectURI: 'REDIRECT_URI',
@@ -42,7 +42,7 @@ var familyLabels = ['family_record_book', 'birth_certificate', 'wedding', 'pacs'
42
42
  * @type {Array<WorkStudyLabels>}
43
43
  */
44
44
 
45
- var workStudyLabels = ['diploma', 'work_contract', 'pay_sheet', 'unemployment_benefit', 'pension', 'work_disability_recognition', 'other_revenue', 'gradebook', 'student_card', 'school_attendance_certificate', 'resume', 'motivation_letter', 'other_work_document'];
45
+ var workStudyLabels = ['diploma', 'work_contract', 'pay_sheet', 'unemployment_benefit', 'pension', 'work_disability_recognition', 'gradebook', 'student_card', 'school_attendance_certificate', 'resume', 'motivation_letter', 'other_work_document'];
46
46
  /**
47
47
  * @type {Array<HealthLabels>}
48
48
  */
@@ -67,7 +67,7 @@ var activityLabels = ['personal_sporting_licence', 'other_activity_document'];
67
67
  * @type {Array<FinanceLabels>}
68
68
  */
69
69
 
70
- var financeLabels = ['tax_return', 'tax_notice', 'tax_timetable', 'receipt', 'other_tax_document', 'bank_details', 'bank_statement', 'loan_agreement', 'payment_proof_family_allowance', 'other_bank_document'];
70
+ var financeLabels = ['tax_return', 'tax_notice', 'tax_timetable', 'receipt', 'other_tax_document', 'bank_details', 'bank_statement', 'loan_agreement', 'payment_proof_family_allowance', 'other_bank_document', 'other_revenue'];
71
71
  /**
72
72
  * @type {Array<InvoiceLabels>}
73
73
  */
@@ -33,7 +33,7 @@
33
33
  "birth_certificate": "Birth certificate",
34
34
  "citizen_registration_certificate": "Certificate of citizen registration",
35
35
  "driver_license": "Driving license",
36
- "other_identity_document": "Other identity",
36
+ "other_identity_document": "Other document of identity",
37
37
  "wedding": "Wedding contract",
38
38
  "pacs": "Civil union",
39
39
  "divorce": "Divorce",
@@ -33,7 +33,7 @@
33
33
  "birth_certificate": "Certificat de naissance",
34
34
  "citizen_registration_certificate": "Attestation de recensement citoyen",
35
35
  "driver_license": "Permis",
36
- "other_identity_document": "Autre identité",
36
+ "other_identity_document": "Autre document d'identité",
37
37
  "wedding": "Contrat de mariage",
38
38
  "pacs": "Attestation de PACS",
39
39
  "divorce": "Attestation de divorce",
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.normalize = normalize;
9
9
  exports.ensureFilePath = ensureFilePath;
10
10
  exports.getParentFolderId = getParentFolderId;
11
- exports.isFromKonnector = exports.hasCertifications = exports.hasQualifications = exports.isPlainText = exports.doMobileUpload = exports.readMobileFile = exports.uploadFileWithConflictStrategy = exports.generateFileNameForRevision = exports.generateNewFileNameOnConflict = exports.overrideFileForPath = exports.move = exports.getFullpath = exports.hasMetadataAttribute = exports.isReferencedByAlbum = exports.fetchFilesByQualificationRules = exports.saveFileQualification = exports.isSharingShorcutNew = exports.isSharingShortcutNew = exports.isSharingShorcut = exports.isSharingShortcut = exports.getSharingShortcutTargetDoctype = exports.getSharingShortcutTargetMime = exports.getSharingShortcutStatus = exports.isShortcut = exports.shouldBeOpenedByOnlyOffice = exports.isOnlyOfficeFile = exports.isNote = exports.isDirectory = exports.isFile = exports.splitFilename = exports.ALBUMS_DOCTYPE = void 0;
11
+ exports.fetchBlobFileById = exports.isFromKonnector = exports.hasCertifications = exports.hasQualifications = exports.isPlainText = exports.doMobileUpload = exports.readMobileFile = exports.uploadFileWithConflictStrategy = exports.generateFileNameForRevision = exports.generateNewFileNameOnConflict = exports.overrideFileForPath = exports.move = exports.getFullpath = exports.hasMetadataAttribute = exports.isReferencedByAlbum = exports.fetchFilesByQualificationRules = exports.saveFileQualification = exports.isSharingShorcutNew = exports.isSharingShortcutNew = exports.isSharingShorcut = exports.isSharingShortcut = exports.getSharingShortcutTargetDoctype = exports.getSharingShortcutTargetMime = exports.getSharingShortcutStatus = exports.isShortcut = exports.shouldBeOpenedByOnlyOffice = exports.isOnlyOfficeFile = exports.isNote = exports.isDirectory = exports.isFile = exports.splitFilename = exports.ALBUMS_DOCTYPE = void 0;
12
12
 
13
13
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
14
14
 
@@ -1023,5 +1023,46 @@ exports.hasCertifications = hasCertifications;
1023
1023
  var isFromKonnector = function isFromKonnector(file) {
1024
1024
  return (0, _has.default)(file, 'cozyMetadata.sourceAccount');
1025
1025
  };
1026
+ /**
1027
+ * @param {CozyClient} client - Instance of CozyClient
1028
+ * @param {string} fileId - Id of io.cozy.files document
1029
+ * @returns {Promise<Blob>}
1030
+ */
1031
+
1032
+
1033
+ exports.isFromKonnector = isFromKonnector;
1034
+
1035
+ var fetchBlobFileById = /*#__PURE__*/function () {
1036
+ var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(client, fileId) {
1037
+ var fileColl, fileBin, fileBlob;
1038
+ return _regenerator.default.wrap(function _callee12$(_context12) {
1039
+ while (1) {
1040
+ switch (_context12.prev = _context12.next) {
1041
+ case 0:
1042
+ fileColl = client.collection(_const.DOCTYPE_FILES);
1043
+ _context12.next = 3;
1044
+ return fileColl.fetchFileContentById(fileId);
1045
+
1046
+ case 3:
1047
+ fileBin = _context12.sent;
1048
+ _context12.next = 6;
1049
+ return fileBin.blob();
1050
+
1051
+ case 6:
1052
+ fileBlob = _context12.sent;
1053
+ return _context12.abrupt("return", fileBlob);
1054
+
1055
+ case 8:
1056
+ case "end":
1057
+ return _context12.stop();
1058
+ }
1059
+ }
1060
+ }, _callee12);
1061
+ }));
1062
+
1063
+ return function fetchBlobFileById(_x25, _x26) {
1064
+ return _ref13.apply(this, arguments);
1065
+ };
1066
+ }();
1026
1067
 
1027
- exports.isFromKonnector = isFromKonnector;
1068
+ exports.fetchBlobFileById = fetchBlobFileById;
@@ -15,6 +15,7 @@ const statByPathSpy = jest.fn().mockName('statByPath')
15
15
  const updateFileMetadataSpy = jest.fn().mockName('updateFileMetadata')
16
16
  const createFileSpy = jest.fn().mockName('createFileSpy')
17
17
  const updateFileSpy = jest.fn().mockName('updateFileSpy')
18
+ const fetchFileContentByIdSpy = jest.fn().mockName('fetchFileContentById')
18
19
 
19
20
  beforeAll(() => {
20
21
  cozyClient.stackClient.collection.mockReturnValue({
@@ -23,7 +24,8 @@ beforeAll(() => {
23
24
  statByPath: statByPathSpy,
24
25
  updateFileMetadata: updateFileMetadataSpy,
25
26
  createFile: createFileSpy,
26
- updateFile: updateFileSpy
27
+ updateFile: updateFileSpy,
28
+ fetchFileContentById: fetchFileContentByIdSpy
27
29
  })
28
30
  })
29
31
 
@@ -702,6 +704,21 @@ describe('File Model', () => {
702
704
  })
703
705
  })
704
706
  })
707
+
708
+ describe('fetchBlobFileById', () => {
709
+ const mockData = { _id: '001', name: 'file01' }
710
+
711
+ it('should return Blob data', async () => {
712
+ fetchFileContentByIdSpy.mockImplementation(() => ({
713
+ blob: jest.fn().mockReturnValue(new Blob([mockData]))
714
+ }))
715
+ const res = await fileModel.fetchBlobFileById(cozyClient, mockData._id)
716
+
717
+ expect(fetchFileContentByIdSpy).toHaveBeenCalledWith('001')
718
+ expect(res instanceof Blob).toEqual(true)
719
+ expect(res.size).toBeGreaterThan(0)
720
+ })
721
+ })
705
722
  })
706
723
 
707
724
  describe('File qualification', () => {
package/dist/types.js CHANGED
@@ -280,7 +280,7 @@ var _dsl = require("./queries/dsl");
280
280
  *
281
281
  * @typedef {'family_record_book'|'birth_certificate'|'wedding'|'pacs'|'divorce'|'large_family_card'|'caf'|'other_family_document'|'payment_proof_family_allowance'} FamilyLabel
282
282
  *
283
- * @typedef {'diploma'|'work_contract'|'pay_sheet'|'unemployment_benefit'|'pension'|'other_revenue'|'gradebook'|'student_card'|'resume'|'motivation_letter'|'other_work_document'|'work_disability_recognition'|'school_attendance_certificate'} WorkStudyLabels
283
+ * @typedef {'diploma'|'work_contract'|'pay_sheet'|'unemployment_benefit'|'pension'|'gradebook'|'student_card'|'resume'|'motivation_letter'|'other_work_document'|'work_disability_recognition'|'school_attendance_certificate'} WorkStudyLabels
284
284
  *
285
285
  * @typedef {'health_certificate'|'health_book'|'national_health_insurance_card'|'health_insurance_card'|'prescription'|'health_invoice'|'national_health_insurance_right_certificate'|'work_disability_recognition'|'pregnancy_medical_certificate'|'other_health_document'} HealthLabels
286
286
  *
@@ -288,7 +288,7 @@ var _dsl = require("./queries/dsl");
288
288
  *
289
289
  * @typedef {'driver_license'|'vehicle_registration'|'car_insurance'|'mechanic_invoice'|'transport_invoice'|'other_transport_document'} TransportLabels
290
290
  *
291
- * @typedef {'tax_return'|'tax_notice'|'tax_timetable'|'receipt'|'other_tax_document'|'bank_details'|'bank_statement'|'loan_agreement'|'other_bank_document'|'payment_proof_family_allowance'} FinanceLabels
291
+ * @typedef {'tax_return'|'tax_notice'|'tax_timetable'|'receipt'|'other_tax_document'|'bank_details'|'bank_statement'|'loan_agreement'|'other_bank_document'|'payment_proof_family_allowance'|'other_revenue'} FinanceLabels
292
292
  *
293
293
  * @typedef {'phone_invoice'|'isp_invoice'|'telecom_invoice'|'energy_invoice'|'water_invoice'|'appliance_invoice'|'web_service_invoice'|'restaurant_invoice'|'work_invoice'|'transport_invoice'|'health_invoice'|'other_invoice'} InvoiceLabels
294
294
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "27.10.0",
3
+ "version": "27.13.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -66,10 +66,10 @@
66
66
  "cozy-ui": ">34.0.0",
67
67
  "react": "^16.7.0",
68
68
  "react-native": "^0.65.0",
69
- "react-native-google-safetynet": "0.0.4",
69
+ "react-native-google-safetynet": "npm:cozy-react-native-google-safetynet@^1.0.0",
70
70
  "react-native-inappbrowser-reborn": "^3.5.1",
71
71
  "react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
72
72
  },
73
73
  "sideEffects": false,
74
- "gitHead": "9feb3af42ffa1a2efbfcbf414754147d63f88edc"
74
+ "gitHead": "722612063fc639ce573a2b4239970cd13e61d2fb"
75
75
  }
@@ -61,6 +61,7 @@ export function isPlainText(mimeType?: string, fileName?: string): boolean;
61
61
  export function hasQualifications(file: IOCozyFile): boolean;
62
62
  export function hasCertifications(file: IOCozyFile): boolean;
63
63
  export function isFromKonnector(file: IOCozyFile): boolean;
64
+ export function fetchBlobFileById(client: CozyClient, fileId: string): Promise<Blob>;
64
65
  export type FileUploadOptions = {
65
66
  /**
66
67
  * - The file name to upload
package/types/types.d.ts CHANGED
@@ -317,12 +317,12 @@ export type QualificationAttributes = {
317
317
  };
318
318
  export type IdentityLabel = "identity_photo" | "national_id_card" | "passport" | "residence_permit" | "family_record_book" | "birth_certificate" | "driver_license" | "other_identity_document" | "citizen_registration_certificate" | "personal_sporting_licence";
319
319
  export type FamilyLabel = "family_record_book" | "birth_certificate" | "wedding" | "pacs" | "divorce" | "large_family_card" | "caf" | "other_family_document" | "payment_proof_family_allowance";
320
- export type WorkStudyLabels = "resume" | "diploma" | "work_contract" | "pay_sheet" | "unemployment_benefit" | "pension" | "other_revenue" | "gradebook" | "student_card" | "motivation_letter" | "other_work_document" | "work_disability_recognition" | "school_attendance_certificate";
320
+ export type WorkStudyLabels = "resume" | "diploma" | "work_contract" | "pay_sheet" | "unemployment_benefit" | "pension" | "gradebook" | "student_card" | "motivation_letter" | "other_work_document" | "work_disability_recognition" | "school_attendance_certificate";
321
321
  export type HealthLabels = "work_disability_recognition" | "health_certificate" | "health_book" | "national_health_insurance_card" | "health_insurance_card" | "prescription" | "health_invoice" | "national_health_insurance_right_certificate" | "pregnancy_medical_certificate" | "other_health_document";
322
322
  export type HomeLabels = "phone_invoice" | "isp_invoice" | "telecom_invoice" | "energy_invoice" | "water_invoice" | "house_sale_agreeement" | "building_permit" | "technical_diagnostic_record" | "lease" | "rent_receipt" | "house_insurance" | "work_quote" | "work_invoice" | "other_house_document" | "unfit_for_habitation_declaration" | "accommodation_proof";
323
323
  export type TransportLabels = "driver_license" | "vehicle_registration" | "car_insurance" | "mechanic_invoice" | "transport_invoice" | "other_transport_document";
324
- export type FinanceLabels = "payment_proof_family_allowance" | "tax_return" | "tax_notice" | "tax_timetable" | "receipt" | "other_tax_document" | "bank_details" | "bank_statement" | "loan_agreement" | "other_bank_document";
324
+ export type FinanceLabels = "payment_proof_family_allowance" | "tax_return" | "tax_notice" | "tax_timetable" | "receipt" | "other_tax_document" | "bank_details" | "bank_statement" | "loan_agreement" | "other_bank_document" | "other_revenue";
325
325
  export type InvoiceLabels = "health_invoice" | "phone_invoice" | "isp_invoice" | "telecom_invoice" | "energy_invoice" | "water_invoice" | "work_invoice" | "transport_invoice" | "appliance_invoice" | "web_service_invoice" | "restaurant_invoice" | "other_invoice";
326
326
  export type ActivityLabels = "personal_sporting_licence" | "other_activity_document";
327
- export type ItemsLabels = "resume" | "identity_photo" | "national_id_card" | "passport" | "residence_permit" | "family_record_book" | "birth_certificate" | "driver_license" | "other_identity_document" | "citizen_registration_certificate" | "personal_sporting_licence" | "wedding" | "pacs" | "divorce" | "large_family_card" | "caf" | "other_family_document" | "payment_proof_family_allowance" | "diploma" | "work_contract" | "pay_sheet" | "unemployment_benefit" | "pension" | "other_revenue" | "gradebook" | "student_card" | "motivation_letter" | "other_work_document" | "work_disability_recognition" | "school_attendance_certificate" | "health_certificate" | "health_book" | "national_health_insurance_card" | "health_insurance_card" | "prescription" | "health_invoice" | "national_health_insurance_right_certificate" | "pregnancy_medical_certificate" | "other_health_document" | "phone_invoice" | "isp_invoice" | "telecom_invoice" | "energy_invoice" | "water_invoice" | "house_sale_agreeement" | "building_permit" | "technical_diagnostic_record" | "lease" | "rent_receipt" | "house_insurance" | "work_quote" | "work_invoice" | "other_house_document" | "unfit_for_habitation_declaration" | "accommodation_proof" | "vehicle_registration" | "car_insurance" | "mechanic_invoice" | "transport_invoice" | "other_transport_document" | "tax_return" | "tax_notice" | "tax_timetable" | "receipt" | "other_tax_document" | "bank_details" | "bank_statement" | "loan_agreement" | "other_bank_document" | "appliance_invoice" | "web_service_invoice" | "restaurant_invoice" | "other_invoice" | "other_activity_document";
327
+ export type ItemsLabels = "resume" | "identity_photo" | "national_id_card" | "passport" | "residence_permit" | "family_record_book" | "birth_certificate" | "driver_license" | "other_identity_document" | "citizen_registration_certificate" | "personal_sporting_licence" | "wedding" | "pacs" | "divorce" | "large_family_card" | "caf" | "other_family_document" | "payment_proof_family_allowance" | "diploma" | "work_contract" | "pay_sheet" | "unemployment_benefit" | "pension" | "gradebook" | "student_card" | "motivation_letter" | "other_work_document" | "work_disability_recognition" | "school_attendance_certificate" | "health_certificate" | "health_book" | "national_health_insurance_card" | "health_insurance_card" | "prescription" | "health_invoice" | "national_health_insurance_right_certificate" | "pregnancy_medical_certificate" | "other_health_document" | "phone_invoice" | "isp_invoice" | "telecom_invoice" | "energy_invoice" | "water_invoice" | "house_sale_agreeement" | "building_permit" | "technical_diagnostic_record" | "lease" | "rent_receipt" | "house_insurance" | "work_quote" | "work_invoice" | "other_house_document" | "unfit_for_habitation_declaration" | "accommodation_proof" | "vehicle_registration" | "car_insurance" | "mechanic_invoice" | "transport_invoice" | "other_transport_document" | "tax_return" | "tax_notice" | "tax_timetable" | "receipt" | "other_tax_document" | "bank_details" | "bank_statement" | "loan_agreement" | "other_bank_document" | "other_revenue" | "appliance_invoice" | "web_service_invoice" | "restaurant_invoice" | "other_invoice" | "other_activity_document";
328
328
  import { QueryDefinition } from "./queries/dsl";