Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 28fb98b

Browse files
authored
Merge pull request #411 from cloudant/409-init-callback-docs
Improved docs for initialization callback
2 parents acea66a + 66f86ca commit 28fb98b

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# UNRELEASED
22
- [FIXED] Expose BasePlugin.
3+
- [IMPROVED] Documented the legacy compatibility behaviour that always adds the
4+
`cookieauth` plugin when using the initialization callback functionality.
35

46
# 4.2.2 (2019-10-23)
57
- [FIXED] Stopped disabling the IAM auth plugin after failed IAM

README.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Note, if you only have a single Cloudant service then specifying the
224224

225225
You can optionally provide a callback to the Cloudant initialization
226226
function. This will make the library automatically
227-
[ping](https://console.bluemix.net/docs/services/Cloudant/api/account.html#ping)
227+
[ping](https://cloud.ibm.com/docs/services/Cloudant/api?topic=cloudant-account#ping)
228228
Cloudant to confirm the connection and that your credentials work.
229229

230230
Here is a simple example of initializing asynchronously, using its optional
@@ -249,6 +249,25 @@ Cloudant({ account: me, password: password }, function(err, cloudant, pong) {
249249
});
250250
~~~
251251

252+
**Note:** For legacy compatibility with older versions of the library using the
253+
initialization callback will always add the `cookieauth` plugin to the list of
254+
configured plugins. If you do not want to use `cookieauth` then you should not
255+
use this initialization callback, instead initalize the client without a
256+
callback and then call the [ping function](https://cloud.ibm.com/docs/services/Cloudant/api?topic=cloudant-account#ping)
257+
e.g.:
258+
259+
```js
260+
const c = new Cloudant({
261+
url: 'http://localhost:5984',
262+
username: 'somebody',
263+
password: 'something',
264+
plugins: [] // disable cookieauth
265+
});
266+
c.ping()
267+
.then(/* do something with response */ console.log)
268+
.catch(/* handle error */ console.log);
269+
```
270+
252271
### Callback Signature
253272

254273
Callback functions receive three arguments:
@@ -387,7 +406,7 @@ var cloudant = Cloudant({ url: myurl, maxAttempt: 5, plugins: [ { iamauth: { iam
387406
388407
IBM Cloud Identity & Access Management enables you to securely authenticate
389408
users and control access to all cloud resources consistently in the IBM
390-
Bluemix Cloud Platform.
409+
Cloud Platform.
391410
392411
This plugin will automatically exchange your IAM API key for a token. It will
393412
handle the authentication and ensure that the token is refreshed as required.
@@ -412,7 +431,7 @@ var cloudant = Cloudant({ url: myurl, maxAttempt: 5, plugins: [ { iamauth: { iam
412431
(either because the IAM token service is down or the IAM API key is
413432
incorrect) then an error is returned to the client.
414433
415-
See [IBM Cloud Identity and Access Management](https://console.bluemix.net/docs/services/Cloudant/guides/iam.html#ibm-cloud-identity-and-access-management) for more information.
434+
See [IBM Cloud Identity and Access Management](https://cloud.ibm.com/docs/services/Cloudant/guides?topic=cloudant-ibm-cloud-identity-and-access-management-iam-) for more information.
416435
417436
3. `retry`
418437
@@ -493,7 +512,7 @@ This library adds documentation for the following:
493512
494513
Cloudant API keys are part of the legacy access controls. They are different from
495514
the access control mechanisms offered by IBM Cloud IAM. See
496-
[here](https://console.bluemix.net/docs/services/Cloudant/guides/iam.html#ibm-cloud-identity-and-access-management-iam-)
515+
[here](https://cloud.ibm.com/docs/services/Cloudant/guides?topic=cloudant-ibm-cloud-identity-and-access-management-iam-)
497516
for more details.
498517
499518
This feature interfaces with the Cloudant [authorization API][Authorization].
@@ -1285,13 +1304,13 @@ specific language governing permissions and limitations under the License.
12851304
* [Issues]
12861305
* [Nano Library]
12871306
1288-
[Authentication]: https://console.bluemix.net/docs/services/Cloudant/api/authentication.html
1289-
[Authorization]: https://console.bluemix.net/docs/services/Cloudant/api/authorization.html#authorization
1290-
[CORS]: https://console.bluemix.net/docs/services/Cloudant/api/cors.html#cors
1291-
[Cloudant Documentation]: https://console.bluemix.net/docs/services/Cloudant/cloudant.html#overview
1292-
[Cloudant Geospatial]: https://console.bluemix.net/docs/services/Cloudant/api/cloudant-geo.html#cloudant-geospatial
1293-
[Cloudant Query]: https://console.bluemix.net/docs/services/Cloudant/api/cloudant_query.html#query
1294-
[Cloudant Search]: https://console.bluemix.net/docs/services/Cloudant/api/search.html
1307+
[Authentication]: https://cloud.ibm.com/docs/services/Cloudant/api?topic=cloudant-authentication
1308+
[Authorization]: https://cloud.ibm.com/docs/services/Cloudant/api?topic=cloudant-authorization
1309+
[CORS]: https://cloud.ibm.com/docs/services/Cloudant/api?topic=cloudant-cors
1310+
[Cloudant Documentation]: https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-overview
1311+
[Cloudant Geospatial]: https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-cloudant-nosql-db-geospatial
1312+
[Cloudant Query]: https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-query
1313+
[Cloudant Search]: https://cloud.ibm.com/docs/services/Cloudant?topic=cloudant-search
12951314
[Follow library]: https://github.com/cloudant-labs/cloudant-follow
12961315
[Issues]: https://github.com/cloudant/nodejs-cloudant/issues
12971316
[Nano Library]: https://github.com/apache/couchdb-nano

0 commit comments

Comments
 (0)