presidium 3.4.8 → 3.6.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/AwsCredentials.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  require('rubico/global')
2
9
  const fs = require('fs')
3
10
  const resolvePath = require('./internal/resolvePath')
@@ -0,0 +1,3 @@
1
+ const DiskHashTable = require('presidium-db/DiskHashTable')
2
+
3
+ module.exports = DiskHashTable
@@ -0,0 +1,3 @@
1
+ const DiskSortedHashTable = require('presidium-db/DiskSortedHashTable')
2
+
3
+ module.exports = DiskSortedHashTable
package/Docker.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  require('rubico/global')
2
9
  const isString = require('rubico/x/isString')
3
10
  const identity = require('rubico/x/identity')
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  require('rubico/global')
2
9
  const crypto = require('crypto')
3
10
  const HTTP = require('./HTTP')
package/DynamoDBStream.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  require('rubico/global')
2
9
  const { differenceWith } = require('rubico/x')
3
10
  const Transducer = require('rubico/Transducer')
package/DynamoDBTable.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  require('rubico/global')
2
9
  const crypto = require('crypto')
3
10
  const HTTP = require('./HTTP')
package/ECR.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  require('rubico/global')
2
9
  const crypto = require('crypto')
3
10
  const HTTP = require('./HTTP')
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  const EventEmitter = require('events')
2
9
  const GoogleChromeForTesting = require('./GoogleChromeForTesting')
3
10
  const WebSocket = require('./WebSocket')
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  const https = require('https')
2
9
  const os = require('os')
3
10
  const fs = require('fs')
package/HTTP.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  const http = require('http')
2
9
  const https = require('https')
3
10
  const path = require('path')
package/NpmToken.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  require('rubico/global')
2
9
  const fs = require('fs')
3
10
  const resolvePath = require('./internal/resolvePath')
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  /**
2
9
  * @name OptionalValidator
3
10
  *
package/Password.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  const crypto = require('crypto')
2
9
 
3
10
  /**
package/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Presidium
2
2
  ![presidium](https://rubico.land/assets/presidium-logo-3-w200.jpg)
3
3
 
4
+ Source code: [GitHub](https://github.com/richytong/presidium) |
5
+ License: [CFOSS](https://cloutsworld.com/en-us/legal/license/cfoss)
6
+
4
7
  ![Node.js CI](https://github.com/richytong/presidium/workflows/Node.js%20CI/badge.svg)
5
8
  [![codecov](https://codecov.io/gh/richytong/presidium/branch/master/graph/badge.svg)](https://codecov.io/gh/richytong/presidium)
6
9
  [![npm version](https://img.shields.io/npm/v/presidium.svg?style=flat)](https://www.npmjs.com/package/presidium)
@@ -350,5 +353,65 @@ const data = await googleChromeDevTools.Page.navigate({
350
353
  })
351
354
  ```
352
355
 
356
+ ## [Store data on disk as a hash table](https://presidium.services/docs/DiskHashTable)
357
+ ```javascript
358
+ const DiskHashTable = require('presidium-db/DiskHashTable')
359
+
360
+ const ht = new DiskHashTable({
361
+ storageFilepath: '/path/to/storage-file',
362
+ headerFilepath: '/path/to/header-file',
363
+ initialLength: 1024,
364
+ })
365
+ await ht.init()
366
+
367
+ await ht.set('my-key', 'my-value')
368
+
369
+ const myValue = await ht.get('my-key')
370
+ console.log(myValue) // 'my-value'
371
+
372
+ await ht.delete('my-key')
373
+ ```
374
+
375
+ ## [Store data on disk as a sorted hash table](https://presidium.services/docs/DiskSortedHashTable)
376
+ ```javascript
377
+ const DiskSortedHashTable = require('presidium-db/DiskSortedHashTable')
378
+
379
+ const sortedHt = new DiskSortedHashTable({
380
+ storageFilepath: '/path/to/storage-file',
381
+ headerFilepath: '/path/to/header-file',
382
+ initialLength: 1024,
383
+ })
384
+ await sortedHt.init()
385
+
386
+ await sortedHt.set('first-key', 'first-value', 1)
387
+ await sortedHt.set('second-key', 'second-value', 2)
388
+ await sortedHt.set('third-key', 'third-value', 3)
389
+
390
+ for await (const value of sortedHt.forwardIterator()) {
391
+ console.log(value) // first-value
392
+ // second-value
393
+ // third-value
394
+ }
395
+
396
+ for await (const value of sortedHt.reverseIterator()) {
397
+ console.log(value) // third-value
398
+ // second-value
399
+ // first-value
400
+ }
401
+
402
+ for await (const value of sortedHt.forwardIterator({ startingSortValue: 2, endingSortValue: 3 })) {
403
+ console.log(value) // second-value
404
+ // third-value
405
+ }
406
+
407
+ for await (const value of sortedHt.reverseIterator({ startingSortValue: 2, endingSortValue: 1 })) {
408
+ console.log(value) // second-value
409
+ // first-value
410
+ }
411
+ ```
412
+
413
+ ## License
414
+ Presidium is distributed under the [CFOSS License](https://cloutsworld.com/en-us/legal/license/cfoss).
415
+
353
416
  # Support
354
417
  * minimum Node.js version: 16
package/Readable.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  /**
2
9
  * @name Readable
3
10
  *
package/S3Bucket.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  require('rubico/global')
2
9
  const crypto = require('crypto')
3
10
  const HTTP = require('./HTTP')
@@ -173,6 +180,7 @@ class S3Bucket {
173
180
  await this.create()
174
181
  await this.putPublicAccessBlock()
175
182
  await this.putRequestPayment()
183
+ await this._putBucketEncryption()
176
184
  if (this.VersioningStatus == 'Enabled') {
177
185
  await this.putVersioning()
178
186
  }
@@ -314,6 +322,43 @@ class S3Bucket {
314
322
  return this.http1[method](url, { headers, body })
315
323
  }
316
324
 
325
+ // _putBucketEncryption() -> Promise<>
326
+ async _putBucketEncryption() {
327
+ const body = `
328
+ <ServerSideEncryptionConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
329
+ <Rule>
330
+ <ApplyServerSideEncryptionByDefault>
331
+ <SSEAlgorithm>AES256</SSEAlgorithm>
332
+ </ApplyServerSideEncryptionByDefault>
333
+ <BlockedEncryptionTypes>
334
+ <EncryptionType>NONE</EncryptionType>
335
+ </BlockedEncryptionTypes>
336
+ <BucketKeyEnabled>true</BucketKeyEnabled>
337
+ </Rule>
338
+ </ServerSideEncryptionConfiguration>
339
+ `.trim()
340
+
341
+ const response = await this._awsRequest0('PUT', '/?encryption', {}, body)
342
+
343
+ if (response.ok) {
344
+ await Readable.Text(response)
345
+ return {}
346
+ }
347
+ throw new AwsError(await Readable.Text(response), response.status)
348
+ }
349
+
350
+ /*
351
+ // _getBucketEncryption() -> data object
352
+ async _getBucketEncryption() {
353
+ const response = await this._awsRequest0('GET', '/?encryption', {}, '')
354
+ if (response.ok) {
355
+ const text = await Readable.Text(response)
356
+ return text
357
+ }
358
+ throw new AwsError(await Readable.Text(response), response.status)
359
+ }
360
+ */
361
+
317
362
  /**
318
363
  * @name getLocation
319
364
  *
package/Secrets.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  require('rubico/global')
2
9
  const fs = require('fs')
3
10
 
package/SecretsManager.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  require('rubico/global')
2
9
  const crypto = require('crypto')
3
10
  const HTTP = require('./HTTP')
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  /**
2
9
  * @name StrictValidator
3
10
  *
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  require('rubico/global')
2
9
  const EventEmitter = require('events')
3
10
  const crypto = require('crypto')
package/XML.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  /**
2
9
  * @name XML
3
10
  *
package/index.js CHANGED
@@ -1,5 +1,14 @@
1
+ /**
2
+ * Presidium
3
+ * https://presidium.services/
4
+ * (c) Richard Tong
5
+ * Presidium may be freely distributed under the CFOSS license.
6
+ */
7
+
1
8
  module.exports = {
2
9
  AwsCredentials: require('./AwsCredentials.js'),
10
+ DiskHashTable: require('./DiskHashTable.js'),
11
+ DiskSortedHashTable: require('./DiskSortedHashTable.js'),
3
12
  Docker: require('./Docker.js'),
4
13
  DynamoDBGlobalSecondaryIndex: require('./DynamoDBGlobalSecondaryIndex.js'),
5
14
  DynamoDBStream: require('./DynamoDBStream.js'),
@@ -1,4 +1,4 @@
1
- const Test = require('./thunk-test')
1
+ const Test = require('thunk-test')
2
2
  const RetryAwsErrors = require('./RetryAwsErrors')
3
3
 
4
4
  // TODO
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "presidium",
3
- "version": "3.4.8",
3
+ "version": "3.6.0",
4
4
  "description": "A library for creating web services",
5
5
  "author": "Richard Tong",
6
- "license": "MIT",
6
+ "license": "CFOSS",
7
7
  "main": "index.js",
8
8
  "repository": {
9
9
  "type": "git",
@@ -13,6 +13,8 @@
13
13
  "files": [
14
14
  "internal",
15
15
  "AwsCredentials.js",
16
+ "DiskHashTable.js",
17
+ "DiskSortedHashTable.js",
16
18
  "Docker.js",
17
19
  "DynamoDBGlobalSecondaryIndex.js",
18
20
  "DynamoDBStream.js",
@@ -62,7 +64,8 @@
62
64
  "dependencies": {
63
65
  "extract-zip": "^2.0.1",
64
66
  "html-entities": "^2.6.0",
65
- "presidium-websocket": ">=2.0.1",
67
+ "presidium-db": ">=3.10.0",
68
+ "presidium-websocket": ">=3.2.1",
66
69
  "rubico": "^2.7.7",
67
70
  "tar-stream": "^3.1.7"
68
71
  },