@fonoster/apiserver 0.14.6 → 0.15.1
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/applications/buildService.d.ts +5 -1
- package/dist/applications/buildService.js +4 -2
- package/dist/applications/createCreateTestToken.d.ts +24 -0
- package/dist/applications/createCreateTestToken.js +77 -0
- package/dist/applications/types.d.ts +3 -1
- package/dist/core/services.d.ts +3 -0
- package/dist/core/services.js +2 -1
- package/dist/core/testTokenConfig.d.ts +21 -0
- package/dist/core/testTokenConfig.js +12 -0
- package/dist/envs.d.ts +1 -0
- package/dist/envs.js +4 -2
- package/package.json +10 -10
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Prisma } from "../core/db";
|
|
2
|
-
|
|
2
|
+
import { TestTokenConfiguration } from "./types";
|
|
3
|
+
declare function buildService(prisma: Prisma, testTokenConfig: TestTokenConfiguration): {
|
|
3
4
|
definition: {
|
|
4
5
|
serviceName: string;
|
|
5
6
|
pckg: string;
|
|
@@ -25,6 +26,9 @@ declare function buildService(prisma: Prisma): {
|
|
|
25
26
|
evaluateIntelligence: (call: {
|
|
26
27
|
request: unknown;
|
|
27
28
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
29
|
+
createTestToken: (call: {
|
|
30
|
+
request: unknown;
|
|
31
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
28
32
|
};
|
|
29
33
|
};
|
|
30
34
|
export { buildService };
|
|
@@ -23,11 +23,12 @@ const autopilot_1 = require("@fonoster/autopilot");
|
|
|
23
23
|
const envs_1 = require("../envs");
|
|
24
24
|
const getIntegrationsFromFile_1 = require("../utils/getIntegrationsFromFile");
|
|
25
25
|
const createCreateApplication_1 = require("./createCreateApplication");
|
|
26
|
+
const createCreateTestToken_1 = require("./createCreateTestToken");
|
|
26
27
|
const createDeleteApplication_1 = require("./createDeleteApplication");
|
|
27
28
|
const createGetApplication_1 = require("./createGetApplication");
|
|
28
29
|
const createListApplications_1 = require("./createListApplications");
|
|
29
30
|
const createUpdateApplication_1 = require("./createUpdateApplication");
|
|
30
|
-
function buildService(prisma) {
|
|
31
|
+
function buildService(prisma, testTokenConfig) {
|
|
31
32
|
const integrations = (0, getIntegrationsFromFile_1.getIntegrationsFromFile)(envs_1.INTEGRATIONS_FILE);
|
|
32
33
|
return {
|
|
33
34
|
definition: {
|
|
@@ -42,7 +43,8 @@ function buildService(prisma) {
|
|
|
42
43
|
listApplications: (0, createListApplications_1.createListApplications)(prisma),
|
|
43
44
|
deleteApplication: (0, createDeleteApplication_1.createDeleteApplication)(prisma),
|
|
44
45
|
updateApplication: (0, createUpdateApplication_1.createUpdateApplication)(prisma),
|
|
45
|
-
evaluateIntelligence: (0, autopilot_1.createEvaluateIntelligence)(integrations)
|
|
46
|
+
evaluateIntelligence: (0, autopilot_1.createEvaluateIntelligence)(integrations),
|
|
47
|
+
createTestToken: (0, createCreateTestToken_1.createCreateTestToken)(testTokenConfig)
|
|
46
48
|
}
|
|
47
49
|
};
|
|
48
50
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { GrpcErrorMessage } from "@fonoster/common";
|
|
20
|
+
import { TestTokenConfiguration } from "./types";
|
|
21
|
+
declare function createCreateTestToken(config: TestTokenConfiguration): (call: {
|
|
22
|
+
request: unknown;
|
|
23
|
+
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
24
|
+
export { createCreateTestToken };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createCreateTestToken = createCreateTestToken;
|
|
16
|
+
/**
|
|
17
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
18
|
+
* http://github.com/fonoster/fonoster
|
|
19
|
+
*
|
|
20
|
+
* This file is part of Fonoster
|
|
21
|
+
*
|
|
22
|
+
* Licensed under the MIT License (the "License");
|
|
23
|
+
* you may not use this file except in compliance with
|
|
24
|
+
* the License. You may obtain a copy of the License at
|
|
25
|
+
*
|
|
26
|
+
* https://opensource.org/licenses/MIT
|
|
27
|
+
*
|
|
28
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
+
* See the License for the specific language governing permissions and
|
|
32
|
+
* limitations under the License.
|
|
33
|
+
*/
|
|
34
|
+
const common_1 = require("@fonoster/common");
|
|
35
|
+
const logger_1 = require("@fonoster/logger");
|
|
36
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
37
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
38
|
+
const uuid_1 = require("uuid");
|
|
39
|
+
const envs_1 = require("../envs");
|
|
40
|
+
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
41
|
+
function createCreateTestToken(config) {
|
|
42
|
+
const createApplication = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
|
|
44
|
+
logger.verbose("call to createTestToken", {
|
|
45
|
+
accessKeyId
|
|
46
|
+
});
|
|
47
|
+
// Build payload
|
|
48
|
+
const payload = {
|
|
49
|
+
ref: (0, uuid_1.v4)(),
|
|
50
|
+
domain: config.domain,
|
|
51
|
+
displayName: config.displayName,
|
|
52
|
+
signalingServer: config.signalingServer,
|
|
53
|
+
targetAor: config.targetAor,
|
|
54
|
+
username: config.username,
|
|
55
|
+
accessKeyId,
|
|
56
|
+
aorLink: config.targetAor,
|
|
57
|
+
privacy: "NONE",
|
|
58
|
+
allowedMethods: ["INVITE"]
|
|
59
|
+
};
|
|
60
|
+
// Sign JWT
|
|
61
|
+
let token;
|
|
62
|
+
try {
|
|
63
|
+
token = jsonwebtoken_1.default.sign(payload, envs_1.IDENTITY_PRIVATE_KEY, {
|
|
64
|
+
expiresIn: "1h",
|
|
65
|
+
algorithm: "RS256"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
logger.error("failed to sign JWT", { error: err });
|
|
70
|
+
callback({ code: grpc_js_1.status.INTERNAL, message: "Failed to sign JWT" });
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const response = Object.assign({ token }, config);
|
|
74
|
+
callback(null, response);
|
|
75
|
+
});
|
|
76
|
+
return (0, common_1.withErrorHandling)(createApplication);
|
|
77
|
+
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { CreateTestTokenResponse } from "@fonoster/types";
|
|
19
20
|
import { ApplicationType } from "@prisma/client";
|
|
20
21
|
type ApplicationData = {
|
|
21
22
|
ref?: string;
|
|
@@ -42,4 +43,5 @@ type ApplicationData = {
|
|
|
42
43
|
};
|
|
43
44
|
};
|
|
44
45
|
};
|
|
45
|
-
|
|
46
|
+
type TestTokenConfiguration = Omit<CreateTestTokenResponse, "token">;
|
|
47
|
+
export { ApplicationData, TestTokenConfiguration };
|
package/dist/core/services.d.ts
CHANGED
|
@@ -24,6 +24,9 @@ declare const services: Promise<[{
|
|
|
24
24
|
evaluateIntelligence: (call: {
|
|
25
25
|
request: unknown;
|
|
26
26
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
27
|
+
createTestToken: (call: {
|
|
28
|
+
request: unknown;
|
|
29
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
27
30
|
};
|
|
28
31
|
}, {
|
|
29
32
|
definition: {
|
package/dist/core/services.js
CHANGED
|
@@ -29,7 +29,8 @@ const buildWelcomeDemoService_1 = require("./buildWelcomeDemoService");
|
|
|
29
29
|
const db_1 = require("./db");
|
|
30
30
|
const identityConfig_1 = require("./identityConfig");
|
|
31
31
|
const routrConfig_1 = require("./routrConfig");
|
|
32
|
-
const
|
|
32
|
+
const testTokenConfig_1 = require("./testTokenConfig");
|
|
33
|
+
const applicationsService = (0, applications_1.buildApplicationsService)(db_1.prisma, testTokenConfig_1.testTokenConfig);
|
|
33
34
|
const secretsService = (0, secrets_1.buildSecretsService)(db_1.prisma);
|
|
34
35
|
const callsService = (0, calls_1.buildCallsService)(influxdb_1.influxdb);
|
|
35
36
|
const identityService = (0, identity_1.buildIdentityService)(identityConfig_1.identityConfig);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { TestTokenConfiguration } from "../applications/types";
|
|
20
|
+
declare const testTokenConfig: TestTokenConfiguration;
|
|
21
|
+
export { testTokenConfig };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.testTokenConfig = void 0;
|
|
4
|
+
const envs_1 = require("../envs");
|
|
5
|
+
const testTokenConfig = {
|
|
6
|
+
username: "internal",
|
|
7
|
+
domain: "internal",
|
|
8
|
+
displayName: "Test Call Agent",
|
|
9
|
+
targetAor: "sip:voice@default",
|
|
10
|
+
signalingServer: envs_1.APISERVER_SIGNALING_SERVER
|
|
11
|
+
};
|
|
12
|
+
exports.testTokenConfig = testTokenConfig;
|
package/dist/envs.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const APISERVER_BIND_ADDR: string;
|
|
2
2
|
export declare const APISERVER_HOST: string;
|
|
3
|
+
export declare const APISERVER_SIGNALING_SERVER: string;
|
|
3
4
|
export declare const APP_URL: string;
|
|
4
5
|
export declare const ASTERISK_ARI_PROXY_URL: string;
|
|
5
6
|
export declare const ASTERISK_ARI_SECRET: string;
|
package/dist/envs.js
CHANGED
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
8
|
-
exports.TWILIO_PHONE_NUMBER = exports.TWILIO_AUTH_TOKEN = exports.TWILIO_ACCOUNT_SID = exports.TEMPLATES_DIR = exports.SMTP_SENDER = exports.SMTP_SECURE = exports.SMTP_PORT = exports.SMTP_HOST = void 0;
|
|
7
|
+
exports.SMTP_AUTH_PASS = exports.ROUTR_DEFAULT_PEER_USERNAME = exports.ROUTR_DEFAULT_PEER_PASSWORD = exports.ROUTR_DEFAULT_PEER_NAME = exports.ROUTR_DEFAULT_PEER_AOR = exports.ROUTR_API_ENDPOINT = exports.OWNER_PASSWORD = exports.OWNER_NAME = exports.OWNER_EMAIL = exports.NATS_URL = exports.INTEGRATIONS_FILE = exports.INFLUXDB_USERNAME = exports.INFLUXDB_URL = exports.INFLUXDB_TOKEN = exports.INFLUXDB_PASSWORD = exports.INFLUXDB_ORG = exports.AUTHZ_SERVICE_METHODS = exports.AUTHZ_SERVICE_PORT = exports.AUTHZ_SERVICE_HOST = exports.AUTHZ_SERVICE_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.CLOAK_ENCRYPTION_KEY = exports.CALLS_TRACK_CALL_SUBJECT = exports.CALLS_CREATE_SUBJECT = exports.ASTERISK_TRUNK = exports.ASTERISK_SYSTEM_DOMAIN = exports.ASTERISK_ARI_USERNAME = exports.ASTERISK_ARI_SECRET = exports.ASTERISK_ARI_PROXY_URL = exports.APP_URL = exports.APISERVER_SIGNALING_SERVER = exports.APISERVER_HOST = exports.APISERVER_BIND_ADDR = void 0;
|
|
8
|
+
exports.TWILIO_PHONE_NUMBER = exports.TWILIO_AUTH_TOKEN = exports.TWILIO_ACCOUNT_SID = exports.TEMPLATES_DIR = exports.SMTP_SENDER = exports.SMTP_SECURE = exports.SMTP_PORT = exports.SMTP_HOST = exports.SMTP_AUTH_USER = void 0;
|
|
9
9
|
/**
|
|
10
10
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
11
11
|
* http://github.com/fonoster/fonoster
|
|
@@ -34,6 +34,7 @@ if (process.env.NODE_ENV === "development") {
|
|
|
34
34
|
const e = process.env;
|
|
35
35
|
(0, common_1.assertEnvsAreSet)([
|
|
36
36
|
"APISERVER_APP_URL",
|
|
37
|
+
"APISERVER_SIGNALING_SERVER",
|
|
37
38
|
"APISERVER_ASTERISK_ARI_PROXY_URL",
|
|
38
39
|
"APISERVER_ASTERISK_ARI_USERNAME",
|
|
39
40
|
"APISERVER_ASTERISK_ARI_SECRET",
|
|
@@ -58,6 +59,7 @@ const IDENTITY_PRIVATE_KEY_PATH = e.APISERVER_IDENTITY_PRIVATE_KEY_PATH || "/opt
|
|
|
58
59
|
const IDENTITY_PUBLIC_KEY_PATH = e.APISERVER_IDENTITY_PUBLIC_KEY_PATH || "/opt/fonoster/keys/public.pem";
|
|
59
60
|
exports.APISERVER_BIND_ADDR = e.APISERVER_BIND_ADDR || "0.0.0.0:50051";
|
|
60
61
|
exports.APISERVER_HOST = e.APISERVER_HOST || "apiserver";
|
|
62
|
+
exports.APISERVER_SIGNALING_SERVER = e.APISERVER_SIGNALING_SERVER;
|
|
61
63
|
// Frontend configurations
|
|
62
64
|
exports.APP_URL = e.APISERVER_APP_URL;
|
|
63
65
|
exports.ASTERISK_ARI_PROXY_URL = e.APISERVER_ASTERISK_ARI_PROXY_URL;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/apiserver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "APIServer for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@deepgram/sdk": "^3.5.1",
|
|
24
|
-
"@fonoster/authz": "^0.
|
|
25
|
-
"@fonoster/autopilot": "^0.
|
|
26
|
-
"@fonoster/common": "^0.
|
|
27
|
-
"@fonoster/identity": "^0.
|
|
28
|
-
"@fonoster/logger": "^0.
|
|
29
|
-
"@fonoster/sipnet": "^0.
|
|
30
|
-
"@fonoster/streams": "^0.
|
|
31
|
-
"@fonoster/types": "^0.
|
|
24
|
+
"@fonoster/authz": "^0.15.1",
|
|
25
|
+
"@fonoster/autopilot": "^0.15.1",
|
|
26
|
+
"@fonoster/common": "^0.15.1",
|
|
27
|
+
"@fonoster/identity": "^0.15.1",
|
|
28
|
+
"@fonoster/logger": "^0.15.1",
|
|
29
|
+
"@fonoster/sipnet": "^0.15.1",
|
|
30
|
+
"@fonoster/streams": "^0.15.1",
|
|
31
|
+
"@fonoster/types": "^0.15.1",
|
|
32
32
|
"@google-cloud/speech": "^6.6.0",
|
|
33
33
|
"@google-cloud/text-to-speech": "^5.3.0",
|
|
34
34
|
"@grpc/grpc-js": "~1.10.6",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"@types/uuid": "^10.0.0",
|
|
75
75
|
"@types/validator": "^13.12.0"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "4e27c619e3b47300465b5f0ba0036d397aef2b17"
|
|
78
78
|
}
|