@indiekit/endpoint-media
Version:
Micropub media endpoint for Indiekit. Enables publishing media files (audio, photos, videos) to your website using the Micropub protocol.
23 lines (19 loc) • 599 B
JavaScript
/**
* Check provided scope(s) satisfies required scope
* @param {string} scope - Provided scope (space separated)
* @param {string} [action] - Required action
* @returns {boolean} `true` if provided scope includes action
*/
export const checkScope = (scope, action = "media") => {
// Default scope request is `create`
if (!scope) {
scope = "create";
}
// Check for scope matching desired action
let hasScope = scope.includes(action);
// `create` scope encompasses `media` scope
if (scope === "create" && action === "media") {
hasScope = true;
}
return hasScope;
};