OSDN Git Service

add access tokens api doc
authorYongfeng LI <wliyongfeng@gmail.com>
Tue, 15 May 2018 11:33:48 +0000 (19:33 +0800)
committerYongfeng LI <wliyongfeng@gmail.com>
Tue, 15 May 2018 11:33:48 +0000 (19:33 +0800)
src/api/accessTokens.js
src/client.js

index a68c420..4a3c819 100644 (file)
@@ -1,7 +1,46 @@
+/**
+ * Access tokens are `name:secret-token` pairs that are granted authorization for accessing Chain Core features.
+ *
+ * @typedef {Object} AccessToken
+ * @global
+ *
+ * @property {String} id
+ * User specified, unique identifier.
+ *
+ * @property {String} token
+ * Only returned in the response from {@link AccessTokensApi~create}.
+ *
+ * @property {String} created_at
+ * Timestamp of token creation, RFC3339 formatted.
+ */
+
+/**
+ * API for interacting with {@link AccessToken access tokens}.
+ *
+ * @module AccessTokensApi
+ */
 const accessTokensApi = (connection) => {
   return {
+    /**
+     * Create a new access token.
+     *
+     * @param {String} id - User specified, unique identifier.
+     * @returns {Promise<AccessToken>} Newly created access token.
+     */
     create: (id) => connection.request('/create-access-token', {id}),
+
+    /**
+     * Get all access tokens.
+     *
+     * @returns {Promise<Array<AccessToken>>} All access tokens.
+     */
     list: () => connection.request('/list-access-tokens', {}),
+
+    /**
+     * Delete the target access token.
+     *
+     * @param {String} id - The to be deleted token id.
+     */
     delete: (id) => connection.request('/delete-access-token', {id})
   }
 }
index e3c708c..7c6c7b7 100644 (file)
@@ -17,7 +17,7 @@ class Client {
     this.transactions = new transactionApi(this.connection)
     this.balances = new balancesApi(this.connection)
     this.unspentOutputs = new unspentOutputsAPI(this.connection)
-    this.accessTokensApi = new accessTokensApi(this.connection)
+    this.accessTokens = new accessTokensApi(this.connection)
   }
 }