MCPcopy Create free account
hub / github.com/garrytan/gstack / grantIdentity

Function grantIdentity

ios-qa/daemon/src/allowlist.ts:78–104  ·  view source on GitHub ↗
(opts: {
  identity: string;
  capability: Capability;
  ttlSeconds?: number | null; // null/undefined = no expiry
  note?: string;
  path?: string;
})

Source from the content-addressed store, hash-verified

76 * Owner-granted mint path. Adds (or upgrades) an allowlist entry.
77 */
78export async function grantIdentity(opts: {
79 identity: string;
80 capability: Capability;
81 ttlSeconds?: number | null; // null/undefined = no expiry
82 note?: string;
83 path?: string;
84}): Promise<Allowlist> {
85 const path = opts.path ?? defaultAllowlistPath();
86 const allowlist = await loadAllowlist(path);
87 const existingIdx = allowlist.entries.findIndex(e => e.identity === opts.identity);
88 const expiresAt = opts.ttlSeconds && opts.ttlSeconds > 0
89 ? new Date(Date.now() + opts.ttlSeconds * 1000).toISOString()
90 : null;
91 const newEntry: AllowlistEntry = {
92 identity: opts.identity,
93 capabilities: [opts.capability],
94 expires_at: expiresAt,
95 note: opts.note,
96 };
97 if (existingIdx >= 0) {
98 allowlist.entries[existingIdx] = newEntry;
99 } else {
100 allowlist.entries.push(newEntry);
101 }
102 await saveAllowlist(allowlist, path);
103 return allowlist;
104}
105
106/**
107 * Revoke an identity from the allowlist.

Callers 5

allowlist.test.tsFile · 0.90
auth-mint.test.tsFile · 0.90
mainFunction · 0.90

Calls 4

defaultAllowlistPathFunction · 0.85
loadAllowlistFunction · 0.85
saveAllowlistFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected