@permguard/permguard 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +145 -0
- package/dist/index.d.mts +190 -0
- package/dist/index.d.ts +190 -0
- package/dist/index.js +4614 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4567 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +35 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
interface AZEndpoint {
|
|
2
|
+
endpoint: string;
|
|
3
|
+
port: number;
|
|
4
|
+
}
|
|
5
|
+
interface AZConfig {
|
|
6
|
+
pdpEndpoint?: AZEndpoint;
|
|
7
|
+
}
|
|
8
|
+
type AZOption = (config: AZConfig) => void;
|
|
9
|
+
declare function withEndpoint(endpoint: string, port: number): AZOption;
|
|
10
|
+
|
|
11
|
+
interface PolicyStore {
|
|
12
|
+
kind?: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
}
|
|
15
|
+
interface Entities {
|
|
16
|
+
schema?: string;
|
|
17
|
+
items?: Record<string, any>[];
|
|
18
|
+
}
|
|
19
|
+
interface Evaluation {
|
|
20
|
+
request_id?: string;
|
|
21
|
+
subject?: Subject;
|
|
22
|
+
resource?: Resource;
|
|
23
|
+
action?: Action;
|
|
24
|
+
context?: Record<string, any>;
|
|
25
|
+
}
|
|
26
|
+
interface AZModel {
|
|
27
|
+
zone_id: number;
|
|
28
|
+
principal?: Principal;
|
|
29
|
+
policy_store?: PolicyStore;
|
|
30
|
+
entities: Entities;
|
|
31
|
+
}
|
|
32
|
+
interface AZRequest {
|
|
33
|
+
authorization_model: AZModel;
|
|
34
|
+
request_id?: string;
|
|
35
|
+
subject?: Subject;
|
|
36
|
+
resource?: Resource;
|
|
37
|
+
action?: Action;
|
|
38
|
+
context?: Record<string, any>;
|
|
39
|
+
evaluations?: Evaluation[];
|
|
40
|
+
}
|
|
41
|
+
interface Principal {
|
|
42
|
+
type?: string;
|
|
43
|
+
id?: string;
|
|
44
|
+
source?: string;
|
|
45
|
+
}
|
|
46
|
+
interface Subject {
|
|
47
|
+
type?: string;
|
|
48
|
+
id?: string;
|
|
49
|
+
source?: string;
|
|
50
|
+
properties?: Record<string, any>;
|
|
51
|
+
}
|
|
52
|
+
interface Resource {
|
|
53
|
+
type?: string;
|
|
54
|
+
id?: string;
|
|
55
|
+
properties?: Record<string, any>;
|
|
56
|
+
}
|
|
57
|
+
interface Action {
|
|
58
|
+
name?: string;
|
|
59
|
+
properties?: Record<string, any>;
|
|
60
|
+
}
|
|
61
|
+
interface ReasonResponse {
|
|
62
|
+
Code?: string;
|
|
63
|
+
Message?: string;
|
|
64
|
+
}
|
|
65
|
+
interface ContextResponse {
|
|
66
|
+
ID?: string;
|
|
67
|
+
ReasonAdmin?: ReasonResponse | null;
|
|
68
|
+
ReasonUser?: ReasonResponse | null;
|
|
69
|
+
}
|
|
70
|
+
interface EvaluationResponse {
|
|
71
|
+
RequestID?: string;
|
|
72
|
+
Decision?: boolean;
|
|
73
|
+
Context?: ContextResponse | null;
|
|
74
|
+
}
|
|
75
|
+
interface AZResponse {
|
|
76
|
+
RequestID?: string;
|
|
77
|
+
Decision: boolean;
|
|
78
|
+
Context?: ContextResponse | null;
|
|
79
|
+
Evaluations?: EvaluationResponse[];
|
|
80
|
+
}
|
|
81
|
+
declare enum ActorType {
|
|
82
|
+
UserType = "USER",
|
|
83
|
+
RoleActorType = "ROLE-ACTOR",
|
|
84
|
+
TwinActorType = "TWIN-ACTOR"
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare class AZClient {
|
|
88
|
+
private azConfig;
|
|
89
|
+
constructor(...opts: AZOption[]);
|
|
90
|
+
check(req: AZRequest): Promise<{
|
|
91
|
+
decision: boolean;
|
|
92
|
+
response: AZResponse | null;
|
|
93
|
+
error: Error | null;
|
|
94
|
+
}>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
declare class ActionBuilder {
|
|
98
|
+
private action;
|
|
99
|
+
constructor(name: string);
|
|
100
|
+
withProperty(key: string, value: any): this;
|
|
101
|
+
build(): Action;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare class ContextBuilder {
|
|
105
|
+
private context;
|
|
106
|
+
constructor();
|
|
107
|
+
withProperty(key: string, value: any): ContextBuilder;
|
|
108
|
+
build(): Record<string, any>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
declare class EvaluationBuilder {
|
|
112
|
+
private azEvaluation;
|
|
113
|
+
constructor(subject: Subject, resource: Resource, action: Action);
|
|
114
|
+
withRequestID(requestID: string): EvaluationBuilder;
|
|
115
|
+
withContext(context: Record<string, any>): EvaluationBuilder;
|
|
116
|
+
build(): Evaluation;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare class PrincipalBuilder {
|
|
120
|
+
private principal;
|
|
121
|
+
constructor(id: string);
|
|
122
|
+
withKind(kind: string): PrincipalBuilder;
|
|
123
|
+
withSource(source: string): PrincipalBuilder;
|
|
124
|
+
build(): Principal;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare class AZAtomicRequestBuilder {
|
|
128
|
+
private requestID?;
|
|
129
|
+
private principal?;
|
|
130
|
+
private azSubjectBuilder;
|
|
131
|
+
private azResourceBuilder;
|
|
132
|
+
private azActionBuilder;
|
|
133
|
+
private azContextBuilder;
|
|
134
|
+
private azRequestBuilder;
|
|
135
|
+
constructor(zoneID: number, ledgerID: string, subjectID: string, resourceKind: string, actionName: string);
|
|
136
|
+
withEntitiesMap(schema: string, entities: Record<string, any>): AZAtomicRequestBuilder;
|
|
137
|
+
withEntitiesItems(schema: string, entities?: Record<string, any>[]): AZAtomicRequestBuilder;
|
|
138
|
+
withRequestID(requestID: string): AZAtomicRequestBuilder;
|
|
139
|
+
withPrincipal(principal: Principal): AZAtomicRequestBuilder;
|
|
140
|
+
withSubjectKind(kind: string): AZAtomicRequestBuilder;
|
|
141
|
+
withSubjectSource(source: string): AZAtomicRequestBuilder;
|
|
142
|
+
withSubjectProperty(key: string, value: any): AZAtomicRequestBuilder;
|
|
143
|
+
withResourceID(id: string): AZAtomicRequestBuilder;
|
|
144
|
+
withResourceProperty(key: string, value: any): AZAtomicRequestBuilder;
|
|
145
|
+
withActionProperty(key: string, value: any): AZAtomicRequestBuilder;
|
|
146
|
+
withContextProperty(key: string, value: any): AZAtomicRequestBuilder;
|
|
147
|
+
withSubjectUserType(): AZAtomicRequestBuilder;
|
|
148
|
+
withSubjectRoleActorType(): AZAtomicRequestBuilder;
|
|
149
|
+
withSubjectTwinActorType(): AZAtomicRequestBuilder;
|
|
150
|
+
withSubjectType(kind: string): AZAtomicRequestBuilder;
|
|
151
|
+
build(): AZRequest;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
declare class AZRequestBuilder {
|
|
155
|
+
private azRequest;
|
|
156
|
+
constructor(zoneID: number, ledgerID: string);
|
|
157
|
+
withPrincipal(principal?: Principal): AZRequestBuilder;
|
|
158
|
+
withRequestID(requestID?: string): AZRequestBuilder;
|
|
159
|
+
withSubject(subject: Subject): AZRequestBuilder;
|
|
160
|
+
withResource(resource: Resource): AZRequestBuilder;
|
|
161
|
+
withAction(action: Action): AZRequestBuilder;
|
|
162
|
+
withContext(context: Record<string, any>): AZRequestBuilder;
|
|
163
|
+
withEntitiesMap(schema: string, entities: Record<string, any>): AZRequestBuilder;
|
|
164
|
+
withEntitiesItems(schema: string, entities?: Record<string, any>[]): AZRequestBuilder;
|
|
165
|
+
withEvaluation(evaluation: Evaluation): AZRequestBuilder;
|
|
166
|
+
build(): AZRequest;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
declare class ResourceBuilder {
|
|
170
|
+
private resource;
|
|
171
|
+
constructor(kind: string);
|
|
172
|
+
withID(id: string): ResourceBuilder;
|
|
173
|
+
withProperty(key: string, value: any): ResourceBuilder;
|
|
174
|
+
build(): Resource;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
declare class SubjectBuilder {
|
|
178
|
+
private subject;
|
|
179
|
+
constructor(id: string);
|
|
180
|
+
withKind(kind: string): SubjectBuilder;
|
|
181
|
+
withSource(source: string): SubjectBuilder;
|
|
182
|
+
withProperty(key: string, value: any): SubjectBuilder;
|
|
183
|
+
withUserType(): SubjectBuilder;
|
|
184
|
+
withRoleActorType(): SubjectBuilder;
|
|
185
|
+
withTwinActorType(): SubjectBuilder;
|
|
186
|
+
withType(subType: string): SubjectBuilder;
|
|
187
|
+
build(): Subject;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export { AZAtomicRequestBuilder, AZClient, type AZConfig, type AZEndpoint, type AZModel, type AZOption, type AZRequest, AZRequestBuilder, type AZResponse, type Action, ActionBuilder, ActorType, ContextBuilder, type ContextResponse, type Entities, type Evaluation, EvaluationBuilder, type EvaluationResponse, type PolicyStore, type Principal, PrincipalBuilder, type ReasonResponse, type Resource, ResourceBuilder, type Subject, SubjectBuilder, withEndpoint };
|