@janssenproject/cedarling_wasm 0.0.307-nodejs → 0.0.308-nodejs
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/README.md +64 -5
- package/cedarling_wasm.d.ts +207 -161
- package/cedarling_wasm.js +976 -1069
- package/cedarling_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,6 +70,25 @@ Before using any function from library you need initialize WASM runtime by calli
|
|
|
70
70
|
*/
|
|
71
71
|
export function init(config: any): Promise<Cedarling>;
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Create a new instance of the Cedarling application from archive bytes.
|
|
75
|
+
*
|
|
76
|
+
* This function allows loading a policy store from a Cedar Archive (.cjar)
|
|
77
|
+
* that was fetched with custom logic (e.g., with authentication headers).
|
|
78
|
+
*
|
|
79
|
+
* # Arguments
|
|
80
|
+
* * `config` - Bootstrap configuration (Map or Object). Policy store config is ignored.
|
|
81
|
+
* * `archive_bytes` - The .cjar archive bytes (Uint8Array)
|
|
82
|
+
*
|
|
83
|
+
* # Example
|
|
84
|
+
* ```javascript
|
|
85
|
+
* const response = await fetch(url, { headers: { Authorization: 'Bearer ...' } });
|
|
86
|
+
* const bytes = new Uint8Array(await response.arrayBuffer());
|
|
87
|
+
* const cedarling = await init_from_archive_bytes(config, bytes);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export function init_from_archive_bytes(config: any, archive_bytes: Uint8Array): Promise<Cedarling>;
|
|
91
|
+
|
|
73
92
|
/**
|
|
74
93
|
* The instance of the Cedarling application.
|
|
75
94
|
*/
|
|
@@ -248,6 +267,50 @@ export class PolicyEvaluationError {
|
|
|
248
267
|
|
|
249
268
|
## Configuration
|
|
250
269
|
|
|
270
|
+
### Policy Store Sources
|
|
271
|
+
|
|
272
|
+
Cedarling supports multiple ways to load policy stores. **In WASM environments, only URL-based loading is available** (no filesystem access).
|
|
273
|
+
|
|
274
|
+
#### WASM-Supported Options
|
|
275
|
+
|
|
276
|
+
```javascript
|
|
277
|
+
// Option 1: Fetch policy store from URL (simple)
|
|
278
|
+
const BOOTSTRAP_CONFIG = {
|
|
279
|
+
CEDARLING_POLICY_STORE_URI: "https://example.com/policy-store.cjar",
|
|
280
|
+
// ... other config
|
|
281
|
+
};
|
|
282
|
+
const cedarling = await init(BOOTSTRAP_CONFIG);
|
|
283
|
+
|
|
284
|
+
// Option 2: Inline JSON string (for embedded policy stores)
|
|
285
|
+
// policyStoreJson is the policy store JSON as a string
|
|
286
|
+
// See: https://docs.jans.io/stable/cedarling/reference/cedarling-policy-store/
|
|
287
|
+
const policyStoreJson = '{"cedar_version":"4.0","policy_stores":{...}}';
|
|
288
|
+
const BOOTSTRAP_CONFIG = {
|
|
289
|
+
CEDARLING_POLICY_STORE_LOCAL: policyStoreJson,
|
|
290
|
+
// ... other config
|
|
291
|
+
};
|
|
292
|
+
const cedarling = await init(BOOTSTRAP_CONFIG);
|
|
293
|
+
|
|
294
|
+
// Option 3: Custom fetch with auth headers (use init_from_archive_bytes)
|
|
295
|
+
const response = await fetch("https://example.com/policy-store.cjar", {
|
|
296
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
297
|
+
});
|
|
298
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
299
|
+
const cedarling = await init_from_archive_bytes(BOOTSTRAP_CONFIG, bytes);
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
> **Note:** Directory-based loading and file-based loading are **NOT supported in WASM** (no filesystem access). Use URL-based loading or `init_from_archive_bytes` for custom fetch scenarios.
|
|
303
|
+
|
|
304
|
+
#### Cedar Archive (.cjar) Format
|
|
305
|
+
|
|
306
|
+
For the new directory-based format in WASM, package the directory structure as a `.cjar` file (ZIP archive):
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
cd policy-store && zip -r ../policy-store.cjar .
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
See [Policy Store Formats](../../../docs/cedarling/reference/cedarling-policy-store.md#policy-store-formats) for details on the directory structure and metadata.json format.
|
|
313
|
+
|
|
251
314
|
### ID Token Trust Mode
|
|
252
315
|
|
|
253
316
|
The `CEDARLING_ID_TOKEN_TRUST_MODE` property controls how ID tokens are validated:
|
|
@@ -271,8 +334,4 @@ const BOOTSTRAP_CONFIG = {
|
|
|
271
334
|
};
|
|
272
335
|
```
|
|
273
336
|
|
|
274
|
-
For complete configuration documentation, see [cedarling-properties.md](../../../docs/cedarling/cedarling-properties.md) or on [our page](https://docs.jans.io/stable/cedarling/cedarling-properties/)
|
|
275
|
-
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
```
|
|
337
|
+
For complete configuration documentation, see [cedarling-properties.md](../../../docs/cedarling/cedarling-properties.md) or on [our page](https://docs.jans.io/stable/cedarling/cedarling-properties/).
|
package/cedarling_wasm.d.ts
CHANGED
|
@@ -1,186 +1,213 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A WASM wrapper for the Rust `cedarling::AuthorizeResult` struct.
|
|
6
|
+
* Represents the result of an authorization request.
|
|
7
|
+
*/
|
|
4
8
|
export class AuthorizeResult {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
9
|
+
private constructor();
|
|
10
|
+
free(): void;
|
|
11
|
+
[Symbol.dispose](): void;
|
|
12
|
+
/**
|
|
13
|
+
* Convert `AuthorizeResult` to json string value
|
|
14
|
+
*/
|
|
15
|
+
json_string(): string;
|
|
16
|
+
principal(principal: string): AuthorizeResultResponse | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Result of authorization
|
|
19
|
+
* true means `ALLOW`
|
|
20
|
+
* false means `Deny`
|
|
21
|
+
*
|
|
22
|
+
* this field is [`bool`] type to be compatible with [authzen Access Evaluation Decision](https://openid.github.io/authzen/#section-6.2.1).
|
|
23
|
+
*/
|
|
24
|
+
decision: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Result of authorization where principal is `Jans::User`
|
|
27
|
+
*/
|
|
28
|
+
get person(): AuthorizeResultResponse | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Result of authorization where principal is `Jans::User`
|
|
31
|
+
*/
|
|
32
|
+
set person(value: AuthorizeResultResponse | null | undefined);
|
|
33
|
+
/**
|
|
34
|
+
* Request ID of the authorization request
|
|
35
|
+
*/
|
|
36
|
+
request_id: string;
|
|
37
|
+
/**
|
|
38
|
+
* Result of authorization where principal is `Jans::Workload`
|
|
39
|
+
*/
|
|
40
|
+
get workload(): AuthorizeResultResponse | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Result of authorization where principal is `Jans::Workload`
|
|
43
|
+
*/
|
|
44
|
+
set workload(value: AuthorizeResultResponse | null | undefined);
|
|
41
45
|
}
|
|
42
46
|
|
|
47
|
+
/**
|
|
48
|
+
* A WASM wrapper for the Rust `cedar_policy::Response` struct.
|
|
49
|
+
* Represents the result of an authorization request.
|
|
50
|
+
*/
|
|
43
51
|
export class AuthorizeResultResponse {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
private constructor();
|
|
53
|
+
free(): void;
|
|
54
|
+
[Symbol.dispose](): void;
|
|
55
|
+
/**
|
|
56
|
+
* Authorization decision
|
|
57
|
+
*/
|
|
58
|
+
readonly decision: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Diagnostics providing more information on how this decision was reached
|
|
61
|
+
*/
|
|
62
|
+
readonly diagnostics: Diagnostics;
|
|
55
63
|
}
|
|
56
64
|
|
|
65
|
+
/**
|
|
66
|
+
* The instance of the Cedarling application.
|
|
67
|
+
*/
|
|
57
68
|
export class Cedarling {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
69
|
+
private constructor();
|
|
70
|
+
free(): void;
|
|
71
|
+
[Symbol.dispose](): void;
|
|
72
|
+
/**
|
|
73
|
+
* Authorize request
|
|
74
|
+
* makes authorization decision based on the [`Request`]
|
|
75
|
+
*/
|
|
76
|
+
authorize(request: any): Promise<AuthorizeResult>;
|
|
77
|
+
/**
|
|
78
|
+
* Authorize multi-issuer request.
|
|
79
|
+
* Makes authorization decision based on multiple JWT tokens from different issuers
|
|
80
|
+
*/
|
|
81
|
+
authorize_multi_issuer(request: any): Promise<MultiIssuerAuthorizeResult>;
|
|
82
|
+
/**
|
|
83
|
+
* Authorize request for unsigned principals.
|
|
84
|
+
* makes authorization decision based on the [`RequestUnsigned`]
|
|
85
|
+
*/
|
|
86
|
+
authorize_unsigned(request: any): Promise<AuthorizeResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Get specific log entry.
|
|
89
|
+
* Returns `Map` with values or `null`.
|
|
90
|
+
*/
|
|
91
|
+
get_log_by_id(id: string): any;
|
|
92
|
+
/**
|
|
93
|
+
* Returns a list of all log ids.
|
|
94
|
+
* Returns `Array` of `String`
|
|
95
|
+
*/
|
|
96
|
+
get_log_ids(): Array<any>;
|
|
97
|
+
/**
|
|
98
|
+
* Get logs by request_id.
|
|
99
|
+
* Return log entries that match the given request_id.
|
|
100
|
+
*/
|
|
101
|
+
get_logs_by_request_id(request_id: string): any[];
|
|
102
|
+
/**
|
|
103
|
+
* Get log by request_id and tag, like composite key `request_id` + `log_kind`.
|
|
104
|
+
* Tag can be `log_kind`, `log_level`.
|
|
105
|
+
* Return log entries that match the given request_id and tag.
|
|
106
|
+
*/
|
|
107
|
+
get_logs_by_request_id_and_tag(request_id: string, tag: string): any[];
|
|
108
|
+
/**
|
|
109
|
+
* Get logs by tag, like `log_kind` or `log level`.
|
|
110
|
+
* Tag can be `log_kind`, `log_level`.
|
|
111
|
+
*/
|
|
112
|
+
get_logs_by_tag(tag: string): any[];
|
|
113
|
+
/**
|
|
114
|
+
* Create a new instance of the Cedarling application.
|
|
115
|
+
* Assume that config is `Object`
|
|
116
|
+
*/
|
|
117
|
+
static new(config: object): Promise<Cedarling>;
|
|
118
|
+
/**
|
|
119
|
+
* Create a new instance of the Cedarling application.
|
|
120
|
+
* Assume that config is `Map`
|
|
121
|
+
*/
|
|
122
|
+
static new_from_map(config: Map<any, any>): Promise<Cedarling>;
|
|
123
|
+
/**
|
|
124
|
+
* Get logs and remove them from the storage.
|
|
125
|
+
* Returns `Array` of `Map`
|
|
126
|
+
*/
|
|
127
|
+
pop_logs(): Array<any>;
|
|
128
|
+
/**
|
|
129
|
+
* Closes the connections to the Lock Server and pushes all available logs.
|
|
130
|
+
*/
|
|
131
|
+
shut_down(): Promise<void>;
|
|
121
132
|
}
|
|
122
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Diagnostics
|
|
136
|
+
* ===========
|
|
137
|
+
*
|
|
138
|
+
* Provides detailed information about how a policy decision was made, including policies that contributed to the decision and any errors encountered during evaluation.
|
|
139
|
+
*/
|
|
123
140
|
export class Diagnostics {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
141
|
+
private constructor();
|
|
142
|
+
free(): void;
|
|
143
|
+
[Symbol.dispose](): void;
|
|
144
|
+
/**
|
|
145
|
+
* Errors that occurred during authorization. The errors should be
|
|
146
|
+
* treated as unordered, since policies may be evaluated in any order.
|
|
147
|
+
*/
|
|
148
|
+
readonly errors: PolicyEvaluationError[];
|
|
149
|
+
/**
|
|
150
|
+
* `PolicyId`s of the policies that contributed to the decision.
|
|
151
|
+
* If no policies applied to the request, this set will be empty.
|
|
152
|
+
*
|
|
153
|
+
* The ids should be treated as unordered,
|
|
154
|
+
*/
|
|
155
|
+
readonly reason: string[];
|
|
139
156
|
}
|
|
140
157
|
|
|
141
158
|
export class JsJsonLogic {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
159
|
+
free(): void;
|
|
160
|
+
[Symbol.dispose](): void;
|
|
161
|
+
apply(logic: any, data: any): any;
|
|
162
|
+
constructor();
|
|
146
163
|
}
|
|
147
164
|
|
|
165
|
+
/**
|
|
166
|
+
* A WASM wrapper for the Rust `cedarling::MultiIssuerAuthorizeResult` struct.
|
|
167
|
+
* Represents the result of a multi-issuer authorization request.
|
|
168
|
+
*/
|
|
148
169
|
export class MultiIssuerAuthorizeResult {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
private constructor();
|
|
171
|
+
free(): void;
|
|
172
|
+
[Symbol.dispose](): void;
|
|
173
|
+
/**
|
|
174
|
+
* Convert `MultiIssuerAuthorizeResult` to json string value
|
|
175
|
+
*/
|
|
176
|
+
json_string(): string;
|
|
177
|
+
/**
|
|
178
|
+
* Result of authorization
|
|
179
|
+
* true means `ALLOW`
|
|
180
|
+
* false means `Deny`
|
|
181
|
+
*/
|
|
182
|
+
decision: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Request ID of the authorization request
|
|
185
|
+
*/
|
|
186
|
+
request_id: string;
|
|
187
|
+
/**
|
|
188
|
+
* Result of Cedar policy authorization
|
|
189
|
+
*/
|
|
190
|
+
response: AuthorizeResultResponse;
|
|
170
191
|
}
|
|
171
192
|
|
|
193
|
+
/**
|
|
194
|
+
* PolicyEvaluationError
|
|
195
|
+
* =====================
|
|
196
|
+
*
|
|
197
|
+
* Represents an error that occurred when evaluating a Cedar policy.
|
|
198
|
+
*/
|
|
172
199
|
export class PolicyEvaluationError {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
200
|
+
private constructor();
|
|
201
|
+
free(): void;
|
|
202
|
+
[Symbol.dispose](): void;
|
|
203
|
+
/**
|
|
204
|
+
* Underlying evaluation error string representation
|
|
205
|
+
*/
|
|
206
|
+
readonly error: string;
|
|
207
|
+
/**
|
|
208
|
+
* Id of the policy with an error
|
|
209
|
+
*/
|
|
210
|
+
readonly id: string;
|
|
184
211
|
}
|
|
185
212
|
|
|
186
213
|
/**
|
|
@@ -188,3 +215,22 @@ export class PolicyEvaluationError {
|
|
|
188
215
|
* This function can take as config parameter the eather `Map` other `Object`
|
|
189
216
|
*/
|
|
190
217
|
export function init(config: any): Promise<Cedarling>;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Create a new instance of the Cedarling application from archive bytes.
|
|
221
|
+
*
|
|
222
|
+
* This function allows loading a policy store from a Cedar Archive (.cjar)
|
|
223
|
+
* that was fetched with custom logic (e.g., with authentication headers).
|
|
224
|
+
*
|
|
225
|
+
* # Arguments
|
|
226
|
+
* * `config` - Bootstrap configuration (Map or Object). Policy store config is ignored.
|
|
227
|
+
* * `archive_bytes` - The .cjar archive bytes (Uint8Array)
|
|
228
|
+
*
|
|
229
|
+
* # Example
|
|
230
|
+
* ```javascript
|
|
231
|
+
* const response = await fetch(url, { headers: { Authorization: 'Bearer ...' } });
|
|
232
|
+
* const bytes = new Uint8Array(await response.arrayBuffer());
|
|
233
|
+
* const cedarling = await init_from_archive_bytes(config, bytes);
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
export function init_from_archive_bytes(config: any, archive_bytes: Uint8Array): Promise<Cedarling>;
|