ElvClient/NTP

Methods for creating and managing NTP instances and tickets

Source:

Methods

static CreateNTPInstance({
tenantId,
objectId,
groupAddressesoptional,
ntpClassoptional,
maxTicketsoptional,
maxRedemptionsoptional,
startTime,
endTime,
ticketLengthoptional
})
→ Promise.<string>

Issue an n-time-password (NTP) instance. This instance contains a specification for the tickets (AKA codes) to be issued, including the target(s) to be authorized, how many tickets can be issued, and when and how many times tickets can be redeemed.

Note: For date types (startTime/endTime), you may specify the date in any format parsable by JavaScript's new Date() constructor, including Unix epoch timestamps and ISO strings

Returns: The ID of the NTP instance. This ID can be used when issuing tickets (See IssueNTPCode)
Parameters:
Name Type Attributes Default Description
tenantId string

The ID of the tenant in which to create the NTP instance

objectId string

ID of the object for the tickets to be authorized to

groupAddresses Array.<string> <optional>

List of group addresses for the tickets to inherit permissions from

ntpClass number <optional>
4

Class of NTP instance to create

maxTickets number <optional>
0

The maximum number of tickets that may be issued for this instance (if 0, no limit)

maxRedemptions number <optional>
100

The maximum number of times each ticket may be redeemed

startTime string | number

The time when issued tickets can be redeemed

endTime string | number

The time when issued tickets can no longer be redeemed

ticketLength number <optional>
6

The number of characters in each ticket code

Examples
async CreateNTPInstance({
  "tenantId": "iten4PgJYBY7UP3YpP2DYm7C9XxxL7kU",
  "objectId": "iq__3ax1WuidvcNm8Bd2CGEnqLYScsxL",
  "groupAddresses": [
    "0x96bb65d1fdbb9fd710ffc3bb30bc4d0f82889d78",
    "0x2b80776155466f77e20fbfa1d45c7e723302b827"
  ],
  "maxTickets": 100,
  "maxRedemptions": 100,
  "ticketLength": 6,
  "startTime": "2020-11-02T23:55:51.043Z",
  "endTime": "2020-11-03T23:55:50.043Z"
});


"QOTPVcP8nDqZhv5"
async CreateNTPInstance({
  "tenantId": "iten4PgJYBY7UP3YpP2DYm7C9XxxL7kU",
  "objectId": "iq__3ax1WuidvcNm8Bd2CGEnqLYScsxL",
  "maxTickets": 100,
  "maxRedemptions": 100,
  "ticketLength": 6,
  "startTime": "2020-11-02T23:55:58.355Z",
  "endTime": "2020-11-03T23:55:57.355Z"
});


"QOTPMd5QEYWokX3"
Source:

static DeleteNTPInstance({
tenantId,
ntpId
})

Delete the specified NTP instance. This action cannot be undone.

Parameters:
Name Type Description
tenantId string

The ID of the tenant in which this NTP instance was created

ntpId string

The ID of the NTP instance

Example
async DeleteNTPInstance({
  "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
  "ntpId": "QOTP3MVczfg3b7j"
});


<No Return Value>
Source:

static IssueNTPCode({
tenantId,
ntpId,
emailoptional,
maxRedemptionsoptional
})
→ Promise.<Object>

Issue a ticket from the specified NTP ID

Returns: The generated ticket code and additional information about the ticket.
Parameters:
Name Type Attributes Description
tenantId string

The ID of the tenant in the NTP instance was created

ntpId string

The ID of the NTP instance from which to issue a ticket

email string <optional>

The email address associated with this ticket. If specified, the email address will have to be provided along with the ticket code in order to redeem the ticket.

maxRedemptions number <optional>

Maximum number of times this ticket may be redeemed. If less than the max redemptions of the NTP instance, the lower limit will be used.

Example
async IssueNTPCode({
  "tenantId": "iten4PgJYBY7UP3YpP2DYm7C9XxxL7kU",
  "ntpId": "QOTPPvF1tHDRqbs",
  "email": ""
});


{
  "token": "Ti4XMa",
  "user_id": "iusr4ZfdFaXZcEE7erZiki3EZoreaui7"
}
Source:

static IssueSignedNTPCode({
tenantId,
ntpId,
emailoptional,
maxRedemptionsoptional
})
→ Promise.<Object>

Identical to IssueNTPCode, but the token is also signed by the current user.

Returns: The generated signed ticket code and additional information about the ticket.
Parameters:
Name Type Attributes Description
tenantId string

The ID of the tenant in the NTP instance was created

ntpId string

The ID of the NTP instance from which to issue a ticket

email string <optional>

The email address associated with this ticket. If specified, the email address will have to be provided along with the ticket code in order to redeem the ticket.

maxRedemptions number <optional>

Maximum number of times this ticket may be redeemed. If less than the max redemptions of the NTP instance, the lower limit will be used.

Source:

static ListNTPInstances({
tenantId,
countoptional,
offsetoptional
})
→ Object

Retrieve info for NTP instances in the specified tenant

Returns: List of NTP instances along with pagination information
Parameters:
Name Type Attributes Default Description
tenantId string

The ID of the tenant

count number <optional>
10

Maximum number of results to return

offset number <optional>
0

Offset from which to return results

Examples
async ListNTPInstances({
  "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
  "count": 5,
  "offset": 0
});


{
  "ntpInstances": [
    {
      "ntpId": "QOTPXTsw4yWRuei",
      "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
      "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
      "objectId": "iq__2hbsAkfw5TKZZZsf5LH9F2Jp6NfN",
      "ntpClass": "Class 4",
      "updatedAt": 1605735797887,
      "startTime": "1598036400000",
      "endTime": "1598252340000",
      "ticketLength": "6",
      "maxRedemptions": "10",
      "maxTickets": 1000,
      "issuedTickets": 0
    },
    {
      "ntpId": "QOTP5h8SyncNkzN",
      "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
      "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
      "objectId": "iq__iTghh4NbMVUVK7wMHSNtXrH2vq8",
      "ntpClass": "Class 4",
      "updatedAt": 1605738066424,
      "startTime": "1604361351043",
      "endTime": "1604447750043",
      "ticketLength": "6",
      "maxRedemptions": "100",
      "maxTickets": 100,
      "issuedTickets": 4
    },
    {
      "ntpId": "QOTP89wcEtS4ZAR",
      "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
      "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
      "objectId": "iq__iTghh4NbMVUVK7wMHSNtXrH2vq8",
      "ntpClass": "Class 4",
      "updatedAt": 1605739052238,
      "startTime": "1604361351043",
      "endTime": "1604447750043",
      "ticketLength": "7",
      "maxRedemptions": "456",
      "maxTickets": 123,
      "issuedTickets": 0
    },
    {
      "ntpId": "QOTP58sHNSbimsA",
      "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
      "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
      "objectId": "iq__iTghh4NbMVUVK7wMHSNtXrH2vq8",
      "ntpClass": "Class 4",
      "updatedAt": 1605739070892,
      "startTime": "1604361351043",
      "endTime": "1604447750043",
      "ticketLength": "8",
      "maxRedemptions": "567",
      "maxTickets": 234,
      "issuedTickets": 0
    },
    {
      "ntpId": "QOTPcDDWKMctWsz",
      "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
      "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
      "objectId": "iq__iTghh4NbMVUVK7wMHSNtXrH2vq8",
      "ntpClass": "Class 4",
      "updatedAt": 1605739086758,
      "startTime": "1604361351043",
      "endTime": "1604447750043",
      "ticketLength": "8",
      "maxRedemptions": "765",
      "maxTickets": 432,
      "issuedTickets": 0
    }
  ],
  "start": 0,
  "end": 5,
  "total": 11
}
async ListNTPInstances({
  "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
  "count": 5,
  "offset": 5
});


{
  "ntpInstances": [
    {
      "ntpId": "QOTPPinMnviApkS",
      "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
      "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
      "objectId": "iq__iTghh4NbMVUVK7wMHSNtXrH2vq8",
      "ntpClass": "Class 4",
      "updatedAt": 1605739099231,
      "startTime": "1604361351043",
      "endTime": "1604447750043",
      "ticketLength": "5",
      "maxRedemptions": "100",
      "maxTickets": 100,
      "issuedTickets": 0
    },
    {
      "ntpId": "QOTPb46EU3G9vxz",
      "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
      "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
      "objectId": "iq__iTghh4NbMVUVK7wMHSNtXrH2vq8",
      "ntpClass": "Class 4",
      "updatedAt": 1605739113234,
      "ticketLength": "5",
      "maxRedemptions": "333",
      "maxTickets": 222,
      "issuedTickets": 0
    },
    {
      "ntpId": "QOTPSrMzwMzTRu5",
      "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
      "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
      "objectId": "iq__iTghh4NbMVUVK7wMHSNtXrH2vq8",
      "ntpClass": "Class 4",
      "updatedAt": 1605740311043,
      "startTime": "1604361351043",
      "endTime": "1604447750043",
      "ticketLength": "6",
      "maxRedemptions": "333",
      "maxTickets": 222,
      "issuedTickets": 0
    },
    {
      "ntpId": "QOTPWmev6BGW6Fp",
      "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
      "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
      "objectId": "iq__38Mk1y6DoXB4FFLkS3dbMuwM2Sh7",
      "ntpClass": "Class 4",
      "updatedAt": 1605745945099,
      "ticketLength": "6",
      "maxRedemptions": "100",
      "maxTickets": 0,
      "issuedTickets": 0
    },
    {
      "ntpId": "QOTP225GKFJVm4q",
      "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
      "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
      "objectId": "iq__38Mk1y6DoXB4FFLkS3dbMuwM2Sh7",
      "ntpClass": "Class 4",
      "updatedAt": 1605810568022,
      "ticketLength": "6",
      "maxRedemptions": "100",
      "maxTickets": 0,
      "issuedTickets": 0
    }
  ],
  "start": 5,
  "end": 10,
  "total": 11
}
Source:

