@mysten/sui 2.18.0 → 2.19.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mysten/sui.js
2
2
 
3
+ ## 2.19.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2be98ce: Add `isValidSignature`, `isValidPersonalMessageSignature`, and
8
+ `isValidTransactionSignature` to `@mysten/sui/verify` — boolean-returning siblings of the existing
9
+ `verify*` functions, taking the same arguments. They return `false` for a malformed or invalid
10
+ signature (or one that doesn't match a supplied `address`) instead of throwing, while still
11
+ letting a genuine environmental failure during verification (e.g. a zkLogin JWK/epoch lookup)
12
+ propagate. The `verify*` functions now delegate to these.
13
+
3
14
  ## 2.18.0
4
15
 
5
16
  ### Minor Changes
@@ -1,21 +1,21 @@
1
1
  import { TypeTag as TypeTag$1 } from "./types.mjs";
2
- import * as _mysten_bcs830 from "@mysten/bcs";
2
+ import * as _mysten_bcs823 from "@mysten/bcs";
3
3
  import { BcsType } from "@mysten/bcs";
4
4
 
5
5
  //#region src/bcs/bcs.d.ts
6
6
  declare const TypeTag: BcsType<string, string | TypeTag$1, string>;
7
- declare function IntentMessage<T extends BcsType<any>>(T: T): _mysten_bcs830.BcsStruct<{
8
- intent: _mysten_bcs830.BcsStruct<{
9
- scope: _mysten_bcs830.BcsEnum<{
7
+ declare function IntentMessage<T extends BcsType<any>>(T: T): _mysten_bcs823.BcsStruct<{
8
+ intent: _mysten_bcs823.BcsStruct<{
9
+ scope: _mysten_bcs823.BcsEnum<{
10
10
  TransactionData: null;
11
11
  TransactionEffects: null;
12
12
  CheckpointSummary: null;
13
13
  PersonalMessage: null;
14
14
  }, "IntentScope">;
15
- version: _mysten_bcs830.BcsEnum<{
15
+ version: _mysten_bcs823.BcsEnum<{
16
16
  V0: null;
17
17
  }, "IntentVersion">;
18
- appId: _mysten_bcs830.BcsEnum<{
18
+ appId: _mysten_bcs823.BcsEnum<{
19
19
  Sui: null;
20
20
  }, "AppId">;
21
21
  }, string>;
@@ -545,7 +545,7 @@ declare const suiBcs: {
545
545
  version: string;
546
546
  digest: string;
547
547
  };
548
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
548
+ }, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
549
549
  FundsWithdrawal: {
550
550
  reservation: {
551
551
  MaxAmountU64: string;
@@ -560,7 +560,7 @@ declare const suiBcs: {
560
560
  Sponsor: true;
561
561
  }, "Sender" | "Sponsor">;
562
562
  };
563
- }, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
563
+ }, "Pure" | "Object" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
564
564
  Pure: {
565
565
  bytes: string | Uint8Array<ArrayBufferLike>;
566
566
  };
@@ -793,7 +793,7 @@ declare const suiBcs: {
793
793
  TransactionEffects: true;
794
794
  CheckpointSummary: true;
795
795
  PersonalMessage: true;
796
- }, "TransactionEffects" | "TransactionData" | "CheckpointSummary" | "PersonalMessage">;
796
+ }, "TransactionData" | "TransactionEffects" | "CheckpointSummary" | "PersonalMessage">;
797
797
  version: {
798
798
  V0: true;
799
799
  $kind: "V0";
@@ -827,7 +827,7 @@ declare const suiBcs: {
827
827
  version: string;
828
828
  digest: string;
829
829
  };
830
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
830
+ }, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
831
831
  FundsWithdrawal: {
832
832
  reservation: {
833
833
  MaxAmountU64: string;
@@ -842,7 +842,7 @@ declare const suiBcs: {
842
842
  Sponsor: true;
843
843
  }, "Sender" | "Sponsor">;
844
844
  };
845
- }, "Object" | "Pure" | "FundsWithdrawal">[];
845
+ }, "Pure" | "Object" | "FundsWithdrawal">[];
846
846
  commands: _mysten_bcs0.EnumOutputShapeWithKeys<{
847
847
  MoveCall: {
848
848
  package: string;
@@ -950,7 +950,7 @@ declare const suiBcs: {
950
950
  chain: string;
951
951
  nonce: number;
952
952
  };
953
- }, "Epoch" | "None" | "ValidDuring">;
953
+ }, "None" | "Epoch" | "ValidDuring">;
954
954
  };
955
955
  $kind: "V1";
956
956
  };
@@ -1193,7 +1193,7 @@ declare const suiBcs: {
1193
1193
  version: string;
1194
1194
  digest: string;
1195
1195
  };
1196
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
1196
+ }, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
1197
1197
  FundsWithdrawal: {
1198
1198
  reservation: {
1199
1199
  MaxAmountU64: string;
@@ -1208,7 +1208,7 @@ declare const suiBcs: {
1208
1208
  Sponsor: true;
1209
1209
  }, "Sender" | "Sponsor">;
1210
1210
  };
1211
- }, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
1211
+ }, "Pure" | "Object" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
1212
1212
  Pure: {
1213
1213
  bytes: string | Uint8Array<ArrayBufferLike>;
1214
1214
  };
@@ -1508,7 +1508,7 @@ declare const suiBcs: {
1508
1508
  version: string;
1509
1509
  digest: string;
1510
1510
  };
1511
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
1511
+ }, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
1512
1512
  FundsWithdrawal: {
1513
1513
  reservation: {
1514
1514
  MaxAmountU64: string;
@@ -1523,7 +1523,7 @@ declare const suiBcs: {
1523
1523
  Sponsor: true;
1524
1524
  }, "Sender" | "Sponsor">;
1525
1525
  };
1526
- }, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
1526
+ }, "Pure" | "Object" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
1527
1527
  Pure: {
1528
1528
  bytes: string | Uint8Array<ArrayBufferLike>;
1529
1529
  };
@@ -1799,7 +1799,7 @@ declare const suiBcs: {
1799
1799
  version: string;
1800
1800
  digest: string;
1801
1801
  };
1802
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
1802
+ }, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
1803
1803
  FundsWithdrawal: {
1804
1804
  reservation: {
1805
1805
  MaxAmountU64: string;
@@ -1814,7 +1814,7 @@ declare const suiBcs: {
1814
1814
  Sponsor: true;
1815
1815
  }, "Sender" | "Sponsor">;
1816
1816
  };
1817
- }, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
1817
+ }, "Pure" | "Object" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
1818
1818
  Pure: {
1819
1819
  bytes: string | Uint8Array<ArrayBufferLike>;
1820
1820
  };
@@ -2271,7 +2271,7 @@ declare const suiBcs: {
2271
2271
  startVersion: string;
2272
2272
  owner: string;
2273
2273
  };
