Class DeviceRegistrationService

This class allows registration of a new device.

Hierarchy (view full)

Constructors

Methods

  • Accepts the device registration for given id.

    Parameters

    • entityOrId: string | number | IIdentified

      entity or id of registration. Using an entity object one can pass a securityToken as string next to the id.

    • OptionalsecurityToken: string

      optional security token to reduce the risk of devices which are not yet registered being taken over by threat actors.

      Examples


      const id = 'abc';

      (async () => {
      const {data, res} = await deviceRegistrationService.accept(id);
      })();

      const entity = { id: 'abc', securityToken: '<secretToken>' };

      (async () => {
      const {data, res} = await deviceRegistrationService.accept(entity);
      })();

      const id = 'abc';
      const securityToken = '<secretToken>';

      (async () => {
      const {data, res} = await deviceRegistrationService.accept(id, securityToken);
      })();

      Providing a securityToken within an entity object together with another securityToken as a parameter of the method will always use the securityToken of the entity object. In the example below is used as the value. is obsolete and ignored.


      const entity = { id: 'abc', securityToken: '<secretTokenA>'};
      const securityToken = '<secretTokenB>';

      (async () => {
      const {data, res} = await deviceRegistrationService.accept(entity, securityToken);
      })();

    Returns Promise<IResult<IDeviceRegistration>>

    Response wrapped in [[IResult]]

  • Bootstraps the device with given id.

    Parameters

    • entityOrId: string | number | IIdentified

      entity or id of registration. Using an entity object one can pass a securityToken as string next to the id.

    • options: IDeviceBootstrapOptions

      for details see [[IDeviceBootstrapOptions]]

    • OptionalsecurityToken: string

      optional security token to reduce the risk of devices which are not yet registered being taken over by threat actors.

      Examples


      const id: 'abc';
      const options: IDeviceBootstrapOptions = {
      basicAuthToken: 'Basic dGVuYW50L3VzZXJuYW1lOnBhc3N3b3Jk',
      basicAuth: {
      user: 'username',
      pass: 'password'
      }
      };

      (async () => {
      const {data, res} = await deviceRegistrationService.bootstrap(id, options);
      })();

      const entity: { id: '123', securityToken: '<secretToken>'};
      const options: IDeviceBootstrapOptions = {
      basicAuthToken: 'Basic dGVuYW50L3VzZXJuYW1lOnBhc3N3b3Jk',
      basicAuth: {
      user: 'username',
      pass: 'password'
      }
      };

      (async () => {
      const {data, res} = await deviceRegistrationService.bootstrap(entity, options);
      })();

      const id: '123';
      const options: IDeviceBootstrapOptions = {
      basicAuthToken: 'Basic dGVuYW50L3VzZXJuYW1lOnBhc3N3b3Jk',
      basicAuth: {
      user: 'username',
      pass: 'password'
      }
      };
      const securityToken: '<secretToken>'

      (async () => {
      const {data, res} = await deviceRegistrationService.bootstrap(id, options, securityToken);
      })();

      Providing a securityToken within an entity object together with another securityToken as a parameter of the method will always use the securityToken of the entity object. In the example below is used as the value. is obsolete and ignored.


      const options: IDeviceBootstrapOptions = {
      basicAuthToken: 'Basic dGVuYW50L3VzZXJuYW1lOnBhc3N3b3Jk',
      basicAuth: {
      user: 'username',
      pass: 'password'
      }
      };
      const entity: { id: '123', securityToken: '<secretTokenA>'};
      const securityToken: '<secretTokenB>'

      (async () => {
      const {data, res} = await deviceRegistrationService.accept(entity, securityToken);
      })();

    Returns Promise<IResult<IDeviceCredentials>>