Skip to content

Commit

Permalink
Reset RSA access state on connect.core.terminate() (#827)
Browse files Browse the repository at this point in the history
Co-authored-by: Andy Wang <[email protected]>
  • Loading branch information
andywang219 and Andy Wang authored Jan 16, 2024
1 parent cac0533 commit 50dcc82
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amazon-connect-streams",
"version": "2.6.8",
"version": "2.6.9",
"description": "Amazon Connect Streams Library",
"engines": {
"node": ">=12.0.0"
Expand Down
2 changes: 1 addition & 1 deletion release/connect-streams-dr-min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion release/connect-streams-dr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion release/connect-streams-min.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion release/connect-streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -26297,7 +26297,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;// AWS SDK for JavaScript v2.1377.0

connect.core = {};
connect.core.initialized = false;
connect.version = "2.6.8";
connect.version = "2.6.9";
connect.outerContextStreamsVersion = null;
connect.DEFAULT_BATCH_SIZE = 500;

Expand Down Expand Up @@ -26703,6 +26703,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;// AWS SDK for JavaScript v2.1377.0
connect.core.softphoneManager = null;
connect.core.upstream = null;
connect.core.keepaliveManager = null;
connect.storageAccess.resetStorageAccessState();
connect.agent.initialized = false;
connect.core.initialized = false;
};
Expand Down Expand Up @@ -30514,6 +30515,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;// AWS SDK for JavaScript v2.1377.0
storageParams = {};
originalCCPUrl = '';
rsaContainer = null;
onGrantCallbackInvoked = false;
};

/**
Expand Down Expand Up @@ -30777,6 +30779,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;// AWS SDK for JavaScript v2.1377.0
getRequestStorageAccessUrl,
storageAccessEvents,
resetStorageAccessState,
getOnGrantCallbackInvoked: () => onGrantCallbackInvoked,
getStorageAccessParams: () => storageParams,
onRequest: onRequestHandler,
request: () => {
Expand Down
1 change: 1 addition & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@
connect.core.softphoneManager = null;
connect.core.upstream = null;
connect.core.keepaliveManager = null;
connect.storageAccess.resetStorageAccessState();
connect.agent.initialized = false;
connect.core.initialized = false;
};
Expand Down
2 changes: 2 additions & 0 deletions src/request-storage-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
storageParams = {};
originalCCPUrl = '';
rsaContainer = null;
onGrantCallbackInvoked = false;
};

/**
Expand Down Expand Up @@ -345,6 +346,7 @@
getRequestStorageAccessUrl,
storageAccessEvents,
resetStorageAccessState,
getOnGrantCallbackInvoked: () => onGrantCallbackInvoked,
getStorageAccessParams: () => storageParams,
onRequest: onRequestHandler,
request: () => {
Expand Down
9 changes: 9 additions & 0 deletions test/unit/core.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2114,16 +2114,25 @@ describe('Core', function () {
});

it("Check if CCP is initialized after calling terminate function and re-calling initCCP", function () {
const storageAccessOriginal = connect.storageAccess;
connect.storageAccess = { ...connect.storageAccess, resetStorageAccessState: sinon.fake()};

expect(params.ccpUrl).not.to.be.a("null");
expect(containerDiv).not.to.be.a("null");
connect.core.initCCP(containerDiv, params);
expect(isCCPInitialized(containerDiv, params)).to.be.true;

connect.core.terminate();
expect(connect.storageAccess.resetStorageAccessState.calledOnce).to.be.true;

connect.core.terminate();
expect(connect.storageAccess.resetStorageAccessState.calledTwice).to.be.true;

expect(isCCPTerminated()).to.be.true;
sandbox.resetHistory();
connect.core.initCCP(containerDiv, params);
expect(isCCPInitialized(containerDiv, params)).to.be.true;
connect.storageAccess = storageAccessOriginal;
});

});
Expand Down
5 changes: 5 additions & 0 deletions test/unit/request-storage-access.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ describe('Request Storage Access module', () => {
});

connect.storageAccess.init(ccpUrl, container);
expect(connect.storageAccess.getOnGrantCallbackInvoked()).to.be.false;
connect.storageAccess.setupRequestHandlers({ onGrant: onGrantSpy });
connect.storageAccess.request();

Expand All @@ -202,10 +203,14 @@ describe('Request Storage Access module', () => {
expect(storageAccessRequestArgs.data.landat).to.be.equals('/connect/ccp-v2');

expect(onGrantSpy.called).to.be.true;
expect(connect.storageAccess.getOnGrantCallbackInvoked()).to.be.true;
connect.storageAccess.request();

/** Should be called only once */
expect(onGrantSpy.calledTwice).not.to.be.true;

connect.storageAccess.resetStorageAccessState();
expect(connect.storageAccess.getOnGrantCallbackInvoked()).to.be.false;
});

it('Should hide container if mode is custom after granting access', () => {
Expand Down

0 comments on commit 50dcc82

Please sign in to comment.