1. Docs
  2. Data Control Platform
  3. SDKs
  4. NodeJS
  5. User Operations

User Operations

Since the IronNode SDK requires that it runs in the context of an authenticated user in your application, methods are provided to manage user information as well as generate a set of device public and private keys which can be used to interact with the SDK.

IronNode.User.verify()

IronNode.User.verify(jwt)

Given a valid, signed JSON Web Token (JWT), check if the user specified within the JWT payload has been synced within IronCore.

Parameters

Parameter NameValueDescription
jwtstringA valid, signed JSON Web Token for the user to verify.

Response

Returns a Promise that resolves with either undefined if the user has not been synced within IronCore or details about the user if they have been synced.

JSON
//If user exists, the Promise will resolve with the following object { //Users synced account ID "accountID": string, //IronCore internal segment ID the user is a part of "segmentID": number, //Users master public key "userMasterPublicKey": { "x": string, "y": string } }

IronNode.User.create()

IronNode.User.create(jwt, password, [options])

Given a valid, signed JSON Web Tokens (JWT) sync the provided user from your application into IronCore. This operation will generate a new “master” key pair for the user and securely encrypt and store their private key using the provided password.

Parameters

Parameter NameValueDescription
jwtstringA valid, signed JSON Web Token for the user to create/sync.
passwordstringA password used to securely encrypt the user’s newly created private key.
[options.needsRotation]booleanSet to true if the private key for this user should be rotated when the user “takes control” of their keys. The main use case for this is a workflow that requires that the user’s account be generated prior to the user logging in for the first time. Optional, defaults to false.

Response

Returns a Promise that resolves with details about the newly synced user.

JSON
{ //Users synced account ID "accountID": string, //IronCore internal segment ID the user is a part of "segmentID": number, //Users master public key "userMasterPublicKey": { "x": string, "y": string } }

IronNode.User.generateDeviceKeys()

IronNode.User.generateDeviceKeys(jwt, password, [options])

Given a valid, signed JSON Web Tokens (JWT) and the user’s private key encryption password, generate a new device key pair that can then be used to initialize the IronNode SDK.

Parameters

Parameter NameValueDescription
jwtstringA valid, signed JSON Web Token for the user to create/sync.
passwordstringThe user’s private key decryption password that was set at user creation time.
[options.deviceName]stringA readable name for the device, returned as name from this method and from SDK.user.listDevices(). The name can only be set when the device is created. Optional; if omitted the device’s name is null.

Response

Returns a Promise that resolves with new device key details. The accountId, segmentId, devicePrivateKey, and signingPrivateKey fields are the device format shared by all IronCore SDKs; the whole object can be stored and later passed to initialize. The deviceId can be passed to SDK.user.deleteDevice() to revoke the device.

JSON
{ //Users synced account ID "accountId": string, //IronCore internal segment ID the user is a part of "segmentId": number, //Base64 encoded device private key "devicePrivateKey": string, //Base64 encoded Ed25519 signing key: the 32 byte seed followed by the 32 byte public key "signingPrivateKey": string, //ID of the new device "deviceId": number, //Readable name of the device, if one was provided "name": string | null, //RFC3339 timestamp of when the device was created "created": string, //RFC3339 timestamp of when the device was last updated "lastUpdated": string, //Deprecated: use accountId "accountID": string, //Deprecated: use segmentId "segmentID": number, //Deprecated: use devicePrivateKey "deviceKeys": { "publicKey": { "x": string, "y": string }, "privateKey": string }, //Deprecated: use signingPrivateKey "signingKeys": { "publicKey": string, "privateKey": string } }

IronNode.User.deleteDeviceByPublicSigningKey()

IronNode.User.deleteDeviceByPublicSigningKey(jwt, publicSigningKey)

Given a valid, signed JSON Web Token (JWT), delete one of the user’s devices given its public signing key. The SDK does not need to be initialized. Requests using the deleted device keys will no longer work.

Parameters

Parameter NameValueDescription
jwtstringA valid, signed JSON Web Token for the user who owns the device.
publicSigningKeystringBase64 encoded public signing key of the device to delete.

Response

Returns a Promise which resolves with an object that shows the ID of the device that was successfully deleted.

JSON
{ "id": number }

Was this page helpful?

One sec... bot checking