Skip to content

Commit

Permalink
feat(actionbasedpolicy): allow to generate proxy from Action Based Po…
Browse files Browse the repository at this point in the history
…licy

updating types and Statement class errors
  • Loading branch information
roggervalf committed Oct 26, 2020
1 parent dd97b69 commit 72f4092
Show file tree
Hide file tree
Showing 14 changed files with 330 additions and 142 deletions.
37 changes: 28 additions & 9 deletions dist/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ declare type Patterns = string[] | string;
interface PrincipalMap {
[key: string]: Patterns;
}
interface PrincipalBlock {
principal: PrincipalMap | Patterns;
interface OptionalPrincipalBlock {
principal?: PrincipalMap | Patterns;
}
interface NotPrincipalBlock {
notPrincipal: PrincipalMap | Patterns;
interface OptionalNotPrincipalBlock {
notPrincipal?: PrincipalMap | Patterns;
}
interface ActionBlock {
action: Patterns;
Expand All @@ -64,6 +64,12 @@ interface ResourceBlock {
interface NotResourceBlock {
notResource: Patterns;
}
interface OptionalResourceBlock {
resource?: Patterns;
}
interface OptionalNotResourceBlock {
notResource?: Patterns;
}
declare type ConditionKey = string | number | boolean;
interface Context {
[key: string]: ConditionKey | Context | string[] | number[];
Expand Down Expand Up @@ -93,9 +99,10 @@ interface MatchActionBasedInterface extends MatchConditionInterface {
interface MatchIdentityBasedInterface extends MatchActionBasedInterface {
resource: string;
}
interface MatchResourceBasedInterface extends MatchIdentityBasedInterface {
principal: string;
interface MatchResourceBasedInterface extends MatchActionBasedInterface {
principal?: string;
principalType?: string;
resource?: string;
}
interface EvaluateActionBasedInterface {
action: string;
Expand All @@ -104,13 +111,24 @@ interface EvaluateActionBasedInterface {
interface EvaluateIdentityBasedInterface extends EvaluateActionBasedInterface {
resource: string;
}
interface EvaluateResourceBasedInterface extends EvaluateIdentityBasedInterface {
principal: string;
interface EvaluateResourceBasedInterface extends EvaluateActionBasedInterface {
principal?: string;
principalType?: string;
resource?: string;
}
declare type ActionBasedType = StatementInterface & (ActionBlock | NotActionBlock);
declare type IdentityBasedType = StatementInterface & (ActionBlock | NotActionBlock) & (ResourceBlock | NotResourceBlock);
declare type ResourceBasedType = StatementInterface & (PrincipalBlock | NotPrincipalBlock) & (ActionBlock | NotActionBlock) & (ResourceBlock | NotResourceBlock);
declare type ResourceBasedType = StatementInterface & (OptionalPrincipalBlock | OptionalNotPrincipalBlock) & (ActionBlock | NotActionBlock) & (OptionalResourceBlock | OptionalNotResourceBlock);
interface ProxyOptions {
get?: {
allow?: boolean;
propertyMap?: Record<string, string>;
};
set?: {
allow?: boolean;
propertyMap?: Record<string, string>;
};
}

declare function applyContext(str: string, context?: Context): string;
declare class Statement {
Expand Down Expand Up @@ -200,6 +218,7 @@ declare class ActionBasedPolicy extends Policy {
evaluate({ action, context }: EvaluateActionBasedInterface): boolean;
can({ action, context }: EvaluateActionBasedInterface): boolean;
cannot({ action, context }: EvaluateActionBasedInterface): boolean;
generateProxy<T, U extends keyof T>(obj: unknown, options?: ProxyOptions): T | undefined;
}

interface IdentityBasedPolicyInterface {
Expand Down
55 changes: 36 additions & 19 deletions dist/main.es.js

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

2 changes: 1 addition & 1 deletion dist/main.es.js.map

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

55 changes: 36 additions & 19 deletions dist/main.js

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

2 changes: 1 addition & 1 deletion dist/main.js.map

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

0 comments on commit 72f4092

Please sign in to comment.