@mysten/sui 2.6.0 → 2.8.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/bcs/index.d.mts +20 -20
  4. package/dist/client/types.d.mts +17 -0
  5. package/dist/client/types.d.mts.map +1 -1
  6. package/dist/cryptography/signature.d.mts +14 -14
  7. package/dist/graphql/core.d.mts.map +1 -1
  8. package/dist/graphql/core.mjs +21 -8
  9. package/dist/graphql/core.mjs.map +1 -1
  10. package/dist/graphql/generated/queries.d.mts.map +1 -1
  11. package/dist/graphql/generated/queries.mjs +18 -3
  12. package/dist/graphql/generated/queries.mjs.map +1 -1
  13. package/dist/graphql/generated/tada-env.d.mts +703 -73
  14. package/dist/grpc/core.d.mts.map +1 -1
  15. package/dist/grpc/core.mjs +15 -2
  16. package/dist/grpc/core.mjs.map +1 -1
  17. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  18. package/dist/grpc/proto/sui/rpc/v2/object.d.mts +38 -1
  19. package/dist/grpc/proto/sui/rpc/v2/object.d.mts.map +1 -1
  20. package/dist/grpc/proto/sui/rpc/v2/object.mjs +26 -1
  21. package/dist/grpc/proto/sui/rpc/v2/object.mjs.map +1 -1
  22. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  23. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  24. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  25. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  26. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts +8 -0
  27. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.d.mts.map +1 -1
  28. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs +23 -12
  29. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.mjs.map +1 -1
  30. package/dist/grpc/proto/types.d.mts +2 -2
  31. package/dist/grpc/proto/types.mjs +2 -1
  32. package/dist/jsonRpc/core.d.mts.map +1 -1
  33. package/dist/jsonRpc/core.mjs +10 -3
  34. package/dist/jsonRpc/core.mjs.map +1 -1
  35. package/dist/keypairs/passkey/keypair.d.mts +11 -4
  36. package/dist/keypairs/passkey/keypair.d.mts.map +1 -1
  37. package/dist/keypairs/passkey/keypair.mjs +19 -6
  38. package/dist/keypairs/passkey/keypair.mjs.map +1 -1
  39. package/dist/transactions/Transaction.d.mts +9 -9
  40. package/dist/transactions/Transaction.d.mts.map +1 -1
  41. package/dist/version.mjs +2 -2
  42. package/dist/version.mjs.map +1 -1
  43. package/dist/zklogin/bcs.d.mts +14 -14
  44. package/docs/bcs.md +131 -0
  45. package/docs/clients/core.md +601 -0
  46. package/docs/clients/graphql.md +99 -0
  47. package/docs/clients/grpc.md +152 -0
  48. package/docs/clients/index.md +93 -0
  49. package/docs/clients/json-rpc.md +235 -0
  50. package/docs/cryptography/keypairs.md +258 -0
  51. package/docs/cryptography/multisig.md +192 -0
  52. package/docs/cryptography/passkey.md +111 -0
  53. package/docs/cryptography/webcrypto-signer.md +81 -0
  54. package/docs/executors.md +147 -0
  55. package/docs/faucet.md +26 -0
  56. package/docs/hello-sui.md +114 -0
  57. package/docs/index.md +54 -0
  58. package/docs/install.md +61 -0
  59. package/docs/llm-docs.md +32 -0
  60. package/docs/llms-index.md +60 -0
  61. package/docs/migrations/0.38.md +57 -0
  62. package/docs/migrations/sui-1.0.md +453 -0
  63. package/docs/migrations/sui-2.0/agent-prompt.md +42 -0
  64. package/docs/migrations/sui-2.0/dapp-kit.md +350 -0
  65. package/docs/migrations/sui-2.0/deepbook-v3.md +33 -0
  66. package/docs/migrations/sui-2.0/index.md +157 -0
  67. package/docs/migrations/sui-2.0/json-rpc-migration.md +383 -0
  68. package/docs/migrations/sui-2.0/kiosk.md +120 -0
  69. package/docs/migrations/sui-2.0/sdk-maintainers.md +90 -0
  70. package/docs/migrations/sui-2.0/seal.md +14 -0
  71. package/docs/migrations/sui-2.0/sui.md +341 -0
  72. package/docs/migrations/sui-2.0/suins.md +42 -0
  73. package/docs/migrations/sui-2.0/wallet-builders.md +66 -0
  74. package/docs/migrations/sui-2.0/walrus.md +41 -0
  75. package/docs/migrations/sui-2.0/zksend.md +94 -0
  76. package/docs/plugins.md +255 -0
  77. package/docs/sdk-building.md +340 -0
  78. package/docs/transaction-building/basics.md +297 -0
  79. package/docs/transaction-building/gas.md +62 -0
  80. package/docs/transaction-building/intents.md +61 -0
  81. package/docs/transaction-building/offline.md +71 -0
  82. package/docs/transaction-building/sponsored-transactions.md +22 -0
  83. package/docs/utils/derived_objects.md +59 -0
  84. package/docs/utils/index.md +52 -0
  85. package/docs/zklogin.md +78 -0
  86. package/package.json +5 -3
  87. package/src/client/types.ts +16 -0
  88. package/src/graphql/core.ts +34 -13
  89. package/src/graphql/generated/queries.ts +252 -14
  90. package/src/graphql/generated/schema.graphql +324 -8
  91. package/src/graphql/generated/tada-env.ts +844 -99
  92. package/src/graphql/queries/objects.graphql +10 -0
  93. package/src/graphql/queries/verifyZkLoginSignature.graphql +0 -1
  94. package/src/grpc/core.ts +34 -0
  95. package/src/grpc/proto/sui/rpc/v2/object.ts +44 -0
  96. package/src/grpc/proto/sui/rpc/v2/transaction_execution_service.ts +16 -0
  97. package/src/jsonRpc/core.ts +9 -0
  98. package/src/keypairs/passkey/keypair.ts +20 -6
  99. package/src/version.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"keypair.d.mts","names":[],"sources":["../../../src/keypairs/passkey/keypair.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAsBK,qBAAA;KAEA,iBAAiB,iCAEP,KAAK,YAAY,EAAE,KANiD,GAQhF,CANE;AAEA,KAMO,8BAAA,GAAiC,IAN7B,CAOf,WAPe,CAOH,kCAPG,CAAA,EAQf,qBARe,CAAA,GAUf,IAV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;EAoEU,OAAA,kBAAA,CAAA,QAAA,EApE5B,eAoE4B,CAAA,EApEV,OAoEU,CApEF,cAoEE,CAAA;EAAR;;;EAqDnD,YAAA,CAAA,CAAA,EAvGK,SAuGL;EAAR;;;AA6BJ;EAA0C,IAAA,CAAA,IAAA,EA5HxB,UA4HwB,CAAA,EA5Hd,OA4Hc,CA5Hd,UA4Hc,CA5Hd,WA4Hc,CAAA,CAAA;EAAmB;;;;wBAlFhC,oBAAoB,cAAc,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAmD3D,0BACD,aACP,QAAQ;;;;;;;;;;iBA6BI,mBAAA,OAA0B,mBAAmB,cAAc"}
@@ -45,11 +45,15 @@ var BrowserPasskeyProvider = class {
45
45
  }
46
46
  } });
47
47
  }
48
- async get(challenge) {
48
+ async get(challenge, credentialId) {
49
49
  return await navigator.credentials.get({ publicKey: {
50
50
  challenge,
51
51
  userVerification: this.#options.authenticatorSelection?.userVerification || "required",
52
- timeout: this.#options.timeout ?? 6e4
52
+ timeout: this.#options.timeout ?? 6e4,
53
+ ...credentialId && { allowCredentials: [{
54
+ type: "public-key",
55
+ id: credentialId
56
+ }] }
53
57
  } });
54
58
  }
55
59
  };
@@ -78,10 +82,19 @@ var PasskeyKeypair = class PasskeyKeypair extends Signer {
78
82
  * If there are existing passkey wallet, use `signAndRecover` to identify the correct
79
83
  * public key and then initialize the instance. See usage in `signAndRecover`.
80
84
  */
81
- constructor(publicKey, provider) {
85
+ constructor(publicKey, provider, credentialId) {
82
86
  super();
83
87
  this.publicKey = publicKey;
84
88
  this.provider = provider;
89
+ this.credentialId = credentialId;
90
+ }
91
+ /**
92
+ * Return the credential ID for this passkey, if available.
93
+ * The credential ID is captured when creating a new passkey via `getPasskeyInstance`
94
+ * and can be used to constrain which credential the browser selects during signing.
95
+ */
96
+ getCredentialId() {
97
+ return this.credentialId;
85
98
  }
86
99
  /**
87
100
  * Creates an instance of Passkey signer invoking the passkey from navigator.
@@ -97,7 +110,7 @@ var PasskeyKeypair = class PasskeyKeypair extends Signer {
97
110
  else {
98
111
  const derSPKI = credential.response.getPublicKey();
99
112
  const pubkeyUncompressed = parseDerSPKI(new Uint8Array(derSPKI));
100
- return new PasskeyKeypair(p256.Point.fromBytes(pubkeyUncompressed).toBytes(true), provider);
113
+ return new PasskeyKeypair(p256.Point.fromBytes(pubkeyUncompressed).toBytes(true), provider, new Uint8Array(credential.rawId));
101
114
  }
102
115
  }
103
116
  /**
@@ -111,7 +124,7 @@ var PasskeyKeypair = class PasskeyKeypair extends Signer {
111
124
  * This is sent to passkey as the challenge field.
112
125
  */
113
126
  async sign(data) {
114
- const credential = await this.provider.get(data);
127
+ const credential = await this.provider.get(data, this.credentialId);
115
128
  const authenticatorData = new Uint8Array(credential.response.authenticatorData);
116
129
  const clientDataJSON = new Uint8Array(credential.response.clientDataJSON);
117
130
  const clientDataJSONString = new TextDecoder().decode(clientDataJSON);
@@ -168,7 +181,7 @@ var PasskeyKeypair = class PasskeyKeypair extends Signer {
168
181
  * const testMessage2 = new TextEncoder().encode('Hello world 2!');
169
182
  * const possiblePks2 = await PasskeyKeypair.signAndRecover(provider, testMessage2);
170
183
  * const commonPk = findCommonPublicKey(possiblePks, possiblePks2);
171
- * const signer = new PasskeyKeypair(provider, commonPk.toRawBytes());
184
+ * const signer = new PasskeyKeypair(commonPk.toRawBytes(), provider);
172
185
  * ```
173
186
  *
174
187
  * @param provider - the passkey provider.
@@ -1 +1 @@
1
- {"version":3,"file":"keypair.mjs","names":["#name","#options","secp256r1"],"sources":["../../../src/keypairs/passkey/keypair.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { toBase64 } from '@mysten/bcs';\nimport { p256 as secp256r1 } from '@noble/curves/nist.js';\nimport { blake2b } from '@noble/hashes/blake2.js';\nimport { sha256 } from '@noble/hashes/sha2.js';\nimport { randomBytes } from '@noble/hashes/utils.js';\n\nimport { PasskeyAuthenticator } from '../../bcs/bcs.js';\nimport type { IntentScope, SignatureWithBytes } from '../../cryptography/index.js';\nimport { messageWithIntent, SIGNATURE_SCHEME_TO_FLAG, Signer } from '../../cryptography/index.js';\nimport type { PublicKey } from '../../cryptography/publickey.js';\nimport type { SignatureScheme } from '../../cryptography/signature-scheme.js';\nimport {\n\tparseDerSPKI,\n\tPASSKEY_PUBLIC_KEY_SIZE,\n\tPASSKEY_SIGNATURE_SIZE,\n\tPasskeyPublicKey,\n} from './publickey.js';\nimport type { AuthenticationCredential, RegistrationCredential } from './types.js';\n\ntype DeepPartialConfigKeys = 'rp' | 'user' | 'authenticatorSelection';\n\ntype DeepPartial<T> = T extends object\n\t? {\n\t\t\t[P in keyof T]?: DeepPartial<T[P]>;\n\t\t}\n\t: T;\n\nexport type BrowserPasswordProviderOptions = Pick<\n\tDeepPartial<PublicKeyCredentialCreationOptions>,\n\tDeepPartialConfigKeys\n> &\n\tOmit<\n\t\tPartial<PublicKeyCredentialCreationOptions>,\n\t\tDeepPartialConfigKeys | 'pubKeyCredParams' | 'challenge'\n\t>;\n\nexport interface PasskeyProvider {\n\tcreate(): Promise<RegistrationCredential>;\n\tget(challenge: Uint8Array): Promise<AuthenticationCredential>;\n}\n\n// Default browser implementation\nexport class BrowserPasskeyProvider implements PasskeyProvider {\n\t#name: string;\n\t#options: BrowserPasswordProviderOptions;\n\n\tconstructor(name: string, options: BrowserPasswordProviderOptions) {\n\t\tthis.#name = name;\n\t\tthis.#options = options;\n\t}\n\n\tasync create(): Promise<RegistrationCredential> {\n\t\treturn (await navigator.credentials.create({\n\t\t\tpublicKey: {\n\t\t\t\ttimeout: this.#options.timeout ?? 60000,\n\t\t\t\t...this.#options,\n\t\t\t\trp: {\n\t\t\t\t\tname: this.#name,\n\t\t\t\t\t...this.#options.rp,\n\t\t\t\t},\n\t\t\t\tuser: {\n\t\t\t\t\tname: this.#name,\n\t\t\t\t\tdisplayName: this.#name,\n\t\t\t\t\t...this.#options.user,\n\t\t\t\t\tid: randomBytes(10) as BufferSource,\n\t\t\t\t},\n\t\t\t\tchallenge: new TextEncoder().encode('Create passkey wallet on Sui'),\n\t\t\t\tpubKeyCredParams: [{ alg: -7, type: 'public-key' }],\n\t\t\t\tauthenticatorSelection: {\n\t\t\t\t\tauthenticatorAttachment: 'cross-platform',\n\t\t\t\t\tresidentKey: 'required',\n\t\t\t\t\trequireResidentKey: true,\n\t\t\t\t\tuserVerification: 'required',\n\t\t\t\t\t...this.#options.authenticatorSelection,\n\t\t\t\t},\n\t\t\t},\n\t\t})) as RegistrationCredential;\n\t}\n\n\tasync get(challenge: Uint8Array): Promise<AuthenticationCredential> {\n\t\treturn (await navigator.credentials.get({\n\t\t\tpublicKey: {\n\t\t\t\tchallenge: challenge as BufferSource,\n\t\t\t\tuserVerification: this.#options.authenticatorSelection?.userVerification || 'required',\n\t\t\t\ttimeout: this.#options.timeout ?? 60000,\n\t\t\t},\n\t\t})) as AuthenticationCredential;\n\t}\n}\n\n/**\n * @experimental\n * A passkey signer used for signing transactions. This is a client side implementation for [SIP-9](https://github.com/sui-foundation/sips/blob/main/sips/sip-9.md).\n */\nexport class PasskeyKeypair extends Signer {\n\tprivate publicKey: Uint8Array;\n\tprivate provider: PasskeyProvider;\n\n\t/**\n\t * Get the key scheme of passkey,\n\t */\n\tgetKeyScheme(): SignatureScheme {\n\t\treturn 'Passkey';\n\t}\n\n\t/**\n\t * Creates an instance of Passkey signer. If no passkey wallet had created before,\n\t * use `getPasskeyInstance`. For example:\n\t * ```\n\t * let provider = new BrowserPasskeyProvider('Sui Passkey Example',{\n\t * \t rpName: 'Sui Passkey Example',\n\t * \t rpId: window.location.hostname,\n\t * } as BrowserPasswordProviderOptions);\n\t * const signer = await PasskeyKeypair.getPasskeyInstance(provider);\n\t * ```\n\t *\n\t * If there are existing passkey wallet, use `signAndRecover` to identify the correct\n\t * public key and then initialize the instance. See usage in `signAndRecover`.\n\t */\n\tconstructor(publicKey: Uint8Array, provider: PasskeyProvider) {\n\t\tsuper();\n\t\tthis.publicKey = publicKey;\n\t\tthis.provider = provider;\n\t}\n\n\t/**\n\t * Creates an instance of Passkey signer invoking the passkey from navigator.\n\t * Note that this will invoke the passkey device to create a fresh credential.\n\t * Should only be called if passkey wallet is created for the first time.\n\t *\n\t * @param provider - the passkey provider.\n\t * @returns the passkey instance.\n\t */\n\tstatic async getPasskeyInstance(provider: PasskeyProvider): Promise<PasskeyKeypair> {\n\t\t// create a passkey secp256r1 with the provider.\n\t\tconst credential = await provider.create();\n\n\t\tif (!credential.response.getPublicKey()) {\n\t\t\tthrow new Error('Invalid credential create response');\n\t\t} else {\n\t\t\tconst derSPKI = credential.response.getPublicKey()!;\n\t\t\tconst pubkeyUncompressed = parseDerSPKI(new Uint8Array(derSPKI));\n\t\t\tconst pubkey = secp256r1.Point.fromBytes(pubkeyUncompressed);\n\t\t\tconst pubkeyCompressed = pubkey.toBytes(true);\n\t\t\treturn new PasskeyKeypair(pubkeyCompressed, provider);\n\t\t}\n\t}\n\n\t/**\n\t * Return the public key for this passkey.\n\t */\n\tgetPublicKey(): PublicKey {\n\t\treturn new PasskeyPublicKey(this.publicKey);\n\t}\n\n\t/**\n\t * Return the signature for the provided data (i.e. blake2b(intent_message)).\n\t * This is sent to passkey as the challenge field.\n\t */\n\tasync sign(data: Uint8Array) {\n\t\t// asks the passkey to sign over challenge as the data.\n\t\tconst credential = await this.provider.get(data);\n\n\t\t// parse authenticatorData (as bytes), clientDataJSON (decoded as string).\n\t\tconst authenticatorData = new Uint8Array(credential.response.authenticatorData);\n\t\tconst clientDataJSON = new Uint8Array(credential.response.clientDataJSON); // response.clientDataJSON is already UTF-8 encoded JSON\n\t\tconst decoder = new TextDecoder();\n\t\tconst clientDataJSONString: string = decoder.decode(clientDataJSON);\n\n\t\tconst sig = secp256r1.Signature.fromBytes(new Uint8Array(credential.response.signature), 'der');\n\t\tconst normalizedSig = sig.hasHighS()\n\t\t\t? new secp256r1.Signature(sig.r, secp256r1.Point.Fn.neg(sig.s))\n\t\t\t: sig;\n\n\t\tconst normalized = normalizedSig.toBytes('compact');\n\n\t\tif (\n\t\t\tnormalized.length !== PASSKEY_SIGNATURE_SIZE ||\n\t\t\tthis.publicKey.length !== PASSKEY_PUBLIC_KEY_SIZE\n\t\t) {\n\t\t\tthrow new Error('Invalid signature or public key length');\n\t\t}\n\n\t\t// construct userSignature as flag || sig || pubkey for the secp256r1 signature.\n\t\tconst arr = new Uint8Array(1 + normalized.length + this.publicKey.length);\n\t\tarr.set([SIGNATURE_SCHEME_TO_FLAG['Secp256r1']]);\n\t\tarr.set(normalized, 1);\n\t\tarr.set(this.publicKey, 1 + normalized.length);\n\n\t\t// serialize all fields into a passkey signature according to https://github.com/sui-foundation/sips/blob/main/sips/sip-9.md#signature-encoding\n\t\treturn PasskeyAuthenticator.serialize({\n\t\t\tauthenticatorData: authenticatorData,\n\t\t\tclientDataJson: clientDataJSONString,\n\t\t\tuserSignature: arr,\n\t\t}).toBytes();\n\t}\n\n\t/**\n\t * This overrides the base class implementation that accepts the raw bytes and signs its\n\t * digest of the intent message, then serialize it with the passkey flag.\n\t */\n\tasync signWithIntent(bytes: Uint8Array, intent: IntentScope): Promise<SignatureWithBytes> {\n\t\t// prepend it into an intent message and computes the digest.\n\t\tconst intentMessage = messageWithIntent(intent, bytes);\n\t\tconst digest = blake2b(intentMessage, { dkLen: 32 });\n\n\t\t// sign the digest.\n\t\tconst signature = await this.sign(digest);\n\n\t\t// prepend with the passkey flag.\n\t\tconst serializedSignature = new Uint8Array(1 + signature.length);\n\t\tserializedSignature.set([SIGNATURE_SCHEME_TO_FLAG[this.getKeyScheme()]]);\n\t\tserializedSignature.set(signature, 1);\n\t\treturn {\n\t\t\tsignature: toBase64(serializedSignature),\n\t\t\tbytes: toBase64(bytes),\n\t\t};\n\t}\n\n\t/**\n\t * Given a message, asks the passkey device to sign it and return all (up to 4) possible public keys.\n\t * See: https://bitcoin.stackexchange.com/questions/81232/how-is-public-key-extracted-from-message-digital-signature-address\n\t *\n\t * This is useful if the user previously created passkey wallet with the origin, but the wallet session\n\t * does not have the public key / address. By calling this method twice with two different messages, the\n\t * wallet can compare the returned public keys and uniquely identify the previously created passkey wallet\n\t * using `findCommonPublicKey`.\n\t *\n\t * Alternatively, one call can be made and all possible public keys should be checked onchain to see if\n\t * there is any assets.\n\t *\n\t * Once the correct public key is identified, a passkey instance can then be initialized with this public key.\n\t *\n\t * Example usage to recover wallet with two signing calls:\n\t * ```\n\t * let provider = new BrowserPasskeyProvider('Sui Passkey Example',{\n\t * rpName: 'Sui Passkey Example',\n\t * \t rpId: window.location.hostname,\n\t * } as BrowserPasswordProviderOptions);\n\t * const testMessage = new TextEncoder().encode('Hello world!');\n\t * const possiblePks = await PasskeyKeypair.signAndRecover(provider, testMessage);\n\t * const testMessage2 = new TextEncoder().encode('Hello world 2!');\n\t * const possiblePks2 = await PasskeyKeypair.signAndRecover(provider, testMessage2);\n\t * const commonPk = findCommonPublicKey(possiblePks, possiblePks2);\n\t * const signer = new PasskeyKeypair(provider, commonPk.toRawBytes());\n\t * ```\n\t *\n\t * @param provider - the passkey provider.\n\t * @param message - the message to sign.\n\t * @returns all possible public keys.\n\t */\n\tstatic async signAndRecover(\n\t\tprovider: PasskeyProvider,\n\t\tmessage: Uint8Array,\n\t): Promise<PublicKey[]> {\n\t\tconst credential = await provider.get(message);\n\t\tconst fullMessage = messageFromAssertionResponse(credential.response);\n\t\tconst sig = secp256r1.Signature.fromBytes(new Uint8Array(credential.response.signature), 'der');\n\n\t\tconst res = [];\n\t\tconst msgHash = sha256(fullMessage);\n\t\tfor (let i = 0; i < 4; i++) {\n\t\t\tconst s = sig.addRecoveryBit(i);\n\t\t\ttry {\n\t\t\t\tconst pubkey = s.recoverPublicKey(msgHash);\n\t\t\t\tconst pk = new PasskeyPublicKey(pubkey.toBytes(true));\n\t\t\t\tres.push(pk);\n\t\t\t} catch {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n}\n\n/**\n * Finds the unique public key that exists in both arrays, throws error if the common\n * pubkey does not equal to one.\n *\n * @param arr1 - The first pubkeys array.\n * @param arr2 - The second pubkeys array.\n * @returns The only common pubkey in both arrays.\n */\nexport function findCommonPublicKey(arr1: PublicKey[], arr2: PublicKey[]): PublicKey {\n\tconst matchingPubkeys: PublicKey[] = [];\n\tfor (const pubkey1 of arr1) {\n\t\tfor (const pubkey2 of arr2) {\n\t\t\tif (pubkey1.equals(pubkey2)) {\n\t\t\t\tmatchingPubkeys.push(pubkey1);\n\t\t\t}\n\t\t}\n\t}\n\tif (matchingPubkeys.length !== 1) {\n\t\tthrow new Error('No unique public key found');\n\t}\n\treturn matchingPubkeys[0];\n}\n\n/**\n * Constructs the message that the passkey signature is produced over as authenticatorData || sha256(clientDataJSON).\n */\nfunction messageFromAssertionResponse(response: AuthenticatorAssertionResponse): Uint8Array {\n\tconst authenticatorData = new Uint8Array(response.authenticatorData);\n\tconst clientDataJSON = new Uint8Array(response.clientDataJSON);\n\tconst clientDataJSONDigest = sha256(clientDataJSON);\n\treturn new Uint8Array([...authenticatorData, ...clientDataJSONDigest]);\n}\n"],"mappings":";;;;;;;;;;;;AA6CA,IAAa,yBAAb,MAA+D;CAC9D;CACA;CAEA,YAAY,MAAc,SAAyC;AAClE,QAAKA,OAAQ;AACb,QAAKC,UAAW;;CAGjB,MAAM,SAA0C;AAC/C,SAAQ,MAAM,UAAU,YAAY,OAAO,EAC1C,WAAW;GACV,SAAS,MAAKA,QAAS,WAAW;GAClC,GAAG,MAAKA;GACR,IAAI;IACH,MAAM,MAAKD;IACX,GAAG,MAAKC,QAAS;IACjB;GACD,MAAM;IACL,MAAM,MAAKD;IACX,aAAa,MAAKA;IAClB,GAAG,MAAKC,QAAS;IACjB,IAAI,YAAY,GAAG;IACnB;GACD,WAAW,IAAI,aAAa,CAAC,OAAO,+BAA+B;GACnE,kBAAkB,CAAC;IAAE,KAAK;IAAI,MAAM;IAAc,CAAC;GACnD,wBAAwB;IACvB,yBAAyB;IACzB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AAI,KAAK,GAAG;WACL;AACP;;;AAGF,SAAO;;;;;;;;;;;AAYT,SAAgB,oBAAoB,MAAmB,MAA8B;CACpF,MAAM,kBAA+B,EAAE;AACvC,MAAK,MAAM,WAAW,KACrB,MAAK,MAAM,WAAW,KACrB,KAAI,QAAQ,OAAO,QAAQ,CAC1B,iBAAgB,KAAK,QAAQ;AAIhC,KAAI,gBAAgB,WAAW,EAC9B,OAAM,IAAI,MAAM,6BAA6B;AAE9C,QAAO,gBAAgB;;;;;AAMxB,SAAS,6BAA6B,UAAsD;CAC3F,MAAM,oBAAoB,IAAI,WAAW,SAAS,kBAAkB;CAEpE,MAAM,uBAAuB,OADN,IAAI,WAAW,SAAS,eAAe,CACX;AACnD,QAAO,IAAI,WAAW,CAAC,GAAG,mBAAmB,GAAG,qBAAqB,CAAC"}
1
+ {"version":3,"file":"keypair.mjs","names":["#name","#options","secp256r1"],"sources":["../../../src/keypairs/passkey/keypair.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { toBase64 } from '@mysten/bcs';\nimport { p256 as secp256r1 } from '@noble/curves/nist.js';\nimport { blake2b } from '@noble/hashes/blake2.js';\nimport { sha256 } from '@noble/hashes/sha2.js';\nimport { randomBytes } from '@noble/hashes/utils.js';\n\nimport { PasskeyAuthenticator } from '../../bcs/bcs.js';\nimport type { IntentScope, SignatureWithBytes } from '../../cryptography/index.js';\nimport { messageWithIntent, SIGNATURE_SCHEME_TO_FLAG, Signer } from '../../cryptography/index.js';\nimport type { PublicKey } from '../../cryptography/publickey.js';\nimport type { SignatureScheme } from '../../cryptography/signature-scheme.js';\nimport {\n\tparseDerSPKI,\n\tPASSKEY_PUBLIC_KEY_SIZE,\n\tPASSKEY_SIGNATURE_SIZE,\n\tPasskeyPublicKey,\n} from './publickey.js';\nimport type { AuthenticationCredential, RegistrationCredential } from './types.js';\n\ntype DeepPartialConfigKeys = 'rp' | 'user' | 'authenticatorSelection';\n\ntype DeepPartial<T> = T extends object\n\t? {\n\t\t\t[P in keyof T]?: DeepPartial<T[P]>;\n\t\t}\n\t: T;\n\nexport type BrowserPasswordProviderOptions = Pick<\n\tDeepPartial<PublicKeyCredentialCreationOptions>,\n\tDeepPartialConfigKeys\n> &\n\tOmit<\n\t\tPartial<PublicKeyCredentialCreationOptions>,\n\t\tDeepPartialConfigKeys | 'pubKeyCredParams' | 'challenge'\n\t>;\n\nexport interface PasskeyProvider {\n\tcreate(): Promise<RegistrationCredential>;\n\tget(challenge: Uint8Array, credentialId?: Uint8Array): Promise<AuthenticationCredential>;\n}\n\n// Default browser implementation\nexport class BrowserPasskeyProvider implements PasskeyProvider {\n\t#name: string;\n\t#options: BrowserPasswordProviderOptions;\n\n\tconstructor(name: string, options: BrowserPasswordProviderOptions) {\n\t\tthis.#name = name;\n\t\tthis.#options = options;\n\t}\n\n\tasync create(): Promise<RegistrationCredential> {\n\t\treturn (await navigator.credentials.create({\n\t\t\tpublicKey: {\n\t\t\t\ttimeout: this.#options.timeout ?? 60000,\n\t\t\t\t...this.#options,\n\t\t\t\trp: {\n\t\t\t\t\tname: this.#name,\n\t\t\t\t\t...this.#options.rp,\n\t\t\t\t},\n\t\t\t\tuser: {\n\t\t\t\t\tname: this.#name,\n\t\t\t\t\tdisplayName: this.#name,\n\t\t\t\t\t...this.#options.user,\n\t\t\t\t\tid: randomBytes(10) as BufferSource,\n\t\t\t\t},\n\t\t\t\tchallenge: new TextEncoder().encode('Create passkey wallet on Sui'),\n\t\t\t\tpubKeyCredParams: [{ alg: -7, type: 'public-key' }],\n\t\t\t\tauthenticatorSelection: {\n\t\t\t\t\tauthenticatorAttachment: 'cross-platform',\n\t\t\t\t\tresidentKey: 'required',\n\t\t\t\t\trequireResidentKey: true,\n\t\t\t\t\tuserVerification: 'required',\n\t\t\t\t\t...this.#options.authenticatorSelection,\n\t\t\t\t},\n\t\t\t},\n\t\t})) as RegistrationCredential;\n\t}\n\n\tasync get(challenge: Uint8Array, credentialId?: Uint8Array): Promise<AuthenticationCredential> {\n\t\treturn (await navigator.credentials.get({\n\t\t\tpublicKey: {\n\t\t\t\tchallenge: challenge as BufferSource,\n\t\t\t\tuserVerification: this.#options.authenticatorSelection?.userVerification || 'required',\n\t\t\t\ttimeout: this.#options.timeout ?? 60000,\n\t\t\t\t...(credentialId && {\n\t\t\t\t\tallowCredentials: [{ type: 'public-key' as const, id: credentialId as BufferSource }],\n\t\t\t\t}),\n\t\t\t},\n\t\t})) as AuthenticationCredential;\n\t}\n}\n\n/**\n * @experimental\n * A passkey signer used for signing transactions. This is a client side implementation for [SIP-9](https://github.com/sui-foundation/sips/blob/main/sips/sip-9.md).\n */\nexport class PasskeyKeypair extends Signer {\n\tprivate publicKey: Uint8Array;\n\tprivate provider: PasskeyProvider;\n\tprivate credentialId?: Uint8Array;\n\n\t/**\n\t * Get the key scheme of passkey,\n\t */\n\tgetKeyScheme(): SignatureScheme {\n\t\treturn 'Passkey';\n\t}\n\n\t/**\n\t * Creates an instance of Passkey signer. If no passkey wallet had created before,\n\t * use `getPasskeyInstance`. For example:\n\t * ```\n\t * let provider = new BrowserPasskeyProvider('Sui Passkey Example',{\n\t * \t rpName: 'Sui Passkey Example',\n\t * \t rpId: window.location.hostname,\n\t * } as BrowserPasswordProviderOptions);\n\t * const signer = await PasskeyKeypair.getPasskeyInstance(provider);\n\t * ```\n\t *\n\t * If there are existing passkey wallet, use `signAndRecover` to identify the correct\n\t * public key and then initialize the instance. See usage in `signAndRecover`.\n\t */\n\tconstructor(publicKey: Uint8Array, provider: PasskeyProvider, credentialId?: Uint8Array) {\n\t\tsuper();\n\t\tthis.publicKey = publicKey;\n\t\tthis.provider = provider;\n\t\tthis.credentialId = credentialId;\n\t}\n\n\t/**\n\t * Return the credential ID for this passkey, if available.\n\t * The credential ID is captured when creating a new passkey via `getPasskeyInstance`\n\t * and can be used to constrain which credential the browser selects during signing.\n\t */\n\tgetCredentialId(): Uint8Array | undefined {\n\t\treturn this.credentialId;\n\t}\n\n\t/**\n\t * Creates an instance of Passkey signer invoking the passkey from navigator.\n\t * Note that this will invoke the passkey device to create a fresh credential.\n\t * Should only be called if passkey wallet is created for the first time.\n\t *\n\t * @param provider - the passkey provider.\n\t * @returns the passkey instance.\n\t */\n\tstatic async getPasskeyInstance(provider: PasskeyProvider): Promise<PasskeyKeypair> {\n\t\t// create a passkey secp256r1 with the provider.\n\t\tconst credential = await provider.create();\n\n\t\tif (!credential.response.getPublicKey()) {\n\t\t\tthrow new Error('Invalid credential create response');\n\t\t} else {\n\t\t\tconst derSPKI = credential.response.getPublicKey()!;\n\t\t\tconst pubkeyUncompressed = parseDerSPKI(new Uint8Array(derSPKI));\n\t\t\tconst pubkey = secp256r1.Point.fromBytes(pubkeyUncompressed);\n\t\t\tconst pubkeyCompressed = pubkey.toBytes(true);\n\t\t\treturn new PasskeyKeypair(pubkeyCompressed, provider, new Uint8Array(credential.rawId));\n\t\t}\n\t}\n\n\t/**\n\t * Return the public key for this passkey.\n\t */\n\tgetPublicKey(): PublicKey {\n\t\treturn new PasskeyPublicKey(this.publicKey);\n\t}\n\n\t/**\n\t * Return the signature for the provided data (i.e. blake2b(intent_message)).\n\t * This is sent to passkey as the challenge field.\n\t */\n\tasync sign(data: Uint8Array) {\n\t\t// asks the passkey to sign over challenge as the data.\n\t\tconst credential = await this.provider.get(data, this.credentialId);\n\n\t\t// parse authenticatorData (as bytes), clientDataJSON (decoded as string).\n\t\tconst authenticatorData = new Uint8Array(credential.response.authenticatorData);\n\t\tconst clientDataJSON = new Uint8Array(credential.response.clientDataJSON); // response.clientDataJSON is already UTF-8 encoded JSON\n\t\tconst decoder = new TextDecoder();\n\t\tconst clientDataJSONString: string = decoder.decode(clientDataJSON);\n\n\t\tconst sig = secp256r1.Signature.fromBytes(new Uint8Array(credential.response.signature), 'der');\n\t\tconst normalizedSig = sig.hasHighS()\n\t\t\t? new secp256r1.Signature(sig.r, secp256r1.Point.Fn.neg(sig.s))\n\t\t\t: sig;\n\n\t\tconst normalized = normalizedSig.toBytes('compact');\n\n\t\tif (\n\t\t\tnormalized.length !== PASSKEY_SIGNATURE_SIZE ||\n\t\t\tthis.publicKey.length !== PASSKEY_PUBLIC_KEY_SIZE\n\t\t) {\n\t\t\tthrow new Error('Invalid signature or public key length');\n\t\t}\n\n\t\t// construct userSignature as flag || sig || pubkey for the secp256r1 signature.\n\t\tconst arr = new Uint8Array(1 + normalized.length + this.publicKey.length);\n\t\tarr.set([SIGNATURE_SCHEME_TO_FLAG['Secp256r1']]);\n\t\tarr.set(normalized, 1);\n\t\tarr.set(this.publicKey, 1 + normalized.length);\n\n\t\t// serialize all fields into a passkey signature according to https://github.com/sui-foundation/sips/blob/main/sips/sip-9.md#signature-encoding\n\t\treturn PasskeyAuthenticator.serialize({\n\t\t\tauthenticatorData: authenticatorData,\n\t\t\tclientDataJson: clientDataJSONString,\n\t\t\tuserSignature: arr,\n\t\t}).toBytes();\n\t}\n\n\t/**\n\t * This overrides the base class implementation that accepts the raw bytes and signs its\n\t * digest of the intent message, then serialize it with the passkey flag.\n\t */\n\tasync signWithIntent(bytes: Uint8Array, intent: IntentScope): Promise<SignatureWithBytes> {\n\t\t// prepend it into an intent message and computes the digest.\n\t\tconst intentMessage = messageWithIntent(intent, bytes);\n\t\tconst digest = blake2b(intentMessage, { dkLen: 32 });\n\n\t\t// sign the digest.\n\t\tconst signature = await this.sign(digest);\n\n\t\t// prepend with the passkey flag.\n\t\tconst serializedSignature = new Uint8Array(1 + signature.length);\n\t\tserializedSignature.set([SIGNATURE_SCHEME_TO_FLAG[this.getKeyScheme()]]);\n\t\tserializedSignature.set(signature, 1);\n\t\treturn {\n\t\t\tsignature: toBase64(serializedSignature),\n\t\t\tbytes: toBase64(bytes),\n\t\t};\n\t}\n\n\t/**\n\t * Given a message, asks the passkey device to sign it and return all (up to 4) possible public keys.\n\t * See: https://bitcoin.stackexchange.com/questions/81232/how-is-public-key-extracted-from-message-digital-signature-address\n\t *\n\t * This is useful if the user previously created passkey wallet with the origin, but the wallet session\n\t * does not have the public key / address. By calling this method twice with two different messages, the\n\t * wallet can compare the returned public keys and uniquely identify the previously created passkey wallet\n\t * using `findCommonPublicKey`.\n\t *\n\t * Alternatively, one call can be made and all possible public keys should be checked onchain to see if\n\t * there is any assets.\n\t *\n\t * Once the correct public key is identified, a passkey instance can then be initialized with this public key.\n\t *\n\t * Example usage to recover wallet with two signing calls:\n\t * ```\n\t * let provider = new BrowserPasskeyProvider('Sui Passkey Example',{\n\t * rpName: 'Sui Passkey Example',\n\t * \t rpId: window.location.hostname,\n\t * } as BrowserPasswordProviderOptions);\n\t * const testMessage = new TextEncoder().encode('Hello world!');\n\t * const possiblePks = await PasskeyKeypair.signAndRecover(provider, testMessage);\n\t * const testMessage2 = new TextEncoder().encode('Hello world 2!');\n\t * const possiblePks2 = await PasskeyKeypair.signAndRecover(provider, testMessage2);\n\t * const commonPk = findCommonPublicKey(possiblePks, possiblePks2);\n\t * const signer = new PasskeyKeypair(commonPk.toRawBytes(), provider);\n\t * ```\n\t *\n\t * @param provider - the passkey provider.\n\t * @param message - the message to sign.\n\t * @returns all possible public keys.\n\t */\n\tstatic async signAndRecover(\n\t\tprovider: PasskeyProvider,\n\t\tmessage: Uint8Array,\n\t): Promise<PublicKey[]> {\n\t\tconst credential = await provider.get(message);\n\t\tconst fullMessage = messageFromAssertionResponse(credential.response);\n\t\tconst sig = secp256r1.Signature.fromBytes(new Uint8Array(credential.response.signature), 'der');\n\n\t\tconst res = [];\n\t\tconst msgHash = sha256(fullMessage);\n\t\tfor (let i = 0; i < 4; i++) {\n\t\t\tconst s = sig.addRecoveryBit(i);\n\t\t\ttry {\n\t\t\t\tconst pubkey = s.recoverPublicKey(msgHash);\n\t\t\t\tconst pk = new PasskeyPublicKey(pubkey.toBytes(true));\n\t\t\t\tres.push(pk);\n\t\t\t} catch {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n}\n\n/**\n * Finds the unique public key that exists in both arrays, throws error if the common\n * pubkey does not equal to one.\n *\n * @param arr1 - The first pubkeys array.\n * @param arr2 - The second pubkeys array.\n * @returns The only common pubkey in both arrays.\n */\nexport function findCommonPublicKey(arr1: PublicKey[], arr2: PublicKey[]): PublicKey {\n\tconst matchingPubkeys: PublicKey[] = [];\n\tfor (const pubkey1 of arr1) {\n\t\tfor (const pubkey2 of arr2) {\n\t\t\tif (pubkey1.equals(pubkey2)) {\n\t\t\t\tmatchingPubkeys.push(pubkey1);\n\t\t\t}\n\t\t}\n\t}\n\tif (matchingPubkeys.length !== 1) {\n\t\tthrow new Error('No unique public key found');\n\t}\n\treturn matchingPubkeys[0];\n}\n\n/**\n * Constructs the message that the passkey signature is produced over as authenticatorData || sha256(clientDataJSON).\n */\nfunction messageFromAssertionResponse(response: AuthenticatorAssertionResponse): Uint8Array {\n\tconst authenticatorData = new Uint8Array(response.authenticatorData);\n\tconst clientDataJSON = new Uint8Array(response.clientDataJSON);\n\tconst clientDataJSONDigest = sha256(clientDataJSON);\n\treturn new Uint8Array([...authenticatorData, ...clientDataJSONDigest]);\n}\n"],"mappings":";;;;;;;;;;;;AA6CA,IAAa,yBAAb,MAA+D;CAC9D;CACA;CAEA,YAAY,MAAc,SAAyC;AAClE,QAAKA,OAAQ;AACb,QAAKC,UAAW;;CAGjB,MAAM,SAA0C;AAC/C,SAAQ,MAAM,UAAU,YAAY,OAAO,EAC1C,WAAW;GACV,SAAS,MAAKA,QAAS,WAAW;GAClC,GAAG,MAAKA;GACR,IAAI;IACH,MAAM,MAAKD;IACX,GAAG,MAAKC,QAAS;IACjB;GACD,MAAM;IACL,MAAM,MAAKD;IACX,aAAa,MAAKA;IAClB,GAAG,MAAKC,QAAS;IACjB,IAAI,YAAY,GAAG;IACnB;GACD,WAAW,IAAI,aAAa,CAAC,OAAO,+BAA+B;GACnE,kBAAkB,CAAC;IAAE,KAAK;IAAI,MAAM;IAAc,CAAC;GACnD,wBAAwB;IACvB,yBAAyB;IACzB,aAAa;IACb,oBAAoB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ACnC,OAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;GAC3B,MAAM,IAAI,IAAI,eAAe,EAAE;AAC/B,OAAI;IAEH,MAAM,KAAK,IAAI,iBADA,EAAE,iBAAiB,QAAQ,CACH,QAAQ,KAAK,CAAC;AACrD,QAAI,KAAK,GAAG;WACL;AACP;;;AAGF,SAAO;;;;;;;;;;;AAYT,SAAgB,oBAAoB,MAAmB,MAA8B;CACpF,MAAM,kBAA+B,EAAE;AACvC,MAAK,MAAM,WAAW,KACrB,MAAK,MAAM,WAAW,KACrB,KAAI,QAAQ,OAAO,QAAQ,CAC1B,iBAAgB,KAAK,QAAQ;AAIhC,KAAI,gBAAgB,WAAW,EAC9B,OAAM,IAAI,MAAM,6BAA6B;AAE9C,QAAO,gBAAgB;;;;;AAMxB,SAAS,6BAA6B,UAAsD;CAC3F,MAAM,oBAAoB,IAAI,WAAW,SAAS,kBAAkB;CAEpE,MAAM,uBAAuB,OADN,IAAI,WAAW,SAAS,eAAe,CACX;AACnD,QAAO,IAAI,WAAW,CAAC,GAAG,mBAAmB,GAAG,qBAAqB,CAAC"}
@@ -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_bcs1124 from "@mysten/bcs";
11
+ import * as _mysten_bcs810 from "@mysten/bcs";
12
12
  import { SerializedBcs } from "@mysten/bcs";
13
13
  import { InferInput } from "valibot";
14
14
 
@@ -77,7 +77,7 @@ declare class Transaction {
77
77
  getData(): {
78
78
  version: 2;
79
79
  sender?: string | null | undefined;
80
- expiration?: _mysten_bcs1124.EnumOutputShapeWithKeys<{
80
+ expiration?: _mysten_bcs810.EnumOutputShapeWithKeys<{
81
81
  None: true;
82
82
  Epoch: string | number;
83
83
  ValidDuring: {
@@ -88,7 +88,7 @@ declare class Transaction {
88
88
  chain: string;
89
89
  nonce: number;
90
90
  };
91
- }, "None" | "Epoch" | "ValidDuring"> | null | undefined;
91
+ }, "Epoch" | "None" | "ValidDuring"> | null | undefined;
92
92
  gasData: {
93
93
  budget: string | number | null;
94
94
  price: string | number | null;
@@ -99,8 +99,8 @@ declare class Transaction {
99
99
  digest: string;
100
100
  }[] | null;
101
101
  };
102
- inputs: _mysten_bcs1124.EnumOutputShapeWithKeys<{
103
- Object: _mysten_bcs1124.EnumOutputShapeWithKeys<{
102
+ inputs: _mysten_bcs810.EnumOutputShapeWithKeys<{
103
+ Object: _mysten_bcs810.EnumOutputShapeWithKeys<{
104
104
  ImmOrOwnedObject: {
105
105
  objectId: string;
106
106
  version: string | number;
@@ -116,7 +116,7 @@ declare class Transaction {
116
116
  version: string | number;
117
117
  digest: string;
118
118
  };
119
- }, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
119
+ }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
120
120
  Pure: {
121
121
  bytes: string;
122
122
  };
@@ -139,13 +139,13 @@ declare class Transaction {
139
139
  Balance: string;
140
140
  $kind: "Balance";
141
141
  };
142
- withdrawFrom: _mysten_bcs1124.EnumOutputShapeWithKeys<{
142
+ withdrawFrom: _mysten_bcs810.EnumOutputShapeWithKeys<{
143
143
  Sender: true;
144
144
  Sponsor: true;
145
145
  }, "Sender" | "Sponsor">;
146
146
  };
147
- }, "Pure" | "Object" | "FundsWithdrawal" | "UnresolvedPure" | "UnresolvedObject">[];
148
- commands: _mysten_bcs1124.EnumOutputShapeWithKeys<{
147
+ }, "Object" | "Pure" | "FundsWithdrawal" | "UnresolvedPure" | "UnresolvedObject">[];
148
+ commands: _mysten_bcs810.EnumOutputShapeWithKeys<{
149
149
  MoveCall: {
150
150
  package: string;
151
151
  module: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Transaction.d.mts","names":[],"sources":["../../src/transactions/Transaction.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;KAoCY,yBAAA,GACT,QAAQ,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A,MAAA,GAAA,iBAAA,GAAA,gBAAA,GAAA,kBAAA,CAAA,EAAA;IAAA,QAAA,wCAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA5mBtD,kBAAkB,WAAW;;;;;;;;;;UA0CjC,kBACA;;;;;;;;;qBA2CW,mBAAmB;;;;;;;;;wBAQhB,mBAAmB;;;;;;;;;2BAQhB,mBAAmB;;;;;;gBAsB9B,kBAAkB,IAAI;uBACf,4BAA4B,sBAAsB,qBAC1D,gBAAgB,IAC1B;gBACW,yDACU,sBAAsB,KAC3C;oCAwGqB,sBAAsB,wDACtC,6CAA6C,UAU8B,QACjF;;qBAGY,UAAU,QAAQ;;;0BAIlB,8CACH,wCAAqC;;;;;;;MAS6C;;;;aAWnF;;;;;;YAMD;MACR;;eAWW;;;;;;iBAOI,sBAAsB;;;;iBAKtB,sBAAsB;;MAElC;4BASO,gDACD,sBAAsB,8BAA2B;;;;;eAe/C;;MAEX;;;;;;;;;;;;;;;;;;;;;;;;mBA8CqB,8BAAmC;;gBAmBrC,cAAc,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2DrB,0BAA+B,QAAQ,WAAW;;;aAW5D;MAER;mCAsJoC,8BAA2B"}
package/dist/version.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region src/version.ts
2
- const PACKAGE_VERSION = "2.6.0";
3
- const TARGETED_RPC_VERSION = "1.68.0";
2
+ const PACKAGE_VERSION = "2.8.0";
3
+ const TARGETED_RPC_VERSION = "1.69.0";
4
4
 
5
5
  //#endregion
6
6
  export { PACKAGE_VERSION, TARGETED_RPC_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.6.0';\nexport const TARGETED_RPC_VERSION = '1.68.0';\n"],"mappings":";AAKA,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB"}
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.8.0';\nexport const TARGETED_RPC_VERSION = '1.69.0';\n"],"mappings":";AAKA,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB"}
@@ -1,31 +1,31 @@
1
- import * as _mysten_bcs810 from "@mysten/bcs";
1
+ import * as _mysten_bcs817 from "@mysten/bcs";
2
2
  import { InferBcsInput } from "@mysten/bcs";
3
3
 
4
4
  //#region src/zklogin/bcs.d.ts
5
- declare const zkLoginSignature: _mysten_bcs810.BcsStruct<{
6
- inputs: _mysten_bcs810.BcsStruct<{
7
- proofPoints: _mysten_bcs810.BcsStruct<{
8
- a: _mysten_bcs810.BcsType<string[], Iterable<string> & {
5
+ declare const zkLoginSignature: _mysten_bcs817.BcsStruct<{
6
+ inputs: _mysten_bcs817.BcsStruct<{
7
+ proofPoints: _mysten_bcs817.BcsStruct<{
8
+ a: _mysten_bcs817.BcsType<string[], Iterable<string> & {
9
9
  length: number;
10
10
  }, string>;
11
- b: _mysten_bcs810.BcsType<string[][], Iterable<Iterable<string> & {
11
+ b: _mysten_bcs817.BcsType<string[][], Iterable<Iterable<string> & {
12
12
  length: number;
13
13
  }> & {
14
14
  length: number;
15
15
  }, string>;
16
- c: _mysten_bcs810.BcsType<string[], Iterable<string> & {
16
+ c: _mysten_bcs817.BcsType<string[], Iterable<string> & {
17
17
  length: number;
18
18
  }, string>;
19
19
  }, string>;
20
- issBase64Details: _mysten_bcs810.BcsStruct<{
21
- value: _mysten_bcs810.BcsType<string, string, "string">;
22
- indexMod4: _mysten_bcs810.BcsType<number, number, "u8">;
20
+ issBase64Details: _mysten_bcs817.BcsStruct<{
21
+ value: _mysten_bcs817.BcsType<string, string, "string">;
22
+ indexMod4: _mysten_bcs817.BcsType<number, number, "u8">;
23
23
  }, string>;
24
- headerBase64: _mysten_bcs810.BcsType<string, string, "string">;
25
- addressSeed: _mysten_bcs810.BcsType<string, string, "string">;
24
+ headerBase64: _mysten_bcs817.BcsType<string, string, "string">;
25
+ addressSeed: _mysten_bcs817.BcsType<string, string, "string">;
26
26
  }, string>;
27
- maxEpoch: _mysten_bcs810.BcsType<string, string | number | bigint, "u64">;
28
- userSignature: _mysten_bcs810.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
27
+ maxEpoch: _mysten_bcs817.BcsType<string, string | number | bigint, "u64">;
28
+ userSignature: _mysten_bcs817.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
29
29
  }, string>;
30
30
  type ZkLoginSignature = InferBcsInput<typeof zkLoginSignature>;
31
31
  type ZkLoginSignatureInputs = ZkLoginSignature['inputs'];
package/docs/bcs.md ADDED
@@ -0,0 +1,131 @@
1
+ # BCS
2
+
3
+ > Binary Canonical Serialization for encoding Sui Move types
4
+
5
+ The `@mysten/sui/bcs` package extends `@mysten/bcs` with Sui specific scheme definitions.
6
+
7
+ To learn more about using BCS see the [BCS documentation](/bcs).
8
+
9
+ the `bcs` export of `@mysten/sui/bcs` contains all the same exports as `bcs` from `@mysten/bcs` plus
10
+ the following pre-defined schemes:
11
+
12
+ - `U8`
13
+ - `U16`
14
+ - `U32`
15
+ - `U64`
16
+ - `U128`
17
+ - `U256`
18
+ - `ULEB128`
19
+ - `Bool`
20
+ - `String`
21
+ - `Address`
22
+ - `Argument`
23
+ - `CallArg`
24
+ - `CompressedSignature`
25
+ - `GasData`
26
+ - `MultiSig`
27
+ - `MultiSigPkMap`
28
+ - `MultiSigPublicKey`
29
+ - `ObjectArg`
30
+ - `ObjectDigest`
31
+ - `ProgrammableMoveCall`
32
+ - `ProgrammableTransaction`
33
+ - `PublicKey`
34
+ - `SenderSignedData`
35
+ - `SharedObjectRef`
36
+ - `StructTag`
37
+ - `SuiObjectRef`
38
+ - `Transaction`
39
+ - `TransactionData`
40
+ - `TransactionDataV1`
41
+ - `TransactionExpiration`
42
+ - `TransactionKind`
43
+ - `TypeTag`
44
+ - `Object` - Complete object with data, owner, previousTransaction, and storageRebate
45
+ - `TransactionEffects` - Transaction execution effects (supports both V1 and V2)
46
+ - `TransactionEffectsV1` - Legacy transaction effects format
47
+ - `TransactionEffectsV2` - Current transaction effects format with detailed object changes
48
+
49
+ All the upper-cased values are `BcsType` instances, and can be used directly to parse and serialize
50
+ data.
51
+
52
+ ```typescript
53
+ bcs.U8.serialize(1);
54
+ bcs.Address.serialize('0x1');
55
+ bcs.TypeTag.serialize({
56
+ vector: {
57
+ u8: true,
58
+ },
59
+ });
60
+ ```
61
+
62
+ ## Working with Objects
63
+
64
+ To parse on-chain objects, fetch them with `include: { content: true }` and pass `object.content` to
65
+ a generated BCS type or a manual struct definition. The `content` field contains only the inner Move
66
+ struct bytes:
67
+
68
+ ```typescript
69
+ const { object } = await client.core.getObject({
70
+ objectId: '0x123...',
71
+ include: { content: true },
72
+ });
73
+
74
+ const parsed = MyStruct.parse(object.content);
75
+ ```
76
+
77
+ ### `bcs.Object` — Full object envelope
78
+
79
+ The `bcs.Object` schema represents the complete on-chain object, including metadata (type, owner,
80
+ version, previous transaction, storage rebate) wrapping the inner struct bytes. This is what the
81
+ `objectBcs` include option returns. Most of this metadata is already available as fields on the
82
+ object response, so you typically only need `content`.
83
+
84
+ ```typescript
85
+
86
+ // Parse a full object envelope (from objectBcs include option)
87
+ const envelope = bcs.Object.parse(object.objectBcs);
88
+ console.log('Owner:', envelope.owner);
89
+ console.log('Inner struct bytes:', envelope.data.Move.contents);
90
+
91
+ // Serialize a full object envelope
92
+ const serialized = bcs.Object.serialize({
93
+ data: {
94
+ Move: {
95
+ type: { GasCoin: null },
96
+ hasPublicTransfer: true,
97
+ version: '1',
98
+ contents: new Uint8Array([...]),
99
+ },
100
+ },
101
+ owner: { AddressOwner: '0x...' },
102
+ previousTransaction: '...',
103
+ storageRebate: '1000',
104
+ });
105
+ ```
106
+
107
+ > **Warning:** Do not pass `objectBcs` bytes to a Move struct parser — it contains wrapping metadata
108
+ > that will cause parsing to fail. Use `content` for parsing Move struct fields. See the
109
+ > [Core API docs](/sui/clients/core#objectbcs) for details.
110
+
111
+ ## Working with Transaction Effects
112
+
113
+ The `bcs.TransactionEffects` schema can be used to parse transaction effects:
114
+
115
+ ```typescript
116
+ // Parse transaction effects
117
+ const effects = bcs.TransactionEffects.parse(effectsBytes);
118
+
119
+ // Check execution status
120
+ if (effects.V2.status.$kind === 'Success') {
121
+ console.log('Transaction succeeded');
122
+ } else {
123
+ console.log('Transaction failed:', effects.V2.status.Failure.error);
124
+ }
125
+
126
+ // Access changed objects
127
+ for (const [objectId, change] of effects.V2.changedObjects) {
128
+ console.log('Object:', objectId);
129
+ console.log('Output state:', change.outputState.$kind);
130
+ }
131
+ ```