@jibidieuw/dexes 0.0.2 → 0.1.1
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/LICENSE +21 -0
- package/dist/index.d.mts +157 -115
- package/dist/index.d.ts +157 -115
- package/dist/index.js +237 -176
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +231 -170
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Cryptogram Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address, TransactionReceipt, PublicClient, WalletClient, BlockTag } from 'viem';
|
|
1
|
+
import { Address, TransactionReceipt, PublicClient, Transport, Chain, WalletClient, BlockTag } from 'viem';
|
|
2
2
|
import * as openpgp from 'openpgp';
|
|
3
3
|
|
|
4
4
|
declare class InvalidHexError extends Error {
|
|
@@ -141,7 +141,7 @@ declare class FlatFee implements IFlatFee {
|
|
|
141
141
|
* @param client A Viem public client for interacting with the blockchain.
|
|
142
142
|
* @param walletClient Optional Viem wallet client for signing transactions.
|
|
143
143
|
*/
|
|
144
|
-
constructor(address: Address, client: PublicClient, walletClient?: WalletClient);
|
|
144
|
+
constructor(address: Address, client: PublicClient<Transport, Chain | undefined>, walletClient?: WalletClient);
|
|
145
145
|
/*****************************************************************************************************************/
|
|
146
146
|
/*****************************************************************************************************************/
|
|
147
147
|
/**
|
|
@@ -159,7 +159,7 @@ declare class FlatFee implements IFlatFee {
|
|
|
159
159
|
/**
|
|
160
160
|
* Sets the Viem public client.
|
|
161
161
|
*/
|
|
162
|
-
set client(client: PublicClient);
|
|
162
|
+
set client(client: PublicClient<Transport, Chain | undefined>);
|
|
163
163
|
/**
|
|
164
164
|
* Gets the Viem wallet client.
|
|
165
165
|
*/
|
|
@@ -667,13 +667,14 @@ interface IWeb3PGPService {
|
|
|
667
667
|
*
|
|
668
668
|
* @description
|
|
669
669
|
* This method:
|
|
670
|
-
* 1. Verifies the provided public key and subkeys have a valid signature, are not expired and not revoked.
|
|
670
|
+
* 1. (If not insecure) Verifies the provided public key and subkeys have a valid signature, are not expired and not revoked.
|
|
671
671
|
* 2. Extracts the primary key fingerprint and subkey fingerprints
|
|
672
672
|
* 3. Ensures the key and its subkeys are not registered on-chain (enforced by smart contract).
|
|
673
673
|
* 4. Serializes the key into the OpenPGP binary format.
|
|
674
674
|
* 5. Registers the key on-chain via the Web3PGP contract
|
|
675
675
|
*
|
|
676
676
|
* @param key The OpenPGP public key to register (may include subkeys)
|
|
677
|
+
* @param insecure If true, skips cryptographic verifications of the key and subkeys. Defaults to false.
|
|
677
678
|
* @returns Transaction receipt after successful registration
|
|
678
679
|
*
|
|
679
680
|
* @throws Error if the key or one of its subkeys are invalid
|
|
@@ -689,7 +690,7 @@ interface IWeb3PGPService {
|
|
|
689
690
|
* console.log(`Key registered at block ${receipt.blockNumber}`);
|
|
690
691
|
* ```
|
|
691
692
|
*/
|
|
692
|
-
register(key: openpgp.PublicKey): Promise<TransactionReceipt>;
|
|
693
|
+
register(key: openpgp.PublicKey, insecure?: boolean): Promise<TransactionReceipt>;
|
|
693
694
|
/**
|
|
694
695
|
* Update an existing OpenPGP public key on the blockchain to add or revoke user ID packets,
|
|
695
696
|
* change preferences or update key expiration.
|
|
@@ -1980,7 +1981,7 @@ declare class Web3PGP extends FlatFee implements IWeb3PGP {
|
|
|
1980
1981
|
private static readonly OWNERSHIP_PROVED_EVENT;
|
|
1981
1982
|
private static readonly KEY_CERTIFIED_EVENT;
|
|
1982
1983
|
private static readonly KEY_CERTIFICATION_REVOKED_EVENT;
|
|
1983
|
-
constructor(address: `0x${string}`, client: PublicClient, walletClient?: WalletClient);
|
|
1984
|
+
constructor(address: `0x${string}`, client: PublicClient<Transport, Chain | undefined>, walletClient?: WalletClient);
|
|
1984
1985
|
/*****************************************************************************************************************/
|
|
1985
1986
|
/*****************************************************************************************************************/
|
|
1986
1987
|
/**
|
|
@@ -2300,8 +2301,8 @@ declare class Web3PGPServiceError extends Error {
|
|
|
2300
2301
|
* This error indicates a serious problem that prevents the operation from continuing such as network failures and others has occurred.
|
|
2301
2302
|
*/
|
|
2302
2303
|
declare class Web3PGPServiceCriticalError extends Web3PGPServiceError {
|
|
2303
|
-
readonly cause?: Error
|
|
2304
|
-
constructor(message: string, cause?: Error
|
|
2304
|
+
readonly cause?: Error;
|
|
2305
|
+
constructor(message: string, cause?: Error);
|
|
2305
2306
|
}
|
|
2306
2307
|
/**
|
|
2307
2308
|
* Error thrown when key or blockchain data validation fails.
|
|
@@ -2406,7 +2407,7 @@ declare class Web3PGPService implements IWeb3PGPService {
|
|
|
2406
2407
|
* console.log(`Key registered at block ${receipt.blockNumber}`);
|
|
2407
2408
|
* ```
|
|
2408
2409
|
*/
|
|
2409
|
-
register(key: openpgp.PublicKey): Promise<TransactionReceipt>;
|
|
2410
|
+
register(key: openpgp.PublicKey, insecure?: boolean): Promise<TransactionReceipt>;
|
|
2410
2411
|
/**
|
|
2411
2412
|
* Update an existing OpenPGP public key on the blockchain to add or revoke user ID packets,
|
|
2412
2413
|
* change preferences or update key expiration.
|
|
@@ -2747,42 +2748,42 @@ declare class Web3PGPService implements IWeb3PGPService {
|
|
|
2747
2748
|
*/
|
|
2748
2749
|
extractFromKeyRevokedLog(log: KeyRevokedLog, skipCryptographicVerifications?: boolean): Promise<[openpgp.PublicKey | undefined, string | undefined]>;
|
|
2749
2750
|
/**
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2751
|
+
* Validate and extract the updated public key from a KeyUpdatedLog event.
|
|
2752
|
+
*
|
|
2753
|
+
* @description
|
|
2754
|
+
* This method:
|
|
2755
|
+
* 1. Validates the log data contains required fields
|
|
2756
|
+
* 2. Extracts and parses the OpenPGP message from the log
|
|
2757
|
+
* 3. Verifies the primary key fingerprint matches the declared one
|
|
2758
|
+
* 4. (if verifications are enabled) Verifies the primary key has a valid signature, is not expired and is not
|
|
2759
|
+
* revoked at the time of update (uses the block timestamp).
|
|
2760
|
+
*
|
|
2761
|
+
* Cryptographic verifications of the key (step 4) can be skipped by setting the `skipCryptographicVerifications`
|
|
2762
|
+
* parameter to true. This is useful when users want to extract and parse the OpenPGP key material in order to perform
|
|
2763
|
+
* custom validations or inspections in case the verification fails, is expected to fail or is performed by an external
|
|
2764
|
+
* OpenPGP toolkit.
|
|
2765
|
+
*
|
|
2766
|
+
* @param log The KeyUpdatedLog event data from the blockchain
|
|
2767
|
+
* @param skipCryptographicVerifications If true, skips cryptographic verifications of key. Defaults to false.
|
|
2768
|
+
* @returns The validated OpenPGP public key extracted from the log
|
|
2769
|
+
*
|
|
2770
|
+
* @throws Web3PGPServiceValidationError if the log data is invalid or missing required fields
|
|
2771
|
+
* @throws Web3PGPServiceValidationError if the extracted OpenPGP message is invalid or corrupted
|
|
2772
|
+
* @throws Web3PGPServiceValidationError if the primary key fingerprint does not match the log data
|
|
2773
|
+
*
|
|
2774
|
+
* @example
|
|
2775
|
+
* ```typescript
|
|
2776
|
+
* const logs = await web3pgp.searchKeyUpdatedLogs();
|
|
2777
|
+
* for (const log of logs) {
|
|
2778
|
+
* try {
|
|
2779
|
+
* const publicKey = await service.extractFromKeyUpdatedLog(log);
|
|
2780
|
+
* console.log(`Valid updated key: ${publicKey.getFingerprint()}`);
|
|
2781
|
+
* } catch (err) {
|
|
2782
|
+
* console.warn(`Invalid log data: ${err.message}`);
|
|
2783
|
+
* }
|
|
2784
|
+
* }
|
|
2785
|
+
* ```
|
|
2786
|
+
*/
|
|
2786
2787
|
extractFromKeyUpdatedLog(log: KeyUpdatedLog, skipCryptographicVerifications?: boolean): Promise<openpgp.PublicKey>;
|
|
2787
2788
|
/**
|
|
2788
2789
|
* Validate and extract the certified public key from a KeyCertifiedLog event.
|
|
@@ -2940,9 +2941,9 @@ declare enum EventType {
|
|
|
2940
2941
|
COPY = 1
|
|
2941
2942
|
}
|
|
2942
2943
|
/**
|
|
2943
|
-
* Constants representing the different event types emitted by the
|
|
2944
|
+
* Constants representing the different event types emitted by the Web3Sign smart contract.
|
|
2944
2945
|
*/
|
|
2945
|
-
declare const
|
|
2946
|
+
declare const Web3SignEvents: {
|
|
2946
2947
|
readonly Document: "Document";
|
|
2947
2948
|
readonly Copy: "Copy";
|
|
2948
2949
|
readonly Notification: "Notification";
|
|
@@ -2962,7 +2963,7 @@ declare const Web3DocEvents: {
|
|
|
2962
2963
|
* @property mimeType Optional, The MIME type of the document and additional attributes (RFC6838)
|
|
2963
2964
|
*/
|
|
2964
2965
|
type DocumentLog = BaseLog & {
|
|
2965
|
-
type: typeof
|
|
2966
|
+
type: typeof Web3SignEvents.Document;
|
|
2966
2967
|
id: bigint;
|
|
2967
2968
|
emitter: `0x${string}`;
|
|
2968
2969
|
dochash: `0x${string}`;
|
|
@@ -2981,7 +2982,7 @@ type DocumentLog = BaseLog & {
|
|
|
2981
2982
|
* @property uri The URI which can be used to download the binary OpenPGP message containing the document from an off-chain storage.
|
|
2982
2983
|
*/
|
|
2983
2984
|
type CopyLog = BaseLog & {
|
|
2984
|
-
type: typeof
|
|
2985
|
+
type: typeof Web3SignEvents.Copy;
|
|
2985
2986
|
copy: bigint;
|
|
2986
2987
|
original: bigint;
|
|
2987
2988
|
emitter: `0x${string}`;
|
|
@@ -2998,7 +2999,7 @@ type CopyLog = BaseLog & {
|
|
|
2998
2999
|
* @property signatureRequested If true, the recipient is prompted by the emitter to sign the document.
|
|
2999
3000
|
*/
|
|
3000
3001
|
type NotificationLog = BaseLog & {
|
|
3001
|
-
type: typeof
|
|
3002
|
+
type: typeof Web3SignEvents.Notification;
|
|
3002
3003
|
id: bigint;
|
|
3003
3004
|
emitter: `0x${string}`;
|
|
3004
3005
|
recipient: `0x${string}`;
|
|
@@ -3014,7 +3015,7 @@ type NotificationLog = BaseLog & {
|
|
|
3014
3015
|
* @property signature The binary OpenPGP message which contains the detached signature over the document.
|
|
3015
3016
|
*/
|
|
3016
3017
|
type SignatureLog = BaseLog & {
|
|
3017
|
-
type: typeof
|
|
3018
|
+
type: typeof Web3SignEvents.Signature;
|
|
3018
3019
|
id: bigint;
|
|
3019
3020
|
emitter: `0x${string}`;
|
|
3020
3021
|
signatureHash: `0x${string}`;
|
|
@@ -3029,7 +3030,7 @@ type SignatureLog = BaseLog & {
|
|
|
3029
3030
|
* @property signature A detached binary OpenPGP signature created over the signature hash.
|
|
3030
3031
|
*/
|
|
3031
3032
|
type SignatureRevocationLog = BaseLog & {
|
|
3032
|
-
type: typeof
|
|
3033
|
+
type: typeof Web3SignEvents.SignatureRevocation;
|
|
3033
3034
|
id: bigint;
|
|
3034
3035
|
emitter: `0x${string}`;
|
|
3035
3036
|
signatureHash: `0x${string}`;
|
|
@@ -3044,7 +3045,7 @@ type SignatureRevocationLog = BaseLog & {
|
|
|
3044
3045
|
* @property signature A detached binary OpenPGP signature created over the keccak256 hash of the document.
|
|
3045
3046
|
*/
|
|
3046
3047
|
type TimestampLog = BaseLog & {
|
|
3047
|
-
type: typeof
|
|
3048
|
+
type: typeof Web3SignEvents.Timestamp;
|
|
3048
3049
|
id: bigint;
|
|
3049
3050
|
emitter: `0x${string}`;
|
|
3050
3051
|
dochash: `0x${string}`;
|
|
@@ -3052,11 +3053,11 @@ type TimestampLog = BaseLog & {
|
|
|
3052
3053
|
};
|
|
3053
3054
|
|
|
3054
3055
|
/**
|
|
3055
|
-
* TypeScript interface for the
|
|
3056
|
+
* TypeScript interface for the Web3Sign smart contract.
|
|
3056
3057
|
*
|
|
3057
|
-
* This interface provides low-level bindings to interact with the
|
|
3058
|
+
* This interface provides low-level bindings to interact with the Web3Sign contract deployed on the blockchain.
|
|
3058
3059
|
*/
|
|
3059
|
-
interface
|
|
3060
|
+
interface IWeb3Sign extends IFlatFee {
|
|
3060
3061
|
/*****************************************************************************************************************/
|
|
3061
3062
|
/*****************************************************************************************************************/
|
|
3062
3063
|
/**
|
|
@@ -3377,17 +3378,17 @@ interface IWeb3Doc extends IFlatFee {
|
|
|
3377
3378
|
}
|
|
3378
3379
|
|
|
3379
3380
|
/**
|
|
3380
|
-
* Interface representing the
|
|
3381
|
+
* Interface representing the Web3Sign service for managing documents on the blockchain.
|
|
3381
3382
|
*
|
|
3382
3383
|
* Higher order bindings are provided and involve OpenPGP operations in order to ease the overall developer experience.
|
|
3383
3384
|
*
|
|
3384
3385
|
* @todo Add methods for document exchange (sendDocument, sendCopy, notifyRecipients, ...)
|
|
3385
3386
|
*/
|
|
3386
|
-
interface
|
|
3387
|
+
interface IWeb3SignService {
|
|
3387
3388
|
/*****************************************************************************************************************/
|
|
3388
3389
|
/*****************************************************************************************************************/
|
|
3389
3390
|
/**
|
|
3390
|
-
* This function allows submitting the data needed to timestamp a document to the
|
|
3391
|
+
* This function allows submitting the data needed to timestamp a document to the Web3Sign smart contract.
|
|
3391
3392
|
*
|
|
3392
3393
|
* The function will download and verify the emitter's public key using the Web3PGP contract and then it will verify
|
|
3393
3394
|
* the provided detached signature over the keccak256 hash of the document. If the signature is valid, it will submit
|
|
@@ -3404,7 +3405,7 @@ interface IWeb3DocService {
|
|
|
3404
3405
|
timestamp(hash: Uint8Array, signature: openpgp.Signature, emitter: `0x${string}`): Promise<[bigint, TransactionReceipt]>;
|
|
3405
3406
|
/**
|
|
3406
3407
|
* Verifies a timestamp entry on the blockchain by its ID. The function retrieves the timestamp data from the
|
|
3407
|
-
*
|
|
3408
|
+
* Web3Sign smart contract and verifies the detached signature over the document hash using the emitter's public key.
|
|
3408
3409
|
*
|
|
3409
3410
|
* The function returns the document hash, the signature, and the public key used for verification.
|
|
3410
3411
|
*
|
|
@@ -3432,12 +3433,12 @@ interface IWeb3DocService {
|
|
|
3432
3433
|
}
|
|
3433
3434
|
|
|
3434
3435
|
/**
|
|
3435
|
-
* Implementation of the
|
|
3436
|
+
* Implementation of the Web3Sign contract interface.
|
|
3436
3437
|
*
|
|
3437
|
-
* This class provides low-level bindings to interact with the
|
|
3438
|
+
* This class provides low-level bindings to interact with the Web3Sign contract deployed on the blockchain.
|
|
3438
3439
|
* Extends FlatFee to inherit fee management and access control functionality.
|
|
3439
3440
|
*/
|
|
3440
|
-
declare class
|
|
3441
|
+
declare class Web3Sign extends FlatFee implements IWeb3Sign {
|
|
3441
3442
|
static readonly abi: readonly [{
|
|
3442
3443
|
readonly type: "constructor";
|
|
3443
3444
|
readonly inputs: readonly [];
|
|
@@ -3479,7 +3480,7 @@ declare class Web3Doc extends FlatFee implements IWeb3Doc {
|
|
|
3479
3480
|
}, {
|
|
3480
3481
|
readonly name: "recipients";
|
|
3481
3482
|
readonly type: "tuple[]";
|
|
3482
|
-
readonly internalType: "struct
|
|
3483
|
+
readonly internalType: "struct IWeb3Sign.Recipient[]";
|
|
3483
3484
|
readonly components: readonly [{
|
|
3484
3485
|
readonly name: "fingerprint";
|
|
3485
3486
|
readonly type: "bytes32";
|
|
@@ -3510,7 +3511,7 @@ declare class Web3Doc extends FlatFee implements IWeb3Doc {
|
|
|
3510
3511
|
}, {
|
|
3511
3512
|
readonly name: "recipients";
|
|
3512
3513
|
readonly type: "tuple[]";
|
|
3513
|
-
readonly internalType: "struct
|
|
3514
|
+
readonly internalType: "struct IWeb3Sign.Recipient[]";
|
|
3514
3515
|
readonly components: readonly [{
|
|
3515
3516
|
readonly name: "fingerprint";
|
|
3516
3517
|
readonly type: "bytes32";
|
|
@@ -3759,7 +3760,7 @@ declare class Web3Doc extends FlatFee implements IWeb3Doc {
|
|
|
3759
3760
|
}, {
|
|
3760
3761
|
readonly name: "recipients";
|
|
3761
3762
|
readonly type: "tuple[]";
|
|
3762
|
-
readonly internalType: "struct
|
|
3763
|
+
readonly internalType: "struct IWeb3Sign.Recipient[]";
|
|
3763
3764
|
readonly components: readonly [{
|
|
3764
3765
|
readonly name: "fingerprint";
|
|
3765
3766
|
readonly type: "bytes32";
|
|
@@ -3798,7 +3799,7 @@ declare class Web3Doc extends FlatFee implements IWeb3Doc {
|
|
|
3798
3799
|
}, {
|
|
3799
3800
|
readonly name: "recipients";
|
|
3800
3801
|
readonly type: "tuple[]";
|
|
3801
|
-
readonly internalType: "struct
|
|
3802
|
+
readonly internalType: "struct IWeb3Sign.Recipient[]";
|
|
3802
3803
|
readonly components: readonly [{
|
|
3803
3804
|
readonly name: "fingerprint";
|
|
3804
3805
|
readonly type: "bytes32";
|
|
@@ -4034,7 +4035,7 @@ declare class Web3Doc extends FlatFee implements IWeb3Doc {
|
|
|
4034
4035
|
readonly name: "source";
|
|
4035
4036
|
readonly type: "uint8";
|
|
4036
4037
|
readonly indexed: false;
|
|
4037
|
-
readonly internalType: "enum
|
|
4038
|
+
readonly internalType: "enum IWeb3Sign.EventType";
|
|
4038
4039
|
}, {
|
|
4039
4040
|
readonly name: "signatureRequested";
|
|
4040
4041
|
readonly type: "bool";
|
|
@@ -4290,9 +4291,9 @@ declare class Web3Doc extends FlatFee implements IWeb3Doc {
|
|
|
4290
4291
|
private static readonly SIGNATURE_REVOCATION_EVENT;
|
|
4291
4292
|
private static readonly TIMESTAMP_EVENT;
|
|
4292
4293
|
/**
|
|
4293
|
-
* Creates a new
|
|
4294
|
+
* Creates a new Web3Sign instance.
|
|
4294
4295
|
*
|
|
4295
|
-
* @param address The address of the
|
|
4296
|
+
* @param address The address of the Web3Sign smart contract.
|
|
4296
4297
|
* @param web3pgp An instance implementing the IWeb3PGP interface for public key operations.
|
|
4297
4298
|
* @param client A Viem public client for interacting with the blockchain.
|
|
4298
4299
|
* @param walletClient Optional Viem wallet client for signing transactions.
|
|
@@ -4617,37 +4618,9 @@ declare class Web3Doc extends FlatFee implements IWeb3Doc {
|
|
|
4617
4618
|
/*****************************************************************************************************************/
|
|
4618
4619
|
/*****************************************************************************************************************/
|
|
4619
4620
|
/**
|
|
4620
|
-
*
|
|
4621
|
-
*/
|
|
4622
|
-
declare class Web3DocServiceError extends Error {
|
|
4623
|
-
constructor(message: string);
|
|
4624
|
-
}
|
|
4625
|
-
/**
|
|
4626
|
-
* Error thrown when a critical failure occurs during service operations.
|
|
4627
|
-
*
|
|
4628
|
-
* This error indicates a serious problem that prevents the operation from continuing such as network failures and others has occurred.
|
|
4629
|
-
*/
|
|
4630
|
-
declare class Web3DocServiceCriticalError extends Web3DocServiceError {
|
|
4631
|
-
readonly cause?: Error | undefined;
|
|
4632
|
-
constructor(message: string, cause?: Error | undefined);
|
|
4633
|
-
}
|
|
4634
|
-
/**
|
|
4635
|
-
* Error thrown when document or blockchain data validation fails.
|
|
4636
|
-
*
|
|
4637
|
-
* This can happen because the smart contract does not validate the data it stores, they
|
|
4638
|
-
* have to be verified by the client application. Furthermore, as anyone can submit documents,
|
|
4639
|
-
* malformed or invalid data may be submitted by malicious actors.
|
|
4640
|
-
*/
|
|
4641
|
-
declare class Web3DocServiceValidationError extends Web3DocServiceError {
|
|
4642
|
-
readonly cause?: Error | undefined;
|
|
4643
|
-
constructor(message: string, cause?: Error | undefined);
|
|
4644
|
-
}
|
|
4645
|
-
/*****************************************************************************************************************/
|
|
4646
|
-
/*****************************************************************************************************************/
|
|
4647
|
-
/**
|
|
4648
|
-
* Configuration options for Web3DocService.
|
|
4621
|
+
* Configuration options for Web3SignService.
|
|
4649
4622
|
*/
|
|
4650
|
-
interface
|
|
4623
|
+
interface Web3SignServiceOptions {
|
|
4651
4624
|
/**
|
|
4652
4625
|
* Maximum number of concurrent operations performed when processing documents and verifying signatures.
|
|
4653
4626
|
*
|
|
@@ -4659,30 +4632,30 @@ interface Web3DocServiceOptions {
|
|
|
4659
4632
|
concurrencyLimit?: number;
|
|
4660
4633
|
}
|
|
4661
4634
|
/**
|
|
4662
|
-
* Implementation of the
|
|
4635
|
+
* Implementation of the Web3Sign service interface.
|
|
4663
4636
|
*
|
|
4664
4637
|
* This service provides high-level functions for managing documents on the blockchain with integrated
|
|
4665
4638
|
* OpenPGP operations to ease developer experience.
|
|
4666
4639
|
*/
|
|
4667
|
-
declare class
|
|
4640
|
+
declare class Web3SignService implements IWeb3SignService {
|
|
4668
4641
|
private _web3pgpService;
|
|
4669
|
-
private
|
|
4642
|
+
private _web3sign;
|
|
4670
4643
|
private _options;
|
|
4671
4644
|
/**
|
|
4672
|
-
* Creates a new
|
|
4645
|
+
* Creates a new Web3SignService instance.
|
|
4673
4646
|
*
|
|
4674
|
-
* @param
|
|
4647
|
+
* @param web3sign An instance implementing the IWeb3Sign interface.
|
|
4675
4648
|
* @param options Optional configuration options for the service.
|
|
4676
4649
|
*/
|
|
4677
|
-
constructor(
|
|
4650
|
+
constructor(web3sign: IWeb3Sign, web3pgpService: IWeb3PGPService, options?: Web3SignServiceOptions);
|
|
4678
4651
|
/**
|
|
4679
|
-
* Gets the
|
|
4652
|
+
* Gets the Web3Sign instance.
|
|
4680
4653
|
*/
|
|
4681
|
-
get
|
|
4654
|
+
get web3sign(): IWeb3Sign;
|
|
4682
4655
|
/**
|
|
4683
|
-
* Sets the
|
|
4656
|
+
* Sets the Web3Sign instance.
|
|
4684
4657
|
*/
|
|
4685
|
-
set
|
|
4658
|
+
set web3sign(value: IWeb3Sign);
|
|
4686
4659
|
/**
|
|
4687
4660
|
* Gets the Web3PGP service instance.
|
|
4688
4661
|
*/
|
|
@@ -4694,15 +4667,15 @@ declare class Web3DocService implements IWeb3DocService {
|
|
|
4694
4667
|
/**
|
|
4695
4668
|
* Gets the service configuration options.
|
|
4696
4669
|
*/
|
|
4697
|
-
get options(): Required<
|
|
4670
|
+
get options(): Required<Web3SignServiceOptions>;
|
|
4698
4671
|
/**
|
|
4699
4672
|
* Sets the service configuration options.
|
|
4700
4673
|
*/
|
|
4701
|
-
set options(value: Required<
|
|
4674
|
+
set options(value: Required<Web3SignServiceOptions>);
|
|
4702
4675
|
/*****************************************************************************************************************/
|
|
4703
4676
|
/*****************************************************************************************************************/
|
|
4704
4677
|
/**
|
|
4705
|
-
* This function allows submitting the data needed to timestamp a document to the
|
|
4678
|
+
* This function allows submitting the data needed to timestamp a document to the Web3Sign smart contract.
|
|
4706
4679
|
*
|
|
4707
4680
|
* The function will download and verify the emitter's public key using the Web3PGP contract and then it will verify
|
|
4708
4681
|
* the provided detached signature over the keccak256 hash of the document. If the signature is valid, it will submit
|
|
@@ -4719,7 +4692,7 @@ declare class Web3DocService implements IWeb3DocService {
|
|
|
4719
4692
|
timestamp(hash: Uint8Array, signature: openpgp.Signature, emitter: `0x${string}`): Promise<[bigint, TransactionReceipt]>;
|
|
4720
4693
|
/**
|
|
4721
4694
|
* Verifies a timestamp entry on the blockchain by its ID. The function retrieves the timestamp data from the
|
|
4722
|
-
*
|
|
4695
|
+
* Web3Sign smart contract and verifies the detached signature over the document hash using the emitter's public key.
|
|
4723
4696
|
*
|
|
4724
4697
|
* The function returns the document hash, the signature, and the public key used for verification.
|
|
4725
4698
|
*
|
|
@@ -4746,4 +4719,73 @@ declare class Web3DocService implements IWeb3DocService {
|
|
|
4746
4719
|
findTimestampsByHash(hash: Uint8Array): Promise<bigint[]>;
|
|
4747
4720
|
}
|
|
4748
4721
|
|
|
4749
|
-
|
|
4722
|
+
/**
|
|
4723
|
+
* Base error class for all Web3Sign-related errors.
|
|
4724
|
+
* Extends the native Error class to provide consistent error handling across the Web3Sign system.
|
|
4725
|
+
*/
|
|
4726
|
+
declare class Web3SignError extends Error {
|
|
4727
|
+
/**
|
|
4728
|
+
* Optional underlying error that caused this error.
|
|
4729
|
+
*/
|
|
4730
|
+
cause?: Error | undefined;
|
|
4731
|
+
/**
|
|
4732
|
+
* Creates a new Web3SignError instance.
|
|
4733
|
+
* @param message - Human-readable error description
|
|
4734
|
+
* @param cause - Optional underlying error that caused this error
|
|
4735
|
+
*/
|
|
4736
|
+
constructor(message: string, cause?: Error);
|
|
4737
|
+
}
|
|
4738
|
+
/**
|
|
4739
|
+
* Critical error class for unrecoverable Web3Sign errors.
|
|
4740
|
+
* Used when the system encounters a fatal condition that requires immediate attention.
|
|
4741
|
+
*/
|
|
4742
|
+
declare class Web3SignCriticalError extends Web3SignError {
|
|
4743
|
+
/**
|
|
4744
|
+
* Creates a new Web3SignCriticalError instance.
|
|
4745
|
+
* @param message - Human-readable error description
|
|
4746
|
+
* @param cause - Optional underlying error that caused this error
|
|
4747
|
+
*/
|
|
4748
|
+
constructor(message: string, cause?: Error);
|
|
4749
|
+
}
|
|
4750
|
+
/**
|
|
4751
|
+
* Base error class for Web3Sign service-related errors.
|
|
4752
|
+
* Used for errors that occur during service operations.
|
|
4753
|
+
*/
|
|
4754
|
+
declare class Web3SignServiceError extends Error {
|
|
4755
|
+
/**
|
|
4756
|
+
* Optional underlying error that caused this error.
|
|
4757
|
+
*/
|
|
4758
|
+
cause?: Error | undefined;
|
|
4759
|
+
/**
|
|
4760
|
+
* Creates a new Web3SignServiceError instance.
|
|
4761
|
+
* @param message - Human-readable error description
|
|
4762
|
+
* @param cause - Optional underlying error that caused this error
|
|
4763
|
+
*/
|
|
4764
|
+
constructor(message: string, cause?: Error);
|
|
4765
|
+
}
|
|
4766
|
+
/**
|
|
4767
|
+
* Validation error class for Web3Sign service validation failures.
|
|
4768
|
+
* Thrown when input validation fails or data does not meet required criteria.
|
|
4769
|
+
*/
|
|
4770
|
+
declare class Web3SignServiceValidationError extends Web3SignServiceError {
|
|
4771
|
+
/**
|
|
4772
|
+
* Creates a new Web3SignServiceValidationError instance.
|
|
4773
|
+
* @param message - Human-readable error description
|
|
4774
|
+
* @param cause - Optional underlying error that caused this error
|
|
4775
|
+
*/
|
|
4776
|
+
constructor(message: string, cause?: Error);
|
|
4777
|
+
}
|
|
4778
|
+
/**
|
|
4779
|
+
* Critical service error class for unrecoverable Web3Sign service errors.
|
|
4780
|
+
* Used when a service encounters a fatal condition that prevents continued operation.
|
|
4781
|
+
*/
|
|
4782
|
+
declare class Web3SignServiceCriticalError extends Web3SignServiceError {
|
|
4783
|
+
/**
|
|
4784
|
+
* Creates a new Web3SignServiceCriticalError instance.
|
|
4785
|
+
* @param message - Human-readable error description
|
|
4786
|
+
* @param cause - Optional underlying error that caused this error
|
|
4787
|
+
*/
|
|
4788
|
+
constructor(message: string, cause?: Error);
|
|
4789
|
+
}
|
|
4790
|
+
|
|
4791
|
+
export { BYTES32_ZERO, type CopyLog, type DocumentLog, EventType, type FeesWithdrawnLog, FlatFee, HexTooLongError, type IFlatFee, type IWeb3PGP, type IWeb3PGPService, type IWeb3Sign, type IWeb3SignService, InvalidHexError, type KeyCertificationRevokedLog, type KeyCertifiedLog, type KeyRegisteredLog, type KeyRevokedLog, type KeyUpdatedLog, type NotificationLog, type OwnershipChallengedLog, type OwnershipProvedLog, type Recipient, type RequestedFeeUpdatedLog, type SignatureLog, type SignatureRevocationLog, type SubkeyAddedLog, type TimestampLog, Web3PGP, type Web3PGPEventLog, Web3PGPEvents, Web3PGPService, Web3PGPServiceCriticalError, Web3PGPServiceError, type Web3PGPServiceOptions, Web3PGPServiceValidationError, Web3Sign, Web3SignCriticalError, Web3SignError, Web3SignEvents, Web3SignService, Web3SignServiceCriticalError, Web3SignServiceError, Web3SignServiceValidationError, to0x, toBytes32 };
|