firebase-tools 14.5.1 → 14.6.0
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/lib/commands/projects-create.js +1 -1
- package/lib/commands/use.js +4 -1
- package/lib/dataconnect/client.js +1 -0
- package/lib/deploy/functions/checkIam.js +38 -3
- package/lib/deploy/functions/prepare.js +1 -0
- package/lib/deploy/functions/services/firestore.js +23 -4
- package/lib/emulator/auth/cloudFunctions.js +14 -1
- package/lib/emulator/dataconnect/pgliteServer.js +20 -12
- package/lib/emulator/downloadableEmulatorInfo.json +18 -18
- package/lib/firestore/delete.js +6 -4
- package/lib/frameworks/constants.js +1 -1
- package/lib/frameworks/utils.js +8 -2
- package/lib/gcp/firestore.js +26 -21
- package/lib/{gif → gemini}/fdcExperience.js +14 -13
- package/lib/init/features/dataconnect/index.js +1 -1
- package/lib/init/features/project.js +13 -6
- package/lib/management/projects.js +6 -5
- package/lib/mcp/tools/core/consult_assistant.js +1 -1
- package/lib/mcp/tools/dataconnect/generate_operation.js +1 -1
- package/lib/mcp/tools/dataconnect/generate_schema.js +1 -1
- package/lib/mcp/tools/firestore/delete_document.js +17 -4
- package/lib/mcp/tools/firestore/emulator.js +16 -0
- package/lib/mcp/tools/firestore/get_documents.js +12 -2
- package/lib/mcp/tools/firestore/list_collections.js +14 -3
- package/lib/mcp/tools/firestore/query_collection.js +12 -2
- package/package.json +3 -2
- package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +0 -11
- package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +0 -69
- package/lib/emulator/dataconnect/pg-gateway/auth/index.js +0 -22
- package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +0 -135
- package/lib/emulator/dataconnect/pg-gateway/auth/password.js +0 -65
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +0 -34
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +0 -298
- package/lib/emulator/dataconnect/pg-gateway/backend-error.js +0 -75
- package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +0 -55
- package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +0 -79
- package/lib/emulator/dataconnect/pg-gateway/connection.js +0 -419
- package/lib/emulator/dataconnect/pg-gateway/connection.types.js +0 -8
- package/lib/emulator/dataconnect/pg-gateway/crypto.js +0 -40
- package/lib/emulator/dataconnect/pg-gateway/duplex.js +0 -53
- package/lib/emulator/dataconnect/pg-gateway/index.js +0 -27
- package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +0 -96
- package/lib/emulator/dataconnect/pg-gateway/message-codes.js +0 -54
- package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +0 -13
- package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +0 -36
- package/lib/emulator/dataconnect/pg-gateway/utils.js +0 -40
- /package/lib/{emulator/dataconnect/pg-gateway/auth/trust.js → gemini/types.js} +0 -0
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
3
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
-
var m = o[Symbol.asyncIterator], i;
|
|
5
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
6
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
7
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
8
|
-
};
|
|
9
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
10
|
-
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
|
11
|
-
var i, p;
|
|
12
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
13
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
14
|
-
};
|
|
15
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
16
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
17
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
18
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
19
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
20
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
21
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
22
|
-
function fulfill(value) { resume("next", value); }
|
|
23
|
-
function reject(value) { resume("throw", value); }
|
|
24
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.decodeBase64 = exports.encodeBase64 = exports.ScramSha256AuthFlow = exports.verifyScramSha256Password = exports.createScramSha256Data = void 0;
|
|
28
|
-
const backend_error_1 = require("../../backend-error");
|
|
29
|
-
const connection_1 = require("../../connection");
|
|
30
|
-
const crypto_1 = require("../../crypto");
|
|
31
|
-
const sasl_mechanism_1 = require("./sasl-mechanism");
|
|
32
|
-
async function createScramSha256Data(password, iterations = 4096) {
|
|
33
|
-
const salt = new Uint8Array(16);
|
|
34
|
-
crypto.getRandomValues(salt);
|
|
35
|
-
const saltedPassword = await (0, crypto_1.pbkdf2)(password, salt, iterations, 32, 'SHA-256');
|
|
36
|
-
const clientKey = await (0, crypto_1.createHmacKey)(saltedPassword, 'Client Key', 'SHA-256');
|
|
37
|
-
const storedKey = await (0, crypto_1.createHashKey)(clientKey, 'SHA-256');
|
|
38
|
-
const serverKey = await (0, crypto_1.createHmacKey)(saltedPassword, 'Server Key', 'SHA-256');
|
|
39
|
-
return {
|
|
40
|
-
salt: encodeBase64(salt),
|
|
41
|
-
iterations,
|
|
42
|
-
storedKey: encodeBase64(storedKey),
|
|
43
|
-
serverKey: encodeBase64(serverKey),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
exports.createScramSha256Data = createScramSha256Data;
|
|
47
|
-
async function verifyScramSha256Password(params) {
|
|
48
|
-
const { authMessage, clientProof, storedKey } = params;
|
|
49
|
-
const clientProofBuffer = decodeBase64(clientProof);
|
|
50
|
-
const storedKeyBuffer = decodeBase64(storedKey);
|
|
51
|
-
const clientSignature = await (0, crypto_1.createHmacKey)(storedKeyBuffer, authMessage, 'SHA-256');
|
|
52
|
-
const clientSignatureView = new Uint8Array(clientSignature);
|
|
53
|
-
const clientKey = new Uint8Array(clientProofBuffer.length);
|
|
54
|
-
for (let i = 0; i < clientProofBuffer.length; i++) {
|
|
55
|
-
clientKey[i] = clientProofBuffer[i] ^ clientSignatureView[i];
|
|
56
|
-
}
|
|
57
|
-
const computedStoredKey = await (0, crypto_1.createHashKey)(clientKey, 'SHA-256');
|
|
58
|
-
return await (0, crypto_1.timingSafeEqual)(storedKeyBuffer, computedStoredKey);
|
|
59
|
-
}
|
|
60
|
-
exports.verifyScramSha256Password = verifyScramSha256Password;
|
|
61
|
-
const ScramSha256Step = {
|
|
62
|
-
Initial: 'Initial',
|
|
63
|
-
ServerFirstMessage: 'ServerFirstMessage',
|
|
64
|
-
ServerFinalMessage: 'ServerFinalMessage',
|
|
65
|
-
Completed: 'Completed',
|
|
66
|
-
};
|
|
67
|
-
class ScramSha256AuthFlow extends sasl_mechanism_1.SaslMechanism {
|
|
68
|
-
constructor(params) {
|
|
69
|
-
var _a;
|
|
70
|
-
super({ writer: params.writer });
|
|
71
|
-
this.step = ScramSha256Step.Initial;
|
|
72
|
-
this.username = params.username;
|
|
73
|
-
this.auth = Object.assign(Object.assign({}, params.auth), { validateCredentials: (_a = params.auth.validateCredentials) !== null && _a !== void 0 ? _a : (async ({ authMessage, clientProof, scramSha256Data }) => {
|
|
74
|
-
return verifyScramSha256Password({
|
|
75
|
-
authMessage,
|
|
76
|
-
clientProof,
|
|
77
|
-
storedKey: scramSha256Data.storedKey,
|
|
78
|
-
});
|
|
79
|
-
}) });
|
|
80
|
-
this.reader = params.reader;
|
|
81
|
-
this.connectionState = params.connectionState;
|
|
82
|
-
}
|
|
83
|
-
async getScramSha256Data(params) {
|
|
84
|
-
if (!this.scramSha256Data) {
|
|
85
|
-
this.scramSha256Data = await this.auth.getScramSha256Data(params, this.connectionState);
|
|
86
|
-
}
|
|
87
|
-
return this.scramSha256Data;
|
|
88
|
-
}
|
|
89
|
-
createInitialAuthMessage() {
|
|
90
|
-
return this.createAuthenticationSASL();
|
|
91
|
-
}
|
|
92
|
-
handleClientMessage(message) {
|
|
93
|
-
return __asyncGenerator(this, arguments, function* handleClientMessage_1() {
|
|
94
|
-
switch (this.step) {
|
|
95
|
-
case ScramSha256Step.Initial:
|
|
96
|
-
return yield __await(yield __await(yield* __asyncDelegator(__asyncValues(this.handleClientFirstMessage(message)))));
|
|
97
|
-
case ScramSha256Step.ServerFirstMessage:
|
|
98
|
-
return yield __await(yield __await(yield* __asyncDelegator(__asyncValues(this.handleClientFinalMessage(message)))));
|
|
99
|
-
default:
|
|
100
|
-
throw new Error('Unexpected SCRAM-SHA-256 authentication step');
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
handleClientFirstMessage(message) {
|
|
105
|
-
return __asyncGenerator(this, arguments, function* handleClientFirstMessage_1() {
|
|
106
|
-
const length = this.reader.int32();
|
|
107
|
-
const saslMechanism = this.reader.cstring();
|
|
108
|
-
if (saslMechanism !== 'SCRAM-SHA-256') {
|
|
109
|
-
yield yield __await((0, backend_error_1.createBackendErrorMessage)({
|
|
110
|
-
severity: 'FATAL',
|
|
111
|
-
code: '28000',
|
|
112
|
-
message: 'Unsupported SASL authentication mechanism',
|
|
113
|
-
}));
|
|
114
|
-
yield yield __await(connection_1.closeSignal);
|
|
115
|
-
return yield __await(void 0);
|
|
116
|
-
}
|
|
117
|
-
const responseLength = this.reader.int32();
|
|
118
|
-
const clientFirstMessage = this.reader.string(responseLength);
|
|
119
|
-
const serverFirstMessage = yield __await(this.createServerFirstMessage(clientFirstMessage));
|
|
120
|
-
this.step = ScramSha256Step.ServerFirstMessage;
|
|
121
|
-
yield yield __await(this.createAuthenticationSASLContinue(serverFirstMessage));
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
async createServerFirstMessage(clientFirstMessage) {
|
|
125
|
-
var _a;
|
|
126
|
-
const clientFirstMessageParts = clientFirstMessage.split(',');
|
|
127
|
-
this.clientFirstMessageBare = clientFirstMessageParts.slice(2).join(',');
|
|
128
|
-
const clientNonce = ((_a = clientFirstMessageParts.find((part) => part.startsWith('r='))) === null || _a === void 0 ? void 0 : _a.substring(2)) || '';
|
|
129
|
-
const serverNoncePart = new Uint8Array(18);
|
|
130
|
-
crypto.getRandomValues(serverNoncePart);
|
|
131
|
-
this.serverNonce = clientNonce + encodeBase64(serverNoncePart);
|
|
132
|
-
const { salt, iterations } = await this.getScramSha256Data({
|
|
133
|
-
username: this.username,
|
|
134
|
-
});
|
|
135
|
-
this.serverFirstMessage = `r=${this.serverNonce},s=${salt},i=${iterations}`;
|
|
136
|
-
return this.serverFirstMessage;
|
|
137
|
-
}
|
|
138
|
-
handleClientFinalMessage(message) {
|
|
139
|
-
return __asyncGenerator(this, arguments, function* handleClientFinalMessage_1() {
|
|
140
|
-
try {
|
|
141
|
-
const serverFinalMessage = yield __await(this.createServerFinalMessage(message));
|
|
142
|
-
this.step = ScramSha256Step.Completed;
|
|
143
|
-
yield yield __await(this.createAuthenticationSASLFinal(serverFinalMessage));
|
|
144
|
-
}
|
|
145
|
-
catch (error) {
|
|
146
|
-
yield yield __await((0, backend_error_1.createBackendErrorMessage)({
|
|
147
|
-
severity: 'FATAL',
|
|
148
|
-
code: '28000',
|
|
149
|
-
message: error.message,
|
|
150
|
-
}));
|
|
151
|
-
yield yield __await(connection_1.closeSignal);
|
|
152
|
-
return yield __await(void 0);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
get isCompleted() {
|
|
157
|
-
return this.step === ScramSha256Step.Completed;
|
|
158
|
-
}
|
|
159
|
-
async createServerFinalMessage(message) {
|
|
160
|
-
var _a, _b, _c;
|
|
161
|
-
const length = this.reader.int32();
|
|
162
|
-
const stringLength = length - 4;
|
|
163
|
-
const clientFinalMessage = this.reader.string(stringLength);
|
|
164
|
-
const clientFinalMessageParts = clientFinalMessage.split(',');
|
|
165
|
-
const channelBinding = (_a = clientFinalMessageParts
|
|
166
|
-
.find((part) => part.startsWith('c='))) === null || _a === void 0 ? void 0 : _a.substring(2);
|
|
167
|
-
const fullNonce = (_b = clientFinalMessageParts.find((part) => part.startsWith('r='))) === null || _b === void 0 ? void 0 : _b.substring(2);
|
|
168
|
-
const clientProof = (_c = clientFinalMessageParts.find((part) => part.startsWith('p='))) === null || _c === void 0 ? void 0 : _c.substring(2);
|
|
169
|
-
if (!channelBinding || !fullNonce || !clientProof) {
|
|
170
|
-
throw new Error('Invalid client final message');
|
|
171
|
-
}
|
|
172
|
-
if (fullNonce !== this.serverNonce) {
|
|
173
|
-
throw new Error('Nonce mismatch');
|
|
174
|
-
}
|
|
175
|
-
const clientFinalMessageWithoutProof = `c=${channelBinding},r=${fullNonce}`;
|
|
176
|
-
const authMessage = `${this.clientFirstMessageBare},${this.serverFirstMessage},${clientFinalMessageWithoutProof}`;
|
|
177
|
-
const data = await this.getScramSha256Data({
|
|
178
|
-
username: this.username,
|
|
179
|
-
});
|
|
180
|
-
const isValid = await this.auth.validateCredentials({
|
|
181
|
-
authMessage,
|
|
182
|
-
clientProof,
|
|
183
|
-
username: this.username,
|
|
184
|
-
scramSha256Data: data,
|
|
185
|
-
}, this.connectionState);
|
|
186
|
-
if (!isValid) {
|
|
187
|
-
throw new Error(`password authentication failed for user "${this.username}"`);
|
|
188
|
-
}
|
|
189
|
-
const serverKeyBuffer = decodeBase64(data.serverKey);
|
|
190
|
-
const serverSignature = await (0, crypto_1.createHmacKey)(serverKeyBuffer, authMessage, 'SHA-256');
|
|
191
|
-
return `v=${encodeBase64(serverSignature)}`;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
exports.ScramSha256AuthFlow = ScramSha256AuthFlow;
|
|
195
|
-
function encodeBase64(data) {
|
|
196
|
-
const uint8 = data;
|
|
197
|
-
let result = "";
|
|
198
|
-
let i;
|
|
199
|
-
const l = uint8.length;
|
|
200
|
-
for (i = 2; i < l; i += 3) {
|
|
201
|
-
result += base64abc[(uint8[i - 2]) >> 2];
|
|
202
|
-
result += base64abc[(((uint8[i - 2]) & 0x03) << 4) |
|
|
203
|
-
((uint8[i - 1]) >> 4)];
|
|
204
|
-
result += base64abc[(((uint8[i - 1]) & 0x0f) << 2) |
|
|
205
|
-
((uint8[i]) >> 6)];
|
|
206
|
-
result += base64abc[(uint8[i]) & 0x3f];
|
|
207
|
-
}
|
|
208
|
-
if (i === l + 1) {
|
|
209
|
-
result += base64abc[(uint8[i - 2]) >> 2];
|
|
210
|
-
result += base64abc[((uint8[i - 2]) & 0x03) << 4];
|
|
211
|
-
result += "==";
|
|
212
|
-
}
|
|
213
|
-
if (i === l) {
|
|
214
|
-
result += base64abc[(uint8[i - 2]) >> 2];
|
|
215
|
-
result += base64abc[(((uint8[i - 2]) & 0x03) << 4) |
|
|
216
|
-
((uint8[i - 1]) >> 4)];
|
|
217
|
-
result += base64abc[((uint8[i - 1]) & 0x0f) << 2];
|
|
218
|
-
result += "=";
|
|
219
|
-
}
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
exports.encodeBase64 = encodeBase64;
|
|
223
|
-
function decodeBase64(b64) {
|
|
224
|
-
const binString = atob(b64);
|
|
225
|
-
const size = binString.length;
|
|
226
|
-
const bytes = new Uint8Array(size);
|
|
227
|
-
for (let i = 0; i < size; i++) {
|
|
228
|
-
bytes[i] = binString.charCodeAt(i);
|
|
229
|
-
}
|
|
230
|
-
return bytes;
|
|
231
|
-
}
|
|
232
|
-
exports.decodeBase64 = decodeBase64;
|
|
233
|
-
const base64abc = [
|
|
234
|
-
"A",
|
|
235
|
-
"B",
|
|
236
|
-
"C",
|
|
237
|
-
"D",
|
|
238
|
-
"E",
|
|
239
|
-
"F",
|
|
240
|
-
"G",
|
|
241
|
-
"H",
|
|
242
|
-
"I",
|
|
243
|
-
"J",
|
|
244
|
-
"K",
|
|
245
|
-
"L",
|
|
246
|
-
"M",
|
|
247
|
-
"N",
|
|
248
|
-
"O",
|
|
249
|
-
"P",
|
|
250
|
-
"Q",
|
|
251
|
-
"R",
|
|
252
|
-
"S",
|
|
253
|
-
"T",
|
|
254
|
-
"U",
|
|
255
|
-
"V",
|
|
256
|
-
"W",
|
|
257
|
-
"X",
|
|
258
|
-
"Y",
|
|
259
|
-
"Z",
|
|
260
|
-
"a",
|
|
261
|
-
"b",
|
|
262
|
-
"c",
|
|
263
|
-
"d",
|
|
264
|
-
"e",
|
|
265
|
-
"f",
|
|
266
|
-
"g",
|
|
267
|
-
"h",
|
|
268
|
-
"i",
|
|
269
|
-
"j",
|
|
270
|
-
"k",
|
|
271
|
-
"l",
|
|
272
|
-
"m",
|
|
273
|
-
"n",
|
|
274
|
-
"o",
|
|
275
|
-
"p",
|
|
276
|
-
"q",
|
|
277
|
-
"r",
|
|
278
|
-
"s",
|
|
279
|
-
"t",
|
|
280
|
-
"u",
|
|
281
|
-
"v",
|
|
282
|
-
"w",
|
|
283
|
-
"x",
|
|
284
|
-
"y",
|
|
285
|
-
"z",
|
|
286
|
-
"0",
|
|
287
|
-
"1",
|
|
288
|
-
"2",
|
|
289
|
-
"3",
|
|
290
|
-
"4",
|
|
291
|
-
"5",
|
|
292
|
-
"6",
|
|
293
|
-
"7",
|
|
294
|
-
"8",
|
|
295
|
-
"9",
|
|
296
|
-
"+",
|
|
297
|
-
"/",
|
|
298
|
-
];
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBackendErrorMessage = void 0;
|
|
4
|
-
const buffer_writer_1 = require("./buffer-writer");
|
|
5
|
-
const message_codes_1 = require("./message-codes");
|
|
6
|
-
function createBackendErrorMessage(error) {
|
|
7
|
-
const writer = new buffer_writer_1.BufferWriter();
|
|
8
|
-
writer.addString('S');
|
|
9
|
-
writer.addCString(error.severity);
|
|
10
|
-
writer.addString('V');
|
|
11
|
-
writer.addCString(error.severity);
|
|
12
|
-
writer.addString('C');
|
|
13
|
-
writer.addCString(error.code);
|
|
14
|
-
writer.addString('M');
|
|
15
|
-
writer.addCString(error.message);
|
|
16
|
-
if (error.detail !== undefined) {
|
|
17
|
-
writer.addString('D');
|
|
18
|
-
writer.addCString(error.detail);
|
|
19
|
-
}
|
|
20
|
-
if (error.hint !== undefined) {
|
|
21
|
-
writer.addString('H');
|
|
22
|
-
writer.addCString(error.hint);
|
|
23
|
-
}
|
|
24
|
-
if (error.position !== undefined) {
|
|
25
|
-
writer.addString('P');
|
|
26
|
-
writer.addCString(error.position);
|
|
27
|
-
}
|
|
28
|
-
if (error.internalPosition !== undefined) {
|
|
29
|
-
writer.addString('p');
|
|
30
|
-
writer.addCString(error.internalPosition);
|
|
31
|
-
}
|
|
32
|
-
if (error.internalQuery !== undefined) {
|
|
33
|
-
writer.addString('q');
|
|
34
|
-
writer.addCString(error.internalQuery);
|
|
35
|
-
}
|
|
36
|
-
if (error.where !== undefined) {
|
|
37
|
-
writer.addString('W');
|
|
38
|
-
writer.addCString(error.where);
|
|
39
|
-
}
|
|
40
|
-
if (error.schema !== undefined) {
|
|
41
|
-
writer.addString('s');
|
|
42
|
-
writer.addCString(error.schema);
|
|
43
|
-
}
|
|
44
|
-
if (error.table !== undefined) {
|
|
45
|
-
writer.addString('t');
|
|
46
|
-
writer.addCString(error.table);
|
|
47
|
-
}
|
|
48
|
-
if (error.column !== undefined) {
|
|
49
|
-
writer.addString('c');
|
|
50
|
-
writer.addCString(error.column);
|
|
51
|
-
}
|
|
52
|
-
if (error.dataType !== undefined) {
|
|
53
|
-
writer.addString('d');
|
|
54
|
-
writer.addCString(error.dataType);
|
|
55
|
-
}
|
|
56
|
-
if (error.constraint !== undefined) {
|
|
57
|
-
writer.addString('n');
|
|
58
|
-
writer.addCString(error.constraint);
|
|
59
|
-
}
|
|
60
|
-
if (error.file !== undefined) {
|
|
61
|
-
writer.addString('F');
|
|
62
|
-
writer.addCString(error.file);
|
|
63
|
-
}
|
|
64
|
-
if (error.line !== undefined) {
|
|
65
|
-
writer.addString('L');
|
|
66
|
-
writer.addCString(error.line);
|
|
67
|
-
}
|
|
68
|
-
if (error.routine !== undefined) {
|
|
69
|
-
writer.addString('R');
|
|
70
|
-
writer.addCString(error.routine);
|
|
71
|
-
}
|
|
72
|
-
writer.addCString('');
|
|
73
|
-
return writer.flush(message_codes_1.BackendMessageCode.ErrorMessage);
|
|
74
|
-
}
|
|
75
|
-
exports.createBackendErrorMessage = createBackendErrorMessage;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BufferReader = void 0;
|
|
4
|
-
class BufferReader {
|
|
5
|
-
constructor(offset = 0) {
|
|
6
|
-
this.offset = offset;
|
|
7
|
-
this.buffer = new Uint8Array();
|
|
8
|
-
this.decoder = new TextDecoder();
|
|
9
|
-
}
|
|
10
|
-
setBuffer(buffer, offset = 0) {
|
|
11
|
-
this.buffer = buffer;
|
|
12
|
-
this.offset = offset;
|
|
13
|
-
}
|
|
14
|
-
int16() {
|
|
15
|
-
const dataView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
16
|
-
const result = dataView.getInt16(this.offset);
|
|
17
|
-
this.offset += 2;
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
byte() {
|
|
21
|
-
const dataView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
22
|
-
const result = dataView.getUint8(this.offset);
|
|
23
|
-
this.offset++;
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
int32() {
|
|
27
|
-
const dataView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
28
|
-
const result = dataView.getInt32(this.offset);
|
|
29
|
-
this.offset += 4;
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
string(length) {
|
|
33
|
-
const dataView = new DataView(this.buffer.buffer, this.offset, length);
|
|
34
|
-
this.offset += length;
|
|
35
|
-
return this.decoder.decode(dataView);
|
|
36
|
-
}
|
|
37
|
-
cstring() {
|
|
38
|
-
var _a;
|
|
39
|
-
const start = this.offset;
|
|
40
|
-
let end = start;
|
|
41
|
-
while (((_a = this.buffer[end++]) !== null && _a !== void 0 ? _a : 0) !== 0) { }
|
|
42
|
-
if (this.buffer[end - 1] === undefined) {
|
|
43
|
-
throw new Error('Reached end of buffer before null character found for PG String');
|
|
44
|
-
}
|
|
45
|
-
const dataView = new DataView(this.buffer.buffer, start, end - start - 1);
|
|
46
|
-
this.offset = end;
|
|
47
|
-
return this.decoder.decode(dataView);
|
|
48
|
-
}
|
|
49
|
-
bytes(length) {
|
|
50
|
-
const result = this.buffer.slice(this.offset, this.offset + length);
|
|
51
|
-
this.offset += length;
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.BufferReader = BufferReader;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BufferWriter = void 0;
|
|
4
|
-
const utils_1 = require("./utils");
|
|
5
|
-
class BufferWriter {
|
|
6
|
-
constructor(size = 256) {
|
|
7
|
-
this.size = size;
|
|
8
|
-
this.offset = 5;
|
|
9
|
-
this.headerPosition = 0;
|
|
10
|
-
this.encoder = new TextEncoder();
|
|
11
|
-
this.buffer = new Uint8Array(size);
|
|
12
|
-
}
|
|
13
|
-
ensure(size) {
|
|
14
|
-
const remaining = this.buffer.length - this.offset;
|
|
15
|
-
if (remaining < size) {
|
|
16
|
-
const oldBuffer = this.buffer;
|
|
17
|
-
const newSize = oldBuffer.length + (oldBuffer.length >> 1) + size;
|
|
18
|
-
this.buffer = new Uint8Array(newSize);
|
|
19
|
-
(0, utils_1.copy)(oldBuffer, this.buffer);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
addInt32(num) {
|
|
23
|
-
this.ensure(4);
|
|
24
|
-
this.buffer[this.offset++] = (num >>> 24) & 0xff;
|
|
25
|
-
this.buffer[this.offset++] = (num >>> 16) & 0xff;
|
|
26
|
-
this.buffer[this.offset++] = (num >>> 8) & 0xff;
|
|
27
|
-
this.buffer[this.offset++] = (num >>> 0) & 0xff;
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
addInt16(num) {
|
|
31
|
-
this.ensure(2);
|
|
32
|
-
this.buffer[this.offset++] = (num >>> 8) & 0xff;
|
|
33
|
-
this.buffer[this.offset++] = (num >>> 0) & 0xff;
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
addCString(string) {
|
|
37
|
-
if (!string) {
|
|
38
|
-
this.ensure(1);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
const stringBuffer = this.encoder.encode(string);
|
|
42
|
-
this.ensure(stringBuffer.byteLength + 1);
|
|
43
|
-
this.buffer.set(stringBuffer, this.offset);
|
|
44
|
-
this.offset += stringBuffer.byteLength;
|
|
45
|
-
}
|
|
46
|
-
this.buffer[this.offset++] = 0;
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
addString(string = '') {
|
|
50
|
-
const stringBuffer = this.encoder.encode(string);
|
|
51
|
-
this.ensure(stringBuffer.byteLength);
|
|
52
|
-
this.buffer.set(stringBuffer, this.offset);
|
|
53
|
-
this.offset += stringBuffer.byteLength;
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
add(otherBuffer) {
|
|
57
|
-
this.ensure(otherBuffer.byteLength);
|
|
58
|
-
(0, utils_1.copy)(otherBuffer, this.buffer, this.offset);
|
|
59
|
-
this.offset += otherBuffer.length;
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
join(code) {
|
|
63
|
-
if (code) {
|
|
64
|
-
this.buffer[this.headerPosition] = code;
|
|
65
|
-
const length = this.offset - (this.headerPosition + 1);
|
|
66
|
-
const dataView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
67
|
-
dataView.setInt32(this.headerPosition + 1, length);
|
|
68
|
-
}
|
|
69
|
-
return this.buffer.slice(code ? 0 : 5, this.offset);
|
|
70
|
-
}
|
|
71
|
-
flush(code) {
|
|
72
|
-
const result = this.join(code);
|
|
73
|
-
this.offset = 5;
|
|
74
|
-
this.headerPosition = 0;
|
|
75
|
-
this.buffer = new Uint8Array(this.size);
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.BufferWriter = BufferWriter;
|