Skip to content

Commit

Permalink
gear: permissions types
Browse files Browse the repository at this point in the history
This implements the first draft of types as specified by the backend implementations:
- urbit/urbit#6493
- master...tinnus-napbus:landscape:tinnus/userspace-permissions

Based on out-of-band conversation with @tinnus-napbus, there is possibly some changes coming to this interface. (to be addressed in a follow up commit).
  • Loading branch information
tomholford committed Jun 9, 2023
1 parent 2d6e599 commit 01c494c
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ui/src/gear/docket/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Cass } from '../hood';
import { Seal } from '../permissions';
export type DeskStatus = 'active' | 'suspended';

export type DocketHref = DocketHrefSite | DocketHrefGlob;
Expand Down Expand Up @@ -54,6 +55,8 @@ export interface Treaty extends Docket {
desk: string;
cass: Cass;
hash: string;
bill: string[];
seal: Seal;
}

export interface Charges {
Expand Down
6 changes: 2 additions & 4 deletions ui/src/gear/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@ export * as docket from './docket';
export * from './docket';
export * as utils from './utils';
export * from './utils';

// TODO: Userspace Permissions
// export * from './permissions';
// export * as permissions from './permissions';
export * from './permissions';
export * as permissions from './permissions';
2 changes: 2 additions & 0 deletions ui/src/gear/permissions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './lib';
export * from './types';
1 change: 1 addition & 0 deletions ui/src/gear/permissions/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {}
78 changes: 78 additions & 0 deletions ui/src/gear/permissions/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

type PermType = "super" | "watch" | "write" | "reads" | "press";

type Vane = 'ames' | 'behn' | 'clay' | 'dill' | 'eyre' | 'gall' | 'iris' | 'jael' | 'khan';

type Tail = {
jump?: boolean;
care?: string | null;
desk?: string | null;
dude?: string | null;
path?: string | null;
ship?: string | null;
spur?: string | null;
vane?: string | null;
} | null;


export interface Perm {
name: PermType;
vane: Vane | null;
tail: Tail;
}

export type Seal = Perm[];

export interface PermSummary {
desc: string;
// TODO: per tinnus, "have" is meant to say whether the app already has all /
// any of / none of the perms in question but currently it doesn't, it just
// always says nil.
have: "nil"
pers: Perm[];
warn: string | null;
}

/**
* A passport-formatted permission
*/
export interface PassportPerm {
kind: {
nom: string;
pes: PermSummary[]
}
}

export interface AppPerm {
pes: {
node: PermSummary[]
};
app: string;
}

/**
* Per lib/perms.hoon, Passport is intended for consumption by permission
* management frontends.
*/
export interface Passport {
/**
* Categorized perms
*/
rad: PassportPerm[];
/**
* Dangerous perms
*/
sys: PassportPerm[];
/**
* All apps perms
*/
any: PassportPerm[];
/**
* Unknown app perms
*/
new: PassportPerm[];
/**
* Specific app perms
*/
app: AppPerm[];
}

0 comments on commit 01c494c

Please sign in to comment.