hivesigner 4.0.0 → 4.1.0

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.
Files changed (52) hide show
  1. package/README.md +16 -2
  2. package/lib/client.d.ts +19 -2
  3. package/lib/hivesigner.min.js +1 -1
  4. package/lib/index.d.ts +4 -0
  5. package/lib/index.js +67 -9
  6. package/lib/pkce.d.ts +16 -0
  7. package/lib/types/index.d.ts +1 -0
  8. package/lib/types/login-options.interface.d.ts +2 -0
  9. package/lib/types/token-response.interface.d.ts +8 -0
  10. package/package.json +4 -1
  11. package/.claude/settings.local.json +0 -12
  12. package/.eslintignore +0 -3
  13. package/.eslintrc.js +0 -16
  14. package/CLAUDE.md +0 -142
  15. package/docs/CNAME +0 -1
  16. package/docs/index.html +0 -221
  17. package/jest.config.js +0 -10
  18. package/rollup.config.js +0 -13
  19. package/src/client.spec.ts +0 -453
  20. package/src/client.ts +0 -318
  21. package/src/consts/api-url.const.ts +0 -1
  22. package/src/consts/base-url.const.ts +0 -1
  23. package/src/consts/beta-url.const.ts +0 -1
  24. package/src/consts/index.ts +0 -3
  25. package/src/default-import.spec.ts +0 -10
  26. package/src/factories/index.ts +0 -1
  27. package/src/factories/initialize.factory.spec.ts +0 -9
  28. package/src/factories/initialize.factory.ts +0 -7
  29. package/src/index.ts +0 -16
  30. package/src/methods/index.ts +0 -4
  31. package/src/methods/send-operation.method.spec.ts +0 -47
  32. package/src/methods/send-operation.method.ts +0 -14
  33. package/src/methods/send-operations.method.spec.ts +0 -47
  34. package/src/methods/send-operations.method.ts +0 -14
  35. package/src/methods/send-transaction.method.spec.ts +0 -47
  36. package/src/methods/send-transaction.method.ts +0 -14
  37. package/src/methods/sign.method.spec.ts +0 -60
  38. package/src/methods/sign.method.ts +0 -22
  39. package/src/modules-import.spec.ts +0 -11
  40. package/src/require-import.spec.js +0 -16
  41. package/src/require-import.spec.ts +0 -10
  42. package/src/types/callback-function.type.ts +0 -1
  43. package/src/types/client-config.interface.ts +0 -8
  44. package/src/types/hive.types.ts +0 -12
  45. package/src/types/index.ts +0 -6
  46. package/src/types/login-options.interface.ts +0 -3
  47. package/src/types/send-response.type.ts +0 -1
  48. package/src/types/sign-errors.interface.ts +0 -4
  49. package/src/utilities/index.ts +0 -1
  50. package/src/utilities/is-browser.util.ts +0 -3
  51. package/tsconfig.json +0 -17
  52. package/webpack.config.js +0 -33
