MCPcopy Create free account
hub / github.com/Effect-TS/effect / decodeAuthentication

Function decodeAuthentication

packages/sql/pg/src/PgProtocol.ts:1763–1788  ·  view source on GitHub ↗
(reader: Reader)

Source from the content-addressed store, hash-verified

1761}
1762
1763const decodeAuthentication = (reader: Reader): BackendMessage => {
1764 const method = reader.int32()
1765 switch (method) {
1766 case 0:
1767 return { _tag: "AuthenticationOk" }
1768 case 3:
1769 return { _tag: "AuthenticationCleartextPassword" }
1770 case 5:
1771 return { _tag: "AuthenticationMD5Password", salt: reader.raw(4) }
1772 case 10: {
1773 const mechanisms: Array<string> = []
1774 for (;;) {
1775 const mechanism = reader.cString()
1776 if (mechanism === "") break
1777 mechanisms.push(mechanism)
1778 }
1779 return { _tag: "AuthenticationSASL", mechanisms }
1780 }
1781 case 11:
1782 return { _tag: "AuthenticationSASLContinue", data: reader.rest() }
1783 case 12:
1784 return { _tag: "AuthenticationSASLFinal", data: reader.rest() }
1785 default:
1786 return { _tag: "AuthenticationUnsupported", method, payload: reader.rest() }
1787 }
1788}
1789
1790const decodeErrorFields = (reader: Reader): ErrorFields => {
1791 const fields: Record<string, string> = {}

Callers 1

decodeBackendFunction · 0.85

Calls 5

restMethod · 0.80
pushMethod · 0.65
int32Method · 0.45
rawMethod · 0.45
cStringMethod · 0.45

Tested by

no test coverage detected