@corti/sdk 0.7.0 → 0.8.0-rc
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/README.md +2 -0
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/api/resources/stream/client/Socket.js +3 -1
- package/dist/cjs/api/resources/transcribe/client/Socket.js +3 -1
- package/dist/cjs/api/types/AgentsMcpServerAuthorizationType.d.ts +3 -2
- package/dist/cjs/api/types/AgentsMcpServerAuthorizationType.js +2 -1
- package/dist/cjs/custom/CortiAuth.d.ts +29 -6
- package/dist/cjs/custom/CortiAuth.js +10 -4
- package/dist/cjs/custom/CortiClient.d.ts +16 -2
- package/dist/cjs/custom/CortiClient.js +24 -21
- package/dist/cjs/custom/CortiWebSocketProxyClient.d.ts +14 -0
- package/dist/cjs/custom/CortiWebSocketProxyClient.js +22 -0
- package/dist/cjs/custom/CustomStream.d.ts +8 -1
- package/dist/cjs/custom/CustomStream.js +13 -3
- package/dist/cjs/custom/CustomStreamSocket.d.ts +5 -0
- package/dist/cjs/custom/CustomStreamSocket.js +6 -0
- package/dist/cjs/custom/CustomTranscribe.d.ts +8 -1
- package/dist/cjs/custom/CustomTranscribe.js +13 -3
- package/dist/cjs/custom/CustomTranscribeSocket.d.ts +5 -0
- package/dist/cjs/custom/CustomTranscribeSocket.js +6 -0
- package/dist/cjs/custom/proxy/CustomProxyStream.d.ts +24 -0
- package/dist/cjs/custom/proxy/CustomProxyStream.js +57 -0
- package/dist/cjs/custom/proxy/CustomProxyTranscribe.d.ts +24 -0
- package/dist/cjs/custom/proxy/CustomProxyTranscribe.js +56 -0
- package/dist/cjs/custom/utils/getEnvironmentFromString.d.ts +1 -1
- package/dist/cjs/custom/utils/getEnvironmentFromString.js +1 -1
- package/dist/cjs/custom/utils/resolveClientOptions.js +31 -10
- package/dist/cjs/custom/utils/tokenRequest.d.ts +1 -0
- package/dist/cjs/custom/utils/tokenRequest.js +4 -1
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +6 -1
- package/dist/cjs/serialization/types/AgentsMcpServerAuthorizationType.d.ts +1 -1
- package/dist/cjs/serialization/types/AgentsMcpServerAuthorizationType.js +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/api/resources/stream/client/Socket.mjs +3 -1
- package/dist/esm/api/resources/transcribe/client/Socket.mjs +3 -1
- package/dist/esm/api/types/AgentsMcpServerAuthorizationType.d.mts +3 -2
- package/dist/esm/api/types/AgentsMcpServerAuthorizationType.mjs +2 -1
- package/dist/esm/custom/CortiAuth.d.mts +29 -6
- package/dist/esm/custom/CortiAuth.mjs +10 -4
- package/dist/esm/custom/CortiClient.d.mts +16 -2
- package/dist/esm/custom/CortiClient.mjs +24 -21
- package/dist/esm/custom/CortiWebSocketProxyClient.d.mts +14 -0
- package/dist/esm/custom/CortiWebSocketProxyClient.mjs +18 -0
- package/dist/esm/custom/CustomStream.d.mts +8 -1
- package/dist/esm/custom/CustomStream.mjs +13 -3
- package/dist/esm/custom/CustomStreamSocket.d.mts +5 -0
- package/dist/esm/custom/CustomStreamSocket.mjs +6 -0
- package/dist/esm/custom/CustomTranscribe.d.mts +8 -1
- package/dist/esm/custom/CustomTranscribe.mjs +13 -3
- package/dist/esm/custom/CustomTranscribeSocket.d.mts +5 -0
- package/dist/esm/custom/CustomTranscribeSocket.mjs +6 -0
- package/dist/esm/custom/proxy/CustomProxyStream.d.mts +24 -0
- package/dist/esm/custom/proxy/CustomProxyStream.mjs +20 -0
- package/dist/esm/custom/proxy/CustomProxyTranscribe.d.mts +24 -0
- package/dist/esm/custom/proxy/CustomProxyTranscribe.mjs +19 -0
- package/dist/esm/custom/utils/getEnvironmentFromString.d.mts +1 -1
- package/dist/esm/custom/utils/getEnvironmentFromString.mjs +1 -1
- package/dist/esm/custom/utils/resolveClientOptions.mjs +31 -10
- package/dist/esm/custom/utils/tokenRequest.d.mts +1 -0
- package/dist/esm/custom/utils/tokenRequest.mjs +4 -1
- package/dist/esm/index.d.mts +4 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/serialization/types/AgentsMcpServerAuthorizationType.d.mts +1 -1
- package/dist/esm/serialization/types/AgentsMcpServerAuthorizationType.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patch: Proxy-specific Transcribe wrapper that enforces `proxy` as required.
|
|
3
|
+
*
|
|
4
|
+
* Reuses the underlying CustomTranscribe class to preserve the logic we added on top
|
|
5
|
+
* of generated sockets (e.g., sending configuration messages, handling responses).
|
|
6
|
+
*/
|
|
7
|
+
import * as api from "../../api/index.js";
|
|
8
|
+
import { TranscribeSocket } from "../CustomTranscribeSocket.js";
|
|
9
|
+
export type ProxyOptions = {
|
|
10
|
+
url: string;
|
|
11
|
+
protocols?: string[];
|
|
12
|
+
queryParameters?: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
export declare class CustomProxyTranscribe {
|
|
15
|
+
private _transcribe;
|
|
16
|
+
constructor();
|
|
17
|
+
connect(args: {
|
|
18
|
+
proxy: ProxyOptions;
|
|
19
|
+
configuration?: api.TranscribeConfig;
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
debug?: boolean;
|
|
22
|
+
reconnectAttempts?: number;
|
|
23
|
+
}): Promise<TranscribeSocket>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Patch: Proxy-specific Transcribe wrapper that enforces `proxy` as required.
|
|
4
|
+
*
|
|
5
|
+
* Reuses the underlying CustomTranscribe class to preserve the logic we added on top
|
|
6
|
+
* of generated sockets (e.g., sending configuration messages, handling responses).
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.CustomProxyTranscribe = void 0;
|
|
43
|
+
const environments = __importStar(require("../../environments.js"));
|
|
44
|
+
const CustomTranscribe_js_1 = require("../CustomTranscribe.js");
|
|
45
|
+
class CustomProxyTranscribe {
|
|
46
|
+
constructor() {
|
|
47
|
+
this._transcribe = new CustomTranscribe_js_1.Transcribe({
|
|
48
|
+
environment: environments.CortiEnvironment.Eu,
|
|
49
|
+
tenantName: "",
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
connect(args) {
|
|
53
|
+
return this._transcribe.connect(args);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.CustomProxyTranscribe = CustomProxyTranscribe;
|
|
@@ -2,4 +2,4 @@ import * as core from "../../core/index.js";
|
|
|
2
2
|
import * as environments from "../../environments.js";
|
|
3
3
|
export type Environment = CortiInternalEnvironment | string;
|
|
4
4
|
export type CortiInternalEnvironment = core.Supplier<environments.CortiEnvironment | environments.CortiEnvironmentUrls>;
|
|
5
|
-
export declare function getEnvironment(environment
|
|
5
|
+
export declare function getEnvironment(environment?: Environment): CortiInternalEnvironment;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEnvironment = getEnvironment;
|
|
4
|
-
function getEnvironment(environment) {
|
|
4
|
+
function getEnvironment(environment = "eu") {
|
|
5
5
|
return typeof environment === "string"
|
|
6
6
|
? {
|
|
7
7
|
base: `https://api.${environment}.corti.app/v2`,
|
|
@@ -48,7 +48,7 @@ const decodeToken_js_1 = require("./decodeToken.js");
|
|
|
48
48
|
const index_js_1 = require("../../core/schemas/index.js");
|
|
49
49
|
const getEnvironmentFromString_js_1 = require("./getEnvironmentFromString.js");
|
|
50
50
|
function isClientCredentialsOptions(options) {
|
|
51
|
-
return "clientId" in options.auth;
|
|
51
|
+
return !!options.auth && "clientId" in options.auth;
|
|
52
52
|
}
|
|
53
53
|
function resolveClientOptions(options) {
|
|
54
54
|
if (isClientCredentialsOptions(options)) {
|
|
@@ -57,9 +57,22 @@ function resolveClientOptions(options) {
|
|
|
57
57
|
environment: options.environment,
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
// When auth is not provided (baseUrl-only or environment-object scenario), use provided values or defaults
|
|
61
|
+
if (!options.auth) {
|
|
62
|
+
return {
|
|
63
|
+
tenantName: options.tenantName || "",
|
|
64
|
+
environment: options.environment || "",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if ("accessToken" in options.auth) {
|
|
68
|
+
const decoded = (0, decodeToken_js_1.decodeToken)(options.auth.accessToken || "");
|
|
69
|
+
/**
|
|
70
|
+
* Do not throw an error when we have some proxying:
|
|
71
|
+
* baseUrl is set
|
|
72
|
+
* or
|
|
73
|
+
* environment is explicitly provided (not string-generated)
|
|
74
|
+
*/
|
|
75
|
+
if (!decoded && !options.baseUrl && typeof options.environment !== "object") {
|
|
63
76
|
throw new index_js_1.ParseError([
|
|
64
77
|
{
|
|
65
78
|
path: ["auth", "accessToken"],
|
|
@@ -68,8 +81,8 @@ function resolveClientOptions(options) {
|
|
|
68
81
|
]);
|
|
69
82
|
}
|
|
70
83
|
return {
|
|
71
|
-
tenantName: options.tenantName || decoded.tenantName,
|
|
72
|
-
environment: options.environment || decoded.environment,
|
|
84
|
+
tenantName: options.tenantName || (decoded === null || decoded === void 0 ? void 0 : decoded.tenantName) || "",
|
|
85
|
+
environment: options.environment || (decoded === null || decoded === void 0 ? void 0 : decoded.environment) || "",
|
|
73
86
|
};
|
|
74
87
|
}
|
|
75
88
|
/**
|
|
@@ -82,10 +95,18 @@ function resolveClientOptions(options) {
|
|
|
82
95
|
environment: options.environment,
|
|
83
96
|
};
|
|
84
97
|
}
|
|
98
|
+
// At this point, auth exists and has refreshAccessToken (BearerOptions without accessToken)
|
|
99
|
+
const auth = options.auth;
|
|
85
100
|
const tokenResponsePromise = (() => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
const tokenResponse = yield core.Supplier.get(
|
|
101
|
+
const tokenResponse = yield core.Supplier.get(auth.refreshAccessToken);
|
|
87
102
|
const decoded = (0, decodeToken_js_1.decodeToken)(tokenResponse.accessToken);
|
|
88
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Do not throw an error when we have some proxying:
|
|
105
|
+
* baseUrl is set
|
|
106
|
+
* or
|
|
107
|
+
* environment is explicitly provided (not string-generated)
|
|
108
|
+
*/
|
|
109
|
+
if (!decoded && !options.baseUrl && typeof options.environment !== "object") {
|
|
89
110
|
throw new index_js_1.ParseError([
|
|
90
111
|
{
|
|
91
112
|
path: ["auth", "refreshAccessToken"],
|
|
@@ -95,8 +116,8 @@ function resolveClientOptions(options) {
|
|
|
95
116
|
}
|
|
96
117
|
return {
|
|
97
118
|
tokenResponse,
|
|
98
|
-
tenantName: decoded.tenantName,
|
|
99
|
-
environment: decoded.environment,
|
|
119
|
+
tenantName: (decoded === null || decoded === void 0 ? void 0 : decoded.tenantName) || "",
|
|
120
|
+
environment: (decoded === null || decoded === void 0 ? void 0 : decoded.environment) || "",
|
|
100
121
|
};
|
|
101
122
|
}))();
|
|
102
123
|
return {
|
|
@@ -40,8 +40,11 @@ const buildTokenRequestBody = (request) => {
|
|
|
40
40
|
unrecognizedObjectKeys: "strip",
|
|
41
41
|
omitUndefined: true,
|
|
42
42
|
});
|
|
43
|
+
// Build scope string: always include "openid", add any additional scopes
|
|
44
|
+
const allScopes = ["openid", ...(request.scopes || [])];
|
|
45
|
+
const scopeString = [...new Set(allScopes)].join(" ");
|
|
43
46
|
const tokenRequestBody = {
|
|
44
|
-
scope:
|
|
47
|
+
scope: scopeString,
|
|
45
48
|
grant_type: request.grantType || "client_credentials",
|
|
46
49
|
};
|
|
47
50
|
Object.entries(serializedRequest).forEach(([key, value]) => {
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export * as serialization from "./serialization/index.js";
|
|
|
5
5
|
* Patch: use custom CortiClient instead of the generated one.
|
|
6
6
|
*/
|
|
7
7
|
export { CortiClient } from "./custom/CortiClient.js";
|
|
8
|
+
/**
|
|
9
|
+
* Patch: lightweight proxy client with only WebSocket resources.
|
|
10
|
+
*/
|
|
11
|
+
export { CortiWebSocketProxyClient } from "./custom/CortiWebSocketProxyClient.js";
|
|
8
12
|
export { CortiEnvironment, CortiEnvironmentUrls } from "./environments.js";
|
|
9
13
|
/**
|
|
10
14
|
* Patch: added new export to provide Authorization code flow support.
|
package/dist/cjs/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.CortiSDKError = exports.ParseError = exports.JsonError = exports.CortiAuth = exports.CortiEnvironment = exports.CortiClient = exports.serialization = exports.CortiTimeoutError = exports.CortiError = exports.Corti = void 0;
|
|
36
|
+
exports.CortiSDKError = exports.ParseError = exports.JsonError = exports.CortiAuth = exports.CortiEnvironment = exports.CortiWebSocketProxyClient = exports.CortiClient = exports.serialization = exports.CortiTimeoutError = exports.CortiError = exports.Corti = void 0;
|
|
37
37
|
exports.Corti = __importStar(require("./api/index.js"));
|
|
38
38
|
var index_js_1 = require("./errors/index.js");
|
|
39
39
|
Object.defineProperty(exports, "CortiError", { enumerable: true, get: function () { return index_js_1.CortiError; } });
|
|
@@ -44,6 +44,11 @@ exports.serialization = __importStar(require("./serialization/index.js"));
|
|
|
44
44
|
*/
|
|
45
45
|
var CortiClient_js_1 = require("./custom/CortiClient.js");
|
|
46
46
|
Object.defineProperty(exports, "CortiClient", { enumerable: true, get: function () { return CortiClient_js_1.CortiClient; } });
|
|
47
|
+
/**
|
|
48
|
+
* Patch: lightweight proxy client with only WebSocket resources.
|
|
49
|
+
*/
|
|
50
|
+
var CortiWebSocketProxyClient_js_1 = require("./custom/CortiWebSocketProxyClient.js");
|
|
51
|
+
Object.defineProperty(exports, "CortiWebSocketProxyClient", { enumerable: true, get: function () { return CortiWebSocketProxyClient_js_1.CortiWebSocketProxyClient; } });
|
|
47
52
|
var environments_js_1 = require("./environments.js");
|
|
48
53
|
Object.defineProperty(exports, "CortiEnvironment", { enumerable: true, get: function () { return environments_js_1.CortiEnvironment; } });
|
|
49
54
|
/**
|
|
@@ -6,5 +6,5 @@ import * as Corti from "../../api/index.js";
|
|
|
6
6
|
import * as core from "../../core/index.js";
|
|
7
7
|
export declare const AgentsMcpServerAuthorizationType: core.serialization.Schema<serializers.AgentsMcpServerAuthorizationType.Raw, Corti.AgentsMcpServerAuthorizationType>;
|
|
8
8
|
export declare namespace AgentsMcpServerAuthorizationType {
|
|
9
|
-
type Raw = "none" | "
|
|
9
|
+
type Raw = "none" | "bearer" | "inherit" | "oauth2.0";
|
|
10
10
|
}
|
|
@@ -38,4 +38,4 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.AgentsMcpServerAuthorizationType = void 0;
|
|
40
40
|
const core = __importStar(require("../../core/index.js"));
|
|
41
|
-
exports.AgentsMcpServerAuthorizationType = core.serialization.enum_(["none", "
|
|
41
|
+
exports.AgentsMcpServerAuthorizationType = core.serialization.enum_(["none", "bearer", "inherit", "oauth2.0"]);
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.8.0-rc";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/Client.mjs
CHANGED
|
@@ -28,8 +28,8 @@ export class CortiClient {
|
|
|
28
28
|
"Tenant-Name": _options === null || _options === void 0 ? void 0 : _options.tenantName,
|
|
29
29
|
"X-Fern-Language": "JavaScript",
|
|
30
30
|
"X-Fern-SDK-Name": "@corti/sdk",
|
|
31
|
-
"X-Fern-SDK-Version": "0.
|
|
32
|
-
"User-Agent": "@corti/sdk/0.
|
|
31
|
+
"X-Fern-SDK-Version": "0.8.0-rc",
|
|
32
|
+
"User-Agent": "@corti/sdk/0.8.0-rc",
|
|
33
33
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
34
34
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
35
35
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -85,7 +85,9 @@ export class StreamSocket {
|
|
|
85
85
|
}
|
|
86
86
|
sendAudio(message) {
|
|
87
87
|
this.assertSocketIsOpen();
|
|
88
|
-
const jsonPayload = core.serialization
|
|
88
|
+
const jsonPayload = core.serialization
|
|
89
|
+
.string()
|
|
90
|
+
.jsonOrThrow(message, {
|
|
89
91
|
unrecognizedObjectKeys: "passthrough",
|
|
90
92
|
allowUnrecognizedUnionMembers: true,
|
|
91
93
|
allowUnrecognizedEnumValues: true,
|
|
@@ -85,7 +85,9 @@ export class TranscribeSocket {
|
|
|
85
85
|
}
|
|
86
86
|
sendAudio(message) {
|
|
87
87
|
this.assertSocketIsOpen();
|
|
88
|
-
const jsonPayload = core.serialization
|
|
88
|
+
const jsonPayload = core.serialization
|
|
89
|
+
.string()
|
|
90
|
+
.jsonOrThrow(message, {
|
|
89
91
|
unrecognizedObjectKeys: "passthrough",
|
|
90
92
|
allowUnrecognizedUnionMembers: true,
|
|
91
93
|
allowUnrecognizedEnumValues: true,
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Type of authorization used by the MCP server.
|
|
6
6
|
*/
|
|
7
|
-
export type AgentsMcpServerAuthorizationType = "none" | "
|
|
7
|
+
export type AgentsMcpServerAuthorizationType = "none" | "bearer" | "inherit" | "oauth2.0";
|
|
8
8
|
export declare const AgentsMcpServerAuthorizationType: {
|
|
9
9
|
readonly None: "none";
|
|
10
|
+
readonly Bearer: "bearer";
|
|
11
|
+
readonly Inherit: "inherit";
|
|
10
12
|
readonly Oauth20: "oauth2.0";
|
|
11
|
-
readonly Oauth21: "oauth2.1";
|
|
12
13
|
};
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { Auth as FernAuth } from "../api/resources/auth/client/Client.mjs";
|
|
15
15
|
import * as core from "../core/index.mjs";
|
|
16
16
|
import * as Corti from "../api/index.mjs";
|
|
17
|
-
import
|
|
17
|
+
import { Environment, CortiInternalEnvironment } from "./utils/getEnvironmentFromString.mjs";
|
|
18
18
|
/**
|
|
19
19
|
* Patch: added codeChallenge to the AuthorizationCodeClient interface to support PKCE flow
|
|
20
20
|
*/
|
|
@@ -22,6 +22,7 @@ interface AuthorizationCodeClient {
|
|
|
22
22
|
clientId: string;
|
|
23
23
|
redirectUri: string;
|
|
24
24
|
codeChallenge?: string;
|
|
25
|
+
scopes?: string[];
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* Patch: renamed AuthorizationCodeClient to AuthorizationCode as it can be used for both(server and client) flows
|
|
@@ -31,6 +32,7 @@ interface AuthorizationCode {
|
|
|
31
32
|
clientSecret: string;
|
|
32
33
|
redirectUri: string;
|
|
33
34
|
code: string;
|
|
35
|
+
scopes?: string[];
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* Patch: added type for AuthorizationPkce request
|
|
@@ -40,6 +42,7 @@ interface AuthorizationPkce {
|
|
|
40
42
|
redirectUri: string;
|
|
41
43
|
code: string;
|
|
42
44
|
codeVerifier?: string;
|
|
45
|
+
scopes?: string[];
|
|
43
46
|
}
|
|
44
47
|
/**
|
|
45
48
|
* Patch: added type for AuthorizationRopc request
|
|
@@ -48,6 +51,7 @@ interface AuthorizationRopcServer {
|
|
|
48
51
|
clientId: string;
|
|
49
52
|
username: string;
|
|
50
53
|
password: string;
|
|
54
|
+
scopes?: string[];
|
|
51
55
|
}
|
|
52
56
|
interface AuthorizationRefreshServer {
|
|
53
57
|
clientId: string;
|
|
@@ -56,34 +60,53 @@ interface AuthorizationRefreshServer {
|
|
|
56
60
|
*/
|
|
57
61
|
clientSecret?: string;
|
|
58
62
|
refreshToken: string;
|
|
63
|
+
scopes?: string[];
|
|
59
64
|
}
|
|
60
65
|
interface Options {
|
|
61
66
|
skipRedirect?: boolean;
|
|
62
67
|
}
|
|
63
|
-
type
|
|
64
|
-
|
|
68
|
+
type AuthOptionsBase = Omit<FernAuth.Options, "environment" | "tenantName" | "baseUrl">;
|
|
69
|
+
type AuthOptionsWithBaseUrl = AuthOptionsBase & {
|
|
70
|
+
baseUrl: core.Supplier<string>;
|
|
71
|
+
environment?: Environment;
|
|
72
|
+
tenantName?: core.Supplier<string>;
|
|
65
73
|
};
|
|
74
|
+
type AuthOptionsWithObjectEnvironment = AuthOptionsBase & {
|
|
75
|
+
baseUrl?: core.Supplier<string>;
|
|
76
|
+
environment: CortiInternalEnvironment;
|
|
77
|
+
tenantName?: core.Supplier<string>;
|
|
78
|
+
};
|
|
79
|
+
type AuthOptionsWithStringEnvironment = AuthOptionsBase & {
|
|
80
|
+
baseUrl?: core.Supplier<string>;
|
|
81
|
+
environment: string;
|
|
82
|
+
tenantName: core.Supplier<string>;
|
|
83
|
+
};
|
|
84
|
+
type AuthOptions = AuthOptionsWithBaseUrl | AuthOptionsWithObjectEnvironment | AuthOptionsWithStringEnvironment;
|
|
66
85
|
export declare class Auth extends FernAuth {
|
|
67
86
|
/**
|
|
68
87
|
* Patch: use custom AuthOptions type to support string-based environment
|
|
88
|
+
* When baseUrl is provided, environment and tenantName become optional
|
|
69
89
|
*/
|
|
70
90
|
constructor(_options: AuthOptions);
|
|
71
91
|
/**
|
|
72
92
|
* Patch: Generate PKCE authorization URL with automatic code verifier generation
|
|
73
93
|
*/
|
|
74
|
-
authorizePkceUrl({ clientId, redirectUri }: AuthorizationCodeClient, options?: Options): Promise<string>;
|
|
94
|
+
authorizePkceUrl({ clientId, redirectUri, scopes }: AuthorizationCodeClient, options?: Options): Promise<string>;
|
|
75
95
|
/**
|
|
76
96
|
* Patch: Get the stored PKCE code verifier
|
|
77
97
|
*/
|
|
78
98
|
getCodeVerifier(): string | null;
|
|
79
99
|
/**
|
|
80
100
|
* Patch: called custom implementation this.__getToken_custom instead of this.__getToken
|
|
101
|
+
* Extended to support additional scopes
|
|
81
102
|
*/
|
|
82
|
-
getToken(request: Corti.AuthGetTokenRequest
|
|
103
|
+
getToken(request: Corti.AuthGetTokenRequest & {
|
|
104
|
+
scopes?: string[];
|
|
105
|
+
}, requestOptions?: FernAuth.RequestOptions): core.HttpResponsePromise<Corti.GetTokenResponse>;
|
|
83
106
|
/**
|
|
84
107
|
* Patch: added method to get Authorization URL for Authorization code flow and PKCE flow
|
|
85
108
|
*/
|
|
86
|
-
authorizeURL({ clientId, redirectUri, codeChallenge }: AuthorizationCodeClient, options?: Options): Promise<string>;
|
|
109
|
+
authorizeURL({ clientId, redirectUri, codeChallenge, scopes }: AuthorizationCodeClient, options?: Options): Promise<string>;
|
|
87
110
|
/**
|
|
88
111
|
* Patch: calls __getToken_custom with additional fields to support Authorization code flow
|
|
89
112
|
*/
|
|
@@ -34,15 +34,16 @@ const CODE_VERIFIER_KEY = "corti_js_sdk_code_verifier";
|
|
|
34
34
|
export class Auth extends FernAuth {
|
|
35
35
|
/**
|
|
36
36
|
* Patch: use custom AuthOptions type to support string-based environment
|
|
37
|
+
* When baseUrl is provided, environment and tenantName become optional
|
|
37
38
|
*/
|
|
38
39
|
constructor(_options) {
|
|
39
|
-
super(Object.assign(Object.assign({}, _options), { environment: getEnvironment(_options.environment) }));
|
|
40
|
+
super(Object.assign(Object.assign({}, _options), { tenantName: _options.tenantName || "", environment: getEnvironment(_options.environment) }));
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
42
43
|
* Patch: Generate PKCE authorization URL with automatic code verifier generation
|
|
43
44
|
*/
|
|
44
45
|
authorizePkceUrl(_a, options_1) {
|
|
45
|
-
return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri }, options) {
|
|
46
|
+
return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri, scopes }, options) {
|
|
46
47
|
const codeVerifier = generateCodeVerifier();
|
|
47
48
|
setLocalStorageItem(CODE_VERIFIER_KEY, codeVerifier);
|
|
48
49
|
const codeChallenge = yield generateCodeChallenge(codeVerifier);
|
|
@@ -50,6 +51,7 @@ export class Auth extends FernAuth {
|
|
|
50
51
|
clientId,
|
|
51
52
|
redirectUri,
|
|
52
53
|
codeChallenge,
|
|
54
|
+
scopes,
|
|
53
55
|
}, options);
|
|
54
56
|
});
|
|
55
57
|
}
|
|
@@ -61,6 +63,7 @@ export class Auth extends FernAuth {
|
|
|
61
63
|
}
|
|
62
64
|
/**
|
|
63
65
|
* Patch: called custom implementation this.__getToken_custom instead of this.__getToken
|
|
66
|
+
* Extended to support additional scopes
|
|
64
67
|
*/
|
|
65
68
|
getToken(request, requestOptions) {
|
|
66
69
|
return core.HttpResponsePromise.fromPromise(this.__getToken_custom(request, requestOptions));
|
|
@@ -69,11 +72,14 @@ export class Auth extends FernAuth {
|
|
|
69
72
|
* Patch: added method to get Authorization URL for Authorization code flow and PKCE flow
|
|
70
73
|
*/
|
|
71
74
|
authorizeURL(_a, options_1) {
|
|
72
|
-
return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri, codeChallenge }, options) {
|
|
75
|
+
return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri, codeChallenge, scopes }, options) {
|
|
73
76
|
var _b;
|
|
74
77
|
const authUrl = new URL(core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)).login, yield core.Supplier.get(this._options.tenantName), "protocol/openid-connect/auth"));
|
|
75
78
|
authUrl.searchParams.set("response_type", "code");
|
|
76
|
-
|
|
79
|
+
// Build scope string: always include "openid profile", add any additional scopes
|
|
80
|
+
const allScopes = ["openid", "profile", ...(scopes || [])];
|
|
81
|
+
const scopeString = [...new Set(allScopes)].join(" ");
|
|
82
|
+
authUrl.searchParams.set("scope", scopeString);
|
|
77
83
|
if (clientId !== undefined) {
|
|
78
84
|
authUrl.searchParams.set("client_id", clientId);
|
|
79
85
|
}
|
|
@@ -40,6 +40,8 @@ export declare namespace CortiClient {
|
|
|
40
40
|
interface BaseOptions {
|
|
41
41
|
/** Additional headers to include in requests. */
|
|
42
42
|
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
43
|
+
/** Specify a custom URL to connect the client to. */
|
|
44
|
+
baseUrl?: core.Supplier<string>;
|
|
43
45
|
}
|
|
44
46
|
interface OptionsWithClientCredentials extends BaseOptions {
|
|
45
47
|
/**
|
|
@@ -59,7 +61,18 @@ export declare namespace CortiClient {
|
|
|
59
61
|
tenantName?: core.Supplier<string>;
|
|
60
62
|
auth: BearerOptions;
|
|
61
63
|
}
|
|
62
|
-
|
|
64
|
+
interface OptionsWithBaseUrl extends BaseOptions {
|
|
65
|
+
baseUrl: core.Supplier<string>;
|
|
66
|
+
environment?: Environment;
|
|
67
|
+
tenantName?: core.Supplier<string>;
|
|
68
|
+
auth?: ClientCredentials | BearerOptions;
|
|
69
|
+
}
|
|
70
|
+
interface OptionsWithObjectEnvironment extends BaseOptions {
|
|
71
|
+
environment: CortiInternalEnvironment;
|
|
72
|
+
tenantName?: core.Supplier<string>;
|
|
73
|
+
auth?: ClientCredentials | BearerOptions;
|
|
74
|
+
}
|
|
75
|
+
type Options = OptionsWithClientCredentials | OptionsWithBearerToken | OptionsWithBaseUrl | OptionsWithObjectEnvironment;
|
|
63
76
|
/**
|
|
64
77
|
* Patch:
|
|
65
78
|
* - renamed `Options` to `InternalOptions`
|
|
@@ -99,8 +112,9 @@ export declare class CortiClient {
|
|
|
99
112
|
protected readonly _options: CortiClient.InternalOptions;
|
|
100
113
|
/**
|
|
101
114
|
* Patch: extended `_oauthTokenProvider` to support both `RefreshBearerProvider` and `OAuthTokenProvider` options
|
|
115
|
+
* Optional - not created when auth is not provided (proxying scenarios)
|
|
102
116
|
*/
|
|
103
|
-
private readonly _oauthTokenProvider
|
|
117
|
+
private readonly _oauthTokenProvider?;
|
|
104
118
|
protected _interactions: Interactions | undefined;
|
|
105
119
|
protected _recordings: Recordings | undefined;
|
|
106
120
|
protected _transcripts: Transcripts | undefined;
|
|
@@ -68,56 +68,59 @@ export class CortiClient {
|
|
|
68
68
|
"User-Agent": `@corti/sdk/${SDK_VERSION}`,
|
|
69
69
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
70
70
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
71
|
-
}, _options === null || _options === void 0 ? void 0 : _options.headers), clientId: "clientId" in _options.auth ? _options.auth.clientId : undefined, clientSecret: "clientSecret" in _options.auth ? _options.auth.clientSecret : undefined, token: "accessToken" in _options.auth ? _options.auth.accessToken : undefined, tenantName, environment: getEnvironment(environment) });
|
|
71
|
+
}, _options === null || _options === void 0 ? void 0 : _options.headers), clientId: _options.auth && "clientId" in _options.auth ? _options.auth.clientId : undefined, clientSecret: _options.auth && "clientSecret" in _options.auth ? _options.auth.clientSecret : undefined, token: _options.auth && "accessToken" in _options.auth ? _options.auth.accessToken : undefined, tenantName, environment: getEnvironment(environment) });
|
|
72
72
|
/**
|
|
73
73
|
* Patch: if `clientId` is provided, use OAuthTokenProvider, otherwise use BearerProvider
|
|
74
|
+
* Only create token provider when auth is provided
|
|
74
75
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
if (_options.auth) {
|
|
77
|
+
this._oauthTokenProvider =
|
|
78
|
+
"clientId" in _options.auth
|
|
79
|
+
? new core.OAuthTokenProvider({
|
|
80
|
+
clientId: _options.auth.clientId,
|
|
81
|
+
clientSecret: _options.auth.clientSecret,
|
|
82
|
+
/**
|
|
83
|
+
* Patch: provide whole `options` object to the Auth client, since it depends on both tenantName and environment
|
|
84
|
+
*/
|
|
85
|
+
authClient: new Auth(this._options),
|
|
86
|
+
})
|
|
87
|
+
: new RefreshBearerProvider(Object.assign(Object.assign({}, _options.auth), { initialTokenResponse }));
|
|
88
|
+
}
|
|
86
89
|
}
|
|
87
90
|
get interactions() {
|
|
88
91
|
var _a;
|
|
89
|
-
return ((_a = this._interactions) !== null && _a !== void 0 ? _a : (this._interactions = new Interactions(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
|
|
92
|
+
return ((_a = this._interactions) !== null && _a !== void 0 ? _a : (this._interactions = new Interactions(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
|
|
90
93
|
}
|
|
91
94
|
get recordings() {
|
|
92
95
|
var _a;
|
|
93
|
-
return ((_a = this._recordings) !== null && _a !== void 0 ? _a : (this._recordings = new Recordings(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
|
|
96
|
+
return ((_a = this._recordings) !== null && _a !== void 0 ? _a : (this._recordings = new Recordings(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
|
|
94
97
|
}
|
|
95
98
|
get transcripts() {
|
|
96
99
|
var _a;
|
|
97
|
-
return ((_a = this._transcripts) !== null && _a !== void 0 ? _a : (this._transcripts = new Transcripts(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
|
|
100
|
+
return ((_a = this._transcripts) !== null && _a !== void 0 ? _a : (this._transcripts = new Transcripts(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
|
|
98
101
|
}
|
|
99
102
|
get facts() {
|
|
100
103
|
var _a;
|
|
101
|
-
return ((_a = this._facts) !== null && _a !== void 0 ? _a : (this._facts = new Facts(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
|
|
104
|
+
return ((_a = this._facts) !== null && _a !== void 0 ? _a : (this._facts = new Facts(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
|
|
102
105
|
}
|
|
103
106
|
get documents() {
|
|
104
107
|
var _a;
|
|
105
|
-
return ((_a = this._documents) !== null && _a !== void 0 ? _a : (this._documents = new Documents(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
|
|
108
|
+
return ((_a = this._documents) !== null && _a !== void 0 ? _a : (this._documents = new Documents(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
|
|
106
109
|
}
|
|
107
110
|
get templates() {
|
|
108
111
|
var _a;
|
|
109
|
-
return ((_a = this._templates) !== null && _a !== void 0 ? _a : (this._templates = new Templates(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
|
|
112
|
+
return ((_a = this._templates) !== null && _a !== void 0 ? _a : (this._templates = new Templates(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
|
|
110
113
|
}
|
|
111
114
|
get agents() {
|
|
112
115
|
var _a;
|
|
113
|
-
return ((_a = this._agents) !== null && _a !== void 0 ? _a : (this._agents = new Agents(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
|
|
116
|
+
return ((_a = this._agents) !== null && _a !== void 0 ? _a : (this._agents = new Agents(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
|
|
114
117
|
}
|
|
115
118
|
get stream() {
|
|
116
119
|
var _a;
|
|
117
|
-
return ((_a = this._stream) !== null && _a !== void 0 ? _a : (this._stream = new Stream(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
|
|
120
|
+
return ((_a = this._stream) !== null && _a !== void 0 ? _a : (this._stream = new Stream(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
|
|
118
121
|
}
|
|
119
122
|
get transcribe() {
|
|
120
123
|
var _a;
|
|
121
|
-
return ((_a = this._transcribe) !== null && _a !== void 0 ? _a : (this._transcribe = new Transcribe(Object.assign(Object.assign({}, this._options), { token: () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) }))));
|
|
124
|
+
return ((_a = this._transcribe) !== null && _a !== void 0 ? _a : (this._transcribe = new Transcribe(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter(this, void 0, void 0, function* () { return yield this._oauthTokenProvider.getToken(); }) : undefined }))));
|
|
122
125
|
}
|
|
123
126
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patch: Lightweight proxy client with only WebSocket resources (stream and transcribe).
|
|
3
|
+
* Use this when you need direct WebSocket connections through your own proxy backend.
|
|
4
|
+
*
|
|
5
|
+
* No environment or tenantName required - proxy is required in connect().
|
|
6
|
+
*/
|
|
7
|
+
import { CustomProxyStream } from "./proxy/CustomProxyStream.mjs";
|
|
8
|
+
import { CustomProxyTranscribe } from "./proxy/CustomProxyTranscribe.mjs";
|
|
9
|
+
export declare class CortiWebSocketProxyClient {
|
|
10
|
+
private static _stream;
|
|
11
|
+
private static _transcribe;
|
|
12
|
+
static get stream(): CustomProxyStream;
|
|
13
|
+
static get transcribe(): CustomProxyTranscribe;
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patch: Lightweight proxy client with only WebSocket resources (stream and transcribe).
|
|
3
|
+
* Use this when you need direct WebSocket connections through your own proxy backend.
|
|
4
|
+
*
|
|
5
|
+
* No environment or tenantName required - proxy is required in connect().
|
|
6
|
+
*/
|
|
7
|
+
import { CustomProxyStream } from "./proxy/CustomProxyStream.mjs";
|
|
8
|
+
import { CustomProxyTranscribe } from "./proxy/CustomProxyTranscribe.mjs";
|
|
9
|
+
export class CortiWebSocketProxyClient {
|
|
10
|
+
static get stream() {
|
|
11
|
+
var _a;
|
|
12
|
+
return ((_a = this._stream) !== null && _a !== void 0 ? _a : (this._stream = new CustomProxyStream()));
|
|
13
|
+
}
|
|
14
|
+
static get transcribe() {
|
|
15
|
+
var _a;
|
|
16
|
+
return ((_a = this._transcribe) !== null && _a !== void 0 ? _a : (this._transcribe = new CustomProxyTranscribe()));
|
|
17
|
+
}
|
|
18
|
+
}
|