@@ -9,7 +9,6 @@ import type {
99} from "@t3tools/contracts" ;
1010import { EnvironmentHttpCommonError , PRIMARY_LOCAL_ENVIRONMENT_ID } from "@t3tools/contracts" ;
1111import type { EnvironmentHttpCommonError as EnvironmentHttpCommonErrorType } from "@t3tools/contracts" ;
12- import * as DateTime from "effect/DateTime" ;
1312import * as Effect from "effect/Effect" ;
1413import * as Schema from "effect/Schema" ;
1514import { HttpClientError } from "effect/unstable/http" ;
@@ -66,7 +65,7 @@ export class PrimaryEnvironmentRequestError extends Schema.TaggedErrorClass<Prim
6665 }
6766}
6867
69- export const isPrimaryEnvironmentRequestError = Schema . is ( PrimaryEnvironmentRequestError ) ;
68+ const isPrimaryEnvironmentRequestError = Schema . is ( PrimaryEnvironmentRequestError ) ;
7069
7170export class PrimaryEnvironmentPairingCredentialRejectedError extends Schema . TaggedErrorClass < PrimaryEnvironmentPairingCredentialRejectedError > ( ) (
7271 "PrimaryEnvironmentPairingCredentialRejectedError" ,
@@ -96,10 +95,6 @@ export class PrimaryEnvironmentAuthSessionTimeoutError extends Schema.TaggedErro
9695 }
9796}
9897
99- export const isPrimaryEnvironmentAuthSessionTimeoutError = Schema . is (
100- PrimaryEnvironmentAuthSessionTimeoutError ,
101- ) ;
102-
10398export class PrimaryEnvironmentPairingCredentialRequiredError extends Schema . TaggedErrorClass < PrimaryEnvironmentPairingCredentialRequiredError > ( ) (
10499 "PrimaryEnvironmentPairingCredentialRequiredError" ,
105100 {
@@ -111,10 +106,6 @@ export class PrimaryEnvironmentPairingCredentialRequiredError extends Schema.Tag
111106 }
112107}
113108
114- export const isPrimaryEnvironmentPairingCredentialRequiredError = Schema . is (
115- PrimaryEnvironmentPairingCredentialRequiredError ,
116- ) ;
117-
118109const isEnvironmentHttpCommonError = Schema . is ( EnvironmentHttpCommonError ) ;
119110
120111export interface ServerPairingLinkRecord {
@@ -386,44 +377,6 @@ export async function createServerPairingCredential(input?: {
386377 }
387378}
388379
389- export async function listServerPairingLinks ( ) : Promise < ReadonlyArray < ServerPairingLinkRecord > > {
390- try {
391- const pairingLinks = await runPrimaryHttp (
392- PrimaryEnvironmentHttpClient . pipe (
393- Effect . flatMap ( ( client ) => client . auth . pairingLinks ( { headers : { } } ) ) ,
394- ) ,
395- ) ;
396- return pairingLinks . map ( ( pairingLink ) => {
397- const timestamps = {
398- createdAt : DateTime . formatIso ( pairingLink . createdAt ) ,
399- expiresAt : DateTime . formatIso ( pairingLink . expiresAt ) ,
400- } ;
401- if ( pairingLink . label === undefined ) {
402- return {
403- id : pairingLink . id ,
404- scopes : pairingLink . scopes ,
405- subject : pairingLink . subject ,
406- createdAt : timestamps . createdAt ,
407- expiresAt : timestamps . expiresAt ,
408- } ;
409- }
410- return {
411- id : pairingLink . id ,
412- scopes : pairingLink . scopes ,
413- subject : pairingLink . subject ,
414- label : pairingLink . label ,
415- createdAt : timestamps . createdAt ,
416- expiresAt : timestamps . expiresAt ,
417- } ;
418- } ) ;
419- } catch ( error ) {
420- throw PrimaryEnvironmentRequestError . fromCause ( {
421- operation : "list-pairing-links" ,
422- cause : error ,
423- } ) ;
424- }
425- }
426-
427380export async function revokeServerPairingLink ( id : string ) : Promise < void > {
428381 try {
429382 await runPrimaryHttp (
@@ -440,38 +393,6 @@ export async function revokeServerPairingLink(id: string): Promise<void> {
440393 }
441394}
442395
443- export async function listServerClientSessions ( ) : Promise <
444- ReadonlyArray < ServerClientSessionRecord >
445- > {
446- try {
447- const clientSessions = await runPrimaryHttp (
448- PrimaryEnvironmentHttpClient . pipe (
449- Effect . flatMap ( ( client ) => client . auth . clients ( { headers : { } } ) ) ,
450- ) ,
451- ) ;
452- return clientSessions . map ( ( clientSession ) => ( {
453- sessionId : clientSession . sessionId ,
454- subject : clientSession . subject ,
455- scopes : clientSession . scopes ,
456- method : clientSession . method ,
457- client : clientSession . client ,
458- issuedAt : DateTime . formatIso ( clientSession . issuedAt ) ,
459- expiresAt : DateTime . formatIso ( clientSession . expiresAt ) ,
460- lastConnectedAt :
461- clientSession . lastConnectedAt === null
462- ? null
463- : DateTime . formatIso ( clientSession . lastConnectedAt ) ,
464- connected : clientSession . connected ,
465- current : clientSession . current ,
466- } ) ) ;
467- } catch ( error ) {
468- throw PrimaryEnvironmentRequestError . fromCause ( {
469- operation : "list-client-sessions" ,
470- cause : error ,
471- } ) ;
472- }
473- }
474-
475396export async function revokeServerClientSession ( sessionId : AuthSessionId ) : Promise < void > {
476397 try {
477398 await runPrimaryHttp (
@@ -531,16 +452,6 @@ export async function resolveInitialServerAuthGateState(): Promise<ServerAuthGat
531452 } ) ;
532453}
533454
534- // Used by the WSL backend swap: invalidate the cached authenticated state
535- // (the new backend signs sessions with a different key) and re-bootstrap
536- // against the desktop bootstrap credential so the next WS reconnect doesn't
537- // hit 401 and start a reauth loop in the renderer.
538- export async function reauthenticatePrimaryEnvironment ( ) : Promise < ServerAuthGateState > {
539- resolvedAuthenticatedGateState = null ;
540- bootstrapPromise = null ;
541- return resolveInitialServerAuthGateState ( ) ;
542- }
543-
544455export function __resetServerAuthBootstrapForTests ( ) {
545456 bootstrapPromise = null ;
546457 resolvedAuthenticatedGateState = null ;
0 commit comments