MCPcopy Index your code
hub / github.com/atomicdata-dev/atomic-data-browser / getRights

Method getRights

lib/src/resource.ts:172–203  ·  view source on GitHub ↗

* Iterates over the parents of the resource, returns who has read / write * rights for this resource

(store: Store)

Source from the content-addressed store, hash-verified

170 * rights for this resource
171 */
172 async getRights(store: Store): Promise<Right[]> {
173 const rights: Right[] = [];
174 const write: string[] = this.getArray(properties.write);
175 write.forEach((subject: string) => {
176 rights.push({
177 for: subject,
178 type: RightType.WRITE,
179 setIn: this.subject,
180 });
181 });
182
183 const read: string[] = this.getArray(properties.read);
184 read.forEach((subject: string) => {
185 rights.push({
186 for: subject,
187 type: RightType.READ,
188 setIn: this.subject,
189 });
190 });
191 const parentSubject = this.get(properties.parent) as string;
192 if (parentSubject != undefined) {
193 if (parentSubject == this.getSubject()) {
194 console.warn('Circular parent', parentSubject);
195 return rights;
196 }
197 const parent = await store.getResourceAsync(parentSubject);
198 const parentRights = await parent.getRights(store);
199 rights.push(...parentRights);
200 }
201 console.log('rights', rights);
202 return rights;
203 }
204
205 /** Returns true is the resource had an `Unauthorized` 401 response. */
206 isUnauthorized(): boolean {

Callers 1

getTheRightsFunction · 0.80

Calls 4

getArrayMethod · 0.95
getMethod · 0.95
getSubjectMethod · 0.95
getResourceAsyncMethod · 0.80

Tested by

no test coverage detected