Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws/language-server-runtimes

Package Overview
Dependencies
Maintainers
0
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws/language-server-runtimes - npm Package Compare versions

Comparing version 0.2.27 to 0.2.28

runtimes/encoding.d.ts

10

package.json
{
"name": "@aws/language-server-runtimes",
"version": "0.2.27",
"version": "0.2.28",
"description": "Runtimes to host Language Servers for AWS",

@@ -36,3 +36,3 @@ "files": [

"dependencies": {
"@aws/language-server-runtimes-types": "^0.0.7",
"@aws/language-server-runtimes-types": "^0.1.0",
"jose": "^5.9.6",

@@ -45,6 +45,6 @@ "rxjs": "^7.8.1",

"@types/mocha": "^10.0.9",
"@types/node": "^22.9.0",
"@types/node": "^22.10.2",
"assert": "^2.0.0",
"husky": "^9.1.6",
"prettier": "3.3.3",
"husky": "^9.1.7",
"prettier": "3.4.2",
"sinon": "^19.0.2",

@@ -51,0 +51,0 @@ "ts-mocha": "^10.0.0",

import { _EM } from 'vscode-jsonrpc';
import { InitializeParams as _InitializeParamsBase, InitializeResult as _InitializeResultBase, ProgressType, RegistrationType, RequestType } from 'vscode-languageserver-protocol';
import { ChatOptions } from '@aws/language-server-runtimes-types';
import { LogLevel } from '../runtimes/util/loggingUtil';
export * from '@aws/language-server-runtimes-types';

@@ -86,2 +87,3 @@ export { TextDocument } from 'vscode-languageserver-textdocument';

[key: string]: any;
logLevel?: LogLevel;
aws: AWSInitializationOptions;

@@ -88,0 +90,0 @@ };

@@ -139,8 +139,13 @@ # Language Server Runtimes

TBD
The runtimes by default supports the logging feature, allowing servers to output logs varied by different log levels.
#### Feature Specification
TBD
The log level to be set in the runtime for logging can be decided by the client as part of initialize request, which is the first
request initiated by client to the LSP server. The log level can be updated dynamically even after server start by triggering `workspace/didChangeConfiguration`
notification from the client - which prompts the runtime to fetch the new log level to be set from the client through LSP `getConfigurations` request.
1. Params in the initialize request: `InitializeParams.initializationOptions.logLevel`
2. Configuration request params for requesting log level from runtimes to client: ``{section: "aws.logLevel"}``
### Chat

@@ -147,0 +152,0 @@

@@ -18,9 +18,19 @@ "use strict";

});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -27,0 +37,0 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

@@ -1,2 +0,2 @@

import { CancellationToken, DidChangeConfigurationParams, ExecuteCommandParams, GetConfigurationFromServerParams, InitializedParams, InitializeError, InitializeParams, InitializeResult, ResponseError } from '../../../protocol';
import { CancellationToken, DidChangeConfigurationParams, ExecuteCommandParams, GetConfigurationFromServerParams, InitializedParams, InitializeError, InitializeParams, InitializeResult, ResponseError, NotificationFollowupParams } from '../../../protocol';
import { Connection } from 'vscode-languageserver/node';

@@ -11,8 +11,10 @@ import { LspServer } from './lspServer';

constructor(lspConnection: Connection, name: string, version?: string | undefined);
get clientSupportsShowNotification(): boolean;
initialize: (params: InitializeParams, token: CancellationToken) => Promise<InitializeResult | ResponseError<InitializeError>>;
executeCommand: (params: ExecuteCommandParams, token: CancellationToken) => Promise<any | undefined | null>;
getConfigurationFromServer: (params: GetConfigurationFromServerParams, token: CancellationToken) => Promise<any>;
didChangeConfiguration: (params: DidChangeConfigurationParams) => void;
onInitialized: (params: InitializedParams) => void;
handleGetConfigurationFromServer: (params: GetConfigurationFromServerParams, token: CancellationToken) => Promise<any>;
onNotificationFollowup: (params: NotificationFollowupParams) => void;
private routeRequestToFirstCapableServer;
private routeNotificationToAllServers;
}

@@ -22,2 +22,3 @@ "use strict";

