Skip to content

Commit

Permalink
Merge pull request #846 from magiclabs/PDEEXP-2153-farcaster-polling-…
Browse files Browse the repository at this point in the history
…blocks-all-other-requests-to-magic

add cancel event to farcaster
  • Loading branch information
Ethella authored Dec 25, 2024
2 parents 9c1662c + d88ef10 commit 00b3f6f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/@magic-ext/farcaster/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Extension } from '@magic-sdk/commons';
import {Extension, FarcasterLoginEventEmit} from '@magic-sdk/commons';
import { FarcasterPayloadMethod } from './types';
import { isMainFrame, isMobile } from './utils';

Expand Down Expand Up @@ -67,6 +67,8 @@ type FarcasterLoginEventHandlers = {
[FarcasterLoginEventOnReceived.OpenChannel]: (channel: CreateChannelAPIResponse) => void;
[FarcasterLoginEventOnReceived.Success]: (data: StatusAPIResponse) => void;
[FarcasterLoginEventOnReceived.Failed]: (error: AuthClientError) => void;

[FarcasterLoginEventEmit.Cancel]: () => void;
};

export class FarcasterExtension extends Extension.Internal<'farcaster'> {
Expand All @@ -92,6 +94,10 @@ export class FarcasterExtension extends Extension.Internal<'farcaster'> {
}
});

handle.on(FarcasterLoginEventEmit.Cancel, () => {
this.createIntermediaryEvent(FarcasterLoginEventEmit.Cancel, payload.id as string)();
});

return handle;
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@magic-sdk/types/src/modules/auth-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export enum AuthEventOnReceived {
}

export enum FarcasterLoginEventEmit {
SuccessSignIn = 'Farcaster/success_sign_in',
Cancel = 'Farcaster/cancel',
}

export enum EnableMFAEventOnReceived {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
AuthEventOnReceived,
DeviceVerificationEventEmit,
DeviceVerificationEventOnReceived,
FarcasterLoginEventEmit,
LoginWithEmailOTPEventEmit,
LoginWithSmsOTPEventEmit,
LoginWithEmailOTPEventOnReceived,
Expand All @@ -17,6 +16,7 @@ import {
EnableMFAEventOnReceived,
DisableMFAEventOnReceived,
DisableMFAEventEmit,
FarcasterLoginEventEmit,
} from './auth-types';
import { NftCheckoutIntermediaryEvents } from './nft-types';

Expand Down

0 comments on commit 00b3f6f

Please sign in to comment.