openrtc 0.1.0 → 0.1.2

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.
Files changed (130) hide show
  1. package/README.md +1 -2
  2. package/dist/{core/types.d.ts → DelegatingRuntimeAdapter-CW8d78dZ.d.ts} +275 -95
  3. package/dist/IpcRuntimeAdapter-CT-W0Mtp.d.ts +24 -0
  4. package/dist/auth/index.d.ts +75 -1
  5. package/dist/auth/index.js +1 -1
  6. package/dist/auth/internal.d.ts +3 -1
  7. package/dist/auth/internal.js +1 -1
  8. package/dist/chunk-4MH42GUI.js +2 -0
  9. package/dist/chunk-CQAKCS2S.js +4 -0
  10. package/dist/chunk-D54VGRRH.js +1 -0
  11. package/dist/chunk-DIQYFAGL.js +2 -0
  12. package/dist/chunk-PZ25OCVG.js +2 -0
  13. package/dist/chunk-UVASANPG.js +1 -0
  14. package/dist/factories-0TxDPMeu.d.ts +1041 -0
  15. package/dist/index.d.ts +160 -3
  16. package/dist/index.js +1 -3
  17. package/dist/openrtc_bg.wasm +0 -0
  18. package/dist/runtime/WasmRuntimeAdapter.d.ts +5 -3
  19. package/dist/runtime/WasmRuntimeAdapter.js +1 -11
  20. package/dist/runtime/index.d.ts +796 -6
  21. package/dist/runtime/index.js +1 -5
  22. package/dist/runtime/tauri.d.ts +12 -8
  23. package/dist/runtime/tauri.js +1 -22
  24. package/package.json +11 -7
  25. package/wasm/openrtc.d.ts +61 -25
  26. package/wasm/openrtc.js +417 -259
  27. package/wasm/openrtc_bg.wasm +0 -0
  28. package/wasm/openrtc_bg.wasm.d.ts +27 -24
  29. package/wasm/package.json +1 -1
  30. package/dist/OpenRTC.d.ts +0 -71
  31. package/dist/OpenRTC.js +0 -130
  32. package/dist/api/MediaTransport.d.ts +0 -7
  33. package/dist/api/MediaTransport.js +0 -262
  34. package/dist/api/PlutoPeerConnection.d.ts +0 -50
  35. package/dist/api/PlutoPeerConnection.js +0 -434
  36. package/dist/api/PlutoWebSocket.d.ts +0 -24
  37. package/dist/api/PlutoWebSocket.js +0 -113
  38. package/dist/api/PlutoWebTransport.d.ts +0 -29
  39. package/dist/api/PlutoWebTransport.js +0 -105
  40. package/dist/auth/host.d.ts +0 -73
  41. package/dist/auth/host.js +0 -513
  42. package/dist/compat/index.d.ts +0 -20
  43. package/dist/compat/index.js +0 -20
  44. package/dist/core/Client.d.ts +0 -352
  45. package/dist/core/Client.js +0 -3689
  46. package/dist/core/Connection.d.ts +0 -67
  47. package/dist/core/Connection.js +0 -404
  48. package/dist/core/IEngineBridge.d.ts +0 -18
  49. package/dist/core/IEngineBridge.js +0 -1
  50. package/dist/core/ISignalingTransport.d.ts +0 -13
  51. package/dist/core/ISignalingTransport.js +0 -1
  52. package/dist/core/PeerLifecycleManager.d.ts +0 -43
  53. package/dist/core/PeerLifecycleManager.js +0 -330
  54. package/dist/core/PeerProjectionStore.d.ts +0 -43
  55. package/dist/core/PeerProjectionStore.js +0 -327
  56. package/dist/core/PlutoRTC.d.ts +0 -13
  57. package/dist/core/PlutoRTC.js +0 -26
  58. package/dist/core/Room.d.ts +0 -47
  59. package/dist/core/Room.js +0 -376
  60. package/dist/core/Signaling.d.ts +0 -39
  61. package/dist/core/Signaling.js +0 -147
  62. package/dist/core/bridges/BridgeCodecs.d.ts +0 -19
  63. package/dist/core/bridges/BridgeCodecs.js +0 -317
  64. package/dist/core/bridges/BrowserFirestoreRooms.d.ts +0 -36
  65. package/dist/core/bridges/BrowserFirestoreRooms.js +0 -169
  66. package/dist/core/bridges/BrowserFirestoreSignaling.d.ts +0 -111
  67. package/dist/core/bridges/BrowserFirestoreSignaling.js +0 -1010
  68. package/dist/core/bridges/NativeIpcBridge.d.ts +0 -156
  69. package/dist/core/bridges/NativeIpcBridge.js +0 -1472
  70. package/dist/core/bridges/RtdbPresence.d.ts +0 -122
  71. package/dist/core/bridges/RtdbPresence.js +0 -201
  72. package/dist/core/bridges/TauriBridge.d.ts +0 -8
  73. package/dist/core/bridges/TauriBridge.js +0 -7
  74. package/dist/core/bridges/WasmBridge.d.ts +0 -233
  75. package/dist/core/bridges/WasmBridge.js +0 -1811
  76. package/dist/core/config.d.ts +0 -31
  77. package/dist/core/config.js +0 -138
  78. package/dist/core/transports/ITransport.d.ts +0 -12
  79. package/dist/core/transports/ITransport.js +0 -1
  80. package/dist/core/transports/LocalDaemonBridge.d.ts +0 -41
  81. package/dist/core/transports/LocalDaemonBridge.js +0 -227
  82. package/dist/core/transports/TauriSignaling.d.ts +0 -28
  83. package/dist/core/transports/TauriSignaling.js +0 -373
  84. package/dist/core/transports/TransportFactory.d.ts +0 -9
  85. package/dist/core/transports/TransportFactory.js +0 -59
  86. package/dist/core/transports/WasmSignaling.d.ts +0 -78
  87. package/dist/core/transports/WasmSignaling.js +0 -522
  88. package/dist/core/transports/WebRTCTransport.d.ts +0 -23
  89. package/dist/core/transports/WebRTCTransport.js +0 -132
  90. package/dist/core/trust.d.ts +0 -23
  91. package/dist/core/trust.js +0 -99
  92. package/dist/core/types.js +0 -19
  93. package/dist/moq/MoQMediaTransport.d.ts +0 -6
  94. package/dist/moq/MoQMediaTransport.js +0 -106
  95. package/dist/moq/MoQPublisher.d.ts +0 -22
  96. package/dist/moq/MoQPublisher.js +0 -179
  97. package/dist/moq/MoQSession.d.ts +0 -35
  98. package/dist/moq/MoQSession.js +0 -166
  99. package/dist/moq/MoQSubscriber.d.ts +0 -19
  100. package/dist/moq/MoQSubscriber.js +0 -235
  101. package/dist/moq/common.d.ts +0 -47
  102. package/dist/moq/common.js +0 -304
  103. package/dist/moq/messages.d.ts +0 -105
  104. package/dist/moq/messages.js +0 -367
  105. package/dist/presets/plutoHosted.d.ts +0 -13
  106. package/dist/presets/plutoHosted.js +0 -18
  107. package/dist/runtime/DelegatingRuntimeAdapter.d.ts +0 -68
  108. package/dist/runtime/DelegatingRuntimeAdapter.js +0 -250
  109. package/dist/runtime/IpcRuntimeAdapter.d.ts +0 -9
  110. package/dist/runtime/IpcRuntimeAdapter.js +0 -13
  111. package/dist/runtime/RuntimeClient.d.ts +0 -257
  112. package/dist/runtime/RuntimeClient.js +0 -1484
  113. package/dist/runtime/TauriRuntimeAdapter.d.ts +0 -1
  114. package/dist/runtime/TauriRuntimeAdapter.js +0 -1
  115. package/dist/runtime/factories.d.ts +0 -24
  116. package/dist/runtime/factories.js +0 -66
  117. package/dist/runtime/ipc.d.ts +0 -8
  118. package/dist/runtime/ipc.js +0 -65
  119. package/dist/runtime/ipcContract.d.ts +0 -46
  120. package/dist/runtime/ipcContract.js +0 -1
  121. package/dist/runtime/types.d.ts +0 -110
  122. package/dist/runtime/types.js +0 -1
  123. package/dist/transports/TauriTransport.d.ts +0 -17
  124. package/dist/transports/TauriTransport.js +0 -49
  125. package/dist/transports/WebTransport.d.ts +0 -23
  126. package/dist/transports/WebTransport.js +0 -71
  127. package/dist/utils/debug.d.ts +0 -4
  128. package/dist/utils/debug.js +0 -33
  129. package/dist/utils/runtime.d.ts +0 -1
  130. package/dist/utils/runtime.js +0 -10
