@ibm-cloud/cloudant 0.0.17 → 0.0.21
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 +21 -9
- package/auth/couchdbSessionAuthenticator.d.ts +7 -0
- package/auth/couchdbSessionAuthenticator.js +10 -1
- package/auth/couchdbSessionAuthenticator.js.map +1 -1
- package/auth/sessionTokenManager.js +4 -4
- package/auth/sessionTokenManager.js.map +1 -1
- package/cloudant/v1.d.ts +133 -118
- package/cloudant/v1.js +520 -647
- package/cloudant/v1.js.map +1 -1
- package/lib/cloudantBaseService.d.ts +4 -0
- package/lib/cloudantBaseService.js +97 -1
- package/lib/cloudantBaseService.js.map +1 -1
- package/lib/getAuthenticatorFromEnvCloudantExtension.js +2 -2
- package/lib/getAuthenticatorFromEnvCloudantExtension.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
[](https://github.com/IBM/cloudant-node-sdk/releases/latest)
|
|
3
3
|
[](https://ibm.github.io/cloudant-node-sdk/)
|
|
4
4
|
|
|
5
|
-
# IBM Cloudant Node.js SDK Version 0.0.
|
|
5
|
+
# IBM Cloudant Node.js SDK Version 0.0.21
|
|
6
6
|
|
|
7
7
|
IBM Cloudant Node.js SDK is a client library that interacts with the
|
|
8
8
|
[IBM Cloudant APIs](https://cloud.ibm.com/apidocs/cloudant?code=node).
|
|
9
9
|
|
|
10
|
-
Disclaimer: This
|
|
11
|
-
|
|
10
|
+
Disclaimer: This library is still a 0.x release. We do consider this
|
|
11
|
+
library production-ready and capable, but there are still some
|
|
12
|
+
limitations we’re working to resolve, and refinements we want to
|
|
13
|
+
deliver. We are working really hard to minimise the disruption from
|
|
14
|
+
now until the 1.0 release, but there may still be some changes that
|
|
15
|
+
impact applications using this SDK. For now, be sure to pin versions
|
|
16
|
+
to avoid surprises.
|
|
12
17
|
|
|
13
18
|
<details>
|
|
14
19
|
<summary>Table of Contents</summary>
|
|
@@ -35,6 +40,7 @@ Changes might occur which impact applications that use this SDK.
|
|
|
35
40
|
* [Authentication with external configuration](#authentication-with-external-configuration)
|
|
36
41
|
* [Programmatic authentication](#programmatic-authentication)
|
|
37
42
|
- [Using the SDK](#using-the-sdk)
|
|
43
|
+
* [Request timeout configuration](#request-timeout-configuration)
|
|
38
44
|
* [Code examples](#code-examples)
|
|
39
45
|
+ [1. Retrieve information from an existing database](#1-retrieve-information-from-an-existing-database)
|
|
40
46
|
+ [2. Create your own database and add a document](#2-create-your-own-database-and-add-a-document)
|
|
@@ -100,12 +106,12 @@ npm install @ibm-cloud/cloudant
|
|
|
100
106
|
|
|
101
107
|
## Authentication
|
|
102
108
|
|
|
103
|
-
[service-credentials]: https://cloud.ibm.com/docs/Cloudant?topic=
|
|
104
|
-
[cloud-IAM-mgmt]: https://cloud.ibm.com/docs/Cloudant?topic=
|
|
109
|
+
[service-credentials]: https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-locating-your-service-credentials
|
|
110
|
+
[cloud-IAM-mgmt]: https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-managing-access-for-cloudant#introduction-iam-ai
|
|
105
111
|
[couch-cookie-auth]: https://docs.couchdb.org/en/stable/api/server/authn.html#cookie-authentication
|
|
106
|
-
[cloudant-cookie-auth]: https://cloud.ibm.com/docs/Cloudant?topic=
|
|
112
|
+
[cloudant-cookie-auth]: https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-account#cookie-authentication
|
|
107
113
|
[couch-basic-auth]: https://docs.couchdb.org/en/stable/api/server/authn.html#basic-authentication
|
|
108
|
-
[cloudant-basic-auth]: https://cloud.ibm.com/docs/
|
|
114
|
+
[cloudant-basic-auth]: https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-account#basic-authentication
|
|
109
115
|
|
|
110
116
|
This library requires some of your
|
|
111
117
|
[Cloudant service credentials][service-credentials] to authenticate with your
|
|
@@ -198,8 +204,14 @@ or in the
|
|
|
198
204
|
|
|
199
205
|
## Using the SDK
|
|
200
206
|
|
|
201
|
-
For
|
|
202
|
-
|
|
207
|
+
For fundamental SDK usage information and config options, please see the common [IBM Cloud SDK](https://github.com/IBM/ibm-cloud-sdk-common/blob/master/README.md) documentation.
|
|
208
|
+
|
|
209
|
+
### Request timeout configuration
|
|
210
|
+
|
|
211
|
+
No request timeout is defined, but a 2.5m connect and 2.5m read timeout is set by default. Be sure to set a request timeout appropriate to your application usage and environment.
|
|
212
|
+
The [request timeout](https://github.com/IBM/ibm-cloud-sdk-common/blob/master/README.md) section contains details on how to change the value.
|
|
213
|
+
|
|
214
|
+
**Note:** System settings may take precedence over configured timeout values.
|
|
203
215
|
|
|
204
216
|
### Code examples
|
|
205
217
|
|
|
@@ -38,6 +38,7 @@ export declare class CouchdbSessionAuthenticator extends Authenticator {
|
|
|
38
38
|
protected tokenManager: SessionTokenManager;
|
|
39
39
|
protected requiredOptions: ['username', 'password'];
|
|
40
40
|
private tokenOptions;
|
|
41
|
+
static readonly AUTHTYPE_COUCHDB_SESSION = "COUCHDB_SESSION";
|
|
41
42
|
/**
|
|
42
43
|
* Create a new CouchdbSessionAuthenticator instance.
|
|
43
44
|
*
|
|
@@ -64,4 +65,10 @@ export declare class CouchdbSessionAuthenticator extends Authenticator {
|
|
|
64
65
|
* @param {object} userOptions - Configuration values for a `request` service.
|
|
65
66
|
*/
|
|
66
67
|
configure(userOptions: UserOptions): void;
|
|
68
|
+
/**
|
|
69
|
+
* Returns the authenticator's type ('COUCHDB_SESSION').
|
|
70
|
+
*
|
|
71
|
+
* @returns a string that indicates the authenticator's type
|
|
72
|
+
*/
|
|
73
|
+
authenticationType(): string;
|
|
67
74
|
}
|
|
@@ -57,7 +57,7 @@ var CouchdbSessionAuthenticator = /** @class */ (function (_super) {
|
|
|
57
57
|
*/
|
|
58
58
|
function CouchdbSessionAuthenticator(options) {
|
|
59
59
|
var _this = _super.call(this) || this;
|
|
60
|
-
ibm_cloud_sdk_core_1.validateInput(options, _this.requiredOptions);
|
|
60
|
+
(0, ibm_cloud_sdk_core_1.validateInput)(options, _this.requiredOptions);
|
|
61
61
|
_this.tokenOptions = Object.assign({}, options);
|
|
62
62
|
return _this;
|
|
63
63
|
}
|
|
@@ -120,6 +120,15 @@ var CouchdbSessionAuthenticator = /** @class */ (function (_super) {
|
|
|
120
120
|
// Set the token manager
|
|
121
121
|
this.tokenManager = new sessionTokenManager_1.SessionTokenManager(this.tokenOptions);
|
|
122
122
|
};
|
|
123
|
+
/**
|
|
124
|
+
* Returns the authenticator's type ('COUCHDB_SESSION').
|
|
125
|
+
*
|
|
126
|
+
* @returns a string that indicates the authenticator's type
|
|
127
|
+
*/
|
|
128
|
+
CouchdbSessionAuthenticator.prototype.authenticationType = function () {
|
|
129
|
+
return CouchdbSessionAuthenticator.AUTHTYPE_COUCHDB_SESSION;
|
|
130
|
+
};
|
|
131
|
+
CouchdbSessionAuthenticator.AUTHTYPE_COUCHDB_SESSION = 'COUCHDB_SESSION';
|
|
123
132
|
return CouchdbSessionAuthenticator;
|
|
124
133
|
}(ibm_cloud_sdk_core_1.Authenticator));
|
|
125
134
|
exports.CouchdbSessionAuthenticator = CouchdbSessionAuthenticator;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IAM5D;;;;;;;OAOG;IACH,qC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;gBACF,oGAAoG;gBACpG,uGAAuG;gBACvG,+CAA+C;gBAC/C,IAAI,wBAAsB,EAAE;oBAC1B,wBAAsB,CAAC,IAAI,CACzB,SAAS,CAAC,KAAK,EACf,SAAS,EACT,SAAS,EACT,EAAE,CACH,CAAC;iBACH;qBAAM;oBACL,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;iBAChE;YACH,CAAC,CAAC;SACH;QACD,8BAA8B;QAE9B,wBAAwB;QACxB,IAAI,CAAC,YAAY,GAAG,IAAI,yCAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACI,wDAAkB,GAAzB;QACE,OAAO,2BAA2B,CAAC,wBAAwB,CAAC;IAC9D,CAAC;IA7Fe,oDAAwB,GAAG,iBAAiB,CAAC;IA8F/D,kCAAC;CAAA,AAlGD,CAAiD,kCAAa,GAkG7D;AAlGY,kEAA2B"}
|
|
@@ -64,7 +64,7 @@ var SessionTokenManager = /** @class */ (function (_super) {
|
|
|
64
64
|
'serviceUrl',
|
|
65
65
|
'jar',
|
|
66
66
|
];
|
|
67
|
-
ibm_cloud_sdk_core_1.validateInput(options, _this.requiredOptions);
|
|
67
|
+
(0, ibm_cloud_sdk_core_1.validateInput)(options, _this.requiredOptions);
|
|
68
68
|
_this.options = options;
|
|
69
69
|
_this.tokenName = 'AuthSession';
|
|
70
70
|
return _this;
|
|
@@ -139,16 +139,16 @@ var SessionTokenManager = /** @class */ (function (_super) {
|
|
|
139
139
|
this.refreshTime = 0;
|
|
140
140
|
}
|
|
141
141
|
else {
|
|
142
|
-
this.expireTime = Number(refreshTime[1]) + ibm_cloud_sdk_core_1.getCurrentTime();
|
|
142
|
+
this.expireTime = Number(refreshTime[1]) + (0, ibm_cloud_sdk_core_1.getCurrentTime)();
|
|
143
143
|
this.refreshTime =
|
|
144
|
-
Number(refreshTime[1]) * fractionOfTtl + ibm_cloud_sdk_core_1.getCurrentTime();
|
|
144
|
+
Number(refreshTime[1]) * fractionOfTtl + (0, ibm_cloud_sdk_core_1.getCurrentTime)();
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
148
148
|
// Store expire time in seconds
|
|
149
149
|
this.expireTime = Date.parse(expireTime[1]) / 1000;
|
|
150
150
|
// Set refresh time from the expire time
|
|
151
|
-
var timeToLive = this.expireTime - ibm_cloud_sdk_core_1.getCurrentTime();
|
|
151
|
+
var timeToLive = this.expireTime - (0, ibm_cloud_sdk_core_1.getCurrentTime)();
|
|
152
152
|
this.refreshTime = this.expireTime - timeToLive * (1.0 - fractionOfTtl);
|
|
153
153
|
}
|
|
154
154
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionTokenManager.js","sourceRoot":"","sources":["../../auth/sessionTokenManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;AAGH,yDAK4B;AAU5B;;;;;GAKG;AACH;IAAyC,uCAAY;IAUnD;;;;;;;;;;;;;;;OAeG;IACH,6BAAY,OAAmC;QAA/C,YACE,kBAAM,OAAO,CAAC,SAMf;QAhCS,qBAAe,GAAa;YACpC,UAAU;YACV,UAAU;YACV,YAAY;YACZ,KAAK;SACN,CAAC;QAuBA,kCAAa,
|
|
1
|
+
{"version":3,"file":"sessionTokenManager.js","sourceRoot":"","sources":["../../auth/sessionTokenManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;AAGH,yDAK4B;AAU5B;;;;;GAKG;AACH;IAAyC,uCAAY;IAUnD;;;;;;;;;;;;;;;OAeG;IACH,6BAAY,OAAmC;QAA/C,YACE,kBAAM,OAAO,CAAC,SAMf;QAhCS,qBAAe,GAAa;YACpC,UAAU;YACV,UAAU;YACV,YAAY;YACZ,KAAK;SACN,CAAC;QAuBA,IAAA,kCAAa,EAAC,O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