@effect/sql-pg 4.0.0-rc.111 → 4.0.0-rc.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-docs/package.json +1 -1
- package/dist/PgAuth.d.ts +69 -0
- package/dist/PgAuth.d.ts.map +1 -0
- package/dist/PgAuth.js +202 -0
- package/dist/PgAuth.js.map +1 -0
- package/dist/PgProtocol.d.ts +750 -0
- package/dist/PgProtocol.d.ts.map +1 -0
- package/dist/PgProtocol.js +1160 -0
- package/dist/PgProtocol.js.map +1 -0
- package/dist/PgTypes.d.ts +361 -0
- package/dist/PgTypes.d.ts.map +1 -0
- package/dist/PgTypes.js +1514 -0
- package/dist/PgTypes.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/package.json +8 -4
- package/src/PgAuth.ts +287 -0
- package/src/PgProtocol.ts +1820 -0
- package/src/PgTypes.ts +1930 -0
- package/src/index.ts +15 -0
package/ai-docs/package.json
CHANGED
package/dist/PgAuth.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as Result from "effect/Result";
|
|
2
|
+
declare const AuthError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
3
|
+
readonly _tag: "PgAuthError";
|
|
4
|
+
} & Readonly<A>;
|
|
5
|
+
/**
|
|
6
|
+
* Failure returned when an authentication exchange cannot be completed.
|
|
7
|
+
*
|
|
8
|
+
* @category errors
|
|
9
|
+
* @since 4.0.0
|
|
10
|
+
*/
|
|
11
|
+
export declare class AuthError extends AuthError_base<{
|
|
12
|
+
readonly message: string;
|
|
13
|
+
}> {
|
|
14
|
+
}
|
|
15
|
+
export declare const md5Password: (options: {
|
|
16
|
+
readonly user: string;
|
|
17
|
+
readonly password: string;
|
|
18
|
+
readonly salt: Uint8Array;
|
|
19
|
+
}) => Result.Result<string, AuthError>;
|
|
20
|
+
/**
|
|
21
|
+
* The only SASL mechanism this module implements.
|
|
22
|
+
*
|
|
23
|
+
* @category SCRAM
|
|
24
|
+
* @since 4.0.0
|
|
25
|
+
*/
|
|
26
|
+
export declare const SCRAM_SHA_256 = "SCRAM-SHA-256";
|
|
27
|
+
/**
|
|
28
|
+
* State after the client's first message, awaiting the server's challenge.
|
|
29
|
+
*
|
|
30
|
+
* @category SCRAM
|
|
31
|
+
* @since 4.0.0
|
|
32
|
+
*/
|
|
33
|
+
export interface ScramFirst {
|
|
34
|
+
readonly _tag: "ScramFirst";
|
|
35
|
+
readonly password: string;
|
|
36
|
+
readonly clientNonce: string;
|
|
37
|
+
readonly clientFirstMessageBare: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* State after the client's final message, awaiting the server signature.
|
|
41
|
+
*
|
|
42
|
+
* @category SCRAM
|
|
43
|
+
* @since 4.0.0
|
|
44
|
+
*/
|
|
45
|
+
export interface ScramFinal {
|
|
46
|
+
readonly _tag: "ScramFinal";
|
|
47
|
+
readonly serverSignature: Uint8Array;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The SCRAM exchange state.
|
|
51
|
+
*
|
|
52
|
+
* @category SCRAM
|
|
53
|
+
* @since 4.0.0
|
|
54
|
+
*/
|
|
55
|
+
export type ScramState = ScramFirst | ScramFinal;
|
|
56
|
+
export declare const scramInit: (options: {
|
|
57
|
+
readonly password: string;
|
|
58
|
+
readonly nonce: string;
|
|
59
|
+
}) => Result.Result<{
|
|
60
|
+
readonly state: ScramFirst;
|
|
61
|
+
readonly response: Uint8Array;
|
|
62
|
+
}, AuthError>;
|
|
63
|
+
export declare const scramContinue: (state: ScramFirst, challenge: Uint8Array) => Result.Result<{
|
|
64
|
+
readonly state: ScramFinal;
|
|
65
|
+
readonly response: Uint8Array;
|
|
66
|
+
}, AuthError>;
|
|
67
|
+
export declare const scramFinish: (state: ScramFinal, challenge: Uint8Array) => Result.Result<void, AuthError>;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=PgAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PgAuth.d.ts","sourceRoot":"","sources":["../src/PgAuth.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;;;;AAGvC;;;;;GAKG;AACH,qBAAa,SAAU,SAAQ,eAAgC;IAC7D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAC;CAAG;AAwEL,eAAO,MAAM,WAAW,YAAa;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAC1B,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAA6C,CAAA;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,kBAAkB,CAAA;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAA;CACxC;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAC3B,QAAQ,CAAC,eAAe,EAAE,UAAU,CAAA;CACrC;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,UAAU,CAAA;AAuDhD,eAAO,MAAM,SAAS,YAAa;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,KAAG,MAAM,CAAC,MAAM,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAA;CAAE,EAAE,SAAS,CAClD,CAAA;AAqDxC,eAAO,MAAM,aAAa,UACjB,UAAU,aACN,UAAU,KACpB,MAAM,CAAC,MAAM,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAA;CAAE,EAAE,SAAS,CACpC,CAAA;AAsBrD,eAAO,MAAM,WAAW,UACf,UAAU,aACN,UAAU,KACpB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAsD,CAAA"}
|
package/dist/PgAuth.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Password authentication for the PostgreSQL protocol: MD5 and
|
|
3
|
+
* SCRAM-SHA-256.
|
|
4
|
+
*
|
|
5
|
+
* Message framing lives in `PgProtocol` - SASL payloads travel as opaque
|
|
6
|
+
* bytes - so this module only computes what goes inside them. Cleartext
|
|
7
|
+
* authentication needs nothing from here; send the password as a
|
|
8
|
+
* `PasswordMessage`.
|
|
9
|
+
*
|
|
10
|
+
* `SCRAM-SHA-256-PLUS` is not implemented: channel binding needs the TLS
|
|
11
|
+
* socket, which this codec does not own. Passwords are used as UTF-8 without
|
|
12
|
+
* SASLprep normalisation, so non-ASCII passwords that require normalisation
|
|
13
|
+
* are not supported.
|
|
14
|
+
*
|
|
15
|
+
* @since 4.0.0
|
|
16
|
+
*/
|
|
17
|
+
import * as Data from "effect/Data";
|
|
18
|
+
import * as Encoding from "effect/Encoding";
|
|
19
|
+
import * as Result from "effect/Result";
|
|
20
|
+
import { createHash, createHmac, pbkdf2Sync } from "node:crypto";
|
|
21
|
+
/**
|
|
22
|
+
* Failure returned when an authentication exchange cannot be completed.
|
|
23
|
+
*
|
|
24
|
+
* @category errors
|
|
25
|
+
* @since 4.0.0
|
|
26
|
+
*/
|
|
27
|
+
export class AuthError extends /*#__PURE__*/Data.TaggedError("PgAuthError") {}
|
|
28
|
+
const fail = message => {
|
|
29
|
+
throw new AuthError({
|
|
30
|
+
message
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const result = evaluate => {
|
|
34
|
+
try {
|
|
35
|
+
return Result.succeed(evaluate());
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error instanceof AuthError) return Result.fail(error);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const textEncoder = /*#__PURE__*/new TextEncoder();
|
|
42
|
+
const textDecoder = /*#__PURE__*/new TextDecoder("utf-8", {
|
|
43
|
+
fatal: true
|
|
44
|
+
});
|
|
45
|
+
const bytesOf = value => Uint8Array.from(value);
|
|
46
|
+
const sha256 = data => bytesOf(createHash("sha256").update(data).digest());
|
|
47
|
+
const hmacSha256 = (key, data) => bytesOf(createHmac("sha256", key).update(data).digest());
|
|
48
|
+
const xor = (left, right) => {
|
|
49
|
+
const result = new Uint8Array(left.length);
|
|
50
|
+
for (let i = 0; i < left.length; i++) {
|
|
51
|
+
result[i] = left[i] ^ right[i];
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
const toBase64 = bytes => Encoding.encodeBase64(bytes);
|
|
56
|
+
const fromBase64 = (text, field) => {
|
|
57
|
+
const decoded = Encoding.decodeBase64(text);
|
|
58
|
+
if (Result.isFailure(decoded)) {
|
|
59
|
+
return fail(`Invalid base64 in SCRAM attribute "${field}"`);
|
|
60
|
+
}
|
|
61
|
+
return decoded.success;
|
|
62
|
+
};
|
|
63
|
+
const decodeUtf8 = (bytes, what) => {
|
|
64
|
+
try {
|
|
65
|
+
return textDecoder.decode(bytes);
|
|
66
|
+
} catch {
|
|
67
|
+
return fail(`Invalid UTF-8 in ${what}`);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Computes the password string for an `AuthenticationMD5Password` challenge:
|
|
72
|
+
* `"md5" + md5(md5(password + user) + salt)`. Send the result verbatim as a
|
|
73
|
+
* `PasswordMessage`.
|
|
74
|
+
*
|
|
75
|
+
* @category MD5
|
|
76
|
+
* @since 4.0.0
|
|
77
|
+
*/
|
|
78
|
+
const md5PasswordUnsafe = options => {
|
|
79
|
+
if (options.salt.length !== 4) {
|
|
80
|
+
return fail(`PostgreSQL MD5 salt must be exactly 4 bytes, received ${options.salt.length}`);
|
|
81
|
+
}
|
|
82
|
+
const inner = createHash("md5").update(textEncoder.encode(options.password + options.user)).digest("hex");
|
|
83
|
+
const outer = createHash("md5").update(textEncoder.encode(inner)).update(options.salt).digest("hex");
|
|
84
|
+
return `md5${outer}`;
|
|
85
|
+
};
|
|
86
|
+
export const md5Password = options => result(() => md5PasswordUnsafe(options));
|
|
87
|
+
/**
|
|
88
|
+
* The only SASL mechanism this module implements.
|
|
89
|
+
*
|
|
90
|
+
* @category SCRAM
|
|
91
|
+
* @since 4.0.0
|
|
92
|
+
*/
|
|
93
|
+
export const SCRAM_SHA_256 = "SCRAM-SHA-256";
|
|
94
|
+
const GS2_HEADER = "n,,";
|
|
95
|
+
/** Base64 of the GS2 header, the `c=` attribute value without channel binding. */
|
|
96
|
+
const CHANNEL_BINDING = "biws";
|
|
97
|
+
const parseAttributes = message => {
|
|
98
|
+
const attributes = new Map();
|
|
99
|
+
for (const part of message.split(",")) {
|
|
100
|
+
const separator = part.indexOf("=");
|
|
101
|
+
if (separator < 1) {
|
|
102
|
+
return fail(`Malformed SCRAM attribute: "${part}"`);
|
|
103
|
+
}
|
|
104
|
+
const key = part.slice(0, separator);
|
|
105
|
+
if (attributes.has(key)) {
|
|
106
|
+
return fail(`Duplicate SCRAM attribute "${key}"`);
|
|
107
|
+
}
|
|
108
|
+
attributes.set(key, part.slice(separator + 1));
|
|
109
|
+
}
|
|
110
|
+
return attributes;
|
|
111
|
+
};
|
|
112
|
+
const attribute = (attributes, key) => attributes.get(key) ?? fail(`Missing SCRAM attribute "${key}"`);
|
|
113
|
+
/**
|
|
114
|
+
* Starts a SCRAM-SHA-256 exchange. The `nonce` must be a fresh, random,
|
|
115
|
+
* printable ASCII string chosen by the caller; this module never generates
|
|
116
|
+
* randomness.
|
|
117
|
+
*
|
|
118
|
+
* The successful result contains the `initialResponse` bytes for a
|
|
119
|
+
* `SASLInitialResponse` message with mechanism `SCRAM_SHA_256`.
|
|
120
|
+
*
|
|
121
|
+
* @category SCRAM
|
|
122
|
+
* @since 4.0.0
|
|
123
|
+
*/
|
|
124
|
+
const scramInitUnsafe = options => {
|
|
125
|
+
if (!/^[\x21-\x2b\x2d-\x7e]+$/.test(options.nonce)) {
|
|
126
|
+
return fail("SCRAM nonce must contain only printable ASCII characters other than comma");
|
|
127
|
+
}
|
|
128
|
+
const clientFirstMessageBare = `n=,r=${options.nonce}`;
|
|
129
|
+
return {
|
|
130
|
+
state: {
|
|
131
|
+
_tag: "ScramFirst",
|
|
132
|
+
password: options.password,
|
|
133
|
+
clientNonce: options.nonce,
|
|
134
|
+
clientFirstMessageBare
|
|
135
|
+
},
|
|
136
|
+
response: textEncoder.encode(GS2_HEADER + clientFirstMessageBare)
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
export const scramInit = options => result(() => scramInitUnsafe(options));
|
|
140
|
+
/**
|
|
141
|
+
* Answers an `AuthenticationSASLContinue` challenge.
|
|
142
|
+
*
|
|
143
|
+
* The successful result contains the payload bytes for a `SASLResponse`
|
|
144
|
+
* message.
|
|
145
|
+
*
|
|
146
|
+
* @category SCRAM
|
|
147
|
+
* @since 4.0.0
|
|
148
|
+
*/
|
|
149
|
+
const scramContinueUnsafe = (state, challenge) => {
|
|
150
|
+
const serverFirstMessage = decodeUtf8(challenge, "the SCRAM server-first-message");
|
|
151
|
+
const attributes = parseAttributes(serverFirstMessage);
|
|
152
|
+
const nonce = attribute(attributes, "r");
|
|
153
|
+
if (!nonce.startsWith(state.clientNonce) || nonce.length === state.clientNonce.length) {
|
|
154
|
+
return fail("SCRAM server nonce does not extend the client nonce");
|
|
155
|
+
}
|
|
156
|
+
const saltText = attribute(attributes, "s");
|
|
157
|
+
if (saltText.length === 0) {
|
|
158
|
+
return fail("SCRAM salt must not be empty");
|
|
159
|
+
}
|
|
160
|
+
const salt = fromBase64(saltText, "s");
|
|
161
|
+
const iterationText = attribute(attributes, "i");
|
|
162
|
+
const iterations = Number(iterationText);
|
|
163
|
+
if (!/^[1-9]\d*$/.test(iterationText) || !Number.isSafeInteger(iterations) || iterations > 0x7fffffff) {
|
|
164
|
+
return fail(`Invalid SCRAM iteration count: ${iterationText}`);
|
|
165
|
+
}
|
|
166
|
+
const saltedPassword = bytesOf(pbkdf2Sync(textEncoder.encode(state.password), salt, iterations, 32, "sha256"));
|
|
167
|
+
const clientKey = hmacSha256(saltedPassword, textEncoder.encode("Client Key"));
|
|
168
|
+
const storedKey = sha256(clientKey);
|
|
169
|
+
const clientFinalMessageWithoutProof = `c=${CHANNEL_BINDING},r=${nonce}`;
|
|
170
|
+
const authMessage = textEncoder.encode(`${state.clientFirstMessageBare},${serverFirstMessage},${clientFinalMessageWithoutProof}`);
|
|
171
|
+
const clientProof = xor(clientKey, hmacSha256(storedKey, authMessage));
|
|
172
|
+
const serverKey = hmacSha256(saltedPassword, textEncoder.encode("Server Key"));
|
|
173
|
+
return {
|
|
174
|
+
state: {
|
|
175
|
+
_tag: "ScramFinal",
|
|
176
|
+
serverSignature: hmacSha256(serverKey, authMessage)
|
|
177
|
+
},
|
|
178
|
+
response: textEncoder.encode(`${clientFinalMessageWithoutProof},p=${toBase64(clientProof)}`)
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
export const scramContinue = (state, challenge) => result(() => scramContinueUnsafe(state, challenge));
|
|
182
|
+
/**
|
|
183
|
+
* Verifies the server signature carried by `AuthenticationSASLFinal`. Returns
|
|
184
|
+
* `Result.void` on success and an `AuthError` failure when the server could
|
|
185
|
+
* not prove that it knows the stored key.
|
|
186
|
+
*
|
|
187
|
+
* @category SCRAM
|
|
188
|
+
* @since 4.0.0
|
|
189
|
+
*/
|
|
190
|
+
const scramFinishUnsafe = (state, challenge) => {
|
|
191
|
+
const attributes = parseAttributes(decodeUtf8(challenge, "the SCRAM server-final-message"));
|
|
192
|
+
const error = attributes.get("e");
|
|
193
|
+
if (error !== undefined) {
|
|
194
|
+
fail(`SCRAM authentication failed: ${error}`);
|
|
195
|
+
}
|
|
196
|
+
const signature = fromBase64(attribute(attributes, "v"), "v");
|
|
197
|
+
if (toBase64(state.serverSignature) !== toBase64(signature)) {
|
|
198
|
+
fail("SCRAM server signature mismatch");
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
export const scramFinish = (state, challenge) => result(() => scramFinishUnsafe(state, challenge));
|
|
202
|
+
//# sourceMappingURL=PgAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PgAuth.js","names":[],"sources":["../src/PgAuth.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;AAgBA,OAAO,KAAK,IAAI,MAAM,aAAa;AACnC,OAAO,KAAK,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,SAAS,UAAU,EAAE,UAAU,EAAE,UAAU,QAAQ,aAAa;AAEhE;;;;;;AAMA,OAAM,MAAO,SAAU,sBAAQ,IAAI,CAAC,WAAW,CAAC,aAAa,CAE3D;AAEF,MAAM,IAAI,GAAI,OAAe,IAAW;EACtC,MAAM,IAAI,SAAS,CAAC;IAAE;EAAO,CAAE,CAAC;AAClC,CAAC;AAED,MAAM,MAAM,GAAO,QAAiB,IAAiC;EACnE,IAAI;IACF,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;EACnC,CAAC,CAAC,OAAO,KAAK,EAAE;IACd,IAAI,KAAK,YAAY,SAAS,EAAE,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;IACzD,MAAM,KAAK;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