@@ -8,13 +8,16 @@ class Unauthorized extends Schema.TaggedErrorClass<Unauthorized>()(
88 { httpApiStatus : 401 } ,
99) { }
1010
11- export class Authorization extends HttpApiMiddleware . Service < Authorization > ( ) ( "@opencode/ExperimentalHttpApiAuthorization" , {
12- error : Unauthorized ,
13- security : {
14- basic : HttpApiSecurity . basic ,
15- authToken : HttpApiSecurity . apiKey ( { in : "query" , key : "auth_token" } ) ,
11+ export class Authorization extends HttpApiMiddleware . Service < Authorization > ( ) (
12+ "@opencode/ExperimentalHttpApiAuthorization" ,
13+ {
14+ error : Unauthorized ,
15+ security : {
16+ basic : HttpApiSecurity . basic ,
17+ authToken : HttpApiSecurity . apiKey ( { in : "query" , key : "auth_token" } ) ,
18+ } ,
1619 } ,
17- } ) { }
20+ ) { }
1821
1922const emptyCredential = {
2023 username : "" ,
@@ -39,19 +42,21 @@ function validateCredential<A, E, R>(
3942}
4043
4144function decodeCredential ( input : string ) {
42- return Encoding . decodeBase64String ( input ) . asEffect ( ) . pipe (
43- Effect . match ( {
44- onFailure : ( ) => emptyCredential ,
45- onSuccess : ( header ) => {
46- const parts = header . split ( ":" )
47- if ( parts . length !== 2 ) return emptyCredential
48- return {
49- username : parts [ 0 ] ,
50- password : Redacted . make ( parts [ 1 ] ) ,
51- }
52- } ,
53- } ) ,
54- )
45+ return Encoding . decodeBase64String ( input )
46+ . asEffect ( )
47+ . pipe (
48+ Effect . match ( {
49+ onFailure : ( ) => emptyCredential ,
50+ onSuccess : ( header ) => {
51+ const parts = header . split ( ":" )
52+ if ( parts . length !== 2 ) return emptyCredential
53+ return {
54+ username : parts [ 0 ] ,
55+ password : Redacted . make ( parts [ 1 ] ) ,
56+ }
57+ } ,
58+ } ) ,
59+ )
5560}
5661
5762export const authorizationLayer = Layer . succeed (
0 commit comments