/** * Copyright 2023 Fluence Labs Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { SecurityTetraplet } from "@fluencelabs/avm"; import { PeerIdB58 } from "@fluencelabs/interfaces"; import { ParticleContext } from "../jsServiceHost/interfaces.js"; /** * A predicate of call params for sig service's sign method which determines whether signing operation is allowed or not */ export type SecurityGuard = (params: ParticleContext) => boolean; /** * Only allow calls when tetraplet for 'data' argument satisfies the predicate */ export declare const allowTetraplet: (pred: (tetraplet: SecurityTetraplet) => boolean) => SecurityGuard; /** * Only allow data which comes from the specified serviceId and fnName */ export declare const allowServiceFn: (serviceId: string, fnName: string) => SecurityGuard; /** * Only allow data originated from the specified json_path */ export declare const allowExactJsonPath: (jsonPath: string) => SecurityGuard; /** * Only allow signing when particle is initiated at the specified peer */ export declare const allowOnlyParticleOriginatedAt: (peerId: PeerIdB58) => SecurityGuard; /** * Only allow signing when all of the predicates are satisfied. * Useful for predicates reuse */ export declare const and: (...predicates: SecurityGuard[]) => SecurityGuard; /** * Only allow signing when any of the predicates are satisfied. * Useful for predicates reuse */ export declare const or: (...predicates: SecurityGuard[]) => SecurityGuard;