@forge/bridge
5.15.2-next.0-experimental-5b726e65.16.0-next.1
out/permissions/permissionsUtil.d.ts~
out/permissions/permissionsUtil.d.tsModified+51
Index: package/out/permissions/permissionsUtil.d.ts
===================================================================
--- package/out/permissions/permissionsUtil.d.ts
+++ package/out/permissions/permissionsUtil.d.ts
@@ -1,10 +1,19 @@
import type { External } from '@forge/manifest';
import type { RuntimePermissions } from '../types';
+/**
+ * Resource types that can be loaded externally
+ */
declare const RESOURCE_TYPES: readonly ["fonts", "styles", "frames", "images", "media", "scripts"];
export declare type ResourceType = (typeof RESOURCE_TYPES)[number];
+/**
+ * Fetch types for external requests
+ */
declare const FETCH_TYPES: readonly ["backend", "client"];
export declare type FetchType = (typeof FETCH_TYPES)[number];
+/**
+ * Required permissions for checking
+ */
export interface PermissionRequirements {
scopes?: string[];
external?: {
fetch?: {
@@ -19,21 +28,63 @@
scripts?: string[];
};
content?: Record<string, unknown>;
}
+/**
+ * Missing permissions information
+ */
export declare type MissingPermissions = PermissionRequirements;
+/**
+ * Permission check result
+ */
export interface PermissionCheckResult {
granted: boolean;
missing: MissingPermissions | null;
}
+/**
+ * Permission utilities for checking runtime permissions
+ */
export interface PermissionUtils {
+ /**
+ * Check if a specific scope is granted
+ */
hasScope: (scope: string) => boolean;
+ /**
+ * Check if fetching from a URL is allowed for the given fetch type
+ * @param type - 'backend' (hostname-only matching) or 'client' (CSP validation with paths)
+ * @param url - The URL to check
+ */
canFetchFrom: (type: FetchType, url: string) => boolean;
+ /**
+ * Check if loading a resource from a URL is allowed
+ * @param type - The resource type (fonts, styles, frames, images, media, scripts)
+ * @param url - The URL to check
+ */
canLoadResource: (type: ResourceType, url: string) => boolean;
+ /**
+ * Get all granted scopes
+ */
getScopes: () => string[];
+ /**
+ * Get all external permissions
+ */
getExternalPermissions: () => External | undefined;
+ /**
+ * Check if any permissions are granted
+ */
hasAnyPermissions: () => boolean;
}
+/**
+ * Create permission utilities from runtime permissions
+ * @param runtimePermissions - The runtime permissions from context
+ * @returns Permission utilities or null if permissions are not available
+ */
export declare function createPermissionUtils(runtimePermissions: RuntimePermissions | undefined): PermissionUtils | null;
+/**
+ * Check if required permissions are granted
+ * @param requiredPermissions - The permissions required to check
+ * @param runtimePermissions - The runtime permissions from context (optional, will be fetched from view.getContext() if not provided)
+ * @returns Promise resolving to permission check result with granted status and missing permissions
+ */
export declare function checkPermissions(requiredPermissions: PermissionRequirements, runtimePermissions?: RuntimePermissions | undefined): Promise<PermissionCheckResult>;
export {};
//# sourceMappingURL=permissionsUtil.d.ts.map
\ No newline at end of file