@mysten/sui 2.7.0 → 2.9.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 +19 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/keypairs/passkey/keypair.d.mts +11 -4
- package/dist/keypairs/passkey/keypair.d.mts.map +1 -1
- package/dist/keypairs/passkey/keypair.mjs +19 -6
- package/dist/keypairs/passkey/keypair.mjs.map +1 -1
- package/dist/utils/constants.d.mts +2 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +2 -1
- package/dist/utils/constants.mjs.map +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +2 -2
- package/dist/version.mjs +2 -2
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.map +1 -1
- package/docs/bcs.md +131 -0
- package/docs/clients/core.md +601 -0
- package/docs/clients/graphql.md +99 -0
- package/docs/clients/grpc.md +152 -0
- package/docs/clients/index.md +93 -0
- package/docs/clients/json-rpc.md +235 -0
- package/docs/cryptography/keypairs.md +258 -0
- package/docs/cryptography/multisig.md +192 -0
- package/docs/cryptography/passkey.md +111 -0
- package/docs/cryptography/webcrypto-signer.md +81 -0
- package/docs/executors.md +147 -0
- package/docs/faucet.md +26 -0
- package/docs/hello-sui.md +114 -0
- package/docs/index.md +54 -0
- package/docs/install.md +61 -0
- package/docs/llm-docs.md +32 -0
- package/docs/llms-index.md +60 -0
- package/docs/migrations/0.38.md +57 -0
- package/docs/migrations/sui-1.0.md +453 -0
- package/docs/migrations/sui-2.0/agent-prompt.md +42 -0
- package/docs/migrations/sui-2.0/dapp-kit.md +350 -0
- package/docs/migrations/sui-2.0/deepbook-v3.md +33 -0
- package/docs/migrations/sui-2.0/index.md +157 -0
- package/docs/migrations/sui-2.0/json-rpc-migration.md +383 -0
- package/docs/migrations/sui-2.0/kiosk.md +120 -0
- package/docs/migrations/sui-2.0/sdk-maintainers.md +90 -0
- package/docs/migrations/sui-2.0/seal.md +14 -0
- package/docs/migrations/sui-2.0/sui.md +341 -0
- package/docs/migrations/sui-2.0/suins.md +42 -0
- package/docs/migrations/sui-2.0/wallet-builders.md +66 -0
- package/docs/migrations/sui-2.0/walrus.md +41 -0
- package/docs/migrations/sui-2.0/zksend.md +94 -0
- package/docs/plugins.md +255 -0
- package/docs/sdk-building.md +340 -0
- package/docs/transaction-building/basics.md +297 -0
- package/docs/transaction-building/gas.md +62 -0
- package/docs/transaction-building/intents.md +61 -0
- package/docs/transaction-building/offline.md +71 -0
- package/docs/transaction-building/sponsored-transactions.md +22 -0
- package/docs/utils/derived_objects.md +59 -0
- package/docs/utils/index.md +52 -0
- package/docs/zklogin.md +78 -0
- package/package.json +4 -2
- package/src/keypairs/passkey/keypair.ts +20 -6
- package/src/utils/constants.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/src/version.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @mysten/sui.js
|
|
2
2
|
|
|
3
|
+
## 2.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c769abb: Add `SUI_COIN_REGISTRY_OBJECT_ID` constant
|
|
8
|
+
|
|
9
|
+
## 2.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- e51dc5d: Add credentialId support to PasskeyKeypair for targeted credential selection during
|
|
14
|
+
signing
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 43e69f8: Add embedded LLM-friendly docs to published packages
|
|
19
|
+
- Updated dependencies [43e69f8]
|
|
20
|
+
- @mysten/bcs@2.0.3
|
|
21
|
+
|
|
3
22
|
## 2.7.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/dist/bcs/bcs.d.mts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { TypeTag as TypeTag$1 } from "./types.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_bcs810 from "@mysten/bcs";
|
|
3
3
|
import { BcsType } from "@mysten/bcs";
|
|
4
4
|
|
|
5
5
|
//#region src/bcs/bcs.d.ts
|
|
6
6
|
|
|
7
7
|
declare const TypeTag: BcsType<string, string | TypeTag$1, string>;
|
|
8
|
-
declare function IntentMessage<T extends BcsType<any>>(T: T):
|
|
9
|
-
intent:
|
|
10
|
-
scope:
|
|
8
|
+
declare function IntentMessage<T extends BcsType<any>>(T: T): _mysten_bcs810.BcsStruct<{
|
|
9
|
+
intent: _mysten_bcs810.BcsStruct<{
|
|
10
|
+
scope: _mysten_bcs810.BcsEnum<{
|
|
11
11
|
TransactionData: null;
|
|
12
12
|
TransactionEffects: null;
|
|
13
13
|
CheckpointSummary: null;
|
|
14
14
|
PersonalMessage: null;
|
|
15
15
|
}, "IntentScope">;
|
|
16
|
-
version:
|
|
16
|
+
version: _mysten_bcs810.BcsEnum<{
|
|
17
17
|
V0: null;
|
|
18
18
|
}, "IntentVersion">;
|
|
19
|
-
appId:
|
|
19
|
+
appId: _mysten_bcs810.BcsEnum<{
|
|
20
20
|
Sui: null;
|
|
21
21
|
}, "AppId">;
|
|
22
22
|
}, string>;
|
|
@@ -33,6 +33,12 @@ declare function parseSerializedSignature(serializedSignature: string): {
|
|
|
33
33
|
clientDataJson: string;
|
|
34
34
|
userSignature: Uint8Array<ArrayBuffer>;
|
|
35
35
|
publicKey: Uint8Array<ArrayBuffer>;
|
|
36
|
+
} | {
|
|
37
|
+
serializedSignature: string;
|
|
38
|
+
signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
|
|
39
|
+
signature: Uint8Array<ArrayBuffer>;
|
|
40
|
+
publicKey: Uint8Array<ArrayBuffer>;
|
|
41
|
+
bytes: Uint8Array<ArrayBuffer>;
|
|
36
42
|
} | {
|
|
37
43
|
serializedSignature: string;
|
|
38
44
|
signatureScheme: "ZkLogin";
|
|
@@ -57,12 +63,6 @@ declare function parseSerializedSignature(serializedSignature: string): {
|
|
|
57
63
|
};
|
|
58
64
|
signature: Uint8Array<ArrayBufferLike>;
|
|
59
65
|
publicKey: Uint8Array<ArrayBuffer>;
|
|
60
|
-
} | {
|
|
61
|
-
serializedSignature: string;
|
|
62
|
-
signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
|
|
63
|
-
signature: Uint8Array<ArrayBuffer>;
|
|
64
|
-
publicKey: Uint8Array<ArrayBuffer>;
|
|
65
|
-
bytes: Uint8Array<ArrayBuffer>;
|
|
66
66
|
} | {
|
|
67
67
|
serializedSignature: string;
|
|
68
68
|
signatureScheme: "MultiSig";
|
|
@@ -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
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime3 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc3 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
|
|
@@ -46,9 +46,9 @@ interface ILedgerServiceClient {
|
|
|
46
46
|
declare class LedgerServiceClient implements ILedgerServiceClient, ServiceInfo {
|
|
47
47
|
private readonly _transport;
|
|
48
48
|
typeName: string;
|
|
49
|
-
methods:
|
|
49
|
+
methods: _protobuf_ts_runtime_rpc3.MethodInfo<any, any>[];
|
|
50
50
|
options: {
|
|
51
|
-
[extensionName: string]:
|
|
51
|
+
[extensionName: string]: _protobuf_ts_runtime3.JsonValue;
|
|
52
52
|
};
|
|
53
53
|
constructor(_transport: RpcTransport);
|
|
54
54
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetDatatypeRequest, GetDatatypeResponse, GetFunctionRequest, GetFunctionResponse, GetPackageRequest, GetPackageResponse, ListPackageVersionsRequest, ListPackageVersionsResponse } from "./move_package_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
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, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts
|
|
@@ -32,9 +32,9 @@ interface IMovePackageServiceClient {
|
|
|
32
32
|
declare class MovePackageServiceClient implements IMovePackageServiceClient, ServiceInfo {
|
|
33
33
|
private readonly _transport;
|
|
34
34
|
typeName: string;
|
|
35
|
-
methods:
|
|
35
|
+
methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
|
|
36
36
|
options: {
|
|
37
|
-
[extensionName: string]:
|
|
37
|
+
[extensionName: string]: _protobuf_ts_runtime5.JsonValue;
|
|
38
38
|
};
|
|
39
39
|
constructor(_transport: RpcTransport);
|
|
40
40
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VerifySignatureRequest, VerifySignatureResponse } from "./signature_verification_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
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/signature_verification_service.client.d.ts
|
|
@@ -22,9 +22,9 @@ interface ISignatureVerificationServiceClient {
|
|
|
22
22
|
declare class SignatureVerificationServiceClient implements ISignatureVerificationServiceClient, ServiceInfo {
|
|
23
23
|
private readonly _transport;
|
|
24
24
|
typeName: string;
|
|
25
|
-
methods:
|
|
25
|
+
methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
|
|
26
26
|
options: {
|
|
27
|
-
[extensionName: string]:
|
|
27
|
+
[extensionName: string]: _protobuf_ts_runtime1.JsonValue;
|
|
28
28
|
};
|
|
29
29
|
constructor(_transport: RpcTransport);
|
|
30
30
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetBalanceRequest, GetBalanceResponse, GetCoinInfoRequest, GetCoinInfoResponse, ListBalancesRequest, ListBalancesResponse, ListDynamicFieldsRequest, ListDynamicFieldsResponse, ListOwnedObjectsRequest, ListOwnedObjectsResponse } from "./state_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
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/state_service.client.d.ts
|
|
@@ -36,9 +36,9 @@ interface IStateServiceClient {
|
|
|
36
36
|
declare class StateServiceClient implements IStateServiceClient, ServiceInfo {
|
|
37
37
|
private readonly _transport;
|
|
38
38
|
typeName: string;
|
|
39
|
-
methods:
|
|
39
|
+
methods: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
|
|
40
40
|
options: {
|
|
41
|
-
[extensionName: string]:
|
|
41
|
+
[extensionName: string]: _protobuf_ts_runtime2.JsonValue;
|
|
42
42
|
};
|
|
43
43
|
constructor(_transport: RpcTransport);
|
|
44
44
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SubscribeCheckpointsRequest, SubscribeCheckpointsResponse } from "./subscription_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
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, ServerStreamingCall, ServiceInfo } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts
|
|
@@ -32,9 +32,9 @@ interface ISubscriptionServiceClient {
|
|
|
32
32
|
declare class SubscriptionServiceClient implements ISubscriptionServiceClient, ServiceInfo {
|
|
33
33
|
private readonly _transport;
|
|
34
34
|
typeName: string;
|
|
35
|
-
methods:
|
|
35
|
+
methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
|
|
36
36
|
options: {
|
|
37
|
-
[extensionName: string]:
|
|
37
|
+
[extensionName: string]: _protobuf_ts_runtime4.JsonValue;
|
|
38
38
|
};
|
|
39
39
|
constructor(_transport: RpcTransport);
|
|
40
40
|
/**
|
|
@@ -11,13 +11,13 @@ type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> }
|
|
|
11
11
|
type BrowserPasswordProviderOptions = Pick<DeepPartial<PublicKeyCredentialCreationOptions>, DeepPartialConfigKeys> & Omit<Partial<PublicKeyCredentialCreationOptions>, DeepPartialConfigKeys | 'pubKeyCredParams' | 'challenge'>;
|
|
12
12
|
interface PasskeyProvider {
|
|
13
13
|
create(): Promise<RegistrationCredential>;
|
|
14
|
-
get(challenge: Uint8Array): Promise<AuthenticationCredential>;
|
|
14
|
+
get(challenge: Uint8Array, credentialId?: Uint8Array): Promise<AuthenticationCredential>;
|
|
15
15
|
}
|
|
16
16
|
declare class BrowserPasskeyProvider implements PasskeyProvider {
|
|
17
17
|
#private;
|
|
18
18
|
constructor(name: string, options: BrowserPasswordProviderOptions);
|
|
19
19
|
create(): Promise<RegistrationCredential>;
|
|
20
|
-
get(challenge: Uint8Array): Promise<AuthenticationCredential>;
|
|
20
|
+
get(challenge: Uint8Array, credentialId?: Uint8Array): Promise<AuthenticationCredential>;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* @experimental
|
|
@@ -26,6 +26,7 @@ declare class BrowserPasskeyProvider implements PasskeyProvider {
|
|
|
26
26
|
declare class PasskeyKeypair extends Signer {
|
|
27
27
|
private publicKey;
|
|
28
28
|
private provider;
|
|
29
|
+
private credentialId?;
|
|
29
30
|
/**
|
|
30
31
|
* Get the key scheme of passkey,
|
|
31
32
|
*/
|
|
@@ -44,7 +45,13 @@ declare class PasskeyKeypair extends Signer {
|
|
|
44
45
|
* If there are existing passkey wallet, use `signAndRecover` to identify the correct
|
|
45
46
|
* public key and then initialize the instance. See usage in `signAndRecover`.
|
|
46
47
|
*/
|
|
47
|
-
constructor(publicKey: Uint8Array, provider: PasskeyProvider);
|
|
48
|
+
constructor(publicKey: Uint8Array, provider: PasskeyProvider, credentialId?: Uint8Array);
|
|
49
|
+
/**
|
|
50
|
+
* Return the credential ID for this passkey, if available.
|
|
51
|
+
* The credential ID is captured when creating a new passkey via `getPasskeyInstance`
|
|
52
|
+
* and can be used to constrain which credential the browser selects during signing.
|
|
53
|
+
*/
|
|
54
|
+
getCredentialId(): Uint8Array | undefined;
|
|
48
55
|
/**
|
|
49
56
|
* Creates an instance of Passkey signer invoking the passkey from navigator.
|
|
50
57
|
* Note that this will invoke the passkey device to create a fresh credential.
|
|
@@ -93,7 +100,7 @@ declare class PasskeyKeypair extends Signer {
|
|
|
93
100
|
* const testMessage2 = new TextEncoder().encode('Hello world 2!');
|
|
94
101
|
* const possiblePks2 = await PasskeyKeypair.signAndRecover(provider, testMessage2);
|
|
95
102
|
* const commonPk = findCommonPublicKey(possiblePks, possiblePks2);
|
|
96
|
-
* const signer = new PasskeyKeypair(
|
|
103
|
+
* const signer = new PasskeyKeypair(commonPk.toRawBytes(), provider);
|
|
97
104
|
* ```
|
|
98
105
|
*
|
|
99
106
|
* @param provider - the passkey provider.
|
|
@@ -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,IAVe,CAWd,OAXc,CAWN,kCAXM,CAAA,EAYd,qBAZc,GAAA,kBAAA,GAAA,WAAA,CAAA;AAAM,UAeL,eAAA,CAfK;EAEP,MAAA,EAAA,EAcJ,OAdI,CAcI,sBAdJ,CAAA;EAAiB,GAAA,CAAA,SAAA,EAehB,UAfgB,CAAA,
|
|
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,IAVe,CAWd,OAXc,CAWN,kCAXM,CAAA,EAYd,qBAZc,GA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;;;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(
|
|
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,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E;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"}
|
|
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;GACn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U,UAAU,IAAI,WAAW,WAAW,SAAS,UAAU,EAAE,MAAM;EAE/F,MAAM,MAAM,EAAE;EACd,MAAM,UAAU,OAAO,YAAY;AACnC,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"}
|
|
@@ -9,7 +9,8 @@ declare const SUI_SYSTEM_MODULE_NAME = "sui_system";
|
|
|
9
9
|
declare const SUI_TYPE_ARG = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
10
10
|
declare const SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000005";
|
|
11
11
|
declare const SUI_RANDOM_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000008";
|
|
12
|
+
declare const SUI_COIN_REGISTRY_OBJECT_ID = "0x000000000000000000000000000000000000000000000000000000000000000c";
|
|
12
13
|
declare const SUI_DENY_LIST_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000403";
|
|
13
14
|
//#endregion
|
|
14
|
-
export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG };
|
|
15
|
+
export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG };
|
|
15
16
|
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","names":[],"sources":["../../src/utils/constants.ts"],"sourcesContent":[],"mappings":";cAGa,YAAA;AAAA,cACA,YADY,EAAA,MAAA;AACZ,cAEA,mBAAA,GAFiC,oEAAA;AAEjC,cAEA,qBAAA,GAFmB,oEAAA;AAEnB,cAEA,kBAAA,GAFqB,oEAAA;AAErB,cAEA,mBAAA,GAFkB,oEAAA;AAElB,cAEA,sBAAA,GAFmB,YAAA;AAEnB,cACA,YAAA,GADsB,8EAAA;AACtB,cACA,0BAAA,GADY,oEAAA;AACZ,cAEA,oBAAA,GAF0B,oEAAA;AAE1B,cAEA,
|
|
1
|
+
{"version":3,"file":"constants.d.mts","names":[],"sources":["../../src/utils/constants.ts"],"sourcesContent":[],"mappings":";cAGa,YAAA;AAAA,cACA,YADY,EAAA,MAAA;AACZ,cAEA,mBAAA,GAFiC,oEAAA;AAEjC,cAEA,qBAAA,GAFmB,oEAAA;AAEnB,cAEA,kBAAA,GAFqB,oEAAA;AAErB,cAEA,mBAAA,GAFkB,oEAAA;AAElB,cAEA,sBAAA,GAFmB,YAAA;AAEnB,cACA,YAAA,GADsB,8EAAA;AACtB,cACA,0BAAA,GADY,oEAAA;AACZ,cAEA,oBAAA,GAF0B,oEAAA;AAE1B,cAEA,2BAAA,GAFoB,oEAAA;AAEpB,cAEA,uBAAA,GAF2B,oEAAA"}
|
package/dist/utils/constants.mjs
CHANGED
|
@@ -9,8 +9,9 @@ const SUI_SYSTEM_MODULE_NAME = "sui_system";
|
|
|
9
9
|
const SUI_TYPE_ARG = `${SUI_FRAMEWORK_ADDRESS}::sui::SUI`;
|
|
10
10
|
const SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000005";
|
|
11
11
|
const SUI_RANDOM_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000008";
|
|
12
|
+
const SUI_COIN_REGISTRY_OBJECT_ID = "0x000000000000000000000000000000000000000000000000000000000000000c";
|
|
12
13
|
const SUI_DENY_LIST_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000403";
|
|
13
14
|
|
|
14
15
|
//#endregion
|
|
15
|
-
export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG };
|
|
16
|
+
export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG };
|
|
16
17
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/utils/constants.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport const SUI_DECIMALS = 9;\nexport const MIST_PER_SUI = BigInt(1000000000);\n\nexport const MOVE_STDLIB_ADDRESS =\n\t'0x0000000000000000000000000000000000000000000000000000000000000001';\nexport const SUI_FRAMEWORK_ADDRESS =\n\t'0x0000000000000000000000000000000000000000000000000000000000000002';\nexport const SUI_SYSTEM_ADDRESS =\n\t'0x0000000000000000000000000000000000000000000000000000000000000003';\nexport const SUI_CLOCK_OBJECT_ID =\n\t'0x0000000000000000000000000000000000000000000000000000000000000006';\nexport const SUI_SYSTEM_MODULE_NAME = 'sui_system';\nexport const SUI_TYPE_ARG = `${SUI_FRAMEWORK_ADDRESS}::sui::SUI`;\nexport const SUI_SYSTEM_STATE_OBJECT_ID =\n\t'0x0000000000000000000000000000000000000000000000000000000000000005';\nexport const SUI_RANDOM_OBJECT_ID =\n\t'0x0000000000000000000000000000000000000000000000000000000000000008';\nexport const SUI_DENY_LIST_OBJECT_ID =\n\t'0x0000000000000000000000000000000000000000000000000000000000000403';\n"],"mappings":";AAGA,MAAa,eAAe;AAC5B,MAAa,eAAe,OAAO,IAAW;AAE9C,MAAa,sBACZ;AACD,MAAa,wBACZ;AACD,MAAa,qBACZ;AACD,MAAa,sBACZ;AACD,MAAa,yBAAyB;AACtC,MAAa,eAAe,GAAG,sBAAsB;AACrD,MAAa,6BACZ;AACD,MAAa,uBACZ;AACD,MAAa,0BACZ"}
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/utils/constants.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport const SUI_DECIMALS = 9;\nexport const MIST_PER_SUI = BigInt(1000000000);\n\nexport const MOVE_STDLIB_ADDRESS =\n\t'0x0000000000000000000000000000000000000000000000000000000000000001';\nexport const SUI_FRAMEWORK_ADDRESS =\n\t'0x0000000000000000000000000000000000000000000000000000000000000002';\nexport const SUI_SYSTEM_ADDRESS =\n\t'0x0000000000000000000000000000000000000000000000000000000000000003';\nexport const SUI_CLOCK_OBJECT_ID =\n\t'0x0000000000000000000000000000000000000000000000000000000000000006';\nexport const SUI_SYSTEM_MODULE_NAME = 'sui_system';\nexport const SUI_TYPE_ARG = `${SUI_FRAMEWORK_ADDRESS}::sui::SUI`;\nexport const SUI_SYSTEM_STATE_OBJECT_ID =\n\t'0x0000000000000000000000000000000000000000000000000000000000000005';\nexport const SUI_RANDOM_OBJECT_ID =\n\t'0x0000000000000000000000000000000000000000000000000000000000000008';\nexport const SUI_COIN_REGISTRY_OBJECT_ID =\n\t'0x000000000000000000000000000000000000000000000000000000000000000c';\nexport const SUI_DENY_LIST_OBJECT_ID =\n\t'0x0000000000000000000000000000000000000000000000000000000000000403';\n"],"mappings":";AAGA,MAAa,eAAe;AAC5B,MAAa,eAAe,OAAO,IAAW;AAE9C,MAAa,sBACZ;AACD,MAAa,wBACZ;AACD,MAAa,qBACZ;AACD,MAAa,sBACZ;AACD,MAAa,yBAAyB;AACtC,MAAa,eAAe,GAAG,sBAAsB;AACrD,MAAa,6BACZ;AACD,MAAa,uBACZ;AACD,MAAa,8BACZ;AACD,MAAa,0BACZ"}
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -2,9 +2,9 @@ import { normalizeTypeTag } from "../bcs/type-tag-serializer.mjs";
|
|
|
2
2
|
import { SUI_ADDRESS_LENGTH, isValidStructTag, isValidSuiAddress, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiObjectId, parseStructTag } from "./sui-types.mjs";
|
|
3
3
|
import { formatAddress, formatDigest } from "./format.mjs";
|
|
4
4
|
import { isValidSuiNSName, normalizeSuiNSName } from "./suins.mjs";
|
|
5
|
-
import { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG } from "./constants.mjs";
|
|
5
|
+
import { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG } from "./constants.mjs";
|
|
6
6
|
import { isValidNamedPackage, isValidNamedType } from "./move-registry.mjs";
|
|
7
7
|
import { deriveDynamicFieldID } from "./dynamic-fields.mjs";
|
|
8
8
|
import { deriveObjectID } from "./derived-objects.mjs";
|
|
9
9
|
import { fromBase58, fromBase64, fromHex, toBase58, toBase64, toHex } from "@mysten/bcs";
|
|
10
|
-
export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_ADDRESS_LENGTH, SUI_CLOCK_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG, deriveDynamicFieldID, deriveObjectID, formatAddress, formatDigest, fromBase58, fromBase64, fromHex, isValidNamedPackage, isValidNamedType, isValidStructTag, isValidSuiAddress, isValidSuiNSName, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiNSName, normalizeSuiObjectId, normalizeTypeTag, parseStructTag, toBase58, toBase64, toHex };
|
|
10
|
+
export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_ADDRESS_LENGTH, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG, deriveDynamicFieldID, deriveObjectID, formatAddress, formatDigest, fromBase58, fromBase64, fromHex, isValidNamedPackage, isValidNamedType, isValidStructTag, isValidSuiAddress, isValidSuiNSName, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiNSName, normalizeSuiObjectId, normalizeTypeTag, parseStructTag, toBase58, toBase64, toHex };
|
package/dist/utils/index.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import { isValidNamedPackage, isValidNamedType } from "./move-registry.mjs";
|
|
|
3
3
|
import { SUI_ADDRESS_LENGTH, isValidStructTag, isValidSuiAddress, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiObjectId, parseStructTag } from "./sui-types.mjs";
|
|
4
4
|
import { normalizeTypeTag } from "../bcs/type-tag-serializer.mjs";
|
|
5
5
|
import { deriveDynamicFieldID } from "./dynamic-fields.mjs";
|
|
6
|
-
import { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG } from "./constants.mjs";
|
|
6
|
+
import { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG } from "./constants.mjs";
|
|
7
7
|
import { formatAddress, formatDigest } from "./format.mjs";
|
|
8
8
|
import { deriveObjectID } from "./derived-objects.mjs";
|
|
9
9
|
import { fromBase58, fromBase64, fromHex, toBase58, toBase64, toHex } from "@mysten/bcs";
|
|
10
10
|
|
|
11
|
-
export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_ADDRESS_LENGTH, SUI_CLOCK_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG, deriveDynamicFieldID, deriveObjectID, formatAddress, formatDigest, fromBase58, fromBase64, fromHex, isValidNamedPackage, isValidNamedType, isValidStructTag, isValidSuiAddress, isValidSuiNSName, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiNSName, normalizeSuiObjectId, normalizeTypeTag, parseStructTag, toBase58, toBase64, toHex };
|
|
11
|
+
export { MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_ADDRESS_LENGTH, SUI_CLOCK_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DECIMALS, SUI_DENY_LIST_OBJECT_ID, SUI_FRAMEWORK_ADDRESS, SUI_RANDOM_OBJECT_ID, SUI_SYSTEM_ADDRESS, SUI_SYSTEM_MODULE_NAME, SUI_SYSTEM_STATE_OBJECT_ID, SUI_TYPE_ARG, deriveDynamicFieldID, deriveObjectID, formatAddress, formatDigest, fromBase58, fromBase64, fromHex, isValidNamedPackage, isValidNamedType, isValidStructTag, isValidSuiAddress, isValidSuiNSName, isValidSuiObjectId, isValidTransactionDigest, normalizeStructTag, normalizeSuiAddress, normalizeSuiNSName, normalizeSuiObjectId, normalizeTypeTag, parseStructTag, toBase58, toBase64, toHex };
|
package/dist/version.mjs
CHANGED
package/dist/version.mjs.map
CHANGED
|
@@ -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.
|
|
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.9.0';\nexport const TARGETED_RPC_VERSION = '1.69.0';\n"],"mappings":";AAKA,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB"}
|
package/dist/zklogin/bcs.d.mts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _mysten_bcs1111 from "@mysten/bcs";
|
|
2
2
|
import { InferBcsInput } from "@mysten/bcs";
|
|
3
3
|
|
|
4
4
|
//#region src/zklogin/bcs.d.ts
|
|
5
|
-
declare const zkLoginSignature:
|
|
6
|
-
inputs:
|
|
7
|
-
proofPoints:
|
|
8
|
-
a:
|
|
5
|
+
declare const zkLoginSignature: _mysten_bcs1111.BcsStruct<{
|
|
6
|
+
inputs: _mysten_bcs1111.BcsStruct<{
|
|
7
|
+
proofPoints: _mysten_bcs1111.BcsStruct<{
|
|
8
|
+
a: _mysten_bcs1111.BcsType<string[], Iterable<string> & {
|
|
9
9
|
length: number;
|
|
10
10
|
}, string>;
|
|
11
|
-
b:
|
|
11
|
+
b: _mysten_bcs1111.BcsType<string[][], Iterable<Iterable<string> & {
|
|
12
12
|
length: number;
|
|
13
13
|
}> & {
|
|
14
14
|
length: number;
|
|
15
15
|
}, string>;
|
|
16
|
-
c:
|
|
16
|
+
c: _mysten_bcs1111.BcsType<string[], Iterable<string> & {
|
|
17
17
|
length: number;
|
|
18
18
|
}, string>;
|
|
19
19
|
}, string>;
|
|
20
|
-
issBase64Details:
|
|
21
|
-
value:
|
|
22
|
-
indexMod4:
|
|
20
|
+
issBase64Details: _mysten_bcs1111.BcsStruct<{
|
|
21
|
+
value: _mysten_bcs1111.BcsType<string, string, "string">;
|
|
22
|
+
indexMod4: _mysten_bcs1111.BcsType<number, number, "u8">;
|
|
23
23
|
}, string>;
|
|
24
|
-
headerBase64:
|
|
25
|
-
addressSeed:
|
|
24
|
+
headerBase64: _mysten_bcs1111.BcsType<string, string, "string">;
|
|
25
|
+
addressSeed: _mysten_bcs1111.BcsType<string, string, "string">;
|
|
26
26
|
}, string>;
|
|
27
|
-
maxEpoch:
|
|
28
|
-
userSignature:
|
|
27
|
+
maxEpoch: _mysten_bcs1111.BcsType<string, string | number | bigint, "u64">;
|
|
28
|
+
userSignature: _mysten_bcs1111.BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">;
|
|
29
29
|
}, string>;
|
|
30
30
|
type ZkLoginSignature = InferBcsInput<typeof zkLoginSignature>;
|
|
31
31
|
type ZkLoginSignatureInputs = ZkLoginSignature['inputs'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/zklogin/bcs.ts"],"sourcesContent":[],"mappings":";;;;cAMa,
|
|
1
|
+
{"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/zklogin/bcs.ts"],"sourcesContent":[],"mappings":";;;;cAMa,kCAAgB;;;MAAhB,CAAA,yBAgBX,CAAA,MAAA,EAAA,UAAA,CAAA,MAAA,CAAA,GAAA;;;;;;;;;;;;;;;;;;;;eAhB2B,yBAAA,WAAA,gBAAA,CAAA,UAAA,CAAA,MAAA,CAAA,EAAA,YAAA,CAAA;CAAA,EAAA,MAAA,CAAA;AAkBjB,KAAA,gBAAA,GAAmB,aAAqB,CAAA,OAAA,gBAAR,CAAA;AAChC,KAAA,sBAAA,GAAyB,gBAAA,CAAA,QAAgB,CAAA"}
|