@caruuto/caruuto-js 0.3.5 → 0.3.6

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/CHANGELOG.md CHANGED
@@ -5,7 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
- ## 0.3.4 - 2024-05-08
8
+ ## 0.3.6 - 2024-09-06
9
+
10
+ ### Added
11
+
12
+ - Added `createToken` method for creating new tokens for reset password, etc.
13
+ - Added `verifyToken` method for verifying tokens created by `createToken`.
14
+
15
+ ## 0.3.5 - 2024-05-08
9
16
 
10
17
  ### Fixed
11
18
 
@@ -297,4 +297,45 @@ module.exports = function (CaruutoClient) {
297
297
 
298
298
  return this._createRequestObject(requestPayload)
299
299
  }
300
+
301
+ /*
302
+ * Create a new token.
303
+ * @param {Object} data
304
+ * @api public
305
+ */
306
+ CaruutoClient.prototype.createToken = function (data) {
307
+ this.endpoint = 'tokens'
308
+
309
+ const requestPayload = {
310
+ body: data,
311
+ method: 'POST',
312
+ uri: this._buildURL()
313
+ }
314
+
315
+ this._setHeader('content-type', 'application/json')
316
+
317
+ return this._createRequestObject(requestPayload)
318
+ }
319
+
320
+ /*
321
+ * Verify a token.
322
+ * @param {Object} data
323
+ * @api public
324
+ */
325
+ CaruutoClient.prototype.verifyToken = function (token) {
326
+ this.endpoint = 'tokens'
327
+
328
+ const requestPayload = {
329
+ body: {
330
+ token,
331
+ verify: true
332
+ },
333
+ method: 'POST',
334
+ uri: this._buildURL()
335
+ }
336
+
337
+ this._setHeader('content-type', 'application/json')
338
+
339
+ return this._createRequestObject(requestPayload)
340
+ }
300
341
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caruuto/caruuto-js",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "A high-level library for interacting with Caruuto",
5
5
  "exports": "./index.js",
6
6
  "scripts": {
package/x.js CHANGED
@@ -13,7 +13,14 @@ const { createClient } = require('./index')
13
13
  // questionId: 'f373b0a2-9c87-41f1-af49-f643da8f836c'
14
14
  // })
15
15
 
16
- x.search({ phrase: 'grower' })
17
- const y = await x.find()
18
- console.log('y :>> ', y)
16
+ // x.search({ phrase: 'grower' })
17
+ // const y = await x.find()
18
+ // console.log('y :>> ', y)
19
+
20
+ // const z = await x.createToken({
21
+ // email: 'jameslambie@gmail.com',
22
+ // type: 'RESET'
23
+ // })
24
+ const z = await x.verifyToken('q8ug8epjx5hzcg48ku')
25
+ console.log('z :>> ', z)
19
26
  })()