@remote.it/core
Version:
Core remote.it JavasScript/TypeScript library
151 lines (140 loc) • 3.74 kB
text/typescript
import { API } from './API'
import pjson from 'pjson'
import { cpu } from 'systeminformation'
import { Environment } from './Environment'
export class RegistrationResource {
static async create({
name,
productID,
type,
}: {
name: string
productID: string
type: 'open' | 'closed'
}) {
return API.post<RegistrationCreateResponse>('/bulk/registration/create/', {
name,
product: productID,
type,
})
}
static async info({
cpuID,
hardwareID,
macAddress,
osLabel,
registrationKey,
serviceList = [],
secret,
version,
}: {
cpuID: string
hardwareID: string
macAddress: string
osLabel?: string
registrationKey: string
secret?: string
serviceList?: number[]
version?: string
}) {
return API.post('/bulk/registration/device/information/', {
BulkIdentificationCode: registrationKey,
HardwareId: hardwareID,
MACAddress: macAddress,
CPUId: cpuID,
OSLabel: osLabel || 'unknown',
R3Package: version || pjson.version || 'unknown',
TCPServiceList: serviceList,
DeviceSecret: secret,
})
}
static async config({
registrationKey,
hardwareID,
}: {
registrationKey: string
hardwareID: string
}) {
return API.get(
`/bulk/registration/device/friendly/configuration/${registrationKey}/${hardwareID}/`
)
}
}
interface RegistrationCreateResponse {
status: 'true' | 'false'
bulk_id: string
}
// import axios from "axios";
// // Create product
// axios.post("https://api.remot3.it/apv/v27/developer/product/", {
// name: "device-a",
// platform: "430",
// scope: "private"
// });
// const resp = {
// status: "true",
// productid: "75450043-9B59-D116-15F7-7DA9CC01F5AC",
// product: {
// id: "75450043-9B59-D116-15F7-7DA9CC01F5AC",
// name: "device-a",
// platform: "430",
// scope: "Private",
// status: "New",
// updated: "2019-09-25T15:27:12-07:00",
// created: "2019-09-25T15:27:12-07:00"
// }
// };
// // Get product
// axios.get(
// "https://api.remot3.it/apv/v27/developer/product/projects/75450043-9B59-D116-15F7-7DA9CC01F5AC"
// );
// const resp2 = {
// status: "true",
// productid: "75450043-9B59-D116-15F7-7DA9CC01F5AC",
// projects: [
// {
// projectname: "Required Bulk",
// projectid: "D937FCEF-0F09-8B71-94DA-5AF7FDB3A46A",
// projecttype: "device",
// projectsecret: "M0NENTM0NUItOTMzOS02NjY2LTdGMEEtN0FFQjRCQTcwQUNC",
// projectkey: "NUFGMUJEOUItNUY3Qi04RjZGLTM2QkUtREY2QzAxOTJDNTVD",
// platformcode: "0",
// platformversion: "1.0",
// platformtype: "430",
// manufacturerid: "0",
// contenttype: "35",
// contentport: "0",
// readabletype: "Required Bulk",
// enabled: "1"
// }
// ]
// };
// // Add service to product
// axios.post("https://api.remot3.it/apv/v27/developer/product/add/project/", {
// enabled: "1",
// localport: "22",
// name: "SSH",
// product_id: "75450043-9B59-D116-15F7-7DA9CC01F5AC",
// type: "28",
// version: "1.0"
// });
// const resp3 = {
// status: "true",
// project_id: "7AA00C17-8544-EFD9-8C5E-BB7D3284F420"
// };
// // Lock product
// axios.post("https://api.remot3.it/apv/v27/developer/product/settings/", {
// lock: "on",
// product_id: "75450043-9B59-D116-15F7-7DA9CC01F5AC"
// });
// const resp4 = { status: "true" };
// // Create registration
// axios.post("https://api.remot3.it/apv/v27/bulk/registration/create/", {
// name: "device-a",
// product: "75450043-9B59-D116-15F7-7DA9CC01F5AC",
// type: "open"
// });
// const resp5 = {
// status: "true",
// bulk_id: "6D210760-4D3A-ADD3-722F-D8156B1B5351"
// };