Skip to content

Commit

Permalink
update TS type
Browse files Browse the repository at this point in the history
  • Loading branch information
ipatka committed Oct 29, 2023
1 parent d1584eb commit 2728f56
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ export enum PolicyDecision {
}

export interface IPolicyStatementResult {
name?: string
message?: string
action?: TriggeredPolicyAction
policy_id: string
invoked: boolean
annotations: {[key: string]: string}
}

export interface IPolicyEnginePolicyResponse {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shield3/banyan",
"version": "0.3.0",
"version": "0.3.1",
"description": "Banyan policy engine",
"main": "dist/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion schemas/IPolicyEnginePolicyResponse.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"type":"object","properties":{"reasons":{"type":"array","items":{"$ref":"#/definitions/IPolicyStatementResult"}},"decision":{"$ref":"#/definitions/PolicyDecision"},"errors":{"type":"array","items":{"type":"string"}}},"required":["decision","errors","reasons"],"definitions":{"IPolicyStatementResult":{"type":"object","properties":{"name":{"type":"string"},"message":{"type":"string"},"action":{"$ref":"#/definitions/TriggeredPolicyAction"},"invoked":{"type":"boolean"}},"required":["invoked"]},"TriggeredPolicyAction":{"enum":["MFA","Notify"],"type":"string"},"PolicyDecision":{"enum":["Allow","Deny"],"type":"string"}},"$schema":"http://json-schema.org/draft-07/schema#"}
{"type":"object","properties":{"reasons":{"type":"array","items":{"$ref":"#/definitions/IPolicyStatementResult"}},"decision":{"$ref":"#/definitions/PolicyDecision"},"errors":{"type":"array","items":{"type":"string"}}},"required":["decision","errors","reasons"],"definitions":{"IPolicyStatementResult":{"type":"object","properties":{"policy_id":{"type":"string"},"invoked":{"type":"boolean"},"annotations":{"type":"object","additionalProperties":{"type":"string"}}},"required":["annotations","invoked","policy_id"]},"PolicyDecision":{"enum":["Allow","Deny"],"type":"string"}},"$schema":"http://json-schema.org/draft-07/schema#"}
4 changes: 2 additions & 2 deletions test/banyan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import DenyRequest from './examples/erc20_limit_deny.json'
describe('Tests on Banyan', () => {
it('Allows something', () => {
const result = invokePolicyEngine(AllowRequest)
console.log({ result })
console.log(JSON.stringify(result, null, 2))
expect(result.decision).toBe(PolicyDecision.ALLOW)
})

it('Denies something', () => {
const result = invokePolicyEngine(DenyRequest)
console.log({ result })
console.log(JSON.stringify(result, null, 2))
expect(result.decision).toBe(PolicyDecision.DENY)
})

Expand Down

0 comments on commit 2728f56

Please sign in to comment.