@fonoster/apiserver 0.58.0 → 0.61.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/dist/calls/createCall.js
CHANGED
|
@@ -50,7 +50,9 @@ function createCall(prisma, publisher, isWorkspaceNumber, admitCall) {
|
|
|
50
50
|
where: { ref: appRef, accessKeyId }
|
|
51
51
|
});
|
|
52
52
|
if (!app) {
|
|
53
|
-
throw (0, notFoundError_1.notFoundError)(`Application with ref ${appRef} not found
|
|
53
|
+
throw (0, notFoundError_1.notFoundError)(`Application with ref ${appRef} not found`, {
|
|
54
|
+
public: true
|
|
55
|
+
});
|
|
54
56
|
}
|
|
55
57
|
// `from` picks the trunk the call leaves by (X-Dod-Number), so it must be one of the
|
|
56
58
|
// workspace's own Numbers; another workspace's number is reported like an unknown one.
|
package/dist/calls/getCall.js
CHANGED
|
@@ -40,7 +40,7 @@ function getCall(fetchSingleCall) {
|
|
|
40
40
|
logger.verbose("call to getCall", { accessKeyId, ref });
|
|
41
41
|
const response = yield fetchSingleCall(accessKeyId, ref);
|
|
42
42
|
if (!response) {
|
|
43
|
-
throw (0, notFoundError_1.notFoundError)(`Call not found: ${ref}
|
|
43
|
+
throw (0, notFoundError_1.notFoundError)(`Call not found: ${ref}`, { public: true });
|
|
44
44
|
}
|
|
45
45
|
callback(null, response);
|
|
46
46
|
});
|
|
@@ -17,7 +17,18 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { status } from "@grpc/grpc-js";
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* A NOT_FOUND error. The caller gets "The requested resource was not found" unless the error
|
|
22
|
+
* is marked public, in which case the caller gets `message` as written.
|
|
23
|
+
*
|
|
24
|
+
* Mark an error public only when it comes from a lookup that filters by the caller's
|
|
25
|
+
* accessKeyId. Never mark the error of a `withAccess` getFn: an unknown ref and another
|
|
26
|
+
* workspace's ref must answer the same message, or callers could probe other workspaces' refs.
|
|
27
|
+
*/
|
|
28
|
+
declare const notFoundError: (message: string, options?: {
|
|
29
|
+
public?: boolean;
|
|
30
|
+
}) => {
|
|
31
|
+
public?: boolean;
|
|
21
32
|
code: status;
|
|
22
33
|
message: string;
|
|
23
34
|
};
|
|
@@ -20,8 +20,13 @@ exports.notFoundError = void 0;
|
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
22
|
const grpc_js_1 = require("@grpc/grpc-js");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
/**
|
|
24
|
+
* A NOT_FOUND error. The caller gets "The requested resource was not found" unless the error
|
|
25
|
+
* is marked public, in which case the caller gets `message` as written.
|
|
26
|
+
*
|
|
27
|
+
* Mark an error public only when it comes from a lookup that filters by the caller's
|
|
28
|
+
* accessKeyId. Never mark the error of a `withAccess` getFn: an unknown ref and another
|
|
29
|
+
* workspace's ref must answer the same message, or callers could probe other workspaces' refs.
|
|
30
|
+
*/
|
|
31
|
+
const notFoundError = (message, options) => (Object.assign({ code: grpc_js_1.status.NOT_FOUND, message }, ((options === null || options === void 0 ? void 0 : options.public) ? { public: true } : {})));
|
|
27
32
|
exports.notFoundError = notFoundError;
|
|
@@ -31,11 +31,10 @@ exports.createProvidersHandlers = createProvidersHandlers;
|
|
|
31
31
|
*/
|
|
32
32
|
const common_1 = require("@fonoster/common");
|
|
33
33
|
const logger_1 = require("@fonoster/logger");
|
|
34
|
+
const notFoundError_1 = require("../core/notFoundError");
|
|
34
35
|
const registryUsage_1 = require("./registryUsage");
|
|
35
36
|
const INVALID_ARGUMENT = 3;
|
|
36
|
-
const NOT_FOUND = 5;
|
|
37
37
|
const invalid = (message) => ({ code: INVALID_ARGUMENT, message });
|
|
38
|
-
const notFound = (message) => ({ code: NOT_FOUND, message });
|
|
39
38
|
const seconds = (d) => (d ? Math.floor(d.getTime() / 1000) : 0);
|
|
40
39
|
/** The Secret name a provider key is stored under. */
|
|
41
40
|
const providerKeySecretName = (providerId) => `provider-key/${providerId}`;
|
|
@@ -203,7 +202,9 @@ function createProvidersHandlers(db) {
|
|
|
203
202
|
where: { accessKeyId_providerId: { accessKeyId, providerId } }
|
|
204
203
|
});
|
|
205
204
|
if (!existing)
|
|
206
|
-
throw
|
|
205
|
+
throw (0, notFoundError_1.notFoundError)(`no key for provider ${providerId}`, {
|
|
206
|
+
public: true
|
|
207
|
+
});
|
|
207
208
|
yield db.secret.delete({ where: { ref: existing.secretRef } });
|
|
208
209
|
callback(null, { providerId });
|
|
209
210
|
});
|
|
@@ -31,11 +31,10 @@ exports.createWebhooksHandlers = createWebhooksHandlers;
|
|
|
31
31
|
const crypto_1 = require("crypto");
|
|
32
32
|
const common_1 = require("@fonoster/common");
|
|
33
33
|
const logger_1 = require("@fonoster/logger");
|
|
34
|
+
const notFoundError_1 = require("../core/notFoundError");
|
|
34
35
|
const ROTATION_WINDOW_MS = 24 * 3600 * 1000;
|
|
35
36
|
const INVALID_ARGUMENT = 3;
|
|
36
|
-
const NOT_FOUND = 5;
|
|
37
37
|
const invalid = (message) => ({ code: INVALID_ARGUMENT, message });
|
|
38
|
-
const notFound = (message) => ({ code: NOT_FOUND, message });
|
|
39
38
|
const seconds = (d) => (d ? Math.floor(d.getTime() / 1000) : 0);
|
|
40
39
|
const hint = (secret) => `…${secret.slice(-4)}`;
|
|
41
40
|
function toWebhook(row) {
|
|
@@ -99,7 +98,7 @@ function createWebhooksHandlers(db, config = {}) {
|
|
|
99
98
|
where: { ref, accessKeyId }
|
|
100
99
|
});
|
|
101
100
|
if (!row)
|
|
102
|
-
throw
|
|
101
|
+
throw (0, notFoundError_1.notFoundError)(`webhook not found: ${ref}`, { public: true });
|
|
103
102
|
return row;
|
|
104
103
|
});
|
|
105
104
|
const createWebhook = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -188,7 +187,7 @@ function createWebhooksHandlers(db, config = {}) {
|
|
|
188
187
|
where: { ref, accessKeyId }
|
|
189
188
|
});
|
|
190
189
|
if (!row)
|
|
191
|
-
throw
|
|
190
|
+
throw (0, notFoundError_1.notFoundError)(`delivery not found: ${ref}`, { public: true });
|
|
192
191
|
return row;
|
|
193
192
|
});
|
|
194
193
|
/** One delivery of the caller's workspace, with the event it sends. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/apiserver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.0",
|
|
4
4
|
"description": "APIServer for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
"fonoster-owner": "./dist/bin/owner.js"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@fonoster/authz": "^0.
|
|
27
|
-
"@fonoster/autopilot": "^0.
|
|
28
|
-
"@fonoster/callrecord": "^0.
|
|
29
|
-
"@fonoster/common": "^0.
|
|
30
|
-
"@fonoster/identity": "^0.
|
|
31
|
-
"@fonoster/logger": "^0.
|
|
32
|
-
"@fonoster/sipnet": "^0.
|
|
33
|
-
"@fonoster/types": "^0.
|
|
26
|
+
"@fonoster/authz": "^0.61.0",
|
|
27
|
+
"@fonoster/autopilot": "^0.61.0",
|
|
28
|
+
"@fonoster/callrecord": "^0.61.0",
|
|
29
|
+
"@fonoster/common": "^0.61.0",
|
|
30
|
+
"@fonoster/identity": "^0.61.0",
|
|
31
|
+
"@fonoster/logger": "^0.61.0",
|
|
32
|
+
"@fonoster/sipnet": "^0.61.0",
|
|
33
|
+
"@fonoster/types": "^0.61.0",
|
|
34
34
|
"@grpc/grpc-js": "~1.14.6",
|
|
35
35
|
"@prisma/client": "^6.19.1",
|
|
36
36
|
"@routr/common": "^2.24.0",
|
|
37
|
-
"@routr/sdk": "^2.
|
|
37
|
+
"@routr/sdk": "^2.34.0",
|
|
38
38
|
"express": "^5.0.1",
|
|
39
39
|
"grpc-health-check": "^2.0.1",
|
|
40
40
|
"jsonwebtoken": "^9.0.2",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@fonoster/ops": "^0.
|
|
65
|
+
"@fonoster/ops": "^0.61.0",
|
|
66
66
|
"@types/express": "^5.0.6",
|
|
67
67
|
"@types/jsonwebtoken": "^9.0.10",
|
|
68
68
|
"@types/uuid": "^10.0.0",
|
|
69
69
|
"@types/validator": "^13.15.10"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "cd26d5635e8eff6f9565e8b2e71aa0a72faa1390",
|
|
72
72
|
"prisma": {
|
|
73
73
|
"seed": "tsx src/core/seed.ts"
|
|
74
74
|
}
|