(.using [library [lux (.except) ["[0]" ffi (.only import:)] [abstract [equivalence (.only Equivalence)]] [data ["[0]" product] ["[0]" text ["%" format (.only format)] [encoding ["[0]" utf8]]]]]]) (type: .public User Text) (type: .public Password Text) (type: .public Identity (Record [#user User #password Password])) (def: .public equivalence (Equivalence Identity) (all product.equivalence text.equivalence text.equivalence )) (import: java/util/Base64$Encoder "[1]::[0]" (encodeToString [[byte]] java/lang/String)) (import: java/util/Base64 "[1]::[0]" ("static" getEncoder [] java/util/Base64$Encoder)) (def: .public (basic_auth user password) (-> User Password Text) (let [credentials (at utf8.codec encoded (format user ":" password))] (|> (java/util/Base64::getEncoder) (java/util/Base64$Encoder::encodeToString credentials) ffi.of_string (format "Basic "))))