@viamrobotics/sdk 0.21.0 → 0.22.0-b.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/app/viam-transport.d.ts +1 -0
- package/dist/main.d.ts +1 -1
- package/dist/main.es.js +23 -11
- package/dist/main.umd.js +2 -2
- package/dist/robot/client.d.ts +1 -0
- package/dist/robot/robot.d.ts +11 -0
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ export declare const isCredential: (object: Credential | AccessToken) => object
|
|
|
18
18
|
* resources.
|
|
19
19
|
*/
|
|
20
20
|
export declare const createViamTransportFactory: (serviceHost: string, credential: Credential | AccessToken) => Promise<grpc.TransportFactory>;
|
|
21
|
+
export declare const getAccessTokenFromCredential: (host: string, credential: Credential) => Promise<AccessToken>;
|
|
21
22
|
export declare class ViamTransport extends MetadataTransport {
|
|
22
23
|
constructor(transportFactory: grpc.TransportFactory, opts: grpc.TransportOptions, accessToken: string);
|
|
23
24
|
}
|
package/dist/main.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export { type Robot, type DialConf, type DialDirectConf, type DialWebRTCConf, ty
|
|
|
16
16
|
*/
|
|
17
17
|
export { RobotClient as Client } from './robot';
|
|
18
18
|
export { createViamClient, type ViamClient, type ViamClientOptions, } from './app/viam-client';
|
|
19
|
-
export type
|
|
19
|
+
export { getAccessTokenFromCredential, type Credential, type CredentialType, type AccessToken, } from './app/viam-transport';
|
|
20
20
|
/**
|
|
21
21
|
* Raw Protobuf interfaces for Data.
|
|
22
22
|
*
|
package/dist/main.es.js
CHANGED
|
@@ -49930,7 +49930,7 @@ class MetadataTransport {
|
|
|
49930
49930
|
constructor(e, s, g) {
|
|
49931
49931
|
this.transport = e(s), this.metadata = g ?? new grpcWebClient_umdExports$1.grpc.Metadata(), this.metadata.set(
|
|
49932
49932
|
"viam-client",
|
|
49933
|
-
`typescript;v0.
|
|
49933
|
+
`typescript;v0.22.0-b.0;${apiVersion}`
|
|
49934
49934
|
);
|
|
49935
49935
|
}
|
|
49936
49936
|
start(e) {
|
|
@@ -50550,6 +50550,14 @@ class RobotClient extends EventDispatcher {
|
|
|
50550
50550
|
o.emit("end", r);
|
|
50551
50551
|
}), o;
|
|
50552
50552
|
}
|
|
50553
|
+
// MODULES
|
|
50554
|
+
async restartModule(e, s) {
|
|
50555
|
+
const { robotService: g } = this, u = new proto$1.RestartModuleRequest();
|
|
50556
|
+
e !== void 0 && u.setModuleId(e), s !== void 0 && u.setModuleName(s), await promisify(
|
|
50557
|
+
g.restartModule.bind(g),
|
|
50558
|
+
u
|
|
50559
|
+
);
|
|
50560
|
+
}
|
|
50553
50561
|
}
|
|
50554
50562
|
const isPosInt = (n) => !!(n > 0 && Number.isInteger(n)), isLocalConnection = (n) => n.includes("local"), dialDirect = async (n) => {
|
|
50555
50563
|
if (console.debug("dialing via gRPC..."), !isLocalConnection(n.host))
|
|
@@ -50982,10 +50990,7 @@ ExternalAuthServiceClient.prototype.authenticateTo = function n(e, s, g) {
|
|
|
50982
50990
|
const isCredential = (n) => "authEntity" in n, createViamTransportFactory = async (n, e) => e.type === "access-token" ? createWithAccessToken(n, e) : createWithCredential(n, e), createWithAccessToken = async (n, e) => {
|
|
50983
50991
|
const s = await dialDirect$1(n);
|
|
50984
50992
|
return (g) => new ViamTransport(s, g, e.payload);
|
|
50985
|
-
},
|
|
50986
|
-
const s = await dialDirect$1(n), g = new AuthServiceClient_1(n, {
|
|
50987
|
-
transport: s
|
|
50988
|
-
});
|
|
50993
|
+
}, getAccessTokenFromCredential = async (n, e) => {
|
|
50989
50994
|
if (e.type === "robot-secret")
|
|
50990
50995
|
throw new Error(
|
|
50991
50996
|
"credential type cannot be 'robot-secret'. Must be either 'robot-location-secret' or 'api-key'."
|
|
@@ -50994,11 +50999,12 @@ const isCredential = (n) => "authEntity" in n, createViamTransportFactory = asyn
|
|
|
50994
50999
|
throw new Error(
|
|
50995
51000
|
"auth entity cannot be null, undefined, or an empty value."
|
|
50996
51001
|
);
|
|
50997
|
-
const
|
|
51002
|
+
const s = await dialDirect$1(n), g = new AuthServiceClient_1(n, {
|
|
51003
|
+
transport: s
|
|
51004
|
+
}), u = e.authEntity, p = new auth_pb.Credentials();
|
|
50998
51005
|
p.setType(e.type), p.setPayload(e.payload);
|
|
50999
51006
|
const l = new auth_pb.AuthenticateRequest();
|
|
51000
|
-
l.setEntity(u), l.setCredentials(p)
|
|
51001
|
-
const o = await new Promise((r, i) => {
|
|
51007
|
+
return l.setEntity(u), l.setCredentials(p), { type: "access-token", payload: await new Promise((r, i) => {
|
|
51002
51008
|
g.authenticate(l, new grpcWebClient_umdExports$1.grpc.Metadata(), (t, c) => {
|
|
51003
51009
|
if (t) {
|
|
51004
51010
|
i(t);
|
|
@@ -51006,8 +51012,13 @@ const isCredential = (n) => "authEntity" in n, createViamTransportFactory = asyn
|
|
|
51006
51012
|
}
|
|
51007
51013
|
r(c?.getAccessToken().toString() ?? "");
|
|
51008
51014
|
});
|
|
51009
|
-
});
|
|
51010
|
-
|
|
51015
|
+
}) };
|
|
51016
|
+
}, createWithCredential = async (n, e) => {
|
|
51017
|
+
const s = await getAccessTokenFromCredential(
|
|
51018
|
+
n,
|
|
51019
|
+
e
|
|
51020
|
+
), g = await dialDirect$1(n);
|
|
51021
|
+
return (u) => new ViamTransport(g, u, s.payload);
|
|
51011
51022
|
};
|
|
51012
51023
|
class ViamTransport extends MetadataTransport {
|
|
51013
51024
|
constructor(e, s, g) {
|
|
@@ -80177,7 +80188,7 @@ class GenericClient {
|
|
|
80177
80188
|
return doCommandFromClient(s, this.name, e, this.options);
|
|
80178
80189
|
}
|
|
80179
80190
|
}
|
|
80180
|
-
const version = "0.
|
|
80191
|
+
const version = "0.22.0-b.0";
|
|
80181
80192
|
export {
|
|
80182
80193
|
ArmClient,
|
|
80183
80194
|
BaseClient,
|
|
@@ -80223,6 +80234,7 @@ export {
|
|
|
80223
80234
|
generic_pb$1 as genericApi,
|
|
80224
80235
|
generic_pb$1 as genericComponentApi,
|
|
80225
80236
|
generic_pb as genericServiceApi,
|
|
80237
|
+
getAccessTokenFromCredential,
|
|
80226
80238
|
pb$d as gripperApi,
|
|
80227
80239
|
input_controller_pb as inputControllerApi,
|
|
80228
80240
|
isValidGeoPoint,
|