import * as crypto from "../crypto/index.js";
import * as identifiers from "../common/identifiers.js";
import * as pathing from "../path.js";
import * as ucanPermissions from "../ucan/permissions.js";
export const isAppState = (state) => {
    return state.kind === "appState";
};
export const isPermissionedAppState = (state) => {
    return state.kind === "permissionedAppState";
};
// VALIDATION
export async function validateSecrets(permissions) {
    return ucanPermissions.paths(permissions).reduce((acc, path) => acc.then(async (bool) => {
        if (bool === false)
            return bool;
        if (pathing.isBranch(pathing.Branch.Public, path))
            return bool;
        const keyName = await identifiers.readKey({ path });
        return await crypto.keystore.keyExists(keyName);
    }), Promise.resolve(true));
}
//# sourceMappingURL=state.js.map