Implements

Constructors

Properties

_signedChainId: undefined | string = undefined

Chain that this permit was signed on. In part used for mock encrypt/unseal on hardhat network. Should not be set manually, included in metadata as part of serialization flows.

contracts: string[]

(base) List of contract addresses that can be accessed with this permission

expiration: number

(base) Expiration timestamp

issuer: string

(base) User that initially created the permission, target of data fetching

issuerSignature: string

(base) signTypedData signature created by issuer. (base) Shared- and Self- permissions differ in signature format: (sealingKey absent in shared signature) (non-sharing) < issuer, expiration, contracts, projects, recipient, validatorId, validatorContract, sealingKey > (sharing) < issuer, expiration, contracts, projects, recipient, validatorId, validatorContract >

name: string

Name for this permit, for organization and UI usage, not included in signature.

projects: string[]

(base) List of project identifiers (strings) that can be accessed

recipient: string

(sharing) The user that this permission will be shared with ** optional, use address(0) to disable **

recipientSignature: string

(sharing) signTypedData signature created by recipient with format: (sharing) < sealingKey, issuerSignature> ** required for shared permits **

sealingPair: SealingKey

(base) The publicKey of a sealingPair used to re-encrypt issuers confidential data (non-sharing) Populated by issuer (sharing) Populated by recipient

type: "recipient" | "self" | "sharing"

The type of the PermitV2 (self / sharing) (self) Permit that will be signed and used by the issuer (sharing) Permit that is signed by the issuer, but intended to be shared with recipient (recipient) Permit that has been received, and signed by the recipient

validatorContract: string

(issuer defined validation) The contract to query to determine permission validity ** optional, user address(0) to disable **

validatorId: number

(issuer defined validation) An id used to query a contract to check this permissions validity ** optional, use 0 to disable **

