A downstream fork of Tranquil PDS for use in margin.cafe margin.cafe
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233export interface RequestedConsentScope { scope: string; required: boolean; granted: boolean | null; restricted?: boolean;}
export interface RequestedPermissionBundle { include_scope: string; granted?: boolean | null; restricted?: boolean;}
export function getInitialConsentSelections( scopes: RequestedConsentScope[], permissionBundles: RequestedPermissionBundle[],): Record<string, boolean> { const selections = Object.fromEntries( scopes .filter((scope) => !scope.restricted) .map((scope) => [ scope.scope, scope.required ? true : (scope.granted ?? true), ]), );
for (const bundle of permissionBundles) { if (!bundle.restricted) selections[bundle.include_scope] = true; }
return selections;}