@ibm-cloud/cloudant 0.0.13 → 0.0.14

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
@@ -14,7 +14,7 @@
14
14
  [![Release](https://img.shields.io/github/v/release/IBM/cloudant-node-sdk?include_prereleases&sort=semver)](https://github.com/IBM/cloudant-node-sdk/releases/latest)
15
15
  [![Docs](https://img.shields.io/static/v1?label=nodedoc&message=latest&color=blue)](https://ibm.github.io/cloudant-node-sdk/)
16
16
 
17
- # IBM Cloudant Node.js SDK Version 0.0.13
17
+ # IBM Cloudant Node.js SDK Version 0.0.14
18
18
 
19
19
  IBM Cloudant Node.js SDK is a client library that interacts with the
20
20
  [IBM Cloudant APIs](https://cloud.ibm.com/apidocs/cloudant?code=node).
@@ -102,8 +102,7 @@ project:
102
102
  service instance or a
103
103
  [CouchDB](https://docs.couchdb.org/en/latest/install/index.html)
104
104
  server.
105
- - **Node.js 10, 12, 14**: This SDK is tested with Node.js versions 10, 12, and 14.
106
- It may work on other versions but those are not officially supported.
105
+ - Node.js 10, 12 or 14.
107
106
 
108
107
  ## Installation
109
108
 
@@ -205,7 +204,7 @@ will guide you.
205
204
 
206
205
  To learn more about how to use programmatic authentication, see the related
207
206
  documentation in the
208
- [Cloudant API docs](https://cloud.ibm.com/apidocs/cloudant?code=python#programmatic-authentication)
207
+ [Cloudant API docs](https://cloud.ibm.com/apidocs/cloudant?code=node#programmatic-authentication)
209
208
  or in the
210
209
  [Node.js SDK Core document](https://github.com/IBM/node-sdk-core/blob/master/Authentication.md) about authentication.
211
210
 
@@ -254,43 +253,43 @@ import {CloudantV1} from "@ibm-cloud/cloudant";
254
253
  [embedmd]:# (test/examples/src/ts/GetInfoFromExistingDatabase.ts /\/\/ 1./ $)
255
254
  ```ts
256
255
  // 1. Create a Cloudant client with "EXAMPLES" service name ===================
257
- const client =
258
- CloudantV1.newInstance({serviceName:"EXAMPLES"});
256
+ const client = CloudantV1.newInstance({ serviceName: 'EXAMPLES' });
259
257
 
260
258
  // 2. Get server information ==================================================
261
259
  // call service without parameters:
262
- client.getServerInformation()
263
- .then(serverInformation => {
264
- const version = serverInformation.result.version;
265
- console.log(`Server version ${version}`);
266
- });
260
+ client.getServerInformation().then((serverInformation) => {
261
+ const version = serverInformation.result.version;
262
+ console.log(`Server version ${version}`);
263
+ });
267
264
 
268
265
  // 3. Get database information for "animaldb" =================================
269
- const dbName = "animaldb";
266
+ const dbName = 'animaldb';
270
267
 
271
268
  // call service with embedded parameters:
272
- client.getDatabaseInformation({db: dbName})
273
- .then(dbInfo => {
274
- const documentCount = dbInfo.result.doc_count;
275
- const dbNameResult = dbInfo.result.db_name;
276
-
277
- // 4. Show document count in database =================================
278
- console.log(`Document count in "${dbNameResult}" database is ` +
279
- documentCount + ".");
280
- });
269
+ client.getDatabaseInformation({ db: dbName }).then((dbInfo) => {
270
+ const documentCount = dbInfo.result.doc_count;
271
+ const dbNameResult = dbInfo.result.db_name;
272
+
273
+ // 4. Show document count in database =================================
274
+ console.log(
275
+ `Document count in "${dbNameResult}" database is ` + documentCount + '.'
276
+ );
277
+ });
281
278
 
282
279
  // 5. Get zebra document out of the database by document id ===================
283
- const getDocParams:
284
- CloudantV1.GetDocumentParams = {db: dbName, docId: "zebra"};
280
+ const getDocParams: CloudantV1.GetDocumentParams = {
281
+ db: dbName,
282
+ docId: 'zebra',
283
+ };
285
284
 
286
285
  // call service with predefined parameters:
287
- client.getDocument(getDocParams)
288
- .then(documentAboutZebra => {
289
- // result object is defined as a Document here:
290
- const result: CloudantV1.Document = documentAboutZebra.result;
291
- console.log("Document retrieved from database:\n" +
292
- JSON.stringify(result, null, 2));
293
- });
286
+ client.getDocument(getDocParams).then((documentAboutZebra) => {
287
+ // result object is defined as a Document here:
288
+ const result: CloudantV1.Document = documentAboutZebra.result;
289
+ console.log(
290
+ 'Document retrieved from database:\n' + JSON.stringify(result, null, 2)
291
+ );
292
+ });
294
293
  ```
295
294
  </details>
296
295
 
@@ -320,7 +319,9 @@ const getInfoFromExistingDatabase = async () => {
320
319
  const dbNameResult = dbInfo.result.db_name;
321
320
 
322
321
  // 4. Show document count in database =================================
323
- console.log(`Document count in "${dbNameResult}" database is ` + documentCount + '.');
322
+ console.log(
323
+ `Document count in "${dbNameResult}" database is ` + documentCount + '.'
324
+ );
324
325
 
325
326
  // 5. Get zebra document out of the database by document id ===================
326
327
  const getDocParams = { db: dbName, docId: 'zebra' };
@@ -331,7 +332,9 @@ const getInfoFromExistingDatabase = async () => {
331
332
  // result object is defined as a Document here:
332
333
  const result = documentAboutZebra.result;
333
334
 
334
- console.log('Document retrieved from database:\n' + JSON.stringify(result, null, 2));
335
+ console.log(
336
+ 'Document retrieved from database:\n' + JSON.stringify(result, null, 2)
337
+ );
335
338
  };
336
339
 
337
340
  if (require.main === module) {
@@ -380,53 +383,59 @@ import {CloudantV1} from "@ibm-cloud/cloudant";
380
383
  [embedmd]:# (test/examples/src/ts/CreateDbAndDoc.ts /interface/ $)
381
384
  ```ts
382
385
  interface OrderDocument extends CloudantV1.Document {
383
- name?: string;
384
- joined?: string;
385
- _id: string;
386
- _rev?: string;
386
+ name?: string;
387
+ joined?: string;
388
+ _id: string;
389
+ _rev?: string;
387
390
  }
388
391
 
389
392
  // 1. Create a client with `CLOUDANT` default service name ================
390
393
  const client = CloudantV1.newInstance({});
391
394
 
392
395
  // 2. Create a database =======================================================
393
- const exampleDbName = "orders";
396
+ const exampleDbName = 'orders';
394
397
 
395
398
  // Try to create database if it doesn't exist
396
- const createDb = client.putDatabase({db: exampleDbName})
397
- .then(putDatabaseResult => {
398
- if (putDatabaseResult.result.ok) {
399
- console.log(`"${exampleDbName}" database created."`);
400
- }
401
- })
402
- .catch(err => {
403
- if (err.code === 412){
404
- console.log("Cannot create \"" + exampleDbName +
405
- "\" database, it already exists.");
406
- }
407
- });
399
+ const createDb = client
400
+ .putDatabase({ db: exampleDbName })
401
+ .then((putDatabaseResult) => {
402
+ if (putDatabaseResult.result.ok) {
403
+ console.log(`"${exampleDbName}" database created."`);
404
+ }
405
+ })
406
+ .catch((err) => {
407
+ if (err.code === 412) {
408
+ console.log(
409
+ 'Cannot create "' + exampleDbName + '" database, it already exists.'
410
+ );
411
+ }
412
+ });
408
413
 
409
414
  // 3. Create a document =======================================================
410
415
  // Create a document object with "example" id
411
- const exampleDocId = "example";
416
+ const exampleDocId = 'example';
412
417
 
413
418
  // set required _id property on exampleDocument:
414
- const exampleDocument: OrderDocument = {_id: exampleDocId};
419
+ const exampleDocument: OrderDocument = { _id: exampleDocId };
415
420
 
416
421
  // Add "name" and "joined" fields to the document
417
- exampleDocument.name = "Bob Smith";
418
- exampleDocument.joined = "2019-01-24T10:42:99.000Z";
422
+ exampleDocument.name = 'Bob Smith';
423
+ exampleDocument.joined = '2019-01-24T10:42:99.000Z';
419
424
 
420
425
  // Save the document in the database
421
426
  createDb.then(() => {
422
- client.postDocument({
423
- db: exampleDbName,
424
- document: exampleDocument
425
- }).then(createDocumentResponse => {
426
- // Keep track with the revision number of the document object
427
- exampleDocument._rev = createDocumentResponse.result.rev;
428
- console.log("You have created the document:\n" +
429
- JSON.stringify(exampleDocument, null, 2));
427
+ client
428
+ .postDocument({
429
+ db: exampleDbName,
430
+ document: exampleDocument,
431
+ })
432
+ .then((createDocumentResponse) => {
433
+ // Keep track with the revision number of the document object
434
+ exampleDocument._rev = createDocumentResponse.result.rev;
435
+ console.log(
436
+ 'You have created the document:\n' +
437
+ JSON.stringify(exampleDocument, null, 2)
438
+ );
430
439
  });
431
440
  });
432
441
  ```
@@ -459,7 +468,9 @@ const createDbAndDoc = async () => {
459
468
  }
460
469
  } catch (err) {
461
470
  if (err.code === 412) {
462
- console.log('Cannot create "' + exampleDbName + '" database, it already exists.');
471
+ console.log(
472
+ 'Cannot create "' + exampleDbName + '" database, it already exists.'
473
+ );
463
474
  }
464
475
  }
465
476
 
@@ -481,7 +492,10 @@ const createDbAndDoc = async () => {
481
492
 
482
493
  // Keep track with the revision number of the document object
483
494
  exampleDocument._rev = createDocumentResponse.result.rev;
484
- console.log('You have created the document:\n' + JSON.stringify(exampleDocument, null, 2));
495
+ console.log(
496
+ 'You have created the document:\n' +
497
+ JSON.stringify(exampleDocument, null, 2)
498
+ );
485
499
  };
486
500
 
487
501
  if (require.main === module) {
@@ -526,51 +540,55 @@ import {CloudantV1} from "@ibm-cloud/cloudant";
526
540
  [embedmd]:# (test/examples/src/ts/UpdateDoc.ts /interface/ $)
527
541
  ```ts
528
542
  interface OrderDocument extends CloudantV1.Document {
529
- address?: string;
530
- joined?: string;
531
- _id?: string;
532
- _rev?: string;
543
+ address?: string;
544
+ joined?: string;
545
+ _id?: string;
546
+ _rev?: string;
533
547
  }
534
548
 
535
549
  // 1. Create a client with `CLOUDANT` default service name ================
536
550
  const client = CloudantV1.newInstance({});
537
551
  // 2. Update the document =====================================================
538
552
  // Set the options to get the document out of the database if it exists
539
- const exampleDbName = "orders";
553
+ const exampleDbName = 'orders';
540
554
 
541
555
  // Try to get the document if it previously existed in the database
542
- const getDocParams: CloudantV1.GetDocumentParams =
543
- {docId: "example", db: exampleDbName};
544
-
545
- client.getDocument(getDocParams)
546
- .then(docResult => {
547
- // using OrderDocument on getDocument result:
548
- const document: OrderDocument = docResult.result;
549
-
550
- // Add Bob Smith's address to the document
551
- document.address = "19 Front Street, Darlington, DL5 1TY";
552
-
553
- // Remove the joined property from document object
554
- delete document.joined;
555
-
556
- // Update the document in the database
557
- client.postDocument({db: exampleDbName, document})
558
- .then(res => {
559
- // Keeping track with the revision number of the document object:
560
- document._rev = res.result.rev;
561
- console.log("You have updated the document:\n" +
562
- JSON.stringify(document, null, 2));
563
- });
564
- })
565
- .catch(err => {
566
- if (err.code === 404) {
567
- console.log(
568
- "Cannot update document because either \"" +
569
- exampleDbName + "\" database or the \"example\" " +
570
- "document was not found."
571
- );
572
- }
556
+ const getDocParams: CloudantV1.GetDocumentParams = {
557
+ docId: 'example',
558
+ db: exampleDbName,
559
+ };
560
+
561
+ client
562
+ .getDocument(getDocParams)
563
+ .then((docResult) => {
564
+ // using OrderDocument on getDocument result:
565
+ const document: OrderDocument = docResult.result;
566
+
567
+ // Add Bob Smith's address to the document
568
+ document.address = '19 Front Street, Darlington, DL5 1TY';
569
+
570
+ // Remove the joined property from document object
571
+ delete document.joined;
572
+
573
+ // Update the document in the database
574
+ client.postDocument({ db: exampleDbName, document }).then((res) => {
575
+ // Keeping track with the revision number of the document object:
576
+ document._rev = res.result.rev;
577
+ console.log(
578
+ 'You have updated the document:\n' + JSON.stringify(document, null, 2)
579
+ );
573
580
  });
581
+ })
582
+ .catch((err) => {
583
+ if (err.code === 404) {
584
+ console.log(
585
+ 'Cannot update document because either "' +
586
+ exampleDbName +
587
+ '" database or the "example" ' +
588
+ 'document was not found.'
589
+ );
590
+ }
591
+ });
574
592
  ```
575
593
  </details>
576
594
 
@@ -612,7 +630,9 @@ const updateDoc = async () => {
612
630
  })
613
631
  ).result.rev;
614
632
 
615
- console.log('You have updated the document:\n' + JSON.stringify(document, null, 2));
633
+ console.log(
634
+ 'You have updated the document:\n' + JSON.stringify(document, null, 2)
635
+ );
616
636
  } catch (err) {
617
637
  if (err.code === 404) {
618
638
  console.log(
@@ -666,11 +686,11 @@ import {CloudantV1} from "@ibm-cloud/cloudant";
666
686
  [embedmd]:# (test/examples/src/ts/DeleteDoc.ts /interface/ $)
667
687
  ```ts
668
688
  interface OrderDocument extends CloudantV1.Document {
669
- name?: string;
670
- address?: string;
671
- joined?: string;
672
- _id?: string;
673
- _rev?: string;
689
+ name?: string;
690
+ address?: string;
691
+ joined?: string;
692
+ _id?: string;
693
+ _rev?: string;
674
694
  }
675
695
 
676
696
  // 1. Create a client with `CLOUDANT` default service name ================
@@ -678,33 +698,40 @@ const client = CloudantV1.newInstance({});
678
698
 
679
699
  // 2. Delete the document =============================================
680
700
  // Set the options to get the document out of the database if it exists
681
- const exampleDbName = "orders";
682
- const exampleDocId = "example";
701
+ const exampleDbName = 'orders';
702
+ const exampleDocId = 'example';
683
703
 
684
704
  // Try to get the document if it previously existed in the database
685
- const getDocParams: CloudantV1.GetDocumentParams =
686
- {docId: exampleDocId, db: exampleDbName};
687
-
688
- client.getDocument(getDocParams)
689
- .then(docResult => {
690
- const document: OrderDocument = docResult.result;
691
-
692
- client.deleteDocument({
693
- db: exampleDbName,
694
- docId: document._id,
695
- rev: document._rev}).then(() => {
696
- console.log("You have deleted the document.");
697
- });
698
- })
699
- .catch(err => {
700
- if (err.code === 404) {
701
- console.log(
702
- "Cannot delete document because either \"" +
703
- exampleDbName + "\" database or the \"example\" " +
704
- "document was not found."
705
- );
706
- }
707
- });
705
+ const getDocParams: CloudantV1.GetDocumentParams = {
706
+ docId: exampleDocId,
707
+ db: exampleDbName,
708
+ };
709
+
710
+ client
711
+ .getDocument(getDocParams)
712
+ .then((docResult) => {
713
+ const document: OrderDocument = docResult.result;
714
+
715
+ client
716
+ .deleteDocument({
717
+ db: exampleDbName,
718
+ docId: document._id,
719
+ rev: document._rev,
720
+ })
721
+ .then(() => {
722
+ console.log('You have deleted the document.');
723
+ });
724
+ })
725
+ .catch((err) => {
726
+ if (err.code === 404) {
727
+ console.log(
728
+ 'Cannot delete document because either "' +
729
+ exampleDbName +
730
+ '" database or the "example" ' +
731
+ 'document was not found.'
732
+ );
733
+ }
734
+ });
708
735
  ```
709
736
  </details>
710
737
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * © Copyright IBM Corporation 2020.
2
+ * © Copyright IBM Corporation 2021. All Rights Reserved.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ export declare type CouchdbSessionAuthenticatorOptions = {
36
36
  */
37
37
  export declare class CouchdbSessionAuthenticator extends Authenticator {
38
38
  protected tokenManager: SessionTokenManager;
39
- protected requiredOptions: ["username", "password"];
39
+ protected requiredOptions: ['username', 'password'];
40
40
  private tokenOptions;
41
41
  /**
42
42
  * Create a new CouchdbSessionAuthenticator instance.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * © Copyright IBM Corporation 2020.
3
+ * © Copyright IBM Corporation 2021. All Rights Reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ var __extends = (this && this.__extends) || (function () {
18
18
  var extendStatics = function (d, b) {
19
19
  extendStatics = Object.setPrototypeOf ||
20
20
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
22
22
  return extendStatics(d, b);
23
23
  };
24
24
  return function (d, b) {
@@ -1 +1 @@
1
- {"version":3,"file":"couchdbSessionAuthenticator.js","sourceRoot":"","sources":["../../auth/couchdbSessionAuthenticator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,yDAA+E;AAC/E,6DAAuF;AAUvF;;;;;;;;;;;GAWG;AACH;IAAiD,+CAAa;IAK5D;;;;;;;OAOG;IACH,qCAAY,OAA2C;QAAvD,YACE,iBAAO,SAGR;QAFC,kCAAa,CAAC,OAAO,EAAE,KAAI,CAAC,eAAe,CAAC,CAAC;QAC7C,KAAI,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;;IACjD,CAAC;IAED;;;;;;;;OAQG;IACI,kDAAY,GAAnB,UAAoB,cAAsB;QACxC,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACI,+CAAS,GAAhB,UAAiB,WAAwB;QACvC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,IAAI,yCAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjE,CAAC;IACH,kCAAC;AAAD,CAAC,AA1CD,CAAiD,kCAAa,GA0C7D;AA1CY,kEAA2B"}
1
+ {"version":3,"file":"couchdbSessionAuthenticator.js","sourceRoot":"","sources":["../../auth/couchdbSessionAuthenticator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,yDAA+E;AAC/E,6DAG+B;AAU/B;;;;;;;;;;;GAWG;AACH;IAAiD,+CAAa;IAK5D;;;;;;;OAOG;IACH,qCAAY,OAA2C;QAAvD,YACE,iBAAO,SAGR;QAFC,kCAAa,CAAC,OAAO,EAAE,KAAI,CAAC,eAAe,CAAC,CAAC;QAC7C,KAAI,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;;IACjD,CAAC;IAED;;;;;;;;OAQG;IACI,kDAAY,GAAnB,UAAoB,cAAsB;QACxC,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACI,+CAAS,GAAhB,UAAiB,WAAwB;QACvC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,IAAI,yCAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjE,CAAC;IACH,kCAAC;AAAD,CAAC,AA1CD,CAAiD,kCAAa,GA0C7D;AA1CY,kEAA2B"}
package/auth/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * © Copyright IBM Corporation 2020.
2
+ * © Copyright IBM Corporation 2020. All Rights Reserved.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
package/auth/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * © Copyright IBM Corporation 2020.
3
+ * © Copyright IBM Corporation 2020. All Rights Reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.SessionTokenManager = exports.CouchdbSessionAuthenticator = exports.getAuthenticatorFromEnvironment = exports.IamTokenManager = exports.IamAuthenticator = exports.BasicAuthenticator = exports.NoAuthAuthenticator = void 0;
18
19
  var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core");
19
20
  Object.defineProperty(exports, "NoAuthAuthenticator", { enumerable: true, get: function () { return ibm_cloud_sdk_core_1.NoAuthAuthenticator; } });
20
21
  Object.defineProperty(exports, "BasicAuthenticator", { enumerable: true, get: function () { return ibm_cloud_sdk_core_1.BasicAuthenticator; } });
package/auth/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../auth/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,yDAM4B;AALxB,yHAAA,mBAAmB,OAAA;AACnB,wHAAA,kBAAkB,OAAA;AAClB,sHAAA,gBAAgB,OAAA;AAChB,qHAAA,eAAe,OAAA;AACf,qIAAA,+BAA+B,OAAA;AAGnC,6EAA0E;AAAlE,0IAAA,2BAA2B,OAAA;AACnC,6DAA0D;AAAlD,0HAAA,mBAAmB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../auth/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,yDAM4B;AAL1B,yHAAA,mBAAmB,OAAA;AACnB,wHAAA,kBAAkB,OAAA;AAClB,sHAAA,gBAAgB,OAAA;AAChB,qHAAA,eAAe,OAAA;AACf,qIAAA,+BAA+B,OAAA;AAGjC,6EAA4E;AAAnE,0IAAA,2BAA2B,OAAA;AACpC,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * © Copyright IBM Corporation 2020.
2
+ * © Copyright IBM Corporation 2020. All Rights Reserved.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  /// <reference types="node" />
17
- import { OutgoingHttpHeaders } from "http";
17
+ import { OutgoingHttpHeaders } from 'http';
18
18
  import { TokenManager, UserOptions } from 'ibm-cloud-sdk-core';
19
19
  /** Configuration options for CouchDB session token retrieval. */
20
20
  export interface SessionTokenManagerOptions extends UserOptions {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * © Copyright IBM Corporation 2020.
3
+ * © Copyright IBM Corporation 2020. All Rights Reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ var __extends = (this && this.__extends) || (function () {
18
18
  var extendStatics = function (d, b) {
19
19
  extendStatics = Object.setPrototypeOf ||
20
20
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
22
22
  return extendStatics(d, b);
23
23
  };
24
24
  return function (d, b) {
@@ -56,7 +56,12 @@ var SessionTokenManager = /** @class */ (function (_super) {
56
56
  */
57
57
  function SessionTokenManager(options) {
58
58
  var _this = _super.call(this, options) || this;
59
- _this.requiredOptions = ['username', 'password', 'serviceUrl', 'jar'];
59
+ _this.requiredOptions = [
60
+ 'username',
61
+ 'password',
62
+ 'serviceUrl',
63
+ 'jar',
64
+ ];
60
65
  ibm_cloud_sdk_core_1.validateInput(options, _this.requiredOptions);
61
66
  _this.options = options;
62
67
  _this.tokenName = 'AuthSession';
@@ -89,9 +94,9 @@ var SessionTokenManager = /** @class */ (function (_super) {
89
94
  method: 'POST',
90
95
  body: {
91
96
  username: this.options.username,
92
- password: this.options.password
93
- }
94
- }
97
+ password: this.options.password,
98
+ },
99
+ },
95
100
  };
96
101
  return this.requestWrapperInstance.sendRequest(parameters);
97
102
  };
@@ -133,7 +138,8 @@ var SessionTokenManager = /** @class */ (function (_super) {
133
138
  }
134
139
  else {
135
140
  this.expireTime = Number(refreshTime[1]) + ibm_cloud_sdk_core_1.getCurrentTime();
136
- this.refreshTime = (Number(refreshTime[1]) * fractionOfTtl) + ibm_cloud_sdk_core_1.getCurrentTime();
141
+ this.refreshTime =
142
+ Number(refreshTime[1]) * fractionOfTtl + ibm_cloud_sdk_core_1.getCurrentTime();
137
143
  }
138
144
  }
139
145
  else {
@@ -141,7 +147,7 @@ var SessionTokenManager = /** @class */ (function (_super) {
141
147
  this.expireTime = Date.parse(expireTime[1]) / 1000;
142
148
  // Set refresh time from the expire time
143
149
  var timeToLive = this.expireTime - ibm_cloud_sdk_core_1.getCurrentTime();
144
- this.refreshTime = this.expireTime - (timeToLive * (1.0 - fractionOfTtl));
150
+ this.refreshTime = this.expireTime - timeToLive * (1.0 - fractionOfTtl);
145
151
  }
146
152
  };
147
153
  return SessionTokenManager;
@@ -1 +1 @@
1
- {"version":3,"file":"sessionTokenManager.js","sourceRoot":"","sources":["../../auth/sessionTokenManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAGH,yDAA8F;AAU9F;;;;;GAKG;AACH;IAAyC,uCAAY;IAKnD;;;;;;;;;;;;;;;OAeG;IACH,6BAAY,OAAmC;QAA/C,YACE,kBAAM,OAAO,CAAC,SAMf;QA3BS,qBAAe,GAAa,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QAuBlF,kCAAa,CAAC,OAAO,EAAE,KAAI,CAAC,eAAe,CAAC,CAAC;QAE7C,KAAI,CAAC,OAA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