@alphapoint/apex-web 5.5.4 → 5.5.5-fe.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.
- package/README.md +27 -2
- package/lib/App.js +30 -18
- package/lib/components/DepositSidePaneComponents/DepositFormComponent.js +2 -7
- package/lib/components/FusionAuth/ConfirmPendingWithdrawModal.js +60 -0
- package/lib/components/FusionAuth/FusionAuthCallbackComponent.js +66 -0
- package/lib/components/FusionAuth/FusionAuthCallbackContainer.js +24 -0
- package/lib/components/FusionAuth/FusionStepUpModal.js +63 -0
- package/lib/components/FusionAuth/LinkOAuthIdentityModal.css +6 -0
- package/lib/components/FusionAuth/LinkOAuthIdentityModal.js +65 -0
- package/lib/components/FuturesOrderBook/FuturesOrderBookContainer.js +5 -0
- package/lib/components/Login/LoginFormComponent.js +15 -4
- package/lib/components/Login/LoginFormContainer.js +21 -26
- package/lib/components/OrderBookComponents/OrderBookComponent.js +27 -25
- package/lib/components/OrderBookComponents/OrderBookContainer.js +5 -0
- package/lib/components/Retail/RetailSidePanes/FiatDeposit/FiatDepositFormComponent.js +2 -6
- package/lib/components/Retail/RetailSidePanes/FiatWithdraw/FiatWithdrawFormComponent.js +2 -6
- package/lib/components/SendReceiveSidePane/ReceiveAddress/ReceiveAddressComponent.js +2 -6
- package/lib/components/SendReceiveSidePane/SendAddress/SendAddressComponent.js +2 -7
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/ProfileFormComponent.js +3 -1
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +10 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +77 -0
- package/lib/components/WithdrawSidePaneComponents/WithdrawForm/WithdrawFormComponent.js +3 -8
- package/lib/components/common/APVerticalScroller/APVerticalScroller.js +8 -5
- package/lib/config/configDefault.json +8 -2
- package/lib/helpers/accountProviderHelper.js +28 -0
- package/lib/helpers/accountProviderHelper.test.js +67 -0
- package/lib/helpers/fusionStepUp.js +79 -0
- package/lib/helpers/fusionStepUp.test.js +136 -0
- package/lib/helpers/orderBook/priceGroupingHelper.js +29 -12
- package/lib/helpers/orderBook/priceGroupingHelper.test.js +50 -35
- package/lib/helpers/safeSessionStorage.js +36 -0
- package/lib/redux/actions/authActions.js +581 -48
- package/lib/redux/actions/fusionAuthActions.test.js +717 -0
- package/lib/redux/actions/modalActions.js +3 -0
- package/lib/redux/actions/withdrawActions.js +99 -65
- package/lib/redux/actions/wsConnectionActions.js +96 -1
- package/lib/redux/actions/wsConnectionLifecycle.test.js +207 -0
- package/package.json +4 -4
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _fusionStepUp = require("./fusionStepUp");
|
|
4
|
+
var STASH_KEY = 'fusionAuthPendingAction';
|
|
5
|
+
|
|
6
|
+
// A withdrawal as withdrawActions builds it: routing fields plus the destination details
|
|
7
|
+
// (TemplateForm) and travel-rule PII (Kytdetails) that must not reach sessionStorage.
|
|
8
|
+
var withdrawPayload = {
|
|
9
|
+
OMSId: 1,
|
|
10
|
+
AccountId: 7,
|
|
11
|
+
ProductId: 1,
|
|
12
|
+
Amount: '0.25',
|
|
13
|
+
TemplateType: 'Standard',
|
|
14
|
+
AccountProviderId: 1,
|
|
15
|
+
TemplateForm: JSON.stringify({
|
|
16
|
+
BankAccountNumber: '12345678',
|
|
17
|
+
BankName: 'Test Bank'
|
|
18
|
+
}),
|
|
19
|
+
Kytdetails: JSON.stringify({
|
|
20
|
+
BeneficiaryName: 'Jane Doe'
|
|
21
|
+
})
|
|
22
|
+
};
|
|
23
|
+
var stashWithdraw = function stashWithdraw() {
|
|
24
|
+
return (0, _fusionStepUp.stashPendingAction)({
|
|
25
|
+
type: _fusionStepUp.PENDING_ACTION_WITHDRAW,
|
|
26
|
+
payload: withdrawPayload
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
describe('fusionStepUp', function () {
|
|
30
|
+
beforeEach(function () {
|
|
31
|
+
sessionStorage.clear();
|
|
32
|
+
(0, _fusionStepUp.clearPendingAction)();
|
|
33
|
+
});
|
|
34
|
+
describe('stashPendingAction()', function () {
|
|
35
|
+
it('keeps the destination details and travel-rule PII out of sessionStorage', function () {
|
|
36
|
+
stashWithdraw();
|
|
37
|
+
var raw = sessionStorage.getItem(STASH_KEY);
|
|
38
|
+
expect(raw).not.toContain('12345678');
|
|
39
|
+
expect(raw).not.toContain('Test Bank');
|
|
40
|
+
expect(raw).not.toContain('Jane Doe');
|
|
41
|
+
var persisted = JSON.parse(raw);
|
|
42
|
+
expect(persisted.payload.TemplateForm).toBeUndefined();
|
|
43
|
+
expect(persisted.payload.Kytdetails).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
it('persists the routing fields needed to describe the request', function () {
|
|
46
|
+
stashWithdraw();
|
|
47
|
+
var _JSON$parse = JSON.parse(sessionStorage.getItem(STASH_KEY)),
|
|
48
|
+
payload = _JSON$parse.payload;
|
|
49
|
+
expect(payload).toMatchObject({
|
|
50
|
+
OMSId: 1,
|
|
51
|
+
AccountId: 7,
|
|
52
|
+
ProductId: 1,
|
|
53
|
+
Amount: '0.25',
|
|
54
|
+
TemplateType: 'Standard',
|
|
55
|
+
AccountProviderId: 1
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
it('does not mutate the caller’s payload', function () {
|
|
59
|
+
stashWithdraw();
|
|
60
|
+
expect(withdrawPayload.TemplateForm).toBeDefined();
|
|
61
|
+
expect(withdrawPayload.Kytdetails).toBeDefined();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
describe('takePendingAction()', function () {
|
|
65
|
+
it('returns the whole payload while this window is still alive', function () {
|
|
66
|
+
stashWithdraw();
|
|
67
|
+
var pending = (0, _fusionStepUp.takePendingAction)();
|
|
68
|
+
expect(pending.type).toBe(_fusionStepUp.PENDING_ACTION_WITHDRAW);
|
|
69
|
+
expect(pending.complete).toBe(true);
|
|
70
|
+
expect(pending.payload).toEqual(withdrawPayload);
|
|
71
|
+
});
|
|
72
|
+
it('clears the stash, so a second read returns null', function () {
|
|
73
|
+
stashWithdraw();
|
|
74
|
+
expect((0, _fusionStepUp.takePendingAction)()).not.toBeNull();
|
|
75
|
+
expect((0, _fusionStepUp.takePendingAction)()).toBeNull();
|
|
76
|
+
expect(sessionStorage.getItem(STASH_KEY)).toBeNull();
|
|
77
|
+
});
|
|
78
|
+
it('returns null when nothing was stashed', function () {
|
|
79
|
+
expect((0, _fusionStepUp.takePendingAction)()).toBeNull();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// The full-page redirect fallback unloads the window, so only the sessionStorage half
|
|
83
|
+
// survives — enough to describe the request, not to resubmit it.
|
|
84
|
+
it('reports complete: false when the in-memory half did not survive', function () {
|
|
85
|
+
stashWithdraw();
|
|
86
|
+
(0, _fusionStepUp.clearPendingAction)();
|
|
87
|
+
// put back only what a reload would have left behind
|
|
88
|
+
sessionStorage.setItem(STASH_KEY, JSON.stringify({
|
|
89
|
+
type: _fusionStepUp.PENDING_ACTION_WITHDRAW,
|
|
90
|
+
payload: {
|
|
91
|
+
OMSId: 1,
|
|
92
|
+
AccountId: 7,
|
|
93
|
+
ProductId: 1,
|
|
94
|
+
Amount: '0.25'
|
|
95
|
+
},
|
|
96
|
+
stashedAt: Date.now()
|
|
97
|
+
}));
|
|
98
|
+
var pending = (0, _fusionStepUp.takePendingAction)();
|
|
99
|
+
expect(pending.complete).toBe(false);
|
|
100
|
+
expect(pending.payload.TemplateForm).toBeUndefined();
|
|
101
|
+
});
|
|
102
|
+
it('returns null once the stash is older than 10 minutes', function () {
|
|
103
|
+
stashWithdraw();
|
|
104
|
+
var stored = JSON.parse(sessionStorage.getItem(STASH_KEY));
|
|
105
|
+
stored.stashedAt = Date.now() - (10 * 60 * 1000 + 1);
|
|
106
|
+
sessionStorage.setItem(STASH_KEY, JSON.stringify(stored));
|
|
107
|
+
expect((0, _fusionStepUp.takePendingAction)()).toBeNull();
|
|
108
|
+
});
|
|
109
|
+
it('accepts a stash just inside the 10 minute window', function () {
|
|
110
|
+
stashWithdraw();
|
|
111
|
+
var stored = JSON.parse(sessionStorage.getItem(STASH_KEY));
|
|
112
|
+
stored.stashedAt = Date.now() - (10 * 60 * 1000 - 1000);
|
|
113
|
+
sessionStorage.setItem(STASH_KEY, JSON.stringify(stored));
|
|
114
|
+
expect((0, _fusionStepUp.takePendingAction)()).not.toBeNull();
|
|
115
|
+
});
|
|
116
|
+
it('returns null when the stash has no timestamp', function () {
|
|
117
|
+
sessionStorage.setItem(STASH_KEY, JSON.stringify({
|
|
118
|
+
type: _fusionStepUp.PENDING_ACTION_WITHDRAW,
|
|
119
|
+
payload: {}
|
|
120
|
+
}));
|
|
121
|
+
expect((0, _fusionStepUp.takePendingAction)()).toBeNull();
|
|
122
|
+
});
|
|
123
|
+
it('returns null rather than throwing on an unparsable stash', function () {
|
|
124
|
+
sessionStorage.setItem(STASH_KEY, 'not json');
|
|
125
|
+
expect((0, _fusionStepUp.takePendingAction)()).toBeNull();
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
describe('clearPendingAction()', function () {
|
|
129
|
+
it('drops both halves', function () {
|
|
130
|
+
stashWithdraw();
|
|
131
|
+
(0, _fusionStepUp.clearPendingAction)();
|
|
132
|
+
expect(sessionStorage.getItem(STASH_KEY)).toBeNull();
|
|
133
|
+
expect((0, _fusionStepUp.takePendingAction)()).toBeNull();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -55,12 +55,21 @@ var isValidGroupingOption = exports.isValidGroupingOption = function isValidGrou
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* Every instrument's grouping lives in a single localStorage
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
58
|
+
* Every server+account+instrument combination's grouping lives in a single localStorage
|
|
59
|
+
* record, keyed by `"<server>:<accountId>:<instrumentId>"`:
|
|
60
|
+
* `{"wss://api.qa-current.apstage.net/WSGateway:1:10":"10","wss://api.qa-next.apstage.net/WSGateway:1:10":"1"}`.
|
|
61
|
+
* One record rather than a key per combination keeps the whole preference readable/clearable
|
|
62
|
+
* in one place instead of accumulating an unbounded number of `orderBookGrouping:<id>` entries
|
|
63
|
+
* as the user visits instruments, switches accounts, and switches servers. Scoping by server as
|
|
64
|
+
* well as account keeps one backend's (or account's) grouping choice for an instrument from
|
|
65
|
+
* leaking into another backend (or account) trading an instrument with the same id - account
|
|
66
|
+
* and instrument ids are backend-assigned and aren't guaranteed to mean the same thing across
|
|
67
|
+
* servers (e.g. qa-current vs qa-next).
|
|
62
68
|
*/
|
|
63
69
|
var GROUPING_STORAGE_KEY = exports.GROUPING_STORAGE_KEY = 'orderBookGrouping';
|
|
70
|
+
var storageKey = function storageKey(server, accountId, instrumentId) {
|
|
71
|
+
return "".concat(server, ":").concat(accountId, ":").concat(instrumentId);
|
|
72
|
+
};
|
|
64
73
|
|
|
65
74
|
// Anything unparseable or not a plain object (a stale value from another format, a user
|
|
66
75
|
// editing localStorage by hand) is treated as "nothing stored" rather than throwing on read.
|
|
@@ -72,28 +81,36 @@ var readStoredGroupings = function readStoredGroupings() {
|
|
|
72
81
|
return {};
|
|
73
82
|
}
|
|
74
83
|
};
|
|
84
|
+
var isMissing = function isMissing(value) {
|
|
85
|
+
return value === undefined || value === null;
|
|
86
|
+
};
|
|
75
87
|
|
|
76
88
|
/**
|
|
89
|
+
* @param {String} server gateway URL of the connected backend
|
|
90
|
+
* @param {Number} accountId
|
|
77
91
|
* @param {Number} instrumentId
|
|
78
92
|
* @param {Array<{value: String, label: String}>} options currently offered options
|
|
79
93
|
* @returns {String|undefined} the stored grouping, or undefined when nothing valid is stored
|
|
80
94
|
*/
|
|
81
|
-
var getStoredGrouping = exports.getStoredGrouping = function getStoredGrouping(instrumentId, options) {
|
|
82
|
-
|
|
95
|
+
var getStoredGrouping = exports.getStoredGrouping = function getStoredGrouping(server, accountId, instrumentId, options) {
|
|
96
|
+
if (isMissing(server) || isMissing(accountId) || isMissing(instrumentId)) return undefined;
|
|
97
|
+
var stored = readStoredGroupings()[storageKey(server, accountId, instrumentId)];
|
|
83
98
|
return stored && isValidGroupingOption(stored, options) ? stored : undefined;
|
|
84
99
|
};
|
|
85
100
|
|
|
86
101
|
/**
|
|
87
|
-
* Merges one instrument's grouping into the shared record, leaving
|
|
88
|
-
*
|
|
89
|
-
*
|
|
102
|
+
* Merges one server+account+instrument combination's grouping into the shared record, leaving
|
|
103
|
+
* every other combination's entry untouched. No-ops without a server, account, and instrument
|
|
104
|
+
* id so a selection made before all three resolve can't leave an "undefined" entry behind.
|
|
90
105
|
*
|
|
106
|
+
* @param {String} server gateway URL of the connected backend
|
|
107
|
+
* @param {Number} accountId
|
|
91
108
|
* @param {Number} instrumentId
|
|
92
109
|
* @param {String} grouping
|
|
93
110
|
*/
|
|
94
|
-
var storeGrouping = exports.storeGrouping = function storeGrouping(instrumentId, grouping) {
|
|
95
|
-
if (
|
|
96
|
-
localStorage.setItem(GROUPING_STORAGE_KEY, JSON.stringify(_objectSpread(_objectSpread({}, readStoredGroupings()), {}, _defineProperty({}, instrumentId, grouping))));
|
|
111
|
+
var storeGrouping = exports.storeGrouping = function storeGrouping(server, accountId, instrumentId, grouping) {
|
|
112
|
+
if (isMissing(server) || isMissing(accountId) || isMissing(instrumentId)) return;
|
|
113
|
+
localStorage.setItem(GROUPING_STORAGE_KEY, JSON.stringify(_objectSpread(_objectSpread({}, readStoredGroupings()), {}, _defineProperty({}, storageKey(server, accountId, instrumentId), grouping))));
|
|
97
114
|
};
|
|
98
115
|
|
|
99
116
|
/**
|
|
@@ -59,57 +59,72 @@ describe('priceGroupingHelper', function () {
|
|
|
59
59
|
});
|
|
60
60
|
describe('stored grouping', function () {
|
|
61
61
|
var options = (0, _priceGroupingHelper.getPriceGroupingOptions)(t);
|
|
62
|
+
var serverA = 'wss://api.qa-current.apstage.net/WSGateway';
|
|
63
|
+
var serverB = 'wss://api.qa-next.apstage.net/WSGateway';
|
|
62
64
|
beforeEach(function () {
|
|
63
65
|
return localStorage.clear();
|
|
64
66
|
});
|
|
65
|
-
it('keeps every instrument in a single record', function () {
|
|
66
|
-
(0, _priceGroupingHelper.storeGrouping)(1, '10');
|
|
67
|
-
(0, _priceGroupingHelper.storeGrouping)(
|
|
68
|
-
expect(JSON.parse(localStorage.getItem(_priceGroupingHelper.GROUPING_STORAGE_KEY))).toEqual({
|
|
69
|
-
1: '10',
|
|
70
|
-
2: '0.1'
|
|
71
|
-
});
|
|
67
|
+
it('keeps every server+account+instrument combination in a single record', function () {
|
|
68
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
69
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 11, '0.1');
|
|
70
|
+
expect(JSON.parse(localStorage.getItem(_priceGroupingHelper.GROUPING_STORAGE_KEY))).toEqual(_defineProperty(_defineProperty({}, "".concat(serverA, ":1:10"), '10'), "".concat(serverA, ":1:11"), '0.1'));
|
|
72
71
|
expect(localStorage.length).toBe(1);
|
|
73
72
|
});
|
|
74
|
-
it("reads back
|
|
75
|
-
(0, _priceGroupingHelper.storeGrouping)(1, '10');
|
|
76
|
-
(0, _priceGroupingHelper.storeGrouping)(
|
|
77
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBe('10');
|
|
78
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(
|
|
79
|
-
});
|
|
80
|
-
it('overwrites one
|
|
81
|
-
(0, _priceGroupingHelper.storeGrouping)(1, '10');
|
|
82
|
-
(0, _priceGroupingHelper.storeGrouping)(
|
|
83
|
-
(0, _priceGroupingHelper.storeGrouping)(1, _priceGroupingHelper.NONE_GROUPING_VALUE);
|
|
84
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBe(_priceGroupingHelper.NONE_GROUPING_VALUE);
|
|
85
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(
|
|
86
|
-
});
|
|
87
|
-
it('
|
|
88
|
-
(0, _priceGroupingHelper.storeGrouping)(1, '10');
|
|
89
|
-
|
|
90
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(
|
|
73
|
+
it("reads back a combination's own value", function () {
|
|
74
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
75
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 11, '0.1');
|
|
76
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBe('10');
|
|
77
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 11, options)).toBe('0.1');
|
|
78
|
+
});
|
|
79
|
+
it('overwrites one combination without disturbing the others', function () {
|
|
80
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
81
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 11, '0.1');
|
|
82
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, _priceGroupingHelper.NONE_GROUPING_VALUE);
|
|
83
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBe(_priceGroupingHelper.NONE_GROUPING_VALUE);
|
|
84
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 11, options)).toBe('0.1');
|
|
85
|
+
});
|
|
86
|
+
it('keeps different accounts trading the same instrument separate', function () {
|
|
87
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
88
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 2, 10, '0.1');
|
|
89
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBe('10');
|
|
90
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 2, 10, options)).toBe('0.1');
|
|
91
|
+
});
|
|
92
|
+
it('keeps different servers with colliding account/instrument ids separate', function () {
|
|
93
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
94
|
+
(0, _priceGroupingHelper.storeGrouping)(serverB, 1, 10, '0.1');
|
|
95
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBe('10');
|
|
96
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverB, 1, 10, options)).toBe('0.1');
|
|
97
|
+
});
|
|
98
|
+
it('returns undefined for a combination with nothing stored', function () {
|
|
99
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
100
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 99, options)).toBeUndefined();
|
|
101
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 99, 10, options)).toBeUndefined();
|
|
102
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverB, 1, 10, options)).toBeUndefined();
|
|
103
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(undefined, 1, 10, options)).toBeUndefined();
|
|
104
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, undefined, 10, options)).toBeUndefined();
|
|
105
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, undefined, options)).toBeUndefined();
|
|
91
106
|
});
|
|
92
107
|
it('returns undefined when the stored value is no longer an offered option', function () {
|
|
93
|
-
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, JSON.stringify({
|
|
94
|
-
|
|
95
|
-
}));
|
|
96
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBeUndefined();
|
|
108
|
+
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, JSON.stringify(_defineProperty({}, "".concat(serverA, ":1:10"), '0.00000001')));
|
|
109
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBeUndefined();
|
|
97
110
|
});
|
|
98
111
|
it('treats an unusable record as nothing stored instead of throwing', function () {
|
|
99
112
|
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, 'not json');
|
|
100
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBeUndefined();
|
|
113
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBeUndefined();
|
|
101
114
|
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, JSON.stringify(['10']));
|
|
102
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBeUndefined();
|
|
115
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBeUndefined();
|
|
103
116
|
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, JSON.stringify(null));
|
|
104
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBeUndefined();
|
|
117
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBeUndefined();
|
|
105
118
|
});
|
|
106
119
|
it('recovers from an unusable record on the next write', function () {
|
|
107
120
|
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, 'not json');
|
|
108
|
-
(0, _priceGroupingHelper.storeGrouping)(1, '10');
|
|
109
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBe('10');
|
|
121
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
122
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBe('10');
|
|
110
123
|
});
|
|
111
|
-
it('does not store an entry when there is no instrument id yet', function () {
|
|
112
|
-
(0, _priceGroupingHelper.storeGrouping)(undefined, '10');
|
|
124
|
+
it('does not store an entry when there is no server, account, or instrument id yet', function () {
|
|
125
|
+
(0, _priceGroupingHelper.storeGrouping)(undefined, 1, 10, '10');
|
|
126
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, undefined, 10, '10');
|
|
127
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, undefined, '10');
|
|
113
128
|
expect(localStorage.getItem(_priceGroupingHelper.GROUPING_STORAGE_KEY)).toBeNull();
|
|
114
129
|
});
|
|
115
130
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.writeSessionItem = exports.removeSessionItem = exports.readSessionItem = void 0;
|
|
7
|
+
// sessionStorage is not always readable: where the browser's storage policy denies access
|
|
8
|
+
// (Safari's "Block All Cookies", enterprise policies, a sandboxed frame) the accessor itself
|
|
9
|
+
// throws a SecurityError rather than returning null. The SSO callback touches storage from its
|
|
10
|
+
// mount path, so an unguarded read there renders a blank page instead of an error the user can
|
|
11
|
+
// act on. These wrappers report the failure instead of propagating it.
|
|
12
|
+
|
|
13
|
+
var readSessionItem = exports.readSessionItem = function readSessionItem(key) {
|
|
14
|
+
try {
|
|
15
|
+
return sessionStorage.getItem(key);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** True when the value was stored; false when storage refused it. */
|
|
22
|
+
var writeSessionItem = exports.writeSessionItem = function writeSessionItem(key, value) {
|
|
23
|
+
try {
|
|
24
|
+
sessionStorage.setItem(key, value);
|
|
25
|
+
return true;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var removeSessionItem = exports.removeSessionItem = function removeSessionItem(key) {
|
|
31
|
+
try {
|
|
32
|
+
sessionStorage.removeItem(key);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// nothing left to clear
|
|
35
|
+
}
|
|
36
|
+
};
|