@cofhe/sdk 1.0.0-alpha.0 → 1.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/acps/onchain-utils.ts +15 -10
- package/acps/sealing.ts +22 -2
- package/acps/test/aclServedAddresses.test.ts +65 -0
- package/acps/test/sealing.test.ts +51 -0
- package/core/acps.ts +64 -23
- package/core/client.ts +32 -1
- package/core/clientTypes.ts +22 -1
- package/core/test/acpsPrepare.test.ts +77 -0
- package/dist/acps.cjs +122 -99
- package/dist/acps.d.cts +4 -358
- package/dist/acps.d.ts +4 -358
- package/dist/acps.js +2 -2
- package/dist/{chunk-OL3DZN7A.js → chunk-2EO4JSR7.js} +65 -23
- package/dist/{chunk-BQWHPIYU.js → chunk-3L2IVPMI.js} +29 -6
- package/dist/{chunk-6ZW76ZKB.js → chunk-WJGTPW7K.js} +1 -1
- package/dist/{clientTypes-CcU5WvdV.d.ts → clientTypes-CnslFzxB.d.ts} +38 -2
- package/dist/{clientTypes-C0A9ji5O.d.cts → clientTypes-RXwLVWou.d.cts} +38 -2
- package/dist/core.cjs +250 -185
- package/dist/core.d.cts +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js +4 -4
- package/dist/node.cjs +184 -119
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +4 -4
- package/dist/{onchain-utils-D9Z33IP7.d.ts → onchain-utils-Ns56cBm0.d.cts} +359 -5
- package/dist/{onchain-utils-D9Z33IP7.d.cts → onchain-utils-Ns56cBm0.d.ts} +359 -5
- package/dist/web.cjs +184 -119
- package/dist/web.d.cts +2 -2
- package/dist/web.d.ts +2 -2
- package/dist/web.js +4 -4
- package/dist/zkProve.worker.js +2 -2
- package/package.json +1 -1
- package/dist/{chunk-XQ32JG3T.js → chunk-J23FYAI2.js} +13 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Hex, Address, PublicClient, WalletClient } from 'viem';
|
|
1
|
+
import { Hex, Address, PublicClient, WalletClient, AbiParameterToPrimitiveType } from 'viem';
|
|
2
2
|
|
|
3
3
|
type EthEncryptedData = {
|
|
4
4
|
data: Uint8Array;
|
|
@@ -504,6 +504,360 @@ declare const ACPUtils: {
|
|
|
504
504
|
checkAccessOnChain: (acp: ACP, publicClient: PublicClient, handle?: bigint | Hex) => Promise<ACPAccessStatus>;
|
|
505
505
|
};
|
|
506
506
|
|
|
507
|
+
/**
|
|
508
|
+
* The on-chain sharing pieces: the share registry and revoker ABIs, the registry payload of a
|
|
509
|
+
* sharing ACP and its share id, and the read of a share from its `Shared` event. Exported so an
|
|
510
|
+
* app can send these writes through its own transaction path and still agree with the registry
|
|
511
|
+
* on ids.
|
|
512
|
+
*
|
|
513
|
+
* The registry is pointer-based: storage keeps a share header (issuer, expiration, recipient,
|
|
514
|
+
* revoker, and the block of its `Shared` event); the full payload and the metadata blob travel in
|
|
515
|
+
* that event. A reader takes headers from `sharesFor` / `getShare` and fetches the events with one
|
|
516
|
+
* single-block `getLogs` per block.
|
|
517
|
+
*/
|
|
518
|
+
declare const ACP_REVOKER_ABI: readonly [{
|
|
519
|
+
readonly name: "revokeSingle";
|
|
520
|
+
readonly type: "function";
|
|
521
|
+
readonly stateMutability: "nonpayable";
|
|
522
|
+
readonly inputs: readonly [{
|
|
523
|
+
readonly type: "uint256";
|
|
524
|
+
readonly name: "id";
|
|
525
|
+
}];
|
|
526
|
+
readonly outputs: readonly [];
|
|
527
|
+
}, {
|
|
528
|
+
readonly name: "revokeAllExisting";
|
|
529
|
+
readonly type: "function";
|
|
530
|
+
readonly stateMutability: "nonpayable";
|
|
531
|
+
readonly inputs: readonly [];
|
|
532
|
+
readonly outputs: readonly [];
|
|
533
|
+
}, {
|
|
534
|
+
readonly name: "disabled";
|
|
535
|
+
readonly type: "function";
|
|
536
|
+
readonly stateMutability: "view";
|
|
537
|
+
readonly inputs: readonly [{
|
|
538
|
+
readonly type: "address";
|
|
539
|
+
readonly name: "issuer";
|
|
540
|
+
}, {
|
|
541
|
+
readonly type: "uint256";
|
|
542
|
+
readonly name: "id";
|
|
543
|
+
}];
|
|
544
|
+
readonly outputs: readonly [{
|
|
545
|
+
readonly type: "bool";
|
|
546
|
+
}];
|
|
547
|
+
}];
|
|
548
|
+
declare const ACP_SHARE_REGISTRY_ABI: readonly [{
|
|
549
|
+
readonly name: "share";
|
|
550
|
+
readonly type: "function";
|
|
551
|
+
readonly stateMutability: "nonpayable";
|
|
552
|
+
readonly inputs: readonly [{
|
|
553
|
+
readonly type: "tuple";
|
|
554
|
+
readonly components: readonly [{
|
|
555
|
+
readonly type: "address";
|
|
556
|
+
readonly name: "issuer";
|
|
557
|
+
}, {
|
|
558
|
+
readonly type: "uint64";
|
|
559
|
+
readonly name: "expiration";
|
|
560
|
+
}, {
|
|
561
|
+
readonly type: "address";
|
|
562
|
+
readonly name: "recipient";
|
|
563
|
+
}, {
|
|
564
|
+
readonly type: "uint256";
|
|
565
|
+
readonly name: "revokerData";
|
|
566
|
+
}, {
|
|
567
|
+
readonly type: "address";
|
|
568
|
+
readonly name: "revokerContract";
|
|
569
|
+
}, {
|
|
570
|
+
readonly type: "uint8";
|
|
571
|
+
readonly name: "scope";
|
|
572
|
+
}, {
|
|
573
|
+
readonly type: "address[]";
|
|
574
|
+
readonly name: "contracts";
|
|
575
|
+
}, {
|
|
576
|
+
readonly type: "bytes32[]";
|
|
577
|
+
readonly name: "handles";
|
|
578
|
+
}, {
|
|
579
|
+
readonly type: "bytes32";
|
|
580
|
+
readonly name: "sealingKey";
|
|
581
|
+
}, {
|
|
582
|
+
readonly type: "bytes";
|
|
583
|
+
readonly name: "issuerSignature";
|
|
584
|
+
}, {
|
|
585
|
+
readonly type: "bytes";
|
|
586
|
+
readonly name: "recipientSignature";
|
|
587
|
+
}];
|
|
588
|
+
readonly name: "acp";
|
|
589
|
+
}, {
|
|
590
|
+
readonly type: "bytes";
|
|
591
|
+
readonly name: "metadata";
|
|
592
|
+
}];
|
|
593
|
+
readonly outputs: readonly [{
|
|
594
|
+
readonly type: "bytes32";
|
|
595
|
+
}];
|
|
596
|
+
}, {
|
|
597
|
+
readonly name: "removeShare";
|
|
598
|
+
readonly type: "function";
|
|
599
|
+
readonly stateMutability: "nonpayable";
|
|
600
|
+
readonly inputs: readonly [{
|
|
601
|
+
readonly type: "bytes32";
|
|
602
|
+
readonly name: "shareId";
|
|
603
|
+
}];
|
|
604
|
+
readonly outputs: readonly [];
|
|
605
|
+
}, {
|
|
606
|
+
readonly name: "sharesFor";
|
|
607
|
+
readonly type: "function";
|
|
608
|
+
readonly stateMutability: "view";
|
|
609
|
+
readonly inputs: readonly [{
|
|
610
|
+
readonly type: "address";
|
|
611
|
+
readonly name: "recipient";
|
|
612
|
+
}];
|
|
613
|
+
readonly outputs: readonly [{
|
|
614
|
+
readonly type: "bytes32[]";
|
|
615
|
+
readonly name: "shareIds";
|
|
616
|
+
}, {
|
|
617
|
+
readonly type: "tuple[]";
|
|
618
|
+
readonly components: readonly [{
|
|
619
|
+
readonly type: "address";
|
|
620
|
+
readonly name: "issuer";
|
|
621
|
+
}, {
|
|
622
|
+
readonly type: "uint64";
|
|
623
|
+
readonly name: "expiration";
|
|
624
|
+
}, {
|
|
625
|
+
readonly type: "address";
|
|
626
|
+
readonly name: "recipient";
|
|
627
|
+
}, {
|
|
628
|
+
readonly type: "uint64";
|
|
629
|
+
readonly name: "blockNumber";
|
|
630
|
+
}, {
|
|
631
|
+
readonly type: "address";
|
|
632
|
+
readonly name: "revokerContract";
|
|
633
|
+
}, {
|
|
634
|
+
readonly type: "uint256";
|
|
635
|
+
readonly name: "revokerData";
|
|
636
|
+
}];
|
|
637
|
+
readonly name: "headers";
|
|
638
|
+
}];
|
|
639
|
+
}, {
|
|
640
|
+
readonly name: "getShare";
|
|
641
|
+
readonly type: "function";
|
|
642
|
+
readonly stateMutability: "view";
|
|
643
|
+
readonly inputs: readonly [{
|
|
644
|
+
readonly type: "bytes32";
|
|
645
|
+
readonly name: "shareId";
|
|
646
|
+
}];
|
|
647
|
+
readonly outputs: readonly [{
|
|
648
|
+
readonly type: "tuple";
|
|
649
|
+
readonly components: readonly [{
|
|
650
|
+
readonly type: "address";
|
|
651
|
+
readonly name: "issuer";
|
|
652
|
+
}, {
|
|
653
|
+
readonly type: "uint64";
|
|
654
|
+
readonly name: "expiration";
|
|
655
|
+
}, {
|
|
656
|
+
readonly type: "address";
|
|
657
|
+
readonly name: "recipient";
|
|
658
|
+
}, {
|
|
659
|
+
readonly type: "uint64";
|
|
660
|
+
readonly name: "blockNumber";
|
|
661
|
+
}, {
|
|
662
|
+
readonly type: "address";
|
|
663
|
+
readonly name: "revokerContract";
|
|
664
|
+
}, {
|
|
665
|
+
readonly type: "uint256";
|
|
666
|
+
readonly name: "revokerData";
|
|
667
|
+
}];
|
|
668
|
+
}];
|
|
669
|
+
}, {
|
|
670
|
+
readonly name: "isShareValid";
|
|
671
|
+
readonly type: "function";
|
|
672
|
+
readonly stateMutability: "view";
|
|
673
|
+
readonly inputs: readonly [{
|
|
674
|
+
readonly type: "bytes32";
|
|
675
|
+
readonly name: "shareId";
|
|
676
|
+
}];
|
|
677
|
+
readonly outputs: readonly [{
|
|
678
|
+
readonly type: "bool";
|
|
679
|
+
}];
|
|
680
|
+
}, {
|
|
681
|
+
readonly name: "Shared";
|
|
682
|
+
readonly type: "event";
|
|
683
|
+
readonly inputs: readonly [{
|
|
684
|
+
readonly type: "address";
|
|
685
|
+
readonly name: "recipient";
|
|
686
|
+
readonly indexed: true;
|
|
687
|
+
}, {
|
|
688
|
+
readonly type: "address";
|
|
689
|
+
readonly name: "issuer";
|
|
690
|
+
readonly indexed: true;
|
|
691
|
+
}, {
|
|
692
|
+
readonly type: "bytes32";
|
|
693
|
+
readonly name: "shareId";
|
|
694
|
+
readonly indexed: true;
|
|
695
|
+
}, {
|
|
696
|
+
readonly type: "tuple";
|
|
697
|
+
readonly components: readonly [{
|
|
698
|
+
readonly type: "address";
|
|
699
|
+
readonly name: "issuer";
|
|
700
|
+
}, {
|
|
701
|
+
readonly type: "uint64";
|
|
702
|
+
readonly name: "expiration";
|
|
703
|
+
}, {
|
|
704
|
+
readonly type: "address";
|
|
705
|
+
readonly name: "recipient";
|
|
706
|
+
}, {
|
|
707
|
+
readonly type: "uint256";
|
|
708
|
+
readonly name: "revokerData";
|
|
709
|
+
}, {
|
|
710
|
+
readonly type: "address";
|
|
711
|
+
readonly name: "revokerContract";
|
|
712
|
+
}, {
|
|
713
|
+
readonly type: "uint8";
|
|
714
|
+
readonly name: "scope";
|
|
715
|
+
}, {
|
|
716
|
+
readonly type: "address[]";
|
|
717
|
+
readonly name: "contracts";
|
|
718
|
+
}, {
|
|
719
|
+
readonly type: "bytes32[]";
|
|
720
|
+
readonly name: "handles";
|
|
721
|
+
}, {
|
|
722
|
+
readonly type: "bytes32";
|
|
723
|
+
readonly name: "sealingKey";
|
|
724
|
+
}, {
|
|
725
|
+
readonly type: "bytes";
|
|
726
|
+
readonly name: "issuerSignature";
|
|
727
|
+
}, {
|
|
728
|
+
readonly type: "bytes";
|
|
729
|
+
readonly name: "recipientSignature";
|
|
730
|
+
}];
|
|
731
|
+
readonly name: "acp";
|
|
732
|
+
}, {
|
|
733
|
+
readonly type: "bytes";
|
|
734
|
+
readonly name: "metadata";
|
|
735
|
+
}];
|
|
736
|
+
}, {
|
|
737
|
+
readonly name: "ShareRemoved";
|
|
738
|
+
readonly type: "event";
|
|
739
|
+
readonly inputs: readonly [{
|
|
740
|
+
readonly type: "address";
|
|
741
|
+
readonly name: "recipient";
|
|
742
|
+
readonly indexed: true;
|
|
743
|
+
}, {
|
|
744
|
+
readonly type: "address";
|
|
745
|
+
readonly name: "issuer";
|
|
746
|
+
readonly indexed: true;
|
|
747
|
+
}, {
|
|
748
|
+
readonly type: "bytes32";
|
|
749
|
+
readonly name: "shareId";
|
|
750
|
+
readonly indexed: true;
|
|
751
|
+
}];
|
|
752
|
+
}];
|
|
753
|
+
declare const ACP_SHARE_TUPLE_ABI: readonly [{
|
|
754
|
+
readonly type: "tuple";
|
|
755
|
+
readonly components: readonly [{
|
|
756
|
+
readonly name: "issuer";
|
|
757
|
+
readonly type: "address";
|
|
758
|
+
}, {
|
|
759
|
+
readonly name: "expiration";
|
|
760
|
+
readonly type: "uint64";
|
|
761
|
+
}, {
|
|
762
|
+
readonly name: "recipient";
|
|
763
|
+
readonly type: "address";
|
|
764
|
+
}, {
|
|
765
|
+
readonly name: "revokerData";
|
|
766
|
+
readonly type: "uint256";
|
|
767
|
+
}, {
|
|
768
|
+
readonly name: "revokerContract";
|
|
769
|
+
readonly type: "address";
|
|
770
|
+
}, {
|
|
771
|
+
readonly name: "scope";
|
|
772
|
+
readonly type: "uint8";
|
|
773
|
+
}, {
|
|
774
|
+
readonly name: "contracts";
|
|
775
|
+
readonly type: "address[]";
|
|
776
|
+
}, {
|
|
777
|
+
readonly name: "handles";
|
|
778
|
+
readonly type: "bytes32[]";
|
|
779
|
+
}, {
|
|
780
|
+
readonly name: "sealingKey";
|
|
781
|
+
readonly type: "bytes32";
|
|
782
|
+
}, {
|
|
783
|
+
readonly name: "issuerSignature";
|
|
784
|
+
readonly type: "bytes";
|
|
785
|
+
}, {
|
|
786
|
+
readonly name: "recipientSignature";
|
|
787
|
+
readonly type: "bytes";
|
|
788
|
+
}];
|
|
789
|
+
}];
|
|
790
|
+
/** The on-chain payload for a sharing ACP: recipient-side fields empty. */
|
|
791
|
+
declare const toChainShare: (acp: ACP) => {
|
|
792
|
+
expiration: bigint;
|
|
793
|
+
revokerData: bigint;
|
|
794
|
+
sealingKey: `0x${string}`;
|
|
795
|
+
recipientSignature: Hex;
|
|
796
|
+
issuer: Hex;
|
|
797
|
+
recipient: Hex;
|
|
798
|
+
revokerContract: Hex;
|
|
799
|
+
scope: number;
|
|
800
|
+
contracts: Hex[];
|
|
801
|
+
handles: Hex[];
|
|
802
|
+
issuerSignature: Hex;
|
|
803
|
+
};
|
|
804
|
+
/** Mirrors the registry's `keccak256(abi.encode(acp))` share id. */
|
|
805
|
+
declare const computeShareId: (acp: ACP) => Hex;
|
|
806
|
+
/** The share id of a registry payload as read back from a `Shared` event. */
|
|
807
|
+
declare const shareIdOfChainShare: (share: ChainShare) => Hex;
|
|
808
|
+
/** A registry payload, as decoded from a `Shared` event (or passed to `share`). */
|
|
809
|
+
type ChainShare = AbiParameterToPrimitiveType<(typeof ACP_SHARE_TUPLE_ABI)[0]>;
|
|
810
|
+
/** What the registry stores of a share: the fields it checks, and the block of its `Shared` event. */
|
|
811
|
+
type ShareHeader = {
|
|
812
|
+
issuer: Address;
|
|
813
|
+
expiration: bigint;
|
|
814
|
+
recipient: Address;
|
|
815
|
+
/** Block of the `Shared` event (the L2 block on Arbitrum). */
|
|
816
|
+
blockNumber: bigint;
|
|
817
|
+
revokerContract: Address;
|
|
818
|
+
revokerData: bigint;
|
|
819
|
+
};
|
|
820
|
+
/** A share as posted: its payload and the metadata blob that came with it (`0x` when none). */
|
|
821
|
+
type PostedShare = {
|
|
822
|
+
shareId: Hex;
|
|
823
|
+
header: ShareHeader;
|
|
824
|
+
share: ChainShare;
|
|
825
|
+
metadata: Hex;
|
|
826
|
+
};
|
|
827
|
+
/** A share the registry lists but whose `Shared` event could not be read, and why. */
|
|
828
|
+
type UnreadableShare = {
|
|
829
|
+
shareId: Hex;
|
|
830
|
+
header: ShareHeader;
|
|
831
|
+
reason: string;
|
|
832
|
+
};
|
|
833
|
+
/** Shares read from their events, and those that could not be; each share is on its own. */
|
|
834
|
+
type PostedShares = {
|
|
835
|
+
posted: PostedShare[];
|
|
836
|
+
unreadable: UnreadableShare[];
|
|
837
|
+
};
|
|
838
|
+
/**
|
|
839
|
+
* Fetches the `Shared` events of shares from the blocks their headers name: one single-block
|
|
840
|
+
* `getLogs` per distinct block, filtered by registry and share ids, so any node answers it. Returns
|
|
841
|
+
* the shares in the order given; where a block holds several events for one share id, the last.
|
|
842
|
+
* Never fails as a whole: a share whose block the node cannot serve yet, whose event is missing
|
|
843
|
+
* from it, or whose event payload does not hash to its id is returned as `unreadable`, with the
|
|
844
|
+
* reason, and the rest are posted as usual.
|
|
845
|
+
*/
|
|
846
|
+
declare const readPostedShares: (publicClient: PublicClient, registry: Address, headers: readonly {
|
|
847
|
+
shareId: Hex;
|
|
848
|
+
header: ShareHeader;
|
|
849
|
+
}[]) => Promise<PostedShares>;
|
|
850
|
+
/**
|
|
851
|
+
* The importable shares addressed to `recipient` (unexpired, not revoked), read from their events;
|
|
852
|
+
* those whose event could not be read are listed apart, so one of them never hides the rest.
|
|
853
|
+
*/
|
|
854
|
+
declare const readSharesFor: (publicClient: PublicClient, registry: Address, recipient: Address) => Promise<PostedShares>;
|
|
855
|
+
/**
|
|
856
|
+
* One share by id, read from its event; null when the registry has no such share (unknown or
|
|
857
|
+
* removed). Throws, with the reason, when the registry lists it but its event could not be read.
|
|
858
|
+
*/
|
|
859
|
+
declare const readShare: (publicClient: PublicClient, registry: Address, shareId: Hex) => Promise<PostedShare | null>;
|
|
860
|
+
|
|
507
861
|
/**
|
|
508
862
|
* - `verified`: the chain confirms the label.
|
|
509
863
|
* - `mismatch`: the chain contradicts it.
|
|
@@ -552,10 +906,10 @@ declare const clearAclServedAddresses: () => void;
|
|
|
552
906
|
* TaskManager -> acl() -> getters). Zero addresses and pre-upgrade ACLs (getters absent -> revert)
|
|
553
907
|
* resolve to `undefined` — callers fall back to `acp.*` config.
|
|
554
908
|
*
|
|
555
|
-
* Resolutions are cached per chainId. A failure to reach the TaskManager
|
|
556
|
-
* error, no CoFHE deployment) is NOT cached, so a transient outage
|
|
557
|
-
* an empty result for the whole session.
|
|
909
|
+
* Resolutions are cached per chainId. A failure to reach the TaskManager or the ACL
|
|
910
|
+
* getters (network error, no CoFHE deployment) is NOT cached, so a transient outage
|
|
911
|
+
* does not pin an empty result for the whole session.
|
|
558
912
|
*/
|
|
559
913
|
declare const getAclServedAddresses: (publicClient: PublicClient, chainId: number) => Promise<AclServedAddresses>;
|
|
560
914
|
|
|
561
|
-
export { type ACP as A, type
|
|
915
|
+
export { type SelfACP as $, type ACP as A, type ChainShare as B, type CreateSelfACPOptions as C, type ShareHeader as D, type EventValueLabel as E, type PostedShares as F, GenerateSealingKey as G, readPostedShares as H, type ImportSharedACPOptions as I, readSharesFor as J, readShare as K, type LabelledShare as L, type ShareLabelReadArg as M, type UnlabelledLabel as N, type LabelVerification as O, type PostedShare as P, type ShareLabelVerifyMode as Q, type ShareLabelCheck as R, type ShareLabel as S, verifyShareLabel as T, type UnreadableShare as U, type ValidationResult as V, verifyShareLabels as W, type EIP712Type as X, type ACPPrivate as Y, type ACPType as Z, type ACPOf as _, type StoredValueLabel as a, type SharingACP as a0, type RecipientACP as a1, ACPScope as a2, type ACPScopeOptions as a3, type ACPAccessStatus as a4, type ACPHashFields as a5, type Expand as a6, type ACPPublic as b, type ACPSignaturePrimaryType as c, type EIP712Types as d, type EIP712Message as e, type SerializedACP as f, type CreateSharingACPOptions as g, type ACPMetadata as h, type SharedACP as i, type IncomingShare as j, type EIP712Domain as k, ACPUtils as l, getAclAddress as m, getAclServedAddresses as n, clearAclServedAddresses as o, type AclServedAddresses as p, type SealingKeyPair as q, type EthEncryptedData as r, seal as s, ACP_REVOKER_ABI as t, unsealWithPrivateKey as u, ACP_SHARE_REGISTRY_ABI as v, ACP_SHARE_TUPLE_ABI as w, toChainShare as x, computeShareId as y, shareIdOfChainShare as z };
|