New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@viamrobotics/rpc

Package Overview
Dependencies
Maintainers
6
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@viamrobotics/rpc - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

dist/polyfills.d.ts

5

dist/main.d.ts

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

declare global {
interface Window {
VIAM: any;
}
}
export { dialDirect, dialWebRTC, type Credentials, type DialOptions, type DialWebRTCOptions, type WebRTCConnection, } from './dial';
export { ConnectionClosedError, GRPCError } from './errors';

3

package.json
{
"name": "@viamrobotics/rpc",
"version": "0.2.3",
"version": "0.2.4",
"license": "Apache-2.0",

@@ -30,2 +30,3 @@ "dependencies": {

"types": "./dist/main.d.ts",
"main": "./dist/main.js",
"exports": {

@@ -32,0 +33,0 @@ ".": {

@@ -26,6 +26,7 @@ import type { ProtobufMessage } from '@improbable-eng/grpc-web/dist/typings/message';

dataChannel.onopen = () => this.onChannelOpen();
dataChannel.onclose = () => this.onChannelClose();
dataChannel.onerror = (ev: Event) =>
this.onChannelError(ev as RTCErrorEvent);
dataChannel.addEventListener('open', () => this.onChannelOpen());
dataChannel.addEventListener('close', () => this.onChannelClose());
dataChannel.addEventListener('error', (ev) => {
this.onChannelError(ev);
});

@@ -73,5 +74,5 @@ peerConn.addEventListener('iceconnectionstatechange', () => {

private onChannelError(ev: RTCErrorEvent) {
private onChannelError(ev: any) {
console.error('channel error', ev);
this.closeWithReason(ev.error);
this.closeWithReason(new Error(ev));
}

@@ -78,0 +79,0 @@

@@ -26,4 +26,5 @@ import type { grpc } from '@improbable-eng/grpc-web';

super(pc, dc);
dc.onmessage = (event: MessageEvent<unknown>) =>
dc.addEventListener('message', (event: MessageEvent<'message'>) => {
this.onChannelMessage(event);
});
pc.addEventListener('iceconnectionstatechange', () => {

@@ -60,3 +61,5 @@ const state = pc.iceConnectionState;

try {
resp = Response.deserializeBinary(event.data);
resp = Response.deserializeBinary(
new Uint8Array(event.data as ArrayBuffer)
);
} catch (e) {

@@ -63,0 +66,0 @@ console.error('error deserializing message', e);

@@ -24,5 +24,5 @@ import { grpc } from '@improbable-eng/grpc-web';

ICECandidate,
WebRTCConfig,
OptionalWebRTCConfigRequest,
OptionalWebRTCConfigResponse,
WebRTCConfig,
} from './gen/proto/rpc/webrtc/v1/signaling_pb';

@@ -32,2 +32,5 @@ import { SignalingService } from './gen/proto/rpc/webrtc/v1/signaling_pb_service';

import { atob, btoa } from './polyfills';
import { CrossBrowserHttpTransportInit } from '@improbable-eng/grpc-web/dist/typings/transports/http/http';
export interface DialOptions {

@@ -97,5 +100,12 @@ authEntity?: string | undefined;

validateDialOptions(opts);
const defaultFactory = (opts: grpc.TransportOptions): grpc.Transport => {
return grpc.CrossBrowserHttpTransport({ withCredentials: false })(opts);
let TransFact: (
init: CrossBrowserHttpTransportInit
) => grpc.TransportFactory;
try {
TransFact = window.VIAM.GRPC_TRANSPORT_FACTORY;
} catch {
TransFact = grpc.CrossBrowserHttpTransport;
}
return TransFact({ withCredentials: false })(opts);
};

@@ -464,41 +474,44 @@

// set up offer
const offerDesc = await pc.createOffer();
const offerDesc = await pc.createOffer({});
let iceComplete = false;
pc.onicecandidate = async (event) => {
await remoteDescSet;
if (exchangeDone) {
return;
}
pc.addEventListener(
'icecandidate',
async (event: { candidate: RTCIceCandidateInit | null }) => {
await remoteDescSet;
if (exchangeDone) {
return;
}
if (event.candidate === null) {
iceComplete = true;
sendDone();
return;
if (event.candidate === null) {
iceComplete = true;
sendDone();
return;
}
const iProto = iceCandidateToProto(event.candidate);
const callRequestUpdate = new CallUpdateRequest();
callRequestUpdate.setUuid(uuid);
callRequestUpdate.setCandidate(iProto);
grpc.unary(SignalingService.CallUpdate, {
request: callRequestUpdate,
metadata: {
'rpc-host': host,
},
host: signalingAddress,
transport: directTransport,
onEnd: (output: grpc.UnaryOutput<CallUpdateResponse>) => {
const { status, statusMessage, message } = output;
if (status === grpc.Code.OK && message) {
return;
}
if (exchangeDone || iceComplete) {
return;
}
console.error('error sending candidate', statusMessage);
},
});
}
);
const iProto = iceCandidateToProto(event.candidate);
const callRequestUpdate = new CallUpdateRequest();
callRequestUpdate.setUuid(uuid);
callRequestUpdate.setCandidate(iProto);
grpc.unary(SignalingService.CallUpdate, {
request: callRequestUpdate,
metadata: {
'rpc-host': host,
},
host: signalingAddress,
transport: directTransport,
onEnd: (output: grpc.UnaryOutput<CallUpdateResponse>) => {
const { status, statusMessage, message } = output;
if (status === grpc.Code.OK && message) {
return;
}
if (exchangeDone || iceComplete) {
return;
}
console.error('error sending candidate', statusMessage);
},
});
};
await pc.setLocalDescription(offerDesc);

@@ -505,0 +518,0 @@ }

@@ -452,2 +452,7 @@ // package: google.api.expr.v1alpha1

clearMacroCallsMap(): void;
clearExtensionsList(): void;
getExtensionsList(): Array<SourceInfo.Extension>;
setExtensionsList(value: Array<SourceInfo.Extension>): void;
addExtensions(value?: SourceInfo.Extension, index?: number): SourceInfo.Extension;
serializeBinary(): Uint8Array;

@@ -470,3 +475,69 @@ toObject(includeInstance?: boolean): SourceInfo.AsObject;

macroCallsMap: Array<[number, Expr.AsObject]>,
extensionsList: Array<SourceInfo.Extension.AsObject>,
}
export class Extension extends jspb.Message {
getId(): string;
setId(value: string): void;
clearAffectedComponentsList(): void;
getAffectedComponentsList(): Array<SourceInfo.Extension.ComponentMap[keyof SourceInfo.Extension.ComponentMap]>;
setAffectedComponentsList(value: Array<SourceInfo.Extension.ComponentMap[keyof SourceInfo.Extension.ComponentMap]>): void;
addAffectedComponents(value: SourceInfo.Extension.ComponentMap[keyof SourceInfo.Extension.ComponentMap], index?: number): SourceInfo.Extension.ComponentMap[keyof SourceInfo.Extension.ComponentMap];
hasVersion(): boolean;
clearVersion(): void;
getVersion(): SourceInfo.Extension.Version | undefined;
setVersion(value?: SourceInfo.Extension.Version): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): Extension.AsObject;
static toObject(includeInstance: boolean, msg: Extension): Extension.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: Extension, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): Extension;
static deserializeBinaryFromReader(message: Extension, reader: jspb.BinaryReader): Extension;
}
export namespace Extension {
export type AsObject = {
id: string,
affectedComponentsList: Array<SourceInfo.Extension.ComponentMap[keyof SourceInfo.Extension.ComponentMap]>,
version?: SourceInfo.Extension.Version.AsObject,
}
export class Version extends jspb.Message {
getMajor(): number;
setMajor(value: number): void;
getMinor(): number;
setMinor(value: number): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): Version.AsObject;
static toObject(includeInstance: boolean, msg: Version): Version.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: Version, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): Version;
static deserializeBinaryFromReader(message: Version, reader: jspb.BinaryReader): Version;
}
export namespace Version {
export type AsObject = {
major: number,
minor: number,
}
}
export interface ComponentMap {
COMPONENT_UNSPECIFIED: 0;
COMPONENT_PARSER: 1;
COMPONENT_TYPE_CHECKER: 2;
COMPONENT_RUNTIME: 3;
}
export const Component: ComponentMap;
}
}

@@ -473,0 +544,0 @@

@@ -53,7 +53,7 @@ // source: google/api/field_behavior.proto

proto.google.api.fieldBehaviorList,
jspb.BinaryReader.prototype.readPackedEnum,
jspb.BinaryWriter.prototype.writePackedEnum,
jspb.BinaryReader.prototype.readEnum,
jspb.BinaryWriter.prototype.writeRepeatedEnum,
undefined,
undefined,
true);
false);
// This registers the extension field with the extended class, so that

@@ -60,0 +60,0 @@ // toObject() will function correctly.

@@ -0,1 +1,7 @@

declare global {
interface Window {
VIAM: any;
}
}
export {

@@ -2,0 +8,0 @@ dialDirect,

@@ -0,1 +1,3 @@

import { atob, btoa } from './polyfills';
interface ReadyPeer {

@@ -62,35 +64,38 @@ pc: RTCPeerConnection;

let negOpen = false;
negotiationChannel.onopen = () => {
negotiationChannel.addEventListener('open', () => {
negOpen = true;
};
negotiationChannel.onmessage = async (event: MessageEvent<any>) => {
try {
const description = new RTCSessionDescription(
JSON.parse(atob(event.data))
);
});
negotiationChannel.addEventListener(
'message',
async (event: MessageEvent<any>) => {
try {
const description = new RTCSessionDescription(
JSON.parse(atob(event.data.toString()))
);
const offerCollision =
description.type === 'offer' &&
(description || peerConnection.signalingState !== 'stable');
ignoreOffer = !polite && offerCollision;
if (ignoreOffer) {
return;
}
const offerCollision =
description.type === 'offer' &&
(description || peerConnection.signalingState !== 'stable');
ignoreOffer = !polite && offerCollision;
if (ignoreOffer) {
return;
}
await peerConnection.setRemoteDescription(description);
await peerConnection.setRemoteDescription(description);
if (description.type === 'offer') {
await peerConnection.setLocalDescription();
const newDescription = addSdpFields(
peerConnection.localDescription,
additionalSdpFields
);
negotiationChannel.send(btoa(JSON.stringify(newDescription)));
if (description.type === 'offer') {
await peerConnection.setLocalDescription();
const newDescription = addSdpFields(
peerConnection.localDescription,
additionalSdpFields
);
negotiationChannel.send(btoa(JSON.stringify(newDescription)));
}
} catch (e) {
console.error(e);
}
} catch (e) {
console.error(e);
}
};
);
peerConnection.onnegotiationneeded = async () => {
peerConnection.addEventListener('negotiationneeded', async () => {
if (!negOpen) {

@@ -109,3 +114,3 @@ return;

}
};
});

@@ -116,3 +121,3 @@ if (!disableTrickle) {

// set up offer
const offerDesc = await peerConnection.createOffer();
const offerDesc = await peerConnection.createOffer({});
try {

@@ -124,3 +129,3 @@ await peerConnection.setLocalDescription(offerDesc);

peerConnection.onicecandidate = async (event) => {
peerConnection.addEventListener('icecandidate', async (event) => {
if (event.candidate !== null) {

@@ -130,5 +135,5 @@ return;

pResolve({ pc: peerConnection, dc: dataChannel });
};
});
return result;
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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