2274
- }, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">][], Iterable<readonly [{
2274
+ }, "AddressOwner" | "ObjectOwner" | "Shared" | "Immutable" | "ConsensusAddressOwner">][], Iterable<readonly [{
2275
2275
  objectId: string | Uint8Array<ArrayBufferLike>;
2276
2276
  version: string | number | bigint;
2277
2277
  digest: string;
@@ -2304,7 +2304,7 @@ declare const suiBcs: {
2304
2304
  startVersion: string;
2305
2305
  owner: string;
2306
2306
  };
2307
- }, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">][], Iterable<readonly [{
2307
+ }, "AddressOwner" | "ObjectOwner" | "Shared" | "Immutable" | "ConsensusAddressOwner">][], Iterable<readonly [{
2308
2308
  objectId: string | Uint8Array<ArrayBufferLike>;
2309
2309
  version: string | number | bigint;
2310
2310
  digest: string;
@@ -2337,7 +2337,7 @@ declare const suiBcs: {
2337
2337
  startVersion: string;
2338
2338
  owner: string;
2339
2339
  };
2340
- }, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">][], Iterable<readonly [{
2340
+ }, "AddressOwner" | "ObjectOwner" | "Shared" | "Immutable" | "ConsensusAddressOwner">][], Iterable<readonly [{
2341
2341
  objectId: string | Uint8Array<ArrayBufferLike>;
2342
2342
  version: string | number | bigint;
2343
2343
  digest: string;
@@ -2604,7 +2604,7 @@ declare const suiBcs: {
2604
2604
  startVersion: string;
2605
2605
  owner: string;
2606
2606
  };
2607
- }, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">];
2607
+ }, "AddressOwner" | "ObjectOwner" | "Shared" | "Immutable" | "ConsensusAddressOwner">];
2608
2608
  }, "NotExist" | "Exist">;
2609
2609
  outputState: _mysten_bcs0.EnumOutputShapeWithKeys<{
2610
2610
  NotExist: true;
@@ -2619,7 +2619,7 @@ declare const suiBcs: {
2619
2619
  startVersion: string;
2620
2620
  owner: string;
2621
2621
  };
2622
- }, "AddressOwner" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">];
2622
+ }, "AddressOwner" | "ObjectOwner" | "Shared" | "Immutable" | "ConsensusAddressOwner">];
2623
2623
  PackageWrite: [string, string];
2624
2624
  AccumulatorWriteV1: {
2625
2625
  address: {
@@ -2705,7 +2705,7 @@ declare const suiBcs: {
2705
2705
  ReadConsensusStreamEnded: string;
2706
2706
  Cancelled: string;
2707
2707
  PerEpochConfig: true;
2708
- }, "MutateConsensusStreamEnded" | "PerEpochConfig" | "ReadConsensusStreamEnded" | "ReadOnlyRoot" | "Cancelled">][], Iterable<readonly [string | Uint8Array<ArrayBufferLike>, _mysten_bcs0.EnumInputShape<{
2708
+ }, "ReadOnlyRoot" | "MutateConsensusStreamEnded" | "ReadConsensusStreamEnded" | "Cancelled" | "PerEpochConfig">][], Iterable<readonly [string | Uint8Array<ArrayBufferLike>, _mysten_bcs0.EnumInputShape<{
2709
2709
  ReadOnlyRoot: readonly [string | number | bigint, string];
2710
2710
  MutateConsensusStreamEnded: string | number | bigint;
2711
2711
  ReadConsensusStreamEnded: string | number | bigint;
@@ -2751,7 +2751,7 @@ declare const suiBcs: {
2751
2751
  version: string;
2752
2752
  digest: string;
2753
2753
  };
2754
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
2754
+ }, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
2755
2755
  FundsWithdrawal: {
2756
2756
  reservation: {
2757
2757
  MaxAmountU64: string;
@@ -2766,7 +2766,7 @@ declare const suiBcs: {
2766
2766
  Sponsor: true;
2767
2767
  }, "Sender" | "Sponsor">;
2768
2768
  };
2769
- }, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
2769
+ }, "Pure" | "Object" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
2770
2770
  Pure: {
2771
2771
  bytes: string | Uint8Array<ArrayBufferLike>;
2772
2772
  };
@@ -23,12 +23,6 @@ declare function toSerializedSignature({
23
23
  * Decodes a serialized signature into its constituent components: the signature scheme, the actual signature, and the public key
24
24
  */
25
25
  declare function parseSerializedSignature(serializedSignature: string): {
26
- serializedSignature: string;
27
- signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
28
- signature: Uint8Array<ArrayBuffer>;
29
- publicKey: Uint8Array<ArrayBuffer>;
30
- bytes: Uint8Array<ArrayBuffer>;
31
- } | {
32
26
  signatureScheme: "Passkey";
33
27
  serializedSignature: string;
34
28
  signature: Uint8Array<ArrayBufferLike>;
@@ -36,6 +30,12 @@ declare function parseSerializedSignature(serializedSignature: string): {
36
30
  clientDataJson: string;
37
31
  userSignature: Uint8Array<ArrayBuffer>;
38
32
  publicKey: Uint8Array<ArrayBuffer>;
33
+ } | {
34
+ serializedSignature: string;
35
+ signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
36
+ signature: Uint8Array<ArrayBuffer>;
37
+ publicKey: Uint8Array<ArrayBuffer>;
38
+ bytes: Uint8Array<ArrayBuffer>;
39
39
  } | {
40
40
  serializedSignature: string;
41
41
  signatureScheme: "ZkLogin";
@@ -1,6 +1,6 @@
1
1
  import { BatchGetObjectsRequest, BatchGetObjectsResponse, BatchGetTransactionsRequest, BatchGetTransactionsResponse, GetCheckpointRequest, GetCheckpointResponse, GetEpochRequest, GetEpochResponse, GetObjectRequest, GetObjectResponse, GetServiceInfoRequest, GetServiceInfoResponse, GetTransactionRequest, GetTransactionResponse } from "./ledger_service.mjs";
2
- import * as _protobuf_ts_runtime5 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc5 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime1 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc1 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts
@@ -45,9 +45,9 @@ interface ILedgerServiceClient {
45
45
  declare class LedgerServiceClient implements ILedgerServiceClient, ServiceInfo {
46
46
  private readonly _transport;
47
47
  typeName: string;
48
- methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
48
+ methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
49
49
  options: {
50
- [extensionName: string]: _protobuf_ts_runtime5.JsonValue;
50
+ [extensionName: string]: _protobuf_ts_runtime1.JsonValue;
51
51
  };
52
52
  constructor(_transport: RpcTransport);
53
53
  /**
@@ -1,6 +1,6 @@
1
1
  import { GetDatatypeRequest, GetDatatypeResponse, GetFunctionRequest, GetFunctionResponse, GetPackageRequest, GetPackageResponse, ListPackageVersionsRequest, ListPackageVersionsResponse } from "./move_package_service.mjs";
2
- import * as _protobuf_ts_runtime6 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc6 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime2 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc2 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts
@@ -31,9 +31,9 @@ interface IMovePackageServiceClient {
31
31
  declare class MovePackageServiceClient implements IMovePackageServiceClient, ServiceInfo {
32
32
  private readonly _transport;
33
33
  typeName: string;
34
- methods: _protobuf_ts_runtime_rpc6.MethodInfo<any, any>[];
34
+ methods: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
35
35
  options: {
36
- [extensionName: string]: _protobuf_ts_runtime6.JsonValue;
36
+ [extensionName: string]: _protobuf_ts_runtime2.JsonValue;
37
37
  };
38
38
  constructor(_transport: RpcTransport);
39
39
  /**
@@ -1,6 +1,6 @@
1
1
  import { LookupNameRequest, LookupNameResponse, ReverseLookupNameRequest, ReverseLookupNameResponse } from "./name_service.mjs";
2
- import * as _protobuf_ts_runtime4 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc4 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime6 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc6 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/name_service.client.d.ts
@@ -23,9 +23,9 @@ interface INameServiceClient {
23
23
  declare class NameServiceClient implements INameServiceClient, ServiceInfo {
24
24
  private readonly _transport;
25
25
  typeName: string;
26
- methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
26
+ methods: _protobuf_ts_runtime_rpc6.MethodInfo<any, any>[];
27
27
  options: {
28
- [extensionName: string]: _protobuf_ts_runtime4.JsonValue;
28
+ [extensionName: string]: _protobuf_ts_runtime6.JsonValue;
29
29
  };
30
30
  constructor(_transport: RpcTransport);
31
31
  /**
@@ -1,6 +1,6 @@
1
1
  import { GetBalanceRequest, GetBalanceResponse, GetCoinInfoRequest, GetCoinInfoResponse, ListBalancesRequest, ListBalancesResponse, ListDynamicFieldsRequest, ListDynamicFieldsResponse, ListOwnedObjectsRequest, ListOwnedObjectsResponse } from "./state_service.mjs";
2
- import * as _protobuf_ts_runtime1 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc1 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime4 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc4 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/state_service.client.d.ts
@@ -35,9 +35,9 @@ interface IStateServiceClient {
35
35
  declare class StateServiceClient implements IStateServiceClient, ServiceInfo {
36
36
  private readonly _transport;
37
37
  typeName: string;
38
- methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
38
+ methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
39
39
  options: {
40
- [extensionName: string]: _protobuf_ts_runtime1.JsonValue;
40
+ [extensionName: string]: _protobuf_ts_runtime4.JsonValue;
41
41
  };
42
42
  constructor(_transport: RpcTransport);
43
43
  /**
@@ -1,6 +1,6 @@
1
1
  import { SubscribeCheckpointsRequest, SubscribeCheckpointsResponse } from "./subscription_service.mjs";
2
- import * as _protobuf_ts_runtime2 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc2 from "@protobuf-ts/runtime-rpc";
2
+ import * as _protobuf_ts_runtime5 from "@protobuf-ts/runtime";
3
+ import * as _protobuf_ts_runtime_rpc5 from "@protobuf-ts/runtime-rpc";
4
4
  import { RpcOptions, RpcTransport, ServerStreamingCall, ServiceInfo } from "@protobuf-ts/runtime-rpc";
5
5
 
6
6
  //#region src/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts
@@ -31,9 +31,9 @@ interface ISubscriptionServiceClient {
31
31
  declare class SubscriptionServiceClient implements ISubscriptionServiceClient, ServiceInfo {
32
32
  private readonly _transport;
33
33
  typeName: string;
34
- methods: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
34
+ methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
35
35
  options: {
36
- [extensionName: string]: _protobuf_ts_runtime2.JsonValue;
36
+ [extensionName: string]: _protobuf_ts_runtime5.JsonValue;
37
37
  };
38
38
  constructor(_transport: RpcTransport);
39
39
  /**
@@ -8,7 +8,7 @@ import { createPure } from "./pure.mjs";
8
8
  import { SignatureWithBytes, Signer } from "../cryptography/keypair.mjs";
9
9
  import "../cryptography/index.mjs";
10
10
  import { ClientWithCoreApi } from "../client/core.mjs";
11
- import * as _mysten_bcs823 from "@mysten/bcs";
11
+ import * as _mysten_bcs1124 from "@mysten/bcs";
12
12
  import { SerializedBcs } from "@mysten/bcs";
13
13
  import { InferInput } from "valibot";
14
14
 
@@ -91,7 +91,7 @@ declare class Transaction {
91
91
  getData(): {
92
92
  version: 2;
93
93
  sender?: string | null | undefined;
94
- expiration?: _mysten_bcs823.EnumOutputShapeWithKeys<{
94
+ expiration?: _mysten_bcs1124.EnumOutputShapeWithKeys<{
95
95
  None: true;
96
96
  Epoch: string | number;
97
97
  ValidDuring: {
@@ -102,7 +102,7 @@ declare class Transaction {
102
102
  chain: string;
103
103
  nonce: number;
104
104
  };
105
- }, "Epoch" | "None" | "ValidDuring"> | null | undefined;
105
+ }, "None" | "Epoch" | "ValidDuring"> | null | undefined;
106
106
  gasData: {
107
107
  budget: string | number | null;
108
108
  price: string | number | null;
@@ -113,8 +113,8 @@ declare class Transaction {
113
113
  digest: string;
114
114
  }[] | null;
115
115
  };
116
- inputs: _mysten_bcs823.EnumOutputShapeWithKeys<{
117
- Object: _mysten_bcs823.EnumOutputShapeWithKeys<{
116
+ inputs: _mysten_bcs1124.EnumOutputShapeWithKeys<{
117
+ Object: _mysten_bcs1124.EnumOutputShapeWithKeys<{
118
118
  ImmOrOwnedObject: {
119
119
  objectId: string;
120
120
  version: string | number;
@@ -130,7 +130,7 @@ declare class Transaction {
130
130
  version: string | number;
131
131
  digest: string;
132
132
  };
133
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
133
+ }, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
134
134
  Pure: {
135
135
  bytes: string;
136
136
  };
@@ -153,13 +153,13 @@ declare class Transaction {
153
153
  Balance: string;
154
154
  $kind: "Balance";
155
155
  };
156
- withdrawFrom: _mysten_bcs823.EnumOutputShapeWithKeys<{
156
+ withdrawFrom: _mysten_bcs1124.EnumOutputShapeWithKeys<{
157
157
  Sender: true;
158
158
  Sponsor: true;
159
159
  }, "Sender" | "Sponsor">;
160
160
  };
161
- }, "Object" | "Pure" | "FundsWithdrawal" | "UnresolvedPure" | "UnresolvedObject">[];
162
- commands: _mysten_bcs823.EnumOutputShapeWithKeys<{
161
+ }, "Pure" | "Object" | "FundsWithdrawal" | "UnresolvedPure" | "UnresolvedObject">[];
162
+ commands: _mysten_bcs1124.EnumOutputShapeWithKeys<{
163
163
  MoveCall: {
164
164
  package: string;
165
165
  module: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Transaction.d.mts","names":[],"sources":["../../src/transactions/Transaction.ts"],"mappings":";;;;;;;;;;;;;;;KAyCY,yBAAA,GACT,OAAA,CAAQ,UAAA,QAAkB,cAAA;EAAmB,KAAA;EAAgB,IAAA;AAAA,OAE7D,EAAA,EAAI,WAAA,KACC,OAAA,CAAQ,UAAA,QAAkB,cAAA;EAAmB,KAAA;EAAgB,IAAA;AAAA,MAClE,qBAAA,CAAsB,yBAAA;AAAA,KAEb,iBAAA,GAAoB,OAAA,CAAQ,QAAA;EAAY,MAAA;AAAA,KACnD,OAAA,CAAQ,QAAA;EAAY,YAAA;AAAA;AAAA,KAET,yBAAA,GACT,OAAA,CAAQ,QAAA;EAAY,MAAA;AAAA,cACX,OAAA,CAAQ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EAW3D,WAAA,CAAA;IACC,IAAA;IACA;EAAA;IAEA,QAAA,GAAW,yBAAA;IACX,IAAA;EAAA,IACA,iBAAA;;;;;;;;EAgBD,UAAA,CAAA;IAAa,MAAA;IAAQ;EAAA;IAAU,MAAA;IAAkC,IAAA;EAAA;IAChE,KAAA;IACA,KAAA;IACA,IAAA;EAAA;;;;;EAuBD,SAAA,CAAA;EAIM,MAAA,CAAO,OAAA,GAAS,2BAAA,GAAmC,OAAA;;EAmBnD,IAAA,CAAK,OAAA,EAAS,WAAA,GAAc,OAAA,CAAQ,kBAAA;;;;;;;;;;EAe1C,0BAAA,CAA2B,OAAA;IAAW,gBAAA;EAAA;;;;;;;;;;;;EA2BtC,eAAA,CAAA;;EAiBM,KAAA,CAAM,OAAA,GAAS,uBAAA,GAA+B,OAAA,CAAQ,UAAA,CAAW,WAAA;EA7btE;EAscK,SAAA,CACL,OAAA;IACC,MAAA,GAAS,iBAAA;EAAA,IAER,OAAA;EAsJG,uBAAA,CAAwB,OAAA,EAAS,2BAAA,GAA2B,OAAA;AAAA"}
@@ -1,2 +1,2 @@
1
- import { publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature } from "./verify.mjs";
2
- export { publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
1
+ import { isValidPersonalMessageSignature, isValidSignature, isValidTransactionSignature, publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature } from "./verify.mjs";
2
+ export { isValidPersonalMessageSignature, isValidSignature, isValidTransactionSignature, publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
@@ -1,3 +1,3 @@
1
- import { publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature } from "./verify.mjs";
1
+ import { isValidPersonalMessageSignature, isValidSignature, isValidTransactionSignature, publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature } from "./verify.mjs";
2
2
 
3
- export { publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
3
+ export { isValidPersonalMessageSignature, isValidSignature, isValidTransactionSignature, publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
@@ -4,6 +4,26 @@ import "../cryptography/index.mjs";
4
4
  import { ClientWithCoreApi } from "../client/core.mjs";
5
5
 
6
6
  //#region src/verify/verify.d.ts
7
+ /**
8
+ * Whether `signature` is a valid signature over `bytes` (and, if `options.address`
9
+ * is given, was produced by that address). Returns `false` for a malformed or
10
+ * cryptographically invalid signature, or one that doesn't match the address;
11
+ * only an *environmental* failure (e.g. a zkLogin JWK/epoch lookup) throws, so a
12
+ * network blip is never reported as an invalid signature.
13
+ */
14
+ declare function isValidSignature(bytes: Uint8Array, signature: string, options?: {
15
+ address?: string;
16
+ }): Promise<boolean>;
17
+ /** Like {@link isValidSignature}, for a personal message. */
18
+ declare function isValidPersonalMessageSignature(message: Uint8Array, signature: string, options?: {
19
+ client?: ClientWithCoreApi;
20
+ address?: string;
21
+ }): Promise<boolean>;
22
+ /** Like {@link isValidSignature}, for transaction bytes. */
23
+ declare function isValidTransactionSignature(transaction: Uint8Array, signature: string, options?: {
24
+ client?: ClientWithCoreApi;
25
+ address?: string;
26
+ }): Promise<boolean>;
7
27
  declare function verifySignature(bytes: Uint8Array, signature: string, options?: {
8
28
  address?: string;
9
29
  }): Promise<PublicKey>;
@@ -24,5 +44,5 @@ declare function publicKeyFromSuiBytes(publicKey: string | Uint8Array, options?:
24
44
  address?: string;
25
45
  }): PublicKey;
26
46
  //#endregion
27
- export { publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
47
+ export { isValidPersonalMessageSignature, isValidSignature, isValidTransactionSignature, publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
28
48
  //# sourceMappingURL=verify.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"verify.d.mts","names":[],"sources":["../../src/verify/verify.ts"],"mappings":";;;;;;iBAesB,eAAA,CACrB,KAAA,EAAO,UAAA,EACP,SAAA,UACA,OAAA;EACC,OAAA;AAAA,IAEC,OAAA,CAAQ,SAAA;AAAA,iBAcW,8BAAA,CACrB,OAAA,EAAS,UAAA,EACT,SAAA,UACA,OAAA;EAAW,MAAA,GAAS,iBAAA;EAAmB,OAAA;AAAA,IACrC,OAAA,CAAQ,SAAA;AAAA,iBAmBW,0BAAA,CACrB,WAAA,EAAa,UAAA,EACb,SAAA,UACA,OAAA;EAAW,MAAA,GAAS,iBAAA;EAAmB,OAAA;AAAA,IACrC,OAAA,CAAQ,SAAA;AAAA,iBAwCK,qBAAA,CACf,eAAA,EAAiB,eAAA,EACjB,KAAA,EAAO,UAAA,EACP,OAAA;EAAW,MAAA,GAAS,iBAAA;EAAmB,OAAA;AAAA,IACrC,SAAA;AAAA,iBAgCa,qBAAA,CACf,SAAA,WAAoB,UAAA,EACpB,OAAA;EAAW,MAAA,GAAS,iBAAA;EAAmB,OAAA;AAAA,IAAuB,SAAA"}
1
+ {"version":3,"file":"verify.d.mts","names":[],"sources":["../../src/verify/verify.ts"],"mappings":";;;;;;;;;;AAsBA;;;iBAAsB,gBAAA,CACrB,KAAA,EAAO,UAAA,EACP,SAAA,UACA,OAAA;EAAW,OAAA;AAAA,IACT,OAAA;;iBAQmB,+BAAA,CACrB,OAAA,EAAS,UAAA,EACT,SAAA,UACA,OAAA;EAAW,MAAA,GAAS,iBAAA;EAAmB,OAAA;AAAA,IACrC,OAAA;;iBAUmB,2BAAA,CACrB,WAAA,EAAa,UAAA,EACb,SAAA,UACA,OAAA;EAAW,MAAA,GAAS,iBAAA;EAAmB,OAAA;AAAA,IACrC,OAAA;AAAA,iBASmB,eAAA,CACrB,KAAA,EAAO,UAAA,EACP,SAAA,UACA,OAAA;EAAW,OAAA;AAAA,IACT,OAAA,CAAQ,SAAA;AAAA,iBAWW,8BAAA,CACrB,OAAA,EAAS,UAAA,EACT,SAAA,UACA,OAAA;EAAW,MAAA,GAAS,iBAAA;EAAmB,OAAA;AAAA,IACrC,OAAA,CAAQ,SAAA;AAAA,iBAWW,0BAAA,CACrB,WAAA,EAAa,UAAA,EACb,SAAA,UACA,OAAA;EAAW,MAAA,GAAS,iBAAA;EAAmB,OAAA;AAAA,IACrC,OAAA,CAAQ,SAAA;AAAA,iBAyCK,qBAAA,CACf,eAAA,EAAiB,eAAA,EACjB,KAAA,EAAO,UAAA,EACP,OAAA;EAAW,MAAA,GAAS,iBAAA;EAAmB,OAAA;AAAA,IACrC,SAAA;AAAA,iBAgCa,qBAAA,CACf,SAAA,WAAoB,UAAA,EACpB,OAAA;EAAW,MAAA,GAAS,iBAAA;EAAmB,OAAA;AAAA,IAAuB,SAAA"}
@@ -9,23 +9,50 @@ import { MultiSigPublicKey } from "../multisig/publickey.mjs";
9
9
  import { fromBase64 } from "@mysten/bcs";
10
10
 
11
11
  //#region src/verify/verify.ts
12
- async function verifySignature(bytes, signature, options) {
13
- const parsedSignature = parseSignature(signature);
14
- if (!await parsedSignature.publicKey.verify(bytes, parsedSignature.serializedSignature)) throw new Error(`Signature is not valid for the provided data`);
15
- if (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) throw new Error(`Signature is not valid for the provided address`);
16
- return parsedSignature.publicKey;
12
+ /**
13
+ * Whether `signature` is a valid signature over `bytes` (and, if `options.address`
14
+ * is given, was produced by that address). Returns `false` for a malformed or
15
+ * cryptographically invalid signature, or one that doesn't match the address;
16
+ * only an *environmental* failure (e.g. a zkLogin JWK/epoch lookup) throws, so a
17
+ * network blip is never reported as an invalid signature.
18
+ */
19
+ async function isValidSignature(bytes, signature, options = {}) {
20
+ const parsed = tryParseSignature(signature);
21
+ if (!parsed) return false;
22
+ if (!await parsed.publicKey.verify(bytes, parsed.serializedSignature)) return false;
23
+ return options.address ? parsed.publicKey.verifyAddress(options.address) : true;
24
+ }
25
+ /** Like {@link isValidSignature}, for a personal message. */
26
+ async function isValidPersonalMessageSignature(message, signature, options = {}) {
27
+ const parsed = tryParseSignature(signature, { client: options.client });
28
+ if (!parsed) return false;
29
+ if (!await parsed.publicKey.verifyPersonalMessage(message, parsed.serializedSignature)) return false;
30
+ return options.address ? parsed.publicKey.verifyAddress(options.address) : true;
31
+ }
32
+ /** Like {@link isValidSignature}, for transaction bytes. */
33
+ async function isValidTransactionSignature(transaction, signature, options = {}) {
34
+ const parsed = tryParseSignature(signature, { client: options.client });
35
+ if (!parsed) return false;
36
+ if (!await parsed.publicKey.verifyTransaction(transaction, parsed.serializedSignature)) return false;
37
+ return options.address ? parsed.publicKey.verifyAddress(options.address) : true;
38
+ }
39
+ async function verifySignature(bytes, signature, options = {}) {
40
+ const { publicKey } = parseSignature(signature);
41
+ if (!await isValidSignature(bytes, signature)) throw new Error(`Signature is not valid for the provided data`);
42
+ if (options.address && !publicKey.verifyAddress(options.address)) throw new Error(`Signature is not valid for the provided address`);
43
+ return publicKey;
17
44
  }
18
45
  async function verifyPersonalMessageSignature(message, signature, options = {}) {
19
- const parsedSignature = parseSignature(signature, options);
20
- if (!await parsedSignature.publicKey.verifyPersonalMessage(message, parsedSignature.serializedSignature)) throw new Error(`Signature is not valid for the provided message`);
21
- if (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) throw new Error(`Signature is not valid for the provided address`);
22
- return parsedSignature.publicKey;
46
+ const { publicKey } = parseSignature(signature, options);
47
+ if (!await isValidPersonalMessageSignature(message, signature, { client: options.client })) throw new Error(`Signature is not valid for the provided message`);
48
+ if (options.address && !publicKey.verifyAddress(options.address)) throw new Error(`Signature is not valid for the provided address`);
49
+ return publicKey;
23
50
  }
24
51
  async function verifyTransactionSignature(transaction, signature, options = {}) {
25
- const parsedSignature = parseSignature(signature, options);
26
- if (!await parsedSignature.publicKey.verifyTransaction(transaction, parsedSignature.serializedSignature)) throw new Error(`Signature is not valid for the provided Transaction`);
27
- if (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) throw new Error(`Signature is not valid for the provided address`);
28
- return parsedSignature.publicKey;
52
+ const { publicKey } = parseSignature(signature, options);
53
+ if (!await isValidTransactionSignature(transaction, signature, { client: options.client })) throw new Error(`Signature is not valid for the provided Transaction`);
54
+ if (options.address && !publicKey.verifyAddress(options.address)) throw new Error(`Signature is not valid for the provided address`);
55
+ return publicKey;
29
56
  }
30
57
  function parseSignature(signature, options = {}) {
31
58
  const parsedSignature = parseSerializedSignature(signature);
@@ -39,6 +66,14 @@ function parseSignature(signature, options = {}) {
39
66
  publicKey
40
67
  };
41
68
  }
69
+ /** {@link parseSignature}, returning `null` instead of throwing on a malformed signature. */
70
+ function tryParseSignature(signature, options = {}) {
71
+ try {
72
+ return parseSignature(signature, options);
73
+ } catch {
74
+ return null;
75
+ }
76
+ }
42
77
  function publicKeyFromRawBytes(signatureScheme, bytes, options = {}) {
43
78
  let publicKey;
44
79
  switch (signatureScheme) {
@@ -72,5 +107,5 @@ function publicKeyFromSuiBytes(publicKey, options = {}) {
72
107
  }
73
108
 
74
109
  //#endregion
75
- export { publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
110
+ export { isValidPersonalMessageSignature, isValidSignature, isValidTransactionSignature, publicKeyFromRawBytes, publicKeyFromSuiBytes, verifyPersonalMessageSignature, verifySignature, verifyTransactionSignature };
76
111
  //# sourceMappingURL=verify.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"verify.mjs","names":[],"sources":["../../src/verify/verify.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64 } from '@mysten/bcs';\n\nimport type { PublicKey, SignatureFlag, SignatureScheme } from '../cryptography/index.js';\nimport { parseSerializedSignature, SIGNATURE_FLAG_TO_SCHEME } from '../cryptography/index.js';\nimport { Ed25519PublicKey } from '../keypairs/ed25519/publickey.js';\nimport { PasskeyPublicKey } from '../keypairs/passkey/publickey.js';\nimport { Secp256k1PublicKey } from '../keypairs/secp256k1/publickey.js';\nimport { Secp256r1PublicKey } from '../keypairs/secp256r1/publickey.js';\nimport { MultiSigPublicKey } from '../multisig/publickey.js';\nimport { ZkLoginPublicIdentifier } from '../zklogin/publickey.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\n\nexport async function verifySignature(\n\tbytes: Uint8Array,\n\tsignature: string,\n\toptions?: {\n\t\taddress?: string;\n\t},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature);\n\n\tif (!(await parsedSignature.publicKey.verify(bytes, parsedSignature.serializedSignature))) {\n\t\tthrow new Error(`Signature is not valid for the provided data`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nexport async function verifyPersonalMessageSignature(\n\tmessage: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature, options);\n\n\tif (\n\t\t!(await parsedSignature.publicKey.verifyPersonalMessage(\n\t\t\tmessage,\n\t\t\tparsedSignature.serializedSignature,\n\t\t))\n\t) {\n\t\tthrow new Error(`Signature is not valid for the provided message`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nexport async function verifyTransactionSignature(\n\ttransaction: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature, options);\n\n\tif (\n\t\t!(await parsedSignature.publicKey.verifyTransaction(\n\t\t\ttransaction,\n\t\t\tparsedSignature.serializedSignature,\n\t\t))\n\t) {\n\t\tthrow new Error(`Signature is not valid for the provided Transaction`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nfunction parseSignature(signature: string, options: { client?: ClientWithCoreApi } = {}) {\n\tconst parsedSignature = parseSerializedSignature(signature);\n\n\tif (parsedSignature.signatureScheme === 'MultiSig') {\n\t\treturn {\n\t\t\t...parsedSignature,\n\t\t\tpublicKey: new MultiSigPublicKey(parsedSignature.multisig.multisig_pk),\n\t\t};\n\t}\n\n\tconst publicKey = publicKeyFromRawBytes(\n\t\tparsedSignature.signatureScheme,\n\t\tparsedSignature.publicKey,\n\t\toptions,\n\t);\n\treturn {\n\t\t...parsedSignature,\n\t\tpublicKey,\n\t};\n}\n\nexport function publicKeyFromRawBytes(\n\tsignatureScheme: SignatureScheme,\n\tbytes: Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): PublicKey {\n\tlet publicKey: PublicKey;\n\tswitch (signatureScheme) {\n\t\tcase 'ED25519':\n\t\t\tpublicKey = new Ed25519PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256k1':\n\t\t\tpublicKey = new Secp256k1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256r1':\n\t\t\tpublicKey = new Secp256r1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'MultiSig':\n\t\t\tpublicKey = new MultiSigPublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'ZkLogin':\n\t\t\tpublicKey = ZkLoginPublicIdentifier.fromBytes(bytes, options);\n\t\t\tbreak;\n\t\tcase 'Passkey':\n\t\t\tpublicKey = new PasskeyPublicKey(bytes);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported signature scheme ${signatureScheme}`);\n\t}\n\n\tif (options.address && publicKey.toSuiAddress() !== options.address) {\n\t\tthrow new Error(`Public key bytes do not match the provided address`);\n\t}\n\n\treturn publicKey;\n}\n\nexport function publicKeyFromSuiBytes(\n\tpublicKey: string | Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n) {\n\tconst bytes = typeof publicKey === 'string' ? fromBase64(publicKey) : publicKey;\n\n\tconst signatureScheme = SIGNATURE_FLAG_TO_SCHEME[bytes[0] as SignatureFlag];\n\n\treturn publicKeyFromRawBytes(signatureScheme, bytes.slice(1), options);\n}\n"],"mappings":";;;;;;;;;;;AAeA,eAAsB,gBACrB,OACA,WACA,SAGqB;CACrB,MAAM,kBAAkB,eAAe,UAAU;AAEjD,KAAI,CAAE,MAAM,gBAAgB,UAAU,OAAO,OAAO,gBAAgB,oBAAoB,CACvF,OAAM,IAAI,MAAM,+CAA+C;AAGhE,KAAI,SAAS,WAAW,CAAC,gBAAgB,UAAU,cAAc,QAAQ,QAAQ,CAChF,OAAM,IAAI,MAAM,kDAAkD;AAGnE,QAAO,gBAAgB;;AAGxB,eAAsB,+BACrB,SACA,WACA,UAA4D,EAAE,EACzC;CACrB,MAAM,kBAAkB,eAAe,WAAW,QAAQ;AAE1D,KACC,CAAE,MAAM,gBAAgB,UAAU,sBACjC,SACA,gBAAgB,oBAChB,CAED,OAAM,IAAI,MAAM,kDAAkD;AAGnE,KAAI,SAAS,WAAW,CAAC,gBAAgB,UAAU,cAAc,QAAQ,QAAQ,CAChF,OAAM,IAAI,MAAM,kDAAkD;AAGnE,QAAO,gBAAgB;;AAGxB,eAAsB,2BACrB,aACA,WACA,UAA4D,EAAE,EACzC;CACrB,MAAM,kBAAkB,eAAe,WAAW,QAAQ;AAE1D,KACC,CAAE,MAAM,gBAAgB,UAAU,kBACjC,aACA,gBAAgB,oBAChB,CAED,OAAM,IAAI,MAAM,sDAAsD;AAGvE,KAAI,SAAS,WAAW,CAAC,gBAAgB,UAAU,cAAc,QAAQ,QAAQ,CAChF,OAAM,IAAI,MAAM,kDAAkD;AAGnE,QAAO,gBAAgB;;AAGxB,SAAS,eAAe,WAAmB,UAA0C,EAAE,EAAE;CACxF,MAAM,kBAAkB,yBAAyB,UAAU;AAE3D,KAAI,gBAAgB,oBAAoB,WACvC,QAAO;EACN,GAAG;EACH,WAAW,IAAI,kBAAkB,gBAAgB,SAAS,YAAY;EACtE;CAGF,MAAM,YAAY,sBACjB,gBAAgB,iBAChB,gBAAgB,WAChB,QACA;AACD,QAAO;EACN,GAAG;EACH;EACA;;AAGF,SAAgB,sBACf,iBACA,OACA,UAA4D,EAAE,EAClD;CACZ,IAAI;AACJ,SAAQ,iBAAR;EACC,KAAK;AACJ,eAAY,IAAI,iBAAiB,MAAM;AACvC;EACD,KAAK;AACJ,eAAY,IAAI,mBAAmB,MAAM;AACzC;EACD,KAAK;AACJ,eAAY,IAAI,mBAAmB,MAAM;AACzC;EACD,KAAK;AACJ,eAAY,IAAI,kBAAkB,MAAM;AACxC;EACD,KAAK;AACJ,eAAY,wBAAwB,UAAU,OAAO,QAAQ;AAC7D;EACD,KAAK;AACJ,eAAY,IAAI,iBAAiB,MAAM;AACvC;EACD,QACC,OAAM,IAAI,MAAM,gCAAgC,kBAAkB;;AAGpE,KAAI,QAAQ,WAAW,UAAU,cAAc,KAAK,QAAQ,QAC3D,OAAM,IAAI,MAAM,qDAAqD;AAGtE,QAAO;;AAGR,SAAgB,sBACf,WACA,UAA4D,EAAE,EAC7D;CACD,MAAM,QAAQ,OAAO,cAAc,WAAW,WAAW,UAAU,GAAG;CAEtE,MAAM,kBAAkB,yBAAyB,MAAM;AAEvD,QAAO,sBAAsB,iBAAiB,MAAM,MAAM,EAAE,EAAE,QAAQ"}
1
+ {"version":3,"file":"verify.mjs","names":[],"sources":["../../src/verify/verify.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64 } from '@mysten/bcs';\n\nimport type { PublicKey, SignatureFlag, SignatureScheme } from '../cryptography/index.js';\nimport { parseSerializedSignature, SIGNATURE_FLAG_TO_SCHEME } from '../cryptography/index.js';\nimport { Ed25519PublicKey } from '../keypairs/ed25519/publickey.js';\nimport { PasskeyPublicKey } from '../keypairs/passkey/publickey.js';\nimport { Secp256k1PublicKey } from '../keypairs/secp256k1/publickey.js';\nimport { Secp256r1PublicKey } from '../keypairs/secp256r1/publickey.js';\nimport { MultiSigPublicKey } from '../multisig/publickey.js';\nimport { ZkLoginPublicIdentifier } from '../zklogin/publickey.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\n\n/**\n * Whether `signature` is a valid signature over `bytes` (and, if `options.address`\n * is given, was produced by that address). Returns `false` for a malformed or\n * cryptographically invalid signature, or one that doesn't match the address;\n * only an *environmental* failure (e.g. a zkLogin JWK/epoch lookup) throws, so a\n * network blip is never reported as an invalid signature.\n */\nexport async function isValidSignature(\n\tbytes: Uint8Array,\n\tsignature: string,\n\toptions: { address?: string } = {},\n): Promise<boolean> {\n\tconst parsed = tryParseSignature(signature);\n\tif (!parsed) return false;\n\tif (!(await parsed.publicKey.verify(bytes, parsed.serializedSignature))) return false;\n\treturn options.address ? parsed.publicKey.verifyAddress(options.address) : true;\n}\n\n/** Like {@link isValidSignature}, for a personal message. */\nexport async function isValidPersonalMessageSignature(\n\tmessage: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<boolean> {\n\tconst parsed = tryParseSignature(signature, { client: options.client });\n\tif (!parsed) return false;\n\tif (!(await parsed.publicKey.verifyPersonalMessage(message, parsed.serializedSignature))) {\n\t\treturn false;\n\t}\n\treturn options.address ? parsed.publicKey.verifyAddress(options.address) : true;\n}\n\n/** Like {@link isValidSignature}, for transaction bytes. */\nexport async function isValidTransactionSignature(\n\ttransaction: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<boolean> {\n\tconst parsed = tryParseSignature(signature, { client: options.client });\n\tif (!parsed) return false;\n\tif (!(await parsed.publicKey.verifyTransaction(transaction, parsed.serializedSignature))) {\n\t\treturn false;\n\t}\n\treturn options.address ? parsed.publicKey.verifyAddress(options.address) : true;\n}\n\nexport async function verifySignature(\n\tbytes: Uint8Array,\n\tsignature: string,\n\toptions: { address?: string } = {},\n): Promise<PublicKey> {\n\tconst { publicKey } = parseSignature(signature);\n\tif (!(await isValidSignature(bytes, signature))) {\n\t\tthrow new Error(`Signature is not valid for the provided data`);\n\t}\n\tif (options.address && !publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\treturn publicKey;\n}\n\nexport async function verifyPersonalMessageSignature(\n\tmessage: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst { publicKey } = parseSignature(signature, options);\n\tif (!(await isValidPersonalMessageSignature(message, signature, { client: options.client }))) {\n\t\tthrow new Error(`Signature is not valid for the provided message`);\n\t}\n\tif (options.address && !publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\treturn publicKey;\n}\n\nexport async function verifyTransactionSignature(\n\ttransaction: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst { publicKey } = parseSignature(signature, options);\n\tif (!(await isValidTransactionSignature(transaction, signature, { client: options.client }))) {\n\t\tthrow new Error(`Signature is not valid for the provided Transaction`);\n\t}\n\tif (options.address && !publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\treturn publicKey;\n}\n\nfunction parseSignature(signature: string, options: { client?: ClientWithCoreApi } = {}) {\n\tconst parsedSignature = parseSerializedSignature(signature);\n\n\tif (parsedSignature.signatureScheme === 'MultiSig') {\n\t\treturn {\n\t\t\t...parsedSignature,\n\t\t\tpublicKey: new MultiSigPublicKey(parsedSignature.multisig.multisig_pk),\n\t\t};\n\t}\n\n\tconst publicKey = publicKeyFromRawBytes(\n\t\tparsedSignature.signatureScheme,\n\t\tparsedSignature.publicKey,\n\t\toptions,\n\t);\n\treturn {\n\t\t...parsedSignature,\n\t\tpublicKey,\n\t};\n}\n\n/** {@link parseSignature}, returning `null` instead of throwing on a malformed signature. */\nfunction tryParseSignature(signature: string, options: { client?: ClientWithCoreApi } = {}) {\n\ttry {\n\t\treturn parseSignature(signature, options);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport function publicKeyFromRawBytes(\n\tsignatureScheme: SignatureScheme,\n\tbytes: Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): PublicKey {\n\tlet publicKey: PublicKey;\n\tswitch (signatureScheme) {\n\t\tcase 'ED25519':\n\t\t\tpublicKey = new Ed25519PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256k1':\n\t\t\tpublicKey = new Secp256k1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256r1':\n\t\t\tpublicKey = new Secp256r1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'MultiSig':\n\t\t\tpublicKey = new MultiSigPublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'ZkLogin':\n\t\t\tpublicKey = ZkLoginPublicIdentifier.fromBytes(bytes, options);\n\t\t\tbreak;\n\t\tcase 'Passkey':\n\t\t\tpublicKey = new PasskeyPublicKey(bytes);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported signature scheme ${signatureScheme}`);\n\t}\n\n\tif (options.address && publicKey.toSuiAddress() !== options.address) {\n\t\tthrow new Error(`Public key bytes do not match the provided address`);\n\t}\n\n\treturn publicKey;\n}\n\nexport function publicKeyFromSuiBytes(\n\tpublicKey: string | Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n) {\n\tconst bytes = typeof publicKey === 'string' ? fromBase64(publicKey) : publicKey;\n\n\tconst signatureScheme = SIGNATURE_FLAG_TO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AAK;AACJ,eAAY,IAAI,kBAAkB,MAAM;AACxC;EACD,KAAK;AACJ,eAAY,wBAAwB,UAAU,OAAO,QAAQ;AAC7D;EACD,KAAK;AACJ,eAAY,IAAI,iBAAiB,MAAM;AACvC;EACD,QACC,OAAM,IAAI,MAAM,gCAAgC,kBAAkB;;AAGpE,KAAI,QAAQ,WAAW,UAAU,cAAc,KAAK,QAAQ,QAC3D,OAAM,IAAI,MAAM,qDAAqD;AAGtE,QAAO;;AAGR,SAAgB,sBACf,WACA,UAA4D,EAAE,EAC7D;CACD,MAAM,QAAQ,OAAO,cAAc,WAAW,WAAW,UAAU,GAAG;CAEtE,MAAM,kBAAkB,yBAAyB,MAAM;AAEvD,QAAO,sBAAsB,iBAAiB,MAAM,MAAM,EAAE,EAAE,QAAQ"}
package/dist/version.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/version.ts
2
- const PACKAGE_VERSION = "2.18.0";
2
+ const PACKAGE_VERSION = "2.19.0";
3
3
 
4
4
  //#endregion
5
5
  export { PACKAGE_VERSION };
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.18.0';\n"],"mappings":";AAKA,MAAa,kBAAkB"}
1
+ {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// This file is generated by genversion.mjs. Do not edit it directly.\n\nexport const PACKAGE_VERSION = '2.19.0';\n"],"mappings":";AAKA,MAAa,kBAAkB"}
@@ -185,7 +185,11 @@ The built-in mutation hooks have been removed. Use TanStack Query's `useMutation
185
185
 
186
186
  In the old dApp kit, you could optionally pass a `chain` parameter (for example, `sui:mainnet`) to
187
187
  methods like `signTransaction` and `signAndExecuteTransaction`. In the new dApp kit, use the
188
- `network` parameter instead - the chain is automatically derived from the network.
188
+ `network` parameter instead - the chain is automatically derived from the network. It is optional
189
+ and defaults to the active network, so you only need it when targeting a network other than the
190
+ active one (for example, an app that operates on both mainnet and testnet). Likewise, the
191
+ per-account `account` override is preserved as an optional parameter that defaults to the connected
192
+ account.
189
193
 
190
194
  ```diff
191
195
  - const { mutateAsync: signAndExecute } = useSignAndExecuteTransaction();
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Mysten Labs <build@mystenlabs.com>",
4
4
  "description": "Sui TypeScript API",
5
5
  "homepage": "https://sdk.mystenlabs.com",
6
- "version": "2.18.0",
6
+ "version": "2.19.0",
7
7
  "license": "Apache-2.0",
8
8
  "sideEffects": false,
9
9
  "files": [
@@ -168,8 +168,8 @@
168
168
  "graphql": "^16.14.2",
169
169
  "poseidon-lite": "0.2.1",
170
170
  "valibot": "^1.4.1",
171
- "@mysten/utils": "^0.4.0",
172
- "@mysten/bcs": "^2.1.0"
171
+ "@mysten/bcs": "^2.1.0",
172
+ "@mysten/utils": "^0.4.0"
173
173
  },
174
174
  "scripts": {
175
175
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
@@ -5,6 +5,9 @@ export {
5
5
  verifySignature,
6
6
  verifyPersonalMessageSignature,
7
7
  verifyTransactionSignature,
8
+ isValidSignature,
9
+ isValidPersonalMessageSignature,
10
+ isValidTransactionSignature,
8
11
  publicKeyFromRawBytes,
9
12
  publicKeyFromSuiBytes,
10
13
  } from './verify.js';
@@ -13,24 +13,65 @@ import { MultiSigPublicKey } from '../multisig/publickey.js';
13
13
  import { ZkLoginPublicIdentifier } from '../zklogin/publickey.js';
14
14
  import type { ClientWithCoreApi } from '../client/core.js';
15
15
 
16
+ /**
17
+ * Whether `signature` is a valid signature over `bytes` (and, if `options.address`
18
+ * is given, was produced by that address). Returns `false` for a malformed or
19
+ * cryptographically invalid signature, or one that doesn't match the address;
20
+ * only an *environmental* failure (e.g. a zkLogin JWK/epoch lookup) throws, so a
21
+ * network blip is never reported as an invalid signature.
22
+ */
23
+ export async function isValidSignature(
24
+ bytes: Uint8Array,
25
+ signature: string,
26
+ options: { address?: string } = {},
27
+ ): Promise<boolean> {
28
+ const parsed = tryParseSignature(signature);
29
+ if (!parsed) return false;
30
+ if (!(await parsed.publicKey.verify(bytes, parsed.serializedSignature))) return false;
31
+ return options.address ? parsed.publicKey.verifyAddress(options.address) : true;
32
+ }
33
+
34
+ /** Like {@link isValidSignature}, for a personal message. */
35
+ export async function isValidPersonalMessageSignature(
36
+ message: Uint8Array,
37
+ signature: string,
38
+ options: { client?: ClientWithCoreApi; address?: string } = {},
39
+ ): Promise<boolean> {
40
+ const parsed = tryParseSignature(signature, { client: options.client });
41
+ if (!parsed) return false;
42
+ if (!(await parsed.publicKey.verifyPersonalMessage(message, parsed.serializedSignature))) {
43
+ return false;
44
+ }
45
+ return options.address ? parsed.publicKey.verifyAddress(options.address) : true;
46
+ }
47
+
48
+ /** Like {@link isValidSignature}, for transaction bytes. */
49
+ export async function isValidTransactionSignature(
50
+ transaction: Uint8Array,
51
+ signature: string,
52
+ options: { client?: ClientWithCoreApi; address?: string } = {},
53
+ ): Promise<boolean> {
54
+ const parsed = tryParseSignature(signature, { client: options.client });
55
+ if (!parsed) return false;
56
+ if (!(await parsed.publicKey.verifyTransaction(transaction, parsed.serializedSignature))) {
57
+ return false;
58
+ }
59
+ return options.address ? parsed.publicKey.verifyAddress(options.address) : true;
60
+ }
61
+
16
62
  export async function verifySignature(
17
63
  bytes: Uint8Array,
18
64
  signature: string,
19
- options?: {
20
- address?: string;
21
- },
65
+ options: { address?: string } = {},
22
66
  ): Promise<PublicKey> {
23
- const parsedSignature = parseSignature(signature);
24
-
25
- if (!(await parsedSignature.publicKey.verify(bytes, parsedSignature.serializedSignature))) {
67
+ const { publicKey } = parseSignature(signature);
68
+ if (!(await isValidSignature(bytes, signature))) {
26
69
  throw new Error(`Signature is not valid for the provided data`);
27
70
  }
28
-
29
- if (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {
71
+ if (options.address && !publicKey.verifyAddress(options.address)) {
30
72
  throw new Error(`Signature is not valid for the provided address`);
31
73
  }
32
-
33
- return parsedSignature.publicKey;
74
+ return publicKey;
34
75
  }
35
76
 
36
77
  export async function verifyPersonalMessageSignature(
@@ -38,22 +79,14 @@ export async function verifyPersonalMessageSignature(
38
79
  signature: string,
39
80
  options: { client?: ClientWithCoreApi; address?: string } = {},
40
81
  ): Promise<PublicKey> {
41
- const parsedSignature = parseSignature(signature, options);
42
-
43
- if (
44
- !(await parsedSignature.publicKey.verifyPersonalMessage(
45
- message,
46
- parsedSignature.serializedSignature,
47
- ))
48
- ) {
82
+ const { publicKey } = parseSignature(signature, options);
83
+ if (!(await isValidPersonalMessageSignature(message, signature, { client: options.client }))) {
49
84
  throw new Error(`Signature is not valid for the provided message`);
50
85
  }
51
-
52
- if (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {
86
+ if (options.address && !publicKey.verifyAddress(options.address)) {
53
87
  throw new Error(`Signature is not valid for the provided address`);
54
88
  }
55
-
56
- return parsedSignature.publicKey;
89
+ return publicKey;
57
90
  }
58
91
 
59
92
  export async function verifyTransactionSignature(
@@ -61,22 +94,14 @@ export async function verifyTransactionSignature(
61
94
  signature: string,
62
95
  options: { client?: ClientWithCoreApi; address?: string } = {},
63
96
  ): Promise<PublicKey> {
64
- const parsedSignature = parseSignature(signature, options);
65
-
66
- if (
67
- !(await parsedSignature.publicKey.verifyTransaction(
68
- transaction,
69
- parsedSignature.serializedSignature,
70
- ))
71
- ) {
97
+ const { publicKey } = parseSignature(signature, options);
98
+ if (!(await isValidTransactionSignature(transaction, signature, { client: options.client }))) {
72
99
  throw new Error(`Signature is not valid for the provided Transaction`);
73
100
  }
74
-
75
- if (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {
101
+ if (options.address && !publicKey.verifyAddress(options.address)) {
76
102
  throw new Error(`Signature is not valid for the provided address`);
77
103
  }
78
-
79
- return parsedSignature.publicKey;
104
+ return publicKey;
80
105
  }
81
106
 
82
107
  function parseSignature(signature: string, options: { client?: ClientWithCoreApi } = {}) {
@@ -100,6 +125,15 @@ function parseSignature(signature: string, options: { client?: ClientWithCoreApi
100
125
  };
101
126
  }
102
127
 
128
+ /** {@link parseSignature}, returning `null` instead of throwing on a malformed signature. */
129
+ function tryParseSignature(signature: string, options: { client?: ClientWithCoreApi } = {}) {
130
+ try {
131
+ return parseSignature(signature, options);
132
+ } catch {
133
+ return null;
134
+ }
135
+ }
136
+
103
137
  export function publicKeyFromRawBytes(
104
138
  signatureScheme: SignatureScheme,
105
139
  bytes: Uint8Array,
package/src/version.ts CHANGED
@@ -3,4 +3,4 @@
3
3
 
4
4
  // This file is generated by genversion.mjs. Do not edit it directly.
5
5
 
6
- export const PACKAGE_VERSION = '2.18.0';
6
+ export const PACKAGE_VERSION = '2.19.0';