mobiletto 1.2.1 → 2.0.1

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/eo/README.md DELETED
@@ -1,481 +0,0 @@
1
- Mobiletto
2
- =========
3
-
4
- Mobiletto estas JavaScript-stoka abstrakta tavolo, kun laŭvola travidebla klientflanka ĉifrado.
5
-
6
- # Enhavo
7
- * [Kial Mobiletto?](#Kial-Mobiletto?)
8
- * [Rapida komenco](#Rapida komenco)
9
- * [Mobiletto CLI](#mobiletto-cli)
10
- * [Fonto](#Fonto)
11
- * [Instalado](#Instalo)
12
- * [Subteno kaj Financado](#Subteno-kaj-Fincado)
13
- * [Baza uzado](#Baza uzado)
14
- * [Metadatumoj](#Metadatumoj)
15
- * [Alterna importa stilo](#Alternate-import-stilo)
16
- * [Kaŝmemoro](#Kaŝmemoro)
17
- * [Spegulado](#Spegulado)
18
- * [Travidebla ĉifrado](#Travidebla-ĉifrado)
19
- * [Ŝlosilrotacio](#Ŝlosilo-rotacio)
20
- * [ŝofora interfaco](#Driver-interfaco)
21
- * [Logging](#Logging)
22
-
23
- # Legu ĉi tion en alia lingvo
24
- Ĉi tiu dokumento README.md estis tradukita, per [hokeylization](https://github.com/cobbzilla/hokeylization), en
25
- **[ĉiu lingvo subtenata de Google Translate](https://cloud.google.com/translate/docs/languages)!**
26
-
27
- Mi certas, ke ĝi ne estas perfekta, sed mi esperas, ke ĝi estas pli bona ol nenio!
28
-
29
- [🇸🇦 araba](../ar/README.md)
30
- [🇧🇩 bengala](../bn/README.md)
31
- [🇩🇪 germana](../de/README.md)
32
- [🇺🇸 angla](../eo/README.md)
33
- [🇪🇸 Hispana](../es/README.md)
34
- [🇫🇷 Franca](../fr/README.md)
35
- [🇹🇩 Hausa](../ha/README.md)
36
- [🇮🇳 Hindia](../hi/README.md)
37
- [🇮🇩 indonezia](../id/README.md)
38
- [🇮🇹 itala](../it/README.md)
39
- [🇯🇵 japana](../ja/README.md)
40
- [🇰🇷 Korea](../ko/README.md)
41
- [🇮🇳 Marathi](../mr/README.md)
42
- [🇵🇱 Pola](../pl/README.md)
43
- [🇧🇷 portugala](../pt/README.md)
44
- [🇷🇺 Rusa](../ru/README.md)
45
- [🇰🇪 Svahila](../sw/README.md)
46
- [🇵🇭 Tagaloga](../tl/README.md)
47
- [🇹🇷 Turka](../tr/README.md)
48
- [🇵🇰 Urdua](../ur/README.md)
49
- [🇻🇳 vjetnama](../vi/README.md)
50
- [🇨🇳 Ĉina](../zh/README.md)
51
-
52
-
53
- **[📚 ... Ĉiuj lingvoj ...](../README.md)**
54
- ----
55
-
56
- ### Ĉu estas problemo kun ĉi tiu traduko de la README?
57
- Ĉi tiu aparta traduko de la originalo [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
58
- povas esti misa -- *korektoj estas tre bonvenaj!* Bonvolu sendi [tiropeton sur GitHub](https://github.com/cobbzilla/mobiletto/pulls),
59
- aŭ se vi ne komfortas fari tion, [malfermu temon](https://github.com/cobbzilla/mobiletto/issues)
60
-
61
- Kiam vi kreas novan GitHub-an numeron pri traduko, bonvolu fari:
62
- * inkluzivu la paĝon URL (kopiu/gluu el retumila adresbreto)
63
- * inkluzivu la ĝustan tekston malĝustan (kopiu/gluu el retumilo)
64
- * bonvolu priskribi kio estas malĝusta -- ĉu la traduko estas malĝusta? ĉu la formatado estas rompita iel?
65
- * bonvolu proponi sugeston pri pli bona traduko, aŭ kiel la teksto estu taŭge formatita
66
- * **Dankon!**
67
-
68
- ## Kial Mobiletto?
69
-
70
- ### Adiaŭ enŝlosado de vendisto!
71
- La diversaj provizantoj de nuba stokado havas malkongruajn API-ojn. Eĉ tiuj, kiuj strebas al "S3-kongruo"
72
- havas idiosinkraziajn kondutojn.
73
-
74
- Kiam vi elektas apartan stokan vendiston por via programo, se vi kodas rekte al ilia API, via programo
75
- nun dependas de tiu servo. Dum tempo pasas kaj kodo akumuliĝas, ŝanĝiĝas vendistoj
76
- ĉiam pli netenebla. Bonvenon al la amuza mondo de vendoŝlosado!
77
-
78
- Mobiletto estis dizajnita por solvi ĉi tiun problemon. Kodigante vian apon al la API de mobiletto, vi povas facile
79
- ŝanĝu provizantojn de stokado kaj sciu, ke la stokatavolo de via programo kondutos idente.
80
-
81
- ### Ampleksa testado
82
- Ĉiuj ŝoforoj estas testitaj pri identa konduto kun 60+ testoj por ĉiu ŝoforo.
83
- Ni testas ĉiujn ŝoforojn kun ĉiu kombinaĵo de:
84
- * Ĉifrado: kaj ebligita kaj malŝaltita
85
- * Redis kaŝmemoro: ambaŭ ebligita kaj malŝaltita
86
-
87
- Ĉi tiu aliro donas al ni trankvilon, ke mobiletto kondutos same sendepende de kiu ŝoforo vi uzas,
88
- kaj sendepende de ĉu vi ebligas kaŝmemoron kaj/aŭ ĉifradon.
89
-
90
- ### Ŝoforsubteno
91
- Nunaj Mobiletto-stokaj ŝoforoj:
92
- * `s3` : Amazon S3
93
- * `b2` : Malantaŭbrilo B2
94
- * `local` : loka dosiersistemo
95
-
96
- *Kontribuoj por subteni pli da nuba stokado provizantoj estas tre bonvenaj!*
97
-
98
- ## mobiletto-cli
99
- Mobiletto estas celita esti uzata kiel biblioteko per alia JavaScript-kodo.
100
-
101
- Por labori kun mobiletto ĉe la komandlinio, uzu [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
102
-
103
- ## Fonto
104
- * [mobiletto sur GitHub](https://github.com/cobbzilla/mobiletto)
105
- * [mobiletto sur npm](https://www.npmjs.com/package/mobiletto)
106
-
107
- ## Subteno kaj Financado
108
- Mi provas esti profesia liberkoda programisto. Mi laboris en
109
- la programara industrio dum multaj jaroj, mi komencis sukcesajn kompaniojn kaj vendis ilin al publikaj kompanioj.
110
- Lastatempe mi perdis mian laboron, kaj mi vere ne havas alian laboron vicigita
111
-
112
- Do mi provos verki helpeman programaron kaj vidi ĉu tio funkcias
113
-
114
- Se vi ĝuas uzi ĉi tiun programaron, mi tre dankus eĉ pro la
115
- plej malgranda [monata kontribuo per Patreon](https://www.patreon.com/cobbzilla)
116
-
117
- *Dankon!*
118
-
119
- ## Instalado
120
- Instalu uzante `npm` aŭ `yarn` . Vi verŝajne volas la version `lite` kiu ne inkluzivas ĉiujn
121
- tradukitaj README-dosieroj:
122
-
123
- npm install mobiletto-lite
124
- yarn add mobiletto-lite
125
-
126
- Se vi vere volas la README-dosierojn en ĉiu lingvo, instalu la plenan version:
127
-
128
- npm install mobiletto
129
- yarn add mobiletto
130
-
131
- ## Rapida Komenco
132
- Mallonga ekzemplo uzante la ŝoforon mobiletto `s3` .
133
-
134
- Ĉi tiu kodo rulus same se la ŝoforo estus `b2` aŭ `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
- ## Baza uzado
165
- Multe pli ampleksa ekzemplo, montranta la plej multajn el la ofertitaj funkcioj:
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
- ## Metadatumoj
267
- La komando `metadata` resendas metadatenojn pri ununura dosiersistem-eniro.
268
- Same, la revenvaloro de la komando `list` estas tabelo de metadatumaj objektoj.
269
-
270
- Metadatuma objekto aspektas jene:
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
- La `type` posedaĵo povas esti `file` , `dir` , `link` , aŭ `special` .
281
-
282
- Depende de la tipo de ŝoforo, komando `list` eble ne resendas ĉiujn kampojn. La `name` kaj `type`
283
- devus ĉiam ĉeesti. Posta `metadata` komando resendos ĉiujn disponeblajn ecojn.
284
-
285
- ## Alterna importa stilo
286
- Importu la plene-skopitan modulon kaj uzu la funkcion `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
- ## Kaŝmemoro
294
- Mobiletto funkcias plej bone kun <a href="https://redis.io">redis-</a> kaŝmemoro.
295
-
296
- Mobiletto provos konektiĝi al redis-instanco sur 127.0.0.1:6379
297
-
298
- Vi povas anstataŭi iun el ĉi tiuj:
299
- * Agordu la env var `MOBILETTO_REDIS_HOST` , mobilepor konekti ĉi tie anstataŭ lokagastiganto
300
- * Agordu la env `MOBILETTO_REDIS_PORT` , ĉi tiu pordo estos uzata
301
-
302
- Mobiletto stokos ĉiujn ĝiajn redis-ŝlosilojn kun la prefikso `_mobiletto__` . Vi povas ŝanĝi ĉi tion
303
- per agordo de la `MOBILETTO_REDIS_PREFIX` var.
304
-
305
- Vi ankaŭ povas agordi pokonektan kaŝmemoron per la objekto `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
- ### Ne volas redis-kaŝmemoron?
317
- Por malŝalti: pasu `enabled: false` en via `opts.redisConfig` objekto kiam vi establas vian konekton.
318
-
319
- Kiel diskutite malsupre, malŝalti kaŝmemoron havos malfavoran efikon al rendimento kaj ricevos pli da petoj
320
- al stokado, kiun vi vere bezonas.
321
-
322
- ### Gvidlibro pri kaŝmemoro
323
- **Ĉifrita stokado**: legado/skribado de ĉifrita stokado estas nur iom pli malrapida ol normale,
324
- sed navigi tra dosierujoj (kion faras iuj aferoj) estas sufiĉe multekosta. Uzante redis-kaŝmemoron
325
- donos al vi signifan rendimentan akcelon.
326
-
327
- La defaŭlta kaŝmemoro estas sekura, sed ne funkcias bone se vi havas multajn skribi/forigi operaciojn.
328
- Ajna operacio de skribo aŭ forigo malvalidigas la tutan kaŝmemoron, certigante ke postaj legoj vidos la
329
- lastaj ŝanĝoj.
330
-
331
- ### CLI-iloj
332
- Se vi uzas CLI-ilon kiel [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
- vi certe volos la redis-kaŝmemoron ebligita, ĉar ĝi daŭras tra alvokoj de la komando `mo` .
334
-
335
- ## Spegulado
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
- La komando `mirror` faras unufojan kopion de ĉiuj dosieroj de unu mobiletto al alia.
344
- Ĝi ne funkciigas ajnan procezon por konservi la spegulon laŭlonge de la tempo. Rulu la komandon `mirror` denove
345
- por sinkronigi ajnajn mankantajn dosierojn.
346
-
347
- La revena valoro de `mirror` estas simpla objekto kun nombriloj por kiom da dosieroj estis sukcese
348
- spegulita kaj kiom da dosieroj havis erarojn:
349
-
350
- {
351
- success: count-of-files-mirrored,
352
- errors: count-of-files-with-errors
353
- }
354
-
355
- AVERTO: Speguli grandajn datumajn arojn povas esti tre temporaba kaj bendolarĝo-intensa
356
-
357
- Kun la `mirror` voka semantiko foje povas esti konfuze kompreni kiu estas la
358
- leganto kaj kiu estas la verkisto. Imagu ĝin kiel asigno deklaro: la "maldekstra mano mobiletto"
359
- estas la aĵo asignita al (spegulaj datumoj skribitaj), kaj la "dekstra mano" (la
360
- argumento al la metodo `mirror` ) estas la valoro asignita (spegulita datumo estas legata).
361
-
362
- ## Travidebla ĉifrado
363
- Ebligu travideblan klientflankan ĉifradon:
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
- Kio okazas? Aparta "dosierujo eniro" (direkta) dosierujo (ĉifrita) spuras kiajn dosierojn estas en tio
383
- dosierujo (alinome la dosierujo dirent).
384
- * La komando `list` legas la dosierujojn enirdosierojn, malĉifras ĉiun listigitan vojon; tiam resendas metadatenojn por ĉiu dosiero
385
- * `list` komandoj estas pli malefikaj, precipe por dosierujoj kun granda nombro da dosieroj
386
- * La komando `write` skribas dirent-dosierojn en la dosierujo de ĉiu gepatro, rekursie; poste skribas la dosieron
387
- * `write` komandoj provos O(N) skribojn, kun N = profundo en la dosierujo-hierarkio
388
- * La komando `remove` forigas la respondan dirent-dosieron, kaj ĝian gepatron se malplena, rekursie; tiam forigas la dosieron
389
- * Ne- `remove` komandoj ricevos O(N) legadojn kaj eble tiom da forigoj, kun N = profundo en la dosierujo-hierarkio
390
- * Rekursivaj `remove` komandoj sur grandaj kaj profundaj dosiersistemoj povas esti multekostaj
391
-
392
- Notu, ke eĉ kun klientflanka ĉifrado ebligita, kontraŭulo kun plena videbleco en vian ĉifritan servilflankon
393
- stokado, eĉ sen la ŝlosilo, ankoraŭ povas vidi la totalan nombron da dosierujoj kaj kiom da dosieroj estas en ĉiu, kaj kun
394
- iom da peno, malkovru iujn aŭ ĉion el la ĝenerala strukturo de la dosierujo-hierarkio.
395
- *Noto: Uzu relative platan strukturon por pli bona sekureco.*
396
- La kontraŭulo ne scius la nomojn de la dosierujoj/dosieroj krom se ili ankaŭ scius vian ĉifradon
397
- ŝlosilo aŭ alie sukcese fendis la ĉifradon. Ĉiuj vetoj estas forigitaj tiam!
398
-
399
- ### Agado kaj kaŝmemoro
400
- Operacioj pri ĉifrita stokado povas esti malrapidaj. Rekursivaj listoj kaj forigoj povas esti tre malrapidaj.
401
- Kaŝmemoro per redis helpas ege, sed notu, ke la kaŝmemoro estas purigita post iuj skriboj aŭ forigoj.
402
-
403
- ## Ŝlosila rotacio
404
- Kreu mobiletto per via nova ŝlosilo, tiam spegulu la malnovajn datumojn en ĝi:
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
- ## Ŝoforinterfaco
417
- Ŝoforo estas ajna JS-dosiero, kiu eksportas funkcion 'storageClient' kun ĉi tiu subskribo:
418
-
419
- function storageClient (key, secret, opts)
420
-
421
- * `key` : ĉeno, via API-ŝlosilo (por la `local` ŝoforo ĉi tio estas la baza dosierujo)
422
- * `secret` : ĉeno, via API-sekreto (povas esti preterlasita por la `local` ŝoforo)
423
- * `opts` : objekto, la propraĵoj estas po-ŝoforoj:
424
- * Por `local` , la `fileMode` kaj `dirMode` determinas kiel novaj kreaj dosieroj kaj dosierujoj estas kreitaj
425
- * Por `s3` , la posedaĵo `bucket` estas bezonata. Laŭvolaj propraĵoj estas:
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
- La objekto, kiun resendas la funkcio storageClient, devas difini ĉi tiujn funkciojn:
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
- ## Registrado
457
- Mobiletto uzas la [winston](https://www.npmjs.com/package/winston) registran bibliotekon.
458
-
459
- Registroj **enhavos dosiervojojn kaj erarmesaĝojn, sed **neniam** enhavos ŝlosilojn, sekretojn,
460
- aŭ ajna alia koneksa agorda informo.
461
-
462
- ### Lognivelo
463
- Uzu la `MOBILETTO_LOG_LEVEL` por agordi la protokolnivelon, uzante unu
464
- de la `npm` niveloj difinitaj en [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
465
-
466
- La defaŭlta nivelo estas `error` . La plej vorta nivelo estas `silly` , kvankam nuntempe mobiletto
467
- ne ensalutas je niveloj sub `debug`
468
-
469
- MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
-
471
- ### Logdosiero
472
- Defaŭlte, la registrilo skribas al la konzolo. Por sendi protokolojn al dosiero, agordu la `MOBILETTO_LOG_FILE`
473
- mediovariablo. Dum ensalutado al dosiero, protokoloj ne plu estos skribitaj al la konzolo.
474
-
475
- MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
-
477
- Por malŝalti registradon:
478
-
479
- MOBILETTO_LOG_FILE=/dev/null
480
-
481
- </pre>