(message: string)
| 180 | const CHANNEL_BINDING = "biws" |
| 181 | |
| 182 | const 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 | |
| 198 | const attribute = (attributes: Map<string, string>, key: string): string => |
| 199 | attributes.get(key) ?? fail(`Missing SCRAM attribute "${key}"`) |
no test coverage detected