// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import * as PoliciesAPI from './policies'; import * as SharedAPI from './shared'; import * as WalletsAPI from './wallets/wallets'; export class Policies extends APIResource {} /** * A parameter in a Solidity ABI function or event definition. */ export interface AbiParameter { type: string; components?: Array<{ [key: string]: unknown }>; indexed?: boolean; internalType?: string; name?: string; } /** * A Solidity ABI definition for decoding smart contract calldata. */ export type AbiSchema = Array; export namespace AbiSchema { export interface AbiSchemaItem { type: 'function' | 'constructor' | 'event' | 'fallback' | 'receive'; anonymous?: boolean; inputs?: Array; name?: string; outputs?: Array; stateMutability?: 'pure' | 'view' | 'nonpayable' | 'payable'; } } /** * Condition on the original wallet action API request body fields. */ export interface ActionRequestBodyCondition { field: string; field_source: 'action_request_body'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * Condition referencing an aggregation value. The field must start with * "aggregation." followed by the aggregation ID. */ export interface AggregationCondition { field: string; field_source: 'reference'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * Operator to use for policy conditions. */ export type ConditionOperator = 'eq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'in_condition_set'; /** * A condition set for grouping related condition values. */ export interface ConditionSet { /** * Unique ID of the created condition set. This will be the primary identifier when * using the condition set in the future. */ id: string; /** * Unix timestamp of when the condition set was created in milliseconds. */ created_at: number; /** * Name of the condition set. */ name: string; /** * A unique identifier for a key quorum. */ owner_id: SharedAPI.KeyQuorumID; } /** * Headers required to authorize modifications to condition sets. */ export interface ConditionSetAuthorizationHeaders { /** * ID of your Privy app. */ 'privy-app-id': string; /** * Request authorization signature. If multiple signatures are required, they * should be comma separated. */ 'privy-authorization-signature'?: string; /** * Request expiry. Value is a Unix timestamp in milliseconds representing the * deadline by which the request must be processed. */ 'privy-request-expiry'?: string; } /** * A single item in a condition set. */ export interface ConditionSetItem { /** * Unique ID of the created condition set item. */ id: string; /** * Unique ID of the condition set this item belongs to. */ condition_set_id: string; /** * Unix timestamp of when the condition set item was created in milliseconds. */ created_at: number; /** * The value stored in this condition set item. */ value: string; } /** * Unique IDs of the condition set and the condition set item within the condition * set to take actions on. */ export interface ConditionSetItemRequestParams { condition_set_id: string; condition_set_item_id: string; } /** * A single value to add to a condition set. */ export interface ConditionSetItemValueInput { value: string; } /** * Array of condition set items. */ export type ConditionSetItems = Array; /** * Array of values to add to the condition set. Maximum 100 items per request. */ export type ConditionSetItemsRequestBody = Array; /** * Paginated list of condition set items. */ export interface ConditionSetItemsResponse { /** * List of condition set items. */ items: Array; /** * Cursor for pagination. Null if there are no more items. */ next_cursor: string | null; } /** * Request body for creating a condition set. Exactly one of `owner` or `owner_id` * is required. */ export interface ConditionSetRequestBody { /** * Name to assign to condition set. */ name: string; /** * The owner of the resource, specified as a Privy user ID, a P-256 public key, or * null to remove the current owner. */ owner?: SharedAPI.OwnerInput | null; /** * The key quorum ID to set as the owner of the resource. If you provide this, do * not specify an owner. */ owner_id?: SharedAPI.OwnerIDInput | null; } /** * Unique ID of the condition set to take actions on. */ export interface ConditionSetRequestParams { condition_set_id: string; } /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ export type ConditionValue = string | Array; /** * Allowed contract addresses for eth_sign7702Authorization requests. */ export interface Ethereum7702AuthorizationCondition { field: 'contract'; field_source: 'ethereum_7702_authorization'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * The decoded calldata in a smart contract interaction as the smart contract * method's parameters. Note that 'ethereum_calldata' conditions must contain an * abi parameter with the JSON ABI of the smart contract. */ export interface EthereumCalldataCondition { /** * A Solidity ABI definition for decoding smart contract calldata. */ abi: AbiSchema; field: string; field_source: 'ethereum_calldata'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * The verbatim Ethereum transaction object in an eth_signTransaction or * eth_sendTransaction request. */ export interface EthereumTransactionCondition { field: 'to' | 'value' | 'chain_id'; field_source: 'ethereum_transaction'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * Attributes from the signing domain that will verify the signature. */ export interface EthereumTypedDataDomainCondition { field: 'chainId' | 'verifyingContract' | 'chain_id' | 'verifying_contract'; field_source: 'ethereum_typed_data_domain'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * 'types' and 'primary_type' attributes of the TypedData JSON object defined in * EIP-712. */ export interface EthereumTypedDataMessageCondition { field: string; field_source: 'ethereum_typed_data_message'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; typed_data: EthereumTypedDataMessageCondition.TypedData; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } export namespace EthereumTypedDataMessageCondition { export interface TypedData { primary_type: string; /** * The type definitions for EIP-712 typed data signing. */ types: WalletsAPI.TypedDataTypesInputParams; } } /** * A policy for controlling wallet operations. */ export interface Policy { /** * Unique ID of the created policy. This will be the primary identifier when using * the policy in the future. */ id: string; /** * The wallet chain types. */ chain_type: WalletsAPI.WalletChainType; /** * Unix timestamp of when the policy was created in milliseconds. */ created_at: number; /** * Name to assign to policy. */ name: string; /** * The key quorum ID of the owner of the policy. */ owner_id: string | null; rules: Array; /** * Version of the policy. Currently, 1.0 is the only version. */ version: '1.0'; } /** * The action to take when a policy rule matches. */ export type PolicyAction = 'ALLOW' | 'DENY'; /** * Headers required to authorize modifications to policies. */ export interface PolicyAuthorizationHeaders { /** * ID of your Privy app. */ 'privy-app-id': string; /** * Request authorization signature. If multiple signatures are required, they * should be comma separated. */ 'privy-authorization-signature'?: string; /** * Request expiry. Value is a Unix timestamp in milliseconds representing the * deadline by which the request must be processed. */ 'privy-request-expiry'?: string; } /** * A condition that must be true for the rule action to be applied. */ export type PolicyCondition = | EthereumTransactionCondition | EthereumCalldataCondition | EthereumTypedDataDomainCondition | EthereumTypedDataMessageCondition | Ethereum7702AuthorizationCondition | TempoTransactionCondition | SolanaProgramInstructionCondition | SolanaSystemProgramInstructionCondition | SolanaTokenProgramInstructionCondition | SystemCondition | TronTransactionCondition | TronCalldataCondition | SuiTransactionCommandCondition | SuiTransferObjectsCommandCondition | ActionRequestBodyCondition | AggregationCondition; /** * Method the rule applies to. */ export type PolicyMethod = | 'eth_sendTransaction' | 'eth_signTransaction' | 'eth_signUserOperation' | 'eth_signTypedData_v4' | 'personal_sign' | 'eth_sign7702Authorization' | 'wallet_sendCalls' | 'signTransaction' | 'signAndSendTransaction' | 'exportPrivateKey' | 'exportSeedPhrase' | 'signTransactionBytes' | 'earn_deposit' | 'earn_withdraw' | 'transfer' | '*'; /** * Unique ID of the policy to take actions on. */ export interface PolicyRequestBody { policy_id: string; } /** * The rules that apply to each method the policy covers. */ export interface PolicyRuleRequestBody { /** * The action to take when a policy rule matches. */ action: PolicyAction; conditions: Array; /** * Method the rule applies to. */ method: PolicyMethod; name: string; } /** * Unique IDs of the policy and the rule within the policy to take actions on. */ export interface PolicyRuleRequestParams { policy_id: string; rule_id: string; } /** * A rule that defines the conditions and action to take if the conditions are * true. */ export interface PolicyRuleResponse { id: string; /** * The action to take when a policy rule matches. */ action: PolicyAction; conditions: Array; /** * Method the rule applies to. */ method: PolicyMethod; name: string; } /** * Solana Program attributes, enables allowlisting Solana Programs. */ export interface SolanaProgramInstructionCondition { field: 'programId'; field_source: 'solana_program_instruction'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * Solana System Program attributes, including more granular Transfer instruction * fields. */ export interface SolanaSystemProgramInstructionCondition { field: 'instructionName' | 'Transfer.from' | 'Transfer.to' | 'Transfer.lamports'; field_source: 'solana_system_program_instruction'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * Solana Token Program attributes, including more granular TransferChecked * instruction fields. */ export interface SolanaTokenProgramInstructionCondition { field: | 'instructionName' | 'Transfer.source' | 'Transfer.destination' | 'Transfer.authority' | 'Transfer.amount' | 'TransferChecked.source' | 'TransferChecked.destination' | 'TransferChecked.authority' | 'TransferChecked.amount' | 'TransferChecked.mint' | 'Burn.account' | 'Burn.mint' | 'Burn.authority' | 'Burn.amount' | 'MintTo.mint' | 'MintTo.account' | 'MintTo.authority' | 'MintTo.amount' | 'CloseAccount.account' | 'CloseAccount.destination' | 'CloseAccount.authority' | 'InitializeAccount3.account' | 'InitializeAccount3.mint' | 'InitializeAccount3.owner'; field_source: 'solana_token_program_instruction'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * SUI transaction command attributes, enables allowlisting specific command types. * Allowed commands: 'TransferObjects', 'SplitCoins', 'MergeCoins'. Only 'eq' and * 'in' operators are supported. */ export interface SuiTransactionCommandCondition { field: 'commandName'; field_source: 'sui_transaction_command'; /** * Operator to use for SUI transaction command conditions. Only 'eq' and 'in' are * supported for command names. */ operator: SuiTransactionCommandOperator; /** * Command name(s) to match. Must be one of: 'TransferObjects', 'SplitCoins', * 'MergeCoins' */ value: WalletsAPI.SuiCommandName | Array; } /** * Operator to use for SUI transaction command conditions. Only 'eq' and 'in' are * supported for command names. */ export type SuiTransactionCommandOperator = 'eq' | 'in'; /** * SUI TransferObjects command attributes, including recipient and amount fields. */ export interface SuiTransferObjectsCommandCondition { /** * Supported fields for SUI TransferObjects command conditions. Only 'recipient' * and 'amount' are supported. */ field: SuiTransferObjectsCommandField; field_source: 'sui_transfer_objects_command'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * Supported fields for SUI TransferObjects command conditions. Only 'recipient' * and 'amount' are supported. */ export type SuiTransferObjectsCommandField = 'recipient' | 'amount'; /** * System attributes, including current unix timestamp (in seconds). */ export interface SystemCondition { field: 'current_unix_timestamp'; field_source: 'system'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * A Tempo (type 118) transaction-level field. Evaluated once per transaction (not * per call). */ export interface TempoTransactionCondition { /** * Tempo (type 118) transaction-level fields that can be referenced in a policy * condition. */ field: TempoTransactionConditionField; field_source: 'tempo_transaction'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * Tempo (type 118) transaction-level fields that can be referenced in a policy * condition. */ export type TempoTransactionConditionField = | 'fee_token' | 'fee_payer_signature' | 'nonce_key' | 'valid_before' | 'valid_after'; /** * Decoded calldata from a TRON TriggerSmartContract interaction. */ export interface TronCalldataCondition { /** * A Solidity ABI definition for decoding smart contract calldata. */ abi: AbiSchema; field: string; field_source: 'tron_trigger_smart_contract_data'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * TRON transaction fields for TransferContract and TriggerSmartContract * transaction types. */ export interface TronTransactionCondition { /** * Supported TRON transaction fields in format "TransactionType.field_name" */ field: | 'TransferContract.to_address' | 'TransferContract.amount' | 'TriggerSmartContract.contract_address' | 'TriggerSmartContract.call_value' | 'TriggerSmartContract.token_id' | 'TriggerSmartContract.call_token_value'; field_source: 'tron_transaction'; /** * Operator to use for policy conditions. */ operator: ConditionOperator; /** * Value to compare against in a policy condition. Can be a single string or an * array of strings. */ value: ConditionValue; } /** * Request body for updating a condition set. At least one field must be provided. * `owner` and `owner_id` are mutually exclusive. */ export interface UpdateConditionSetRequestBody { /** * Name to assign to condition set. */ name?: string; /** * The owner of the resource, specified as a Privy user ID, a P-256 public key, or * null to remove the current owner. */ owner?: SharedAPI.OwnerInput | null; /** * The key quorum ID to set as the owner of the resource. If you provide this, do * not specify an owner. */ owner_id?: SharedAPI.OwnerIDInput | null; } export declare namespace Policies { export { type AbiParameter as AbiParameter, type AbiSchema as AbiSchema, type ActionRequestBodyCondition as ActionRequestBodyCondition, type AggregationCondition as AggregationCondition, type ConditionOperator as ConditionOperator, type ConditionSet as ConditionSet, type ConditionSetAuthorizationHeaders as ConditionSetAuthorizationHeaders, type ConditionSetItem as ConditionSetItem, type ConditionSetItemRequestParams as ConditionSetItemRequestParams, type ConditionSetItemValueInput as ConditionSetItemValueInput, type ConditionSetItems as ConditionSetItems, type ConditionSetItemsRequestBody as ConditionSetItemsRequestBody, type ConditionSetItemsResponse as ConditionSetItemsResponse, type ConditionSetRequestBody as ConditionSetRequestBody, type ConditionSetRequestParams as ConditionSetRequestParams, type ConditionValue as ConditionValue, type Ethereum7702AuthorizationCondition as Ethereum7702AuthorizationCondition, type EthereumCalldataCondition as EthereumCalldataCondition, type EthereumTransactionCondition as EthereumTransactionCondition, type EthereumTypedDataDomainCondition as EthereumTypedDataDomainCondition, type EthereumTypedDataMessageCondition as EthereumTypedDataMessageCondition, type Policy as Policy, type PolicyAction as PolicyAction, type PolicyAuthorizationHeaders as PolicyAuthorizationHeaders, type PolicyCondition as PolicyCondition, type PolicyMethod as PolicyMethod, type PolicyRequestBody as PolicyRequestBody, type PolicyRuleRequestBody as PolicyRuleRequestBody, type PolicyRuleRequestParams as PolicyRuleRequestParams, type PolicyRuleResponse as PolicyRuleResponse, type SolanaProgramInstructionCondition as SolanaProgramInstructionCondition, type SolanaSystemProgramInstructionCondition as SolanaSystemProgramInstructionCondition, type SolanaTokenProgramInstructionCondition as SolanaTokenProgramInstructionCondition, type SuiTransactionCommandCondition as SuiTransactionCommandCondition, type SuiTransactionCommandOperator as SuiTransactionCommandOperator, type SuiTransferObjectsCommandCondition as SuiTransferObjectsCommandCondition, type SuiTransferObjectsCommandField as SuiTransferObjectsCommandField, type SystemCondition as SystemCondition, type TempoTransactionCondition as TempoTransactionCondition, type TempoTransactionConditionField as TempoTransactionConditionField, type TronCalldataCondition as TronCalldataCondition, type TronTransactionCondition as TronTransactionCondition, type UpdateConditionSetRequestBody as UpdateConditionSetRequestBody, }; }