Skip to content

Commit

Permalink
tweak ux when config is new
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Sherman <[email protected]>
  • Loading branch information
usingtechnology committed Aug 22, 2024
1 parent a4a34f0 commit dce7251
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ defineExpose({
</v-expand-transition>
<v-row class="pl-6 m-0">
<v-col cols="12" class="pl-0 pr-0 pb-0">
<span>
<span v-if="form.eventStreamConfig.updatedBy">
<span :lang="locale" class="font-weight-bold"
>{{ $t('trans.formSettings.eventStreamUpdatedBy') }}:
</span>
Expand Down
2 changes: 2 additions & 0 deletions app/src/forms/form/encryptionKey/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const service = {
// special case for forms. they have only one event stream configuration
// that requires an encryption key if it has private streams.
// NOTE: event stream config will remove this key if it is unneeded!

const externalTrx = transaction != undefined;
let trx;
let id;
Expand All @@ -51,6 +52,7 @@ const service = {
}
} else {
// add a new configuration.
if (data && !data.algorithm && !data.key) return; // no encryption key to insert
id = uuidv4();
data.id = id;
data.formId = formId;
Expand Down
1 change: 1 addition & 0 deletions app/src/forms/form/eventStreamConfig/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const service = {
// let's deal with encryption key
const encKey = await encryptionKeyService.upsertForEventStreamConfig(formId, data.encryptionKey, currentUser, transaction);
data.encryptionKeyId = encKey && data.enablePrivateStream ? encKey.id : null;
data.encryptionKey = null; // only want the id for config upsert

if (existing) {
// do we need to update?
Expand Down
9 changes: 7 additions & 2 deletions event-stream-service/package-lock.json

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

1 change: 1 addition & 0 deletions event-stream-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"license": "Apache-2.0",
"scripts": {},
"dependencies": {
"cryptr": "^6.3.0",
"nats": "^2.28.0"
}
}
14 changes: 13 additions & 1 deletion event-stream-service/pullConsumer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { AckPolicy, connect } = require("nats");
const Cryptr = require("cryptr");

// connection info
const servers = ["localhost:4222", "localhost:4223", "localhost:4224"];
Expand All @@ -13,6 +14,7 @@ const STREAM_NAME = "CHEFS";
const FILTER_SUBJECTS = ["PUBLIC.forms.>", "PRIVATE.forms.>"];
const MAX_MESSAGES = 2;
const DURABLE_NAME = "pullConsumer";
const ENCRYPTION_KEY = "";

const printMsg = (m) => {
// illustrate grabbing the sequence and timestamp from the nats message...
Expand All @@ -22,7 +24,17 @@ const printMsg = (m) => {
`msg seq: ${m.seq}, subject: ${m.subject}, timestamp: ${ts}, streamSequence: ${m.info.streamSequence}, deliverySequence: ${m.info.deliverySequence}`
);
// illustrate (one way of) grabbing message content as json
console.log(JSON.stringify(m.json(), null, 2));
const data = m.json();
console.log(JSON.stringify(data, null, 2));
try {
if (data && data["payload"] && data["payload"]["data"]) {
const cryptr = new Cryptr(ENCRYPTION_KEY);
const d = cryptr.decrypt(data["payload"]["data"]);
console.log(JSON.stringify(d, null, 2));
}
} catch (err) {
console.error("Error decrypting payload.data");
}
} catch (e) {
console.error(`Error printing message: ${e.message}`);
}
Expand Down

0 comments on commit dce7251

Please sign in to comment.