Skip to content

Commit

Permalink
Merge pull request #1296 from GW2Treasures/feature/fedcm-types
Browse files Browse the repository at this point in the history
Add some FedCM types
  • Loading branch information
darthmaim authored Jan 9, 2025
2 parents 8e3140b + 278da7c commit 1472405
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/web/app/(fed-cm)/fed-cm/login/SetLoginStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { useEffect, type FC } from 'react';
export const SetLoginStatus: FC = () => {
useEffect(() => {
if('login' in navigator) {
(navigator.login as { setStatus(status: string): void }).setStatus('logged-in');
navigator.login.setStatus('logged-in');
}

if('IdentityProvider' in window) {
(window.IdentityProvider as { close(): void }).close();
window.IdentityProvider.close();
}
});

Expand Down
23 changes: 23 additions & 0 deletions apps/web/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,26 @@ declare module '*.svg?svgr' {
const SVG: React.VFC<React.SVGProps<SVGSVGElement>>;
export default SVG;
}

interface Navigator {
/** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/login) */
login: NavigatorLogin
}

/** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLoginn) */
interface NavigatorLogin {
/** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLogin/setStatus) */
setStatus(status: 'logged-in' | 'logged-out'): Promise<undefined>
}

interface Window {
/** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/IdentityProvider) */
IdentityProvider: IdentityProvider
}

/** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/IdentityProvider) */
interface IdentityProvider {
/** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/IdentityProvider/close_static) */
close(): undefined
}

0 comments on commit 1472405

Please sign in to comment.