static NTPInstance({
tenantId,
ntpId
})
→ Object

Retrieve a info about the specified NTP instance

Returns: Info about the NTP instance
Parameters:
Name Type Description
tenantId string

The ID of the tenant

ntpId string

The ID of the NTP instance

Example
async NTPInstance({
  "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
  "ntpId": "QOTP3MVczfg3b7j"
});


{
  "ntpId": "QOTP3MVczfg3b7j",
  "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
  "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
  "objectId": "iq__iTghh4NbMVUVK7wMHSNtXrH2vq8",
  "ntpClass": "Class 4",
  "updatedAt": 1605812427397,
  "startTime": "1541202951043",
  "endTime": "1667519750043",
  "ticketLength": "6",
  "maxRedemptions": "456",
  "maxTickets": 123,
  "issuedTickets": 0
}
Source:

static RedeemCode({
issueroptional,
tenantIdoptional,
ntpIdoptional,
code,
emailoptional,
includeNTPIdoptional
})
→ Promise.<(string|Object)>

Redeem the specified ticket/code to authorize the client. Must provide either issuer or tenantId and ntpId

Returns: The object ID which the ticket is authorized to, or an object containing the object ID and NTP ID if includeNTPId is specified
Parameters:
Name Type Attributes Description
issuer string <optional>

Issuer to authorize against

tenantId string <optional>

The ID of the tenant from which the ticket was issued

ntpId string <optional>

The ID of the NTP instance from which the ticket was issued

code string

Access code

email string <optional>

Email address associated with the code

includeNTPId boolean <optional>

If specified, the response will include both the target object ID as well as the NTP ID associated with the ticket

Examples
async RedeemCode({
  "tenantId": "iten4PgJYBY7UP3YpP2DYm7C9XxxL7kU",
  "ntpId": "QOTPVcP8nDqZhv5",
  "code": "4Rj7Vu",
  "email": ""
});


"iq__3ax1WuidvcNm8Bd2CGEnqLYScsxL"
async RedeemCode({
  "tenantId": "iten4PgJYBY7UP3YpP2DYm7C9XxxL7kU",
  "ntpId": "QOTPMd5QEYWokX3",
  "code": "Cxr5Za",
  "email": ""
});


"iq__3ax1WuidvcNm8Bd2CGEnqLYScsxL"
async RedeemCode({
  "tenantId": "iten4PgJYBY7UP3YpP2DYm7C9XxxL7kU",
  "ntpId": "QOTPMd5QEYWokX3",
  "code": "Ne94Tv",
  "email": "person@example.com"
});


"iq__3ax1WuidvcNm8Bd2CGEnqLYScsxL"
Source:

static SuspendNTPInstance({
tenantId,
ntpId
})

Suspend the specified NTP instance. All tickets issued for this instance will be considered expired.

To reactivate the NTP instance, reset the expiration date using UpdateNTPInstance

Parameters:
Name Type Description
tenantId string

The ID of the tenant in which this NTP instance was created

ntpId string

The ID of the NTP instance

Example
async SuspendNTPInstance({
  "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
  "ntpId": "QOTP3MVczfg3b7j"
});


<No Return Value>
Source:

static UpdateNTPInstance({
tenantId,
ntpId,
maxTicketsoptional,
maxRedemptionsoptional,
startTime,
endTime
})
→ Object

Update the attributes of the specified NTP instance. Only the specified attributes will be updated ; others will be unchanged.

Returns: Info about the NTP Instance
Parameters:
Name Type Attributes Default Description
tenantId string

The ID of the tenant in which this NTP instance was created

ntpId string

The ID of the NTP instance to update

maxTickets number <optional>
0

The maximum number of tickets that may be issued for this instance (if 0, no limit)

maxRedemptions number <optional>
100

The maximum number of times each ticket may be redeemed

startTime string | number

The time when issued tickets can be redeemed

endTime string | number

The time when issued tickets can no longer be redeemed

Example
async UpdateNTPInstance({
  "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
  "ntpId": "QOTP3MVczfg3b7j",
  "maxTickets": 123,
  "maxRedemptions": 456,
  "startTime": "2018-11-02T23:55:51.043Z",
  "endTime": "2022-11-03T23:55:50.043Z"
});


{
  "ntpId": "QOTP3MVczfg3b7j",
  "tenantId": "iten3PumhoQT6LG4VTDZozu83a6qw9JS",
  "kmsId": "ikms4ZPRRaZiwQN6rxEz7D75tqzvGQ3g",
  "objectId": "iq__iTghh4NbMVUVK7wMHSNtXrH2vq8",
  "ntpClass": "Class 4",
  "updatedAt": 1605812427397,
  "startTime": "1541202951043",
  "endTime": "1667519750043",
  "ticketLength": "6",
  "maxRedemptions": "456",
  "maxTickets": 123
}
Source: