@barchart/portfolio-client-js 1.3.9 → 1.3.12
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/example/example.js +47 -26
- package/lib/common/Configuration.js +13 -11
- package/lib/gateway/PortfolioGateway.js +17 -0
- package/lib/gateway/jwt/JwtGateway.js +24 -24
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/example/example.js
CHANGED
|
@@ -63,6 +63,8 @@ module.exports = function () {
|
|
|
63
63
|
return 'xos40seq3e.execute-api.us-east-1.amazonaws.com/prod';
|
|
64
64
|
} else if (host === Configuration.adminHost) {
|
|
65
65
|
return 'q1x45oxon1.execute-api.us-east-1.amazonaws.com/admin';
|
|
66
|
+
} else if (host === Configuration.demoHost) {
|
|
67
|
+
return 'b9132ukaob.execute-api.us-east-1.amazonaws.com/demo';
|
|
66
68
|
} else {
|
|
67
69
|
return '';
|
|
68
70
|
}
|
|
@@ -97,35 +99,35 @@ module.exports = function () {
|
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
/**
|
|
100
|
-
* The host of the
|
|
102
|
+
* The host of the public demo system.
|
|
101
103
|
*
|
|
102
104
|
* @public
|
|
103
105
|
* @static
|
|
104
|
-
* @
|
|
106
|
+
* @return {String}
|
|
105
107
|
*/
|
|
106
108
|
|
|
107
109
|
}, {
|
|
108
|
-
key: '
|
|
110
|
+
key: 'demoHost',
|
|
109
111
|
get: function get() {
|
|
110
|
-
return 'portfolio.aws.barchart.com';
|
|
112
|
+
return 'portfolio-demo.aws.barchart.com';
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
/**
|
|
114
|
-
* The host of the
|
|
116
|
+
* The host of the production system.
|
|
115
117
|
*
|
|
116
118
|
* @public
|
|
117
119
|
* @static
|
|
118
|
-
* @
|
|
120
|
+
* @returns {String}
|
|
119
121
|
*/
|
|
120
122
|
|
|
121
123
|
}, {
|
|
122
|
-
key: '
|
|
124
|
+
key: 'productionHost',
|
|
123
125
|
get: function get() {
|
|
124
|
-
return 'portfolio
|
|
126
|
+
return 'portfolio.aws.barchart.com';
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
/**
|
|
128
|
-
* The host of the
|
|
130
|
+
* The host of the internal admin system.
|
|
129
131
|
*
|
|
130
132
|
* @public
|
|
131
133
|
* @static
|
|
@@ -133,9 +135,9 @@ module.exports = function () {
|
|
|
133
135
|
*/
|
|
134
136
|
|
|
135
137
|
}, {
|
|
136
|
-
key: '
|
|
138
|
+
key: 'adminHost',
|
|
137
139
|
get: function get() {
|
|
138
|
-
return 'portfolio-
|
|
140
|
+
return 'portfolio-admin.aws.barchart.com';
|
|
139
141
|
}
|
|
140
142
|
}]);
|
|
141
143
|
|
|
@@ -1035,6 +1037,25 @@ module.exports = function () {
|
|
|
1035
1037
|
});
|
|
1036
1038
|
}
|
|
1037
1039
|
|
|
1040
|
+
/**
|
|
1041
|
+
* Creates and starts a new {@link PortfolioGateway} for use in the demo environment.
|
|
1042
|
+
*
|
|
1043
|
+
* @public
|
|
1044
|
+
* @static
|
|
1045
|
+
* @param {RequestInterceptor=|Promise<RequestInterceptor>=} requestInterceptor - A request interceptor used with each request (typically used to inject JWT tokens).
|
|
1046
|
+
* @returns {Promise<PortfolioGateway>}
|
|
1047
|
+
*/
|
|
1048
|
+
|
|
1049
|
+
}, {
|
|
1050
|
+
key: 'forDemo',
|
|
1051
|
+
value: function forDemo(requestInterceptor) {
|
|
1052
|
+
return Promise.resolve(requestInterceptor).then(function (requestInterceptor) {
|
|
1053
|
+
assert.argumentIsOptional(requestInterceptor, 'requestInterceptor', RequestInterceptor, 'RequestInterceptor');
|
|
1054
|
+
|
|
1055
|
+
return start(new PortfolioGateway('https', Configuration.demoHost, 443, 'development', requestInterceptor));
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1038
1059
|
/**
|
|
1039
1060
|
* Creates and starts a new {@link PortfolioGateway} for use in the production environment.
|
|
1040
1061
|
*
|
|
@@ -1359,15 +1380,15 @@ module.exports = function () {
|
|
|
1359
1380
|
var refreshToken = function refreshToken() {
|
|
1360
1381
|
var refreshPromise = scheduler.backoff(function () {
|
|
1361
1382
|
return _this4.readToken();
|
|
1362
|
-
},
|
|
1383
|
+
}, 750, 'Read JWT token', 3).then(function (token) {
|
|
1363
1384
|
if (_this4._refreshInterval) {
|
|
1364
1385
|
cachePromise = refreshPromise;
|
|
1365
|
-
}
|
|
1366
1386
|
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1387
|
+
if (cacheDisposable === null) {
|
|
1388
|
+
cacheDisposable = scheduler.repeat(function () {
|
|
1389
|
+
return refreshToken();
|
|
1390
|
+
}, _this4._refreshInterval, 'Refresh JWT token');
|
|
1391
|
+
}
|
|
1371
1392
|
}
|
|
1372
1393
|
|
|
1373
1394
|
return token;
|
|
@@ -1619,6 +1640,14 @@ module.exports = function () {
|
|
|
1619
1640
|
}).withRequestInterceptor(externalRequestInterceptor).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
|
|
1620
1641
|
}
|
|
1621
1642
|
|
|
1643
|
+
function _forDemo(userId) {
|
|
1644
|
+
return EndpointBuilder.for('read-jwt-token-for-demo', 'lookup user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.demoHost).withPathBuilder(function (pb) {
|
|
1645
|
+
pb.withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
|
|
1646
|
+
}).withQueryBuilder(function (qb) {
|
|
1647
|
+
qb.withLiteralParameter('user', 'userId', userId).withLiteralParameter('legacy user', 'userLegacyId', userId).withLiteralParameter('user context', 'userContext', 'Barchart').withLiteralParameter('user permission level', 'userPermissions', 'registered');
|
|
1648
|
+
}).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1622
1651
|
function _forProduction(externalRequestInterceptor) {
|
|
1623
1652
|
return EndpointBuilder.for('translate-jwt-token-for-production', 'lookup Barchart user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.productionHost).withPathBuilder(function (pb) {
|
|
1624
1653
|
pb.withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
|
|
@@ -1641,14 +1670,6 @@ module.exports = function () {
|
|
|
1641
1670
|
}).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
|
|
1642
1671
|
}
|
|
1643
1672
|
|
|
1644
|
-
function _forDemo(userId) {
|
|
1645
|
-
return EndpointBuilder.for('read-jwt-token-for-demo', 'lookup user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.developmentHost).withPathBuilder(function (pb) {
|
|
1646
|
-
pb.withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
|
|
1647
|
-
}).withQueryBuilder(function (qb) {
|
|
1648
|
-
qb.withLiteralParameter('user', 'userId', userId).withLiteralParameter('legacy user', 'userLegacyId', userId).withLiteralParameter('user context', 'userContext', 'Barchart').withLiteralParameter('user permission level', 'userPermissions', 'registered');
|
|
1649
|
-
}).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
1673
|
return JwtGateway;
|
|
1653
1674
|
}();
|
|
1654
1675
|
|
|
@@ -1664,7 +1685,7 @@ module.exports = function () {
|
|
|
1664
1685
|
return {
|
|
1665
1686
|
JwtGateway: JwtGateway,
|
|
1666
1687
|
PortfolioGateway: PortfolioGateway,
|
|
1667
|
-
version: '1.3.
|
|
1688
|
+
version: '1.3.12'
|
|
1668
1689
|
};
|
|
1669
1690
|
}();
|
|
1670
1691
|
|
|
@@ -20,6 +20,8 @@ module.exports = (() => {
|
|
|
20
20
|
return 'xos40seq3e.execute-api.us-east-1.amazonaws.com/prod';
|
|
21
21
|
} else if (host === Configuration.adminHost) {
|
|
22
22
|
return 'q1x45oxon1.execute-api.us-east-1.amazonaws.com/admin';
|
|
23
|
+
} else if (host === Configuration.demoHost) {
|
|
24
|
+
return 'b9132ukaob.execute-api.us-east-1.amazonaws.com/demo';
|
|
23
25
|
} else {
|
|
24
26
|
return '';
|
|
25
27
|
}
|
|
@@ -48,36 +50,36 @@ module.exports = (() => {
|
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
|
-
* The host of the
|
|
53
|
+
* The host of the public demo system.
|
|
52
54
|
*
|
|
53
55
|
* @public
|
|
54
56
|
* @static
|
|
55
|
-
* @
|
|
57
|
+
* @return {String}
|
|
56
58
|
*/
|
|
57
|
-
static get
|
|
58
|
-
return 'portfolio.aws.barchart.com';
|
|
59
|
+
static get demoHost() {
|
|
60
|
+
return 'portfolio-demo.aws.barchart.com';
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
/**
|
|
62
|
-
* The host of the
|
|
64
|
+
* The host of the production system.
|
|
63
65
|
*
|
|
64
66
|
* @public
|
|
65
67
|
* @static
|
|
66
|
-
* @
|
|
68
|
+
* @returns {String}
|
|
67
69
|
*/
|
|
68
|
-
static get
|
|
69
|
-
return 'portfolio
|
|
70
|
+
static get productionHost() {
|
|
71
|
+
return 'portfolio.aws.barchart.com';
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
|
-
* The host of the
|
|
75
|
+
* The host of the internal admin system.
|
|
74
76
|
*
|
|
75
77
|
* @public
|
|
76
78
|
* @static
|
|
77
79
|
* @return {String}
|
|
78
80
|
*/
|
|
79
|
-
static get
|
|
80
|
-
return 'portfolio-
|
|
81
|
+
static get adminHost() {
|
|
82
|
+
return 'portfolio-admin.aws.barchart.com';
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
toString() {
|
|
@@ -965,6 +965,23 @@ module.exports = (() => {
|
|
|
965
965
|
});
|
|
966
966
|
}
|
|
967
967
|
|
|
968
|
+
/**
|
|
969
|
+
* Creates and starts a new {@link PortfolioGateway} for use in the demo environment.
|
|
970
|
+
*
|
|
971
|
+
* @public
|
|
972
|
+
* @static
|
|
973
|
+
* @param {RequestInterceptor=|Promise<RequestInterceptor>=} requestInterceptor - A request interceptor used with each request (typically used to inject JWT tokens).
|
|
974
|
+
* @returns {Promise<PortfolioGateway>}
|
|
975
|
+
*/
|
|
976
|
+
static forDemo(requestInterceptor) {
|
|
977
|
+
return Promise.resolve(requestInterceptor)
|
|
978
|
+
.then((requestInterceptor) => {
|
|
979
|
+
assert.argumentIsOptional(requestInterceptor, 'requestInterceptor', RequestInterceptor, 'RequestInterceptor');
|
|
980
|
+
|
|
981
|
+
return start(new PortfolioGateway('https', Configuration.demoHost, 443, 'development', requestInterceptor));
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
|
|
968
985
|
/**
|
|
969
986
|
* Creates and starts a new {@link PortfolioGateway} for use in the production environment.
|
|
970
987
|
*
|
|
@@ -101,14 +101,14 @@ module.exports = (() => {
|
|
|
101
101
|
let cacheDisposable = null;
|
|
102
102
|
|
|
103
103
|
const refreshToken = () => {
|
|
104
|
-
const refreshPromise = scheduler.backoff(() => this.readToken(),
|
|
104
|
+
const refreshPromise = scheduler.backoff(() => this.readToken(), 750, 'Read JWT token', 3)
|
|
105
105
|
.then((token) => {
|
|
106
106
|
if (this._refreshInterval) {
|
|
107
107
|
cachePromise = refreshPromise;
|
|
108
|
-
}
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
if (cacheDisposable === null) {
|
|
110
|
+
cacheDisposable = scheduler.repeat(() => refreshToken(), this._refreshInterval, 'Refresh JWT token');
|
|
111
|
+
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
return token;
|
|
@@ -354,6 +354,26 @@ module.exports = (() => {
|
|
|
354
354
|
.endpoint;
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
+
function forDemo(userId) {
|
|
358
|
+
return EndpointBuilder.for('read-jwt-token-for-demo', 'lookup user identity')
|
|
359
|
+
.withVerb(VerbType.GET)
|
|
360
|
+
.withProtocol(ProtocolType.HTTPS)
|
|
361
|
+
.withHost(Configuration.demoHost)
|
|
362
|
+
.withPathBuilder((pb) => {
|
|
363
|
+
pb.withLiteralParameter('token', 'token')
|
|
364
|
+
.withLiteralParameter('barchart', 'barchart')
|
|
365
|
+
.withLiteralParameter('generator', 'generator');
|
|
366
|
+
})
|
|
367
|
+
.withQueryBuilder((qb) => {
|
|
368
|
+
qb.withLiteralParameter('user', 'userId', userId)
|
|
369
|
+
.withLiteralParameter('legacy user', 'userLegacyId', userId)
|
|
370
|
+
.withLiteralParameter('user context', 'userContext', 'Barchart')
|
|
371
|
+
.withLiteralParameter('user permission level', 'userPermissions', 'registered');
|
|
372
|
+
})
|
|
373
|
+
.withResponseInterceptor(ResponseInterceptor.DATA)
|
|
374
|
+
.endpoint;
|
|
375
|
+
}
|
|
376
|
+
|
|
357
377
|
function forProduction(externalRequestInterceptor) {
|
|
358
378
|
return EndpointBuilder.for('translate-jwt-token-for-production', 'lookup Barchart user identity')
|
|
359
379
|
.withVerb(VerbType.GET)
|
|
@@ -395,25 +415,5 @@ module.exports = (() => {
|
|
|
395
415
|
.endpoint;
|
|
396
416
|
}
|
|
397
417
|
|
|
398
|
-
function forDemo(userId) {
|
|
399
|
-
return EndpointBuilder.for('read-jwt-token-for-demo', 'lookup user identity')
|
|
400
|
-
.withVerb(VerbType.GET)
|
|
401
|
-
.withProtocol(ProtocolType.HTTPS)
|
|
402
|
-
.withHost(Configuration.developmentHost)
|
|
403
|
-
.withPathBuilder((pb) => {
|
|
404
|
-
pb.withLiteralParameter('token', 'token')
|
|
405
|
-
.withLiteralParameter('barchart', 'barchart')
|
|
406
|
-
.withLiteralParameter('generator', 'generator');
|
|
407
|
-
})
|
|
408
|
-
.withQueryBuilder((qb) => {
|
|
409
|
-
qb.withLiteralParameter('user', 'userId', userId)
|
|
410
|
-
.withLiteralParameter('legacy user', 'userLegacyId', userId)
|
|
411
|
-
.withLiteralParameter('user context', 'userContext', 'Barchart')
|
|
412
|
-
.withLiteralParameter('user permission level', 'userPermissions', 'registered');
|
|
413
|
-
})
|
|
414
|
-
.withResponseInterceptor(ResponseInterceptor.DATA)
|
|
415
|
-
.endpoint;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
418
|
return JwtGateway;
|
|
419
419
|
})();
|
package/lib/index.js
CHANGED