@@ -1 +1,75 @@
1
- export { getAuthHost, authHost } from './host';
1
+ import { FirebaseApp } from 'firebase/app';
2
+ import { User, Auth } from 'firebase/auth';
3
+
4
+ type ProviderName = 'google' | 'apple';
5
+ interface SignInCredentialPayload {
6
+ provider: ProviderName;
7
+ idToken: string;
8
+ accessToken?: string;
9
+ nonce?: string;
10
+ isCustomToken?: boolean;
11
+ callbackId?: string;
12
+ email?: string;
13
+ displayName?: string;
14
+ photoURL?: string;
15
+ }
16
+ type DesktopAuthRelay = (payload: {
17
+ authToken: string | null;
18
+ refreshToken: string | null;
19
+ }) => Promise<void> | void;
20
+ declare function registerDesktopAuthRelay(relay: DesktopAuthRelay | null): void;
21
+ declare class AuthHost {
22
+ private app;
23
+ private auth;
24
+ private functions;
25
+ private persistenceReady;
26
+ private redirectResultPromise;
27
+ private redirectResultConsumed;
28
+ private lastRelayedToken;
29
+ private lastRelayedRefreshToken;
30
+ private desktopTokenRefreshIntervalId;
31
+ private syncDesktopAuthToken;
32
+ constructor();
33
+ getApp(): FirebaseApp;
34
+ getCurrentUser(): User | null;
35
+ getAuth(): Auth;
36
+ onAuthStateChanged(callback: (user: User | null) => void): () => void;
37
+ onIdTokenChanged(callback: (user: User | null) => void): () => void;
38
+ getIdToken(options?: {
39
+ forceRefresh?: boolean;
40
+ }): Promise<string | null>;
41
+ checkForSSOToken(): Promise<void>;
42
+ signInWithCustomTokenValue(token: string): Promise<User>;
43
+ signInWithPluto(options?: {
44
+ redirectUri?: string;
45
+ authorizeBaseUrl?: string;
46
+ }): Promise<void>;
47
+ waitForAuth(): Promise<void>;
48
+ signInAnonymously(): Promise<void>;
49
+ signIn(email: string, password: string): Promise<User>;
50
+ signUp(email: string, password: string): Promise<User>;
51
+ signOut(): Promise<void>;
52
+ deleteAccount(): Promise<void>;
53
+ signInWithCredential(payload: SignInCredentialPayload): Promise<User>;
54
+ private mintSessionTokenFromProviderToken;
55
+ signInWithPopup(provider: ProviderName): Promise<{
56
+ idToken: string;
57
+ refreshToken?: string;
58
+ }>;
59
+ signInWithRedirect(provider: ProviderName, options?: {
60
+ nonce?: string;
61
+ }): Promise<void>;
62
+ consumeRedirectResult(): Promise<{
63
+ fromRedirect: boolean;
64
+ user: User | null;
65
+ providerId?: string | null;
66
+ idToken?: string | null;
67
+ } | null>;
68
+ startGoogleSignIn(): Promise<void>;
69
+ startAppleSignIn(): Promise<void>;
70
+ mintSessionToken(): Promise<string>;
71
+ }
72
+ declare function getAuthHost(): AuthHost;
73
+ declare const authHost: AuthHost;
74
+
75
+ export { authHost, getAuthHost, registerDesktopAuthRelay };
@@ -1 +1 @@
1
- export { getAuthHost, authHost } from './host';
1
+ export{f as authHost,e as getAuthHost,d as registerDesktopAuthRelay}from'../chunk-4MH42GUI.js';
@@ -1 +1,3 @@
1
- export { registerDesktopAuthRelay } from './host';
1
+ export { registerDesktopAuthRelay } from './index.js';
2
+ import 'firebase/app';
3
+ import 'firebase/auth';
@@ -1 +1 @@
1
- export { registerDesktopAuthRelay } from './host';
1
+ export{d as registerDesktopAuthRelay}from'../chunk-4MH42GUI.js';
@@ -0,0 +1,2 @@
1
+ import {getApps,initializeApp}from'firebase/app';import {getFunctions,connectFunctionsEmulator,httpsCallable}from'firebase/functions';import {browserLocalPersistence,inMemoryPersistence,browserPopupRedirectResolver,initializeAuth,getAuth,connectAuthEmulator,setPersistence,onIdTokenChanged,getIdToken,signInWithCustomToken,onAuthStateChanged,signInAnonymously,signInWithEmailAndPassword,createUserWithEmailAndPassword,signOut,deleteUser,updateProfile,GoogleAuthProvider,OAuthProvider,signInWithCredential,signInWithPopup,signInWithRedirect,getRedirectResult}from'firebase/auth';function f(){return typeof window>"u"?false:!!(window.__TAURI_IPC__||window.__TAURI_INTERNALS__||window.__TAURI__||window.location.protocol==="tauri:"||window.location.hostname==="tauri.localhost")}var P="pluto-rtc-prod",R={apiKey:"AIzaSyA62Krj-7ZYFT5xjrTUq7mXana41Ahj_mM",authDomain:"api.openrtc.app",projectId:P,storageBucket:"pluto-rtc-prod.firebasestorage.app",messagingSenderId:"607066575224",appId:"1:607066575224:web:ed3f51825ba228db92b88d"};function te(i){let e=typeof i.projectId=="string"&&i.projectId.trim()?i.projectId.trim():P;return {...i,projectId:e}}var S="pluto-rtc-auth";function X(i){return new Promise(e=>setTimeout(e,i))}var g=null;function Y(){if(typeof globalThis<"u"&&globalThis.__OPENRTC_DEBUG__===true)return true;if(typeof localStorage<"u")try{return localStorage.getItem("openrtc:debug")==="1"}catch{return false}return false}function o(i,e){if(Y()){if(typeof e>"u"){console.log(i);return}console.log(i,e);}}function pe(i){g=i;}function Z(){return f()}function C(){return typeof navigator>"u"?false:/iPhone|iPad|iPod|Android/i.test(navigator.userAgent||"")}function y(){return Z()&&C()}function u(i,e,n){return Promise.race([i,new Promise((r,t)=>{setTimeout(()=>t(new Error(`${n} timeout after ${e}ms`)),e);})])}function b(i){let e="0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._",n=new Uint8Array(i);window.crypto.getRandomValues(n);let r="";for(let t=0;t<i;t+=1)r+=e[n[t]%e.length];return r}async function O(i){let n=new TextEncoder().encode(i),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}var k=class{constructor(){this.redirectResultPromise=null;this.redirectResultConsumed=false;this.lastRelayedToken=null;this.lastRelayedRefreshToken=null;this.desktopTokenRefreshIntervalId=null;let e=getApps().find(t=>t.name===S);this.app=e||initializeApp(R,S);let n=C(),r=y();if(n)try{let t=r?{persistence:[browserLocalPersistence,inMemoryPersistence]}:{persistence:[browserLocalPersistence,inMemoryPersistence],popupRedirectResolver:browserPopupRedirectResolver};this.auth=initializeAuth(this.app,t),o("[PLUTO-RTC][AUTH-HOST] Using mobile-safe Firebase auth initialization",{appName:this.app.name,persistence:"browserLocalPersistence->inMemoryPersistence",redirectResolver:r?"disabled-for-tauri-mobile":"browserPopupRedirectResolver",tauriMobile:r});}catch{this.auth=getAuth(this.app),console.warn("[PLUTO-RTC][AUTH-HOST] Mobile-safe auth initialization unavailable; falling back to default getAuth");}else this.auth=getAuth(this.app);this.functions=getFunctions(this.app);try{let t=typeof import.meta<"u"?import.meta.env:null;if(!!t&&String(t.VITE_USE_EMULATORS)==="true"&&(t.DEV||String(t.VITE_E2E)==="true")){let a=String(t.VITE_OPENRTC_EMULATOR_HOST??"127.0.0.1").trim()||"127.0.0.1",H=Number(t.VITE_OPENRTC_AUTH_EMULATOR_PORT??9100),_=Number(t.VITE_OPENRTC_FUNCTIONS_EMULATOR_PORT??5002);try{connectAuthEmulator(this.auth,`http://${a}:${H}`,{disableWarnings:!0});}catch{}try{connectFunctionsEmulator(this.functions,a,_);}catch{}}}catch{}n?this.persistenceReady=Promise.resolve():this.persistenceReady=setPersistence(this.auth,browserLocalPersistence).catch(t=>{console.warn("[PLUTO-RTC][AUTH-HOST] Failed to set auth persistence",{message:t?.message});}),o("[PLUTO-RTC][AUTH-HOST] Initialized auth host",{appName:this.app.name,mobileSafeAuth:n}),onIdTokenChanged(this.auth,t=>{o("[PLUTO-RTC][AUTH-HOST] Firebase ID token changed",{hasUser:!!t,uid:t?.uid,providerDataCount:t?.providerData?.length||0}),this.syncDesktopAuthToken(t);}),this.desktopTokenRefreshIntervalId||(this.desktopTokenRefreshIntervalId=setInterval(()=>{this.syncDesktopAuthToken(this.auth.currentUser,true);},600*1e3));}async syncDesktopAuthToken(e,n=false){if(!g)return;let r=e?await getIdToken(e,n).catch(()=>null):null,t=e?e.refreshToken??null:null;if(r===this.lastRelayedToken&&t===this.lastRelayedRefreshToken)return;this.lastRelayedToken=r,this.lastRelayedRefreshToken=t;let s=await Promise.allSettled([Promise.resolve(g({authToken:r,refreshToken:t}))]);s[0]?.status==="rejected"&&console.warn("[PLUTO-RTC][AUTH-HOST] Failed to relay auth token to desktop backend",{message:s[0].reason?.message});}getApp(){return this.app}getCurrentUser(){return this.auth.currentUser}getAuth(){return this.auth}onAuthStateChanged(e){return o("[PLUTO-RTC][AUTH-HOST] onAuthStateChanged listener registered (via onIdTokenChanged)"),onIdTokenChanged(this.auth,e)}onIdTokenChanged(e){return o("[PLUTO-RTC][AUTH-HOST] onIdTokenChanged listener registered"),onIdTokenChanged(this.auth,e)}async getIdToken(e){return this.auth.currentUser?getIdToken(this.auth.currentUser,e?.forceRefresh??true):null}async checkForSSOToken(){if(typeof window>"u")return;let e=new URLSearchParams(window.location.search),n=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.slice(1):window.location.hash),r=e.get("token")||n.get("token")||(e.get("custom_token")==="true"||n.get("custom_token")==="true"?e.get("id_token")||n.get("id_token"):null);if(r)try{await this.persistenceReady,await signInWithCustomToken(this.auth,r),window.history.replaceState({},document.title,window.location.pathname);}catch(t){console.error("[PLUTO-RTC][AUTH-HOST] SSO sign-in failed:",t);}}async signInWithCustomTokenValue(e){return await this.persistenceReady,(await signInWithCustomToken(this.auth,e)).user}async signInWithPluto(e){if(typeof window>"u")throw new Error("Pluto SSO requires a browser environment.");let n=e?.redirectUri||window.location.href,r=e?.authorizeBaseUrl||"https://pluto.openrtc.app/sso/authorize",t=new URL(r);t.searchParams.set("redirect_uri",n),window.location.assign(t.toString());}async waitForAuth(){if(await this.persistenceReady,!this.auth.currentUser)return new Promise(e=>{let n=onAuthStateChanged(this.auth,r=>{r&&(n(),e());});})}async signInAnonymously(){await signInAnonymously(this.auth);}async signIn(e,n){return (await signInWithEmailAndPassword(this.auth,e,n)).user}async signUp(e,n){return (await createUserWithEmailAndPassword(this.auth,e,n)).user}async signOut(){await signOut(this.auth);}async deleteAccount(){if(!this.auth.currentUser)throw new Error("No user signed in");await deleteUser(this.auth.currentUser);}async signInWithCredential(e){let n=Date.now();if(o("[PLUTO-RTC][AUTH-HOST] signInWithCredential start",{callbackId:e.callbackId,provider:e.provider,hasIdToken:!!e.idToken,hasAccessToken:!!e.accessToken,hasNonce:!!e.nonce}),e.isCustomToken){o("[PLUTO-RTC][AUTH-HOST] signInWithCredential: custom token detected, using signInWithCustomToken");try{if(y())o("[PLUTO-RTC][AUTH-HOST] Skipping authStateReady before custom token sign-in on Tauri mobile",{callbackId:e.callbackId});else {o("[PLUTO-RTC][AUTH-HOST] Awaiting authStateReady...");try{await u(this.auth.authStateReady(),5e3,"authStateReady"),o("[PLUTO-RTC][AUTH-HOST] Auth state ready, signing in with custom token...");}catch(a){console.warn("[PLUTO-RTC][AUTH-HOST] authStateReady did not resolve in time; continuing custom token sign-in",{callbackId:e.callbackId,message:a?.message});}}let s;try{s=await u(signInWithCustomToken(this.auth,e.idToken),25e3,"signInWithCustomToken (custom token path)");}catch(a){console.warn("[PLUTO-RTC][AUTH-HOST] First custom token sign-in attempt failed; retrying once",{callbackId:e.callbackId,message:a?.message,code:a?.code}),await X(250),s=await u(signInWithCustomToken(this.auth,e.idToken),25e3,"signInWithCustomToken (custom token path retry)");}if(o("[PLUTO-RTC][AUTH-HOST] signInWithCustomToken success",{callbackId:e.callbackId,provider:e.provider,uid:s.user?.uid,elapsedMs:Date.now()-n}),s.user&&(e.displayName||e.photoURL))try{await updateProfile(s.user,{displayName:e.displayName||s.user.displayName||void 0,photoURL:e.photoURL||s.user.photoURL||void 0});}catch(a){console.warn("[PLUTO-RTC][AUTH-HOST] Failed to update custom-token user profile",{callbackId:e.callbackId,message:a?.message});}return s.user}catch(t){throw console.error("[PLUTO-RTC][AUTH-HOST] signInWithCustomToken failed",{callbackId:e.callbackId,error:t?.message,code:t?.code,stack:t?.stack,elapsedMs:Date.now()-n}),t}}let r;e.provider==="google"?r=GoogleAuthProvider.credential(e.idToken,e.accessToken):r=new OAuthProvider("apple.com").credential({idToken:e.idToken,rawNonce:e.nonce,accessToken:e.accessToken});try{let t=await u(signInWithCredential(this.auth,r),1e4,"firebase signInWithCredential");return o("[PLUTO-RTC][AUTH-HOST] signInWithCredential success",{callbackId:e.callbackId,provider:e.provider,uid:t.user?.uid,elapsedMs:Date.now()-n}),t.user}catch(t){console.warn("[PLUTO-RTC][AUTH-HOST] signInWithCredential primary path failed; trying custom token fallback",{callbackId:e.callbackId,provider:e.provider,elapsedMs:Date.now()-n,code:t?.code,message:t?.message});let s=await u(this.mintSessionTokenFromProviderToken(e),15e3,"mintSessionTokenFromProviderToken"),a=await u(signInWithCustomToken(this.auth,s),15e3,"signInWithCustomToken");return o("[PLUTO-RTC][AUTH-HOST] signInWithCustomToken fallback success",{callbackId:e.callbackId,provider:e.provider,uid:a.user?.uid,elapsedMs:Date.now()-n}),a.user}}async mintSessionTokenFromProviderToken(e){let n=httpsCallable(this.functions,"mintSessionToken");o("[PLUTO-RTC][AUTH-HOST] mintSessionToken fallback request start",{provider:e.provider,hasIdToken:!!e.idToken,hasNonce:!!e.nonce});let t=(await n({provider:e.provider,idToken:e.idToken,nonce:e.nonce})).data?.token;if(!t)throw new Error("mintSessionToken did not return a token for provider exchange");return o("[PLUTO-RTC][AUTH-HOST] mintSessionToken fallback request success",{provider:e.provider}),t}async signInWithPopup(e){if(e==="google"){let s=new GoogleAuthProvider;s.addScope("email"),s.addScope("profile"),s.setCustomParameters({prompt:"select_account"});let a=await signInWithPopup(this.auth,s);return {idToken:await getIdToken(a.user,true),refreshToken:a.user.refreshToken}}let n=new OAuthProvider("apple.com");n.addScope("email"),n.addScope("name");let r=b(32);typeof sessionStorage<"u"&&sessionStorage.setItem("apple_auth_nonce",r),n.setCustomParameters({nonce:await O(r)});let t=await signInWithPopup(this.auth,n);return {idToken:await getIdToken(t.user,true),refreshToken:t.user.refreshToken}}async signInWithRedirect(e,n){if(e==="google"){let s=new GoogleAuthProvider;s.addScope("email"),s.addScope("profile"),s.setCustomParameters({prompt:"select_account"}),await signInWithRedirect(this.auth,s);return}let r=new OAuthProvider("apple.com");r.addScope("email"),r.addScope("name");let t=n?.nonce||b(32);typeof sessionStorage<"u"&&sessionStorage.setItem("apple_auth_nonce",t),r.setCustomParameters({nonce:await O(t)}),await signInWithRedirect(this.auth,r);}async consumeRedirectResult(){return this.redirectResultConsumed?(o("[PLUTO-RTC][AUTH-HOST] consumeRedirectResult skipped (already consumed)"),null):this.redirectResultPromise?this.redirectResultPromise:(this.redirectResultPromise=(async()=>{try{o("[PLUTO-RTC][AUTH-HOST] consumeRedirectResult start");let e=await getRedirectResult(this.auth);if(!e)return o("[PLUTO-RTC][AUTH-HOST] consumeRedirectResult: no redirect result"),{fromRedirect:!1,user:null};this.redirectResultConsumed=!0;let n=await getIdToken(e.user,!0).catch(()=>null),r=e.providerId||e.user.providerData?.[0]?.providerId||null;return o("[PLUTO-RTC][AUTH-HOST] consumeRedirectResult success",{uid:e.user.uid,providerId:r,hasIdToken:!!n}),{fromRedirect:!0,user:e.user,providerId:r,idToken:n}}finally{this.redirectResultPromise=null;}})(),this.redirectResultPromise)}async startGoogleSignIn(){await this.signInWithRedirect("google");}async startAppleSignIn(){await this.signInWithRedirect("apple");}async mintSessionToken(){let r=(await httpsCallable(this.functions,"mintSessionToken")()).data;if(!r?.token)throw new Error("mintSessionToken did not return a token");return r.token}},m=null;function Q(){return m||(m=new k),m}var me=new Proxy({},{get(i,e,n){let r=Q(),t=r[e];return typeof t=="function"?t.bind(r):t}});
2
+ export{f as a,P as b,te as c,pe as d,Q as e,me as f};