package/docs/index.html DELETED
@@ -1,221 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Hivesigner demo with Vue.js</title>
6
- <link rel="stylesheet" href="https://unpkg.com/primer-css@9.6.0/build/build.css" />
7
- <script src="https://unpkg.com/vue@latest/dist/vue.js"></script>
8
- <script src="https://unpkg.com/hivesigner@latest/lib/hivesigner.min.js"></script>
9
- <!-- <script src="https://cdn.jsdelivr.net/npm/hivesigner@3.2.2"></script> -->
10
- <!-- <script src="../dist/hivesigner.min.js"></script> -->
11
- </head>
12
- <body>
13
-
14
- <div id="main" class="Box p-4 my-4" v-cloak>
15
- <div class="bg-gray text-center mb-4 p-4 rounded">
16
- <h3>HiveSigner demo with Vue.js</h3>
17
- <p>
18
- <a target="_blank" href="https://github.com/ecency/hivesigner-sdk/blob/master/docs/index.html">
19
- See the code on GitHub
20
- </a>
21
- </p>
22
- </div>
23
-
24
- <p v-if="!isInit">Loading...</p>
25
- <div v-else>
26
- <div v-if="!username" class="text-center">
27
-
28
- <button @click="login" class="btn btn-primary" :disabled="isLoading">
29
- Log in
30
- </button>
31
- </div>
32
-
33
- <div v-if="username">
34
- <p class="mb-4">
35
- You are logged as <b>{{username}}</b>
36
- <a href="#" @click="logout">logout</a>
37
- </p>
38
-
39
- <div class="mb-4">
40
- <h4 class="mb-2">Comment and vote</h4>
41
- <p class="mb-2">
42
- You are commenting on the post:
43
- <b>
44
- <a :href="`https://ecency.com/@${parentAuthor}/${parentPermlink}`" target="_blank">
45
- @{{ parentAuthor }}/{{ parentPermlink }}
46
- </a>
47
- </b>
48
- </p>
49
-
50
- <textarea
51
- v-model="form.comment"
52
- placeholder="Write a comment"
53
- class="form-control mb-2 btn-block text-left"
54
- :disabled="isLoading"
55
- ></textarea>
56
-
57
- <button @click="comment" class="btn btn-primary mb-2 mr-1" :disabled="isLoading">
58
- Comment
59
- </button>
60
-
61
- <button @click="vote" class="btn mb-2" :disabled="isLoading">
62
- Upvote
63
- </button>
64
- </div>
65
-
66
- <div class="mb-4">
67
- <h4 class="mb-2">Request transfer</h4>
68
- <button @click="transfer" class="btn mb-2" :disabled="isLoading">
69
- Transfer
70
- </button>
71
- </div>
72
-
73
- <div v-if="txId" class="flash flash-success mb-2">
74
- <p>
75
- The transaction has been broadcasted, here is the tx id:
76
- <a :href="'https://hiveblocks.com/tx/' + txId" target="_blank">
77
- <b>{{ txId }}</b>
78
- </a>
79
- </p>
80
- </div>
81
-
82
- <div v-if="error" class="flash flash-error mb-2">
83
- <p>{{ error.error_description || error.error || error }}</p>
84
- </div>
85
- </div>
86
- </div>
87
- </div>
88
-
89
- <script type="text/javascript">
90
- const client = new hivesigner.Client({
91
- app: 'demo',
92
- callbackURL: 'https://demo.hivesigner.com'
93
- });
94
-
95
- window.onload = function() {
96
- new Vue({
97
- el: '#main',
98
- data: {
99
- username: null,
100
- form: {
101
- username: null,
102
- comment: null,
103
- },
104
- isInit: false,
105
- isLoading: false,
106
- txId: null,
107
- error: null,
108
- parentAuthor: 'steemguest',
109
- parentPermlink: '4lx1se-test-post',
110
-
111
- },
112
- mounted: function () {
113
- let params = (new URL(location)).searchParams;
114
- const token = params.get('access_token') || localStorage.getItem('sc_token');
115
- if (token) {
116
- const self = this;
117
- this.isInit = false;
118
- client.setAccessToken(token);
119
-
120
- client.me(function(err, result) {
121
- if (result) self.username = result.name;
122
- if (err) self.error = err;
123
- localStorage.setItem('sc_token', token);
124
- self.isInit = true;
125
- console.log(err, result);
126
- });
127
- } else {
128
- this.isInit = true;
129
- }
130
- },
131
- methods: {
132
- login: function () {
133
- const self = this;
134
- this.isLoading = true;
135
-
136
- const loginObj = {};
137
- if (this.form.username) loginObj.username = this.form.username;
138
-
139
- client.login(loginObj, function(err, token) {
140
- console.log('Log in result', err, token);
141
- if (err) return self.isLoading = false;
142
- client.setAccessToken(token);
143
-
144
- client.me(function(err, result) {
145
- console.log('Verification result', err, result);
146
- if (result) self.username = result.name;
147
- if (err) self.error = err;
148
- localStorage.setItem('sc_token', token);
149
- self.isLoading = false;
150
- });
151
- });
152
- },
153
- comment: function () {
154
- const self = this;
155
- this.isLoading = true;
156
- this.txId = null;
157
- this.error = null;
158
-
159
- const permlink = 'hivesigner-' + new Date().getTime();
160
- const jsonMetadata = JSON.stringify({ tags: ['hivesigner'], app: 'hivesigner' });
161
-
162
- client.comment(this.parentAuthor, this.parentPermlink, this.username, permlink, '', this.form.comment, jsonMetadata, function(err, result) {
163
- console.log('Comment result', err, result);
164
- self.isLoading = false;
165
- if (result) self.txId = result.id || result.result.id;
166
- if (err) self.error = err;
167
- });
168
- },
169
- vote: function () {
170
- const self = this;
171
- this.isLoading = true;
172
- this.txId = null;
173
- this.error = null;
174
-
175
- client.vote(this.username, this.parentAuthor, this.parentPermlink, 10000, function(err, result) {
176
- console.log('Vote result', err, result);
177
- self.isLoading = false;
178
- if (result) self.txId = result.id || result.result.id;
179
- if (err) self.error = err;
180
- });
181
- },
182
- transfer: function () {
183
- const self = this;
184
- this.txId = null;
185
- this.error = null;
186
-
187
- const op = ['transfer', {
188
- from: '__signer',
189
- to: 'ecency',
190
- amount: '0.001 HIVE',
191
- memo: 'Transfer with HiveSigner demo'
192
- }];
193
- hivesigner.sendOperation(op, {}, function(err, result) {
194
- console.log('Transfer result', err, result);
195
- if (result) self.txId = result.id || result.result.id;
196
- if (err) self.error = err;
197
- });
198
- },
199
- logout: function () {
200
- this.username = null;
201
- localStorage.removeItem('sc_token');
202
- }
203
- }
204
- });
205
- };
206
- </script>
207
-
208
- <style type="text/css">
209
- #main {
210
- width: 100%;
211
- max-width: 600px;
212
- margin: 0 auto;
213
- }
214
-
215
- [v-cloak] {
216
- display: none;
217
- }
218
- </style>
219
-
220
- </body>
221
- </html>
package/jest.config.js DELETED
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- preset: 'ts-jest',
3
- testEnvironment: 'node',
4
- globals: {
5
- window: {
6
- open: () => {},
7
- location: ''
8
- }
9
- }
10
- };
package/rollup.config.js DELETED
@@ -1,13 +0,0 @@
1
- import typescript from '@rollup/plugin-typescript';
2
-
3
- export default {
4
- input: './src/index.ts',
5
- output: {
6
- file: 'lib/index.js',
7
- format: 'cjs',
8
- exports: 'named',
9
- },
10
- plugins: [
11
- typescript({ declaration: false, sourceMap: false, module: 'esnext' })
12
- ]
13
- }
@@ -1,453 +0,0 @@
1
- import { Client } from './client'
2
- import { ClientConfig } from './types'
3
- import { API_URL, BASE_URL } from './consts'
4
- import * as utilities from './utilities'
5
-
6
- jest.mock('./utilities')
7
-
8
- describe('Client', function () {
9
- let instance: Client
10
- let isBrowserMock: jest.Mock
11
- let fetchMock: jest.Mock
12
- let fetchResponseMock: { status: string | number, json: () => {} }
13
-
14
- beforeEach(() => {
15
- instance = new Client({
16
- app: 'test-app',
17
- callbackURL: 'test-callback',
18
- apiURL: API_URL,
19
- accessToken: 'test-access-token',
20
- responseType: 'test-response-type',
21
- scope: ['test-scope-item'],
22
- })
23
-
24
- isBrowserMock = utilities.isBrowser as jest.Mock
25
- isBrowserMock.mockReturnValue(false)
26
-
27
- fetchResponseMock = {
28
- status: 200,
29
- json: async () => ({ error: '' })
30
- }
31
- fetchMock = jest.fn().mockImplementation(async (...args: any[]) => fetchResponseMock)
32
- global.fetch = fetchMock
33
- })
34
-
35
- it('should create instance', function () {
36
- expect(new Client({} as ClientConfig)).toBeInstanceOf(Client)
37
- })
38
-
39
- it('should set api url', function () {
40
- instance.setApiURL('another-test-api-url')
41
- expect(instance.apiURL).toBe('another-test-api-url')
42
- })
43
-
44
- it('should set app', function () {
45
- instance.setApp('another-app')
46
- expect(instance.app).toBe('another-app')
47
- })
48
-
49
- it('should set callback url', function () {
50
- instance.setCallbackURL('another-url')
51
- expect(instance.callbackURL).toBe('another-url')
52
- })
53
-
54
- it('should set access token', function () {
55
- instance.setAccessToken('another-token')
56
- expect(instance.accessToken).toBe('another-token')
57
- })
58
-
59
- it('should remove access token', function () {
60
- instance.removeAccessToken()
61
- expect(instance.accessToken).toBeFalsy()
62
- })
63
-
64
- it('should set scope', function () {
65
- instance.setScope([])
66
- expect(instance.scope).toStrictEqual([])
67
- })
68
-
69
- it('should return login url', function () {
70
- instance.scope = null
71
- expect(instance.getLoginURL(''))
72
- .toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}`)
73
-
74
- instance.scope = ['test-scope', 'test-scope-1']
75
- expect(instance.getLoginURL(''))
76
- .toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}&scope=test-scope,test-scope-1`)
77
-
78
- instance.responseType = 'code'
79
- expect(instance.getLoginURL(''))
80
- .toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}&response_type=code&scope=test-scope,test-scope-1`)
81
-
82
- expect(instance.getLoginURL('state'))
83
- .toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}&response_type=code&scope=test-scope,test-scope-1&state=state`)
84
-
85
- expect(instance.getLoginURL('state', 'demo'))
86
- .toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}&response_type=code&scope=test-scope,test-scope-1&state=state&account=demo`)
87
- })
88
-
89
- it('should change window location on login if its browser', function () {
90
- isBrowserMock.mockReturnValue(false)
91
- instance.login({ state: '' })
92
- expect(window.location).toBe('')
93
-
94
- isBrowserMock.mockReturnValue(true)
95
- instance.login({ state: '' })
96
- expect(window.location)
97
- .toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}&scope=test-scope-item`)
98
- })
99
-
100
- it('should return promise resolve on send call', async function () {
101
- const response = await instance.send('me', 'POST', {})
102
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/me`,{
103
- method: 'POST',
104
- headers: {
105
- Accept: 'application/json, text/plain, */*',
106
- 'Content-Type': 'application/json',
107
- Authorization: 'test-access-token',
108
- },
109
- body: JSON.stringify({})
110
- })
111
- expect(response).toStrictEqual(await fetchResponseMock.json())
112
- })
113
-
114
- it('should return promise error on send call with if 200 status', async function () {
115
- fetchResponseMock = {
116
- status: 'not_200_OK',
117
- json: async () => ({ error: '' })
118
- }
119
- try {
120
- const response = await instance.send('me', 'POST', {})
121
- // Test should be broken
122
- console.error('Client.send not threw error')
123
- expect(true).toBe(false)
124
- } catch (failureResponse) {
125
- expect(failureResponse).toStrictEqual(await fetchResponseMock.json())
126
- }
127
- })
128
-
129
- it('should return promise error on send call if has json error', async function () {
130
- fetchResponseMock = {
131
- status: 200,
132
- json: async () => ({ error: 'I have an error' })
133
- }
134
- try {
135
- const response = await instance.send('me', 'POST', {})
136
- // Test should be broken
137
- console.error('Client.send not threw error')
138
- expect(true).toBe(false)
139
- } catch (failureResponse) {
140
- expect(failureResponse).toBeTruthy()
141
- expect(failureResponse).toStrictEqual(await fetchResponseMock.json())
142
- }
143
- })
144
-
145
- it('should return promise with results on send call with callback', async function () {
146
- const callback = jest.fn().mockReturnValue('results')
147
- const response = await instance.send('me', 'POST', {}, callback)
148
-
149
- expect(callback).toHaveBeenCalled()
150
- expect(callback).toHaveBeenCalledWith(null, await fetchResponseMock.json())
151
- expect(callback).lastReturnedWith('results')
152
- expect(response).toBe('results')
153
- })
154
-
155
- it('should return promise with failure results on send call with callback', async function () {
156
- const callback = jest.fn().mockReturnValue('results')
157
- fetchResponseMock = {
158
- status: 'not_200_OK',
159
- json: async () => ({ error: '' })
160
- }
161
- const response = await instance.send('me', 'POST', {}, callback)
162
-
163
-
164
- expect(callback).toHaveBeenCalled()
165
- expect(callback).toHaveBeenCalledWith(await fetchResponseMock.json(), null)
166
- expect(callback).lastReturnedWith('results')
167
- expect(response).toBe('results')
168
- })
169
-
170
- it('should return promise on broadcast call', async function () {
171
- const response = await instance.broadcast([])
172
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
173
- method: 'POST',
174
- headers: {
175
- Accept: 'application/json, text/plain, */*',
176
- 'Content-Type': 'application/json',
177
- Authorization: 'test-access-token',
178
- },
179
- body: JSON.stringify({ operations: [] })
180
- })
181
- expect(response).toBeTruthy()
182
- })
183
-
184
- it('should return promise on updateUserMetadata call', async function () {
185
- const response = await instance.updateUserMetadata({ username: '' })
186
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/me`,{
187
- method: 'PUT',
188
- headers: {
189
- Accept: 'application/json, text/plain, */*',
190
- 'Content-Type': 'application/json',
191
- Authorization: 'test-access-token',
192
- },
193
- body: JSON.stringify({ user_metadata: { username: '' } })
194
- })
195
- expect(response).toBeTruthy()
196
- })
197
-
198
- it('should send request and return client instance on revokeToken call', async function () {
199
- const response = await instance.revokeToken()
200
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/oauth2/token/revoke`,{
201
- method: 'POST',
202
- headers: {
203
- Accept: 'application/json, text/plain, */*',
204
- 'Content-Type': 'application/json',
205
- Authorization: 'test-access-token',
206
- },
207
- body: JSON.stringify({ token: 'test-access-token' })
208
- })
209
- expect(response).toBeInstanceOf(Client)
210
- })
211
-
212
- it('should send request and return promise on claimRewardBalance call', async function () {
213
- const response = await instance.claimRewardBalance('', '', '', '')
214
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
215
- method: 'POST',
216
- headers: {
217
- Accept: 'application/json, text/plain, */*',
218
- 'Content-Type': 'application/json',
219
- Authorization: 'test-access-token',
220
- },
221
- body: JSON.stringify({
222
- operations: [['claim_reward_balance', {
223
- account: '',
224
- reward_hive: '',
225
- reward_hbd: '',
226
- reward_vests: ''
227
- }]]
228
- })
229
- })
230
- expect(response).toBeTruthy()
231
- })
232
-
233
- it('should send request and return promise on custom json call', async function () {
234
- const response = await instance.customJson('', '', '', {})
235
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
236
- method: 'POST',
237
- headers: {
238
- Accept: 'application/json, text/plain, */*',
239
- 'Content-Type': 'application/json',
240
- Authorization: 'test-access-token',
241
- },
242
- body: JSON.stringify({
243
- operations: [['custom_json', {
244
- required_auths: '',
245
- required_posting_auths: '',
246
- id: '',
247
- json: {}
248
- }]]
249
- })
250
- })
251
- expect(response).toBeTruthy()
252
- })
253
-
254
- it('should send request and return promise on ignore call', async function () {
255
- const response = await instance.ignore('', '')
256
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
257
- method: 'POST',
258
- headers: {
259
- Accept: 'application/json, text/plain, */*',
260
- 'Content-Type': 'application/json',
261
- Authorization: 'test-access-token',
262
- },
263
- body: JSON.stringify({
264
- operations: [['custom_json', {
265
- required_auths: [],
266
- required_posting_auths: [''],
267
- id: 'follow',
268
- json: JSON.stringify(['follow', {
269
- follower: '',
270
- following: '',
271
- what: ['ignore']
272
- }])
273
- }]]
274
- })
275
- })
276
- expect(response).toBeTruthy()
277
- })
278
-
279
- it('should send request and return promise on unfollow call', async function () {
280
- const response = await instance.unfollow('', '')
281
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
282
- method: 'POST',
283
- headers: {
284
- Accept: 'application/json, text/plain, */*',
285
- 'Content-Type': 'application/json',
286
- Authorization: 'test-access-token',
287
- },
288
- body: JSON.stringify({
289
- operations: [['custom_json', {
290
- required_auths: [],
291
- required_posting_auths: [''],
292
- id: 'follow',
293
- json: JSON.stringify(['follow', {
294
- follower: '',
295
- following: '',
296
- what: []
297
- }])
298
- }]]
299
- })
300
- })
301
- expect(response).toBeTruthy()
302
- })
303
-
304
- it('should send request and return promise on follow call', async function () {
305
- const response = await instance.follow('', '')
306
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
307
- method: 'POST',
308
- headers: {
309
- Accept: 'application/json, text/plain, */*',
310
- 'Content-Type': 'application/json',
311
- Authorization: 'test-access-token',
312
- },
313
- body: JSON.stringify({
314
- operations: [['custom_json', {
315
- required_auths: [],
316
- required_posting_auths: [''],
317
- id: 'follow',
318
- json: JSON.stringify(['follow', {
319
- follower: '',
320
- following: '',
321
- what: ['blog']
322
- }])
323
- }]]
324
- })
325
- })
326
- expect(response).toBeTruthy()
327
- })
328
-
329
- it('should send request and return promise on reblog call', async function () {
330
- const response = await instance.reblog('', '', '')
331
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
332
- method: 'POST',
333
- headers: {
334
- Accept: 'application/json, text/plain, */*',
335
- 'Content-Type': 'application/json',
336
- Authorization: 'test-access-token',
337
- },
338
- body: JSON.stringify({
339
- operations: [['custom_json', {
340
- required_auths: [],
341
- required_posting_auths: [''],
342
- id: 'follow',
343
- json: JSON.stringify(['reblog', {
344
- account: '',
345
- author: '',
346
- permlink: ''
347
- }])
348
- }]]
349
- })
350
- })
351
- expect(response).toBeTruthy()
352
- })
353
-
354
- it('should send request and return promise on deleteComment call', async function () {
355
- const response = await instance.deleteComment('', '')
356
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
357
- method: 'POST',
358
- headers: {
359
- Accept: 'application/json, text/plain, */*',
360
- 'Content-Type': 'application/json',
361
- Authorization: 'test-access-token',
362
- },
363
- body: JSON.stringify({
364
- operations: [['delete_comment', {
365
- author: '',
366
- permlink: ''
367
- }]]
368
- })
369
- })
370
- expect(response).toBeTruthy()
371
- })
372
-
373
- it('should send request and return promise on comment call', async function () {
374
- let response = await instance.comment('', '', '', '', '', {}, {})
375
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
376
- method: 'POST',
377
- headers: {
378
- Accept: 'application/json, text/plain, */*',
379
- 'Content-Type': 'application/json',
380
- Authorization: 'test-access-token',
381
- },
382
- body: JSON.stringify({
383
- operations: [['comment', {
384
- parent_author: '',
385
- parent_permlink: '',
386
- author: '',
387
- permlink: '',
388
- title: '',
389
- body: {},
390
- json_metadata: JSON.stringify({})
391
- }]]
392
- })
393
- })
394
- expect(response).toBeTruthy()
395
-
396
- response = await instance.comment('', '', '', '', '', {}, 'meta')
397
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
398
- method: 'POST',
399
- headers: {
400
- Accept: 'application/json, text/plain, */*',
401
- 'Content-Type': 'application/json',
402
- Authorization: 'test-access-token',
403
- },
404
- body: JSON.stringify({
405
- operations: [['comment', {
406
- parent_author: '',
407
- parent_permlink: '',
408
- author: '',
409
- permlink: '',
410
- title: '',
411
- body: {},
412
- json_metadata: 'meta'
413
- }]]
414
- })
415
- })
416
- expect(response).toBeTruthy()
417
- })
418
-
419
- it('should send request and return promise on vote call', async function () {
420
- const response = await instance.vote('', '', '', 0)
421
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
422
- method: 'POST',
423
- headers: {
424
- Accept: 'application/json, text/plain, */*',
425
- 'Content-Type': 'application/json',
426
- Authorization: 'test-access-token',
427
- },
428
- body: JSON.stringify({
429
- operations: [['vote', {
430
- voter: '',
431
- author: '',
432
- permlink: '',
433
- weight: 0
434
- }]]
435
- })
436
- })
437
- expect(response).toBeTruthy()
438
- })
439
-
440
- it('should send request and return promise on me call', async function () {
441
- const response = await instance.me()
442
- expect(global.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/me`,{
443
- method: 'POST',
444
- headers: {
445
- Accept: 'application/json, text/plain, */*',
446
- 'Content-Type': 'application/json',
447
- Authorization: 'test-access-token',
448
- },
449
- body: JSON.stringify({})
450
- })
451
- expect(response).toBeTruthy()
452
- })
453
- })