From 711e492334f4926212f09461d61201f42f7414f8 Mon Sep 17 00:00:00 2001 From: tomholford Date: Fri, 9 Jun 2023 00:11:53 -0700 Subject: [PATCH] gear: permissions types This implements the first draft of types as specified by the backend implementations: - urbit/urbit#6493 - https://github.com/tloncorp/landscape/compare/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). --- ui/src/gear/docket/types.ts | 3 ++ ui/src/gear/index.ts | 6 +-- ui/src/gear/permissions/index.ts | 2 + ui/src/gear/permissions/lib.ts | 1 + ui/src/gear/permissions/types.ts | 78 ++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 ui/src/gear/permissions/index.ts create mode 100644 ui/src/gear/permissions/lib.ts create mode 100644 ui/src/gear/permissions/types.ts diff --git a/ui/src/gear/docket/types.ts b/ui/src/gear/docket/types.ts index c35399b5..eb3fd7f8 100644 --- a/ui/src/gear/docket/types.ts +++ b/ui/src/gear/docket/types.ts @@ -1,4 +1,5 @@ import { Cass } from '../hood'; +import { Seal } from '../permissions'; export type DeskStatus = 'active' | 'suspended'; export type DocketHref = DocketHrefSite | DocketHrefGlob; @@ -54,6 +55,8 @@ export interface Treaty extends Docket { desk: string; cass: Cass; hash: string; + bill: string[]; + seal: Seal; } export interface Charges { diff --git a/ui/src/gear/index.ts b/ui/src/gear/index.ts index 9e87d9af..32fc330a 100644 --- a/ui/src/gear/index.ts +++ b/ui/src/gear/index.ts @@ -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'; diff --git a/ui/src/gear/permissions/index.ts b/ui/src/gear/permissions/index.ts new file mode 100644 index 00000000..e06143cf --- /dev/null +++ b/ui/src/gear/permissions/index.ts @@ -0,0 +1,2 @@ +export * from './lib'; +export * from './types'; diff --git a/ui/src/gear/permissions/lib.ts b/ui/src/gear/permissions/lib.ts new file mode 100644 index 00000000..693da49f --- /dev/null +++ b/ui/src/gear/permissions/lib.ts @@ -0,0 +1 @@ +export {} \ No newline at end of file diff --git a/ui/src/gear/permissions/types.ts b/ui/src/gear/permissions/types.ts new file mode 100644 index 00000000..db9ec033 --- /dev/null +++ b/ui/src/gear/permissions/types.ts @@ -0,0 +1,78 @@ + +type PermType = "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; + + +interface Perm { + name: PermType; + vane: Vane | null; + tail: Tail; +} + +export type Seal = Perm[]; + +/** + * A passport-formatted permission + */ +interface PassportPerm { + kind: { + nom: string; + pes: { + 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; + }[] + } +} + +interface AppPerm { + pes: { + node: { + desc: string; + have: "nil"; + pers: Perm[]; + }[] + }; + 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[]; +}