Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(auth): desktop-local sessions renew without the bootstrap token #16274

Closedjuliusmarmingewants to merge 1 commit intot3/desktop-bootstrap-1-stop-retrying fromt3/desktop-bootstrap-2-keep-sessionopened View on GitHub

Showing 8 changed files with 137 additions and 0 deletions (loading 5).

x
0 of 8 viewed, 8 left
54 additions and 0 deletionsapps/server/src/auth/EnvironmentAuth.test.tsModified
View file
@@ -452,6 +452,60 @@
​
+ it.effect("renews a desktop bearer session without its bootstrap token", () =>
+ Effect.gen(function* () {
+ const serverAuth = yield* EnvironmentAuth.EnvironmentAuth;
+ const first = yield* serverAuth.exchangeBootstrapCredentialForAccessToken(
+ "desktop-bootstrap-token",
+ undefined,
+ requestMetadata,
+ );
+ const firstSession = yield* serverAuth.authenticateHttpRequest(
+ makeBearerRequest(first.access_token),
+ );
+​
+ const renewed = yield* serverAuth.renewDesktopSession(firstSession, requestMetadata);
+ const renewedSession = yield* serverAuth.authenticateHttpRequest(
+ makeBearerRequest(renewed.access_token),
+ );
+ const firstError = yield* serverAuth
+ .authenticateHttpRequest(makeBearerRequest(first.access_token))
+ .pipe(Effect.flip);
+​
+ expect(renewedSession.subject).toBe("desktop-bootstrap");
+ expect(renewedSession.scopes).toEqual(firstSession.scopes);
+ expect(renewedSession.sessionId).not.toBe(firstSession.sessionId);
+ expect(firstError._tag).toBe("ServerAuthInvalidCredentialError");
+ }).pipe(
+ Effect.provide(