mobiletto 1.2.1 → 2.0.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.
Files changed (124) hide show
  1. package/lib/cjs/index.d.ts +2 -0
  2. package/lib/cjs/index.js +30 -0
  3. package/lib/cjs/package.json +16 -0
  4. package/lib/esm/index.d.ts +2 -0
  5. package/lib/esm/index.js +12 -0
  6. package/package.json +27 -13
  7. package/.babelrc +0 -5
  8. package/.eslintrc.js +0 -14
  9. package/docs/README.md +0 -113
  10. package/docs/af/README.md +0 -481
  11. package/docs/am/README.md +0 -481
  12. package/docs/ar/README.md +0 -481
  13. package/docs/az/README.md +0 -481
  14. package/docs/be/README.md +0 -481
  15. package/docs/bg/README.md +0 -481
  16. package/docs/bn/README.md +0 -481
  17. package/docs/bs/README.md +0 -481
  18. package/docs/ca/README.md +0 -481
  19. package/docs/ceb/README.md +0 -481
  20. package/docs/co/README.md +0 -481
  21. package/docs/cs/README.md +0 -481
  22. package/docs/cy/README.md +0 -481
  23. package/docs/da/README.md +0 -481
  24. package/docs/de/README.md +0 -481
  25. package/docs/el/README.md +0 -481
  26. package/docs/eo/README.md +0 -481
  27. package/docs/es/README.md +0 -481
  28. package/docs/et/README.md +0 -481
  29. package/docs/eu/README.md +0 -481
  30. package/docs/fa/README.md +0 -481
  31. package/docs/fi/README.md +0 -481
  32. package/docs/fr/README.md +0 -481
  33. package/docs/fy/README.md +0 -481
  34. package/docs/ga/README.md +0 -481
  35. package/docs/gd/README.md +0 -481
  36. package/docs/gl/README.md +0 -481
  37. package/docs/gu/README.md +0 -481
  38. package/docs/ha/README.md +0 -481
  39. package/docs/haw/README.md +0 -481
  40. package/docs/he/README.md +0 -481
  41. package/docs/hi/README.md +0 -481
  42. package/docs/hmn/README.md +0 -481
  43. package/docs/hr/README.md +0 -481
  44. package/docs/ht/README.md +0 -481
  45. package/docs/hu/README.md +0 -481
  46. package/docs/hy/README.md +0 -481
  47. package/docs/id/README.md +0 -481
  48. package/docs/ig/README.md +0 -481
  49. package/docs/is/README.md +0 -481
  50. package/docs/it/README.md +0 -481
  51. package/docs/iw/README.md +0 -481
  52. package/docs/ja/README.md +0 -481
  53. package/docs/jv/README.md +0 -481
  54. package/docs/ka/README.md +0 -481
  55. package/docs/kk/README.md +0 -481
  56. package/docs/km/README.md +0 -481
  57. package/docs/kn/README.md +0 -481
  58. package/docs/ko/README.md +0 -481
  59. package/docs/ku/README.md +0 -481
  60. package/docs/ky/README.md +0 -481
  61. package/docs/la/README.md +0 -481
  62. package/docs/lb/README.md +0 -481
  63. package/docs/lo/README.md +0 -481
  64. package/docs/lt/README.md +0 -481
  65. package/docs/lv/README.md +0 -481
  66. package/docs/mg/README.md +0 -481
  67. package/docs/mi/README.md +0 -481
  68. package/docs/mk/README.md +0 -481
  69. package/docs/ml/README.md +0 -481
  70. package/docs/mn/README.md +0 -481
  71. package/docs/mr/README.md +0 -481
  72. package/docs/ms/README.md +0 -481
  73. package/docs/mt/README.md +0 -481
  74. package/docs/my/README.md +0 -481
  75. package/docs/ne/README.md +0 -481
  76. package/docs/nl/README.md +0 -481
  77. package/docs/no/README.md +0 -481
  78. package/docs/ny/README.md +0 -481
  79. package/docs/or/README.md +0 -481
  80. package/docs/pa/README.md +0 -481
  81. package/docs/pl/README.md +0 -481
  82. package/docs/ps/README.md +0 -481
  83. package/docs/pt/README.md +0 -481
  84. package/docs/ro/README.md +0 -481
  85. package/docs/ru/README.md +0 -481
  86. package/docs/rw/README.md +0 -481
  87. package/docs/sd/README.md +0 -481
  88. package/docs/si/README.md +0 -481
  89. package/docs/sk/README.md +0 -481
  90. package/docs/sl/README.md +0 -481
  91. package/docs/sm/README.md +0 -481
  92. package/docs/sn/README.md +0 -481
  93. package/docs/so/README.md +0 -481
  94. package/docs/sq/README.md +0 -481
  95. package/docs/sr/README.md +0 -481
  96. package/docs/st/README.md +0 -481
  97. package/docs/su/README.md +0 -481
  98. package/docs/sv/README.md +0 -481
  99. package/docs/sw/README.md +0 -481
  100. package/docs/ta/README.md +0 -481
  101. package/docs/te/README.md +0 -481
  102. package/docs/tg/README.md +0 -481
  103. package/docs/th/README.md +0 -481
  104. package/docs/tk/README.md +0 -481
  105. package/docs/tl/README.md +0 -481
  106. package/docs/tr/README.md +0 -481
  107. package/docs/tt/README.md +0 -481
  108. package/docs/ug/README.md +0 -481
  109. package/docs/uk/README.md +0 -481
  110. package/docs/ur/README.md +0 -481
  111. package/docs/uz/README.md +0 -481
  112. package/docs/vi/README.md +0 -481
  113. package/docs/xh/README.md +0 -481
  114. package/docs/yi/README.md +0 -481
  115. package/docs/yo/README.md +0 -481
  116. package/docs/zh/README.md +0 -481
  117. package/docs/zu/README.md +0 -481
  118. package/drivers/b2/index.js +0 -451
  119. package/drivers/local/index.js +0 -315
  120. package/drivers/s3/index.js +0 -316
  121. package/hokey.json +0 -16
  122. package/index.js +0 -29
  123. package/test/api.spec.js +0 -512
  124. package/test/crypt.spec.js +0 -67
package/docs/iw/README.md DELETED
@@ -1,481 +0,0 @@
1
- Mobiletto
2
- =========
3
-
4
- Mobiletto היא שכבת הפשטה לאחסון JavaScript, עם הצפנה שקופה אופציונלית בצד הלקוח.
5
-
6
- # תוכן
7
- * [למה Mobiletto?](#Why-Mobiletto?)
8
- * [התחלה מהירה](#Quick-start)
9
- * [Mobiletto CLI](#mobiletto-cli)
10
- * [מקור](#מקור)
11
- * [התקנה](#התקנה)
12
- * [תמיכה ומימון](#Support-and-Funding)
13
- * [שימוש בסיסי](#שימוש בסיסי)
14
- * [Metadata](#Metadata)
15
- * [סגנון ייבוא חלופי](#סגנון ייבוא חלופי)
16
- * [מטמון](#Caching)
17
- * [שיקוף](#שיקוף)
18
- * [הצפנה שקופה](#שקופה-הצפנה)
19
- * [סיבוב מפתח](#Key-rotation)
20
- * [ממשק מנהל התקן](#ממשק מנהל התקן)
21
- * [רישום](#לוגינג)
22
-
23
- # קרא את זה בשפה אחרת
24
- מסמך README.md זה תורגם, באמצעות [hokeylization](https://github.com/cobbzilla/hokeylization), ל-
25
- **[בכל שפה נתמכת על ידי Google Translate](https://cloud.google.com/translate/docs/languages)!**
26
-
27
- אני בטוח שזה לא מושלם, אבל אני מקווה שזה יותר טוב מכלום!
28
-
29
- [🇸🇦 ערבית](../ar/README.md)
30
- [🇧🇩 בנגלית](../bn/README.md)
31
- [🇩🇪 גרמנית](../de/README.md)
32
- [🇺🇸 אנגלית](../en/README.md)
33
- [🇪🇸 ספרדית](../es/README.md)
34
- [🇫🇷 צרפתית](../fr/README.md)
35
- [🇹🇩 Hausa](../ha/README.md)
36
- [🇮🇳 הינדי](../hi/README.md)
37
- [🇮🇩 אינדונזית](../id/README.md)
38
- [🇮🇹 איטלקית](../it/README.md)
39
- [🇯🇵 יפנית](../ja/README.md)
40
- [🇰🇷 קוריאנית](../ko/README.md)
41
- [🇮🇳 Marathi](../mr/README.md)
42
- [🇵🇱 פולנית](../pl/README.md)
43
- [🇧🇷 פורטוגזית](../pt/README.md)
44
- [🇷🇺 רוסית](../ru/README.md)
45
- [🇰🇪 סוואהילי](../sw/README.md)
46
- [🇵🇭 Tagalog](../tl/README.md)
47
- [🇹🇷 טורקית](../tr/README.md)
48
- [🇵🇰 אורדו](../ur/README.md)
49
- [🇻🇳 וייטנאמית](../vi/README.md)
50
- [🇨🇳 סינית](../zh/README.md)
51
-
52
-
53
- **[📚 ... כל השפות ...](../README.md)**
54
- ----
55
-
56
- ### האם יש בעיה עם התרגום הזה של README?
57
- התרגום הספציפי הזה של [README] המקורי (https://github.com/cobbzilla/mobiletto/blob/master/README.md)
58
- עשוי להיות פגום -- *תיקונים יתקבלו בברכה!* אנא שלח [בקשת משיכה ב-GitHub](https://github.com/cobbzilla/mobiletto/pulls),
59
- או אם אתה לא מרגיש בנוח לעשות את זה, [פתח בעיה](https://github.com/cobbzilla/mobiletto/issues)
60
-
61
- כאשר אתה יוצר בעיה חדשה של GitHub על תרגום, אנא עשה:
62
- * כלול את כתובת האתר של הדף (העתק/הדבק משורת הכתובת של הדפדפן)
63
- * כלול את הטקסט המדויק השגוי (העתק/הדבק מדפדפן)
64
- * נא לתאר מה לא בסדר -- האם התרגום שגוי? הפורמט שבור איכשהו?
65
- * אנא הציעו הצעה לתרגום טוב יותר, או כיצד יש לעצב את הטקסט כראוי
66
- * **תודה!**
67
-
68
- ## למה Mobiletto?
69
-
70
- ### להתראות נעילת ספק!
71
- לספקי אחסון הענן השונים יש ממשקי API לא תואמים. גם אלה השואפים ל"תאימות S3"
72
- בעלי התנהגויות ייחודיות.
73
-
74
- כאשר אתה בוחר ספק אחסון מסוים עבור האפליקציה שלך, אם אתה מקודד ישירות ל-API שלו, האפליקציה שלך
75
- כעת תלוי בשירות זה. ככל שהזמן עובר והקוד מצטבר, ספקים משתנים הופכים
76
- יותר ויותר בלתי נסבל. ברוכים הבאים לעולם המהנה של נעילת ספקים!
77
-
78
- Mobiletto תוכנן לפתור בעיה זו. על ידי קידוד האפליקציה שלך ל-API של mobiletto, אתה יכול בקלות
79
- להחליף ספקי אחסון ולדעת ששכבת האחסון של האפליקציה שלך תתנהג בצורה זהה.
80
-
81
- ### בדיקות מקיפות
82
- כל הנהגים נבדקים להתנהגות זהה עם 60+ בדיקות לכל נהג.
83
- אנו בודקים את כל הנהגים עם כל שילוב של:
84
- * הצפנה: מופעלת וגם מושבתת
85
- * מטמון Redis: מופעל וגם מושבת
86
-
87
- גישה זו נותנת לנו שקט נפשי ש-mobiltto יתנהג אותו דבר ללא קשר לנהג שאתה משתמש בו,
88
- ובלי קשר אם אתה מפעיל מטמון ו/או הצפנה.
89
-
90
- ### תמיכה בנהגים
91
- מנהלי האחסון הנוכחיים של Mobiletto:
92
- * `s3` : Amazon S3
93
- * `b2` : Backblaze B2
94
- * `local` : מערכת קבצים מקומית
95
-
96
- *תרומות לתמיכה בספקי אחסון ענן נוספים יתקבלו בברכה!*
97
-
98
- ## mobiletto-cli
99
- Mobiletto מיועד לשמש כספרייה על ידי קוד JavaScript אחר.
100
-
101
- כדי לעבוד עם mobiletto בשורת הפקודה, השתמש ב-[mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
102
-
103
- ## מקור
104
- * [mobiletto ב-GitHub](https://github.com/cobbzilla/mobiletto)
105
- * [mobiletto ב-npm](https://www.npmjs.com/package/mobiletto)
106
-
107
- ## תמיכה ומימון
108
- אני מנסה להיות מפתח תוכנה מקצועי בקוד פתוח. עבדתי ב
109
- בתעשיית התוכנה במשך שנים רבות, הקמתי חברות מצליחות ומכרתי אותן לחברות ציבוריות.
110
- לאחרונה איבדתי את עבודתי, ואין לי באמת עבודה אחרת
111
-
112
- אז אני הולך לנסות לכתוב תוכנה מועילה ולראות אם זה עובד
113
-
114
- אם אתה נהנה להשתמש בתוכנה זו, אני אודה מאוד אפילו על
115
- הקטן ביותר [תרומה חודשית דרך Patreon](https://www.patreon.com/cobbzilla)
116
-
117
- *תודה!*
118
-
119
- ## התקנה
120
- התקן באמצעות `npm` או `yarn` . אתה בטח רוצה את גרסת `lite` שאינה כוללת את כל ה
121
- קובצי README מתורגמים:
122
-
123
- npm install mobiletto-lite
124
- yarn add mobiletto-lite
125
-
126
- אם אתה באמת רוצה את קבצי README בכל שפה, התקן את הגרסה המלאה:
127
-
128
- npm install mobiletto
129
- yarn add mobiletto
130
-
131
- ## התחלה מהירה
132
- דוגמה קצרה באמצעות מנהל ההתקן של `s3` .
133
-
134
- קוד זה ירוץ אותו הדבר אם מנהל ההתקן היה `b2` ' או `local` .
135
-
136
- const storage = require('mobiletto')
137
- const bucket = await storage.connect('s3', aws_key, aws_secret, {bucket: 'bk'})
138
-
139
- // list objects: returns array of metadata objects
140
- const listing = await bucket.list()
141
- const dirList = await bucket.list('some/dir/')
142
- const everything = await bucket.list('', {recursive: true})
143
-
144
- // write an entire file
145
- let bytesWritten = await bucket.writeFile('some/path', someBufferOfData)
146
-
147
- // write a file from a stream/generator
148
- bytesWritten = await bucket.write('some/path', streamOrGenerator)
149
-
150
- // read an entire file
151
- // returns null if an exception would otherwise be thrown
152
- const bufferOrNull = await bucket.safeReadFile('some/path')
153
-
154
- // stream-read a file, passing data to callback
155
- const bytesRead = await bucket.read('some/path', (chunk) => { ...do something with chunk... } )
156
-
157
- // remove a file, returns the path removed
158
- let removed = await bucket.remove('some/path') // removed is a string
159
-
160
- // remove a directory, returns array of paths removed
161
- removed = await bucket.remove('some/directory', {recursive: true}) // removed is now an array!
162
-
163
- ----
164
- ## שימוש בסיסי
165
- דוגמה הרבה יותר נרחבת, המציגה את רוב התכונות המוצעות:
166
-
167
- const { mobiletto } = require('mobiletto')
168
-
169
- // General usage
170
- const api = await mobiletto(driverName, key, secret, opts)
171
-
172
- // To use 'local' driver:
173
- // * key: base directory
174
- // * secret: ignored, can be null
175
- // * opts object:
176
- // * readOnly: optional, never change anything on the filesystem; default is false
177
- // * fileMode: optional, permissions used when creating new files, default is 0600. can be string or integer
178
- // * dirMode: optional, permissions used when creating new directories, default is 0700. can be string or integer
179
- const local = await mobiletto('local', '/home/ubuntu/tmp', null, {fileMode: 0o0600, dirMode: '0700'})
180
-
181
- // To use 's3' driver:
182
- // * key: AWS Access Key ID
183
- // * secret: AWS Secret Key
184
- // * opts object:
185
- // * readOnly: optional, never change anything on the bucket; default is false
186
- // * bucket: required, name of the S3 bucket
187
- // * region: optional, the AWS region to communicate with, default is us-east-1
188
- // * prefix: optional, all read/writes within the S3 bucket will be under this prefix
189
- // * delimiter: optional, directory delimiter, default is '/' (note: always '/' when encryption is enabled)
190
- const s3 = await mobiletto('s3', aws_key, aws_secret, {bucket: 'bk', region: 'us-east-1'})
191
-
192
- // To use 'b2' driver:
193
- // * key: Backblaze Key ID
194
- // * secret: Backblaze Application Key
195
- // * opts object:
196
- // * readOnly: optional, never change anything on the bucket; default is false
197
- // * bucket: required, the ID (**not the name**) of the B2 bucket
198
- // * prefix: optional, all read/writes within the B2 bucket will be under this prefix
199
- // * delimiter: optional, directory delimiter, default is '/' (note: always '/' when encryption is enabled)
200
- // * partSize: optional, large files will be split into chunks of this size when uploading
201
- const b3 = await mobiletto('b2', b2_key_id, b2_app_key, {bucket: 'bk', partSize: 10000000})
202
-
203
- // List files
204
- api.list() // --> returns an array of metadata objects
205
-
206
- // List files recursively
207
- api.list({ recursive: true })
208
-
209
- // List files in a directory
210
- const path = 'some/path'
211
- api.list(path)
212
- api.list(path, { recursive: true }) // also supports recursive flag
213
-
214
- // Visit files in a directory -- visitor function must be async
215
- api.list(path, { visitor: myAsyncFunc })
216
- api.list(path, { visitor: myAsyncFunc, recursive: true })
217
-
218
- // The `list` method throws MobilettoNotFoundError if the path does not exist
219
- // When you call `safeList` on a non-existent path, it returns an empty array
220
- api.safeList('/path/that/does/not/exist') // returns []
221
-
222
- // Read metadata for a file
223
- api.metadata(path) // returns metadata object
224
-
225
- // The `metadata` method throws MobilettoNotFoundError if the path does not exist
226
- // When you call `safeMetadata` on a non-existent path, it returns null
227
- api.safeMetadata('/tmp/does_not_exist') // returns null
228
-
229
- // Read a file
230
- // Provide a callback that writes the data someplace
231
- const callback = (chunk) => { ... write chunk somewhere ... }
232
- api.read(path, callback) // returns count of bytes read
233
-
234
- // Read an entire file at once
235
- const data = await api.readFile(path) // returns a byte Buffer of the file contents
236
-
237
- // Read an entire file at once
238
- // returns null if an exception would otherwise be thrown
239
- const bufferOrNull = await bucket.safeReadFile('some/path')
240
-
241
- // Write a file
242
- // Provide a generator function that yields chunks of data
243
- const generator = function* () {
244
- while ( ... more-data-to-return ... ) {
245
- data = ... load-data ...
246
- yield data
247
- }
248
- }
249
- local.api(path, generator) // returns count of bytes written
250
-
251
- // Write an entire file at once (convenience method)
252
- await api.writeFile(path, bufferOrString) // returns count of bytes written
253
-
254
- // Delete a file
255
- // Quiet param is optional (default false), when set errors will not be thrown if the path does not exist
256
- // Always returns a value or throws an error.
257
- // Return value may be a single string of the file removed, or an array of all files removed (driver-dependent)
258
- const quiet = true
259
- api.remove(path, {quiet}) // returns single path removed
260
-
261
- // Recursively delete a directory and do it quietly (do not report errors)
262
- const recursive = true
263
- const quiet = true
264
- api.remove(path, {recursive, quiet}) // returns array of paths removed
265
-
266
- ## מטא נתונים
267
- הפקודה `metadata` מחזירה מטא נתונים לגבי ערך מערכת קבצים בודדת.
268
- באופן דומה, ערך ההחזרה מהפקודה `list` רשימה' הוא מערך של אובייקטי מטא נתונים.
269
-
270
- אובייקט מטא נתונים נראה כך:
271
-
272
- {
273
- "name": "fully/qualified/path/to/file",
274
- "type": "entry-type",
275
- "size": size-in-bytes,
276
- "ctime": creation-time-epoch-millis,
277
- "mtime": modification-time-epoch-millis
278
- }
279
-
280
- המאפיין `type` יכול להיות `file` ' , `dir` ' , `link` ' או `special` .
281
-
282
- בהתאם לסוג מנהל ההתקן, ייתכן שפקודה `list` רשימה' לא תחזיר את כל השדות. המאפיינים `name` שם `type`
283
- צריך להיות נוכח תמיד. פקודת `metadata` הבאה תחזיר את כל המאפיינים הזמינים.
284
-
285
- ## סגנון ייבוא חלופי
286
- ייבא את המודול בהיקף מלא והשתמש בפונקציית `connect` :
287
-
288
- const storage = require('mobiletto')
289
- const opts = {bucket: 'bk', region: 'us-east-1'}
290
- const s3 = await storage.connect('s3', aws_key, aws_secret, opts)
291
- const objectData = await s3.readFile('some/path')
292
-
293
- ## שמירה במטמון
294
- Mobiletto עובד הכי טוב עם מטמון <a href="https://redis.io">redis</a> .
295
-
296
- Mobiletto ינסה להתחבר למופע redis ב-127.0.0.1:6379
297
-
298
- אתה יכול לעקוף אחד מאלה:
299
- * הגדר את `MOBILETTO_REDIS_HOST` env var, mobiletכדי להתחבר לכאן במקום המארח המקומי
300
- * הגדר את ה-env var `MOBILETTO_REDIS_PORT` , היציאה הזו תשמש
301
-
302
- Mobiletto יאחסן את כל מפתחות ה-Redis שלה עם הקידומת `_mobiletto__` . אתה יכול לשנות את זה
303
- על ידי הגדרת `MOBILETTO_REDIS_PREFIX` env var.
304
-
305
- אתה יכול גם להגדיר מטמון לכל חיבור עם האובייקט `opts.redisConfig` :
306
-
307
- const redisConfig = {
308
- enabled: true, // optional, default is true. if false other props are ignored
309
- host: '127.0.0.1',
310
- port: 6379,
311
- prefix: '_mobiletto__'
312
- }
313
- const opts = { redisConfig, bucket: 'bk', region: 'us-east-1' }
314
- const s3 = await storage.connect('s3', aws_key, aws_secret, opts)
315
-
316
- ### לא רוצה אחסון מחדש במטמון?
317
- כדי להשבית: העבר את `enabled: false` ' באובייקט `opts.redisConfig` שלך כשאתה יוצר את החיבור שלך.
318
-
319
- כפי שנדון להלן, השבתת שמירה במטמון תשפיע לרעה על הביצועים ותגרום לבקשות נוספות
320
- לאחסון שאתה באמת צריך.
321
-
322
- ### הדרכה לשמירה במטמון
323
- **אחסון מוצפן**: קריאה/כתיבה של אחסון מוצפן הוא רק קצת יותר איטי מהרגיל,
324
- אבל ניווט בין ספריות (מה שעושים דברים מסוימים) הוא די יקר. שימוש במטמון redis
325
- ייתן לך שיפור משמעותי בביצועים.
326
-
327
- מטמון ברירת המחדל בטוח, אך אינו פועל היטב אם יש לך הרבה פעולות כתיבה/הסרה.
328
- כל פעולת כתיבה או הסרה מבטלת את תוקף המטמון כולו, ומבטיחה שהקריאה הבאה תראה את
329
- השינויים האחרונים.
330
-
331
- ### כלי CLI
332
- אם אתה משתמש בכלי CLI כמו [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
- אתה בהחלט רוצה את המטמון של redis מופעל, מכיוון שהוא נמשך לאורך כל פניות של פקודת `mo` .
334
-
335
- ## שיקוף
336
-
337
- // Copy a local filesystem mobiletto to S3
338
- s3.mirror(local)
339
-
340
- // Mirror a local subdirectory from one mobiletto to an S3 mobiletto, with it's own subdirectory
341
- local.mirror(s3, 'some/local-folder', 'some/s3-folder')
342
-
343
- הפקודה `mirror` מבצעת העתקה חד פעמית של כל הקבצים מ-mobiltto אחד לאחר.
344
- זה לא מפעיל שום תהליך כדי לשמור על המראה לאורך זמן. הפעל שוב את הפקודה `mirror`
345
- כדי לסנכרן את כל הקבצים החסרים.
346
-
347
- ערך ההחזרה `mirror` הוא אובייקט פשוט עם מונים למספר הקבצים שהצליחו
348
- שיקוף ובכמה קבצים היו שגיאות:
349
-
350
- {
351
- success: count-of-files-mirrored,
352
- errors: count-of-files-with-errors
353
- }
354
-
355
- אזהרה: שיקוף של ערכות נתונים גדולות עשוי להיות גוזל זמן רב ורוחב פס
356
-
357
- עם סמנטיקה של הקריאה `mirror` זה לפעמים יכול להיות מבלבל להבין מיהו
358
- הקורא ומיהו הכותב. דמיינו את זה כמו הצהרת משימה: "הנייד השמאלי"
359
- הוא הדבר שאליו מוקצה (נכתבים נתוני שיקוף), וה-"mobiltto הימני" (ה
360
- ארגומנט לשיטת `mirror` ) הוא הערך המוקצה (נתוני שיקוף נקראים).
361
-
362
- ## הצפנה שקופה
363
- אפשר הצפנה שקופה בצד הלקוח:
364
-
365
- // Pass encryption parameters
366
- const encryption = {
367
- // key is required, must be >= 16 chars
368
- key: randomstring.generate(128),
369
-
370
- // optional, the default is to derive IV from key
371
- // when set, IV must be >= 16 chars
372
- iv: randomstring.generate(128),
373
-
374
- // optional, the default is aes-256-cbc
375
- algo: 'aes-256-cbc'
376
- }
377
- const api = await mobiletto(driverName, key, secret, opts, encryption)
378
-
379
- // Subsequent write operations will encrypt data (client side) when writing
380
- // Subsequent read operations will decrypt data (client side) when reading
381
-
382
- מה קורה? ספריה נפרדת של "כניסת ספרייה" (דורה) (מוצפנת) עוקבת אחר הקבצים שנמצאים בה
383
- ספרייה (המכונה גם ספריית ה-Dirent).
384
- * הפקודה `list` רשימה' קוראת את קבצי הזנת הספריות, מפענחת כל נתיב ברשימה; לאחר מכן מחזיר מטא נתונים עבור כל קובץ
385
- * פקודות `list` אינן יעילות יותר, במיוחד עבור ספריות עם מספר רב של קבצים
386
- * הפקודה `write` כותבת קבצי dirent בספריית dirent של כל הורה, באופן רקורסיבי; ואז כותב את הקובץ
387
- * פקודות `write` O(N), כאשר N = עומק בהיררכיית הספריות
388
- * הפקודה `remove` מסירה את קובץ ה-dirent המתאים, ואת האב שלו אם ריק, באופן רקורסיבי; לאחר מכן מסיר את הקובץ
389
- * פקודות `remove` לא רקורסיביות יגרמו לקריאה של O(N) וייתכן כי כמה שיותר מחיקות, כאשר N = עומק בהיררכיית הספריות
390
- * פקודות `remove` רקורסיביות במערכות קבצים גדולות ועמוקות יכולות להיות יקרות
391
-
392
- שים לב שגם כשההצפנה בצד הלקוח מופעלת, יריב עם נראות מלאה לצד השרת המוצפן שלך
393
- אחסון, גם ללא המפתח, עדיין יכול לראות את המספר הכולל של ספריות וכמה קבצים יש בכל אחת, ועם
394
- קצת מאמץ, גלה חלק מהמבנה הכללי של היררכיית הספריות או את כולו.
395
- *הערה: השתמשו במבנה שטוח יחסית לאבטחה טובה יותר.*
396
- היריב לא יידע את שמות הספריות/הקבצים אלא אם כן ידע גם את ההצפנה שלך
397
- מפתח או פיצח בהצלחה את ההצפנה. אז כל ההימורים מושבתים!
398
-
399
- ### ביצועים ושמירה במטמון
400
- הפעולות באחסון מוצפן יכולות להיות איטיות. רשימות והסרות רקורסיביות יכולות להיות איטיות מאוד.
401
- שמירה במטמון באמצעות redis עוזרת מאוד, אך שימו לב שהמטמון נשטף בכל כתיבה או הסרה.
402
-
403
- ## סיבוב מפתח
404
- צור Mobiletto עם המפתח החדש שלך, ולאחר מכן שיקוף את הנתונים הישנים לתוכו:
405
-
406
- const storage = require('mobiletto')
407
-
408
- const oldEncryption = { key: .... }
409
- const oldStorage = await storage.connect('s3', aws_key, aws_secret, {bucket: 'bk', region: 'us-east-1'}, oldEncryption)
410
-
411
- const newEncryption = { key: .... }
412
- const newStorage = await storage.connect('s3', aws_key, aws_secret, {bucket: 'zz', region: 'us-east-1'}, newEncryption)
413
-
414
- newStorage.mirror(oldStorage) // if oldStorage is very large, this may take a looooooong time...
415
-
416
- ## ממשק מנהל ההתקן
417
- מנהל התקן הוא כל קובץ JS שמייצא פונקציית 'storageClient' עם החתימה הזו:
418
-
419
- function storageClient (key, secret, opts)
420
-
421
- * `key` : מחרוזת, מפתח ה-API שלך (עבור מנהל ההתקן `local` זוהי ספריית הבסיס)
422
- * `secret` : מחרוזת, סוד ה-API שלך (ניתן להשמיט עבור מנהל ההתקן `local` )
423
- * `opts` : אובייקט, המאפיינים הם לכל מנהל התקן:
424
- * עבור `local` , `fileMode` `dirMode` קובעים כיצד נוצרים קבצי יצירה וספריות חדשות
425
- * עבור `s3` , המאפיין `bucket` נדרש. מאפיינים אופציונליים הם:
426
- * `region`: the S3 region, default is us-east-1
427
- * `prefix`: a prefix to prepend to all S3 paths, default is the empty string
428
- * `delimiter`: the directory delimiter, default is '/'
429
-
430
- האובייקט שהפונקציה storageClient מחזירה חייב להגדיר את הפונקציות הבאות:
431
-
432
- // Test the driver before using, ensure proper configuration
433
- async testConfig ()
434
-
435
- // List files in path (or from base-directory)
436
- // If recursive is true, list recursively
437
- // If visitor is defined, it will be an async function. await the visitor function on each file found
438
- // Otherwise, perform the listing and return an array of objects
439
- async list (path, recursive = false, visitor = null) // path may be omitted
440
-
441
- // Read metadata for a path
442
- async metadata (path)
443
-
444
- // Read a file
445
- // callback receives a chunk of data. endCallback is called at end-of-stream
446
- async read (path, callback, endCallback = null)
447
-
448
- // Write a file
449
- // driver must be able to handle a generator or a stream
450
- async write (path, generatorOrReadableStream)
451
-
452
- // Remove a file, or recursively delete a directory
453
- // returns a string of a single path removed, or an array of multiple paths removed
454
- async remove (path, recursive = false, quiet = false)
455
-
456
- ## רישום
457
- Mobiletto משתמש בספריית הרישום של [winston](https://www.npmjs.com/package/winston).
458
-
459
- יומנים **יכילו** נתיבי קבצים והודעות שגיאה, אך **לעולם לא** יכילו מפתחות, סודות,
460
- או כל מידע אחר על תצורת החיבור.
461
-
462
- ### רמת יומן
463
- השתמש במשתנה הסביבה `MOBILETTO_LOG_LEVEL` כדי להגדיר את רמת היומן, באמצעות אחד
464
- `npm` המוגדרות ב-[https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
465
-
466
- רמת ברירת המחדל היא `error` . הרמה המילולית ביותר היא `silly` , אם כי כרגע mobiletto
467
- לא מתחבר ברמות מתחת `debug`
468
-
469
- MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
-
471
- ### קובץ לוג
472
- כברירת מחדל, לוגר כותב למסוף. כדי לשלוח יומנים לקובץ, הגדר את `MOBILETTO_LOG_FILE`
473
- משתנה הסביבה. בעת כניסה לקובץ, יומנים לא ייכתבו יותר למסוף.
474
-
475
- MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
-
477
- כדי לכבות את הרישום:
478
-
479
- MOBILETTO_LOG_FILE=/dev/null
480
-
481
- </pre>