Methods

  • Export the necessary permit data to share a permit with another user

    Returns string

  • Returns a stable hash depending on the core data of the permit. Is used in the store as each permit's key in the permit map.

    Returns string

  • Extracts a contract input ready permission from this permit. The permission inherits most fields from the permit, however permit.sealingPair is removed and replaced by permit.sealingPair.publicKey in the sealingKey field.

    Parameters

    • skipValidation: boolean = false

    Returns {
        contracts: string[];
        expiration: number;
        issuer: string;
        issuerSignature: string;
        projects: string[];
        recipient: string;
        recipientSignature: string;
        sealingKey: string;
        validatorContract: string;
        validatorId: number;
    }

    • contracts: string[]

      (base) List of contract addresses that can be accessed with this permission

    • expiration: number

      (base) Expiration timestamp

    • issuer: string

      (base) User that initially created the permission, target of data fetching

    • issuerSignature: string

      (base) signTypedData signature created by issuer. (base) Shared- and Self- permissions differ in signature format: (sealingKey absent in shared signature) (non-sharing) < issuer, expiration, contracts, projects, recipient, validatorId, validatorContract, sealingKey > (sharing) < issuer, expiration, contracts, projects, recipient, validatorId, validatorContract >

    • projects: string[]

      (base) List of project identifiers (strings) that can be accessed

    • recipient: string

      (sharing) The user that this permission will be shared with ** optional, use address(0) to disable **

    • recipientSignature: string

      (sharing) signTypedData signature created by recipient with format: (sharing) < sealingKey, issuerSignature> ** required for shared permits **

    • sealingKey: string
    • validatorContract: string

      (issuer defined validation) The contract to query to determine permission validity ** optional, user address(0) to disable **

    • validatorId: number

      (issuer defined validation) An id used to query a contract to check this permissions validity ** optional, use 0 to disable **

    Permit

    skipValidation - Flag to prevent running validation on the permit before returning the extracted permission. Used internally.

  • Check if permit satisfies the requirements param. Permit must satisfy either the contracts list or the projects list

    Parameters

    • requirements: {
          contracts?: string[];
          projects?: string[];
      }

      Lists of contract and project requirements.

      • Optional contracts?: string[]
      • Optional projects?: string[]

    Returns {
        satisfies: true;
        unsatisfiedContracts: null;
        unsatisfiedProjects: null;
    } | {
        satisfies: false;
        unsatisfiedContracts: string[];
        unsatisfiedProjects: string[];
    }

    • satisfied if either req list is fulfilled.
  • Returns the domain, types, primaryType, and message fields required to request the user's signature Primary type is returned to allow viem clients to more easily connect

    Parameters

    • chainId: string
    • primaryType: "PermissionedV2IssuerSelf" | "PermissionedV2IssuerShared" | "PermissionedV2Recipient"

    Returns {
        domain: {
            chainId: number;
            name: string;
            verifyingContract: string;
            version: string;
        };
        message: EIP712Message;
        primaryType: string;
        types: EIP712Types;
    }

    • domain: {
          chainId: number;
          name: string;
          verifyingContract: string;
          version: string;
      }
      • chainId: number
      • name: string
      • verifyingContract: string
      • version: string
    • message: EIP712Message
    • primaryType: string
    • types: EIP712Types
  • Returns whether this permit has expired due to permit.expiration

    Returns boolean

  • Returns whether the active party has created their signature. If permit.type is self or sharing, the active party is issuer. If permit.type is recipient, the active party is recipient

    Returns boolean

  • Overall validity checker of a permit, checks the signatures and expirations

    Returns {
        error: "expired";
        valid: false;
    } | {
        error: "not-signed";
        valid: false;
    } | {
        error: null;
        valid: true;
    }

    • If valid, error is null, else error indicates which validity check failed
  • Determines the required signature type. Creates the EIP712 types and message. Prompts the user for their signature. Inserts the signature into issuerSignature or recipientSignature as necessary.

    Parameters

    • chainId: undefined | string

      Used as part of the EIP712 domain, throws if undefined

    • signer: undefined | AbstractSigner

      Signer responsible for signing the EIP712 permit signature, throws if undefined

    Returns Promise<void>

  • Uses the privateKey of permit.sealingPair to recursively unseal any contained SealedItems. If item is a single SealedItem it will be individually. NOTE: Only unseals typed SealedItems returned from FHE.sealoutputTyped and the FHE bindings' e____.sealTyped.

    Type Parameters

    • T

    Parameters

    • item: T

      Array, object, or item. Any nested SealedItems will be unsealed.

    Returns MappedUnsealedTypes<T>

    • Recursively unsealed data in the target type, SealedBool -> boolean, SealedAddress -> string, etc.
  • Type Parameters

    • T extends any[]

    Parameters

    • item: [...T[]]

    Returns [...MappedUnsealedTypes<T>[]]

  • Use the privateKey of permit.sealingPair to unseal ciphertext returned from the Fhenix chain. Useful when not using SealedItem structs and need to unseal an individual ciphertext.

    Parameters

    • ciphertext: string

    Returns bigint

  • Creates a PermitV2 from a serialized permit, hydrating methods and classes NOTE: Does not return a stringified permit

    Parameters

    Returns PermitV2

    • New instance of PermitV2 class
  • Parameters

    Returns SafeParseReturnType<{
        contracts?: string[];
        expiration?: number;
        issuer: string;
        issuerSignature?: string;
        name?: string;
        projects?: string[];
        recipient?: string;
        recipientSignature?: string;
        sealingPair: {
            privateKey: string;
            publicKey: string;
        };
        type: "recipient" | "self" | "sharing";
        validatorContract?: string;
        validatorId?: number;
    }, {
        contracts: string[];
        expiration: number;
        issuer: string;
        issuerSignature: string;
        name: string;
        projects: string[];
        recipient: string;
        recipientSignature: string;
        sealingPair: {
            privateKey: string;
            publicKey: string;
        };
        type: "recipient" | "self" | "sharing";
        validatorContract: string;
        validatorId: number;
    }>