this.initialize = (params, token) => __awaiter(this, void 0, void 0, function* () {
var _a, _b;
this.clientInitializeParams = params;

@@ -48,18 +49,17 @@ let responsesList = yield Promise.all(this.servers.map(s => s.initialize(params, token)));

resultList.unshift(defaultResponse);
return resultList.reduceRight((acc, curr) => {
const result = resultList.reduceRight((acc, curr) => {
return (0, util_1.mergeObjects)(acc, curr);
});
this.lspConnection.console.info(`Runtime: Initializing server ${JSON.stringify((_a = result.serverInfo) === null || _a === void 0 ? void 0 : _a.name)} version ${JSON.stringify((_b = result.serverInfo) === null || _b === void 0 ? void 0 : _b.version)} with capabilities:
${JSON.stringify(Object.assign(Object.assign({}, result.capabilities), result.awsServerCapabilities))}`);
return result;
});
this.executeCommand = (params, token) => __awaiter(this, void 0, void 0, function* () {
for (const s of this.servers) {
const [executed, result] = yield s.tryExecuteCommand(params, token);
if (executed) {
return result;
}
}
return this.routeRequestToFirstCapableServer((server, params, token) => server.tryExecuteCommand(params, token), params, token);
});
this.getConfigurationFromServer = (params, token) => __awaiter(this, void 0, void 0, function* () {
return this.routeRequestToFirstCapableServer((server, params, token) => server.tryGetServerConfiguration(params, token), params, token);
});
this.didChangeConfiguration = (params) => {
for (const s of this.servers) {
s.sendDidChangeConfigurationNotification(params);
}
this.routeNotificationToAllServers((server, params) => server.sendDidChangeConfigurationNotification(params), params);
};

@@ -73,9 +73,18 @@ this.onInitialized = (params) => {

}
for (const s of this.servers) {
s.sendInitializedNotification(params);
}
this.routeNotificationToAllServers((server, params) => server.sendInitializedNotification(params), params);
};
this.handleGetConfigurationFromServer = (params, token) => __awaiter(this, void 0, void 0, function* () {
for (const s of this.servers) {
const [executed, result] = yield s.tryGetServerConfiguration(params, token);
this.onNotificationFollowup = (params) => {
this.routeNotificationToAllServers((server, params) => server.sendNotificationFollowup(params), params);
};
lspConnection.onDidChangeConfiguration(this.didChangeConfiguration);
lspConnection.onExecuteCommand(this.executeCommand);
lspConnection.onInitialize(this.initialize);
lspConnection.onInitialized(this.onInitialized);
lspConnection.onRequest(protocol_1.getConfigurationFromServerRequestType, this.getConfigurationFromServer);
lspConnection.onNotification(protocol_1.notificationFollowupRequestType, this.onNotificationFollowup);
}
routeRequestToFirstCapableServer(action, params, token) {
return __awaiter(this, void 0, void 0, function* () {
for (const server of this.servers) {
const [executed, result] = yield action(server, params, token);
if (executed) {

@@ -86,11 +95,9 @@ return result;

});
lspConnection.onDidChangeConfiguration(this.didChangeConfiguration);
lspConnection.onExecuteCommand(this.executeCommand);
lspConnection.onInitialize(this.initialize);
lspConnection.onInitialized(this.onInitialized);
lspConnection.onRequest(protocol_1.getConfigurationFromServerRequestType, this.handleGetConfigurationFromServer);
}
get clientSupportsShowNotification() {
var _a, _b, _c, _d, _e;
return ((_e = (_d = (_c = (_b = (_a = this.clientInitializeParams) === null || _a === void 0 ? void 0 : _a.initializationOptions) === null || _b === void 0 ? void 0 : _b.aws.awsClientCapabilities) === null || _c === void 0 ? void 0 : _c.window) === null || _d === void 0 ? void 0 : _d.notifications) !== null && _e !== void 0 ? _e : false);
routeNotificationToAllServers(action, params) {
return __awaiter(this, void 0, void 0, function* () {
for (const server of this.servers) {
action(server, params);
}
});
}

@@ -97,0 +104,0 @@ }

@@ -22,9 +22,14 @@ "use strict";

const sandbox = sinon_1.default.createSandbox();
const lspConnection = {
onInitialize: (handler) => { },
onInitialized: (handler) => { },
onExecuteCommand: (handler) => { },
onRequest: (handler) => { },
onDidChangeConfiguration: (handler) => { },
const encoding = {
encode: (value) => value,
decode: (value) => value,
};
const logging = {
log: sandbox.stub(),
debug: sandbox.stub(),
error: sandbox.stub(),
warn: sandbox.stub(),
info: sandbox.stub(),
};
const lspConnection = stubLspConnection();
let executeCommandHandler;

@@ -49,18 +54,2 @@ let initializeHandler;

});
it('should set clientSupportsShowNotification from InitializeParam', () => {
assert_1.default.equal(lspRouter.clientSupportsShowNotification, false);
const initParam = {
initializationOptions: {
aws: {
awsClientCapabilities: {
window: {
notifications: true,
},
},
},
},
};
initializeHandler(initParam, {});
assert_1.default.equal(lspRouter.clientSupportsShowNotification, true);
});
it('should return the default response when no handlers are registered', () => __awaiter(void 0, void 0, void 0, function* () {

@@ -301,3 +290,3 @@ const result = yield initializeHandler({}, {});

const params = { section: 'test' };
const result = yield lspRouter.handleGetConfigurationFromServer(params, {});
const result = yield lspRouter.getConfigurationFromServer(params, {});
assert_1.default.strictEqual(result, 'server2');

@@ -337,8 +326,96 @@ }));

const params = { section: 'something' };
const result = yield lspRouter.handleGetConfigurationFromServer(params, {});
const result = yield lspRouter.getConfigurationFromServer(params, {});
assert_1.default.strictEqual(result, undefined);
}));
});
function newServer({ didChangeConfigurationHandler, executeCommandHandler, getServerConfigurationHandler, initializeHandler, initializedHandler, }) {
const server = new lspServer_1.LspServer();
describe('notifications', () => {
const initHandler = () => {
return {
serverInfo: {
name: 'Notification Server',
},
};
};
const initParam = {
initializationOptions: {
aws: {
awsClientCapabilities: {
window: {
notifications: true,
},
},
},
},
};
const notificationParams = {
id: 'id-1',
type: protocol_1.MessageType.Info,
content: {
text: 'Update happened',
},
};
it('should send notification if notifications are supported and server name is defined', () => __awaiter(void 0, void 0, void 0, function* () {
const notificationSpy = sandbox.spy();
const lspConn = {};
lspConn.sendNotification = notificationSpy;
const server = newServer({ lspConnection: lspConn, initializeHandler: initHandler });
yield server.initialize(initParam, {});
server.notification.showNotification(notificationParams);
(0, assert_1.default)(notificationSpy.calledOnce);
}));
it('should not send notification if server name is not defined', () => __awaiter(void 0, void 0, void 0, function* () {
const notificationSpy = sandbox.spy();
const lspConn = {};
lspConn.sendNotification = notificationSpy;
const server = newServer({
lspConnection: lspConn,
initializeHandler: () => {
// no server name defined
},
});
yield server.initialize(initParam, {});
server.notification.showNotification(notificationParams);
(0, assert_1.default)(notificationSpy.notCalled);
}));
it('should not send notification if not supported by client', () => __awaiter(void 0, void 0, void 0, function* () {
const notificationSpy = sandbox.spy();
const lspConn = {};
lspConn.sendNotification = notificationSpy;
const server = newServer({ lspConnection: lspConn, initializeHandler: initHandler });
yield server.initialize({}, {});
server.notification.showNotification(notificationParams);
(0, assert_1.default)(notificationSpy.notCalled);
}));
it('should send followup to source server by matching server name in id', () => __awaiter(void 0, void 0, void 0, function* () {
const lspConn = {};
const server = newServer({ lspConnection: lspConn, initializeHandler: initHandler });
yield server.initialize(initParam, {});
lspRouter.servers = [server];
const notificationFollowupSpy = sandbox.spy();
server.notification.onNotificationFollowup(notificationFollowupSpy);
const notificationFollowup = {
source: {
id: '{"serverName":"Notification Server", "id":"1"}',
},
action: 'Acknowledge',
};
lspRouter.onNotificationFollowup(notificationFollowup);
(0, assert_1.default)(notificationFollowupSpy.calledOnce);
}));
});
function stubLspConnection() {
return {
console: {
info: (message) => { },
},
onInitialize: (handler) => { },
onInitialized: (handler) => { },
onExecuteCommand: (handler) => { },
onRequest: (handler) => { },
onNotification: (handler) => { },
onDidChangeConfiguration: (handler) => { },
};
}
function newServer({ didChangeConfigurationHandler, executeCommandHandler, getServerConfigurationHandler, initializeHandler, initializedHandler, lspConnection, }) {
const server = new lspServer_1.LspServer(lspConnection || stubLspConnection(), encoding, logging);
server.setDidChangeConfigurationHandler(didChangeConfigurationHandler);

@@ -345,0 +422,0 @@ server.setExecuteCommandHandler(executeCommandHandler);

@@ -1,4 +0,11 @@

import { CancellationToken, DidChangeConfigurationParams, ExecuteCommandParams, GetConfigurationFromServerParams, InitializedParams, InitializeError, NotificationHandler, RequestHandler, ResponseError } from '../../../protocol';
import { CancellationToken, DidChangeConfigurationParams, ExecuteCommandParams, GetConfigurationFromServerParams, InitializedParams, InitializeError, NotificationHandler, RequestHandler, ResponseError, NotificationFollowupParams } from '../../../protocol';
import { InitializeParams, PartialInitializeResult } from '../../../server-interface/lsp';
import { Logging, Notification } from '../../../server-interface';
import { Connection } from 'vscode-languageserver/node';
import { Encoding } from '../../encoding';
export declare class LspServer {
private lspConnection;
private encoding;
private logger;
readonly notification: Notification;
private didChangeConfigurationHandler?;

@@ -9,4 +16,7 @@ private executeCommandHandler?;

private initializedHandler?;
private serverCapabilities?;
private awsServerCapabilities?;
private clientSupportsNotifications?;
private initializeResult?;
private notificationRouter?;
private notificationFollowupHandler?;
constructor(lspConnection: Connection, encoding: Encoding, logger: Logging);
setInitializedHandler: (handler: NotificationHandler<InitializedParams>) => void;

@@ -22,2 +32,3 @@ setDidChangeConfigurationHandler: (handler: NotificationHandler<DidChangeConfigurationParams>) => void;

sendInitializedNotification: (params: InitializedParams) => void;
sendNotificationFollowup: (params: NotificationFollowupParams) => void;
}

@@ -15,4 +15,8 @@ "use strict";

const util_1 = require("./util");
const routerByServerName_1 = require("./routerByServerName");
class LspServer {
constructor() {
constructor(lspConnection, encoding, logger) {
this.lspConnection = lspConnection;
this.encoding = encoding;
this.logger = logger;
this.setInitializedHandler = (handler) => {

@@ -34,2 +38,5 @@ this.initializedHandler = handler;

this.initialize = (params, token) => __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c;
this.clientSupportsNotifications =
(_c = (_b = (_a = params.initializationOptions) === null || _a === void 0 ? void 0 : _a.aws.awsClientCapabilities) === null || _b === void 0 ? void 0 : _b.window) === null || _c === void 0 ? void 0 : _c.notifications;
if (!this.initializeHandler) {

@@ -40,4 +47,6 @@ return;

if (!(initializeResult instanceof protocol_1.ResponseError)) {
this.serverCapabilities = initializeResult.capabilities;
this.awsServerCapabilities = initializeResult.awsServerCapabilities;
this.initializeResult = initializeResult;
if (initializeResult === null || initializeResult === void 0 ? void 0 : initializeResult.serverInfo) {
this.notificationRouter = new routerByServerName_1.RouterByServerName(initializeResult.serverInfo.name, this.encoding);
}
}

@@ -47,4 +56,4 @@ return initializeResult;

this.tryExecuteCommand = (params, token) => __awaiter(this, void 0, void 0, function* () {
var _a, _b;
if (((_b = (_a = this.serverCapabilities) === null || _a === void 0 ? void 0 : _a.executeCommandProvider) === null || _b === void 0 ? void 0 : _b.commands.some(c => c === params.command)) &&
var _a, _b, _c;
if (((_c = (_b = (_a = this.initializeResult) === null || _a === void 0 ? void 0 : _a.capabilities) === null || _b === void 0 ? void 0 : _b.executeCommandProvider) === null || _c === void 0 ? void 0 : _c.commands.some(c => c === params.command)) &&
this.executeCommandHandler) {

@@ -57,4 +66,4 @@ const result = yield (0, util_1.asPromise)(this.executeCommandHandler(params, token));

this.tryGetServerConfiguration = (params, token) => __awaiter(this, void 0, void 0, function* () {
var _a, _b;
if (((_b = (_a = this.awsServerCapabilities) === null || _a === void 0 ? void 0 : _a.configurationProvider) === null || _b === void 0 ? void 0 : _b.sections.some(c => c === params.section)) &&
var _a, _b, _c;
if (((_c = (_b = (_a = this.initializeResult) === null || _a === void 0 ? void 0 : _a.awsServerCapabilities) === null || _b === void 0 ? void 0 : _b.configurationProvider) === null || _c === void 0 ? void 0 : _c.sections.some(c => c === params.section)) &&
this.getServerConfigurationHandler) {

@@ -67,11 +76,28 @@ const result = yield (0, util_1.asPromise)(this.getServerConfigurationHandler(params, token));

this.sendDidChangeConfigurationNotification = (params) => {
if (this.didChangeConfigurationHandler) {
this.didChangeConfigurationHandler(params);
}
var _a;
(_a = this.didChangeConfigurationHandler) === null || _a === void 0 ? void 0 : _a.call(this, params);
};
this.sendInitializedNotification = (params) => {
if (this.initializedHandler) {
this.initializedHandler(params);
var _a;
(_a = this.initializedHandler) === null || _a === void 0 ? void 0 : _a.call(this, params);
};
this.sendNotificationFollowup = (params) => {
if (this.notificationFollowupHandler && this.notificationRouter) {
this.notificationRouter.processFollowup(this.notificationFollowupHandler, params);
}
};
this.notification = {
showNotification: params => {
var _a;
if (this.clientSupportsNotifications) {
if (!this.notificationRouter) {
this.logger.log(`Notifications are not supported: serverInfo is not defined`);
}
(_a = this.notificationRouter) === null || _a === void 0 ? void 0 : _a.send(params => this.lspConnection.sendNotification(protocol_1.showNotificationRequestType.method, params), params);
}
},
onNotificationFollowup: handler => {
this.notificationFollowupHandler = handler;
},
};
}

@@ -78,0 +104,0 @@ }

@@ -7,6 +7,10 @@ import { RuntimeProps } from './runtime';

* - CredentialsProvider: provides IAM and bearer credentials
* - LSP: Initializes a connection based on STDIN / STDOUT
* - LSP: initializes a connection based on STDIN / STDOUT
* - Logging: logs messages through the LSP connection
* - Telemetry: emits telemetry through the LSP connection
* - Workspace: tracks open and closed files from the LSP connection
* - Chat: provides access to chat functionalities
* - Runtime: holds information about runtime server and platform
* - Identity Management: manages user profiles and SSO sessions
* - Notification: sends notifications and follow-up actions
*

@@ -24,5 +28,6 @@ * By instantiating features inside the runtime we can tree-shake features or

*
* @param servers The list of servers to initialize and run
* @param props Runtime initialization properties
* @param props.servers The list of servers to initialize and run
* @returns
*/
export declare const standalone: (props: RuntimeProps) => void;

@@ -18,9 +18,19 @@ "use strict";

});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -55,2 +65,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

const serverDataDirPath_1 = require("./util/serverDataDirPath");
const loggingServer_1 = require("./lsp/router/loggingServer");
// Honor shared aws config file

@@ -65,6 +76,10 @@ if ((0, sharedConfigFile_1.checkAWSConfigFile)()) {

* - CredentialsProvider: provides IAM and bearer credentials
* - LSP: Initializes a connection based on STDIN / STDOUT
* - LSP: initializes a connection based on STDIN / STDOUT
* - Logging: logs messages through the LSP connection
* - Telemetry: emits telemetry through the LSP connection
* - Workspace: tracks open and closed files from the LSP connection
* - Chat: provides access to chat functionalities
* - Runtime: holds information about runtime server and platform
* - Identity Management: manages user profiles and SSO sessions
* - Notification: sends notifications and follow-up actions
*

@@ -82,3 +97,4 @@ * By instantiating features inside the runtime we can tree-shake features or

*
* @param servers The list of servers to initialize and run
* @param props Runtime initialization properties
* @param props.servers The list of servers to initialize and run
* @returns

@@ -121,7 +137,2 @@ */

const documents = new vscode_languageserver_1.TextDocuments(protocol_1.TextDocument);
// Set up logging over LSP
// TODO: set up Logging once implemented
const logging = {
log: message => lspConnection.console.info(`[${new Date().toISOString()}] ${message}`),
};
// Set up telemetry over LSP

@@ -178,8 +189,26 @@ const telemetry = {

};
const notification = {
showNotification: params => {
var _a;
return (_a = lspRouter.clientSupportsShowNotification) !== null && _a !== void 0 ? _a : lspConnection.sendNotification(protocol_1.showNotificationRequestType.method, params);
},
onNotificationFollowup: handler => lspConnection.onNotification(protocol_1.notificationFollowupRequestType.method, handler),
if (!encryptionKey) {
chat = new baseChat_1.BaseChat(lspConnection);
}
const identityManagement = {
onListProfiles: handler => lspConnection.onRequest(server_interface_1.listProfilesRequestType, handler),
onUpdateProfile: handler => lspConnection.onRequest(server_interface_1.updateProfileRequestType, handler),
onGetSsoToken: handler => lspConnection.onRequest(server_interface_1.getSsoTokenRequestType, (params, token) => __awaiter(this, void 0, void 0, function* () {
const result = yield handler(params, token);
// Encrypt SsoToken.accessToken before sending to client
if (result && !(result instanceof Error) && encryptionKey) {
if (result.ssoToken.accessToken) {
result.ssoToken.accessToken = yield (0, encryption_1.encryptObjectWithKey)(result.ssoToken.accessToken, encryptionKey);
}
if (result.updateCredentialsParams.data && !result.updateCredentialsParams.encrypted) {
result.updateCredentialsParams.data = yield (0, encryption_1.encryptObjectWithKey)(
// decodeCredentialsRequestToken expects nested 'data' fields
{ data: result.updateCredentialsParams.data }, encryptionKey);
result.updateCredentialsParams.encrypted = true;
}
}
return result;
})),
onInvalidateSsoToken: handler => lspConnection.onRequest(server_interface_1.invalidateSsoTokenRequestType, handler),
sendSsoTokenChanged: params => lspConnection.sendNotification(server_interface_1.ssoTokenChangedRequestType, params),
};

@@ -194,11 +223,19 @@ const credentialsProvider = auth.getCredentialsProvider();

};
const encoding = {
encode: value => Buffer.from(value).toString('base64'),
decode: value => Buffer.from(value, 'base64').toString('utf-8'),
};
// Create router that will be routing LSP events from the client to server(s)
const lspRouter = new lspRouter_1.LspRouter(lspConnection, props.name, props.version);
const loggingServer = new loggingServer_1.LoggingServer(lspConnection, encoding);
const logging = loggingServer.getLoggingObject();
lspRouter.servers.push(loggingServer.getLspServer());
// Initialize every Server
const disposables = props.servers.map(s => {
// Create server representation, processing LSP event handlers, in runtimes
// and add it to the LSP router
const lspServer = new lspServer_1.LspServer();
// Create LSP server representation that holds internal server state
// and processes LSP event handlers
const lspServer = new lspServer_1.LspServer(lspConnection, encoding, logging);
lspRouter.servers.push(lspServer);
// Set up LSP events handlers per server
// TODO: Move lsp feature inside lspServer
const lsp = {

@@ -244,27 +281,2 @@ addInitializer: lspServer.setInitializeHandler,

};
if (!encryptionKey) {
chat = new baseChat_1.BaseChat(lspConnection);
}
const identityManagement = {
onListProfiles: handler => lspConnection.onRequest(server_interface_1.listProfilesRequestType, handler),
onUpdateProfile: handler => lspConnection.onRequest(server_interface_1.updateProfileRequestType, handler),
onGetSsoToken: handler => lspConnection.onRequest(server_interface_1.getSsoTokenRequestType, (params, token) => __awaiter(this, void 0, void 0, function* () {
const result = yield handler(params, token);
// Encrypt SsoToken.accessToken before sending to client
if (result && !(result instanceof Error) && encryptionKey) {
if (result.ssoToken.accessToken) {
result.ssoToken.accessToken = yield (0, encryption_1.encryptObjectWithKey)(result.ssoToken.accessToken, encryptionKey);
}
if (result.updateCredentialsParams.data && !result.updateCredentialsParams.encrypted) {
result.updateCredentialsParams.data = yield (0, encryption_1.encryptObjectWithKey)(
// decodeCredentialsRequestToken expects nested 'data' fields
{ data: result.updateCredentialsParams.data }, encryptionKey);
result.updateCredentialsParams.encrypted = true;
}
}
return result;
})),
onInvalidateSsoToken: handler => lspConnection.onRequest(server_interface_1.invalidateSsoTokenRequestType, handler),
sendSsoTokenChanged: params => lspConnection.sendNotification(server_interface_1.ssoTokenChangedRequestType, params),
};
return s({

@@ -279,3 +291,3 @@ chat,

identityManagement,
notification,
notification: lspServer.notification,
});

@@ -282,0 +294,0 @@ });

@@ -18,9 +18,19 @@ "use strict";

});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -27,0 +37,0 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

@@ -21,2 +21,4 @@ "use strict";

const identity_management_1 = require("../protocol/identity-management");
const encoding_1 = require("./encoding");
const loggingServer_1 = require("./lsp/router/loggingServer");
// TODO: testing rig for runtimes

@@ -29,6 +31,2 @@ const webworker = (props) => {

const lspRouter = new lspRouter_1.LspRouter(lspConnection, props.name, props.version);
// Set up logigng over LSP
const logging = {
log: message => lspConnection.console.info(`[${new Date().toISOString()}] ${message}`),
};
// Set up telemetry over LSP

@@ -74,8 +72,8 @@ const telemetry = {

};
const notification = {
showNotification: params => {
var _a;
return (_a = lspRouter.clientSupportsShowNotification) !== null && _a !== void 0 ? _a : lspConnection.sendNotification(protocol_1.showNotificationRequestType.method, params);
},
onNotificationFollowup: handler => lspConnection.onNotification(protocol_1.notificationFollowupRequestType.method, handler),
const identityManagement = {
onListProfiles: handler => lspConnection.onRequest(identity_management_1.listProfilesRequestType, handler),
onUpdateProfile: handler => lspConnection.onRequest(identity_management_1.updateProfileRequestType, handler),
onGetSsoToken: handler => lspConnection.onRequest(identity_management_1.getSsoTokenRequestType, handler),
onInvalidateSsoToken: handler => lspConnection.onRequest(identity_management_1.invalidateSsoTokenRequestType, handler),
sendSsoTokenChanged: params => lspConnection.sendNotification(identity_management_1.ssoTokenChangedRequestType, params),
};

@@ -92,2 +90,6 @@ // Set up auth without encryption

};
const encoding = new encoding_1.WebBase64Encoding(self);
const loggingServer = new loggingServer_1.LoggingServer(lspConnection, encoding);
const logging = loggingServer.getLoggingObject();
lspRouter.servers.push(loggingServer.getLspServer());
// Initialize every Server

@@ -97,3 +99,3 @@ const disposables = props.servers.map(s => {

// and add it to the LSP router
const lspServer = new lspServer_1.LspServer();
const lspServer = new lspServer_1.LspServer(lspConnection, encoding, logging);
lspRouter.servers.push(lspServer);

@@ -137,9 +139,2 @@ // Set up LSP events handlers per server

};
const identityManagement = {
onListProfiles: handler => lspConnection.onRequest(identity_management_1.listProfilesRequestType, handler),
onUpdateProfile: handler => lspConnection.onRequest(identity_management_1.updateProfileRequestType, handler),
onGetSsoToken: handler => lspConnection.onRequest(identity_management_1.getSsoTokenRequestType, handler),
onInvalidateSsoToken: handler => lspConnection.onRequest(identity_management_1.invalidateSsoTokenRequestType, handler),
sendSsoTokenChanged: params => lspConnection.sendNotification(identity_management_1.ssoTokenChangedRequestType, params),
};
return s({

@@ -154,3 +149,3 @@ chat,

identityManagement,
notification,
notification: lspServer.notification,
});

@@ -157,0 +152,0 @@ });

@@ -5,3 +5,7 @@ /**

export type Logging = {
error: (message: string) => void;
warn: (message: string) => void;
info: (message: string) => void;
log: (message: string) => void;
debug: (message: string) => void;
};

@@ -8,3 +8,3 @@ import { CompletionItem, CompletionList, CompletionParams, ConfigurationOptions, DidChangeConfigurationParams, DidChangeTextDocumentParams, DidChangeWorkspaceFoldersParams, DidCloseTextDocumentParams, DidOpenTextDocumentParams, DocumentFormattingParams, ExecuteCommandParams, GetConfigurationFromServerParams, Hover, HoverParams, InitializeError, InitializeParams, InitializedParams, InlineCompletionItem, InlineCompletionItemWithReferences, InlineCompletionList, InlineCompletionListWithReferences, InlineCompletionParams, LogInlineCompletionSessionResultsParams, NotificationHandler, ProgressToken, ProgressType, PublishDiagnosticsParams, ChatOptions, RequestHandler, ServerCapabilities, TextEdit, SemanticTokensParams, SemanticTokens, SignatureHelp, SignatureHelpParams, ShowMessageParams, ShowMessageRequestParams, MessageActionItem, ShowDocumentParams, ShowDocumentResult, LSPAny, ApplyWorkspaceEditParams, ApplyWorkspaceEditResult } from '../protocol';

* Information about the server respresented by @type {Server}.
* serverInfo is used to differentiate servers internally in the system and is not exposed to the client.
* serverInfo is used to differentiate servers internally in the system and is not exposed to a client.
*/

@@ -11,0 +11,0 @@ serverInfo?: {

@@ -6,3 +6,3 @@ import { Logging, Lsp, Telemetry, Workspace, CredentialsProvider, Chat, Runtime, Notification } from '.';

*
* Servers can make use of the {CredentialsProvider}, {Lsp}, {Workspace}, {Logging} and {Telemetry} features
* Servers can make use of the {CredentialsProvider}, {Lsp}, {Workspace}, {Logging}, {Telemetry} and other features
* to implement their functionality. Servers are notexpected to perform actions when their method

@@ -19,3 +19,4 @@ * is called, but instead to set up listeners, event handlers, etc to handle.

*/
export type Server = (features: {
export type Server = (features: Features) => () => void;
export type Features = {
chat: Chat;

@@ -30,2 +31,2 @@ credentialsProvider: CredentialsProvider;

notification: Notification;
}) => () => void;
};

@@ -40,3 +40,3 @@ import { Server, CredentialsProvider, Logging, Lsp, Telemetry, Workspace, Chat, Runtime, Notification } from '../server-interface';

doSignatureHelp(params: SignatureHelpParams, token: CancellationToken): Promise<import("vscode-languageserver-types").SignatureHelp | import("vscode-jsonrpc/lib/common/messages").ResponseError<void> | null | undefined>;
doInlineCompletionWithReferences(...args: Parameters<Parameters<Lsp['extensions']['onInlineCompletionWithReferences']>[0]>): Promise<import("@aws/language-server-runtimes-types/out/inlineCompletionWithReferences").InlineCompletionListWithReferences | import("@aws/language-server-runtimes-types/out/inlineCompletionWithReferences").InlineCompletionItemWithReferences[] | import("vscode-jsonrpc/lib/common/messages").ResponseError<void> | null | undefined>;
doInlineCompletionWithReferences(...args: Parameters<Parameters<Lsp['extensions']['onInlineCompletionWithReferences']>[0]>): Promise<import("@aws/language-server-runtimes-types/inlineCompletionWithReferences").InlineCompletionListWithReferences | import("@aws/language-server-runtimes-types/inlineCompletionWithReferences").InlineCompletionItemWithReferences[] | import("vscode-jsonrpc/lib/common/messages").ResponseError<void> | null | undefined>;
doLogInlineCompletionSessionResults(...args: Parameters<Parameters<Lsp['extensions']['onLogInlineCompletionSessionResults']>[0]>): Promise<void>;

@@ -43,0 +43,0 @@ openDocument(document: TextDocument): this;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc