@ikonintegration/mod-license-client 0.4.8 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ const API = new SMLicense({
20
20
  apiKey: config.examProvider.key, //API token on IDM.AppID format (generate from APIKey at https://runkit.com/gwdp/idm-appid-v1)
21
21
  //Must be specified when using admin or user routes
22
22
  authorizationToken: '', -- optional, IDM JWT for shared module admins and user routes -- Accepts a function to be called async and return the token
23
- namespace: ''
23
+ tenantID: ''
24
24
  });
25
25
 
26
26
  //Revoke License
@@ -55,6 +55,7 @@ The following header must be specified in every request!
55
55
  - API.order.getOrder(externalID, orderID) - Admin, users and services
56
56
  - API.order.getOrdersByExternalID(externalID) - Admin, users and services
57
57
  - API.order.getOrdersFromToTimestamp(from, to /*timestamps*/) - Admin and services
58
+ - API.order.getOrderReceipt(externalID, orderID) - Admin, users and services
58
59
  - API.order.getPendingOrders() - Admin and services
59
60
  - API.order.submitInvoiceOrder(orderObj) - Admin and services
60
61
  - API.order.approveInvoiceOrder(orderObj) - Admin and services
@@ -82,13 +83,9 @@ The following header must be specified in every request!
82
83
  - API.voucher.verifyVoucher(voucherID) - Admin, users and services
83
84
  - API.voucher.getVouchers() - Admin only
84
85
 
85
- **Client:**
86
- - API.client.createClient(clientName) - Admin only
87
- - API.client.updateClient(clientName, clientID) - Admin only
88
- - API.client.deleteClient(clientID) - Admin only
89
- - API.client.getClient(clientID) - Admin only
90
- - API.client.getAllClient() - Admin only
91
-
92
86
  **Key:**
93
87
  - API.key.getAvailableKeys(externalID, numberOfLicenses) - Admin, users and services
94
- - API.key.getKey(activationKey) - Service only
88
+ - API.key.getKey(activationKey) - Service only
89
+
90
+ **Vault**
91
+ - API.vault.getVaultNonce(externalID, userInfo) - Sysadmins, Admins and users (no services here)
package/lib/Client.js CHANGED
@@ -5,10 +5,10 @@ import APIRequest from './core/Request';
5
5
  import OperationProduct from './operations/Product';
6
6
  import OperationLicense from './operations/License';
7
7
  import OperationLicenseConsumption from './operations/LicenseConsumption';
8
- import OperationClient from './operations/Client';
9
8
  import OperationOrder from './operations/Order';
10
9
  import OperationVoucher from './operations/Voucher';
11
10
  import OperationKey from './operations/Key';
11
+ import OperationVault from './operations/Vault';
12
12
  //
13
13
  export default class Client {
14
14
  /* config structure
@@ -16,20 +16,20 @@ export default class Client {
16
16
  endpoint: 'https://localhost',
17
17
  port: 9998,
18
18
  apiKey: '',
19
- namespace: '',
19
+ tenantID: '',
20
20
  authorizationToken: '' -- optional
21
21
  }
22
22
  */
23
23
  constructor(config) {
24
24
  this.config = config;
25
25
  // api operations
26
- this.client = new OperationClient(this);
27
26
  this.license = new OperationLicense(this);
28
27
  this.licenseConsumption = new OperationLicenseConsumption(this);
29
28
  this.product = new OperationProduct(this);
30
29
  this.order = new OperationOrder(this);
31
30
  this.voucher = new OperationVoucher(this);
32
31
  this.key = new OperationKey(this);
32
+ this.vault = new OperationVault(this);
33
33
  }
34
34
 
35
35
  async newBaseRequest(method) {
@@ -46,9 +46,7 @@ export default class Client {
46
46
  }
47
47
  req.appendHeader('Authorization', token);
48
48
  }
49
- if (this.config.namespace) {
50
- req.appendHeader('Namespace', this.config.namespace);
51
- }
49
+ if (this.config.tenantID) req.appendHeader('tenantID', this.config.tenantID);
52
50
  //
53
51
  req.baseURL = this.config.endpoint;
54
52
  if (this.config.port) req.baseURL += `:${this.config.port}`;
@@ -8,6 +8,9 @@ export default class Order {
8
8
  isMonerisEnabledForProduct(product) {
9
9
  return (this.getProviderFromProduct(product).indexOf('moneris') != -1);
10
10
  }
11
+ isBraintreeEnabledForProduct(product) {
12
+ return (this.getProviderFromProduct(product).indexOf('braintree') != -1);
13
+ }
11
14
  //CC/Skip order
12
15
  async preOrder(orderObj) {
13
16
  const req = await this.api.newBaseRequest('POST');
@@ -86,4 +89,10 @@ export default class Order {
86
89
  req.path = '/orders/invoices';
87
90
  return await req.exec();
88
91
  }
92
+ async getOrderReceipt(externalID, orderID) {
93
+ const req = await this.api.newBaseRequest('GET');
94
+ req.path = `/order/${externalID}/${orderID}/receipt`;
95
+ req.bodyType = 'BINARY';
96
+ return await req.exec();
97
+ }
89
98
  }
@@ -19,7 +19,7 @@ export default class Product {
19
19
  alternateTaxID: 'any?',
20
20
  //Compatibility
21
21
  id: 'any?',
22
- clientID: 'any?',
22
+ tenantID: 'any?',
23
23
  createdBy: 'any?',
24
24
  updatedBy: 'any?',
25
25
  updatedOn: 'any?',
@@ -0,0 +1,11 @@
1
+ export default class Vault {
2
+ constructor(API) {
3
+ this.api = API;
4
+ }
5
+ async getVaultNonce(externalID, userInfo) {
6
+ const req = await this.api.newBaseRequest('POST');
7
+ req.path = '/vault/nonce/' + (externalID || '');
8
+ req.body = { ...userInfo };
9
+ return await req.exec();
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@ikonintegration/mod-license-client",
3
- "version": "0.4.8",
3
+ "version": "2.0.2",
4
4
  "description": "Shared module license API client",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "pre-publish": "npm i -production && curl -sf https://gobinaries.com/tj/node-prune | sh && node-prune"
8
9
  },
9
10
  "author": "Ikon Integration",
10
11
  "dependencies": {
@@ -1,32 +0,0 @@
1
- export default class Client {
2
- constructor(API) {
3
- this.api = API;
4
- }
5
- async createClient(clientName) {
6
- const req = await this.api.newBaseRequest('POST');
7
- req.path = '/client/new';
8
- req.body = { name: clientName };
9
- return await req.exec();
10
- }
11
- async updateClient(clientName, clientID) {
12
- const req = await this.api.newBaseRequest('PUT');
13
- req.path = '/client/' + clientID;
14
- req.body = { name: clientName };
15
- return await req.exec();
16
- }
17
- async deleteClient(clientID) {
18
- const req = await this.api.newBaseRequest('DELETE');
19
- req.path = '/client/' + clientID;
20
- return await req.exec();
21
- }
22
- async getClient(clientID) {
23
- const req = await this.api.newBaseRequest('GET');
24
- req.path = '/client/' + clientID;
25
- return await req.exec();
26
- }
27
- async getAllClient() {
28
- const req = await this.api.newBaseRequest('GET');
29
- req.path = '/clients';
30
- return await req.exec();
31
- }
32
- }