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

Function parseAttributes

packages/sql/pg/src/PgAuth.ts:182–196  ·  view source on GitHub ↗
(message: string)

Source from the content-addressed store, hash-verified

180const CHANNEL_BINDING = "biws"
181
182const parseAttributes = (message: string): Map<string, string> => {
183 const attributes = new Map<string, string>()
184 for (const part of message.split(",")) {
185 const separator = part.indexOf("=")
186 if (separator < 1) {
187 return fail(`Malformed SCRAM attribute: "${part}"`)
188 }
189 const key = part.slice(0, separator)
190 if (attributes.has(key)) {
191 return fail(`Duplicate SCRAM attribute "${key}"`)
192 }
193 attributes.set(key, part.slice(separator + 1))
194 }
195 return attributes
196}
197
198const attribute = (attributes: Map<string, string>, key: string): string =>
199 attributes.get(key) ?? fail(`Missing SCRAM attribute "${key}"`)

Callers 2

scramContinueUnsafeFunction · 0.70
scramFinishUnsafeFunction · 0.70

Calls 5

sliceMethod · 0.80
failFunction · 0.70
hasMethod · 0.65
setMethod · 0.65
splitMethod · 0.45

Tested by

no test coverage detected