Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

DSAT-87 - Fix policy building #77

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased](https://github.com/virtru/protect-and-track/compare/master...HEAD)

- NO-REF: _patch_
- Fix policy building by using `policy.builder()`
- NO-REF: _patch_
- Use Audit from SDK

Expand Down
17 changes: 14 additions & 3 deletions src/utils/VirtruWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@ function _pushAction(action) {
*
* @param {?object} opts
*/
function policyBuilder(opts) {
const builder = new Virtru.PolicyBuilder(opts);
let actions = [`const policy = new Virtru.PolicyBuilder(${opts ? 'policy' : ''})`];
function policyBuilder(existingPolicy) {
if (existingPolicy) {
_pushAction({
title: 'Get Policy Builder',
code: 'const builder = existingPolicy.builder();',
});
} else {
_pushAction({
title: 'Create Policy Builder',
code: 'const builder = new Virtru.PolicyBuilder();',
});
}
const builder = existingPolicy ? existingPolicy.builder() : new Virtru.PolicyBuilder();
let actions = ['const policy = builder'];
// This proxy records all calls, then logs them to the UI on `build` invocations.
return new Proxy(builder, {
get(target, propKey, receiver) {
Expand Down