@dronedeploy/rocos-js-sdk 3.0.1-alpha.15 → 3.0.1-alpha.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/cjs/IRocosSDK.d.ts +2 -1
  2. package/cjs/RocosSDK.d.ts +7 -2
  3. package/cjs/RocosSDK.js +11 -1
  4. package/cjs/constants/api.d.ts +4 -2
  5. package/cjs/constants/api.js +5 -3
  6. package/cjs/models/RocosError.d.ts +1 -0
  7. package/cjs/models/RocosError.js +1 -0
  8. package/cjs/models/ServiceEnum.d.ts +2 -1
  9. package/cjs/models/ServiceEnum.js +1 -0
  10. package/cjs/models/device-credentials/DeviceCredentials.d.ts +61 -0
  11. package/cjs/models/device-credentials/DeviceCredentials.js +2 -0
  12. package/cjs/node/RocosSDKNode.d.ts +2 -1
  13. package/cjs/node/RocosSDKNode.js +6 -0
  14. package/cjs/services/AuthService.d.ts +12 -1
  15. package/cjs/services/AuthService.js +19 -1
  16. package/cjs/services/DeviceCredentialsService.d.ts +15 -0
  17. package/cjs/services/DeviceCredentialsService.js +50 -0
  18. package/cjs/services/MapService.d.ts +1 -1
  19. package/cjs/services/MapService.js +1 -1
  20. package/cjs/services/ProfileService.d.ts +2 -1
  21. package/cjs/services/ProfileService.js +9 -3
  22. package/cjs/services/index.d.ts +1 -0
  23. package/cjs/services/index.js +1 -0
  24. package/esm/IRocosSDK.d.ts +2 -1
  25. package/esm/RocosSDK.d.ts +7 -2
  26. package/esm/RocosSDK.js +12 -2
  27. package/esm/constants/api.d.ts +4 -2
  28. package/esm/constants/api.js +4 -2
  29. package/esm/models/RocosError.d.ts +1 -0
  30. package/esm/models/RocosError.js +1 -0
  31. package/esm/models/ServiceEnum.d.ts +2 -1
  32. package/esm/models/ServiceEnum.js +1 -0
  33. package/esm/models/device-credentials/DeviceCredentials.d.ts +61 -0
  34. package/esm/models/device-credentials/DeviceCredentials.js +1 -0
  35. package/esm/node/RocosSDKNode.d.ts +2 -1
  36. package/esm/node/RocosSDKNode.js +7 -1
  37. package/esm/services/AuthService.d.ts +12 -1
  38. package/esm/services/AuthService.js +19 -1
  39. package/esm/services/DeviceCredentialsService.d.ts +15 -0
  40. package/esm/services/DeviceCredentialsService.js +46 -0
  41. package/esm/services/MapService.d.ts +1 -1
  42. package/esm/services/MapService.js +1 -1
  43. package/esm/services/ProfileService.d.ts +2 -1
  44. package/esm/services/ProfileService.js +9 -3
  45. package/esm/services/index.d.ts +1 -0
  46. package/esm/services/index.js +1 -0
  47. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, SearchService, SpotProvisioningService, SpotProvisioningServiceNode, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
1
+ import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, DeviceCredentialsService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, SearchService, SpotProvisioningService, SpotProvisioningServiceNode, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
2
2
  import { IBaseService, IDebugLevel, ServiceEnum } from './models';
3
3
  import { RTPWebRTCService } from './services/RTPWebRTCService';
4
4
  export declare abstract class IRocosSDK {
@@ -27,6 +27,7 @@ export declare abstract class IRocosSDK {
27
27
  abstract getSpotProvisionerService(): SpotProvisioningService | SpotProvisioningServiceNode;
28
28
  abstract getIntegrationService(): IntegrationService;
29
29
  abstract getEvaluatorService(): EvaluatorService;
30
+ abstract getDeviceCredentialsService(): DeviceCredentialsService;
30
31
  abstract cleanup(): Promise<boolean>;
31
32
  abstract enableDebugMode(on: boolean): void;
32
33
  abstract setDebugLevel(level: IDebugLevel): void;
package/cjs/RocosSDK.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, ProfileService, ProjectService, RTPWebRTCService, RobotService, ScheduleService, SearchService, SpotProvisioningService, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
1
+ import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, DeviceCredentialsService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, ProfileService, ProjectService, RTPWebRTCService, RobotService, ScheduleService, SearchService, SpotProvisioningService, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
2
2
  import { AuthorisedConfig, IBaseService, IDebugLevel, IRocosSDKConfig, ServiceEnum } from './models';
3
3
  import { IRocosSDK } from './IRocosSDK';
4
4
  import { Logger } from 'loglevel';
@@ -19,7 +19,7 @@ export declare class RocosSDK implements IRocosSDK {
19
19
  */
20
20
  getService<T extends IBaseService>(name: ServiceEnum): T;
21
21
  /**
22
- * GEts the authentication service.
22
+ * Gets the authentication service.
23
23
  */
24
24
  getAuthService(): AuthService;
25
25
  /**
@@ -126,6 +126,11 @@ export declare class RocosSDK implements IRocosSDK {
126
126
  * @returns EvaluatorService
127
127
  */
128
128
  getEvaluatorService(): EvaluatorService;
129
+ /**
130
+ * Gets the device credentials service.
131
+ * @returns DeviceCredentialsService
132
+ */
133
+ getDeviceCredentialsService(): DeviceCredentialsService;
129
134
  get platformTimeOffset(): number;
130
135
  get platformTime(): number;
131
136
  /**
package/cjs/RocosSDK.js CHANGED
@@ -104,13 +104,16 @@ class RocosSDK {
104
104
  case models_1.ServiceEnum.EVALUATOR:
105
105
  this.services[name] = new services_1.EvaluatorService(config);
106
106
  break;
107
+ case models_1.ServiceEnum.DEVICE_CREDENTIALS:
108
+ this.services[name] = new services_1.DeviceCredentialsService(config);
109
+ break;
107
110
  }
108
111
  }
109
112
  this.logger.debug(`Found service ${name}.`);
110
113
  return this.services[name];
111
114
  }
112
115
  /**
113
- * GEts the authentication service.
116
+ * Gets the authentication service.
114
117
  */
115
118
  getAuthService() {
116
119
  return this.getService(models_1.ServiceEnum.AUTH);
@@ -267,6 +270,13 @@ class RocosSDK {
267
270
  getEvaluatorService() {
268
271
  return this.getService(models_1.ServiceEnum.EVALUATOR);
269
272
  }
273
+ /**
274
+ * Gets the device credentials service.
275
+ * @returns DeviceCredentialsService
276
+ */
277
+ getDeviceCredentialsService() {
278
+ return this.getService(models_1.ServiceEnum.DEVICE_CREDENTIALS);
279
+ }
270
280
  get platformTimeOffset() {
271
281
  return services_1.PlatFormTimeService.getInstance(this.getTimeSyncerService())?.platformTimeOffset;
272
282
  }
@@ -82,8 +82,8 @@ export declare const API_PROJECT_DEFINITION_ACTION_URL = "https://{url}/projects
82
82
  export declare const API_PROJECT_DEFINITION_BUTTON_URL = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/buttons";
83
83
  export declare const API_PROJECT_DEFINITION_TRIGGER_URL = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/triggers";
84
84
  export declare const API_PROJECT_DEFINITION_GAMEPAD_URL = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/gamepads";
85
- export declare const API_PROJECT_DEFINITION_EXPORT = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/export";
86
- export declare const API_PROJECT_DEFINITION_IMPORT = "https://{url}/projects/{projectId}/robot-definitions/import";
85
+ export declare const API_PROJECT_DEFINITION_EXPORT = "https://{url}/import-export/projects/{projectId}/robot-definitions/{definitionId}/export";
86
+ export declare const API_PROJECT_DEFINITION_IMPORT = "https://{url}/import-export/projects/{projectId}/robot-definitions/import";
87
87
  export declare const API_PROJECT_GROUP_TYPE_URL = "https://{url}/projects/{projectId}/config-groups/{type}";
88
88
  export declare const API_PROJECT_GROUP_TYPE_ID_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}";
89
89
  export declare const API_PROJECT_GROUP_TYPE_PUBLISH_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/publish";
@@ -131,3 +131,5 @@ export declare const API_PROJECT_WORKFLOW_ID_URL = "https://{url}/projects/{proj
131
131
  export declare const API_PROJECT_WORKFLOW_ASSET_URL = "https://{url}/projects/{projectId}/automate/flows/{workflowId}/assets";
132
132
  export declare const API_PROJECT_DEPLOYED_WORKFLOW_URL = "https://{url}/projects/{projectId}/robots/{callsign}/automate/flows/deployments";
133
133
  export declare const API_LINKED_PROJECT_URL = "https://{url}/linked-projects/{linkedProjectId}";
134
+ export declare const API_DEVICE_CREDENTIALS_URL = "https://{url}/projects/{projectId}/callsigns/{callsign}/device-credentials";
135
+ export declare const API_DEVICE_CREDENTIALS_AUTH_URL = "https://{url}/device-credentials/auth";
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.API_PROJECT_ROBOT_REGISTER_URL = exports.API_PROJECT_ROBOT_DEFINITION_URL = exports.API_PROJECT_ROBOT_ATTRIBUTES_URL = exports.API_PROJECT_ROBOT_ID_URL = exports.API_PROJECT_ROBOT_URL = exports.API_PROJECT_MAPPED_ASSETS_PATH_URL = exports.API_PROJECT_MISSION_ASSET_PATH_URL = exports.API_PROJECT_MISSION_ASSETS_PATH_URL = exports.API_PROJECT_FLOW_ASSET_PATH_URL = exports.API_PROJECT_ROBOT_ASSET_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATION_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATIONS_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATION_PROVIDERS_PATH_URL = exports.API_PROJECT_ASSET_PROFILES_SYNC_DEFINITION_PATH_URL = exports.API_PROJECT_ASSET_ROBOTS_SYNC_DEFINITION_PATH_URL = exports.API_PROJECT_ASSET_PATH_URL = exports.API_PROJECT_ASSET_URL = exports.API_PROJECT_USERS_URL = exports.API_PROJECT_ID_URL = exports.API_PROJECT_URL = exports.API_ACCOUNT_PROJECT_APPLICATION_ID_URL = exports.API_ACCOUNT_PROJECT_APPLICATION_URL = exports.API_ACCOUNT_PROJECT_USER_ID_URL = exports.API_ACCOUNT_PROJECT_USER_URL = exports.API_ACCOUNT_PROJECT_ID_URL = exports.API_ACCOUNT_PROJECT_URL = exports.API_SERVER_TIME_URL = exports.API_ACCOUNT_INTEGRATION_TYPE_URL = exports.API_ACCOUNT_INTEGRATION_URL = exports.API_ACCOUNT_SETTINGS_URL = exports.API_AUTH_USER_ACCOUNT_USER_ID_URL = exports.API_AUTH_USER_ACCOUNT_USER_URL = exports.API_ACCOUNT_ACTIVATE_URL = exports.API_ACCOUNT_ID_URL = exports.API_ACCOUNT_URL = exports.API_USER_PAT_TOKEN_URL = exports.API_USER_PAT_URL = exports.API_USER_VERIFY_EMAIL_URL = exports.API_USER_INVITATION_CHECK_URL = exports.API_USER_INVITATION_ACCEPT_URL = exports.API_USER_INVITATION_URL = exports.API_USER_PASSWORD_FORGOT_URL = exports.API_USER_PASSWORD_RESET_URL = exports.API_OTP_AUTH_URL = exports.API_OTP_URL = exports.API_USER_TOKEN_URL = exports.API_USER_AUTH_URL = exports.API_USER_URL = exports.API_ADMIN_USER_INVITATION_URL = exports.API_APPLICATION_AUTH_URL = void 0;
4
4
  exports.API_PROJECT_ROBOT_DASHBOARD_ID_URL = exports.API_PROJECT_ROBOT_DASHBOARD_URL = exports.API_PROJECT_STREAM_CALLSIGN_URL = exports.API_PROJECT_STREAM_DATA_URL = exports.API_PROJECT_STREAM_ID_URL = exports.API_PROJECT_STREAM_URL = exports.API_PROJECT_EXPORT_URL = exports.API_PROJECT_GROUP_TYPE_OWNER_OVERRIDE_URL = exports.API_PROJECT_GROUP_TYPE_OWNER_ID_URL = exports.API_PROJECT_GROUP_TYPE_VERSION_URL = exports.API_PROJECT_GROUP_TYPE_CONFIG_URL = exports.API_PROJECT_GROUP_TYPE_PUBLISH_URL = exports.API_PROJECT_GROUP_TYPE_ID_URL = exports.API_PROJECT_GROUP_TYPE_URL = exports.API_PROJECT_DEFINITION_IMPORT = exports.API_PROJECT_DEFINITION_EXPORT = exports.API_PROJECT_DEFINITION_GAMEPAD_URL = exports.API_PROJECT_DEFINITION_TRIGGER_URL = exports.API_PROJECT_DEFINITION_BUTTON_URL = exports.API_PROJECT_DEFINITION_ACTION_URL = exports.API_PROJECT_DEFINITION_EVENT_URL = exports.API_PROJECT_DEFINITION_COMMAND2_URL = exports.API_PROJECT_DEFINITION_COMMAND_URL = exports.API_PROJECT_DEFINITION_AGENT_URL = exports.API_PROJECT_DEFINITION_SETTING_URL = exports.API_PROJECT_DEFINITION_BLOB_URL = exports.API_PROJECT_DEFINITION_DASHBOARD_URL = exports.API_PROJECT_DEFINITION_COPY_URL = exports.API_PROJECT_DEFINITION_STREAM_URL = exports.API_PROJECT_DEFINITION_ID_URL = exports.API_PROJECT_DEFINITION_URL = exports.API_PROJECT_VROBOT_DEPLOY_URL = exports.API_PROJECT_VROBOT_DETAILS_URL = exports.API_PROJECT_COLLECTION_DOCS_URL = exports.API_PROJECT_COLLECTION_ID_URL = exports.API_PROJECT_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_DASHBOARD_WIDGET_URL = exports.API_PROJECT_DASHBOARD_ID_URL = exports.API_PROJECT_DASHBOARD_URL = exports.API_PROJECT_OPERATION_ID_URL = exports.API_PROJECT_OPERATION_URL = exports.API_PROJECT_ROBOT_GAMEPAD_URL = exports.API_PROJECT_ROBOT_TRIGGER_URL = exports.API_PROJECT_ROBOT_BUTTON_URL = exports.API_PROJECT_ROBOT_COMMAND2_URL = exports.API_PROJECT_ROBOT_COMMAND_URL = exports.API_PROJECT_ROBOT_AGENT_URL = exports.API_PROJECT_ROBOT_SETTING_URL = exports.API_PROJECT_ROBOT_EVENT_HISTORY_URL = exports.API_PROJECT_ROBOT_EVENT_URL = void 0;
5
- exports.API_LINKED_PROJECT_URL = exports.API_PROJECT_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_WORKFLOW_ASSET_URL = exports.API_PROJECT_WORKFLOW_ID_URL = exports.API_PROJECT_WORKFLOW_URL = exports.API_OBSERVATION_KEYS_URL = exports.API_OBSERVATIONS_URL = exports.API_MAPS_PANORAMA_OBSERVATIONS_URL = exports.API_MAPS_GEOJSON_URL = exports.API_MAPS_DEPLOY_URL = exports.API_MAPS_COPY_URL = exports.API_MAP_ID_URL = exports.API_MAPS_MERGE_URL = exports.API_MAPS_DEPLOYED_URL = exports.API_MAPS_URL = exports.API_DD_INTEGRATION_ISSUES_URL = exports.API_DD_INTEGRATION_OVERLAYS_URL = exports.API_DD_INTEGRATION_PLAN_BY_ID_URL = exports.API_DD_INTEGRATION_PLANS_URL = exports.API_SPOTTY_URL = exports.API_PROJECT_SCHEDULES_URL = exports.API_SOURCE_ID_URL = exports.API_SOURCE_URL = exports.API_SOURCE_SCHEMA_URL = exports.API_TEMPLATE_EXPORTER_URL = exports.API_TEMPLATE_PROVISION_ID_URL = exports.API_TEMPLATE_PROVISION_URL = exports.API_TEMPLATE_DEPLOY_URL = exports.API_PROJECT_PROFILE_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_PROFILE_DASHBOARD_ID_URL = exports.API_PROJECT_PROFILE_DASHBOARD_URL = exports.API_PROJECT_CALLSIGN_STREAM_URL = exports.API_PROJECT_ROBOT_DASHBOARD_CUSTOM_WIDGET_URL = void 0;
5
+ exports.API_DEVICE_CREDENTIALS_AUTH_URL = exports.API_DEVICE_CREDENTIALS_URL = exports.API_LINKED_PROJECT_URL = exports.API_PROJECT_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_WORKFLOW_ASSET_URL = exports.API_PROJECT_WORKFLOW_ID_URL = exports.API_PROJECT_WORKFLOW_URL = exports.API_OBSERVATION_KEYS_URL = exports.API_OBSERVATIONS_URL = exports.API_MAPS_PANORAMA_OBSERVATIONS_URL = exports.API_MAPS_GEOJSON_URL = exports.API_MAPS_DEPLOY_URL = exports.API_MAPS_COPY_URL = exports.API_MAP_ID_URL = exports.API_MAPS_MERGE_URL = exports.API_MAPS_DEPLOYED_URL = exports.API_MAPS_URL = exports.API_DD_INTEGRATION_ISSUES_URL = exports.API_DD_INTEGRATION_OVERLAYS_URL = exports.API_DD_INTEGRATION_PLAN_BY_ID_URL = exports.API_DD_INTEGRATION_PLANS_URL = exports.API_SPOTTY_URL = exports.API_PROJECT_SCHEDULES_URL = exports.API_SOURCE_ID_URL = exports.API_SOURCE_URL = exports.API_SOURCE_SCHEMA_URL = exports.API_TEMPLATE_EXPORTER_URL = exports.API_TEMPLATE_PROVISION_ID_URL = exports.API_TEMPLATE_PROVISION_URL = exports.API_TEMPLATE_DEPLOY_URL = exports.API_PROJECT_PROFILE_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_PROFILE_DASHBOARD_ID_URL = exports.API_PROJECT_PROFILE_DASHBOARD_URL = exports.API_PROJECT_CALLSIGN_STREAM_URL = exports.API_PROJECT_ROBOT_DASHBOARD_CUSTOM_WIDGET_URL = void 0;
6
6
  exports.API_APPLICATION_AUTH_URL = 'https://{url}/applications/auth';
7
7
  exports.API_ADMIN_USER_INVITATION_URL = 'https://{url}/admin/users/invitations';
8
8
  exports.API_USER_URL = 'https://{url}/users';
@@ -87,8 +87,8 @@ exports.API_PROJECT_DEFINITION_ACTION_URL = 'https://{url}/projects/{projectId}/
87
87
  exports.API_PROJECT_DEFINITION_BUTTON_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/buttons';
88
88
  exports.API_PROJECT_DEFINITION_TRIGGER_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/triggers';
89
89
  exports.API_PROJECT_DEFINITION_GAMEPAD_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/gamepads';
90
- exports.API_PROJECT_DEFINITION_EXPORT = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/export';
91
- exports.API_PROJECT_DEFINITION_IMPORT = 'https://{url}/projects/{projectId}/robot-definitions/import';
90
+ exports.API_PROJECT_DEFINITION_EXPORT = 'https://{url}/import-export/projects/{projectId}/robot-definitions/{definitionId}/export';
91
+ exports.API_PROJECT_DEFINITION_IMPORT = 'https://{url}/import-export/projects/{projectId}/robot-definitions/import';
92
92
  exports.API_PROJECT_GROUP_TYPE_URL = 'https://{url}/projects/{projectId}/config-groups/{type}';
93
93
  exports.API_PROJECT_GROUP_TYPE_ID_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}';
94
94
  exports.API_PROJECT_GROUP_TYPE_PUBLISH_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/publish';
@@ -136,3 +136,5 @@ exports.API_PROJECT_WORKFLOW_ID_URL = 'https://{url}/projects/{projectId}/automa
136
136
  exports.API_PROJECT_WORKFLOW_ASSET_URL = 'https://{url}/projects/{projectId}/automate/flows/{workflowId}/assets';
137
137
  exports.API_PROJECT_DEPLOYED_WORKFLOW_URL = 'https://{url}/projects/{projectId}/robots/{callsign}/automate/flows/deployments';
138
138
  exports.API_LINKED_PROJECT_URL = 'https://{url}/linked-projects/{linkedProjectId}';
139
+ exports.API_DEVICE_CREDENTIALS_URL = 'https://{url}/projects/{projectId}/callsigns/{callsign}/device-credentials';
140
+ exports.API_DEVICE_CREDENTIALS_AUTH_URL = 'https://{url}/device-credentials/auth';
@@ -24,6 +24,7 @@ export declare const errorCodes: {
24
24
  MAPS_SERVICE_ERROR: string;
25
25
  EVALUATOR_SERVICE_ERROR: string;
26
26
  WEBRTC_SERVICE_ERROR: string;
27
+ DEVICE_CREDENTIALS_SERVICE_ERROR: string;
27
28
  };
28
29
  export declare class RocosError extends Error {
29
30
  code?: string;
@@ -27,6 +27,7 @@ exports.errorCodes = {
27
27
  MAPS_SERVICE_ERROR: 'MAPS_SERVICE_ERROR',
28
28
  EVALUATOR_SERVICE_ERROR: 'EVALUATOR_SERVICE_ERROR',
29
29
  WEBRTC_SERVICE_ERROR: 'WEBRTC_SERVICE_ERROR',
30
+ DEVICE_CREDENTIALS_SERVICE_ERROR: 'DEVICE_CREDENTIALS_SERVICE_ERROR',
30
31
  };
31
32
  class RocosError extends Error {
32
33
  constructor(err, code, statusCode) {
@@ -24,5 +24,6 @@ export declare enum ServiceEnum {
24
24
  INTEGRATION = "integration",
25
25
  MAP = "map",
26
26
  EVALUATOR = "evaluator",
27
- RTP_WEBRTC = "rtp_webrtc"
27
+ RTP_WEBRTC = "rtp_webrtc",
28
+ DEVICE_CREDENTIALS = "device_credentials"
28
29
  }
@@ -29,4 +29,5 @@ var ServiceEnum;
29
29
  ServiceEnum["MAP"] = "map";
30
30
  ServiceEnum["EVALUATOR"] = "evaluator";
31
31
  ServiceEnum["RTP_WEBRTC"] = "rtp_webrtc";
32
+ ServiceEnum["DEVICE_CREDENTIALS"] = "device_credentials";
32
33
  })(ServiceEnum || (exports.ServiceEnum = ServiceEnum = {}));
@@ -0,0 +1,61 @@
1
+ export interface DeviceCredentials {
2
+ [component: string]: {
3
+ [system: string]: DeviceCredential;
4
+ };
5
+ }
6
+ export interface DeviceCredential {
7
+ /**
8
+ * Device ID or username
9
+ */
10
+ id: string;
11
+ /**
12
+ * Device secret or password
13
+ */
14
+ key: string;
15
+ }
16
+ export interface DeviceCredentialCreate {
17
+ /**
18
+ * Will automatically be generated if not provided
19
+ */
20
+ id?: string;
21
+ /**
22
+ * Will automatically be generated if not provided
23
+ */
24
+ key?: string;
25
+ /**
26
+ * The agent component the credentials are for e.g. dji, spot, etc.
27
+ */
28
+ component: string;
29
+ /**
30
+ * The system the credentials are for e.g. mqtt, rtmp, etc.
31
+ */
32
+ system: string;
33
+ /**
34
+ * Access control list for the credentials
35
+ */
36
+ acl?: DeviceCredentialACLItem[];
37
+ }
38
+ export interface DeviceCredentialACLItem {
39
+ /**
40
+ * The resource the ACL item is for e.g. /sys/product/{device_sn}/*
41
+ */
42
+ resource: string;
43
+ /**
44
+ * The action the ACL item is for e.g. allow, deny, ignore
45
+ */
46
+ action: DeviceCredentialAuthAction;
47
+ }
48
+ export type DeviceCredentialAuthAction = 'allow' | 'deny' | 'ignore';
49
+ export interface DeviceCredentialAuth extends DeviceCredential {
50
+ /**
51
+ * The agent component the credentials are for e.g. dji, spot, etc.
52
+ */
53
+ component: string;
54
+ /**
55
+ * The system the credentials are for e.g. mqtt, rtmp, etc.
56
+ */
57
+ system: string;
58
+ }
59
+ export interface DeviceCredentialAuthResult {
60
+ result: 'allow' | 'deny';
61
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { EvaluatorService, ScheduleService } from '../services';
1
+ import { DeviceCredentialsService, EvaluatorService, ScheduleService } from '../services';
2
2
  import { IBaseService, ServiceEnum } from '../models';
3
3
  import { CallerServiceNode } from '../services/CallerServiceNode';
4
4
  import { CommandServiceNode } from '../services/CommandServiceNode';
@@ -48,4 +48,5 @@ export declare class RocosSDKNode extends RocosSDK {
48
48
  * @deprecated Not supported in Node.js
49
49
  */
50
50
  getRTPWebRTCService(): never;
51
+ getDeviceCredentialsService(): DeviceCredentialsService;
51
52
  }
@@ -81,6 +81,9 @@ class RocosSDKNode extends RocosSDK_1.RocosSDK {
81
81
  case models_1.ServiceEnum.MAP:
82
82
  this.services[name] = new services_1.MapService(config);
83
83
  break;
84
+ case models_1.ServiceEnum.DEVICE_CREDENTIALS:
85
+ this.services[name] = new services_1.DeviceCredentialsService(config);
86
+ break;
84
87
  }
85
88
  }
86
89
  this.logger.debug(`Found service ${name}.`);
@@ -143,5 +146,8 @@ class RocosSDKNode extends RocosSDK_1.RocosSDK {
143
146
  getRTPWebRTCService() {
144
147
  throw new Error('WebRTC service is not supported in NodeJS');
145
148
  }
149
+ getDeviceCredentialsService() {
150
+ return this.getService(models_1.ServiceEnum.DEVICE_CREDENTIALS);
151
+ }
146
152
  }
147
153
  exports.RocosSDKNode = RocosSDKNode;
@@ -1,10 +1,20 @@
1
1
  import { IBaseService, IRocosSDKConfig, RocosError, Token } from '../models';
2
+ import { Observable } from 'rxjs';
2
3
  import { BaseServiceAbstract } from './BaseServiceAbstract';
3
4
  export declare class AuthService extends BaseServiceAbstract implements IBaseService {
4
5
  protected config: IRocosSDKConfig;
5
6
  private token?;
6
7
  private tokenRefreshTimeoutId?;
8
+ private tokenSubject$;
7
9
  constructor(config: IRocosSDKConfig);
10
+ /** Observable for token updates
11
+ *
12
+ * This is useful for getting notified when the token changes.
13
+ * i.e. when the token is refreshed from the token refresh checker.
14
+ *
15
+ * This will not emit until the token is set, either by `setToken` or by getting a new token.
16
+ */
17
+ get tokenUpdates$(): Observable<Token>;
8
18
  getStatus(): boolean;
9
19
  teardown(): void;
10
20
  protected getError(e: RocosError): RocosError;
@@ -62,9 +72,10 @@ export declare class AuthService extends BaseServiceAbstract implements IBaseSer
62
72
  * If you want to refresh the token regardless of the expiry time, use `refreshToken`.
63
73
  *
64
74
  * @param minutes the number of minutes before the token expires to refresh the token
75
+ * @returns true if the token was refreshed
65
76
  * @see refreshToken
66
77
  */
67
- refreshTokenIfExpired(minutes: number): Promise<void>;
78
+ refreshTokenIfExpired(minutes: number): Promise<boolean>;
68
79
  /** Start a 5-minute loop to check if the token needs to be refreshed
69
80
  *
70
81
  * This is useful when you are using GRPC services (i.e. telemetry) which does not automatically refresh the token.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AuthService = void 0;
4
4
  const api_1 = require("../constants/api");
5
5
  const models_1 = require("../models");
6
+ const rxjs_1 = require("rxjs");
6
7
  const BaseServiceAbstract_1 = require("./BaseServiceAbstract");
7
8
  const RocosLogger_1 = require("../logger/RocosLogger");
8
9
  const RocosStore_1 = require("../store/RocosStore");
@@ -12,11 +13,25 @@ class AuthService extends BaseServiceAbstract_1.BaseServiceAbstract {
12
13
  constructor(config) {
13
14
  super(config);
14
15
  this.config = config;
16
+ this.tokenSubject$ = new rxjs_1.Subject();
15
17
  this.config = config;
16
18
  this.logger = RocosLogger_1.RocosLogger.getInstance(`AuthService(${this.config.url})`);
17
19
  if (this.config.token) {
18
20
  this.setToken(this.config.token);
19
21
  }
22
+ this.tokenUpdates$.subscribe((token) => {
23
+ RocosStore_1.RocosStore.getChangeSubject().next({ type: 'token', url: this.config.url, data: token.value });
24
+ });
25
+ }
26
+ /** Observable for token updates
27
+ *
28
+ * This is useful for getting notified when the token changes.
29
+ * i.e. when the token is refreshed from the token refresh checker.
30
+ *
31
+ * This will not emit until the token is set, either by `setToken` or by getting a new token.
32
+ */
33
+ get tokenUpdates$() {
34
+ return this.tokenSubject$.asObservable();
20
35
  }
21
36
  getStatus() {
22
37
  return true;
@@ -42,7 +57,7 @@ class AuthService extends BaseServiceAbstract_1.BaseServiceAbstract {
42
57
  }
43
58
  this.config.token = this.token.value;
44
59
  // output a message for token change
45
- RocosStore_1.RocosStore.getChangeSubject().next({ type: 'token', url: this.config.url, data: this.token.value });
60
+ this.tokenSubject$?.next(this.token);
46
61
  }
47
62
  /**
48
63
  * Clear token
@@ -166,6 +181,7 @@ class AuthService extends BaseServiceAbstract_1.BaseServiceAbstract {
166
181
  * If you want to refresh the token regardless of the expiry time, use `refreshToken`.
167
182
  *
168
183
  * @param minutes the number of minutes before the token expires to refresh the token
184
+ * @returns true if the token was refreshed
169
185
  * @see refreshToken
170
186
  */
171
187
  async refreshTokenIfExpired(minutes) {
@@ -173,7 +189,9 @@ class AuthService extends BaseServiceAbstract_1.BaseServiceAbstract {
173
189
  this.logger.info('Token expires in 15 minutes. Refreshing.');
174
190
  const newToken = await this.refreshToken();
175
191
  this.setToken(newToken);
192
+ return true;
176
193
  }
194
+ return false;
177
195
  }
178
196
  /** Start a 5-minute loop to check if the token needs to be refreshed
179
197
  *
@@ -0,0 +1,15 @@
1
+ import { DeviceCredentialAuth, DeviceCredentialAuthResult, DeviceCredentialCreate, DeviceCredentials } from '../models/device-credentials/DeviceCredentials';
2
+ import { IBaseService, IRocosSDKConfig, RocosError } from '../models';
3
+ import { BaseServiceAbstract } from './BaseServiceAbstract';
4
+ /**
5
+ * Manage external devices authenticating with the platform
6
+ */
7
+ export declare class DeviceCredentialsService extends BaseServiceAbstract implements IBaseService {
8
+ constructor(config: IRocosSDKConfig);
9
+ getStatus(): boolean;
10
+ protected getError(e: Error): RocosError;
11
+ list(projectId: string, callsign: string): Promise<DeviceCredentials>;
12
+ create(projectId: string, callsign: string, credentials: DeviceCredentialCreate): Promise<DeviceCredentialCreate>;
13
+ delete(projectId: string, callsign: string, component: string, system: string): Promise<void>;
14
+ auth(credentials: DeviceCredentialAuth): Promise<DeviceCredentialAuthResult>;
15
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeviceCredentialsService = void 0;
4
+ const api_1 = require("../constants/api");
5
+ const models_1 = require("../models");
6
+ const BaseServiceAbstract_1 = require("./BaseServiceAbstract");
7
+ const RocosLogger_1 = require("../logger/RocosLogger");
8
+ const formatServiceUrl_1 = require("../helpers/formatServiceUrl");
9
+ /**
10
+ * Manage external devices authenticating with the platform
11
+ */
12
+ class DeviceCredentialsService extends BaseServiceAbstract_1.BaseServiceAbstract {
13
+ constructor(config) {
14
+ super(config);
15
+ this.logger = RocosLogger_1.RocosLogger.getInstance(`DeviceCredentials(${this.config.url})`);
16
+ }
17
+ getStatus() {
18
+ return true;
19
+ }
20
+ getError(e) {
21
+ return new models_1.RocosError(e, models_1.errorCodes.DEVICE_CREDENTIALS_SERVICE_ERROR);
22
+ }
23
+ list(projectId, callsign) {
24
+ return this.callGet((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_DEVICE_CREDENTIALS_URL, {
25
+ url: this.config.url,
26
+ projectId,
27
+ callsign,
28
+ }, this.config.insecure), 'Failed to get device credentials.');
29
+ }
30
+ create(projectId, callsign, credentials) {
31
+ return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_DEVICE_CREDENTIALS_URL, {
32
+ url: this.config.url,
33
+ projectId,
34
+ callsign,
35
+ }, this.config.insecure), credentials, 'Failed to create device credentials.');
36
+ }
37
+ delete(projectId, callsign, component, system) {
38
+ return this.callDelete((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_DEVICE_CREDENTIALS_URL, {
39
+ url: this.config.url,
40
+ projectId,
41
+ callsign,
42
+ }, this.config.insecure), 'Failed to delete device credentials.', { component, system });
43
+ }
44
+ auth(credentials) {
45
+ return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_DEVICE_CREDENTIALS_AUTH_URL, {
46
+ url: this.config.url,
47
+ }, this.config.insecure), credentials, 'Failed to delete device credentials.');
48
+ }
49
+ }
50
+ exports.DeviceCredentialsService = DeviceCredentialsService;
@@ -2,7 +2,7 @@ import { IBaseService, IRocosSDKConfig, Map, RocosError } from '../models';
2
2
  import { BaseServiceAbstract } from './BaseServiceAbstract';
3
3
  import { Observation } from '../models/maps/Panorama';
4
4
  /**
5
- * Integrations to retrieve data from the linked project in DroneDeploy
5
+ * Maps service for managing robot maps in the cloud and on robots
6
6
  */
7
7
  export declare class MapService extends BaseServiceAbstract implements IBaseService {
8
8
  constructor(config: IRocosSDKConfig);
@@ -7,7 +7,7 @@ const BaseServiceAbstract_1 = require("./BaseServiceAbstract");
7
7
  const RocosLogger_1 = require("../logger/RocosLogger");
8
8
  const formatServiceUrl_1 = require("../helpers/formatServiceUrl");
9
9
  /**
10
- * Integrations to retrieve data from the linked project in DroneDeploy
10
+ * Maps service for managing robot maps in the cloud and on robots
11
11
  */
12
12
  class MapService extends BaseServiceAbstract_1.BaseServiceAbstract {
13
13
  constructor(config) {
@@ -249,10 +249,11 @@ export declare class ProfileService extends BaseServiceAbstract implements IBase
249
249
  * @param projectId - Project Id
250
250
  * @param profileData - Robot definition data
251
251
  * @param newName - Optional new name for the robot definition. If not provided, the name from the imported definition will be used.
252
+ * @param newDescription - Optional new description for the robot definition. If not provided, the description from the imported definition will be used.
252
253
  *
253
254
  * @see export
254
255
  */
255
- import(projectId: string, profileData: Record<string, unknown>, newName?: string): Promise<{
256
+ import(projectId: string, profileData: Blob | File, newName?: string, newDescription?: string): Promise<{
256
257
  profileId: string;
257
258
  }>;
258
259
  /**
@@ -367,14 +367,20 @@ class ProfileService extends BaseServiceAbstract_1.BaseServiceAbstract {
367
367
  * @param projectId - Project Id
368
368
  * @param profileData - Robot definition data
369
369
  * @param newName - Optional new name for the robot definition. If not provided, the name from the imported definition will be used.
370
+ * @param newDescription - Optional new description for the robot definition. If not provided, the description from the imported definition will be used.
370
371
  *
371
372
  * @see export
372
373
  */
373
- async import(projectId, profileData, newName) {
374
+ async import(projectId, profileData, newName, newDescription) {
375
+ const formData = new FormData();
374
376
  if (newName) {
375
- profileData.name = newName;
377
+ formData.append('name', newName);
376
378
  }
377
- return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_DEFINITION_IMPORT, { url: this.config.url, projectId }, this.config.insecure), profileData, `Failed to import robot definition for ${projectId}.`);
379
+ if (newDescription) {
380
+ formData.append('description', newDescription);
381
+ }
382
+ formData.append('file', profileData);
383
+ return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_DEFINITION_IMPORT, { url: this.config.url, projectId }, this.config.insecure), formData, `Failed to import robot definition for ${projectId}.`);
378
384
  }
379
385
  /**
380
386
  * Update gamepads for a robot definition
@@ -5,6 +5,7 @@ export * from './CommandService';
5
5
  export * from './ConfigGroupService';
6
6
  export * from './ControlService';
7
7
  export * from './DashboardService';
8
+ export * from './DeviceCredentialsService';
8
9
  export * from './EventService';
9
10
  export * from './FileAccessorService';
10
11
  export * from './IntegrationService';
@@ -21,6 +21,7 @@ __exportStar(require("./CommandService"), exports);
21
21
  __exportStar(require("./ConfigGroupService"), exports);
22
22
  __exportStar(require("./ControlService"), exports);
23
23
  __exportStar(require("./DashboardService"), exports);
24
+ __exportStar(require("./DeviceCredentialsService"), exports);
24
25
  __exportStar(require("./EventService"), exports);
25
26
  __exportStar(require("./FileAccessorService"), exports);
26
27
  __exportStar(require("./IntegrationService"), exports);
@@ -1,4 +1,4 @@
1
- import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, SearchService, SpotProvisioningService, SpotProvisioningServiceNode, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
1
+ import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, DeviceCredentialsService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, SearchService, SpotProvisioningService, SpotProvisioningServiceNode, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
2
2
  import { IBaseService, IDebugLevel, ServiceEnum } from './models';
3
3
  import { RTPWebRTCService } from './services/RTPWebRTCService';
4
4
  export declare abstract class IRocosSDK {
@@ -27,6 +27,7 @@ export declare abstract class IRocosSDK {
27
27
  abstract getSpotProvisionerService(): SpotProvisioningService | SpotProvisioningServiceNode;
28
28
  abstract getIntegrationService(): IntegrationService;
29
29
  abstract getEvaluatorService(): EvaluatorService;
30
+ abstract getDeviceCredentialsService(): DeviceCredentialsService;
30
31
  abstract cleanup(): Promise<boolean>;
31
32
  abstract enableDebugMode(on: boolean): void;
32
33
  abstract setDebugLevel(level: IDebugLevel): void;
package/esm/RocosSDK.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, ProfileService, ProjectService, RTPWebRTCService, RobotService, ScheduleService, SearchService, SpotProvisioningService, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
1
+ import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, DeviceCredentialsService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, ProfileService, ProjectService, RTPWebRTCService, RobotService, ScheduleService, SearchService, SpotProvisioningService, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
2
2
  import { AuthorisedConfig, IBaseService, IDebugLevel, IRocosSDKConfig, ServiceEnum } from './models';
3
3
  import { IRocosSDK } from './IRocosSDK';
4
4
  import { Logger } from 'loglevel';
@@ -19,7 +19,7 @@ export declare class RocosSDK implements IRocosSDK {
19
19
  */
20
20
  getService<T extends IBaseService>(name: ServiceEnum): T;
21
21
  /**
22
- * GEts the authentication service.
22
+ * Gets the authentication service.
23
23
  */
24
24
  getAuthService(): AuthService;
25
25
  /**
@@ -126,6 +126,11 @@ export declare class RocosSDK implements IRocosSDK {
126
126
  * @returns EvaluatorService
127
127
  */
128
128
  getEvaluatorService(): EvaluatorService;
129
+ /**
130
+ * Gets the device credentials service.
131
+ * @returns DeviceCredentialsService
132
+ */
133
+ getDeviceCredentialsService(): DeviceCredentialsService;
129
134
  get platformTimeOffset(): number;
130
135
  get platformTime(): number;
131
136
  /**
package/esm/RocosSDK.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, PlatFormTimeService, ProfileService, ProjectService, RTPWebRTCService, RobotService, ScheduleService, SearchService, SpotProvisioningService, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService, } from './services';
1
+ import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, DeviceCredentialsService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, PlatFormTimeService, ProfileService, ProjectService, RTPWebRTCService, RobotService, ScheduleService, SearchService, SpotProvisioningService, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService, } from './services';
2
2
  import { ServiceEnum } from './models';
3
3
  import { RocosLogger } from './logger/RocosLogger';
4
4
  import { RocosStore } from './store/RocosStore';
@@ -101,13 +101,16 @@ export class RocosSDK {
101
101
  case ServiceEnum.EVALUATOR:
102
102
  this.services[name] = new EvaluatorService(config);
103
103
  break;
104
+ case ServiceEnum.DEVICE_CREDENTIALS:
105
+ this.services[name] = new DeviceCredentialsService(config);
106
+ break;
104
107
  }
105
108
  }
106
109
  this.logger.debug(`Found service ${name}.`);
107
110
  return this.services[name];
108
111
  }
109
112
  /**
110
- * GEts the authentication service.
113
+ * Gets the authentication service.
111
114
  */
112
115
  getAuthService() {
113
116
  return this.getService(ServiceEnum.AUTH);
@@ -264,6 +267,13 @@ export class RocosSDK {
264
267
  getEvaluatorService() {
265
268
  return this.getService(ServiceEnum.EVALUATOR);
266
269
  }
270
+ /**
271
+ * Gets the device credentials service.
272
+ * @returns DeviceCredentialsService
273
+ */
274
+ getDeviceCredentialsService() {
275
+ return this.getService(ServiceEnum.DEVICE_CREDENTIALS);
276
+ }
267
277
  get platformTimeOffset() {
268
278
  return PlatFormTimeService.getInstance(this.getTimeSyncerService())?.platformTimeOffset;
269
279
  }
@@ -82,8 +82,8 @@ export declare const API_PROJECT_DEFINITION_ACTION_URL = "https://{url}/projects
82
82
  export declare const API_PROJECT_DEFINITION_BUTTON_URL = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/buttons";
83
83
  export declare const API_PROJECT_DEFINITION_TRIGGER_URL = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/triggers";
84
84
  export declare const API_PROJECT_DEFINITION_GAMEPAD_URL = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/gamepads";
85
- export declare const API_PROJECT_DEFINITION_EXPORT = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/export";
86
- export declare const API_PROJECT_DEFINITION_IMPORT = "https://{url}/projects/{projectId}/robot-definitions/import";
85
+ export declare const API_PROJECT_DEFINITION_EXPORT = "https://{url}/import-export/projects/{projectId}/robot-definitions/{definitionId}/export";
86
+ export declare const API_PROJECT_DEFINITION_IMPORT = "https://{url}/import-export/projects/{projectId}/robot-definitions/import";
87
87
  export declare const API_PROJECT_GROUP_TYPE_URL = "https://{url}/projects/{projectId}/config-groups/{type}";
88
88
  export declare const API_PROJECT_GROUP_TYPE_ID_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}";
89
89
  export declare const API_PROJECT_GROUP_TYPE_PUBLISH_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/publish";
@@ -131,3 +131,5 @@ export declare const API_PROJECT_WORKFLOW_ID_URL = "https://{url}/projects/{proj
131
131
  export declare const API_PROJECT_WORKFLOW_ASSET_URL = "https://{url}/projects/{projectId}/automate/flows/{workflowId}/assets";
132
132
  export declare const API_PROJECT_DEPLOYED_WORKFLOW_URL = "https://{url}/projects/{projectId}/robots/{callsign}/automate/flows/deployments";
133
133
  export declare const API_LINKED_PROJECT_URL = "https://{url}/linked-projects/{linkedProjectId}";
134
+ export declare const API_DEVICE_CREDENTIALS_URL = "https://{url}/projects/{projectId}/callsigns/{callsign}/device-credentials";
135
+ export declare const API_DEVICE_CREDENTIALS_AUTH_URL = "https://{url}/device-credentials/auth";
@@ -82,8 +82,8 @@ export const API_PROJECT_DEFINITION_ACTION_URL = 'https://{url}/projects/{projec
82
82
  export const API_PROJECT_DEFINITION_BUTTON_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/buttons';
83
83
  export const API_PROJECT_DEFINITION_TRIGGER_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/triggers';
84
84
  export const API_PROJECT_DEFINITION_GAMEPAD_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/gamepads';
85
- export const API_PROJECT_DEFINITION_EXPORT = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/export';
86
- export const API_PROJECT_DEFINITION_IMPORT = 'https://{url}/projects/{projectId}/robot-definitions/import';
85
+ export const API_PROJECT_DEFINITION_EXPORT = 'https://{url}/import-export/projects/{projectId}/robot-definitions/{definitionId}/export';
86
+ export const API_PROJECT_DEFINITION_IMPORT = 'https://{url}/import-export/projects/{projectId}/robot-definitions/import';
87
87
  export const API_PROJECT_GROUP_TYPE_URL = 'https://{url}/projects/{projectId}/config-groups/{type}';
88
88
  export const API_PROJECT_GROUP_TYPE_ID_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}';
89
89
  export const API_PROJECT_GROUP_TYPE_PUBLISH_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/publish';
@@ -131,3 +131,5 @@ export const API_PROJECT_WORKFLOW_ID_URL = 'https://{url}/projects/{projectId}/a
131
131
  export const API_PROJECT_WORKFLOW_ASSET_URL = 'https://{url}/projects/{projectId}/automate/flows/{workflowId}/assets';
132
132
  export const API_PROJECT_DEPLOYED_WORKFLOW_URL = 'https://{url}/projects/{projectId}/robots/{callsign}/automate/flows/deployments';
133
133
  export const API_LINKED_PROJECT_URL = 'https://{url}/linked-projects/{linkedProjectId}';
134
+ export const API_DEVICE_CREDENTIALS_URL = 'https://{url}/projects/{projectId}/callsigns/{callsign}/device-credentials';
135
+ export const API_DEVICE_CREDENTIALS_AUTH_URL = 'https://{url}/device-credentials/auth';
@@ -24,6 +24,7 @@ export declare const errorCodes: {
24
24
  MAPS_SERVICE_ERROR: string;
25
25
  EVALUATOR_SERVICE_ERROR: string;
26
26
  WEBRTC_SERVICE_ERROR: string;
27
+ DEVICE_CREDENTIALS_SERVICE_ERROR: string;
27
28
  };
28
29
  export declare class RocosError extends Error {
29
30
  code?: string;
@@ -24,6 +24,7 @@ export const errorCodes = {
24
24
  MAPS_SERVICE_ERROR: 'MAPS_SERVICE_ERROR',
25
25
  EVALUATOR_SERVICE_ERROR: 'EVALUATOR_SERVICE_ERROR',
26
26
  WEBRTC_SERVICE_ERROR: 'WEBRTC_SERVICE_ERROR',
27
+ DEVICE_CREDENTIALS_SERVICE_ERROR: 'DEVICE_CREDENTIALS_SERVICE_ERROR',
27
28
  };
28
29
  export class RocosError extends Error {
29
30
  constructor(err, code, statusCode) {
@@ -24,5 +24,6 @@ export declare enum ServiceEnum {
24
24
  INTEGRATION = "integration",
25
25
  MAP = "map",
26
26
  EVALUATOR = "evaluator",
27
- RTP_WEBRTC = "rtp_webrtc"
27
+ RTP_WEBRTC = "rtp_webrtc",
28
+ DEVICE_CREDENTIALS = "device_credentials"
28
29
  }
@@ -26,4 +26,5 @@ export var ServiceEnum;
26
26
  ServiceEnum["MAP"] = "map";
27
27
  ServiceEnum["EVALUATOR"] = "evaluator";
28
28
  ServiceEnum["RTP_WEBRTC"] = "rtp_webrtc";
29
+ ServiceEnum["DEVICE_CREDENTIALS"] = "device_credentials";
29
30
  })(ServiceEnum || (ServiceEnum = {}));
@@ -0,0 +1,61 @@
1
+ export interface DeviceCredentials {
2
+ [component: string]: {
3
+ [system: string]: DeviceCredential;
4
+ };
5
+ }
6
+ export interface DeviceCredential {
7
+ /**
8
+ * Device ID or username
9
+ */
10
+ id: string;
11
+ /**
12
+ * Device secret or password
13
+ */
14
+ key: string;
15
+ }
16
+ export interface DeviceCredentialCreate {
17
+ /**
18
+ * Will automatically be generated if not provided
19
+ */
20
+ id?: string;
21
+ /**
22
+ * Will automatically be generated if not provided
23
+ */
24
+ key?: string;
25
+ /**
26
+ * The agent component the credentials are for e.g. dji, spot, etc.
27
+ */
28
+ component: string;
29
+ /**
30
+ * The system the credentials are for e.g. mqtt, rtmp, etc.
31
+ */
32
+ system: string;
33
+ /**
34
+ * Access control list for the credentials
35
+ */
36
+ acl?: DeviceCredentialACLItem[];
37
+ }
38
+ export interface DeviceCredentialACLItem {
39
+ /**
40
+ * The resource the ACL item is for e.g. /sys/product/{device_sn}/*
41
+ */
42
+ resource: string;
43
+ /**
44
+ * The action the ACL item is for e.g. allow, deny, ignore
45
+ */
46
+ action: DeviceCredentialAuthAction;
47
+ }
48
+ export type DeviceCredentialAuthAction = 'allow' | 'deny' | 'ignore';
49
+ export interface DeviceCredentialAuth extends DeviceCredential {
50
+ /**
51
+ * The agent component the credentials are for e.g. dji, spot, etc.
52
+ */
53
+ component: string;
54
+ /**
55
+ * The system the credentials are for e.g. mqtt, rtmp, etc.
56
+ */
57
+ system: string;
58
+ }
59
+ export interface DeviceCredentialAuthResult {
60
+ result: 'allow' | 'deny';
61
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { EvaluatorService, ScheduleService } from '../services';
1
+ import { DeviceCredentialsService, EvaluatorService, ScheduleService } from '../services';
2
2
  import { IBaseService, ServiceEnum } from '../models';
3
3
  import { CallerServiceNode } from '../services/CallerServiceNode';
4
4
  import { CommandServiceNode } from '../services/CommandServiceNode';
@@ -48,4 +48,5 @@ export declare class RocosSDKNode extends RocosSDK {
48
48
  * @deprecated Not supported in Node.js
49
49
  */
50
50
  getRTPWebRTCService(): never;
51
+ getDeviceCredentialsService(): DeviceCredentialsService;
51
52
  }
@@ -1,4 +1,4 @@
1
- import { AssetStorageService, AuthService, ConfigGroupService, DashboardService, EventService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, ScheduleService, SpotProvisioningServiceNode, StreamService, UserService, } from '../services';
1
+ import { AssetStorageService, AuthService, ConfigGroupService, DashboardService, DeviceCredentialsService, EventService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, ScheduleService, SpotProvisioningServiceNode, StreamService, UserService, } from '../services';
2
2
  import { ServiceEnum } from '../models';
3
3
  import { CallerServiceNode } from '../services/CallerServiceNode';
4
4
  import { CommandServiceNode } from '../services/CommandServiceNode';
@@ -78,6 +78,9 @@ export class RocosSDKNode extends RocosSDK {
78
78
  case ServiceEnum.MAP:
79
79
  this.services[name] = new MapService(config);
80
80
  break;
81
+ case ServiceEnum.DEVICE_CREDENTIALS:
82
+ this.services[name] = new DeviceCredentialsService(config);
83
+ break;
81
84
  }
82
85
  }
83
86
  this.logger.debug(`Found service ${name}.`);
@@ -140,4 +143,7 @@ export class RocosSDKNode extends RocosSDK {
140
143
  getRTPWebRTCService() {
141
144
  throw new Error('WebRTC service is not supported in NodeJS');
142
145
  }
146
+ getDeviceCredentialsService() {
147
+ return this.getService(ServiceEnum.DEVICE_CREDENTIALS);
148
+ }
143
149
  }
@@ -1,10 +1,20 @@
1
1
  import { IBaseService, IRocosSDKConfig, RocosError, Token } from '../models';
2
+ import { Observable } from 'rxjs';
2
3
  import { BaseServiceAbstract } from './BaseServiceAbstract';
3
4
  export declare class AuthService extends BaseServiceAbstract implements IBaseService {
4
5
  protected config: IRocosSDKConfig;
5
6
  private token?;
6
7
  private tokenRefreshTimeoutId?;
8
+ private tokenSubject$;
7
9
  constructor(config: IRocosSDKConfig);
10
+ /** Observable for token updates
11
+ *
12
+ * This is useful for getting notified when the token changes.
13
+ * i.e. when the token is refreshed from the token refresh checker.
14
+ *
15
+ * This will not emit until the token is set, either by `setToken` or by getting a new token.
16
+ */
17
+ get tokenUpdates$(): Observable<Token>;
8
18
  getStatus(): boolean;
9
19
  teardown(): void;
10
20
  protected getError(e: RocosError): RocosError;
@@ -62,9 +72,10 @@ export declare class AuthService extends BaseServiceAbstract implements IBaseSer
62
72
  * If you want to refresh the token regardless of the expiry time, use `refreshToken`.
63
73
  *
64
74
  * @param minutes the number of minutes before the token expires to refresh the token
75
+ * @returns true if the token was refreshed
65
76
  * @see refreshToken
66
77
  */
67
- refreshTokenIfExpired(minutes: number): Promise<void>;
78
+ refreshTokenIfExpired(minutes: number): Promise<boolean>;
68
79
  /** Start a 5-minute loop to check if the token needs to be refreshed
69
80
  *
70
81
  * This is useful when you are using GRPC services (i.e. telemetry) which does not automatically refresh the token.
@@ -1,5 +1,6 @@
1
1
  import { API_APPLICATION_AUTH_URL, API_OTP_AUTH_URL, API_OTP_URL, API_USER_TOKEN_URL } from '../constants/api';
2
2
  import { RocosError, Token, errorCodes } from '../models';
3
+ import { Subject } from 'rxjs';
3
4
  import { BaseServiceAbstract } from './BaseServiceAbstract';
4
5
  import { RocosLogger } from '../logger/RocosLogger';
5
6
  import { RocosStore } from '../store/RocosStore';
@@ -9,11 +10,25 @@ export class AuthService extends BaseServiceAbstract {
9
10
  constructor(config) {
10
11
  super(config);
11
12
  this.config = config;
13
+ this.tokenSubject$ = new Subject();
12
14
  this.config = config;
13
15
  this.logger = RocosLogger.getInstance(`AuthService(${this.config.url})`);
14
16
  if (this.config.token) {
15
17
  this.setToken(this.config.token);
16
18
  }
19
+ this.tokenUpdates$.subscribe((token) => {
20
+ RocosStore.getChangeSubject().next({ type: 'token', url: this.config.url, data: token.value });
21
+ });
22
+ }
23
+ /** Observable for token updates
24
+ *
25
+ * This is useful for getting notified when the token changes.
26
+ * i.e. when the token is refreshed from the token refresh checker.
27
+ *
28
+ * This will not emit until the token is set, either by `setToken` or by getting a new token.
29
+ */
30
+ get tokenUpdates$() {
31
+ return this.tokenSubject$.asObservable();
17
32
  }
18
33
  getStatus() {
19
34
  return true;
@@ -39,7 +54,7 @@ export class AuthService extends BaseServiceAbstract {
39
54
  }
40
55
  this.config.token = this.token.value;
41
56
  // output a message for token change
42
- RocosStore.getChangeSubject().next({ type: 'token', url: this.config.url, data: this.token.value });
57
+ this.tokenSubject$?.next(this.token);
43
58
  }
44
59
  /**
45
60
  * Clear token
@@ -163,6 +178,7 @@ export class AuthService extends BaseServiceAbstract {
163
178
  * If you want to refresh the token regardless of the expiry time, use `refreshToken`.
164
179
  *
165
180
  * @param minutes the number of minutes before the token expires to refresh the token
181
+ * @returns true if the token was refreshed
166
182
  * @see refreshToken
167
183
  */
168
184
  async refreshTokenIfExpired(minutes) {
@@ -170,7 +186,9 @@ export class AuthService extends BaseServiceAbstract {
170
186
  this.logger.info('Token expires in 15 minutes. Refreshing.');
171
187
  const newToken = await this.refreshToken();
172
188
  this.setToken(newToken);
189
+ return true;
173
190
  }
191
+ return false;
174
192
  }
175
193
  /** Start a 5-minute loop to check if the token needs to be refreshed
176
194
  *
@@ -0,0 +1,15 @@
1
+ import { DeviceCredentialAuth, DeviceCredentialAuthResult, DeviceCredentialCreate, DeviceCredentials } from '../models/device-credentials/DeviceCredentials';
2
+ import { IBaseService, IRocosSDKConfig, RocosError } from '../models';
3
+ import { BaseServiceAbstract } from './BaseServiceAbstract';
4
+ /**
5
+ * Manage external devices authenticating with the platform
6
+ */
7
+ export declare class DeviceCredentialsService extends BaseServiceAbstract implements IBaseService {
8
+ constructor(config: IRocosSDKConfig);
9
+ getStatus(): boolean;
10
+ protected getError(e: Error): RocosError;
11
+ list(projectId: string, callsign: string): Promise<DeviceCredentials>;
12
+ create(projectId: string, callsign: string, credentials: DeviceCredentialCreate): Promise<DeviceCredentialCreate>;
13
+ delete(projectId: string, callsign: string, component: string, system: string): Promise<void>;
14
+ auth(credentials: DeviceCredentialAuth): Promise<DeviceCredentialAuthResult>;
15
+ }
@@ -0,0 +1,46 @@
1
+ import { API_DEVICE_CREDENTIALS_AUTH_URL, API_DEVICE_CREDENTIALS_URL } from '../constants/api';
2
+ import { RocosError, errorCodes } from '../models';
3
+ import { BaseServiceAbstract } from './BaseServiceAbstract';
4
+ import { RocosLogger } from '../logger/RocosLogger';
5
+ import { formatServiceUrl } from '../helpers/formatServiceUrl';
6
+ /**
7
+ * Manage external devices authenticating with the platform
8
+ */
9
+ export class DeviceCredentialsService extends BaseServiceAbstract {
10
+ constructor(config) {
11
+ super(config);
12
+ this.logger = RocosLogger.getInstance(`DeviceCredentials(${this.config.url})`);
13
+ }
14
+ getStatus() {
15
+ return true;
16
+ }
17
+ getError(e) {
18
+ return new RocosError(e, errorCodes.DEVICE_CREDENTIALS_SERVICE_ERROR);
19
+ }
20
+ list(projectId, callsign) {
21
+ return this.callGet(formatServiceUrl(API_DEVICE_CREDENTIALS_URL, {
22
+ url: this.config.url,
23
+ projectId,
24
+ callsign,
25
+ }, this.config.insecure), 'Failed to get device credentials.');
26
+ }
27
+ create(projectId, callsign, credentials) {
28
+ return this.callPost(formatServiceUrl(API_DEVICE_CREDENTIALS_URL, {
29
+ url: this.config.url,
30
+ projectId,
31
+ callsign,
32
+ }, this.config.insecure), credentials, 'Failed to create device credentials.');
33
+ }
34
+ delete(projectId, callsign, component, system) {
35
+ return this.callDelete(formatServiceUrl(API_DEVICE_CREDENTIALS_URL, {
36
+ url: this.config.url,
37
+ projectId,
38
+ callsign,
39
+ }, this.config.insecure), 'Failed to delete device credentials.', { component, system });
40
+ }
41
+ auth(credentials) {
42
+ return this.callPost(formatServiceUrl(API_DEVICE_CREDENTIALS_AUTH_URL, {
43
+ url: this.config.url,
44
+ }, this.config.insecure), credentials, 'Failed to delete device credentials.');
45
+ }
46
+ }
@@ -2,7 +2,7 @@ import { IBaseService, IRocosSDKConfig, Map, RocosError } from '../models';
2
2
  import { BaseServiceAbstract } from './BaseServiceAbstract';
3
3
  import { Observation } from '../models/maps/Panorama';
4
4
  /**
5
- * Integrations to retrieve data from the linked project in DroneDeploy
5
+ * Maps service for managing robot maps in the cloud and on robots
6
6
  */
7
7
  export declare class MapService extends BaseServiceAbstract implements IBaseService {
8
8
  constructor(config: IRocosSDKConfig);
@@ -4,7 +4,7 @@ import { BaseServiceAbstract } from './BaseServiceAbstract';
4
4
  import { RocosLogger } from '../logger/RocosLogger';
5
5
  import { formatServiceUrl } from '../helpers/formatServiceUrl';
6
6
  /**
7
- * Integrations to retrieve data from the linked project in DroneDeploy
7
+ * Maps service for managing robot maps in the cloud and on robots
8
8
  */
9
9
  export class MapService extends BaseServiceAbstract {
10
10
  constructor(config) {
@@ -249,10 +249,11 @@ export declare class ProfileService extends BaseServiceAbstract implements IBase
249
249
  * @param projectId - Project Id
250
250
  * @param profileData - Robot definition data
251
251
  * @param newName - Optional new name for the robot definition. If not provided, the name from the imported definition will be used.
252
+ * @param newDescription - Optional new description for the robot definition. If not provided, the description from the imported definition will be used.
252
253
  *
253
254
  * @see export
254
255
  */
255
- import(projectId: string, profileData: Record<string, unknown>, newName?: string): Promise<{
256
+ import(projectId: string, profileData: Blob | File, newName?: string, newDescription?: string): Promise<{
256
257
  profileId: string;
257
258
  }>;
258
259
  /**
@@ -364,14 +364,20 @@ export class ProfileService extends BaseServiceAbstract {
364
364
  * @param projectId - Project Id
365
365
  * @param profileData - Robot definition data
366
366
  * @param newName - Optional new name for the robot definition. If not provided, the name from the imported definition will be used.
367
+ * @param newDescription - Optional new description for the robot definition. If not provided, the description from the imported definition will be used.
367
368
  *
368
369
  * @see export
369
370
  */
370
- async import(projectId, profileData, newName) {
371
+ async import(projectId, profileData, newName, newDescription) {
372
+ const formData = new FormData();
371
373
  if (newName) {
372
- profileData.name = newName;
374
+ formData.append('name', newName);
373
375
  }
374
- return this.callPost(formatServiceUrl(API_PROJECT_DEFINITION_IMPORT, { url: this.config.url, projectId }, this.config.insecure), profileData, `Failed to import robot definition for ${projectId}.`);
376
+ if (newDescription) {
377
+ formData.append('description', newDescription);
378
+ }
379
+ formData.append('file', profileData);
380
+ return this.callPost(formatServiceUrl(API_PROJECT_DEFINITION_IMPORT, { url: this.config.url, projectId }, this.config.insecure), formData, `Failed to import robot definition for ${projectId}.`);
375
381
  }
376
382
  /**
377
383
  * Update gamepads for a robot definition
@@ -5,6 +5,7 @@ export * from './CommandService';
5
5
  export * from './ConfigGroupService';
6
6
  export * from './ControlService';
7
7
  export * from './DashboardService';
8
+ export * from './DeviceCredentialsService';
8
9
  export * from './EventService';
9
10
  export * from './FileAccessorService';
10
11
  export * from './IntegrationService';
@@ -5,6 +5,7 @@ export * from './CommandService';
5
5
  export * from './ConfigGroupService';
6
6
  export * from './ControlService';
7
7
  export * from './DashboardService';
8
+ export * from './DeviceCredentialsService';
8
9
  export * from './EventService';
9
10
  export * from './FileAccessorService';
10
11
  export * from './IntegrationService';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dronedeploy/rocos-js-sdk",
3
- "version": "3.0.1-alpha.15",
3
+ "version": "3.0.1-alpha.18",
4
4
  "description": "Javascript SDK for rocos",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",