datomic-client-js 0.1.9 → 0.1.11

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
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.1.11 (January 9, 2026).
4
+
5
+ * Update aws-sdk dependency version.
6
+
3
7
  ## 0.1.9 (January 16, 2020).
4
8
 
5
9
  * Handle EDN strings with template variables properly.
@@ -30,4 +34,4 @@
30
34
 
31
35
  ## 0.1.3 (January 12, 2020).
32
36
 
33
- * Initial semi-working release.
37
+ * Initial semi-working release.
package/README.md CHANGED
@@ -23,16 +23,19 @@ let peerConf = {
23
23
 
24
24
  // cloud config map example
25
25
  let cloudConf = {
26
- endpoint: 'http://entry.your-system-name.your-region.datomic.net:8182/',
26
+ endpoint: 'https://your-apigateway-url',
27
27
  serverType: 'cloud',
28
28
  region: 'your-region',
29
29
  system: 'your-system',
30
- proxyPort: 8182 // if connecting via the bastion server
30
+ dbName: 'your-db-name',
31
31
  };
32
+ // Can also still set endpoint to a private datomic.net URL,
33
+ // and set proxyPort if using an older Datomic cloud release
34
+ // with a proxy server for access.
32
35
 
33
36
  let client = require('datomic-client-js');
34
37
 
35
- // List databases
38
+ // List databases, you can omit dbName from config
36
39
  client.listDatabases(cloudConf).then((dbs) => `${dbs}`);
37
40
 
38
41
  // Create database (cloud only)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datomic-client-js",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Client for Datomic Cloud and Peer Server",
5
5
  "scripts": {
6
6
  "test": "mocha",
@@ -12,16 +12,16 @@
12
12
  "author": "Casey Marshall",
13
13
  "license": "Apache-2.0",
14
14
  "dependencies": {
15
- "aws-sdk": "2.599.0",
15
+ "aws-sdk": "2.1693.0",
16
+ "jsedn": "~0.4.1",
16
17
  "npm": "^6.13.6",
17
18
  "socks-proxy-agent": "4.0.2",
18
19
  "transit-js": "0.8.861",
19
- "uuid": "latest",
20
- "jsedn": "~0.4.1"
20
+ "uuid": "latest"
21
21
  },
22
22
  "devDependencies": {
23
- "promise": "~8.0.3",
24
- "jsdoc": "~3.6.3"
23
+ "jsdoc": "~3.6.3",
24
+ "promise": "~8.0.3"
25
25
  },
26
26
  "main": "index.js",
27
27
  "repository": {
package/src/channel.js CHANGED
@@ -44,6 +44,9 @@ Channel.prototype.close = function() {
44
44
  this.producers.forEach(p => {
45
45
  p[2](false);
46
46
  });
47
+ this.consumers.forEach(c => {
48
+ c[0](null);
49
+ });
47
50
  };
48
51
 
49
52
  /**
package/src/cloud.js CHANGED
@@ -7,6 +7,13 @@ let SocksProxyAgent = require('socks-proxy-agent');
7
7
  let transit = require('transit-js');
8
8
  let url = require('url');
9
9
 
10
+ let debug;
11
+ if (process.env.DATOMIC_CLIENT_JS_DEBUG === 'true') {
12
+ debug = console.log;
13
+ } else {
14
+ debug = () => {};
15
+ }
16
+
10
17
  function createAccessKeyIdForType(args) {
11
18
  if (args.type === 'admin') {
12
19
  return args.prefix + '/' + args.system + '/datomic/access/admin/' + args.keyName;
@@ -72,6 +79,7 @@ function Spi(config, routingMap, agent) {
72
79
  this.routingMap = routingMap;
73
80
  this._cachedKeys = {};
74
81
  this.agent = agent;
82
+ this.serverType = 'cloud';
75
83
  }
76
84
 
77
85
  Spi.prototype.addRouting = function (request) {
@@ -84,6 +92,7 @@ Spi.prototype.addRouting = function (request) {
84
92
  Spi.prototype.getSignParams = function(request, address) {
85
93
  let baseKeyId = baseAccessKeyId(this.config, address, request);
86
94
  let res = this._cachedKeys[baseKeyId];
95
+ debug('getSignParams', baseKeyId, res);
87
96
  if (res != null) {
88
97
  return signParams(this.config, res);
89
98
  } else {
@@ -112,6 +121,11 @@ Spi.prototype.getAgent = function () {
112
121
  return this.agent;
113
122
  };
114
123
 
124
+ Spi.prototype.usePrivateTrustAnchor = function () {
125
+ let u = new url.URL(this.config.endpoint);
126
+ return u.protocol === 'http:';
127
+ }
128
+
115
129
  let shared = require('./shared');
116
130
  function signParams(config, creds) {
117
131
  return {
@@ -153,11 +167,12 @@ function parseAccessKeyId(s) {
153
167
  }
154
168
 
155
169
  async function getKeyFile(config, s3url) {
170
+ debug('getKeyFile', config, s3url);
156
171
  let s3 = new aws.S3({region: config.region});
157
- let u = url.parse(s3url);
172
+ let u = new url.URL(s3url);
158
173
  let request = {
159
174
  Bucket: u.hostname,
160
- Key: u.path.replace(/^\/+/, '')
175
+ Key: u.pathname.replace(/^\/+/, '')
161
176
  };
162
177
  let result = await s3.getObject(request).promise();
163
178
  let reader = transit.reader('json');
@@ -169,7 +184,8 @@ const DEFAULT_HTTPS_PORT = 443;
169
184
 
170
185
  function parseEndpoint(s) {
171
186
  if (s != null) {
172
- let uri = url.parse(s);
187
+ let uri = new url.URL(s);
188
+ debug('parseEndpoint', s, uri);
173
189
  let protocol;
174
190
  if (uri.protocol === 'http:') {
175
191
  protocol = 'http';
@@ -177,10 +193,10 @@ function parseEndpoint(s) {
177
193
  protocol = 'https';
178
194
  }
179
195
  let port = uri.port;
180
- if (port == null) {
181
- if (uri.protocol === 'http') {
196
+ if (port == null || port === '') {
197
+ if (uri.protocol === 'http:') {
182
198
  port = DEFAULT_HTTP_PORT;
183
- } else if (uri.protocol === 'https') {
199
+ } else if (uri.protocol === 'https:') {
184
200
  port = DEFAULT_HTTPS_PORT;
185
201
  }
186
202
  } else {
@@ -237,6 +253,7 @@ function getS3AuthPath(request, agent) {
237
253
  }
238
254
 
239
255
  async function createSpi(args) {
256
+ debug('createSpi', args);
240
257
  args = Object.assign({}, args, {endpointMap: parseEndpoint(args.endpoint)});
241
258
  let agent = null;
242
259
  if (args.proxyPort != null) {
@@ -247,6 +264,7 @@ async function createSpi(args) {
247
264
  });
248
265
  }
249
266
  let s3Path = await getS3AuthPath(Object.assign({}, args.endpointMap,{method: 'get', path: '/'}), agent);
267
+ debug('s3path:', s3Path);
250
268
  let spiArgs = Object.assign(args, {s3AuthPath: 's3://' + s3Path});
251
269
  spiArgs.endpointMap.path = '/api';
252
270
  return new Spi(spiArgs, spiArgs.endpointMap, agent);
package/src/pro.js CHANGED
@@ -19,6 +19,7 @@ function routingMap(endpoint) {
19
19
  function Spi(signingMap, routingMap) {
20
20
  this.signingMap = signingMap;
21
21
  this.routingMap = routingMap;
22
+ this.serverType = 'peer-server';
22
23
  }
23
24
 
24
25
  Spi.prototype.addRouting = function(request) {
@@ -40,6 +41,10 @@ Spi.prototype.getAgent = function() {
40
41
  return null;
41
42
  };
42
43
 
44
+ Spi.prototype.usePrivateTrustAnchor = function () {
45
+ return true;
46
+ }
47
+
43
48
  function createSpi(args) {
44
49
  if (args.accessKey != null && args.endpoint != null) {
45
50
  let routing = routingMap(args.endpoint);
package/src/query.js CHANGED
@@ -8,6 +8,8 @@ let transit = require('transit-js');
8
8
  * specify transit.Keyword and transit.Symbol values in your query,
9
9
  * which is verbose and cumbersome.
10
10
  *
11
+ * @deprecated Use EDN template strings instead.
12
+ *
11
13
  * @constructor QueryBuilder
12
14
  */
13
15
  function QueryBuilder() {
package/src/shared.js CHANGED
@@ -312,6 +312,17 @@ function Connection(client, state, info, refreshInterval, lastRefresh) {
312
312
  this.lastRefresh = lastRefresh;
313
313
  }
314
314
 
315
+ function get_in(m, ...ks) {
316
+ let ret = m;
317
+ for (const k of ks) {
318
+ ret = ret[k];
319
+ if (ret == null) {
320
+ break;
321
+ }
322
+ }
323
+ return ret;
324
+ }
325
+
315
326
  Connection.prototype.advanceT = function(db) {
316
327
  let newState = this.state;
317
328
  let thisT = this.state.t;
@@ -350,6 +361,10 @@ Connection.prototype.getState = function() {
350
361
  return this.state;
351
362
  };
352
363
 
364
+ Connection.prototype.getServerType = function() {
365
+ return get_in(this, 'client', 'spi', 'serverType');
366
+ }
367
+
353
368
  /**
354
369
  * Sync with the most recent transaction on the server, and return
355
370
  * a Db value with that state.
@@ -569,8 +584,10 @@ function doSendWithRetry(httpRequest, requestContext, spi, timeout, signParams,
569
584
  let execRequest = function(signParams) {
570
585
  let signedRequest = signRequest(httpRequest, signParams);
571
586
  signedRequest.timeout = timeout;
572
- signedRequest.ca = transactorTrust;
573
- signedRequest.checkServerIdentity = function(_, __) {};
587
+ if (spi.usePrivateTrustAnchor()) {
588
+ signedRequest.ca = transactorTrust;
589
+ signedRequest.checkServerIdentity = function(_, __) {};
590
+ }
574
591
  if (spi.getAgent() != null) {
575
592
  signedRequest.agent = spi.getAgent();
576
593
  }
package/src/tx.js CHANGED
@@ -6,6 +6,8 @@ let shared = require('./shared.js');
6
6
  /**
7
7
  * A transaction builder.
8
8
  *
9
+ * @deprecated Use EDN template strings instead.
10
+ *
9
11
  * @constructor TxBuilder
10
12
  */
11
13
  function TxBuilder() {