MCPcopy
hub / github.com/immich-app/immich / requirePermissions

Function requirePermissions

packages/cli/src/utils.ts:40–65  ·  view source on GitHub ↗
(permissions: Permission[])

Source from the content-addressed store, hash-verified

38
39let _apiKey: ApiKeyResponseDto;
40export const requirePermissions = async (permissions: Permission[]) => {
41 if (!_apiKey) {
42 _apiKey = await getMyApiKey();
43 }
44
45 if (_apiKey.permissions.includes(Permission.All)) {
46 return;
47 }
48
49 const missing: Permission[] = [];
50
51 for (const permission of permissions) {
52 if (!_apiKey.permissions.includes(permission)) {
53 missing.push(permission);
54 }
55 }
56
57 if (missing.length > 0) {
58 const combined = missing.map((permission) => `"${permission}"`).join(', ');
59 console.log(
60 `Missing required permission${s(missing.length)}: ${combined}.
61Please make sure your API key has the correct permissions.`,
62 );
63 process.exit(1);
64 }
65};
66
67export const connect = async (url: string, key: string) => {
68 const wellKnownUrl = new URL('.well-known/immich', url);

Callers 3

serverInfoFunction · 0.90
uploadFunction · 0.90
loginFunction · 0.90

Calls 5

getMyApiKeyFunction · 0.90
sFunction · 0.85
mapMethod · 0.80
logMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected