@mysten/sui 1.17.0 → 1.18.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.
Files changed (177) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/bcs/bcs.d.ts +95 -95
  3. package/dist/cjs/bcs/effects.d.ts +41 -41
  4. package/dist/cjs/bcs/index.d.ts +136 -136
  5. package/dist/cjs/client/client.d.ts +1 -0
  6. package/dist/cjs/client/types/generated.d.ts +76 -27
  7. package/dist/cjs/client/types/generated.js.map +1 -1
  8. package/dist/cjs/client/types/params.d.ts +5 -1
  9. package/dist/cjs/client/types/params.js.map +1 -1
  10. package/dist/cjs/cryptography/intent.d.ts +1 -1
  11. package/dist/cjs/cryptography/publickey.d.ts +4 -0
  12. package/dist/cjs/cryptography/publickey.js +6 -0
  13. package/dist/cjs/cryptography/publickey.js.map +2 -2
  14. package/dist/cjs/cryptography/signature.d.ts +9 -9
  15. package/dist/cjs/graphql/generated/2024.1/tada-env.d.ts +11380 -0
  16. package/dist/cjs/graphql/generated/2024.1/tada-env.js +13142 -0
  17. package/dist/cjs/graphql/generated/2024.1/tada-env.js.map +7 -0
  18. package/dist/cjs/graphql/generated/2024.1/tsconfig.tada.js +1 -1
  19. package/dist/cjs/graphql/generated/2024.1/tsconfig.tada.js.map +1 -1
  20. package/dist/cjs/graphql/generated/2024.4/tada-env.d.ts +11496 -0
  21. package/dist/cjs/graphql/generated/2024.4/tada-env.js +13288 -0
  22. package/dist/cjs/graphql/generated/2024.4/tada-env.js.map +7 -0
  23. package/dist/cjs/graphql/generated/2024.4/tsconfig.tada.js +1 -1
  24. package/dist/cjs/graphql/generated/2024.4/tsconfig.tada.js.map +1 -1
  25. package/dist/cjs/graphql/generated/latest/tada-env.d.ts +12540 -0
  26. package/dist/cjs/graphql/generated/latest/tada-env.js +14498 -0
  27. package/dist/cjs/graphql/generated/latest/tada-env.js.map +7 -0
  28. package/dist/cjs/graphql/generated/latest/tsconfig.tada.js +12 -0
  29. package/dist/cjs/graphql/generated/latest/tsconfig.tada.js.map +7 -0
  30. package/dist/cjs/graphql/schemas/2024.1/index.d.ts +6 -8999
  31. package/dist/cjs/graphql/schemas/2024.1/index.js.map +1 -1
  32. package/dist/cjs/graphql/schemas/2024.4/index.d.ts +6 -9053
  33. package/dist/cjs/graphql/schemas/2024.4/index.js.map +1 -1
  34. package/dist/cjs/graphql/schemas/latest/index.d.ts +10 -0
  35. package/dist/cjs/graphql/schemas/latest/index.js +31 -0
  36. package/dist/cjs/graphql/schemas/latest/index.js.map +7 -0
  37. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.d.ts +0 -5
  38. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +1 -25
  39. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js.map +3 -3
  40. package/dist/cjs/keypairs/ed25519/keypair.d.ts +1 -1
  41. package/dist/cjs/keypairs/ed25519/keypair.js +22 -18
  42. package/dist/cjs/keypairs/ed25519/keypair.js.map +3 -3
  43. package/dist/cjs/keypairs/ed25519/publickey.js +2 -12
  44. package/dist/cjs/keypairs/ed25519/publickey.js.map +3 -3
  45. package/dist/cjs/keypairs/passkey/keypair.d.ts +1 -1
  46. package/dist/cjs/keypairs/passkey/publickey.d.ts +4 -4
  47. package/dist/cjs/keypairs/secp256k1/keypair.d.ts +1 -1
  48. package/dist/cjs/keypairs/secp256r1/keypair.d.ts +1 -1
  49. package/dist/cjs/transactions/Arguments.d.ts +11 -980
  50. package/dist/cjs/transactions/Arguments.js +1 -3
  51. package/dist/cjs/transactions/Arguments.js.map +2 -2
  52. package/dist/cjs/transactions/ObjectCache.d.ts +2 -1
  53. package/dist/cjs/transactions/ObjectCache.js +8 -3
  54. package/dist/cjs/transactions/ObjectCache.js.map +2 -2
  55. package/dist/cjs/transactions/Transaction.d.ts +13 -33
  56. package/dist/cjs/transactions/Transaction.js +8 -8
  57. package/dist/cjs/transactions/Transaction.js.map +2 -2
  58. package/dist/cjs/transactions/TransactionData.d.ts +1 -1
  59. package/dist/cjs/transactions/executor/caching.d.ts +1 -1
  60. package/dist/cjs/transactions/executor/serial.d.ts +3 -3
  61. package/dist/cjs/transactions/executor/serial.js +3 -5
  62. package/dist/cjs/transactions/executor/serial.js.map +3 -3
  63. package/dist/cjs/verify/verify.d.ts +5 -1
  64. package/dist/cjs/verify/verify.js +10 -1
  65. package/dist/cjs/verify/verify.js.map +2 -2
  66. package/dist/cjs/version.d.ts +2 -2
  67. package/dist/cjs/version.js +2 -2
  68. package/dist/cjs/version.js.map +1 -1
  69. package/dist/cjs/zklogin/publickey.d.ts +6 -2
  70. package/dist/cjs/zklogin/publickey.js +22 -10
  71. package/dist/cjs/zklogin/publickey.js.map +2 -2
  72. package/dist/esm/bcs/bcs.d.ts +95 -95
  73. package/dist/esm/bcs/effects.d.ts +41 -41
  74. package/dist/esm/bcs/index.d.ts +136 -136
  75. package/dist/esm/client/client.d.ts +1 -0
  76. package/dist/esm/client/types/generated.d.ts +76 -27
  77. package/dist/esm/client/types/params.d.ts +5 -1
  78. package/dist/esm/cryptography/intent.d.ts +1 -1
  79. package/dist/esm/cryptography/publickey.d.ts +4 -0
  80. package/dist/esm/cryptography/publickey.js +6 -0
  81. package/dist/esm/cryptography/publickey.js.map +2 -2
  82. package/dist/esm/cryptography/signature.d.ts +9 -9
  83. package/dist/esm/graphql/generated/2024.1/tada-env.d.ts +11380 -0
  84. package/dist/esm/graphql/generated/2024.1/tada-env.js +13122 -0
  85. package/dist/esm/graphql/generated/2024.1/tada-env.js.map +7 -0
  86. package/dist/esm/graphql/generated/2024.1/tsconfig.tada.js +1 -1
  87. package/dist/esm/graphql/generated/2024.1/tsconfig.tada.js.map +1 -1
  88. package/dist/esm/graphql/generated/2024.4/tada-env.d.ts +11496 -0
  89. package/dist/esm/graphql/generated/2024.4/tada-env.js +13268 -0
  90. package/dist/esm/graphql/generated/2024.4/tada-env.js.map +7 -0
  91. package/dist/esm/graphql/generated/2024.4/tsconfig.tada.js +1 -1
  92. package/dist/esm/graphql/generated/2024.4/tsconfig.tada.js.map +1 -1
  93. package/dist/esm/graphql/generated/latest/tada-env.d.ts +12540 -0
  94. package/dist/esm/graphql/generated/latest/tada-env.js +14478 -0
  95. package/dist/esm/graphql/generated/latest/tada-env.js.map +7 -0
  96. package/dist/esm/graphql/generated/latest/tsconfig.tada.js +17 -0
  97. package/dist/esm/graphql/generated/latest/tsconfig.tada.js.map +7 -0
  98. package/dist/esm/graphql/schemas/2024.1/index.d.ts +6 -8999
  99. package/dist/esm/graphql/schemas/2024.1/index.js.map +1 -1
  100. package/dist/esm/graphql/schemas/2024.4/index.d.ts +6 -9053
  101. package/dist/esm/graphql/schemas/2024.4/index.js.map +1 -1
  102. package/dist/esm/graphql/schemas/latest/index.d.ts +10 -0
  103. package/dist/esm/graphql/schemas/latest/index.js +10 -0
  104. package/dist/esm/graphql/schemas/latest/index.js.map +7 -0
  105. package/dist/esm/keypairs/ed25519/ed25519-hd-key.d.ts +0 -5
  106. package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +1 -15
  107. package/dist/esm/keypairs/ed25519/ed25519-hd-key.js.map +2 -2
  108. package/dist/esm/keypairs/ed25519/keypair.d.ts +1 -1
  109. package/dist/esm/keypairs/ed25519/keypair.js +22 -8
  110. package/dist/esm/keypairs/ed25519/keypair.js.map +2 -2
  111. package/dist/esm/keypairs/ed25519/publickey.js +2 -2
  112. package/dist/esm/keypairs/ed25519/publickey.js.map +2 -2
  113. package/dist/esm/keypairs/passkey/keypair.d.ts +1 -1
  114. package/dist/esm/keypairs/passkey/publickey.d.ts +4 -4
  115. package/dist/esm/keypairs/secp256k1/keypair.d.ts +1 -1
  116. package/dist/esm/keypairs/secp256r1/keypair.d.ts +1 -1
  117. package/dist/esm/transactions/Arguments.d.ts +11 -980
  118. package/dist/esm/transactions/Arguments.js +1 -3
  119. package/dist/esm/transactions/Arguments.js.map +2 -2
  120. package/dist/esm/transactions/ObjectCache.d.ts +2 -1
  121. package/dist/esm/transactions/ObjectCache.js +8 -3
  122. package/dist/esm/transactions/ObjectCache.js.map +2 -2
  123. package/dist/esm/transactions/Transaction.d.ts +13 -33
  124. package/dist/esm/transactions/Transaction.js +8 -8
  125. package/dist/esm/transactions/Transaction.js.map +2 -2
  126. package/dist/esm/transactions/TransactionData.d.ts +1 -1
  127. package/dist/esm/transactions/executor/caching.d.ts +1 -1
  128. package/dist/esm/transactions/executor/serial.d.ts +3 -3
  129. package/dist/esm/transactions/executor/serial.js +3 -5
  130. package/dist/esm/transactions/executor/serial.js.map +2 -2
  131. package/dist/esm/verify/verify.d.ts +5 -1
  132. package/dist/esm/verify/verify.js +10 -1
  133. package/dist/esm/verify/verify.js.map +2 -2
  134. package/dist/esm/version.d.ts +2 -2
  135. package/dist/esm/version.js +2 -2
  136. package/dist/esm/version.js.map +1 -1
  137. package/dist/esm/zklogin/publickey.d.ts +6 -2
  138. package/dist/esm/zklogin/publickey.js +21 -9
  139. package/dist/esm/zklogin/publickey.js.map +2 -2
  140. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  141. package/dist/tsconfig.tsbuildinfo +1 -1
  142. package/graphql/schemas/latest/package.json +6 -0
  143. package/package.json +15 -13
  144. package/src/client/types/generated.ts +110 -59
  145. package/src/client/types/params.ts +5 -1
  146. package/src/cryptography/publickey.ts +7 -0
  147. package/src/graphql/generated/2024.1/tada-env.ts +13144 -0
  148. package/src/graphql/generated/2024.1/tsconfig.tada.json +1 -1
  149. package/src/graphql/generated/2024.4/tada-env.ts +13290 -0
  150. package/src/graphql/generated/2024.4/tsconfig.tada.json +1 -1
  151. package/src/graphql/generated/latest/schema.graphql +4808 -0
  152. package/src/graphql/generated/latest/tada-env.ts +14500 -0
  153. package/src/graphql/generated/latest/tsconfig.tada.json +11 -0
  154. package/src/graphql/schemas/2024.1/index.ts +1 -1
  155. package/src/graphql/schemas/2024.4/index.ts +1 -1
  156. package/src/graphql/schemas/latest/index.ts +17 -0
  157. package/src/keypairs/ed25519/ed25519-hd-key.ts +4 -14
  158. package/src/keypairs/ed25519/keypair.ts +23 -8
  159. package/src/keypairs/ed25519/publickey.ts +2 -2
  160. package/src/transactions/Arguments.ts +6 -5
  161. package/src/transactions/ObjectCache.ts +5 -1
  162. package/src/transactions/Transaction.ts +21 -15
  163. package/src/transactions/__tests__/bcs.test.ts +1 -1
  164. package/src/transactions/executor/serial.ts +3 -5
  165. package/src/verify/verify.ts +21 -3
  166. package/src/version.ts +2 -2
  167. package/src/zklogin/publickey.ts +19 -8
  168. package/dist/cjs/graphql/generated/2024.1/tada-env.d.js +0 -17
  169. package/dist/cjs/graphql/generated/2024.1/tada-env.d.js.map +0 -7
  170. package/dist/cjs/graphql/generated/2024.4/tada-env.d.js +0 -17
  171. package/dist/cjs/graphql/generated/2024.4/tada-env.d.js.map +0 -7
  172. package/dist/esm/graphql/generated/2024.1/tada-env.d.js +0 -1
  173. package/dist/esm/graphql/generated/2024.1/tada-env.d.js.map +0 -7
  174. package/dist/esm/graphql/generated/2024.4/tada-env.d.js +0 -1
  175. package/dist/esm/graphql/generated/2024.4/tada-env.d.js.map +0 -7
  176. package/src/graphql/generated/2024.1/tada-env.d.ts +0 -201
  177. package/src/graphql/generated/2024.4/tada-env.d.ts +0 -203
@@ -25,6 +25,7 @@ type NetworkOrTransport = {
25
25
  };
26
26
  export declare function isSuiClient(client: unknown): client is SuiClient;
27
27
  export declare class SuiClient {
28
+ [x: number]: boolean;
28
29
  protected transport: SuiTransport;
29
30
  /**
30
31
  * Establish a connection to a Sui RPC endpoint
@@ -6,6 +6,11 @@
6
6
  * This file is generated from:
7
7
  * /crates/sui-open-rpc/spec/openrpc.json
8
8
  */
9
+ export type Authenticator =
10
+ /** The contained SuiAddress exclusively has all permissions: read, write, delete, transfer */
11
+ {
12
+ SingleOwner: string;
13
+ };
9
14
  export interface Balance {
10
15
  coinObjectCount: number;
11
16
  coinType: string;
@@ -154,15 +159,25 @@ export interface DryRunTransactionBlockResponse {
154
159
  input: TransactionBlockData;
155
160
  objectChanges: SuiObjectChange[];
156
161
  }
157
- export interface DynamicFieldInfo {
162
+ export type DynamicFieldInfo = {
163
+ digest: string;
164
+ name: DynamicFieldName;
165
+ objectId: string;
166
+ objectType: string;
167
+ type: DynamicFieldType;
168
+ version: string;
169
+ bcsEncoding: 'base64';
158
170
  bcsName: string;
171
+ } | {
159
172
  digest: string;
160
173
  name: DynamicFieldName;
161
174
  objectId: string;
162
175
  objectType: string;
163
176
  type: DynamicFieldType;
164
177
  version: string;
165
- }
178
+ bcsEncoding: 'base58';
179
+ bcsName: string;
180
+ };
166
181
  export interface DynamicFieldName {
167
182
  type: string;
168
183
  value: unknown;
@@ -190,9 +205,28 @@ export interface EndOfEpochData {
190
205
  */
191
206
  nextEpochProtocolVersion: string;
192
207
  }
193
- export interface SuiEvent {
194
- /** Base 58 encoded bcs bytes of the move event */
208
+ export type SuiEvent = {
209
+ /**
210
+ * Sequential event ID, ie (transaction seq number, event seq number). 1) Serves as a unique event ID
211
+ * for each fullnode 2) Also serves to sequence events for the purposes of pagination and querying. A
212
+ * higher id is an event seen later by that fullnode. This ID is the "cursor" for event querying.
213
+ */
214
+ id: EventId;
215
+ /** Move package where this event was emitted. */
216
+ packageId: string;
217
+ /** Parsed json value of the event */
218
+ parsedJson: unknown;
219
+ /** Sender's Sui address. */
220
+ sender: string;
221
+ /** UTC timestamp in milliseconds since epoch (1/1/1970) */
222
+ timestampMs?: string | null;
223
+ /** Move module where this event was emitted. */
224
+ transactionModule: string;
225
+ /** Move event type. */
226
+ type: string;
195
227
  bcs: string;
228
+ bcsEncoding: 'base64';
229
+ } | {
196
230
  /**
197
231
  * Sequential event ID, ie (transaction seq number, event seq number). 1) Serves as a unique event ID
198
232
  * for each fullnode 2) Also serves to sequence events for the purposes of pagination and querying. A
@@ -211,15 +245,19 @@ export interface SuiEvent {
211
245
  transactionModule: string;
212
246
  /** Move event type. */
213
247
  type: string;
214
- }
248
+ bcs: string;
249
+ bcsEncoding: 'base58';
250
+ };
215
251
  export type SuiEventFilter =
216
- /** Query by sender address. */
252
+ /** Return all events. */
217
253
  {
254
+ All: [];
255
+ } /** Return events that match any of the given filters. Only supported on event subscriptions. */ | {
256
+ Any: SuiEventFilter[];
257
+ } /** Query by sender address. */ | {
218
258
  Sender: string;
219
259
  } /** Return events emitted by the given transaction. */ | {
220
260
  Transaction: string;
221
- } /** Return events emitted in a specified Package. */ | {
222
- Package: string;
223
261
  } /**
224
262
  * Return events emitted in a specified Move module. If the event is defined in Module A but emitted in
225
263
  * a tx with Module B, query `MoveModule` by module B returns the event. Query `MoveEventModule` by
@@ -247,11 +285,6 @@ export type SuiEventFilter =
247
285
  /** the Move package ID */
248
286
  package: string;
249
287
  };
250
- } | {
251
- MoveEventField: {
252
- path: string;
253
- value: unknown;
254
- };
255
288
  } /** Return events emitted in [start_time, end_time] interval */ | {
256
289
  TimeRange: {
257
290
  /** right endpoint of time interval, milliseconds since epoch, exclusive */
@@ -259,18 +292,8 @@ export type SuiEventFilter =
259
292
  /** left endpoint of time interval, milliseconds since epoch, inclusive */
260
293
  startTime: string;
261
294
  };
262
- } | {
263
- All: SuiEventFilter[];
264
- } | {
265
- Any: SuiEventFilter[];
266
- } | {
267
- And: [SuiEventFilter, SuiEventFilter];
268
- } | {
269
- Or: [SuiEventFilter, SuiEventFilter];
270
295
  };
271
- /**
272
- * Unique ID of a Sui Event, the ID is a combination of transaction digest and event seq number.
273
- */
296
+ /** Unique ID of a Sui Event, the ID is a combination of transaction digest and event seq number. */
274
297
  export interface EventId {
275
298
  eventSeq: string;
276
299
  txDigest: string;
@@ -593,7 +616,21 @@ export type ObjectOwner =
593
616
  /** The version at which the object became shared */
594
617
  initial_shared_version: string;
595
618
  };
596
- } | 'Immutable';
619
+ } | 'Immutable' /**
620
+ * Object is sequenced via consensus. Ownership is managed by the configured authenticator.
621
+ *
622
+ * Note: wondering what happened to `V1`? `Shared` above was the V1 of consensus objects.
623
+ */ | {
624
+ ConsensusV2: {
625
+ /** The authentication mode of the object */
626
+ authenticator: Authenticator;
627
+ /**
628
+ * The version at which the object most recently became a consensus object. This serves the same
629
+ * function as `initial_shared_version`, except it may change if the object's Owner type changes.
630
+ */
631
+ start_version: string;
632
+ };
633
+ };
597
634
  /**
598
635
  * `next_cursor` points to the last item in the page; Reading with `next_cursor` will start from the
599
636
  * next item after `next_cursor` if `next_cursor` is `Some`, otherwise it will start from the first
@@ -864,6 +901,13 @@ export interface SuiMoveModuleId {
864
901
  address: string;
865
902
  name: string;
866
903
  }
904
+ export interface SuiMoveNormalizedEnum {
905
+ abilities: SuiMoveAbilitySet;
906
+ typeParameters: SuiMoveStructTypeParameter[];
907
+ variants: {
908
+ [key: string]: SuiMoveNormalizedField[];
909
+ };
910
+ }
867
911
  export interface SuiMoveNormalizedField {
868
912
  name: string;
869
913
  type: SuiMoveNormalizedType;
@@ -877,6 +921,9 @@ export interface SuiMoveNormalizedFunction {
877
921
  }
878
922
  export interface SuiMoveNormalizedModule {
879
923
  address: string;
924
+ enums?: {
925
+ [key: string]: SuiMoveNormalizedEnum;
926
+ };
880
927
  exposedFunctions: {
881
928
  [key: string]: SuiMoveNormalizedFunction;
882
929
  };
@@ -1336,7 +1383,7 @@ export interface SuiTransactionBlockResponseQuery {
1336
1383
  options?: SuiTransactionBlockResponseOptions | null;
1337
1384
  }
1338
1385
  export type TransactionFilter =
1339
- /** Query by checkpoint. */
1386
+ /** CURRENTLY NOT SUPPORTED. Query by checkpoint. */
1340
1387
  {
1341
1388
  Checkpoint: string;
1342
1389
  } /** Query by move function. */ | {
@@ -1349,6 +1396,8 @@ export type TransactionFilter =
1349
1396
  InputObject: string;
1350
1397
  } /** Query by changed object, including created, mutated and unwrapped objects. */ | {
1351
1398
  ChangedObject: string;
1399
+ } /** Query for transactions that touch this object. */ | {
1400
+ AffectedObject: string;
1352
1401
  } /** Query by sender address. */ | {
1353
1402
  FromAddress: string;
1354
1403
  } /** Query by recipient address. */ | {
@@ -1358,7 +1407,7 @@ export type TransactionFilter =
1358
1407
  from: string;
1359
1408
  to: string;
1360
1409
  };
1361
- } /** Query txs that have a given address as sender or recipient. */ | {
1410
+ } /** CURRENTLY NOT SUPPORTED. Query txs that have a given address as sender or recipient. */ | {
1362
1411
  FromOrToAddress: {
1363
1412
  addr: string;
1364
1413
  };
@@ -202,7 +202,11 @@ export interface GetBalanceParams {
202
202
  */
203
203
  coinType?: string | null | undefined;
204
204
  }
205
- /** Return metadata(e.g., symbol, decimals) for a coin */
205
+ /**
206
+ * Return metadata (e.g., symbol, decimals) for a coin. Note that if the coin's metadata was wrapped in
207
+ * the transaction that published its marker type, or the latest version of the metadata object is
208
+ * wrapped or deleted, it will not be found.
209
+ */
206
210
  export interface GetCoinMetadataParams {
207
211
  /** type name for the coin (e.g., 0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC) */
208
212
  coinType: string;
@@ -3,4 +3,4 @@ export type IntentScope = Exclude<keyof typeof bcs.IntentScope.$inferType, '$kin
3
3
  /**
4
4
  * Inserts a domain separator for a message that is being signed
5
5
  */
6
- export declare function messageWithIntent(scope: IntentScope, message: Uint8Array): Uint8Array;
6
+ export declare function messageWithIntent(scope: IntentScope, message: Uint8Array): Uint8Array<ArrayBufferLike>;
@@ -32,6 +32,10 @@ export declare abstract class PublicKey {
32
32
  * Verifies that the signature is valid for for the provided Transaction
33
33
  */
34
34
  verifyTransaction(transaction: Uint8Array, signature: Uint8Array | string): Promise<boolean>;
35
+ /**
36
+ * Verifies that the public key is associated with the provided address
37
+ */
38
+ verifyAddress(address: string): boolean;
35
39
  /**
36
40
  * Returns the bytes representation of the public key
37
41
  * prefixed with the signature scheme flag
@@ -64,6 +64,12 @@ class PublicKey {
64
64
  verifyTransaction(transaction, signature) {
65
65
  return this.verifyWithIntent(transaction, signature, "TransactionData");
66
66
  }
67
+ /**
68
+ * Verifies that the public key is associated with the provided address
69
+ */
70
+ verifyAddress(address) {
71
+ return this.toSuiAddress() === address;
72
+ }
67
73
  /**
68
74
  * Returns the bytes representation of the public key
69
75
  * prefixed with the signature scheme flag
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cryptography/publickey.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { toBase64 } from '@mysten/bcs';\nimport { blake2b } from '@noble/hashes/blake2b';\nimport { bytesToHex } from '@noble/hashes/utils';\n\nimport { bcs } from '../bcs/index.js';\nimport { normalizeSuiAddress, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';\nimport type { IntentScope } from './intent.js';\nimport { messageWithIntent } from './intent.js';\n\n/**\n * Value to be converted into public key.\n */\nexport type PublicKeyInitData = string | Uint8Array | Iterable<number>;\n\nexport function bytesEqual(a: Uint8Array, b: Uint8Array) {\n\tif (a === b) return true;\n\n\tif (a.length !== b.length) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < a.length; i++) {\n\t\tif (a[i] !== b[i]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * A public key\n */\nexport abstract class PublicKey {\n\t/**\n\t * Checks if two public keys are equal\n\t */\n\tequals(publicKey: PublicKey) {\n\t\treturn bytesEqual(this.toRawBytes(), publicKey.toRawBytes());\n\t}\n\n\t/**\n\t * Return the base-64 representation of the public key\n\t */\n\ttoBase64() {\n\t\treturn toBase64(this.toRawBytes());\n\t}\n\n\ttoString(): never {\n\t\tthrow new Error(\n\t\t\t'`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.',\n\t\t);\n\t}\n\n\t/**\n\t * Return the Sui representation of the public key encoded in\n\t * base-64. A Sui public key is formed by the concatenation\n\t * of the scheme flag with the raw bytes of the public key\n\t */\n\ttoSuiPublicKey(): string {\n\t\tconst bytes = this.toSuiBytes();\n\t\treturn toBase64(bytes);\n\t}\n\n\tverifyWithIntent(\n\t\tbytes: Uint8Array,\n\t\tsignature: Uint8Array | string,\n\t\tintent: IntentScope,\n\t): Promise<boolean> {\n\t\tconst intentMessage = messageWithIntent(intent, bytes);\n\t\tconst digest = blake2b(intentMessage, { dkLen: 32 });\n\n\t\treturn this.verify(digest, signature);\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided PersonalMessage\n\t */\n\tverifyPersonalMessage(message: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\treturn this.verifyWithIntent(\n\t\t\tbcs.vector(bcs.u8()).serialize(message).toBytes(),\n\t\t\tsignature,\n\t\t\t'PersonalMessage',\n\t\t);\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided Transaction\n\t */\n\tverifyTransaction(transaction: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\treturn this.verifyWithIntent(transaction, signature, 'TransactionData');\n\t}\n\n\t/**\n\t * Returns the bytes representation of the public key\n\t * prefixed with the signature scheme flag\n\t */\n\ttoSuiBytes(): Uint8Array {\n\t\tconst rawBytes = this.toRawBytes();\n\t\tconst suiBytes = new Uint8Array(rawBytes.length + 1);\n\t\tsuiBytes.set([this.flag()]);\n\t\tsuiBytes.set(rawBytes, 1);\n\n\t\treturn suiBytes;\n\t}\n\n\t/**\n\t * Return the Sui address associated with this Ed25519 public key\n\t */\n\ttoSuiAddress(): string {\n\t\t// Each hex char represents half a byte, hence hex address doubles the length\n\t\treturn normalizeSuiAddress(\n\t\t\tbytesToHex(blake2b(this.toSuiBytes(), { dkLen: 32 })).slice(0, SUI_ADDRESS_LENGTH * 2),\n\t\t);\n\t}\n\n\t/**\n\t * Return the byte array representation of the public key\n\t */\n\tabstract toRawBytes(): Uint8Array;\n\n\t/**\n\t * Return signature scheme flag of the public key\n\t */\n\tabstract flag(): number;\n\n\t/**\n\t * Verifies that the signature is valid for for the provided message\n\t */\n\tabstract verify(data: Uint8Array, signature: Uint8Array | string): Promise<boolean>;\n}\n"],
5
- "mappings": "AAGA,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAE3B,SAAS,WAAW;AACpB,SAAS,qBAAqB,0BAA0B;AAExD,SAAS,yBAAyB;AAO3B,SAAS,WAAW,GAAe,GAAe;AACxD,MAAI,MAAM,EAAG,QAAO;AAEpB,MAAI,EAAE,WAAW,EAAE,QAAQ;AAC1B,WAAO;AAAA,EACR;AAEA,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AAClC,QAAI,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG;AAClB,aAAO;AAAA,IACR;AAAA,EACD;AACA,SAAO;AACR;AAKO,MAAe,UAAU;AAAA;AAAA;AAAA;AAAA,EAI/B,OAAO,WAAsB;AAC5B,WAAO,WAAW,KAAK,WAAW,GAAG,UAAU,WAAW,CAAC;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW;AACV,WAAO,SAAS,KAAK,WAAW,CAAC;AAAA,EAClC;AAAA,EAEA,WAAkB;AACjB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,iBAAyB;AACxB,UAAM,QAAQ,KAAK,WAAW;AAC9B,WAAO,SAAS,KAAK;AAAA,EACtB;AAAA,EAEA,iBACC,OACA,WACA,QACmB;AACnB,UAAM,gBAAgB,kBAAkB,QAAQ,KAAK;AACrD,UAAM,SAAS,QAAQ,eAAe,EAAE,OAAO,GAAG,CAAC;AAEnD,WAAO,KAAK,OAAO,QAAQ,SAAS;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA,EAKA,sBAAsB,SAAqB,WAAkD;AAC5F,WAAO,KAAK;AAAA,MACX,IAAI,OAAO,IAAI,GAAG,CAAC,EAAE,UAAU,OAAO,EAAE,QAAQ;AAAA,MAChD;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB,aAAyB,WAAkD;AAC5F,WAAO,KAAK,iBAAiB,aAAa,WAAW,iBAAiB;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAyB;AACxB,UAAM,WAAW,KAAK,WAAW;AACjC,UAAM,WAAW,IAAI,WAAW,SAAS,SAAS,CAAC;AACnD,aAAS,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AAC1B,aAAS,IAAI,UAAU,CAAC;AAExB,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,eAAuB;AAEtB,WAAO;AAAA,MACN,WAAW,QAAQ,KAAK,WAAW,GAAG,EAAE,OAAO,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAC;AAAA,IACtF;AAAA,EACD;AAgBD;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { toBase64 } from '@mysten/bcs';\nimport { blake2b } from '@noble/hashes/blake2b';\nimport { bytesToHex } from '@noble/hashes/utils';\n\nimport { bcs } from '../bcs/index.js';\nimport { normalizeSuiAddress, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';\nimport type { IntentScope } from './intent.js';\nimport { messageWithIntent } from './intent.js';\n\n/**\n * Value to be converted into public key.\n */\nexport type PublicKeyInitData = string | Uint8Array | Iterable<number>;\n\nexport function bytesEqual(a: Uint8Array, b: Uint8Array) {\n\tif (a === b) return true;\n\n\tif (a.length !== b.length) {\n\t\treturn false;\n\t}\n\n\tfor (let i = 0; i < a.length; i++) {\n\t\tif (a[i] !== b[i]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * A public key\n */\nexport abstract class PublicKey {\n\t/**\n\t * Checks if two public keys are equal\n\t */\n\tequals(publicKey: PublicKey) {\n\t\treturn bytesEqual(this.toRawBytes(), publicKey.toRawBytes());\n\t}\n\n\t/**\n\t * Return the base-64 representation of the public key\n\t */\n\ttoBase64() {\n\t\treturn toBase64(this.toRawBytes());\n\t}\n\n\ttoString(): never {\n\t\tthrow new Error(\n\t\t\t'`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.',\n\t\t);\n\t}\n\n\t/**\n\t * Return the Sui representation of the public key encoded in\n\t * base-64. A Sui public key is formed by the concatenation\n\t * of the scheme flag with the raw bytes of the public key\n\t */\n\ttoSuiPublicKey(): string {\n\t\tconst bytes = this.toSuiBytes();\n\t\treturn toBase64(bytes);\n\t}\n\n\tverifyWithIntent(\n\t\tbytes: Uint8Array,\n\t\tsignature: Uint8Array | string,\n\t\tintent: IntentScope,\n\t): Promise<boolean> {\n\t\tconst intentMessage = messageWithIntent(intent, bytes);\n\t\tconst digest = blake2b(intentMessage, { dkLen: 32 });\n\n\t\treturn this.verify(digest, signature);\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided PersonalMessage\n\t */\n\tverifyPersonalMessage(message: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\treturn this.verifyWithIntent(\n\t\t\tbcs.vector(bcs.u8()).serialize(message).toBytes(),\n\t\t\tsignature,\n\t\t\t'PersonalMessage',\n\t\t);\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided Transaction\n\t */\n\tverifyTransaction(transaction: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\treturn this.verifyWithIntent(transaction, signature, 'TransactionData');\n\t}\n\n\t/**\n\t * Verifies that the public key is associated with the provided address\n\t */\n\tverifyAddress(address: string): boolean {\n\t\treturn this.toSuiAddress() === address;\n\t}\n\n\t/**\n\t * Returns the bytes representation of the public key\n\t * prefixed with the signature scheme flag\n\t */\n\ttoSuiBytes(): Uint8Array {\n\t\tconst rawBytes = this.toRawBytes();\n\t\tconst suiBytes = new Uint8Array(rawBytes.length + 1);\n\t\tsuiBytes.set([this.flag()]);\n\t\tsuiBytes.set(rawBytes, 1);\n\n\t\treturn suiBytes;\n\t}\n\n\t/**\n\t * Return the Sui address associated with this Ed25519 public key\n\t */\n\ttoSuiAddress(): string {\n\t\t// Each hex char represents half a byte, hence hex address doubles the length\n\t\treturn normalizeSuiAddress(\n\t\t\tbytesToHex(blake2b(this.toSuiBytes(), { dkLen: 32 })).slice(0, SUI_ADDRESS_LENGTH * 2),\n\t\t);\n\t}\n\n\t/**\n\t * Return the byte array representation of the public key\n\t */\n\tabstract toRawBytes(): Uint8Array;\n\n\t/**\n\t * Return signature scheme flag of the public key\n\t */\n\tabstract flag(): number;\n\n\t/**\n\t * Verifies that the signature is valid for for the provided message\n\t */\n\tabstract verify(data: Uint8Array, signature: Uint8Array | string): Promise<boolean>;\n}\n"],
5
+ "mappings": "AAGA,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAE3B,SAAS,WAAW;AACpB,SAAS,qBAAqB,0BAA0B;AAExD,SAAS,yBAAyB;AAO3B,SAAS,WAAW,GAAe,GAAe;AACxD,MAAI,MAAM,EAAG,QAAO;AAEpB,MAAI,EAAE,WAAW,EAAE,QAAQ;AAC1B,WAAO;AAAA,EACR;AAEA,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AAClC,QAAI,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG;AAClB,aAAO;AAAA,IACR;AAAA,EACD;AACA,SAAO;AACR;AAKO,MAAe,UAAU;AAAA;AAAA;AAAA;AAAA,EAI/B,OAAO,WAAsB;AAC5B,WAAO,WAAW,KAAK,WAAW,GAAG,UAAU,WAAW,CAAC;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW;AACV,WAAO,SAAS,KAAK,WAAW,CAAC;AAAA,EAClC;AAAA,EAEA,WAAkB;AACjB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,iBAAyB;AACxB,UAAM,QAAQ,KAAK,WAAW;AAC9B,WAAO,SAAS,KAAK;AAAA,EACtB;AAAA,EAEA,iBACC,OACA,WACA,QACmB;AACnB,UAAM,gBAAgB,kBAAkB,QAAQ,KAAK;AACrD,UAAM,SAAS,QAAQ,eAAe,EAAE,OAAO,GAAG,CAAC;AAEnD,WAAO,KAAK,OAAO,QAAQ,SAAS;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA,EAKA,sBAAsB,SAAqB,WAAkD;AAC5F,WAAO,KAAK;AAAA,MACX,IAAI,OAAO,IAAI,GAAG,CAAC,EAAE,UAAU,OAAO,EAAE,QAAQ;AAAA,MAChD;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB,aAAyB,WAAkD;AAC5F,WAAO,KAAK,iBAAiB,aAAa,WAAW,iBAAiB;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA,EAKA,cAAc,SAA0B;AACvC,WAAO,KAAK,aAAa,MAAM;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAyB;AACxB,UAAM,WAAW,KAAK,WAAW;AACjC,UAAM,WAAW,IAAI,WAAW,SAAS,SAAS,CAAC;AACnD,aAAS,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AAC1B,aAAS,IAAI,UAAU,CAAC;AAExB,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,eAAuB;AAEtB,WAAO;AAAA,MACN,WAAW,QAAQ,KAAK,WAAW,GAAG,EAAE,OAAO,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAC;AAAA,IACtF;AAAA,EACD;AAgBD;",
6
6
  "names": []
7
7
  }
@@ -21,11 +21,11 @@ export declare function toSerializedSignature({ signature, signatureScheme, publ
21
21
  export declare function parseSerializedSignature(serializedSignature: string): {
22
22
  signatureScheme: "Passkey";
23
23
  serializedSignature: string;
24
- signature: Uint8Array;
24
+ signature: Uint8Array<ArrayBufferLike>;
25
25
  authenticatorData: number[];
26
26
  clientDataJson: string;
27
- userSignature: Uint8Array;
28
- publicKey: Uint8Array;
27
+ userSignature: Uint8Array<ArrayBuffer>;
28
+ publicKey: Uint8Array<ArrayBuffer>;
29
29
  } | {
30
30
  serializedSignature: string;
31
31
  signatureScheme: "ZkLogin";
@@ -48,20 +48,20 @@ export declare function parseSerializedSignature(serializedSignature: string): {
48
48
  iss: string;
49
49
  addressSeed: bigint;
50
50
  };
51
- signature: Uint8Array;
52
- publicKey: Uint8Array;
51
+ signature: Uint8Array<ArrayBufferLike>;
52
+ publicKey: Uint8Array<ArrayBufferLike>;
53
53
  } | {
54
54
  serializedSignature: string;
55
55
  signatureScheme: "MultiSig";
56
56
  multisig: MultiSigStruct;
57
- bytes: Uint8Array;
57
+ bytes: Uint8Array<ArrayBufferLike>;
58
58
  signature?: undefined;
59
59
  publicKey?: undefined;
60
60
  } | {
61
61
  serializedSignature: string;
62
62
  signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
63
- signature: Uint8Array;
64
- publicKey: Uint8Array;
65
- bytes: Uint8Array;
63
+ signature: Uint8Array<ArrayBuffer>;
64
+ publicKey: Uint8Array<ArrayBuffer>;
65
+ bytes: Uint8Array<ArrayBufferLike>;
66
66
  multisig?: undefined;
67
67
  };