@fonoster/common 0.27.0 → 0.31.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/{voice/PlayDtmf.d.ts → agents/index.d.ts} +3 -5
- package/dist/{assistants → agents}/index.js +2 -6
- package/dist/agents/sessionAgentSchema.d.ts +755 -0
- package/dist/agents/sessionAgentSchema.js +117 -0
- package/dist/{voice/Dial.d.ts → calls/index.d.ts} +16 -13
- package/dist/calls/index.js +44 -0
- package/dist/cellsecrets/index.d.ts +91 -0
- package/dist/cellsecrets/index.js +299 -0
- package/dist/config/cli/check.d.ts +6 -0
- package/dist/config/cli/check.js +202 -0
- package/dist/config/cli/envFile.d.ts +23 -0
- package/dist/config/cli/envFile.js +81 -0
- package/dist/config/cli/exposure.d.ts +10 -0
- package/dist/config/cli/exposure.js +93 -0
- package/dist/config/cli/index.d.ts +2 -0
- package/dist/{identity/tokenHasAccessKeyId.js → config/cli/index.js} +7 -8
- package/dist/config/cli/info.d.ts +6 -0
- package/dist/config/cli/info.js +62 -0
- package/dist/config/cli/init.d.ts +9 -0
- package/dist/config/cli/init.js +152 -0
- package/dist/config/cli/main.d.ts +11 -0
- package/dist/config/cli/main.js +155 -0
- package/dist/config/cli/render.d.ts +44 -0
- package/dist/config/cli/render.js +129 -0
- package/dist/config/cli/secrets.d.ts +21 -0
- package/dist/config/cli/secrets.js +117 -0
- package/dist/config/cli/types.d.ts +24 -0
- package/dist/config/cli/types.js +7 -0
- package/dist/{assistants/index.d.ts → config/configHints.d.ts} +8 -7
- package/dist/config/configHints.js +47 -0
- package/dist/{voice → config}/index.d.ts +11 -13
- package/dist/{voice → config}/index.js +11 -13
- package/dist/config/interpolateEnv.d.ts +34 -0
- package/dist/config/interpolateEnv.js +70 -0
- package/dist/config/loadServiceConfig.d.ts +28 -0
- package/dist/config/loadServiceConfig.js +112 -0
- package/dist/config/logsSchema.d.ts +76 -0
- package/dist/config/logsSchema.js +49 -0
- package/dist/config/natsConnection.d.ts +53 -0
- package/dist/config/natsConnection.js +58 -0
- package/dist/config/parseConfigFile.d.ts +7 -0
- package/dist/config/parseConfigFile.js +60 -0
- package/dist/config/resolveConfigFile.d.ts +17 -0
- package/dist/config/resolveConfigFile.js +54 -0
- package/dist/config/resolveSecretRefs.d.ts +35 -0
- package/dist/config/resolveSecretRefs.js +129 -0
- package/dist/{assistants/audioFiltersSchema.d.ts → config/strictDeep.d.ts} +9 -12
- package/dist/config/strictDeep.js +58 -0
- package/dist/config/telemetrySchema.d.ts +39 -0
- package/dist/config/telemetrySchema.js +44 -0
- package/dist/config/toJsonSchema.d.ts +30 -0
- package/dist/config/toJsonSchema.js +161 -0
- package/dist/constants.d.ts +1 -6
- package/dist/constants.js +4 -7
- package/dist/envs.d.ts +2 -1
- package/dist/envs.js +13 -11
- package/dist/errors/handleZodError.js +3 -1
- package/dist/filters/index.d.ts +70 -0
- package/dist/filters/index.js +101 -0
- package/dist/identity/createAuthInterceptor.d.ts +9 -2
- package/dist/identity/createAuthInterceptor.js +36 -30
- package/dist/identity/hasAccess.d.ts +9 -3
- package/dist/identity/hasAccess.js +32 -8
- package/dist/identity/index.d.ts +1 -0
- package/dist/identity/index.js +1 -0
- package/dist/identity/isValidToken.d.ts +12 -2
- package/dist/identity/isValidToken.js +25 -9
- package/dist/identity/roles.js +33 -7
- package/dist/identity/types.d.ts +6 -1
- package/dist/identity/types.js +1 -0
- package/dist/{assistants/LanguageModelProvider.js → identity/verifyAccessToken.d.ts} +10 -11
- package/dist/identity/verifyAccessToken.js +44 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.js +18 -3
- package/dist/net/assertPublicDestination.d.ts +52 -0
- package/dist/net/assertPublicDestination.js +342 -0
- package/dist/{voice/StopSay.d.ts → net/index.d.ts} +1 -6
- package/dist/net/index.js +35 -0
- package/dist/notifications/createSendEmail.js +3 -1
- package/dist/protos/applications.proto +138 -3
- package/dist/protos/authz.proto +26 -4
- package/dist/protos/billing.proto +92 -0
- package/dist/protos/calls.proto +4 -0
- package/dist/protos/capabilities.proto +102 -0
- package/dist/protos/identity.proto +26 -1
- package/dist/protos/providers.proto +139 -0
- package/dist/protos/roomr.proto +146 -0
- package/dist/protos/session.proto +194 -0
- package/dist/protos/usage.proto +59 -0
- package/dist/protos/webhooks.proto +140 -0
- package/dist/{utils/types.d.ts → regions/hub/index.d.ts} +1 -5
- package/dist/regions/hub/index.js +35 -0
- package/dist/regions/hub/natsJwt.d.ts +63 -0
- package/dist/regions/hub/natsJwt.js +195 -0
- package/dist/registry/Registry.d.ts +87 -0
- package/dist/registry/Registry.js +432 -0
- package/dist/registry/cli.d.ts +20 -0
- package/dist/registry/cli.js +436 -0
- package/dist/registry/features.d.ts +31 -0
- package/dist/registry/features.js +38 -0
- package/dist/registry/index.d.ts +24 -0
- package/dist/registry/index.js +40 -0
- package/dist/registry/prisma.d.ts +67 -0
- package/dist/registry/prisma.js +399 -0
- package/dist/registry/stores.d.ts +21 -0
- package/dist/{assistants/languageModelConfigSchema.js → registry/stores.js} +55 -38
- package/dist/registry/types.d.ts +110 -0
- package/dist/{assistants/LanguageModelProvider.d.ts → registry/types.js} +6 -8
- package/dist/registry/workspaceKeys.d.ts +41 -0
- package/dist/registry/workspaceKeys.js +64 -0
- package/dist/roomr/health.d.ts +9 -0
- package/dist/{assistants/eventsHookSchema.js → roomr/health.js} +22 -18
- package/dist/roomr/index.d.ts +75 -0
- package/dist/roomr/index.js +146 -0
- package/dist/roomr/session.d.ts +133 -0
- package/dist/roomr/session.js +132 -0
- package/dist/session/index.d.ts +19 -0
- package/dist/session/index.js +35 -0
- package/dist/session/schema.d.ts +2140 -0
- package/dist/session/schema.js +448 -0
- package/dist/sessions/index.d.ts +96 -0
- package/dist/sessions/index.js +197 -0
- package/dist/telemetry.d.ts +76 -0
- package/dist/telemetry.js +360 -0
- package/dist/types.d.ts +3 -5
- package/dist/{voice/Gather.d.ts → usage/CallUsage.d.ts} +19 -18
- package/dist/usage/CallUsage.js +76 -0
- package/dist/usage/index.d.ts +22 -0
- package/dist/usage/index.js +38 -0
- package/dist/usage/meters.d.ts +113 -0
- package/dist/usage/meters.js +90 -0
- package/dist/usage/types.d.ts +159 -0
- package/dist/usage/types.js +84 -0
- package/dist/usage/usageId.d.ts +6 -0
- package/dist/usage/usageId.js +45 -0
- package/dist/utils/{findIntegrationsCredentials.js → WriteBehind.d.ts} +13 -10
- package/dist/utils/WriteBehind.js +64 -0
- package/dist/utils/index.d.ts +1 -3
- package/dist/utils/index.js +1 -3
- package/dist/utils/{createFetchSingleCallByCallId.d.ts → logUnhandledRejections.d.ts} +8 -4
- package/dist/{assistants/audioFiltersSchema.js → utils/logUnhandledRejections.js} +17 -12
- package/dist/utils/withErrorHandling.js +1 -1
- package/dist/validators/calls.d.ts +3 -0
- package/dist/validators/calls.js +12 -2
- package/dist/validators/identity.d.ts +37 -8
- package/dist/validators/identity.js +22 -3
- package/dist/validators/index.d.ts +1 -0
- package/dist/validators/index.js +1 -0
- package/dist/validators/sip.d.ts +40 -0
- package/dist/validators/sip.js +99 -0
- package/dist/validators/sipnet/credentials.d.ts +2 -2
- package/dist/validators/sipnet/domains.js +7 -7
- package/dist/validators/sipnet/trunks.d.ts +14 -14
- package/dist/validators/sipnet/trunks.js +4 -2
- package/dist/webhooks/Dispatcher.d.ts +87 -0
- package/dist/webhooks/Dispatcher.js +225 -0
- package/dist/webhooks/bus.d.ts +68 -0
- package/dist/webhooks/bus.js +178 -0
- package/dist/webhooks/events.d.ts +66 -0
- package/dist/webhooks/events.js +62 -0
- package/dist/webhooks/index.d.ts +23 -0
- package/dist/webhooks/index.js +39 -0
- package/dist/webhooks/prisma.d.ts +55 -0
- package/dist/webhooks/prisma.js +242 -0
- package/dist/webhooks/signing.d.ts +8 -0
- package/dist/webhooks/signing.js +53 -0
- package/package.json +25 -11
- package/schema/session.v1.json +871 -0
- package/dist/assistants/assistantSchema.d.ts +0 -739
- package/dist/assistants/assistantSchema.js +0 -37
- package/dist/assistants/conversationSettingsSchema.d.ts +0 -122
- package/dist/assistants/conversationSettingsSchema.js +0 -133
- package/dist/assistants/eventsHookSchema.d.ts +0 -38
- package/dist/assistants/languageModelConfigSchema.d.ts +0 -206
- package/dist/identity/tokenHasAccessKeyId.d.ts +0 -2
- package/dist/protos/voice.proto +0 -557
- package/dist/utils/createFetchSingleCallByCallId.js +0 -33
- package/dist/utils/findIntegrationsCredentials.d.ts +0 -23
- package/dist/utils/types.js +0 -2
- package/dist/voice/Dial.js +0 -20
- package/dist/voice/Gather.js +0 -9
- package/dist/voice/Mute.d.ts +0 -31
- package/dist/voice/Mute.js +0 -9
- package/dist/voice/Play.d.ts +0 -30
- package/dist/voice/Play.js +0 -2
- package/dist/voice/PlayDtmf.js +0 -2
- package/dist/voice/PlaybackControl.d.ts +0 -31
- package/dist/voice/PlaybackControl.js +0 -11
- package/dist/voice/Record.d.ts +0 -36
- package/dist/voice/Record.js +0 -7
- package/dist/voice/Say.d.ts +0 -28
- package/dist/voice/Say.js +0 -2
- package/dist/voice/StopSay.js +0 -2
- package/dist/voice/Stream.d.ts +0 -53
- package/dist/voice/Stream.js +0 -19
- package/dist/voice/StreamGather.d.ts +0 -34
- package/dist/voice/StreamGather.js +0 -9
- package/dist/voice/Verb.d.ts +0 -27
- package/dist/voice/Verb.js +0 -2
- package/dist/voice/voice.d.ts +0 -171
- package/dist/voice/voice.js +0 -65
- package/dist/{assistants → agents}/testCasesSchema.d.ts +4 -4
- /package/dist/{assistants → agents}/testCasesSchema.js +0 -0
- /package/dist/{assistants → agents}/tools/index.d.ts +0 -0
- /package/dist/{assistants → agents}/tools/index.js +0 -0
- /package/dist/{assistants → agents}/tools/propertySchema.d.ts +0 -0
- /package/dist/{assistants → agents}/tools/propertySchema.js +0 -0
- /package/dist/{assistants → agents}/tools/toolSchema.d.ts +0 -0
- /package/dist/{assistants → agents}/tools/toolSchema.js +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AudioFilterConfigError = exports.audioFilterConfigSchema = exports.FILTER_NAMES = exports.FILTER_BY_PROVIDER = exports.FILTER_SCHEMAS = exports.aiCousticsPublicOptionsSchema = exports.AI_COUSTICS_FILTER = void 0;
|
|
4
|
+
exports.providerOfFilter = providerOfFilter;
|
|
5
|
+
exports.parseFilters = parseFilters;
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
8
|
+
* http://github.com/fonoster/fonoster
|
|
9
|
+
*
|
|
10
|
+
* This file is part of Fonoster
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the MIT License (the "License");
|
|
13
|
+
* you may not use this file except in compliance with
|
|
14
|
+
* the License. You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* https://opensource.org/licenses/MIT
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
const zod_1 = require("zod");
|
|
25
|
+
/**
|
|
26
|
+
* The audio filters an app may configure (voice-session, "An app's audio filters are set through
|
|
27
|
+
* the Applications API"). Apps are untrusted input, so each filter exposes a public option schema
|
|
28
|
+
* here, shared by the apiserver (validation on write) and the appbridge (the filter factory).
|
|
29
|
+
* Anything that touches the media server's filesystem, environment or credentials stays out.
|
|
30
|
+
*/
|
|
31
|
+
exports.AI_COUSTICS_FILTER = "aiCoustics";
|
|
32
|
+
/** The ai-coustics filter's public options. */
|
|
33
|
+
exports.aiCousticsPublicOptionsSchema = zod_1.z
|
|
34
|
+
.object({
|
|
35
|
+
// The vendor's model id; restricted to its shape so it cannot name a path
|
|
36
|
+
model: zod_1.z
|
|
37
|
+
.string()
|
|
38
|
+
.regex(/^[a-z0-9]+(-[a-z0-9.]+)*$/, { message: "Invalid model name" })
|
|
39
|
+
.default("quail-vf-2.2-s-16khz"),
|
|
40
|
+
// Higher values suppress more, competing speech included
|
|
41
|
+
enhancementLevel: zod_1.z.number().min(0).max(1).default(1),
|
|
42
|
+
// Keeps the delay but stops enhancing (for A/B tests)
|
|
43
|
+
bypass: zod_1.z.boolean().default(false)
|
|
44
|
+
})
|
|
45
|
+
// Reject anything else outright, so a server-only option (or a key) is refused, not ignored
|
|
46
|
+
.strict();
|
|
47
|
+
/** Public option schemas by filter name. */
|
|
48
|
+
exports.FILTER_SCHEMAS = {
|
|
49
|
+
[exports.AI_COUSTICS_FILTER]: exports.aiCousticsPublicOptionsSchema
|
|
50
|
+
};
|
|
51
|
+
/** The filter a noise-cancelling (`nc`) provider runs, by provider id. */
|
|
52
|
+
exports.FILTER_BY_PROVIDER = {
|
|
53
|
+
aicoustics: exports.AI_COUSTICS_FILTER
|
|
54
|
+
};
|
|
55
|
+
exports.FILTER_NAMES = Object.keys(exports.FILTER_SCHEMAS);
|
|
56
|
+
/** The `nc` provider whose credential a filter runs with, or undefined for a filter without one. */
|
|
57
|
+
function providerOfFilter(name) {
|
|
58
|
+
var _a;
|
|
59
|
+
return (_a = Object.entries(exports.FILTER_BY_PROVIDER).find(([, f]) => f === name)) === null || _a === void 0 ? void 0 : _a[0];
|
|
60
|
+
}
|
|
61
|
+
exports.audioFilterConfigSchema = zod_1.z
|
|
62
|
+
.object({
|
|
63
|
+
name: zod_1.z.string().min(1),
|
|
64
|
+
options: zod_1.z.record(zod_1.z.unknown()).optional()
|
|
65
|
+
})
|
|
66
|
+
.strict();
|
|
67
|
+
class AudioFilterConfigError extends Error {
|
|
68
|
+
constructor(message) {
|
|
69
|
+
super(message);
|
|
70
|
+
this.name = "AudioFilterConfigError";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.AudioFilterConfigError = AudioFilterConfigError;
|
|
74
|
+
/**
|
|
75
|
+
* Validates an app's `filters` list: known names and public options only. Returns the list with
|
|
76
|
+
* each filter's options as given (defaults are applied by the filter itself). Throws
|
|
77
|
+
* AudioFilterConfigError naming the first offending filter or option.
|
|
78
|
+
*/
|
|
79
|
+
function parseFilters(input) {
|
|
80
|
+
const list = zod_1.z.array(exports.audioFilterConfigSchema).safeParse(input);
|
|
81
|
+
if (!list.success) {
|
|
82
|
+
throw new AudioFilterConfigError(`filters must be a list of { name, options? }: ${issues(list.error)}`);
|
|
83
|
+
}
|
|
84
|
+
return list.data.map((f) => {
|
|
85
|
+
var _a;
|
|
86
|
+
const schema = exports.FILTER_SCHEMAS[f.name];
|
|
87
|
+
if (!schema) {
|
|
88
|
+
throw new AudioFilterConfigError(`unknown audio filter "${f.name}" (known: ${exports.FILTER_NAMES.join(", ")})`);
|
|
89
|
+
}
|
|
90
|
+
const parsed = schema.safeParse((_a = f.options) !== null && _a !== void 0 ? _a : {});
|
|
91
|
+
if (!parsed.success) {
|
|
92
|
+
throw new AudioFilterConfigError(`invalid options for audio filter "${f.name}": ${issues(parsed.error)}`);
|
|
93
|
+
}
|
|
94
|
+
return f.options ? { name: f.name, options: f.options } : { name: f.name };
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function issues(error) {
|
|
98
|
+
return error.issues
|
|
99
|
+
.map((i) => i.path.length ? `${i.path.join(".")}: ${i.message}` : i.message)
|
|
100
|
+
.join("; ");
|
|
101
|
+
}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { ServerInterceptingCall } from "@grpc/grpc-js";
|
|
2
|
+
import { TokenVerifyOptions } from "./isValidToken";
|
|
2
3
|
/**
|
|
3
4
|
* This function is a gRPC interceptor that checks if the request is valid
|
|
4
5
|
* and if the user has the right permissions to access the resource. When
|
|
5
6
|
* validating the request, the function will check if the request is in the
|
|
6
|
-
* skip list, if the token is valid
|
|
7
|
+
* skip list, if the token is a valid access token (RS256, unexpired,
|
|
8
|
+
* `tokenUse: "access"`, and the pinned issuer and audience when given) and if
|
|
9
|
+
* the caller's role in the target workspace is allowed by the RBAC.
|
|
10
|
+
*
|
|
11
|
+
* It fails closed: any error while checking a request answers
|
|
12
|
+
* UNAUTHENTICATED instead of reaching the handler or throwing.
|
|
7
13
|
*
|
|
8
14
|
* @param {string} identityPublicKey - The public key to validate the token
|
|
9
15
|
* @param {string[]} publicPath - The list of public paths
|
|
16
|
+
* @param {TokenVerifyOptions} options - Issuer and audience to pin
|
|
10
17
|
* @return {Function} - The gRPC interceptor
|
|
11
18
|
*/
|
|
12
|
-
declare function createAuthInterceptor(identityPublicKey: string, publicPath: string[]): (methodDefinition: {
|
|
19
|
+
declare function createAuthInterceptor(identityPublicKey: string, publicPath: string[], options?: TokenVerifyOptions): (methodDefinition: {
|
|
13
20
|
path: string;
|
|
14
21
|
}, call: ServerInterceptingCall) => ServerInterceptingCall;
|
|
15
22
|
export { createAuthInterceptor };
|
|
@@ -20,26 +20,29 @@ exports.createAuthInterceptor = createAuthInterceptor;
|
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
22
|
const logger_1 = require("@fonoster/logger");
|
|
23
|
-
const decodeToken_1 = require("./decodeToken");
|
|
24
23
|
const errors_1 = require("./errors");
|
|
25
24
|
const getAccessKeyIdFromCall_1 = require("./getAccessKeyIdFromCall");
|
|
26
25
|
const getTokenFromCall_1 = require("./getTokenFromCall");
|
|
27
26
|
const hasAccess_1 = require("./hasAccess");
|
|
28
|
-
const
|
|
29
|
-
const roles_1 = require("./roles");
|
|
30
|
-
const tokenHasAccessKeyId_1 = require("./tokenHasAccessKeyId");
|
|
27
|
+
const verifyAccessToken_1 = require("./verifyAccessToken");
|
|
31
28
|
const logger = (0, logger_1.getLogger)({ service: "common", filePath: __filename });
|
|
32
29
|
/**
|
|
33
30
|
* This function is a gRPC interceptor that checks if the request is valid
|
|
34
31
|
* and if the user has the right permissions to access the resource. When
|
|
35
32
|
* validating the request, the function will check if the request is in the
|
|
36
|
-
* skip list, if the token is valid
|
|
33
|
+
* skip list, if the token is a valid access token (RS256, unexpired,
|
|
34
|
+
* `tokenUse: "access"`, and the pinned issuer and audience when given) and if
|
|
35
|
+
* the caller's role in the target workspace is allowed by the RBAC.
|
|
36
|
+
*
|
|
37
|
+
* It fails closed: any error while checking a request answers
|
|
38
|
+
* UNAUTHENTICATED instead of reaching the handler or throwing.
|
|
37
39
|
*
|
|
38
40
|
* @param {string} identityPublicKey - The public key to validate the token
|
|
39
41
|
* @param {string[]} publicPath - The list of public paths
|
|
42
|
+
* @param {TokenVerifyOptions} options - Issuer and audience to pin
|
|
40
43
|
* @return {Function} - The gRPC interceptor
|
|
41
44
|
*/
|
|
42
|
-
function createAuthInterceptor(identityPublicKey, publicPath) {
|
|
45
|
+
function createAuthInterceptor(identityPublicKey, publicPath, options = {}) {
|
|
43
46
|
/**
|
|
44
47
|
* Inner function that will be called by the gRPC server.
|
|
45
48
|
*
|
|
@@ -49,33 +52,36 @@ function createAuthInterceptor(identityPublicKey, publicPath) {
|
|
|
49
52
|
* @return {ServerInterceptingCall} - The modified call object
|
|
50
53
|
*/
|
|
51
54
|
return (methodDefinition, call) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
try {
|
|
56
|
+
const { path } = methodDefinition;
|
|
57
|
+
const accessKeyId = (0, getAccessKeyIdFromCall_1.getAccessKeyIdFromCall)(call);
|
|
58
|
+
logger.verbose("intercepting api call to path", { accessKeyId, path });
|
|
59
|
+
if (publicPath.includes(path)) {
|
|
60
|
+
logger.verbose("passing auth control to edge function", { path });
|
|
61
|
+
return call;
|
|
62
|
+
}
|
|
63
|
+
logger.verbose("validating token", { accessKeyId, path });
|
|
64
|
+
const decodedToken = (0, verifyAccessToken_1.verifyAccessToken)((0, getTokenFromCall_1.getTokenFromCall)(call), identityPublicKey, options);
|
|
65
|
+
if (!decodedToken) {
|
|
66
|
+
return (0, errors_1.unauthenticatedError)(call);
|
|
67
|
+
}
|
|
68
|
+
const allowed = (0, hasAccess_1.hasAccess)(decodedToken, path, accessKeyId);
|
|
69
|
+
logger.verbose("checking access for accessKeyId", {
|
|
70
|
+
accessKeyId,
|
|
71
|
+
path,
|
|
72
|
+
hasAccess: allowed
|
|
73
|
+
});
|
|
74
|
+
if (!allowed) {
|
|
75
|
+
return (0, errors_1.permissionDeniedError)(call);
|
|
76
|
+
}
|
|
57
77
|
return call;
|
|
58
78
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
79
|
+
catch (error) {
|
|
80
|
+
logger.warn("refusing a call that failed the auth check", {
|
|
81
|
+
path: methodDefinition === null || methodDefinition === void 0 ? void 0 : methodDefinition.path,
|
|
82
|
+
error: error === null || error === void 0 ? void 0 : error.message
|
|
83
|
+
});
|
|
62
84
|
return (0, errors_1.unauthenticatedError)(call);
|
|
63
85
|
}
|
|
64
|
-
const decodedToken = (0, decodeToken_1.decodeToken)(token);
|
|
65
|
-
logger.verbose("checking access for accessKeyId", {
|
|
66
|
-
accessKeyId,
|
|
67
|
-
path,
|
|
68
|
-
hasAccess: (0, hasAccess_1.hasAccess)(decodedToken, path),
|
|
69
|
-
pathIsWorkspacePath: roles_1.workspaceResourceAccess.includes(path),
|
|
70
|
-
tokenHasAccessKeyId: (0, tokenHasAccessKeyId_1.tokenHasAccessKeyId)(token, accessKeyId)
|
|
71
|
-
});
|
|
72
|
-
if (!(0, hasAccess_1.hasAccess)(decodedToken, path) ||
|
|
73
|
-
(roles_1.workspaceResourceAccess.includes(path) &&
|
|
74
|
-
!(0, tokenHasAccessKeyId_1.tokenHasAccessKeyId)(token, accessKeyId)) ||
|
|
75
|
-
(roles_1.workspaceResourceOwnerOrAdminAccess.includes(path) &&
|
|
76
|
-
!(0, tokenHasAccessKeyId_1.tokenHasAccessKeyId)(token, accessKeyId))) {
|
|
77
|
-
return (0, errors_1.permissionDeniedError)(call);
|
|
78
|
-
}
|
|
79
|
-
return call;
|
|
80
86
|
};
|
|
81
87
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Access } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Whether the token's roles allow the gRPC method. For a workspace method only
|
|
4
|
+
* the caller's role in the target workspace (`targetAccessKeyId`) counts, never
|
|
5
|
+
* a role held in another workspace; without a matching entry it is refused.
|
|
6
|
+
* Malformed claims are refused rather than thrown on.
|
|
7
|
+
*/
|
|
2
8
|
declare function hasAccess(decodedToken: {
|
|
3
|
-
access
|
|
4
|
-
accessKeyId
|
|
5
|
-
}, method: string): boolean;
|
|
9
|
+
access?: Access[];
|
|
10
|
+
accessKeyId?: string;
|
|
11
|
+
}, method: string, targetAccessKeyId?: string): boolean;
|
|
6
12
|
export { hasAccess };
|
|
@@ -21,12 +21,36 @@ exports.hasAccess = hasAccess;
|
|
|
21
21
|
*/
|
|
22
22
|
const types_1 = require("@fonoster/types");
|
|
23
23
|
const roles_1 = require("./roles");
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
/** Methods that act inside one workspace, named by the request's accessKeyId. */
|
|
25
|
+
const isWorkspaceMethod = (method) => roles_1.workspaceResourceAccess.includes(method) ||
|
|
26
|
+
roles_1.workspaceResourceOwnerOrAdminAccess.includes(method);
|
|
27
|
+
const roleAllows = (roleName, method) => roles_1.roles.some((role) => role.name === roleName && role.access.includes(method));
|
|
28
|
+
/**
|
|
29
|
+
* Whether the token's roles allow the gRPC method. For a workspace method only
|
|
30
|
+
* the caller's role in the target workspace (`targetAccessKeyId`) counts, never
|
|
31
|
+
* a role held in another workspace; without a matching entry it is refused.
|
|
32
|
+
* Malformed claims are refused rather than thrown on.
|
|
33
|
+
*/
|
|
34
|
+
function hasAccess(decodedToken, method, targetAccessKeyId) {
|
|
35
|
+
const access = Array.isArray(decodedToken === null || decodedToken === void 0 ? void 0 : decodedToken.access)
|
|
36
|
+
? decodedToken.access.filter((a) => a && typeof a.role === "string" && typeof a.accessKeyId === "string")
|
|
37
|
+
: [];
|
|
38
|
+
const accessKeyId = typeof (decodedToken === null || decodedToken === void 0 ? void 0 : decodedToken.accessKeyId) === "string"
|
|
39
|
+
? decodedToken.accessKeyId
|
|
40
|
+
: "";
|
|
41
|
+
if (isWorkspaceMethod(method)) {
|
|
42
|
+
if (!targetAccessKeyId) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const entry = access.find((a) => a.accessKeyId === targetAccessKeyId);
|
|
46
|
+
return entry ? roleAllows(entry.role, method) : false;
|
|
47
|
+
}
|
|
48
|
+
// User tokens (accessKeyId "US…") always carry the USER role, so methods
|
|
49
|
+
// about the user themselves (e.g. UpdateUser, CreateWorkspace) keep working
|
|
50
|
+
// once they belong to a workspace. Their workspace roles add to it.
|
|
51
|
+
const workspaceRoles = access.map((a) => a.role);
|
|
52
|
+
const roleList = accessKeyId.startsWith("US")
|
|
53
|
+
? [types_1.Role.USER, ...workspaceRoles]
|
|
54
|
+
: workspaceRoles;
|
|
55
|
+
return roleList.some((r) => roleAllows(r, method));
|
|
32
56
|
}
|
package/dist/identity/index.d.ts
CHANGED
package/dist/identity/index.js
CHANGED
|
@@ -39,5 +39,6 @@ __exportStar(require("./getAccessKeyIdFromCall"), exports);
|
|
|
39
39
|
__exportStar(require("./getTokenFromCall"), exports);
|
|
40
40
|
__exportStar(require("./hasAccess"), exports);
|
|
41
41
|
__exportStar(require("./isValidToken"), exports);
|
|
42
|
+
__exportStar(require("./verifyAccessToken"), exports);
|
|
42
43
|
__exportStar(require("./types"), exports);
|
|
43
44
|
__exportStar(require("./roles"), exports);
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import jwt from "jsonwebtoken";
|
|
2
|
+
/** Identity signs every token with RS256; nothing else is accepted. */
|
|
3
|
+
declare const IDENTITY_SIGN_ALGORITHMS: jwt.Algorithm[];
|
|
4
|
+
/** Claims to pin when verifying; each one is checked only when given. */
|
|
5
|
+
type TokenVerifyOptions = {
|
|
6
|
+
issuer?: string;
|
|
7
|
+
audience?: string;
|
|
8
|
+
};
|
|
9
|
+
/** The verified claims, or undefined when the signature, expiry or claims don't check out. */
|
|
10
|
+
declare function verifyToken(token: string, secret: string, options?: TokenVerifyOptions): Record<string, unknown> | undefined;
|
|
11
|
+
declare function isValidToken(token: string, secret: string, options?: TokenVerifyOptions): boolean;
|
|
12
|
+
export { IDENTITY_SIGN_ALGORITHMS, isValidToken, TokenVerifyOptions, verifyToken };
|
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IDENTITY_SIGN_ALGORITHMS = void 0;
|
|
6
7
|
exports.isValidToken = isValidToken;
|
|
8
|
+
exports.verifyToken = verifyToken;
|
|
7
9
|
/**
|
|
8
10
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
9
11
|
* http://github.com/fonoster/fonoster
|
|
@@ -26,26 +28,40 @@ const logger_1 = require("@fonoster/logger");
|
|
|
26
28
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
27
29
|
const types_1 = require("./types");
|
|
28
30
|
const logger = (0, logger_1.getLogger)({ service: "identity", filePath: __filename });
|
|
29
|
-
|
|
31
|
+
/** Identity signs every token with RS256; nothing else is accepted. */
|
|
32
|
+
const IDENTITY_SIGN_ALGORITHMS = ["RS256"];
|
|
33
|
+
exports.IDENTITY_SIGN_ALGORITHMS = IDENTITY_SIGN_ALGORITHMS;
|
|
34
|
+
/** The verified claims, or undefined when the signature, expiry or claims don't check out. */
|
|
35
|
+
function verifyToken(token, secret, options = {}) {
|
|
36
|
+
if (!token || typeof token !== "string") {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
30
39
|
try {
|
|
31
|
-
const decoded = jsonwebtoken_1.default.verify(token, secret);
|
|
40
|
+
const decoded = jsonwebtoken_1.default.verify(token, secret, Object.assign(Object.assign({ algorithms: IDENTITY_SIGN_ALGORITHMS }, (options.issuer ? { issuer: options.issuer } : {})), (options.audience ? { audience: options.audience } : {})));
|
|
41
|
+
if (!decoded || typeof decoded !== "object") {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const { exp } = decoded;
|
|
32
45
|
const currentTime = Math.floor(Date.now() / 1000);
|
|
33
|
-
if (
|
|
34
|
-
logger.verbose("token expired", { exp
|
|
35
|
-
return
|
|
46
|
+
if (typeof exp !== "number" || exp <= currentTime) {
|
|
47
|
+
logger.verbose("token expired or without expiry", { exp, currentTime });
|
|
48
|
+
return undefined;
|
|
36
49
|
}
|
|
37
|
-
return
|
|
50
|
+
return decoded;
|
|
38
51
|
}
|
|
39
52
|
catch (error) {
|
|
40
53
|
if (error.name === types_1.JsonWebErrorEnum.JsonWebTokenError) {
|
|
41
|
-
logger.verbose("invalid JWT token"
|
|
54
|
+
logger.verbose("invalid JWT token");
|
|
42
55
|
}
|
|
43
56
|
else if (error.name === types_1.JsonWebErrorEnum.TokenExpiredError) {
|
|
44
|
-
logger.verbose("token expired"
|
|
57
|
+
logger.verbose("token expired");
|
|
45
58
|
}
|
|
46
59
|
else {
|
|
47
60
|
logger.verbose("unexpected JWT error:", error);
|
|
48
61
|
}
|
|
49
|
-
return
|
|
62
|
+
return undefined;
|
|
50
63
|
}
|
|
51
64
|
}
|
|
65
|
+
function isValidToken(token, secret, options = {}) {
|
|
66
|
+
return verifyToken(token, secret, options) !== undefined;
|
|
67
|
+
}
|
package/dist/identity/roles.js
CHANGED
|
@@ -30,6 +30,18 @@ const workspaceResourceAccess = [
|
|
|
30
30
|
"/fonoster.applications.v1beta2.Applications/DeleteApplication",
|
|
31
31
|
"/fonoster.applications.v1beta2.Applications/ListApplications",
|
|
32
32
|
"/fonoster.applications.v1beta2.Applications/EvaluateIntelligence",
|
|
33
|
+
"/fonoster.applications.v1beta2.Applications/RotateSigningSecret",
|
|
34
|
+
"/fonoster.webhooks.v1beta2.Webhooks/CreateWebhook",
|
|
35
|
+
"/fonoster.webhooks.v1beta2.Webhooks/ListWebhooks",
|
|
36
|
+
"/fonoster.webhooks.v1beta2.Webhooks/GetWebhook",
|
|
37
|
+
"/fonoster.webhooks.v1beta2.Webhooks/UpdateWebhook",
|
|
38
|
+
"/fonoster.webhooks.v1beta2.Webhooks/DeleteWebhook",
|
|
39
|
+
"/fonoster.webhooks.v1beta2.Webhooks/RotateWebhookSecret",
|
|
40
|
+
"/fonoster.webhooks.v1beta2.Webhooks/ListWebhookDeliveries",
|
|
41
|
+
"/fonoster.webhooks.v1beta2.Webhooks/ResendWebhookDelivery",
|
|
42
|
+
"/fonoster.providers.v1beta2.Providers/ListCatalog",
|
|
43
|
+
"/fonoster.providers.v1beta2.Providers/ListProviderKeys",
|
|
44
|
+
"/fonoster.providers.v1beta2.Providers/ListWarnings",
|
|
33
45
|
"/fonoster.agents.v1beta2.Agents/CreateAgent",
|
|
34
46
|
"/fonoster.agents.v1beta2.Agents/UpdateAgent",
|
|
35
47
|
"/fonoster.agents.v1beta2.Agents/GetAgent",
|
|
@@ -65,24 +77,37 @@ const workspaceResourceAccess = [
|
|
|
65
77
|
"/fonoster.secrets.v1beta2.Secrets/GetSecret",
|
|
66
78
|
"/fonoster.secrets.v1beta2.Secrets/DeleteSecret",
|
|
67
79
|
"/fonoster.secrets.v1beta2.Secrets/ListSecrets",
|
|
80
|
+
"/fonoster.usage.v1beta2.Usage/GetUsage",
|
|
68
81
|
"/fonoster.calls.v1beta2.Calls/CreateCall",
|
|
69
82
|
"/fonoster.calls.v1beta2.Calls/ListCalls",
|
|
70
83
|
"/fonoster.calls.v1beta2.Calls/GetCall",
|
|
71
84
|
"/fonoster.calls.v1beta2.Calls/TrackCall",
|
|
72
|
-
"/fonoster.voice.v1beta2.Voice/CreateSession"
|
|
73
|
-
"/fonoster.identity.v1beta2.Identity/CreateApiKey",
|
|
74
|
-
"/fonoster.identity.v1beta2.Identity/DeleteApiKey",
|
|
75
|
-
"/fonoster.identity.v1beta2.Identity/ListApiKeys",
|
|
76
|
-
"/fonoster.identity.v1beta2.Identity/RegenerateApiKey"
|
|
85
|
+
"/fonoster.voice.v1beta2.Voice/CreateSession"
|
|
77
86
|
];
|
|
78
87
|
exports.workspaceResourceAccess = workspaceResourceAccess;
|
|
79
88
|
const workspaceResourceOwnerOrAdminAccess = [
|
|
89
|
+
// Bring-your-own vendor keys (add-provider-registry P1): owners and admins only.
|
|
90
|
+
"/fonoster.providers.v1beta2.Providers/SetProviderKey",
|
|
91
|
+
"/fonoster.providers.v1beta2.Providers/DeleteProviderKey",
|
|
80
92
|
"/fonoster.identity.v1beta2.Identity/ListWorkspaceMembers",
|
|
81
93
|
"/fonoster.identity.v1beta2.Identity/InviteUserToWorkspace",
|
|
82
94
|
"/fonoster.identity.v1beta2.Identity/RemoveUserFromWorkspace",
|
|
83
|
-
"/fonoster.identity.v1beta2.Identity/ResendWorkspaceMembershipInvitation"
|
|
95
|
+
"/fonoster.identity.v1beta2.Identity/ResendWorkspaceMembershipInvitation",
|
|
96
|
+
// API keys act with WORKSPACE_ADMIN rights, so only owners and admins manage them.
|
|
97
|
+
"/fonoster.identity.v1beta2.Identity/CreateApiKey",
|
|
98
|
+
"/fonoster.identity.v1beta2.Identity/DeleteApiKey",
|
|
99
|
+
"/fonoster.identity.v1beta2.Identity/ListApiKeys",
|
|
100
|
+
"/fonoster.identity.v1beta2.Identity/RegenerateApiKey"
|
|
84
101
|
];
|
|
85
102
|
exports.workspaceResourceOwnerOrAdminAccess = workspaceResourceOwnerOrAdminAccess;
|
|
103
|
+
// Billing belongs to the owner (add-billing-service): only owners see or change it.
|
|
104
|
+
const workspaceOwnerAccess = [
|
|
105
|
+
"/fonoster.billing.v1beta2.Billing/GetBilling",
|
|
106
|
+
"/fonoster.billing.v1beta2.Billing/UpdateAutoRecharge",
|
|
107
|
+
"/fonoster.billing.v1beta2.Billing/CreateTopUp",
|
|
108
|
+
"/fonoster.billing.v1beta2.Billing/Subscribe",
|
|
109
|
+
"/fonoster.billing.v1beta2.Billing/CreatePortalSession"
|
|
110
|
+
];
|
|
86
111
|
const fullIdentityAccess = [
|
|
87
112
|
"/fonoster.identity.v1beta2.Identity/GetUser",
|
|
88
113
|
"/fonoster.identity.v1beta2.Identity/UpdateUser",
|
|
@@ -106,7 +131,8 @@ const roles = [
|
|
|
106
131
|
access: [
|
|
107
132
|
...fullIdentityAccess,
|
|
108
133
|
...workspaceResourceAccess,
|
|
109
|
-
...workspaceResourceOwnerOrAdminAccess
|
|
134
|
+
...workspaceResourceOwnerOrAdminAccess,
|
|
135
|
+
...workspaceOwnerAccess
|
|
110
136
|
]
|
|
111
137
|
},
|
|
112
138
|
{
|
package/dist/identity/types.d.ts
CHANGED
|
@@ -20,7 +20,8 @@ import { Role } from "@fonoster/types";
|
|
|
20
20
|
declare enum TokenUseEnum {
|
|
21
21
|
ID = "id",
|
|
22
22
|
ACCESS = "access",
|
|
23
|
-
REFRESH = "refresh"
|
|
23
|
+
REFRESH = "refresh",
|
|
24
|
+
INVITE = "invite"
|
|
24
25
|
}
|
|
25
26
|
declare enum JsonWebErrorEnum {
|
|
26
27
|
JsonWebTokenError = "JsonWebTokenError",
|
|
@@ -49,6 +50,8 @@ type IdToken = BaseToken & {
|
|
|
49
50
|
phoneNumberVerified: boolean;
|
|
50
51
|
phoneNumber: string;
|
|
51
52
|
email: string;
|
|
53
|
+
/** True while the user holds an invite's one-time password. */
|
|
54
|
+
mustChangePassword?: boolean;
|
|
52
55
|
tokenUse: TokenUseEnum.ID;
|
|
53
56
|
};
|
|
54
57
|
type AccessToken = BaseToken & {
|
|
@@ -57,6 +60,8 @@ type AccessToken = BaseToken & {
|
|
|
57
60
|
};
|
|
58
61
|
type RefreshToken = BaseToken & {
|
|
59
62
|
tokenUse: TokenUseEnum.REFRESH;
|
|
63
|
+
/** Unique id, tracked by Identity for rotation and revocation. */
|
|
64
|
+
jti?: string;
|
|
60
65
|
};
|
|
61
66
|
type DecodedToken<T extends TokenUseEnum> = T extends TokenUseEnum.ID ? IdToken : T extends TokenUseEnum.ACCESS ? AccessToken : T extends TokenUseEnum.REFRESH ? TokenUseEnum : never;
|
|
62
67
|
export { Access, AccessToken, DecodedToken, IdToken, RefreshToken, RoleType, TokenUseEnum, JsonWebErrorEnum };
|
package/dist/identity/types.js
CHANGED
|
@@ -6,6 +6,7 @@ var TokenUseEnum;
|
|
|
6
6
|
TokenUseEnum["ID"] = "id";
|
|
7
7
|
TokenUseEnum["ACCESS"] = "access";
|
|
8
8
|
TokenUseEnum["REFRESH"] = "refresh";
|
|
9
|
+
TokenUseEnum["INVITE"] = "invite";
|
|
9
10
|
})(TokenUseEnum || (exports.TokenUseEnum = TokenUseEnum = {}));
|
|
10
11
|
var JsonWebErrorEnum;
|
|
11
12
|
(function (JsonWebErrorEnum) {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LanguageModelProvider = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
6
3
|
* http://github.com/fonoster/fonoster
|
|
@@ -19,11 +16,13 @@ exports.LanguageModelProvider = void 0;
|
|
|
19
16
|
* See the License for the specific language governing permissions and
|
|
20
17
|
* limitations under the License.
|
|
21
18
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
import { TokenVerifyOptions } from "./isValidToken";
|
|
20
|
+
import { AccessToken } from "./types";
|
|
21
|
+
/**
|
|
22
|
+
* Verifies `token` and returns it only when it is an access token: signed by
|
|
23
|
+
* Identity (RS256), unexpired, `tokenUse: "access"`, with a string
|
|
24
|
+
* `accessKeyId` and a well-formed `access` array. Id, refresh, invite and other
|
|
25
|
+
* signed tokens are refused (undefined), as is anything malformed.
|
|
26
|
+
*/
|
|
27
|
+
declare function verifyAccessToken(token: string, identityPublicKey: string, options?: TokenVerifyOptions): AccessToken | undefined;
|
|
28
|
+
export { verifyAccessToken };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyAccessToken = verifyAccessToken;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the MIT License (the "License");
|
|
11
|
+
* you may not use this file except in compliance with
|
|
12
|
+
* the License. You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://opensource.org/licenses/MIT
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
const isValidToken_1 = require("./isValidToken");
|
|
23
|
+
const types_1 = require("./types");
|
|
24
|
+
const isAccessEntry = (entry) => typeof entry === "object" &&
|
|
25
|
+
entry !== null &&
|
|
26
|
+
typeof entry.accessKeyId === "string" &&
|
|
27
|
+
typeof entry.role === "string";
|
|
28
|
+
/**
|
|
29
|
+
* Verifies `token` and returns it only when it is an access token: signed by
|
|
30
|
+
* Identity (RS256), unexpired, `tokenUse: "access"`, with a string
|
|
31
|
+
* `accessKeyId` and a well-formed `access` array. Id, refresh, invite and other
|
|
32
|
+
* signed tokens are refused (undefined), as is anything malformed.
|
|
33
|
+
*/
|
|
34
|
+
function verifyAccessToken(token, identityPublicKey, options = {}) {
|
|
35
|
+
const claims = (0, isValidToken_1.verifyToken)(token, identityPublicKey, options);
|
|
36
|
+
if (!claims ||
|
|
37
|
+
claims.tokenUse !== types_1.TokenUseEnum.ACCESS ||
|
|
38
|
+
typeof claims.accessKeyId !== "string" ||
|
|
39
|
+
!Array.isArray(claims.access) ||
|
|
40
|
+
!claims.access.every(isAccessEntry)) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return claims;
|
|
44
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
export * from "./
|
|
19
|
+
export * from "./agents";
|
|
20
|
+
export * from "./config";
|
|
20
21
|
export * from "./GrpcError";
|
|
21
22
|
export * from "./constants";
|
|
22
23
|
export * from "./errors";
|
|
@@ -29,6 +30,18 @@ export * from "./types";
|
|
|
29
30
|
export * from "./utils";
|
|
30
31
|
export * as Validators from "./validators";
|
|
31
32
|
export * from "./validators";
|
|
32
|
-
export * from "./
|
|
33
|
+
export * from "./calls";
|
|
33
34
|
export * from "./countryIsoCodes";
|
|
34
35
|
export * from "./identity";
|
|
36
|
+
export { getRootDomain, setRootDomain } from "./envs";
|
|
37
|
+
export * from "./session";
|
|
38
|
+
export * as Registry from "./registry";
|
|
39
|
+
export * as AudioFilters from "./filters";
|
|
40
|
+
export * as Webhooks from "./webhooks";
|
|
41
|
+
export * as Usage from "./usage";
|
|
42
|
+
export * as CellSecrets from "./cellsecrets";
|
|
43
|
+
export * from "./telemetry";
|
|
44
|
+
export * from "./net";
|
|
45
|
+
export * as Sessions from "./sessions";
|
|
46
|
+
export * as RegionHub from "./regions/hub";
|
|
47
|
+
export * as Roomr from "./roomr";
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Validators = exports.Messages = void 0;
|
|
39
|
+
exports.Roomr = exports.RegionHub = exports.Sessions = exports.CellSecrets = exports.Usage = exports.Webhooks = exports.AudioFilters = exports.Registry = exports.setRootDomain = exports.getRootDomain = exports.Validators = exports.Messages = void 0;
|
|
40
40
|
/**
|
|
41
41
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
42
42
|
* http://github.com/fonoster/fonoster
|
|
@@ -55,7 +55,8 @@ exports.Validators = exports.Messages = void 0;
|
|
|
55
55
|
* See the License for the specific language governing permissions and
|
|
56
56
|
* limitations under the License.
|
|
57
57
|
*/
|
|
58
|
-
__exportStar(require("./
|
|
58
|
+
__exportStar(require("./agents"), exports);
|
|
59
|
+
__exportStar(require("./config"), exports);
|
|
59
60
|
__exportStar(require("./GrpcError"), exports);
|
|
60
61
|
__exportStar(require("./constants"), exports);
|
|
61
62
|
__exportStar(require("./errors"), exports);
|
|
@@ -68,6 +69,20 @@ __exportStar(require("./types"), exports);
|
|
|
68
69
|
__exportStar(require("./utils"), exports);
|
|
69
70
|
exports.Validators = __importStar(require("./validators"));
|
|
70
71
|
__exportStar(require("./validators"), exports);
|
|
71
|
-
__exportStar(require("./
|
|
72
|
+
__exportStar(require("./calls"), exports);
|
|
72
73
|
__exportStar(require("./countryIsoCodes"), exports);
|
|
73
74
|
__exportStar(require("./identity"), exports);
|
|
75
|
+
var envs_1 = require("./envs");
|
|
76
|
+
Object.defineProperty(exports, "getRootDomain", { enumerable: true, get: function () { return envs_1.getRootDomain; } });
|
|
77
|
+
Object.defineProperty(exports, "setRootDomain", { enumerable: true, get: function () { return envs_1.setRootDomain; } });
|
|
78
|
+
__exportStar(require("./session"), exports);
|
|
79
|
+
exports.Registry = __importStar(require("./registry"));
|
|
80
|
+
exports.AudioFilters = __importStar(require("./filters"));
|
|
81
|
+
exports.Webhooks = __importStar(require("./webhooks"));
|
|
82
|
+
exports.Usage = __importStar(require("./usage"));
|
|
83
|
+
exports.CellSecrets = __importStar(require("./cellsecrets"));
|
|
84
|
+
__exportStar(require("./telemetry"), exports);
|
|
85
|
+
__exportStar(require("./net"), exports);
|
|
86
|
+
exports.Sessions = __importStar(require("./sessions"));
|
|
87
|
+
exports.RegionHub = __importStar(require("./regions/hub"));
|
|
88
|
+
exports.Roomr = __importStar(require("./roomr"));
|