| author | |
| committer | |
| log | 29c3a54a4e64cbfcb42a6545e9c66482e3549522 |
| tree | 345c691e1a2b6be8157e84426ef1db4f7343cf33 |
| parent | 47e250a842ee254cd2230949f8575093da6a7adf |
| signature | Signed by PGP key B5690EEEBB952194 |
2 files changed, 0 insertions(+), 42 deletions(-)
packages/client-runtime/src/relay/managedRelayState.test.ts-12| ... | @@ -25,7 +25,6 @@ import { | ... | @@ -25,7 +25,6 @@ import { |
| 25 | managedRelaySessionAtom, | 25 | managedRelaySessionAtom, |
| 26 | readManagedRelaySnapshotState, | 26 | readManagedRelaySnapshotState, |
| 27 | setManagedRelaySession, | 27 | setManagedRelaySession, |
| 28 | waitForManagedRelayClerkToken, | ||
| 29 | } from "./managedRelayState.ts"; | 28 | } from "./managedRelayState.ts"; |
| 30 | 29 | ||
| 31 | let registry = AtomRegistry.make(); | 30 | let registry = AtomRegistry.make(); |
| ... | @@ -118,17 +117,6 @@ function clerkToken(expiresAtSeconds: number): string { | ... | @@ -118,17 +117,6 @@ function clerkToken(expiresAtSeconds: number): string { |
| 118 | describe("createManagedRelayQueryManager", () => { | 117 | describe("createManagedRelayQueryManager", () => { |
| 119 | afterEach(resetRegistry); | 118 | afterEach(resetRegistry); |
| 120 | 119 | ||
| 121 | it.effect("waits for the current cloud session before reading its token", () => | ||
| 122 | Effect.gen(function* () { | ||
| 123 | const tokenFiber = yield* waitForManagedRelayClerkToken(registry).pipe(Effect.forkChild); | ||
| 124 | |||
| 125 | setSession(); | ||
| 126 | |||
| 127 | expect(yield* Fiber.join(tokenFiber)).toBe("clerk-token"); | ||
| 128 | expect(registry.getNodes().get(managedRelaySessionAtom)?.listeners.size).toBe(0); | ||
| 129 | }), | ||
| 130 | ); | ||
| 131 | |||
| 132 | it.effect("deregisters an environment through the current Clerk session", () => | 120 | it.effect("deregisters an environment through the current Clerk session", () => |
| 133 | Effect.gen(function* () { | 121 | Effect.gen(function* () { |
| 134 | const unlinkEnvironment = vi.fn(() => Effect.succeed({ ok: true })); | 122 | const unlinkEnvironment = vi.fn(() => Effect.succeed({ ok: true })); |
packages/client-runtime/src/relay/managedRelayState.ts-30| ... | @@ -192,36 +192,6 @@ function readSessionClerkToken( | ... | @@ -192,36 +192,6 @@ function readSessionClerkToken( |
| 192 | ); | 192 | ); |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | export const waitForManagedRelayClerkToken = Effect.fn( | ||
| 196 | "clientRuntime.managedRelaySession.waitForClerkToken", | ||
| 197 | )(function* (registry: AtomRegistry.AtomRegistry) { | ||
| 198 | return yield* Effect.callback<string, ManagedRelaySessionError>((resume) => { | ||
| 199 | let unsubscribe: (() => void) | undefined; | ||
| 200 | let completed = false; | ||
| 201 | const readCurrentSession = () => { | ||
| 202 | if (completed) { | ||
| 203 | return true; | ||
| 204 | } | ||
| 205 | const session = registry.get(managedRelaySessionAtom); | ||
| 206 | if (!session) { | ||
| 207 | return false; | ||
| 208 | } | ||
| 209 | completed = true; | ||
| 210 | unsubscribe?.(); | ||
| 211 | resume(readSessionClerkToken(session)); | ||
| 212 | return true; | ||
| 213 | }; | ||
| 214 | |||
| 215 | if (readCurrentSession()) { | ||
| 216 | return; | ||
| 217 | } | ||
| 218 | |||
| 219 | unsubscribe = registry.subscribe(managedRelaySessionAtom, readCurrentSession); | ||
| 220 | readCurrentSession(); | ||
| 221 | return Effect.sync(() => unsubscribe?.()); | ||
| 222 | }); | ||
| 223 | }); | ||
| 224 | |||
| 225 | /** Removes an environment from the signed-in account without contacting that environment. */ | 195 | /** Removes an environment from the signed-in account without contacting that environment. */ |
| 226 | export const deregisterManagedRelayEnvironment = Effect.fn( | 196 | export const deregisterManagedRelayEnvironment = Effect.fn( |
| 227 | "clientRuntime.managedRelaySession.deregisterEnvironment", | 197 | "clientRuntime.managedRelaySession.deregisterEnvironment", |