@mpfrontend/access-core 0.0.0-stage → 0.1.0
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 +202 -0
- package/README.md +31 -2
- package/dist/authority-fence.d.ts +10 -0
- package/dist/authority-fence.js +22 -0
- package/dist/authority-fence.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +73 -0
- package/dist/manifest.js +120 -0
- package/dist/manifest.js.map +1 -0
- package/dist/page-access.d.ts +16 -0
- package/dist/page-access.js +25 -0
- package/dist/page-access.js.map +1 -0
- package/dist/snapshot.d.ts +48 -0
- package/dist/snapshot.js +95 -0
- package/dist/snapshot.js.map +1 -0
- package/package.json +25 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mpfrontend/access-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Local development package. Runtime: universal. Public API is exported from src/index.ts and compiled
|
|
4
|
+
into dist. Nx owns build, typecheck, lint and test targets. Consumer applications install packed artifacts.
|
|
5
|
+
See ../../docs/IMPLEMENTATION-STATUS.md for observed evidence and remaining work.
|
|
6
|
+
|
|
7
|
+
`AuthorityFence` aborts in-flight browser work and rejects stale publication after a consumer-owned
|
|
8
|
+
authority identity changes. Capture before starting a request and assert again immediately before
|
|
9
|
+
publishing its result. Identical context refreshes preserve work; switching away and back does not
|
|
10
|
+
resurrect an old response. Consumers choose the identity (subject, tenant, role revision/session).
|
|
11
|
+
This is a UI isolation guard, not permission enforcement; it cannot recall an upstream mutation.
|
|
12
|
+
|
|
13
|
+
## Snapshot validation and field state
|
|
14
|
+
|
|
15
|
+
`parsePageAccess(value, {now, contextRef, keys})` validates a snapshot at run time before anything reads it:
|
|
16
|
+
exactly the five members (so no identity or token data rides along), a bounded context reference and revision,
|
|
17
|
+
a finite expiry, boolean grants and field access, the context the caller expects and, when given, the known keys.
|
|
18
|
+
A malformed, expired or mismatched snapshot is refused whole (`MALFORMED`, `EXPIRED`, `CONTEXT_MISMATCH`,
|
|
19
|
+
`UNKNOWN_KEY`) and grants nothing. `pickPageAccess` keeps only the listed keys. `fieldState` returns `hidden`,
|
|
20
|
+
`disabled` or `enabled`; a control that is already disabled or busy stays disabled. `accessReader(snapshot)`
|
|
21
|
+
reads one snapshot for components and is closed without one. `can`, `fieldAccess`, `projectFields` and
|
|
22
|
+
`dirtyPatch` are unchanged.
|
|
23
|
+
|
|
24
|
+
## Page manifest
|
|
25
|
+
|
|
26
|
+
`definePageManifest` lists every route of an app once: the capability its page needs, the capability of its menu
|
|
27
|
+
entry, its elements and the field keys its components read, and the navigation groups. `buildNavigation` shows a
|
|
28
|
+
page when the snapshot grants its menu and its page capability, and a group when it grants the group's menu and
|
|
29
|
+
at least one child shows: a parent grants no child, and a group with no visible child is pruned.
|
|
30
|
+
`checkPageManifest` and `assertPageManifest` report a duplicate id, an id the app uses that the manifest does not
|
|
31
|
+
register and a route with no entry. `pageKeys`, `navigationKeys` and `manifestKeys` give the keys a provider
|
|
32
|
+
needs and the keys a snapshot is checked against. The React bindings are `@mpfrontend/access-react`.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A UI publication fence, never an authorization decision. Servers still enforce every request. */
|
|
2
|
+
export declare class AuthorityFence {
|
|
3
|
+
private identity;
|
|
4
|
+
private controller;
|
|
5
|
+
update(identity: string | null): void;
|
|
6
|
+
capture(expectedIdentity: string): Readonly<{
|
|
7
|
+
signal: AbortSignal;
|
|
8
|
+
assertCurrent: () => void;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** A UI publication fence, never an authorization decision. Servers still enforce every request. */
|
|
2
|
+
export class AuthorityFence {
|
|
3
|
+
identity = null;
|
|
4
|
+
controller = new AbortController();
|
|
5
|
+
update(identity) {
|
|
6
|
+
if (identity === this.identity)
|
|
7
|
+
return;
|
|
8
|
+
this.controller.abort(new DOMException('AUTHORITY_CHANGED', 'AbortError'));
|
|
9
|
+
this.controller = new AbortController();
|
|
10
|
+
this.identity = identity;
|
|
11
|
+
}
|
|
12
|
+
capture(expectedIdentity) {
|
|
13
|
+
const controller = this.controller;
|
|
14
|
+
const assertCurrent = () => {
|
|
15
|
+
if (!this.identity || this.identity !== expectedIdentity || controller !== this.controller || controller.signal.aborted)
|
|
16
|
+
throw new DOMException('AUTHORITY_CHANGED', 'AbortError');
|
|
17
|
+
};
|
|
18
|
+
assertCurrent();
|
|
19
|
+
return { signal: controller.signal, assertCurrent };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=authority-fence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-fence.js","sourceRoot":"","sources":["../src/authority-fence.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,OAAO,cAAc;IACjB,QAAQ,GAAa,IAAI,CAAC;IAC1B,UAAU,GAAC,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,CAAC,QAAoB;QACzB,IAAG,QAAQ,KAAG,IAAI,CAAC,QAAQ;YAAC,OAAO;QACnC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,mBAAmB,EAAC,YAAY,CAAC,CAAC,CAAC;QAC1E,IAAI,CAAC,UAAU,GAAC,IAAI,eAAe,EAAE,CAAC;QAAA,IAAI,CAAC,QAAQ,GAAC,QAAQ,CAAC;IAC/D,CAAC;IACD,OAAO,CAAC,gBAAuB;QAC7B,MAAM,UAAU,GAAC,IAAI,CAAC,UAAU,CAAC;QACjC,MAAM,aAAa,GAAC,GAAE,EAAE;YACtB,IAAG,CAAC,IAAI,CAAC,QAAQ,IAAE,IAAI,CAAC,QAAQ,KAAG,gBAAgB,IAAE,UAAU,KAAG,IAAI,CAAC,UAAU,IAAE,UAAU,CAAC,MAAM,CAAC,OAAO;gBAC1G,MAAM,IAAI,YAAY,CAAC,mBAAmB,EAAC,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC;QACF,aAAa,EAAE,CAAC;QAAA,OAAO,EAAC,MAAM,EAAC,UAAU,CAAC,MAAM,EAAC,aAAa,EAAC,CAAC;IAClE,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AuthorityFence } from './authority-fence.js';
|
|
2
|
+
export { DENIED, can, fieldAccess, projectFields, dirtyPatch, type FieldAccess, type PageAccess } from './page-access.js';
|
|
3
|
+
export { parsePageAccess, pickPageAccess, fieldState, accessReader, type AccessKeys, type AccessExpectation, type AccessRefusal, type AccessCheck, type FieldPresentation, type ControlState, type AccessReader } from './snapshot.js';
|
|
4
|
+
export { definePageManifest, elementCapability, pageKeys, navigationKeys, manifestKeys, buildNavigation, checkPageManifest, assertPageManifest, type ManifestElement, type ManifestPage, type ManifestGroup, type PageManifest, type NavigationEntry, type ManifestProblem } from './manifest.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AuthorityFence } from './authority-fence.js';
|
|
2
|
+
export { DENIED, can, fieldAccess, projectFields, dirtyPatch } from './page-access.js';
|
|
3
|
+
export { parsePageAccess, pickPageAccess, fieldState, accessReader } from './snapshot.js';
|
|
4
|
+
export { definePageManifest, elementCapability, pageKeys, navigationKeys, manifestKeys, buildNavigation, checkPageManifest, assertPageManifest } from './manifest.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,MAAM,EAAC,GAAG,EAAC,WAAW,EAAC,aAAa,EAAC,UAAU,EAAkC,MAAM,kBAAkB,CAAC;AAClH,OAAO,EAAC,eAAe,EAAC,cAAc,EAAC,UAAU,EAAC,YAAY,EAC0E,MAAM,eAAe,CAAC;AAC9J,OAAO,EAAC,kBAAkB,EAAC,iBAAiB,EAAC,QAAQ,EAAC,cAAc,EAAC,YAAY,EAAC,eAAe,EAAC,iBAAiB,EAAC,kBAAkB,EACd,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type PageAccess } from './page-access.js';
|
|
2
|
+
import type { AccessKeys } from './snapshot.js';
|
|
3
|
+
/** An element of a page. Without `capability` its own id is its capability key. */
|
|
4
|
+
export type ManifestElement = Readonly<{
|
|
5
|
+
id: string;
|
|
6
|
+
capability?: string;
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* One route. `page` is the capability the page needs; `menu`, when set, is the capability its menu entry needs.
|
|
10
|
+
* `fields` lists the field keys the page's components read.
|
|
11
|
+
*/
|
|
12
|
+
export type ManifestPage = Readonly<{
|
|
13
|
+
id: string;
|
|
14
|
+
route: string;
|
|
15
|
+
page: string;
|
|
16
|
+
menu?: string;
|
|
17
|
+
elements?: readonly ManifestElement[];
|
|
18
|
+
fields?: readonly string[];
|
|
19
|
+
}>;
|
|
20
|
+
/** A navigation group: its own menu capability and its children, page or group ids, in order. */
|
|
21
|
+
export type ManifestGroup = Readonly<{
|
|
22
|
+
id: string;
|
|
23
|
+
menu: string;
|
|
24
|
+
children: readonly string[];
|
|
25
|
+
}>;
|
|
26
|
+
/** Every route of an app, its navigation groups and the order of the top level of its navigation. */
|
|
27
|
+
export type PageManifest = Readonly<{
|
|
28
|
+
pages: readonly ManifestPage[];
|
|
29
|
+
groups?: readonly ManifestGroup[];
|
|
30
|
+
navigation?: readonly string[];
|
|
31
|
+
}>;
|
|
32
|
+
export type NavigationEntry = Readonly<{
|
|
33
|
+
kind: 'page';
|
|
34
|
+
id: string;
|
|
35
|
+
route: string;
|
|
36
|
+
}> | Readonly<{
|
|
37
|
+
kind: 'group';
|
|
38
|
+
id: string;
|
|
39
|
+
children: readonly NavigationEntry[];
|
|
40
|
+
}>;
|
|
41
|
+
export type ManifestProblem = Readonly<{
|
|
42
|
+
code: 'DUPLICATE_ID' | 'UNREGISTERED_ID' | 'UNLISTED_ROUTE' | 'UNKNOWN_CHILD' | 'NO_MENU' | 'NAVIGATION_CYCLE';
|
|
43
|
+
id: string;
|
|
44
|
+
}>;
|
|
45
|
+
/** Defines the manifest once, frozen. Ids are stable strings; checkPageManifest finds duplicates and gaps. */
|
|
46
|
+
export declare function definePageManifest<const M extends PageManifest>(manifest: M): M;
|
|
47
|
+
export declare function elementCapability(element: ManifestElement): string;
|
|
48
|
+
/** The keys one page's components read: its page and menu capabilities, its elements' capabilities and its fields. */
|
|
49
|
+
export declare function pageKeys(manifest: PageManifest, pageId: string): AccessKeys;
|
|
50
|
+
/** The keys navigation reads: every group's menu capability and the menu and page capability of every page with a menu. */
|
|
51
|
+
export declare function navigationKeys(manifest: PageManifest): AccessKeys;
|
|
52
|
+
/** Every key the manifest declares: the known keys a snapshot is checked against. */
|
|
53
|
+
export declare function manifestKeys(manifest: PageManifest): AccessKeys;
|
|
54
|
+
/**
|
|
55
|
+
* Navigation from the manifest and the snapshot. A page shows when the snapshot grants both its menu and its page
|
|
56
|
+
* capability; a group shows when it grants the group's menu and at least one child shows. A parent's visibility
|
|
57
|
+
* grants no child, and a group with no visible child is pruned.
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildNavigation(manifest: PageManifest, access: PageAccess | undefined, now?: number): NavigationEntry[];
|
|
60
|
+
/**
|
|
61
|
+
* The problems a test reports: an id defined twice, an id the app uses that the manifest does not register (ids and
|
|
62
|
+
* capability keys are registered), an app route without a page entry, a navigation child that is neither a page nor
|
|
63
|
+
* a group, a page in navigation without a menu capability, and a group that contains itself.
|
|
64
|
+
*/
|
|
65
|
+
export declare function checkPageManifest(manifest: PageManifest, input?: Readonly<{
|
|
66
|
+
routes?: Iterable<string>;
|
|
67
|
+
ids?: Iterable<string>;
|
|
68
|
+
}>): ManifestProblem[];
|
|
69
|
+
/** Throws PAGE_MANIFEST_INVALID with every problem, for a test of the consumer's manifest. */
|
|
70
|
+
export declare function assertPageManifest(manifest: PageManifest, input?: Readonly<{
|
|
71
|
+
routes?: Iterable<string>;
|
|
72
|
+
ids?: Iterable<string>;
|
|
73
|
+
}>): void;
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { can } from './page-access.js';
|
|
2
|
+
function deepFreeze(value) {
|
|
3
|
+
if (value && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
4
|
+
for (const child of Object.values(value))
|
|
5
|
+
deepFreeze(child);
|
|
6
|
+
Object.freeze(value);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
/** Defines the manifest once, frozen. Ids are stable strings; checkPageManifest finds duplicates and gaps. */
|
|
11
|
+
export function definePageManifest(manifest) { return deepFreeze(manifest); }
|
|
12
|
+
export function elementCapability(element) { return element.capability ?? element.id; }
|
|
13
|
+
const unique = (values) => [...new Set(values)];
|
|
14
|
+
/** The keys one page's components read: its page and menu capabilities, its elements' capabilities and its fields. */
|
|
15
|
+
export function pageKeys(manifest, pageId) {
|
|
16
|
+
const page = manifest.pages.find(entry => entry.id === pageId);
|
|
17
|
+
if (!page)
|
|
18
|
+
return { capabilities: [], fields: [] };
|
|
19
|
+
return { capabilities: unique([page.page, ...(page.menu ? [page.menu] : []), ...(page.elements ?? []).map(elementCapability)]), fields: unique(page.fields ?? []) };
|
|
20
|
+
}
|
|
21
|
+
/** The keys navigation reads: every group's menu capability and the menu and page capability of every page with a menu. */
|
|
22
|
+
export function navigationKeys(manifest) {
|
|
23
|
+
return { capabilities: unique([...(manifest.groups ?? []).map(group => group.menu),
|
|
24
|
+
...manifest.pages.flatMap(page => page.menu ? [page.menu, page.page] : [])]), fields: [] };
|
|
25
|
+
}
|
|
26
|
+
/** Every key the manifest declares: the known keys a snapshot is checked against. */
|
|
27
|
+
export function manifestKeys(manifest) {
|
|
28
|
+
const pages = manifest.pages.map(page => pageKeys(manifest, page.id));
|
|
29
|
+
return { capabilities: unique([...navigationKeys(manifest).capabilities, ...pages.flatMap(keys => keys.capabilities)]),
|
|
30
|
+
fields: unique(pages.flatMap(keys => keys.fields)) };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Navigation from the manifest and the snapshot. A page shows when the snapshot grants both its menu and its page
|
|
34
|
+
* capability; a group shows when it grants the group's menu and at least one child shows. A parent's visibility
|
|
35
|
+
* grants no child, and a group with no visible child is pruned.
|
|
36
|
+
*/
|
|
37
|
+
export function buildNavigation(manifest, access, now = Date.now()) {
|
|
38
|
+
const pages = new Map(manifest.pages.map(page => [page.id, page])), groups = new Map((manifest.groups ?? []).map(group => [group.id, group]));
|
|
39
|
+
const visit = (id, path) => {
|
|
40
|
+
if (path.has(id))
|
|
41
|
+
return undefined;
|
|
42
|
+
const page = pages.get(id);
|
|
43
|
+
if (page)
|
|
44
|
+
return page.menu && can(access, page.menu, now) && can(access, page.page, now) ? Object.freeze({ kind: 'page', id, route: page.route }) : undefined;
|
|
45
|
+
const group = groups.get(id);
|
|
46
|
+
if (!group || !can(access, group.menu, now))
|
|
47
|
+
return undefined;
|
|
48
|
+
const inner = new Set(path).add(id);
|
|
49
|
+
const children = group.children.map(child => visit(child, inner)).filter((entry) => entry !== undefined);
|
|
50
|
+
return children.length ? Object.freeze({ kind: 'group', id, children: Object.freeze(children) }) : undefined;
|
|
51
|
+
};
|
|
52
|
+
return (manifest.navigation ?? []).map(id => visit(id, new Set())).filter((entry) => entry !== undefined);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The problems a test reports: an id defined twice, an id the app uses that the manifest does not register (ids and
|
|
56
|
+
* capability keys are registered), an app route without a page entry, a navigation child that is neither a page nor
|
|
57
|
+
* a group, a page in navigation without a menu capability, and a group that contains itself.
|
|
58
|
+
*/
|
|
59
|
+
export function checkPageManifest(manifest, input = {}) {
|
|
60
|
+
const problems = [], seen = new Set();
|
|
61
|
+
const ids = [...manifest.pages.map(page => page.id), ...(manifest.groups ?? []).map(group => group.id),
|
|
62
|
+
...manifest.pages.flatMap(page => (page.elements ?? []).map(element => element.id))];
|
|
63
|
+
for (const id of ids) {
|
|
64
|
+
if (seen.has(id))
|
|
65
|
+
problems.push({ code: 'DUPLICATE_ID', id });
|
|
66
|
+
seen.add(id);
|
|
67
|
+
}
|
|
68
|
+
const registered = new Set([...ids, ...manifestKeys(manifest).capabilities]);
|
|
69
|
+
for (const id of unique(input.ids ?? []))
|
|
70
|
+
if (!registered.has(id))
|
|
71
|
+
problems.push({ code: 'UNREGISTERED_ID', id });
|
|
72
|
+
const routes = new Set(manifest.pages.map(page => page.route));
|
|
73
|
+
for (const route of unique(input.routes ?? []))
|
|
74
|
+
if (!routes.has(route))
|
|
75
|
+
problems.push({ code: 'UNLISTED_ROUTE', id: route });
|
|
76
|
+
const pages = new Map(manifest.pages.map(page => [page.id, page])), groups = new Map((manifest.groups ?? []).map(group => [group.id, group]));
|
|
77
|
+
const reported = new Set();
|
|
78
|
+
const walk = (id, path) => {
|
|
79
|
+
if (path.includes(id)) {
|
|
80
|
+
if (!reported.has('cycle:' + id)) {
|
|
81
|
+
reported.add('cycle:' + id);
|
|
82
|
+
problems.push({ code: 'NAVIGATION_CYCLE', id });
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const page = pages.get(id), group = groups.get(id);
|
|
87
|
+
if (page) {
|
|
88
|
+
if (!page.menu && !reported.has('menu:' + id)) {
|
|
89
|
+
reported.add('menu:' + id);
|
|
90
|
+
problems.push({ code: 'NO_MENU', id });
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (!group) {
|
|
95
|
+
if (!reported.has('child:' + id)) {
|
|
96
|
+
reported.add('child:' + id);
|
|
97
|
+
problems.push({ code: 'UNKNOWN_CHILD', id });
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
for (const child of group.children)
|
|
102
|
+
walk(child, [...path, id]);
|
|
103
|
+
};
|
|
104
|
+
for (const id of manifest.navigation ?? [])
|
|
105
|
+
walk(id, []);
|
|
106
|
+
for (const group of manifest.groups ?? [])
|
|
107
|
+
for (const child of group.children)
|
|
108
|
+
if (!pages.has(child) && !groups.has(child) && !reported.has('child:' + child)) {
|
|
109
|
+
reported.add('child:' + child);
|
|
110
|
+
problems.push({ code: 'UNKNOWN_CHILD', id: child });
|
|
111
|
+
}
|
|
112
|
+
return problems;
|
|
113
|
+
}
|
|
114
|
+
/** Throws PAGE_MANIFEST_INVALID with every problem, for a test of the consumer's manifest. */
|
|
115
|
+
export function assertPageManifest(manifest, input = {}) {
|
|
116
|
+
const problems = checkPageManifest(manifest, input);
|
|
117
|
+
if (problems.length)
|
|
118
|
+
throw new Error('PAGE_MANIFEST_INVALID ' + problems.map(problem => problem.code + ':' + problem.id).join(' '));
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAiB,MAAM,kBAAkB,CAAC;AAsBrD,SAAS,UAAU,CAAI,KAAO;IAC5B,IAAG,KAAK,IAAE,OAAO,KAAK,KAAG,QAAQ,IAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAC,CA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AAI,QAAQ,CAAC,UAAU,IAAE,EAAE;QAAC,IAAI,CAAC,EAAE,EAAC,EAAE,CAAC,CAAC;IACpD,KAAI,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,IAAE,EAAE;QAAC,KAAI,MAAM,KAAK,IAAI,KAAK,CAAC,QAAQ;YAAC,IAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,GAAC,KAAK,CAAC,EAAC,CAAC;gBAChJ,QAAQ,CAAC,GAAG,CAAC,QAAQ,GAAC,KAAK,CAAC,CAAC;gBAAA,QAAQ,CAAC,IAAI,CAAC,EAAC,IAAI,EAAC,eAAe,EAAC,EAAE,EAAC,KAAK,EAAC,CAAC,CAAC;YAC9E,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AACD,8FAA8F;AAC9F,MAAM,UAAU,kBAAkB,CAAC,QAAqB,EAAC,QAAiE,EAAE;IAC1H,MAAM,QAAQ,GAAC,iBAAiB,CAAC,QAAQ,EAAC,KAAK,CAAC,CAAC;IACjD,IAAG,QAAQ,CAAC,MAAM;QAAC,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAA,EAAE,CAAA,OAAO,CAAC,IAAI,GAAC,GAAG,GAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5H,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type FieldAccess = Readonly<{
|
|
2
|
+
view: boolean;
|
|
3
|
+
edit: boolean;
|
|
4
|
+
}>;
|
|
5
|
+
export type PageAccess = Readonly<{
|
|
6
|
+
contextRef: string;
|
|
7
|
+
revision: string;
|
|
8
|
+
expiresAt: number;
|
|
9
|
+
capabilities: Readonly<Record<string, boolean>>;
|
|
10
|
+
fields: Readonly<Record<string, FieldAccess>>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const DENIED: FieldAccess;
|
|
13
|
+
export declare function fieldAccess(access: PageAccess | undefined, key: string, now?: number): FieldAccess;
|
|
14
|
+
export declare function can(access: PageAccess | undefined, capability: string, now?: number): boolean;
|
|
15
|
+
export declare function projectFields(data: Readonly<Record<string, unknown>>, access: PageAccess, now?: number): Record<string, unknown>;
|
|
16
|
+
export declare function dirtyPatch(original: Readonly<Record<string, unknown>>, draft: Readonly<Record<string, unknown>>, access: PageAccess, now?: number): Record<string, unknown>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const DENIED = Object.freeze({ view: false, edit: false });
|
|
2
|
+
export function fieldAccess(access, key, now = Date.now()) {
|
|
3
|
+
if (!access || access.expiresAt <= now)
|
|
4
|
+
return DENIED;
|
|
5
|
+
const field = access.fields[key];
|
|
6
|
+
return field?.view ? { view: true, edit: field.edit === true } : DENIED;
|
|
7
|
+
}
|
|
8
|
+
export function can(access, capability, now = Date.now()) {
|
|
9
|
+
return !!access && access.expiresAt > now && access.capabilities[capability] === true;
|
|
10
|
+
}
|
|
11
|
+
export function projectFields(data, access, now = Date.now()) {
|
|
12
|
+
return Object.fromEntries(Object.entries(data).filter(([key]) => fieldAccess(access, key, now).view));
|
|
13
|
+
}
|
|
14
|
+
export function dirtyPatch(original, draft, access, now = Date.now()) {
|
|
15
|
+
const patch = {};
|
|
16
|
+
for (const [key, value] of Object.entries(draft)) {
|
|
17
|
+
if (Object.is(original[key], value))
|
|
18
|
+
continue;
|
|
19
|
+
if (!fieldAccess(access, key, now).edit)
|
|
20
|
+
throw new Error('FORBIDDEN_FIELD');
|
|
21
|
+
patch[key] = value;
|
|
22
|
+
}
|
|
23
|
+
return patch;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=page-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-access.js","sourceRoot":"","sources":["../src/page-access.ts"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AE,CAAC;IAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC;YAAE,SAAS;QAC9C,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC5E,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type FieldAccess, type PageAccess } from './page-access.js';
|
|
2
|
+
/** The capability and field keys a consumer knows; a snapshot that names another key is refused. */
|
|
3
|
+
export type AccessKeys = Readonly<{
|
|
4
|
+
capabilities: readonly string[];
|
|
5
|
+
fields: readonly string[];
|
|
6
|
+
}>;
|
|
7
|
+
/** What a snapshot must match to be used: the current time, the context the request is in, the known keys. */
|
|
8
|
+
export type AccessExpectation = Readonly<{
|
|
9
|
+
now?: number;
|
|
10
|
+
contextRef?: string;
|
|
11
|
+
keys?: AccessKeys;
|
|
12
|
+
}>;
|
|
13
|
+
/** Why a snapshot was refused. A refused snapshot is never used: every entry stays closed. */
|
|
14
|
+
export type AccessRefusal = 'MALFORMED' | 'EXPIRED' | 'CONTEXT_MISMATCH' | 'UNKNOWN_KEY';
|
|
15
|
+
export type AccessCheck = Readonly<{
|
|
16
|
+
ok: true;
|
|
17
|
+
access: PageAccess;
|
|
18
|
+
}> | Readonly<{
|
|
19
|
+
ok: false;
|
|
20
|
+
reason: AccessRefusal;
|
|
21
|
+
}>;
|
|
22
|
+
/** How a field is presented: not rendered, rendered and not editable, or editable. */
|
|
23
|
+
export type FieldPresentation = 'hidden' | 'disabled' | 'enabled';
|
|
24
|
+
/** A state the control already has; either one keeps it disabled whatever the snapshot grants. */
|
|
25
|
+
export type ControlState = Readonly<{
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
busy?: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Validates an access snapshot at run time before anything reads it: its shape (exactly the five members, no
|
|
31
|
+
* identity or token data beside them), its context reference and revision, its expiry, the context the caller
|
|
32
|
+
* expects and, when given, the known keys. The result is a frozen copy; a refused snapshot grants nothing.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parsePageAccess(value: unknown, expected?: AccessExpectation): AccessCheck;
|
|
35
|
+
/** The part of a snapshot that some components need: only the listed keys, never more than the snapshot grants. */
|
|
36
|
+
export declare function pickPageAccess(access: PageAccess, keys: AccessKeys): PageAccess;
|
|
37
|
+
/** Hidden when the field may not be viewed, disabled when it may not be edited or the control is disabled or busy. */
|
|
38
|
+
export declare function fieldState(access: PageAccess | undefined, key: string, state?: ControlState, now?: number): FieldPresentation;
|
|
39
|
+
/** One snapshot read for components. Without a snapshot every entry is closed. Each read uses the current time. */
|
|
40
|
+
export type AccessReader = Readonly<{
|
|
41
|
+
snapshot: PageAccess | undefined;
|
|
42
|
+
can: (capability: string) => boolean;
|
|
43
|
+
field: (key: string) => FieldAccess;
|
|
44
|
+
fieldState: (key: string, state?: ControlState) => FieldPresentation;
|
|
45
|
+
/** The changed fields that may be edited (dirtyPatch); a change to any other field throws FORBIDDEN_FIELD. */
|
|
46
|
+
patch: (original: Readonly<Record<string, unknown>>, draft: Readonly<Record<string, unknown>>) => Record<string, unknown>;
|
|
47
|
+
}>;
|
|
48
|
+
export declare function accessReader(snapshot: PageAccess | undefined, now?: () => number): AccessReader;
|
package/dist/snapshot.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { can, dirtyPatch, fieldAccess } from './page-access.js';
|
|
2
|
+
const SNAPSHOT_KEYS = ['capabilities', 'contextRef', 'expiresAt', 'fields', 'revision'];
|
|
3
|
+
const REFERENCE = /^[A-Za-z0-9._:~-]{1,128}$/;
|
|
4
|
+
const KEY = /^[A-Za-z0-9_.:/~-]{1,200}$/;
|
|
5
|
+
// Records are plain objects, so that a server component can pass a snapshot to a client component; a key that
|
|
6
|
+
// would name the prototype is refused.
|
|
7
|
+
const key = (value) => KEY.test(value) && value !== '__proto__';
|
|
8
|
+
const MAX_KEYS = 4096;
|
|
9
|
+
function plainObject(value) {
|
|
10
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
11
|
+
return false;
|
|
12
|
+
const prototype = Object.getPrototypeOf(value);
|
|
13
|
+
return prototype === Object.prototype || prototype === null;
|
|
14
|
+
}
|
|
15
|
+
function exactKeys(value, keys) {
|
|
16
|
+
const own = Object.keys(value).sort();
|
|
17
|
+
return own.length === keys.length && own.every((key, index) => key === keys[index]);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validates an access snapshot at run time before anything reads it: its shape (exactly the five members, no
|
|
21
|
+
* identity or token data beside them), its context reference and revision, its expiry, the context the caller
|
|
22
|
+
* expects and, when given, the known keys. The result is a frozen copy; a refused snapshot grants nothing.
|
|
23
|
+
*/
|
|
24
|
+
export function parsePageAccess(value, expected = {}) {
|
|
25
|
+
const refuse = (reason) => ({ ok: false, reason });
|
|
26
|
+
if (!plainObject(value) || !exactKeys(value, SNAPSHOT_KEYS))
|
|
27
|
+
return refuse('MALFORMED');
|
|
28
|
+
const { contextRef, revision, expiresAt, capabilities, fields } = value;
|
|
29
|
+
if (typeof contextRef !== 'string' || !REFERENCE.test(contextRef))
|
|
30
|
+
return refuse('MALFORMED');
|
|
31
|
+
if (typeof revision !== 'string' || !REFERENCE.test(revision))
|
|
32
|
+
return refuse('MALFORMED');
|
|
33
|
+
if (typeof expiresAt !== 'number' || !Number.isFinite(expiresAt))
|
|
34
|
+
return refuse('MALFORMED');
|
|
35
|
+
if (!plainObject(capabilities) || !plainObject(fields))
|
|
36
|
+
return refuse('MALFORMED');
|
|
37
|
+
const capabilityEntries = Object.entries(capabilities), fieldEntries = Object.entries(fields);
|
|
38
|
+
if (capabilityEntries.length > MAX_KEYS || fieldEntries.length > MAX_KEYS)
|
|
39
|
+
return refuse('MALFORMED');
|
|
40
|
+
const grants = [];
|
|
41
|
+
for (const [name, granted] of capabilityEntries) {
|
|
42
|
+
if (!key(name) || typeof granted !== 'boolean')
|
|
43
|
+
return refuse('MALFORMED');
|
|
44
|
+
grants.push([name, granted]);
|
|
45
|
+
}
|
|
46
|
+
const access = [];
|
|
47
|
+
for (const [name, field] of fieldEntries) {
|
|
48
|
+
if (!key(name) || !plainObject(field) || !exactKeys(field, ['edit', 'view']) || typeof field.view !== 'boolean' || typeof field.edit !== 'boolean')
|
|
49
|
+
return refuse('MALFORMED');
|
|
50
|
+
access.push([name, Object.freeze({ view: field.view, edit: field.edit })]);
|
|
51
|
+
}
|
|
52
|
+
if (expiresAt <= (expected.now ?? Date.now()))
|
|
53
|
+
return refuse('EXPIRED');
|
|
54
|
+
if (expected.contextRef !== undefined && expected.contextRef !== contextRef)
|
|
55
|
+
return refuse('CONTEXT_MISMATCH');
|
|
56
|
+
if (expected.keys) {
|
|
57
|
+
const knownCapabilities = new Set(expected.keys.capabilities), knownFields = new Set(expected.keys.fields);
|
|
58
|
+
if (capabilityEntries.some(([key]) => !knownCapabilities.has(key)) || fieldEntries.some(([key]) => !knownFields.has(key)))
|
|
59
|
+
return refuse('UNKNOWN_KEY');
|
|
60
|
+
}
|
|
61
|
+
return { ok: true, access: Object.freeze({ contextRef, revision, expiresAt,
|
|
62
|
+
capabilities: Object.freeze(Object.fromEntries(grants)), fields: Object.freeze(Object.fromEntries(access)) }) };
|
|
63
|
+
}
|
|
64
|
+
/** The part of a snapshot that some components need: only the listed keys, never more than the snapshot grants. */
|
|
65
|
+
export function pickPageAccess(access, keys) {
|
|
66
|
+
const capabilities = [], fields = [];
|
|
67
|
+
for (const name of new Set(keys.capabilities))
|
|
68
|
+
if (Object.hasOwn(access.capabilities, name))
|
|
69
|
+
capabilities.push([name, access.capabilities[name] === true]);
|
|
70
|
+
for (const name of new Set(keys.fields)) {
|
|
71
|
+
const field = Object.hasOwn(access.fields, name) ? access.fields[name] : undefined;
|
|
72
|
+
if (field)
|
|
73
|
+
fields.push([name, Object.freeze({ view: field.view === true, edit: field.edit === true })]);
|
|
74
|
+
}
|
|
75
|
+
return Object.freeze({ contextRef: access.contextRef, revision: access.revision, expiresAt: access.expiresAt,
|
|
76
|
+
capabilities: Object.freeze(Object.fromEntries(capabilities)), fields: Object.freeze(Object.fromEntries(fields)) });
|
|
77
|
+
}
|
|
78
|
+
/** Hidden when the field may not be viewed, disabled when it may not be edited or the control is disabled or busy. */
|
|
79
|
+
export function fieldState(access, key, state = {}, now = Date.now()) {
|
|
80
|
+
const field = fieldAccess(access, key, now);
|
|
81
|
+
if (!field.view)
|
|
82
|
+
return 'hidden';
|
|
83
|
+
return field.edit && !state.disabled && !state.busy ? 'enabled' : 'disabled';
|
|
84
|
+
}
|
|
85
|
+
const CLOSED = Object.freeze({ contextRef: 'closed', revision: 'closed', expiresAt: 0, capabilities: Object.freeze({}), fields: Object.freeze({}) });
|
|
86
|
+
export function accessReader(snapshot, now = Date.now) {
|
|
87
|
+
return Object.freeze({
|
|
88
|
+
snapshot,
|
|
89
|
+
can: (capability) => can(snapshot, capability, now()),
|
|
90
|
+
field: (key) => fieldAccess(snapshot, key, now()),
|
|
91
|
+
fieldState: (key, state = {}) => fieldState(snapshot, key, state, now()),
|
|
92
|
+
patch: (original, draft) => dirtyPatch(original, draft, snapshot ?? CLOSED, now()),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,UAAU,EAAC,WAAW,EAAkC,MAAM,kBAAkB,CAAC;AAc7F,MAAM,aAAa,GAAC,CA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AG,CAAC,QAAQ,EAAC,UAAU,EAAC,GAAG,EAAE,CAAC;QACvD,KAAK,EAAC,CAAC,GAAU,EAAC,EAAE,CAAA,WAAW,CAAC,QAAQ,EAAC,GAAG,EAAC,GAAG,EAAE,CAAC;QACnD,UAAU,EAAC,CAAC,GAAU,EAAC,QAAmB,EAAE,EAAC,EAAE,CAAA,UAAU,CAAC,QAAQ,EAAC,GAAG,EAAC,KAAK,EAAC,GAAG,EAAE,CAAC;QACnF,KAAK,EAAC,CAAC,QAAyC,EAAC,KAAsC,EAAC,EAAE,CAAA,UAAU,CAAC,QAAQ,EAAC,KAAK,EAAC,QAAQ,IAAE,MAAM,EAAC,GAAG,EAAE,CAAC;KAC5I,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpfrontend/access-core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/panahister/mpfrontend.git",
|
|
8
|
+
"directory": "packages/access-core"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public",
|
|
25
|
+
"provenance": true
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {}
|
|
6
28
|
}
|