type SlackScopesSource = "auth.scopes" | "apps.permissions.info";
function collectScopes(value: unknown, into: string[]) { if (!value) { return;
} if (Array.isArray(value)) { for (const entry of value) { if (typeof entry === "string" && entry.trim()) {
into.push(entry.trim());
}
} return;
} if (typeof value === "string") { const raw = value.trim(); if (!raw) { return;
} const parts = raw.split(/[,\s]+/).map((part) => part.trim()); for (const part of parts) { if (part) {
into.push(part);
}
} return;
} if (!isRecord(value)) { return;
} for (const entry of Object.values(value)) { if (Array.isArray(entry) || typeof entry === "string") {
collectScopes(entry, into);
}
}
}
function normalizeScopes(scopes: string[]) { return Array.from(new Set(scopes.map((scope) => scope.trim()).filter(Boolean))).toSorted();
}
function extractScopes(payload: unknown): string[] { if (!isRecord(payload)) { return [];
} const scopes: string[] = [];
collectScopes(payload.scopes, scopes);
collectScopes(payload.scope, scopes); if (isRecord(payload.info)) {
collectScopes(payload.info.scopes, scopes);
collectScopes(payload.info.scope, scopes);
collectScopes((payload.info as { user_scopes?: unknown }).user_scopes, scopes);
collectScopes((payload.info as { bot_scopes?: unknown }).bot_scopes, scopes);
} return normalizeScopes(scopes);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.