Skip to content

Commit 344746d

Browse files
committed
feat: updated event emits
1 parent 82e8a97 commit 344746d

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

packages/no-modal/src/base/connector/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export const CONNECTOR_STATUS = {
66
DISCONNECTING: "disconnecting",
77
DISCONNECTED: "disconnected",
88
ERRORED: "errored",
9+
AUTHORIZED: "authorized",
10+
AUTHORIZING: "authorizing",
911
} as const;
1012

1113
export const CONNECTOR_EVENTS = {
@@ -15,8 +17,6 @@ export const CONNECTOR_EVENTS = {
1517
CONNECTORS_UPDATED: "connectors_updated",
1618
MFA_ENABLED: "mfa_enabled",
1719
REHYDRATION_ERROR: "rehydration_error",
18-
AUTHORIZED: "authorized",
19-
AUTHORIZING: "authorizing",
2020
} as const;
2121

2222
export const CONNECTOR_CATEGORY = {

packages/no-modal/src/base/connector/interfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export type ConnectorEvents = {
118118
[CONNECTOR_EVENTS.CONNECTED]: (data: CONNECTED_EVENT_DATA) => void;
119119
[CONNECTOR_EVENTS.DISCONNECTED]: () => void;
120120
[CONNECTOR_EVENTS.CONNECTING]: (data: { connector: string }) => void;
121+
[CONNECTOR_EVENTS.AUTHORIZING]: (data: { connector: string }) => void;
122+
[CONNECTOR_EVENTS.AUTHORIZED]: (data: { connector: string }) => void;
121123
[CONNECTOR_EVENTS.ERRORED]: (error: Web3AuthError) => void;
122124
[CONNECTOR_EVENTS.REHYDRATION_ERROR]: (error: Web3AuthError) => void;
123125
[CONNECTOR_EVENTS.CONNECTOR_DATA_UPDATED]: (data: IConnectorDataEvent) => void;

packages/no-modal/src/connectors/auth-connector/authConnector.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,11 @@ class AuthConnector extends BaseConnector<AuthLoginParams> {
401401
// No need to get the identity token for auth connector as it is already handled
402402
let identityTokenInfo: IdentityTokenInfo | undefined;
403403
if (params.getIdentityToken) {
404+
this.status = CONNECTOR_STATUS.AUTHORIZING;
405+
this.emit(CONNECTOR_EVENTS.AUTHORIZING, { connector: WALLET_CONNECTORS.AUTH });
404406
identityTokenInfo = await this.getIdentityToken();
407+
this.status = CONNECTOR_STATUS.AUTHORIZED;
408+
this.emit(CONNECTOR_EVENTS.AUTHORIZED, { connector: WALLET_CONNECTORS.AUTH });
405409
}
406410
this.status = CONNECTOR_STATUS.CONNECTED;
407411
this.emit(CONNECTOR_EVENTS.CONNECTED, {

packages/no-modal/src/noModal.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ export class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> imp
302302
throw WalletInitializationError.notFound(`Please add wallet connector for ${connectorName} wallet, before connecting`);
303303

304304
const initialChain = this.getInitialChainIdForConnector(connector);
305-
const finalLoginParams = { ...loginParams, chainId: initialChain.chainId };
305+
const finalLoginParams = {
306+
...loginParams,
307+
chainId: initialChain.chainId,
308+
getIdentityToken: this.coreOptions.initialAuthenticationMode === "connect-and-sign",
309+
};
306310

307311
// track connection started event
308312
const startTime = Date.now();

0 commit comments

Comments
 (0)