Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 1.26 KB

ux4iot-typescript-client.md

File metadata and controls

58 lines (43 loc) · 1.26 KB

ux4iot-admin-node

The Node Admin SDK can be found on GitHub.

First, add the dependency:

{% tabs %} {% tab title="NPM" %}

npm install ux4iot-admin-node

{% endtab %}

{% tab title="Yarn" %}

yarn add ux4iot-admin-node

{% endtab %} {% endtabs %}

Initialize the SDK using the connection string. You can retrieve the connection string from the Azure portal.

const Ux4iotAdminSDK = require('ux4iot-admin');
const sdk = new Ux4iotAdminSDK({
    connectionString: "HostName=...;Key=secret";
});

Now you can whitelist grant requests using:

sdk.grant(grantRequest);

Usually, the grantRequest will be exactly identical to the body received by the custom security backend. In the security backend, you merely decide which grant requests to forward and which not to forward.

If you want to revoke the grant at a later point in time, you can do this using:

sdk.revokeGrant({
  sessionId: "ijfoewio22490320",
  deviceId: "d123",
  grantType: "subscribeToTelemetry"
});

You can revoke all grants for a session with this:

sdk.revokeSession("ijfoewio22490320");

You can even revoke all sessions:

sdk.revokeAllSessions();