javascript-ampache 1.0.9 → 1.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 (46) hide show
  1. package/README.md +50 -47
  2. package/dist/base.d.ts +5 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.m.js.map +1 -1
  5. package/dist/index.modern.mjs.map +1 -1
  6. package/dist/index.umd.js.map +1 -1
  7. package/package.json +38 -38
  8. package/src/albums/index.ts +86 -86
  9. package/src/albums/types.ts +38 -32
  10. package/src/artists/index.ts +88 -88
  11. package/src/artists/types.ts +38 -32
  12. package/src/auth/index.ts +103 -103
  13. package/src/auth/types.ts +25 -25
  14. package/src/base.ts +134 -119
  15. package/src/bookmarks/index.ts +115 -122
  16. package/src/bookmarks/types.ts +15 -9
  17. package/src/catalogs/index.ts +130 -119
  18. package/src/catalogs/types.ts +27 -15
  19. package/src/genres/index.ts +39 -40
  20. package/src/genres/types.ts +23 -17
  21. package/src/index.ts +63 -26
  22. package/src/labels/index.ts +43 -44
  23. package/src/labels/types.ts +20 -14
  24. package/src/licenses/index.ts +43 -44
  25. package/src/licenses/types.ts +14 -8
  26. package/src/live-streams/index.ts +104 -107
  27. package/src/live-streams/types.ts +16 -10
  28. package/src/playlists/index.ts +264 -269
  29. package/src/playlists/types.ts +20 -14
  30. package/src/podcasts/index.ts +174 -177
  31. package/src/podcasts/types.ts +85 -67
  32. package/src/preferences/index.ts +114 -116
  33. package/src/preferences/types.ts +18 -12
  34. package/src/shares/index.ts +100 -96
  35. package/src/shares/types.ts +25 -19
  36. package/src/shouts/index.ts +18 -22
  37. package/src/shouts/types.ts +9 -9
  38. package/src/songs/index.ts +208 -203
  39. package/src/songs/types.ts +77 -65
  40. package/src/system/index.ts +689 -572
  41. package/src/system/types.ts +33 -19
  42. package/src/users/index.ts +227 -245
  43. package/src/users/types.ts +38 -32
  44. package/src/utils.ts +25 -25
  45. package/src/videos/index.ts +49 -53
  46. package/src/videos/types.ts +42 -30
@@ -1,19 +1,33 @@
1
- import { Song } from "../songs/types";
2
- import { Album } from "../albums/types";
3
- import { Artist } from "../artists/types";
4
- import { Playlist } from "../playlists/types";
5
- import { Podcast, PodcastEpisode } from "../podcasts/types";
6
- import { LiveStream } from "../live-streams/types";
7
- import { Video } from "../videos/types";
8
- import { UID } from "../base";
9
-
10
- export type IndexType = Song | Album | Artist | Playlist | Podcast | PodcastEpisode | LiveStream;
11
-
12
- export type StatsType = Song | Album | Artist | Video | Playlist | Podcast | PodcastEpisode;
13
-
14
- export type IndexEntry = {
15
- id: UID,
16
- name: string,
17
- prefix: string,
18
- basename: string,
19
- }
1
+ import { SongResponse } from "../songs/types";
2
+ import { AlbumResponse } from "../albums/types";
3
+ import { ArtistResponse } from "../artists/types";
4
+ import { PlaylistResponse } from "../playlists/types";
5
+ import { PodcastResponse, PodcastEpisodeResponse } from "../podcasts/types";
6
+ import { LiveStreamResponse } from "../live-streams/types";
7
+ import { VideoResponse } from "../videos/types";
8
+ import { UID } from "../base";
9
+
10
+ export type IndexType =
11
+ | SongResponse
12
+ | AlbumResponse
13
+ | ArtistResponse
14
+ | PlaylistResponse
15
+ | PodcastResponse
16
+ | PodcastEpisodeResponse
17
+ | LiveStreamResponse;
18
+
19
+ export type StatsType =
20
+ | SongResponse
21
+ | AlbumResponse
22
+ | ArtistResponse
23
+ | VideoResponse
24
+ | PlaylistResponse
25
+ | PodcastResponse
26
+ | PodcastEpisodeResponse;
27
+
28
+ export type IndexEntry = {
29
+ id: UID;
30
+ name: string;
31
+ prefix: string;
32
+ basename: string;
33
+ };
@@ -1,245 +1,227 @@
1
- import qs from 'querystringify';
2
- import { User, UserSummary, Activity } from './types';
3
- import {Base, BinaryBoolean, ExtendedPagination, Success} from '../base';
4
-
5
- export class Users extends Base {
6
- /**
7
- * Get ids and usernames for your site
8
- * @remarks MINIMUM_API_VERSION=5.0.0
9
- * @see {@link https://ampache.org/api/api-json-methods#users}
10
- */
11
- async users() {
12
- let query = 'users';
13
- let data = await this.request<{user: UserSummary[]}>(query);
14
- return (data.user) ? data.user : data;
15
- }
16
-
17
- /**
18
- * This get a user's public information (or current user if username is omitted)
19
- * @remarks MINIMUM_API_VERSION=380001
20
- * @param [params.username] UID to find
21
- * @see {@link https://ampache.org/api/api-json-methods#user}
22
- */
23
- async user (params?: {
24
- username?: string
25
- }) {
26
- let query = 'user';
27
- query += qs.stringify(params, '&');
28
- return await this.request<User>(query);
29
- }
30
-
31
- /**
32
- * Create a new user
33
- * ACCESS REQUIRED: 100 (Admin)
34
- * @remarks MINIMUM_API_VERSION=400001
35
- * @param params.username Username
36
- * @param params.password SHA256 hashed password
37
- * @param params.email Email
38
- * @param [params.fullname] Full Name
39
- * @param [params.disable] 0, 1
40
- * @param [params.catalog_filter_group] Catalog filter group, default = 0
41
- * @see {@link https://ampache.org/api/api-json-methods#user_create}
42
- */
43
- userCreate (params: {
44
- username: string,
45
- password: string,
46
- email: string,
47
- fullname?: string,
48
- disable?: BinaryBoolean,
49
- catalog_filter_group?: number
50
- }) {
51
- let query = 'user_create';
52
- query += qs.stringify(params, '&');
53
- return this.request<Success>(query);
54
- }
55
-
56
- /**
57
- * Register as a new user if allowed.
58
- * @remarks MINIMUM_API_VERSION=6.0.0
59
- * @param params.username Username
60
- * @param params.password SHA256 hashed password
61
- * @param params.email Email
62
- * @param [params.fullname] Full Name
63
- * @see {@link https://ampache.org/api/api-json-methods/#register}
64
- */
65
- register (params: {
66
- username: string,
67
- password: string,
68
- email: string,
69
- fullname?: string
70
- }) {
71
- let query = 'register';
72
- query += qs.stringify(params, '&');
73
- return this.request<Success>(query);
74
- }
75
-
76
- /**
77
- * Update an existing user
78
- * ACCESS REQUIRED: 100 (Admin)
79
- * @remarks MINIMUM_API_VERSION=400001
80
- * @param params.username Username
81
- * @param [params.password] Password
82
- * @param [params.email] Email
83
- * @param [params.fullname] Full Name
84
- * @param [params.website] Website
85
- * @param [params.state] State
86
- * @param [params.city] City
87
- * @param [params.disable] 0, 1
88
- * @param [params.maxbitrate] Max bitrate for transcoding
89
- * @see {@link https://ampache.org/api/api-json-methods#user_update}
90
- * @deprecated Being removed in 7.0.0. Use `user_edit` instead.
91
- */
92
- userUpdate (params: {
93
- username: string,
94
- password?: string,
95
- email?: string,
96
- fullname?: string,
97
- website?: string,
98
- state?: string,
99
- city?: string,
100
- disable?: BinaryBoolean,
101
- maxbitrate?: string
102
- }) {
103
- let query = 'user_update';
104
- query += qs.stringify(params, '&');
105
- return this.request<Success>(query);
106
- }
107
-
108
- /**
109
- * Update an existing user
110
- * ACCESS REQUIRED: 100 (Admin)
111
- * @remarks MINIMUM_API_VERSION=6.0.0
112
- * @param params.username Username
113
- * @param [params.password] Password
114
- * @param [params.email] Email
115
- * @param [params.fullname] Full Name
116
- * @param [params.website] Website
117
- * @param [params.state] State
118
- * @param [params.city] City
119
- * @param [params.disable] 0, 1
120
- * @param [params.maxbitrate] Max bitrate for transcoding
121
- * @param [params.group] Catalog filter group, default = 0
122
- * @param [params.fullname_public] show fullname in public display
123
- * @param [params.reset_apikey] reset user Api Key
124
- * @param [params.reset_streamtoken] reset user Stream Token
125
- * @param [params.clear_stats] reset all stats for this user
126
- * @see {@link https://ampache.org/api/api-json-methods#user_edit}
127
- */
128
- userEdit (params: {
129
- username: string,
130
- password?: string,
131
- email?: string,
132
- fullname?: string,
133
- website?: string,
134
- state?: string,
135
- city?: string,
136
- maxbitrate?: string,
137
- group?: number,
138
- disable?: BinaryBoolean,
139
- fullname_public?: BinaryBoolean,
140
- reset_apikey?: BinaryBoolean,
141
- reset_streamtoken?: BinaryBoolean,
142
- clear_stats?: BinaryBoolean,
143
- }) {
144
- let query = 'user_edit';
145
- query += qs.stringify(params, '&');
146
- return this.request<Success>(query);
147
- }
148
-
149
- /**
150
- * Delete an existing user.
151
- * ACCESS REQUIRED: 100 (Admin)
152
- * @remarks MINIMUM_API_VERSION=400001
153
- * @param params.filter UID of user to delete
154
- * @see {@link https://ampache.org/api/api-json-methods#user_delete}
155
- */
156
- userDelete (params: {
157
- filter: string,
158
- }) {
159
- let query = 'user_delete';
160
- query += qs.stringify(params, '&');
161
- return this.request<Success>(query);
162
- }
163
-
164
- /**
165
- * This gets the followers for the requested username
166
- * @remarks MINIMUM_API_VERSION=380001
167
- * @param params.username UID to find
168
- * @param [params.offset]
169
- * @param [params.limit]
170
- * @param [params.cond]
171
- * @param [params.sort]
172
- * @see {@link https://ampache.org/api/api-json-methods#followers}
173
- */
174
- async followers (params: {
175
- username: string,
176
- } & ExtendedPagination ) {
177
- let query = 'followers';
178
- query += qs.stringify(params, '&');
179
- let data = await this.request<{user: UserSummary[]}>(query);
180
- return (data.user) ? data.user : data;
181
- }
182
-
183
- /**
184
- * Get a list of people that this user follows
185
- * @remarks MINIMUM_API_VERSION=380001
186
- * @see {@link https://ampache.org/api/api-json-methods#following}
187
- */
188
- async following (params: {
189
- username: string,
190
- }) {
191
- let query = 'following';
192
- query += qs.stringify(params, '&');
193
- let data = await this.request<{user: UserSummary[]}>(query);
194
- return (data.user) ? data.user : data;
195
- }
196
-
197
- /**
198
- * This will follow/unfollow a user
199
- * @param params.username Username string to find
200
- * @see {@link https://ampache.org/api/api-json-methods#toggle_follow}
201
- */
202
- toggleFollow(params: {
203
- username: string,
204
- }) {
205
- let query = 'toggle_follow';
206
- query += qs.stringify(params, '&');
207
- return this.request<Success>(query);
208
- }
209
-
210
- /**
211
- * This get a user timeline
212
- * @remarks MINIMUM_API_VERSION=380001
213
- * @param params.username Username to find
214
- * @param [params.limit] Max results to return
215
- * @param [params.since] UNIXTIME
216
- * @see {@link https://ampache.org/api/api-json-methods#timeline}
217
- */
218
- async timeline (params: {
219
- username: string,
220
- limit?: number,
221
- since?: number,
222
- }) {
223
- let query = 'timeline';
224
- query += qs.stringify(params, '&');
225
- let data = await this.request<{activity: Activity[]}>(query);
226
- return (data.activity) ? data.activity : data;
227
- }
228
-
229
- /**
230
- * This get current user friends timeline
231
- * @remarks MINIMUM_API_VERSION=380001
232
- * @param [params.limit] Max results to return
233
- * @param [params.since] UNIXTIME
234
- * @see {@link https://ampache.org/api/api-json-methods#friends_timeline}
235
- */
236
- async friendsTimeline (params?: {
237
- limit?: number,
238
- since?: number,
239
- }) {
240
- let query = 'friends_timeline';
241
- query += qs.stringify(params, '&');
242
- let data = await this.request<{activity: Activity[]}>(query);
243
- return (data.activity) ? data.activity : data;
244
- }
245
- }
1
+ import qs from "querystringify";
2
+ import { UserResponse, UserSummary, ActivityResponse } from "./types";
3
+ import { Base, BinaryBoolean, ExtendedPagination, Success } from "../base";
4
+
5
+ export class Users extends Base {
6
+ /**
7
+ * Get ids and usernames for your site
8
+ * @remarks MINIMUM_API_VERSION=5.0.0
9
+ * @see {@link https://ampache.org/api/api-json-methods#users}
10
+ */
11
+ users() {
12
+ let query = "users";
13
+ return this.request<{ user: UserSummary[] }>(query);
14
+ }
15
+
16
+ /**
17
+ * This get a user's public information (or current user if username is omitted)
18
+ * @remarks MINIMUM_API_VERSION=380001
19
+ * @param [params.username] UID to find
20
+ * @see {@link https://ampache.org/api/api-json-methods#user}
21
+ */
22
+ user(params?: { username?: string }) {
23
+ let query = "user";
24
+ query += qs.stringify(params, "&");
25
+ return this.request<UserResponse>(query);
26
+ }
27
+
28
+ /**
29
+ * Create a new user
30
+ * ACCESS REQUIRED: 100 (Admin)
31
+ * @remarks MINIMUM_API_VERSION=400001
32
+ * @param params.username Username
33
+ * @param params.password SHA256 hashed password
34
+ * @param params.email Email
35
+ * @param [params.fullname] Full Name
36
+ * @param [params.disable] 0, 1
37
+ * @param [params.catalog_filter_group] Catalog filter group, default = 0
38
+ * @see {@link https://ampache.org/api/api-json-methods#user_create}
39
+ */
40
+ userCreate(params: {
41
+ username: string;
42
+ password: string;
43
+ email: string;
44
+ fullname?: string;
45
+ disable?: BinaryBoolean;
46
+ catalog_filter_group?: number;
47
+ }) {
48
+ let query = "user_create";
49
+ query += qs.stringify(params, "&");
50
+ return this.request<Success>(query);
51
+ }
52
+
53
+ /**
54
+ * Register as a new user if allowed.
55
+ * @remarks MINIMUM_API_VERSION=6.0.0
56
+ * @param params.username Username
57
+ * @param params.password SHA256 hashed password
58
+ * @param params.email Email
59
+ * @param [params.fullname] Full Name
60
+ * @see {@link https://ampache.org/api/api-json-methods/#register}
61
+ */
62
+ register(params: {
63
+ username: string;
64
+ password: string;
65
+ email: string;
66
+ fullname?: string;
67
+ }) {
68
+ let query = "register";
69
+ query += qs.stringify(params, "&");
70
+ return this.request<Success>(query);
71
+ }
72
+
73
+ /**
74
+ * Update an existing user
75
+ * ACCESS REQUIRED: 100 (Admin)
76
+ * @remarks MINIMUM_API_VERSION=400001
77
+ * @param params.username Username
78
+ * @param [params.password] Password
79
+ * @param [params.email] Email
80
+ * @param [params.fullname] Full Name
81
+ * @param [params.website] Website
82
+ * @param [params.state] State
83
+ * @param [params.city] City
84
+ * @param [params.disable] 0, 1
85
+ * @param [params.maxbitrate] Max bitrate for transcoding
86
+ * @see {@link https://ampache.org/api/api-json-methods#user_update}
87
+ * @deprecated Being removed in 7.0.0. Use `user_edit` instead.
88
+ */
89
+ userUpdate(params: {
90
+ username: string;
91
+ password?: string;
92
+ email?: string;
93
+ fullname?: string;
94
+ website?: string;
95
+ state?: string;
96
+ city?: string;
97
+ disable?: BinaryBoolean;
98
+ maxbitrate?: string;
99
+ }) {
100
+ let query = "user_update";
101
+ query += qs.stringify(params, "&");
102
+ return this.request<Success>(query);
103
+ }
104
+
105
+ /**
106
+ * Update an existing user
107
+ * ACCESS REQUIRED: 100 (Admin)
108
+ * @remarks MINIMUM_API_VERSION=6.0.0
109
+ * @param params.username Username
110
+ * @param [params.password] Password
111
+ * @param [params.email] Email
112
+ * @param [params.fullname] Full Name
113
+ * @param [params.website] Website
114
+ * @param [params.state] State
115
+ * @param [params.city] City
116
+ * @param [params.disable] 0, 1
117
+ * @param [params.maxbitrate] Max bitrate for transcoding
118
+ * @param [params.group] Catalog filter group, default = 0
119
+ * @param [params.fullname_public] show fullname in public display
120
+ * @param [params.reset_apikey] reset user Api Key
121
+ * @param [params.reset_streamtoken] reset user Stream Token
122
+ * @param [params.clear_stats] reset all stats for this user
123
+ * @see {@link https://ampache.org/api/api-json-methods#user_edit}
124
+ */
125
+ userEdit(params: {
126
+ username: string;
127
+ password?: string;
128
+ email?: string;
129
+ fullname?: string;
130
+ website?: string;
131
+ state?: string;
132
+ city?: string;
133
+ maxbitrate?: string;
134
+ group?: number;
135
+ disable?: BinaryBoolean;
136
+ fullname_public?: BinaryBoolean;
137
+ reset_apikey?: BinaryBoolean;
138
+ reset_streamtoken?: BinaryBoolean;
139
+ clear_stats?: BinaryBoolean;
140
+ }) {
141
+ let query = "user_edit";
142
+ query += qs.stringify(params, "&");
143
+ return this.request<Success>(query);
144
+ }
145
+
146
+ /**
147
+ * Delete an existing user.
148
+ * ACCESS REQUIRED: 100 (Admin)
149
+ * @remarks MINIMUM_API_VERSION=400001
150
+ * @param params.filter UID of user to delete
151
+ * @see {@link https://ampache.org/api/api-json-methods#user_delete}
152
+ */
153
+ userDelete(params: { filter: string }) {
154
+ let query = "user_delete";
155
+ query += qs.stringify(params, "&");
156
+ return this.request<Success>(query);
157
+ }
158
+
159
+ /**
160
+ * This gets the followers for the requested username
161
+ * @remarks MINIMUM_API_VERSION=380001
162
+ * @param params.username UID to find
163
+ * @param [params.offset]
164
+ * @param [params.limit]
165
+ * @param [params.cond]
166
+ * @param [params.sort]
167
+ * @see {@link https://ampache.org/api/api-json-methods#followers}
168
+ */
169
+ followers(
170
+ params: {
171
+ username: string;
172
+ } & ExtendedPagination,
173
+ ) {
174
+ let query = "followers";
175
+ query += qs.stringify(params, "&");
176
+ return this.request<{ user: UserSummary[] }>(query);
177
+ }
178
+
179
+ /**
180
+ * Get a list of people that this user follows
181
+ * @remarks MINIMUM_API_VERSION=380001
182
+ * @see {@link https://ampache.org/api/api-json-methods#following}
183
+ */
184
+ following(params: { username: string }) {
185
+ let query = "following";
186
+ query += qs.stringify(params, "&");
187
+ return this.request<{ user: UserSummary[] }>(query);
188
+ }
189
+
190
+ /**
191
+ * This will follow/unfollow a user
192
+ * @param params.username Username string to find
193
+ * @see {@link https://ampache.org/api/api-json-methods#toggle_follow}
194
+ */
195
+ toggleFollow(params: { username: string }) {
196
+ let query = "toggle_follow";
197
+ query += qs.stringify(params, "&");
198
+ return this.request<Success>(query);
199
+ }
200
+
201
+ /**
202
+ * This get a user timeline
203
+ * @remarks MINIMUM_API_VERSION=380001
204
+ * @param params.username Username to find
205
+ * @param [params.limit] Max results to return
206
+ * @param [params.since] UNIXTIME
207
+ * @see {@link https://ampache.org/api/api-json-methods#timeline}
208
+ */
209
+ timeline(params: { username: string; limit?: number; since?: number }) {
210
+ let query = "timeline";
211
+ query += qs.stringify(params, "&");
212
+ return this.request<{ activity: ActivityResponse[] }>(query);
213
+ }
214
+
215
+ /**
216
+ * This get current user friends timeline
217
+ * @remarks MINIMUM_API_VERSION=380001
218
+ * @param [params.limit] Max results to return
219
+ * @param [params.since] UNIXTIME
220
+ * @see {@link https://ampache.org/api/api-json-methods#friends_timeline}
221
+ */
222
+ friendsTimeline(params?: { limit?: number; since?: number }) {
223
+ let query = "friends_timeline";
224
+ query += qs.stringify(params, "&");
225
+ return this.request<{ activity: ActivityResponse[] }>(query);
226
+ }
227
+ }
@@ -1,32 +1,38 @@
1
- import { UID } from "../base";
2
-
3
- export type UserSummary = {
4
- id: UID,
5
- username: string,
6
- }
7
-
8
- export type User = {
9
- id: UID,
10
- username: string,
11
- auth: string,
12
- email: string,
13
- access: number,
14
- streamtoken: string | null,
15
- fullname_public: number,
16
- validation: string | null,
17
- disabled: boolean,
18
- create_date: number,
19
- last_seen: number,
20
- website: string | null,
21
- state: string | null,
22
- city: string | null,
23
- }
24
-
25
- export type Activity = {
26
- id: UID,
27
- date: number,
28
- object_type: string,
29
- object_id: UID,
30
- action: string,
31
- user: UserSummary,
32
- }
1
+ import { UID } from "../base";
2
+
3
+ export type UserSummary = {
4
+ id: UID;
5
+ username: string;
6
+ };
7
+
8
+ export type UserResponse = {
9
+ id: UID;
10
+ username: string;
11
+ auth: string;
12
+ email: string;
13
+ access: number;
14
+ streamtoken: string | null;
15
+ fullname_public: number;
16
+ validation: string | null;
17
+ disabled: boolean;
18
+ create_date: number;
19
+ last_seen: number;
20
+ website: string | null;
21
+ state: string | null;
22
+ city: string | null;
23
+ };
24
+
25
+ export type UsersResponse = {
26
+ total_count: number;
27
+ md5: string;
28
+ user: UserResponse[];
29
+ };
30
+
31
+ export type ActivityResponse = {
32
+ id: UID;
33
+ date: number;
34
+ object_type: string;
35
+ object_id: UID;
36
+ action: string;
37
+ user: UserSummary;
38
+ };
package/src/utils.ts CHANGED
@@ -1,25 +1,25 @@
1
- import JsSHA from "jssha/dist/sha256";
2
-
3
- export function applyMixins(derivedCtor: any, baseCtors: any[]) {
4
- baseCtors.forEach(baseCtor => {
5
- Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
6
- Object.defineProperty(
7
- derivedCtor.prototype,
8
- name,
9
- Object.getOwnPropertyDescriptor(baseCtor.prototype, name)
10
- );
11
- });
12
- });
13
- }
14
-
15
- export function encryptPassword(password: string, time: number) {
16
- let key = getSHA256(password);
17
- return getSHA256(time + key);
18
-
19
- function getSHA256(text) {
20
- let shaObj = new JsSHA("SHA-256", "TEXT", { encoding: "UTF8" });
21
- shaObj.update(text);
22
-
23
- return shaObj.getHash("HEX");
24
- }
25
- }
1
+ import JsSHA from "jssha/dist/sha256";
2
+
3
+ export function applyMixins(derivedCtor: any, baseCtors: any[]) {
4
+ baseCtors.forEach((baseCtor) => {
5
+ Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
6
+ Object.defineProperty(
7
+ derivedCtor.prototype,
8
+ name,
9
+ Object.getOwnPropertyDescriptor(baseCtor.prototype, name),
10
+ );
11
+ });
12
+ });
13
+ }
14
+
15
+ export function encryptPassword(password: string, time: number) {
16
+ let key = getSHA256(password);
17
+ return getSHA256(time + key);
18
+
19
+ function getSHA256(text) {
20
+ let shaObj = new JsSHA("SHA-256", "TEXT", { encoding: "UTF8" });
21
+ shaObj.update(text);
22
+
23
+ return shaObj.getHash("HEX");
24
+ }
25
+ }