Skip to content

Commit

Permalink
⬆️ Update to virtru-sdk 5.1.1 (#253)
Browse files Browse the repository at this point in the history
* remove unique storage id parameter from virtru-private/oidc
  • Loading branch information
dmihalcik-virtru authored Aug 17, 2023
1 parent c4caabe commit 2556360
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 42 deletions.
20 changes: 10 additions & 10 deletions .buildkite/pr.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
env:
USE_NODE_18: true
NODE_VERSION: "$(cat .nvmrc)"
NODE_VERSION: '$(cat .nvmrc)'

steps:
- label: ":npm: Install Dependencies (CI)"
command: "buildkite-scripts/mars/wrap/npm-ci.sh"
key: "dependency"
- label: ':npm: Install Dependencies (CI)'
command: 'buildkite-scripts/mars/wrap/npm-ci.sh'
key: 'dependency'

- label: ":mag: Run unit tests"
command: "buildkite-scripts/scripts/npm-test.sh"
key: "unit-tests"
depends_on: "dependency"
- label: ':mag: Run unit tests'
command: 'buildkite-scripts/scripts/npm-test.sh'
key: 'unit-tests'
depends_on: 'dependency'

- label: ":mag: Run e2e tests"
depends_on: "dependency"
- label: ':mag: Run e2e tests'
depends_on: 'dependency'
plugins:
- docker-compose#v4.14.0:
run: front
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: "3.9"
version: '3.9'

services:
front:
extra_hosts:
- "local.virtru.com:127.0.0.1"
- 'local.virtru.com:127.0.0.1'
build:
context: .
dockerfile: ./Dockerfile
ports:
- "443:3000"
- '443:3000'
container_name: protect-and-track
8 changes: 4 additions & 4 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
Expand Up @@ -15,7 +15,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"redux-zero": "^5.1.7",
"virtru-sdk": "^5.1.1-alpha.1.1"
"virtru-sdk": "^5.1.1"
},
"license": "MIT",
"repository": {
Expand Down
1 change: 0 additions & 1 deletion src/scenes/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import localForage from 'localforage';
import { restoreUserId } from '../../utils/oidc';
import { oidc as oidcConfig, clientConfig } from '../../utils/config';


/**
* An SDK Share App.
* This will have several children:
Expand Down
8 changes: 5 additions & 3 deletions src/scenes/Document/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ function Document({
if (encryptState !== ENCRYPT_STATES.PROTECTED) {
return;
}
let timeout = 2000;
try {
/**** Virtru Block ****
*
Expand All @@ -165,13 +166,14 @@ function Document({
setAuditEvents({ events: auditData, error: false });
} catch (err) {
console.error(err);
timeout = 60_000;
setAuditEvents({ error: err });
}
if (currentTimerId !== auditTimerId) {
// The policy changed while waiting for the audit log, so don't update it.
return;
}
auditTimerId = setTimeout(updateAuditEvents, 2000);
auditTimerId = setTimeout(updateAuditEvents, timeout);
}
if (auditTimerId) {
// Clear the existing timer
Expand Down Expand Up @@ -394,8 +396,8 @@ const actions = {
if (fileName && fileName.endsWith('.tdf')) {
try {
const decryptParams = new Virtru.DecryptParamsBuilder()
.withArrayBufferSource(fileBuffer)
.build();
.withArrayBufferSource(fileBuffer)
.build();

const decryptStream = await virtruClient.decrypt(decryptParams);
const decrypted = await decryptStream.toBuffer();
Expand Down
2 changes: 1 addition & 1 deletion src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ try {
}

const oidcClient = new OidcClient(oidcConfig);
const userId = restoreUserId(oidcConfig);
const userId = restoreUserId();
let authState = userId ? 'loggedin' : false;
let virtruClient = false;

Expand Down
22 changes: 5 additions & 17 deletions src/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function fromOldEnvironment(e) {

const environment = fromOldEnvironment(process.env.REACT_APP_VIRTRU_ENV);

const oidcConfigShared = {
const oidcConfig = {
...getDefaultOidcClientConfig({
environment,
redirectUri: window.location.href.split(/[?#]/)[0],
Expand All @@ -33,10 +33,7 @@ const develop01 = {
acmEndpoint: 'https://api-develop01.develop.virtru.com/acm',
readerUrl: 'https://secure-develop01.develop.virtru.com/start?htmlProtocol=1',
},
oidc: {
...oidcConfigShared,
storageKeyUniqueId: 'pt-dev01',
},
oidc: oidcConfig,
proxy: {
url: 'https://sdk-develop01.develop.virtru.com/js/latest/proxy.html',
origins: [
Expand All @@ -59,10 +56,7 @@ const develop02 = {
acmEndpoint: 'https://api-develop02.develop.virtru.com/acm',
readerUrl: 'https://secure-develop02.develop.virtru.com/start?htmlProtocol=1',
},
oidc: {
...develop01.oidc,
storageKeyUniqueId: 'pt-dev02',
},
oidc: oidcConfig,
proxy: {
url: 'https://sdk-develop02.develop.virtru.com/js/latest/proxy.html',
origins: [
Expand All @@ -85,10 +79,7 @@ const staging = {
acmEndpoint: 'https://api.staging.virtru.com/acm',
readerUrl: 'https://secure.staging.virtru.com/start?htmlProtocol=1',
},
oidc: {
...oidcConfigShared,
storageKeyUniqueId: 'pt-staging',
},
oidc: oidcConfig,
proxy: {
url: 'https://sdk.staging.virtru.com/js/latest/proxy.html',
origins: ['https://api.staging.virtru.com', 'https://audit.staging.virtru.com'],
Expand All @@ -108,10 +99,7 @@ const production = {
acmEndpoint: 'https://api.virtru.com/acm',
readerUrl: 'https://secure.virtru.com/start?htmlProtocol=1',
},
oidc: {
...oidcConfigShared,
storageKeyUniqueId: 'pt',
},
oidc: oidcConfig,
proxy: undefined,
};

Expand Down
4 changes: 2 additions & 2 deletions src/utils/oidc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function restoreUserId(oidcConfig) {
const key = `virtru-oidc:user:${oidcConfig.storageKeyUniqueId}`;
export function restoreUserId() {
const key = 'virtru-oidc:user';
const oidcUser = localStorage.getItem(key);
console.log({ [key]: oidcUser });
if (!oidcUser) {
Expand Down

0 comments on commit 2556360

Please sign in to comment.