zksync-sso 0.3.3 → 0.4.0-beta.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/README.md +2 -1
- package/dist/_cjs/abi/GuardianRecoveryModule.js +767 -0
- package/dist/_cjs/abi/GuardianRecoveryModule.js.map +1 -0
- package/dist/_cjs/abi/OidcKeyRegistry.js +492 -0
- package/dist/_cjs/abi/OidcKeyRegistry.js.map +1 -0
- package/dist/_cjs/abi/OidcRecoveryValidator.js +528 -0
- package/dist/_cjs/abi/OidcRecoveryValidator.js.map +1 -0
- package/dist/_cjs/abi/WebAuthModule.js +301 -0
- package/dist/_cjs/abi/WebAuthModule.js.map +1 -0
- package/dist/_cjs/abi/index.js +9 -1
- package/dist/_cjs/abi/index.js.map +1 -1
- package/dist/_cjs/client/oidc/account.js +43 -0
- package/dist/_cjs/client/oidc/account.js.map +1 -0
- package/dist/_cjs/client/oidc/actions/addNewPasskeyViaOidc.js +28 -0
- package/dist/_cjs/client/oidc/actions/addNewPasskeyViaOidc.js.map +1 -0
- package/dist/_cjs/client/oidc/actions/index.js +12 -0
- package/dist/_cjs/client/oidc/actions/index.js.map +1 -0
- package/dist/_cjs/client/oidc/client.js +46 -0
- package/dist/_cjs/client/oidc/client.js.map +1 -0
- package/dist/_cjs/client/oidc/decorators/actions.js +3 -0
- package/dist/_cjs/client/oidc/decorators/actions.js.map +1 -0
- package/dist/_cjs/client/oidc/index.js +20 -0
- package/dist/_cjs/client/oidc/index.js.map +1 -0
- package/dist/_cjs/client/oidc/serialize.js +3 -0
- package/dist/_cjs/client/oidc/serialize.js.map +1 -0
- package/dist/_cjs/client/passkey/actions/account.js +5 -1
- package/dist/_cjs/client/passkey/actions/account.js.map +1 -1
- package/dist/_cjs/client/passkey/decorators/passkey.js +12 -0
- package/dist/_cjs/client/passkey/decorators/passkey.js.map +1 -1
- package/dist/_cjs/client/recovery/actions/oidc.js +55 -0
- package/dist/_cjs/client/recovery/actions/oidc.js.map +1 -0
- package/dist/_cjs/client-auth-server/Signer.js +4 -2
- package/dist/_cjs/client-auth-server/Signer.js.map +1 -1
- package/dist/_cjs/client-auth-server/WalletProvider.js +3 -2
- package/dist/_cjs/client-auth-server/WalletProvider.js.map +1 -1
- package/dist/_cjs/communicator/PopupCommunicator.js +30 -5
- package/dist/_cjs/communicator/PopupCommunicator.js.map +1 -1
- package/dist/_cjs/connector/index.js +1 -0
- package/dist/_cjs/connector/index.js.map +1 -1
- package/dist/_esm/abi/GuardianRecoveryModule.js +764 -0
- package/dist/_esm/abi/GuardianRecoveryModule.js.map +1 -0
- package/dist/_esm/abi/OidcKeyRegistry.js +489 -0
- package/dist/_esm/abi/OidcKeyRegistry.js.map +1 -0
- package/dist/_esm/abi/OidcRecoveryValidator.js +525 -0
- package/dist/_esm/abi/OidcRecoveryValidator.js.map +1 -0
- package/dist/_esm/abi/WebAuthModule.js +298 -0
- package/dist/_esm/abi/WebAuthModule.js.map +1 -0
- package/dist/_esm/abi/index.js +4 -0
- package/dist/_esm/abi/index.js.map +1 -1
- package/dist/_esm/client/oidc/account.js +40 -0
- package/dist/_esm/client/oidc/account.js.map +1 -0
- package/dist/_esm/client/oidc/actions/addNewPasskeyViaOidc.js +26 -0
- package/dist/_esm/client/oidc/actions/addNewPasskeyViaOidc.js.map +1 -0
- package/dist/_esm/client/oidc/actions/index.js +9 -0
- package/dist/_esm/client/oidc/actions/index.js.map +1 -0
- package/dist/_esm/client/oidc/client.js +41 -0
- package/dist/_esm/client/oidc/client.js.map +1 -0
- package/dist/_esm/client/oidc/decorators/actions.js +2 -0
- package/dist/_esm/client/oidc/decorators/actions.js.map +1 -0
- package/dist/_esm/client/oidc/index.js +4 -0
- package/dist/_esm/client/oidc/index.js.map +1 -0
- package/dist/_esm/client/oidc/serialize.js +2 -0
- package/dist/_esm/client/oidc/serialize.js.map +1 -0
- package/dist/_esm/client/passkey/actions/account.js +5 -1
- package/dist/_esm/client/passkey/actions/account.js.map +1 -1
- package/dist/_esm/client/passkey/decorators/passkey.js +12 -0
- package/dist/_esm/client/passkey/decorators/passkey.js.map +1 -1
- package/dist/_esm/client/recovery/actions/oidc.js +52 -0
- package/dist/_esm/client/recovery/actions/oidc.js.map +1 -0
- package/dist/_esm/client-auth-server/Signer.js +4 -2
- package/dist/_esm/client-auth-server/Signer.js.map +1 -1
- package/dist/_esm/client-auth-server/WalletProvider.js +3 -2
- package/dist/_esm/client-auth-server/WalletProvider.js.map +1 -1
- package/dist/_esm/communicator/PopupCommunicator.js +30 -5
- package/dist/_esm/communicator/PopupCommunicator.js.map +1 -1
- package/dist/_esm/connector/index.js +1 -0
- package/dist/_esm/connector/index.js.map +1 -1
- package/dist/_types/abi/GuardianRecoveryModule.d.ts +590 -0
- package/dist/_types/abi/GuardianRecoveryModule.d.ts.map +1 -0
- package/dist/_types/abi/OidcKeyRegistry.d.ts +375 -0
- package/dist/_types/abi/OidcKeyRegistry.d.ts.map +1 -0
- package/dist/_types/abi/OidcRecoveryValidator.d.ts +404 -0
- package/dist/_types/abi/OidcRecoveryValidator.d.ts.map +1 -0
- package/dist/_types/abi/WebAuthModule.d.ts +228 -0
- package/dist/_types/abi/WebAuthModule.d.ts.map +1 -0
- package/dist/_types/abi/index.d.ts +4 -0
- package/dist/_types/abi/index.d.ts.map +1 -1
- package/dist/_types/client/oidc/account.d.ts +13 -0
- package/dist/_types/client/oidc/account.d.ts.map +1 -0
- package/dist/_types/client/oidc/actions/addNewPasskeyViaOidc.d.ts +12 -0
- package/dist/_types/client/oidc/actions/addNewPasskeyViaOidc.d.ts.map +1 -0
- package/dist/_types/client/oidc/actions/index.d.ts +5 -0
- package/dist/_types/client/oidc/actions/index.d.ts.map +1 -0
- package/dist/_types/client/oidc/client.d.ts +24 -0
- package/dist/_types/client/oidc/client.d.ts.map +1 -0
- package/dist/_types/client/oidc/decorators/actions.d.ts +5 -0
- package/dist/_types/client/oidc/decorators/actions.d.ts.map +1 -0
- package/dist/_types/client/oidc/index.d.ts +4 -0
- package/dist/_types/client/oidc/index.d.ts.map +1 -0
- package/dist/_types/client/oidc/serialize.d.ts +10 -0
- package/dist/_types/client/oidc/serialize.d.ts.map +1 -0
- package/dist/_types/client/passkey/actions/account.d.ts +1 -0
- package/dist/_types/client/passkey/actions/account.d.ts.map +1 -1
- package/dist/_types/client/passkey/client.d.ts +2 -0
- package/dist/_types/client/passkey/client.d.ts.map +1 -1
- package/dist/_types/client/passkey/decorators/passkey.d.ts +4 -1
- package/dist/_types/client/passkey/decorators/passkey.d.ts.map +1 -1
- package/dist/_types/client/recovery/actions/oidc.d.ts +24 -0
- package/dist/_types/client/recovery/actions/oidc.d.ts.map +1 -0
- package/dist/_types/client-auth-server/Signer.d.ts +3 -1
- package/dist/_types/client-auth-server/Signer.d.ts.map +1 -1
- package/dist/_types/client-auth-server/WalletProvider.d.ts +5 -1
- package/dist/_types/client-auth-server/WalletProvider.d.ts.map +1 -1
- package/dist/_types/communicator/PopupCommunicator.d.ts +13 -1
- package/dist/_types/communicator/PopupCommunicator.d.ts.map +1 -1
- package/dist/_types/connector/index.d.ts +2 -0
- package/dist/_types/connector/index.d.ts.map +1 -1
- package/dist/_types/utils/storage.d.ts +1 -1
- package/dist/_types/utils/storage.d.ts.map +1 -1
- package/package.json +8 -2
- package/project.json +3 -0
- package/src/abi/GuardianRecoveryModule.ts +763 -0
- package/src/abi/OidcKeyRegistry.ts +488 -0
- package/src/abi/OidcRecoveryValidator.ts +524 -0
- package/src/abi/WebAuthModule.ts +297 -0
- package/src/abi/index.ts +4 -0
- package/src/client/oidc/account.ts +65 -0
- package/src/client/oidc/actions/addNewPasskeyViaOidc.ts +54 -0
- package/src/client/oidc/actions/index.ts +16 -0
- package/src/client/oidc/client.ts +122 -0
- package/src/client/oidc/decorators/actions.ts +5 -0
- package/src/client/oidc/index.ts +3 -0
- package/src/client/oidc/serialize.ts +10 -0
- package/src/client/passkey/actions/account.ts +7 -1
- package/src/client/passkey/client.ts +2 -0
- package/src/client/passkey/decorators/passkey.ts +20 -1
- package/src/client/recovery/actions/oidc.ts +103 -0
- package/src/client-auth-server/Signer.ts +6 -3
- package/src/client-auth-server/WalletProvider.ts +7 -2
- package/src/communicator/PopupCommunicator.ts +24 -5
- package/src/connector/index.ts +3 -0
- package/src/utils/storage.ts +1 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Account,
|
|
3
|
+
type Address,
|
|
4
|
+
type Chain,
|
|
5
|
+
type Client,
|
|
6
|
+
encodeFunctionData,
|
|
7
|
+
type Hash,
|
|
8
|
+
type Hex,
|
|
9
|
+
type Prettify,
|
|
10
|
+
type TransactionReceipt,
|
|
11
|
+
type Transport,
|
|
12
|
+
} from "viem";
|
|
13
|
+
import { waitForTransactionReceipt } from "viem/actions";
|
|
14
|
+
import {
|
|
15
|
+
getGeneralPaymasterInput,
|
|
16
|
+
sendTransaction,
|
|
17
|
+
} from "viem/zksync";
|
|
18
|
+
|
|
19
|
+
import { OidcRecoveryValidatorAbi } from "../../../abi/index.js";
|
|
20
|
+
import { noThrow } from "../../../utils/helpers.js";
|
|
21
|
+
|
|
22
|
+
export type AddOidcAccountArgs = {
|
|
23
|
+
contracts: {
|
|
24
|
+
recoveryOidc: Address; // oidc recovery module
|
|
25
|
+
};
|
|
26
|
+
paymaster?: {
|
|
27
|
+
address: Address;
|
|
28
|
+
paymasterInput?: Hex;
|
|
29
|
+
};
|
|
30
|
+
oidcDigest: Hex;
|
|
31
|
+
iss: string;
|
|
32
|
+
onTransactionSent?: (hash: Hash) => void;
|
|
33
|
+
};
|
|
34
|
+
export type AddOidcAccountReturnType = {
|
|
35
|
+
transactionReceipt: TransactionReceipt;
|
|
36
|
+
};
|
|
37
|
+
export const addOidcAccount = async <
|
|
38
|
+
transport extends Transport,
|
|
39
|
+
chain extends Chain,
|
|
40
|
+
account extends Account,
|
|
41
|
+
>(client: Client<transport, chain, account>, args: Prettify<AddOidcAccountArgs>): Promise<Prettify<AddOidcAccountReturnType>> => {
|
|
42
|
+
const callData = encodeFunctionData({
|
|
43
|
+
abi: OidcRecoveryValidatorAbi,
|
|
44
|
+
functionName: "addOidcAccount",
|
|
45
|
+
args: [args.oidcDigest, args.iss],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const sendTransactionArgs = {
|
|
49
|
+
account: client.account,
|
|
50
|
+
to: args.contracts.recoveryOidc,
|
|
51
|
+
paymaster: args.paymaster?.address,
|
|
52
|
+
paymasterInput: args.paymaster?.address ? (args.paymaster?.paymasterInput || getGeneralPaymasterInput({ innerInput: "0x" })) : undefined,
|
|
53
|
+
data: callData,
|
|
54
|
+
gas: 10_000_000n, // TODO: Remove when gas estimation is fixed
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
} as any;
|
|
57
|
+
|
|
58
|
+
const transactionHash = await sendTransaction(client, sendTransactionArgs);
|
|
59
|
+
if (args.onTransactionSent) {
|
|
60
|
+
noThrow(() => args.onTransactionSent?.(transactionHash));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const transactionReceipt = await waitForTransactionReceipt(client, { hash: transactionHash });
|
|
64
|
+
if (transactionReceipt.status !== "success") throw new Error("addOidcAccount transaction reverted");
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
transactionReceipt,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type RemoveOidcAccountArgs = {
|
|
72
|
+
contracts: {
|
|
73
|
+
recoveryOidc: Address; // oidc recovery module
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const removeOidcAccount = async <
|
|
78
|
+
transport extends Transport,
|
|
79
|
+
chain extends Chain,
|
|
80
|
+
account extends Account,
|
|
81
|
+
>(client: Client<transport, chain, account>, args: Prettify<RemoveOidcAccountArgs>): Promise<TransactionReceipt> => {
|
|
82
|
+
const callData = encodeFunctionData({
|
|
83
|
+
abi: OidcRecoveryValidatorAbi,
|
|
84
|
+
functionName: "deleteOidcAccount",
|
|
85
|
+
args: [],
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const sendTransactionArgs = {
|
|
89
|
+
account: client.account,
|
|
90
|
+
to: args.contracts.recoveryOidc,
|
|
91
|
+
data: callData,
|
|
92
|
+
gas: 10_000_000n, // TODO: Remove when gas estimation is fixed
|
|
93
|
+
type: "eip712",
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
+
} as any;
|
|
96
|
+
|
|
97
|
+
const transactionHash = await sendTransaction(client, sendTransactionArgs);
|
|
98
|
+
|
|
99
|
+
const transactionReceipt = await waitForTransactionReceipt(client, { hash: transactionHash });
|
|
100
|
+
if (transactionReceipt.status !== "success") throw new Error("removeOidcAccount transaction reverted");
|
|
101
|
+
|
|
102
|
+
return transactionReceipt;
|
|
103
|
+
};
|
|
@@ -5,7 +5,7 @@ import { createZksyncSessionClient, type ZksyncSsoSessionClient } from "../clien
|
|
|
5
5
|
import type { Communicator } from "../communicator/index.js";
|
|
6
6
|
import { type CustomPaymasterHandler, getTransactionWithPaymasterData } from "../paymaster/index.js";
|
|
7
7
|
import type { SessionStateEvent } from "../utils/session.js";
|
|
8
|
-
import { StorageItem } from "../utils/storage.js";
|
|
8
|
+
import { StorageItem, type StorageLike } from "../utils/storage.js";
|
|
9
9
|
import type { AppMetadata, RequestArguments } from "./interface.js";
|
|
10
10
|
import type { AuthServerRpcSchema, ExtractParams, ExtractReturnType, Method, RPCRequestMessage, RPCResponseMessage, RpcSchema } from "./rpc.js";
|
|
11
11
|
import type { SessionPreferences } from "./session/index.js";
|
|
@@ -44,6 +44,7 @@ type SignerConstructorParams = {
|
|
|
44
44
|
paymasterHandler?: CustomPaymasterHandler;
|
|
45
45
|
onSessionStateChange?: (event: { address: Address; chainId: number; state: SessionStateEvent }) => void;
|
|
46
46
|
skipPreTransactionStateValidation?: boolean; // Useful if you want to send session transactions really fast
|
|
47
|
+
storage?: StorageLike;
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
type ChainsInfo = ExtractReturnType<"eth_requestAccounts", AuthServerRpcSchema>["chainsInfo"];
|
|
@@ -60,10 +61,10 @@ export class Signer implements SignerInterface {
|
|
|
60
61
|
private readonly skipPreTransactionStateValidation?: boolean;
|
|
61
62
|
|
|
62
63
|
private _account: StorageItem<Account | null>;
|
|
63
|
-
private _chainsInfo
|
|
64
|
+
private _chainsInfo: StorageItem<ChainsInfo>;
|
|
64
65
|
private client: { instance: ZksyncSsoSessionClient; type: "session" } | { instance: WalletClient; type: "auth-server" } | undefined;
|
|
65
66
|
|
|
66
|
-
constructor({ metadata, communicator, updateListener, session, chains, transports, paymasterHandler, onSessionStateChange, skipPreTransactionStateValidation }: SignerConstructorParams) {
|
|
67
|
+
constructor({ metadata, communicator, updateListener, session, chains, transports, paymasterHandler, onSessionStateChange, skipPreTransactionStateValidation, storage }: SignerConstructorParams) {
|
|
67
68
|
if (!chains.length) throw new Error("At least one chain must be included in the config");
|
|
68
69
|
|
|
69
70
|
this.getMetadata = metadata;
|
|
@@ -76,6 +77,7 @@ export class Signer implements SignerInterface {
|
|
|
76
77
|
this.onSessionStateChange = onSessionStateChange;
|
|
77
78
|
this.skipPreTransactionStateValidation = skipPreTransactionStateValidation;
|
|
78
79
|
|
|
80
|
+
this._chainsInfo = new StorageItem<ChainsInfo>(StorageItem.scopedStorageKey("chainsInfo"), [], { storage });
|
|
79
81
|
this._account = new StorageItem<Account | null>(StorageItem.scopedStorageKey("account"), null, {
|
|
80
82
|
onChange: (newValue) => {
|
|
81
83
|
if (newValue) {
|
|
@@ -86,6 +88,7 @@ export class Signer implements SignerInterface {
|
|
|
86
88
|
this.updateListener.onAccountsUpdate([]);
|
|
87
89
|
}
|
|
88
90
|
},
|
|
91
|
+
storage,
|
|
89
92
|
});
|
|
90
93
|
try {
|
|
91
94
|
if (this.account) this.createWalletClient();
|
|
@@ -2,11 +2,13 @@ import { EventEmitter } from "eventemitter3";
|
|
|
2
2
|
import type { Address, Chain, Transport } from "viem";
|
|
3
3
|
import { toHex } from "viem";
|
|
4
4
|
|
|
5
|
+
import type { Communicator } from "../communicator/index.js";
|
|
5
6
|
import { PopupCommunicator } from "../communicator/PopupCommunicator.js";
|
|
6
7
|
import { serializeError, standardErrors } from "../errors/index.js";
|
|
7
8
|
import type { CustomPaymasterHandler } from "../paymaster/index.js";
|
|
8
9
|
import { getFavicon, getWebsiteName } from "../utils/helpers.js";
|
|
9
10
|
import type { SessionStateEvent } from "../utils/session.js";
|
|
11
|
+
import type { StorageLike } from "../utils/storage.js";
|
|
10
12
|
import type {
|
|
11
13
|
AppMetadata,
|
|
12
14
|
ProviderInterface,
|
|
@@ -27,15 +29,17 @@ export type WalletProviderConstructorOptions = {
|
|
|
27
29
|
paymasterHandler?: CustomPaymasterHandler;
|
|
28
30
|
onSessionStateChange?: (state: { address: Address; chainId: number; state: SessionStateEvent }) => void;
|
|
29
31
|
skipPreTransactionStateValidation?: boolean; // Useful if you want to send session transactions really fast
|
|
32
|
+
customCommunicator?: Communicator;
|
|
33
|
+
storage?: StorageLike;
|
|
30
34
|
};
|
|
31
35
|
|
|
32
36
|
export class WalletProvider extends EventEmitter implements ProviderInterface {
|
|
33
37
|
readonly isZksyncSso = true;
|
|
34
38
|
private signer: Signer;
|
|
35
39
|
|
|
36
|
-
constructor({ metadata, chains, transports, session, authServerUrl, paymasterHandler, onSessionStateChange, skipPreTransactionStateValidation }: WalletProviderConstructorOptions) {
|
|
40
|
+
constructor({ metadata, chains, transports, session, authServerUrl, paymasterHandler, onSessionStateChange, skipPreTransactionStateValidation, customCommunicator, storage }: WalletProviderConstructorOptions) {
|
|
37
41
|
super();
|
|
38
|
-
const communicator = new PopupCommunicator(authServerUrl || DEFAULT_AUTH_SERVER_URL);
|
|
42
|
+
const communicator = customCommunicator ?? new PopupCommunicator(authServerUrl || DEFAULT_AUTH_SERVER_URL);
|
|
39
43
|
this.signer = new Signer({
|
|
40
44
|
metadata: () => ({
|
|
41
45
|
name: metadata?.name || getWebsiteName() || "Unknown DApp",
|
|
@@ -50,6 +54,7 @@ export class WalletProvider extends EventEmitter implements ProviderInterface {
|
|
|
50
54
|
paymasterHandler,
|
|
51
55
|
onSessionStateChange,
|
|
52
56
|
skipPreTransactionStateValidation,
|
|
57
|
+
storage,
|
|
53
58
|
});
|
|
54
59
|
}
|
|
55
60
|
|
|
@@ -4,14 +4,29 @@ import type { Communicator, Message } from "./index.js";
|
|
|
4
4
|
export interface PopupConfigMessage extends Message {
|
|
5
5
|
event: "PopupLoaded" | "PopupUnload";
|
|
6
6
|
}
|
|
7
|
+
type PositionCalculator = (width: number, height: number) => { left: number; top: number };
|
|
7
8
|
|
|
8
9
|
export class PopupCommunicator implements Communicator {
|
|
9
10
|
private readonly url: URL;
|
|
10
11
|
private popup: Window | null = null;
|
|
11
12
|
private listeners = new Map<(_: MessageEvent) => void, { reject: (_: Error) => void }>();
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
private readonly width: number;
|
|
15
|
+
private readonly height: number;
|
|
16
|
+
private readonly calculatePosition?: PositionCalculator;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
url: string,
|
|
20
|
+
options?: {
|
|
21
|
+
width?: number;
|
|
22
|
+
height?: number;
|
|
23
|
+
calculatePosition?: PositionCalculator;
|
|
24
|
+
},
|
|
25
|
+
) {
|
|
14
26
|
this.url = new URL(url);
|
|
27
|
+
this.width = options?.width ?? 420;
|
|
28
|
+
this.height = options?.height ?? 600;
|
|
29
|
+
this.calculatePosition = options?.calculatePosition;
|
|
15
30
|
}
|
|
16
31
|
|
|
17
32
|
postMessage = async (message: Message) => {
|
|
@@ -64,14 +79,18 @@ export class PopupCommunicator implements Communicator {
|
|
|
64
79
|
};
|
|
65
80
|
|
|
66
81
|
openPopup = () => {
|
|
67
|
-
const width =
|
|
68
|
-
const height =
|
|
82
|
+
const width = this.width;
|
|
83
|
+
const height = this.height;
|
|
69
84
|
|
|
70
85
|
const url = new URL(this.url.toString());
|
|
71
86
|
url.searchParams.set("origin", window.location.origin);
|
|
72
87
|
|
|
73
|
-
const left
|
|
74
|
-
|
|
88
|
+
const { left, top } = this.calculatePosition
|
|
89
|
+
? this.calculatePosition(width, height)
|
|
90
|
+
: {
|
|
91
|
+
left: (window.innerWidth - width) / 2 + window.screenX,
|
|
92
|
+
top: (window.innerHeight - height) / 2 + window.screenY,
|
|
93
|
+
};
|
|
75
94
|
|
|
76
95
|
const popup = window.open(
|
|
77
96
|
url,
|
package/src/connector/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "viem";
|
|
18
18
|
|
|
19
19
|
import type { ZksyncSsoSessionClient } from "../client/index.js";
|
|
20
|
+
import type { Communicator } from "../communicator/interface.js";
|
|
20
21
|
import { EthereumProviderError } from "../errors/errors.js";
|
|
21
22
|
import { type AppMetadata, type ProviderInterface, type SessionPreferences, WalletProvider } from "../index.js";
|
|
22
23
|
import type { CustomPaymasterHandler } from "../paymaster/index.js";
|
|
@@ -27,6 +28,7 @@ export type ZksyncSsoConnectorOptions = {
|
|
|
27
28
|
session?: SessionPreferences | (() => SessionPreferences | Promise<SessionPreferences>);
|
|
28
29
|
authServerUrl?: string;
|
|
29
30
|
paymasterHandler?: CustomPaymasterHandler;
|
|
31
|
+
communicator?: Communicator;
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export const zksyncSsoConnector = (parameters: ZksyncSsoConnectorOptions) => {
|
|
@@ -144,6 +146,7 @@ export const zksyncSsoConnector = (parameters: ZksyncSsoConnectorOptions) => {
|
|
|
144
146
|
transports: config.transports,
|
|
145
147
|
chains: config.chains,
|
|
146
148
|
paymasterHandler: parameters.paymasterHandler,
|
|
149
|
+
customCommunicator: parameters.communicator,
|
|
147
150
|
});
|
|
148
151
|
}
|
|
149
152
|
return walletProvider;
|
package/src/utils/storage.ts
CHANGED