-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TW-1229 Add another way for Google authorization
- Loading branch information
1 parent
dd24892
commit 961fc22
Showing
9 changed files
with
114 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { TempleMessageType } from 'lib/temple/types'; | ||
|
||
import { getIntercom } from './intercom-client'; | ||
|
||
enum AuthEventType { | ||
AuthRequest = 'authrequest', | ||
AuthAck = 'authack' | ||
} | ||
|
||
window.addEventListener('message', async (e: MessageEvent) => { | ||
try { | ||
if (e.data?.type === AuthEventType.AuthRequest) { | ||
await getIntercom().request({ | ||
type: TempleMessageType.GoogleAuthTokenReceivedRequest, | ||
authToken: e.data.content | ||
}); | ||
window.postMessage({ type: AuthEventType.AuthAck }, '*'); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { IntercomClient } from 'lib/intercom/client'; | ||
|
||
let intercom: IntercomClient; | ||
export function getIntercom() { | ||
if (!intercom) { | ||
intercom = new IntercomClient(); | ||
} | ||
return intercom; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters