@fonoster/apiserver 0.61.0 → 0.63.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/billing/buildService.d.ts +5 -3
- package/dist/billing/buildService.js +12 -8
- package/dist/config/schema.d.ts +3 -2
- package/dist/config/schema.js +4 -4
- package/dist/core/routrConfig.d.ts +1 -0
- package/dist/core/routrConfig.js +2 -1
- package/dist/core/services.d.ts +1 -1
- package/dist/envs.d.ts +2 -0
- package/dist/envs.js +4 -2
- package/package.json +13 -13
|
@@ -6,9 +6,11 @@ import * as grpc from "@grpc/grpc-js";
|
|
|
6
6
|
export declare function ownerOfCall(call: unknown): string | undefined;
|
|
7
7
|
/**
|
|
8
8
|
* The Billing API for the dashboard (billing.proto), when billing is on: each call is passed to
|
|
9
|
-
* the billing service with owner_ref set from the caller, never from the request.
|
|
9
|
+
* the billing service with owner_ref set from the caller, never from the request. GetCallsStatus
|
|
10
|
+
* is for anyone in the workspace (the authorization interceptor checks the role) and gets
|
|
11
|
+
* access_key_id from the call.
|
|
10
12
|
*/
|
|
11
|
-
declare function buildService(address: string, ownerOf?: typeof ownerOfCall): {
|
|
13
|
+
declare function buildService(address: string, ownerOf?: typeof ownerOfCall, accessKeyIdOf?: (call: unknown) => string | undefined): {
|
|
12
14
|
definition: {
|
|
13
15
|
serviceName: string;
|
|
14
16
|
pckg: string;
|
|
@@ -16,7 +18,7 @@ declare function buildService(address: string, ownerOf?: typeof ownerOfCall): {
|
|
|
16
18
|
proto: string;
|
|
17
19
|
};
|
|
18
20
|
handlers: {
|
|
19
|
-
|
|
21
|
+
getCallsStatus: (call: {
|
|
20
22
|
request: Record<string, unknown>;
|
|
21
23
|
}, callback: (error: grpc.ServiceError | null | Partial<grpc.ServiceError>, response?: unknown) => void) => void;
|
|
22
24
|
};
|
|
@@ -85,10 +85,17 @@ function ownerOfCall(call) {
|
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* The Billing API for the dashboard (billing.proto), when billing is on: each call is passed to
|
|
88
|
-
* the billing service with owner_ref set from the caller, never from the request.
|
|
88
|
+
* the billing service with owner_ref set from the caller, never from the request. GetCallsStatus
|
|
89
|
+
* is for anyone in the workspace (the authorization interceptor checks the role) and gets
|
|
90
|
+
* access_key_id from the call.
|
|
89
91
|
*/
|
|
90
|
-
function buildService(address, ownerOf = ownerOfCall) {
|
|
92
|
+
function buildService(address, ownerOf = ownerOfCall, accessKeyIdOf = (call) => (0, common_1.getAccessKeyIdFromCall)(call)) {
|
|
91
93
|
const client = new (grpc.makeGenericClientConstructor(definition(), "Billing", {}))(address, grpc.credentials.createInsecure());
|
|
94
|
+
const send = (method, request, callback) => client[method](request, (error, response) => {
|
|
95
|
+
if (error)
|
|
96
|
+
logger.verbose("billing call refused", { method, code: error.code });
|
|
97
|
+
callback(error ? { code: error.code, message: error.details } : null, response);
|
|
98
|
+
});
|
|
92
99
|
const forward = (method) => (call, callback) => {
|
|
93
100
|
const ownerRef = ownerOf(call);
|
|
94
101
|
if (!ownerRef) {
|
|
@@ -98,12 +105,9 @@ function buildService(address, ownerOf = ownerOfCall) {
|
|
|
98
105
|
});
|
|
99
106
|
return;
|
|
100
107
|
}
|
|
101
|
-
|
|
102
|
-
if (error)
|
|
103
|
-
logger.verbose("billing call refused", { method, code: error.code });
|
|
104
|
-
callback(error ? { code: error.code, message: error.details } : null, response);
|
|
105
|
-
});
|
|
108
|
+
send(method, Object.assign(Object.assign({}, call.request), { ownerRef }), callback);
|
|
106
109
|
};
|
|
110
|
+
const getCallsStatus = (call, callback) => send("getCallsStatus", Object.assign(Object.assign({}, call.request), { accessKeyId: accessKeyIdOf(call) }), callback);
|
|
107
111
|
return {
|
|
108
112
|
definition: {
|
|
109
113
|
serviceName: "Billing",
|
|
@@ -111,6 +115,6 @@ function buildService(address, ownerOf = ownerOfCall) {
|
|
|
111
115
|
version: "v1beta2",
|
|
112
116
|
proto: "billing.proto"
|
|
113
117
|
},
|
|
114
|
-
handlers: Object.fromEntries(METHODS.map((m) => [m, forward(m)]))
|
|
118
|
+
handlers: Object.assign(Object.assign({}, Object.fromEntries(METHODS.map((m) => [m, forward(m)]))), { getCallsStatus })
|
|
115
119
|
};
|
|
116
120
|
}
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -161,8 +161,9 @@ declare const fonosterConfigSchema: z.ZodObject<{
|
|
|
161
161
|
}>>;
|
|
162
162
|
}, z.core.$strip>>;
|
|
163
163
|
}, z.core.$strip>>;
|
|
164
|
-
routr: z.
|
|
164
|
+
routr: z.ZodObject<{
|
|
165
165
|
apiEndpoint: z.ZodDefault<z.ZodString>;
|
|
166
|
+
apiKey: z.ZodString;
|
|
166
167
|
sipProxy: z.ZodDefault<z.ZodString>;
|
|
167
168
|
roomrPeer: z.ZodPrefault<z.ZodObject<{
|
|
168
169
|
aor: z.ZodDefault<z.ZodString>;
|
|
@@ -170,7 +171,7 @@ declare const fonosterConfigSchema: z.ZodObject<{
|
|
|
170
171
|
username: z.ZodDefault<z.ZodString>;
|
|
171
172
|
password: z.ZodOptional<z.ZodString>;
|
|
172
173
|
}, z.core.$strip>>;
|
|
173
|
-
}, z.core.$strip
|
|
174
|
+
}, z.core.$strip>;
|
|
174
175
|
nats: z.ZodObject<{
|
|
175
176
|
url: z.ZodString;
|
|
176
177
|
user: z.ZodOptional<z.ZodString>;
|
package/dist/config/schema.js
CHANGED
|
@@ -275,9 +275,10 @@ const fonosterConfigSchema = zod_1.z
|
|
|
275
275
|
})
|
|
276
276
|
.prefault({}),
|
|
277
277
|
features: featuresSchema,
|
|
278
|
-
routr: zod_1.z
|
|
279
|
-
.object({
|
|
278
|
+
routr: zod_1.z.object({
|
|
280
279
|
apiEndpoint: zod_1.z.string().default("routr:51907"),
|
|
280
|
+
/** Sent as "authorization: Bearer <key>" on every Data API call (spec.data.apiKeys). */
|
|
281
|
+
apiKey: zod_1.z.string().min(1),
|
|
281
282
|
/**
|
|
282
283
|
* host:port of Routr's SIP listener: API-originated calls are dialed through it
|
|
283
284
|
* (CreateCall's to.proxy), as the roomr peer below (to.auth).
|
|
@@ -295,8 +296,7 @@ const fonosterConfigSchema = zod_1.z
|
|
|
295
296
|
password: zod_1.z.string().optional()
|
|
296
297
|
})
|
|
297
298
|
.prefault({})
|
|
298
|
-
})
|
|
299
|
-
.prefault({}),
|
|
299
|
+
}),
|
|
300
300
|
// user/password: the apiserver's NATS user when the server has per-service users
|
|
301
301
|
// (add-platform 4.1); password is usually a secret:// reference.
|
|
302
302
|
nats: zod_1.z.object({
|
package/dist/core/routrConfig.js
CHANGED
|
@@ -26,7 +26,8 @@ const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
|
26
26
|
const envs_1 = require("../envs");
|
|
27
27
|
const routrConfig = {
|
|
28
28
|
endpoint: envs_1.ROUTR_API_ENDPOINT,
|
|
29
|
-
insecure: true
|
|
29
|
+
insecure: true,
|
|
30
|
+
apiKey: envs_1.ROUTR_API_KEY
|
|
30
31
|
};
|
|
31
32
|
exports.routrConfig = routrConfig;
|
|
32
33
|
let numbers;
|
package/dist/core/services.d.ts
CHANGED
|
@@ -410,7 +410,7 @@ declare const services: Promise<[{
|
|
|
410
410
|
proto: string;
|
|
411
411
|
};
|
|
412
412
|
handlers: {
|
|
413
|
-
|
|
413
|
+
getCallsStatus: (call: {
|
|
414
414
|
request: Record<string, unknown>;
|
|
415
415
|
}, callback: (error: import("@grpc/grpc-js").ServiceError | null | Partial<import("@grpc/grpc-js").ServiceError>, response?: unknown) => void) => void;
|
|
416
416
|
};
|
package/dist/envs.d.ts
CHANGED
|
@@ -66,6 +66,8 @@ export declare const NATS: {
|
|
|
66
66
|
inboxPrefix?: string;
|
|
67
67
|
};
|
|
68
68
|
export declare const ROUTR_API_ENDPOINT: string;
|
|
69
|
+
/** Routr's Data API key (spec.data.apiKeys), sent as a Bearer token on every call. */
|
|
70
|
+
export declare const ROUTR_API_KEY: string;
|
|
69
71
|
export declare const ROUTR_ROOMR_PEER: {
|
|
70
72
|
aor: string;
|
|
71
73
|
name: string;
|
package/dist/envs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
exports.DOMAIN_NAMES_ROOT = exports.TRUNK_NAMES_ROOT = exports.SIP_ROOT = exports.PSTN_ROOT = exports.DOMAIN = exports.REGIONS = exports.WEBHOOKS = exports.SESSION_APPS = exports.CALL_RECORDS = exports.TWILIO_PHONE_NUMBER = exports.TWILIO_AUTH_TOKEN = exports.TWILIO_ACCOUNT_SID = void 0;
|
|
4
|
+
exports.SMTP_SENDER = exports.SMTP_SECURE = exports.SMTP_PORT = exports.SMTP_HOST = exports.SMTP_AUTH_USER = exports.SMTP_AUTH_PASS = exports.ROUTR_SIP_PROXY = exports.ROUTR_ROOMR_PEER = exports.ROUTR_API_KEY = exports.ROUTR_API_ENDPOINT = exports.NATS = exports.NATS_CONNECTION = exports.NATS_URL = exports.EVALUATIONS = exports.AUTHZ_SERVICE_METHODS = exports.AUTHZ_SERVICE_PORT = exports.AUTHZ_SERVICE_HOST = exports.AUTHZ_SERVICE_ENABLED = exports.BILLING_ADDRESS = exports.BILLING_ENABLED = exports.IDENTITY_DATABASE_URL = exports.IDENTITY_WORKSPACE_INVITE_URL = exports.IDENTITY_WORKSPACE_INVITE_EXPIRATION = exports.IDENTITY_WORKSPACE_INVITE_FAIL_URL = exports.IDENTITY_REFRESH_TOKEN_EXPIRES_IN = exports.IDENTITY_PUBLIC_KEY = exports.IDENTITY_PRIVATE_KEY = exports.IDENTITY_OAUTH2_GITHUB_CLIENT_SECRET = exports.IDENTITY_OAUTH2_GITHUB_CLIENT_ID = exports.IDENTITY_OAUTH2_GITHUB_ENABLED = exports.IDENTITY_TWO_FACTOR_AUTHENTICATION_REQUIRED = exports.IDENTITY_CONTACT_VERIFICATION_REQUIRED = exports.IDENTITY_ISSUER = exports.IDENTITY_ID_TOKEN_EXPIRES_IN = exports.IDENTITY_AUDIENCE = exports.IDENTITY_ACCESS_TOKEN_EXPIRES_IN = exports.HTTP_BRIDGE_PORT = exports.DEFAULT_NATS_QUEUE_GROUP = exports.DATABASE_URL = exports.CLOAK_ENCRYPTION_KEY = exports.NODE_HEARTBEAT_WILDCARD = exports.MEDIA_CALL_EVENTS_WILDCARD = exports.mediaCallEventsSubject = exports.CALL_EVENTS_WILDCARD = exports.callEventsSubject = exports.CALLS_CREATE_SUBJECT = exports.APP_URL = exports.APISERVER_SIGNALING_SERVER = exports.APISERVER_HOST = exports.APISERVER_BIND_ADDR = void 0;
|
|
5
|
+
exports.DOMAIN_NAMES_ROOT = exports.TRUNK_NAMES_ROOT = exports.SIP_ROOT = exports.PSTN_ROOT = exports.DOMAIN = exports.REGIONS = exports.WEBHOOKS = exports.SESSION_APPS = exports.CALL_RECORDS = exports.TWILIO_PHONE_NUMBER = exports.TWILIO_AUTH_TOKEN = exports.TWILIO_ACCOUNT_SID = exports.TEMPLATES_DIR = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
8
8
|
* http://github.com/fonoster/fonoster
|
|
@@ -94,6 +94,8 @@ exports.NATS_CONNECTION = config.nats;
|
|
|
94
94
|
/** nats.js connect options: the URL plus the apiserver's NATS user, when set (add-platform 4.1). */
|
|
95
95
|
exports.NATS = (0, common_1.natsConnectOptions)(config.nats);
|
|
96
96
|
exports.ROUTR_API_ENDPOINT = config.routr.apiEndpoint;
|
|
97
|
+
/** Routr's Data API key (spec.data.apiKeys), sent as a Bearer token on every call. */
|
|
98
|
+
exports.ROUTR_API_KEY = config.routr.apiKey;
|
|
97
99
|
// The roomr peer every app-linked number points at (add-roomr 4.1)
|
|
98
100
|
exports.ROUTR_ROOMR_PEER = config.routr.roomrPeer;
|
|
99
101
|
/** Routr's SIP address: API-originated calls are dialed through it (Roomr CreateCall). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/apiserver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.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.63.0",
|
|
27
|
+
"@fonoster/autopilot": "^0.63.0",
|
|
28
|
+
"@fonoster/callrecord": "^0.63.0",
|
|
29
|
+
"@fonoster/common": "^0.63.0",
|
|
30
|
+
"@fonoster/identity": "^0.63.0",
|
|
31
|
+
"@fonoster/logger": "^0.63.0",
|
|
32
|
+
"@fonoster/sipnet": "^0.63.0",
|
|
33
|
+
"@fonoster/types": "^0.63.0",
|
|
34
34
|
"@grpc/grpc-js": "~1.14.6",
|
|
35
35
|
"@prisma/client": "^6.19.1",
|
|
36
|
-
"@routr/common": "^
|
|
37
|
-
"@routr/sdk": "^
|
|
36
|
+
"@routr/common": "^3.0.0",
|
|
37
|
+
"@routr/sdk": "^3.0.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.63.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": "23c2f96ed0fdc2ad3961328a937388fc26dd57ce",
|
|
72
72
|
"prisma": {
|
|
73
73
|
"seed": "tsx src/core/seed.ts"
|
|
74
74
|
}
|