Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gear: permissions types #195

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ui/src/gear/docket/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ export const scryAllyTreaties = (ship: string): Scry => ({
path: `/treaties/${ship}`
});

export const scryPassport = (ship: string, desk: string): Scry => ({
app: 'treaty',
path: `/passport/${ship}/${desk}`
});

export const scrySeal = (ship: string, desk: string): Scry => ({
app: 'treaty',
path: `/seal/${ship}/${desk}`
});

/**
* Uninstall a desk, and remove docket
*/
Expand Down
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';
34 changes: 34 additions & 0 deletions ui/src/gear/permissions/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Poke } from "@urbit/http-api";
import { ApprovePermsPoke, DenyPermsPoke, Passport, PokePerm, Seal } from "./types";
import api from "@/api";

export function approvePerms(desk: string, perms: PokePerm[]): Poke<ApprovePermsPoke> {
return {
app: 'helm',
mark: 'helm-hope',
json: {
desk,
perms
}
};
}

export function denyPerms(desk: string, perms: PokePerm[]): Poke<DenyPermsPoke> {
return {
app: 'helm',
mark: 'helm-curb',
json: {
desk,
perms
}
};
}

export async function sealToPassport(seal: Seal) {
return await api.thread<Passport, Seal>({
inputMark: "json",
outputMark: "json",
threadName: "get-passport",
body: seal
});
}
Loading