rettiwt-api 2.4.2 → 2.5.1

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 (134) hide show
  1. package/.eslintrc.js +5 -0
  2. package/.github/workflows/documentation.yml +1 -1
  3. package/.github/workflows/publish.yml +1 -1
  4. package/.prettierrc +1 -1
  5. package/README.md +69 -19
  6. package/dist/Rettiwt.d.ts +7 -4
  7. package/dist/Rettiwt.js +4 -2
  8. package/dist/Rettiwt.js.map +1 -1
  9. package/dist/cli.js +4 -2
  10. package/dist/cli.js.map +1 -1
  11. package/dist/commands/Auth.d.ts +2 -1
  12. package/dist/commands/Auth.js +10 -17
  13. package/dist/commands/Auth.js.map +1 -1
  14. package/dist/commands/Tweet.js +36 -3
  15. package/dist/commands/Tweet.js.map +1 -1
  16. package/dist/enums/{ApiErrors.js → Api.js} +1 -1
  17. package/dist/enums/Api.js.map +1 -0
  18. package/dist/enums/Http.d.ts +68 -0
  19. package/dist/enums/Http.js +73 -0
  20. package/dist/enums/Http.js.map +1 -0
  21. package/dist/enums/Logging.d.ts +1 -0
  22. package/dist/enums/Logging.js +1 -0
  23. package/dist/enums/Logging.js.map +1 -1
  24. package/dist/index.d.ts +15 -14
  25. package/dist/index.js +22 -17
  26. package/dist/index.js.map +1 -1
  27. package/dist/models/args/TweetArgs.d.ts +44 -0
  28. package/dist/models/args/TweetArgs.js +82 -0
  29. package/dist/models/args/TweetArgs.js.map +1 -0
  30. package/dist/models/{public → data}/CursoredData.d.ts +5 -3
  31. package/dist/models/{public → data}/CursoredData.js +1 -0
  32. package/dist/models/data/CursoredData.js.map +1 -0
  33. package/dist/{types/public → models/data}/List.d.ts +8 -1
  34. package/dist/models/data/List.js.map +1 -0
  35. package/dist/models/data/Media.d.ts +14 -0
  36. package/dist/models/data/Media.js +19 -0
  37. package/dist/models/data/Media.js.map +1 -0
  38. package/dist/{types/public → models/data}/Tweet.d.ts +26 -8
  39. package/dist/models/{public → data}/Tweet.js +4 -0
  40. package/dist/models/data/Tweet.js.map +1 -0
  41. package/dist/{types/public → models/data}/User.d.ts +8 -1
  42. package/dist/models/data/User.js.map +1 -0
  43. package/dist/models/errors/ApiError.d.ts +17 -0
  44. package/dist/models/errors/ApiError.js +42 -0
  45. package/dist/models/errors/ApiError.js.map +1 -0
  46. package/dist/models/errors/HttpError.d.ts +17 -0
  47. package/dist/models/errors/HttpError.js +42 -0
  48. package/dist/models/errors/HttpError.js.map +1 -0
  49. package/dist/models/errors/RettiwtError.d.ts +8 -0
  50. package/dist/models/errors/RettiwtError.js +34 -0
  51. package/dist/models/errors/RettiwtError.js.map +1 -0
  52. package/dist/models/errors/TimeoutError.d.ts +14 -0
  53. package/dist/models/errors/TimeoutError.js +39 -0
  54. package/dist/models/errors/TimeoutError.js.map +1 -0
  55. package/dist/services/internal/ErrorService.d.ts +85 -0
  56. package/dist/services/internal/ErrorService.js +144 -0
  57. package/dist/services/internal/ErrorService.js.map +1 -0
  58. package/dist/services/internal/FetcherService.d.ts +22 -24
  59. package/dist/services/internal/FetcherService.js +79 -59
  60. package/dist/services/internal/FetcherService.js.map +1 -1
  61. package/dist/services/public/AuthService.d.ts +66 -0
  62. package/dist/services/public/AuthService.js +160 -0
  63. package/dist/services/public/AuthService.js.map +1 -0
  64. package/dist/services/public/TweetService.d.ts +27 -8
  65. package/dist/services/public/TweetService.js +45 -8
  66. package/dist/services/public/TweetService.js.map +1 -1
  67. package/dist/services/public/UserService.d.ts +5 -5
  68. package/dist/services/public/UserService.js.map +1 -1
  69. package/dist/types/ErrorHandler.d.ts +13 -0
  70. package/dist/types/{public/User.js → ErrorHandler.js} +1 -1
  71. package/dist/types/ErrorHandler.js.map +1 -0
  72. package/dist/types/RettiwtConfig.d.ts +32 -0
  73. package/dist/types/RettiwtConfig.js.map +1 -0
  74. package/package.json +6 -5
  75. package/src/Rettiwt.ts +10 -5
  76. package/src/cli.ts +4 -2
  77. package/src/commands/Auth.ts +5 -16
  78. package/src/commands/Tweet.ts +56 -3
  79. package/src/enums/Http.ts +68 -0
  80. package/src/enums/Logging.ts +1 -0
  81. package/src/index.ts +25 -18
  82. package/src/models/args/TweetArgs.ts +98 -0
  83. package/src/models/{public → data}/CursoredData.ts +6 -5
  84. package/src/models/{public → data}/List.ts +14 -4
  85. package/src/models/data/Media.ts +19 -0
  86. package/src/models/{public → data}/Tweet.ts +39 -5
  87. package/src/models/{public → data}/User.ts +28 -4
  88. package/src/models/errors/ApiError.ts +24 -0
  89. package/src/models/errors/HttpError.ts +24 -0
  90. package/src/models/errors/RettiwtError.ts +12 -0
  91. package/src/models/errors/TimeoutError.ts +18 -0
  92. package/src/services/internal/ErrorService.ts +158 -0
  93. package/src/services/internal/FetcherService.ts +94 -80
  94. package/src/services/public/AuthService.ts +97 -0
  95. package/src/services/public/TweetService.ts +48 -10
  96. package/src/services/public/UserService.ts +7 -5
  97. package/src/types/ErrorHandler.ts +13 -0
  98. package/src/types/RettiwtConfig.ts +40 -0
  99. package/dist/enums/ApiErrors.js.map +0 -1
  100. package/dist/enums/HTTP.d.ts +0 -17
  101. package/dist/enums/HTTP.js +0 -22
  102. package/dist/enums/HTTP.js.map +0 -1
  103. package/dist/models/internal/RettiwtConfig.d.ts +0 -18
  104. package/dist/models/internal/RettiwtConfig.js +0 -24
  105. package/dist/models/internal/RettiwtConfig.js.map +0 -1
  106. package/dist/models/public/CursoredData.js.map +0 -1
  107. package/dist/models/public/List.d.ts +0 -22
  108. package/dist/models/public/List.js.map +0 -1
  109. package/dist/models/public/Tweet.d.ts +0 -62
  110. package/dist/models/public/Tweet.js.map +0 -1
  111. package/dist/models/public/User.d.ts +0 -29
  112. package/dist/models/public/User.js.map +0 -1
  113. package/dist/types/internal/RettiwtConfig.d.ts +0 -15
  114. package/dist/types/internal/RettiwtConfig.js.map +0 -1
  115. package/dist/types/public/CursoredData.d.ts +0 -22
  116. package/dist/types/public/CursoredData.js +0 -3
  117. package/dist/types/public/CursoredData.js.map +0 -1
  118. package/dist/types/public/List.js +0 -3
  119. package/dist/types/public/List.js.map +0 -1
  120. package/dist/types/public/Tweet.js +0 -3
  121. package/dist/types/public/Tweet.js.map +0 -1
  122. package/dist/types/public/User.js.map +0 -1
  123. package/src/enums/HTTP.ts +0 -17
  124. package/src/models/internal/RettiwtConfig.ts +0 -26
  125. package/src/types/internal/RettiwtConfig.ts +0 -18
  126. package/src/types/public/CursoredData.ts +0 -24
  127. package/src/types/public/List.ts +0 -27
  128. package/src/types/public/Tweet.ts +0 -86
  129. package/src/types/public/User.ts +0 -48
  130. /package/dist/enums/{ApiErrors.d.ts → Api.d.ts} +0 -0
  131. /package/dist/models/{public → data}/List.js +0 -0
  132. /package/dist/models/{public → data}/User.js +0 -0
  133. /package/dist/types/{internal/RettiwtConfig.js → RettiwtConfig.js} +0 -0
  134. /package/src/enums/{ApiErrors.ts → Api.ts} +0 -0
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -47,16 +58,18 @@ var https_1 = __importDefault(require("https"));
47
58
  var rettiwt_auth_1 = require("rettiwt-auth");
48
59
  var https_proxy_agent_1 = require("https-proxy-agent");
49
60
  // SERVICES
61
+ var ErrorService_1 = require("./ErrorService");
50
62
  var LogService_1 = require("./LogService");
51
63
  // ENUMS
52
- var HTTP_1 = require("../../enums/HTTP");
53
- var ApiErrors_1 = require("../../enums/ApiErrors");
64
+ var Api_1 = require("../../enums/Api");
54
65
  var Logging_1 = require("../../enums/Logging");
55
- var CursoredData_1 = require("../../models/public/CursoredData");
56
- var Tweet_1 = require("../../models/public/Tweet");
57
- var User_1 = require("../../models/public/User");
66
+ // MODELS
67
+ var CursoredData_1 = require("../../models/data/CursoredData");
68
+ var Tweet_1 = require("../../models/data/Tweet");
69
+ var User_1 = require("../../models/data/User");
58
70
  // HELPERS
59
71
  var JsonUtils_1 = require("../../helper/JsonUtils");
72
+ var fs_1 = require("fs");
60
73
  /**
61
74
  * The base service that handles all HTTP requests.
62
75
  *
@@ -67,6 +80,7 @@ var FetcherService = /** @class */ (function () {
67
80
  * @param config - The config object for configuring the Rettiwt instance.
68
81
  */
69
82
  function FetcherService(config) {
83
+ var _a, _b, _c;
70
84
  // If API key is supplied
71
85
  if (config === null || config === void 0 ? void 0 : config.apiKey) {
72
86
  this.cred = this.getAuthCredential(config.apiKey);
@@ -80,8 +94,11 @@ var FetcherService = /** @class */ (function () {
80
94
  this.cred = undefined;
81
95
  }
82
96
  this.isAuthenticated = (config === null || config === void 0 ? void 0 : config.apiKey) ? true : false;
97
+ this.authProxyUrl = (_a = config === null || config === void 0 ? void 0 : config.authProxyUrl) !== null && _a !== void 0 ? _a : config === null || config === void 0 ? void 0 : config.proxyUrl;
83
98
  this.httpsAgent = this.getHttpsAgent(config === null || config === void 0 ? void 0 : config.proxyUrl);
99
+ this.timeout = (_b = config === null || config === void 0 ? void 0 : config.timeout) !== null && _b !== void 0 ? _b : 0;
84
100
  this.logger = new LogService_1.LogService(config === null || config === void 0 ? void 0 : config.logging);
101
+ this.errorHandler = (_c = config === null || config === void 0 ? void 0 : config.errorHandler) !== null && _c !== void 0 ? _c : new ErrorService_1.ErrorService();
85
102
  }
86
103
  /**
87
104
  * Returns an AuthCredential generated using the given API key.
@@ -101,8 +118,6 @@ var FetcherService = /** @class */ (function () {
101
118
  * @returns The generated AuthCredential.
102
119
  */
103
120
  FetcherService.prototype.getGuestCredential = function (guestKey) {
104
- // Converting guestKey from base64 to string
105
- guestKey = Buffer.from(guestKey).toString('ascii');
106
121
  return new rettiwt_auth_1.AuthCredential(undefined, guestKey);
107
122
  };
108
123
  /**
@@ -119,7 +134,7 @@ var FetcherService = /** @class */ (function () {
119
134
  resourceType != rettiwt_core_1.EResourceType.USER_DETAILS &&
120
135
  resourceType != rettiwt_core_1.EResourceType.USER_TWEETS &&
121
136
  this.isAuthenticated == false) {
122
- throw new Error(ApiErrors_1.EApiErrors.RESOURCE_NOT_ALLOWED);
137
+ throw new Error(Api_1.EApiErrors.RESOURCE_NOT_ALLOWED);
123
138
  }
124
139
  };
125
140
  /**
@@ -134,82 +149,46 @@ var FetcherService = /** @class */ (function () {
134
149
  }
135
150
  return new https_1.default.Agent();
136
151
  };
137
- /**
138
- * The middleware for handling any http error.
139
- *
140
- * @param res - The response object received.
141
- * @returns The received response, if no HTTP errors are found.
142
- * @throws An error if any HTTP-related error has occured.
143
- */
144
- FetcherService.prototype.handleHttpError = function (res) {
145
- /**
146
- * If the status code is not 200 =\> the HTTP request was not successful. hence throwing error
147
- */
148
- if (res.status != 200 && res.status in HTTP_1.EHttpStatus) {
149
- throw new Error(HTTP_1.EHttpStatus[res.status]);
150
- }
151
- return res;
152
- };
153
- /**
154
- * The middleware for handling any Twitter API-level errors.
155
- *
156
- * @param res - The response object received.
157
- * @returns The received response, if no API errors are found.
158
- * @throws An error if any API-related error has occured.
159
- */
160
- FetcherService.prototype.handleApiError = function (res) {
161
- // If error exists
162
- if (res.data.errors && res.data.errors.length) {
163
- // Getting the error code
164
- var code = res.data.errors[0].code;
165
- // Getting the error message
166
- var message = ApiErrors_1.EApiErrors[(0, JsonUtils_1.findKeyByValue)(rettiwt_core_1.EErrorCodes, "".concat(code))];
167
- // Throw the error
168
- throw new Error(message);
169
- }
170
- return res;
171
- };
172
152
  /**
173
153
  * Makes an HTTP request according to the given parameters.
174
154
  *
155
+ * @typeParam ResType - The type of the returned response data.
175
156
  * @param config - The request configuration.
176
157
  * @returns The response received.
177
158
  */
178
159
  FetcherService.prototype.request = function (config) {
179
160
  var _a;
180
161
  return __awaiter(this, void 0, void 0, function () {
181
- var _b, _c, axiosRequest;
162
+ var _b, _c;
182
163
  var _this = this;
183
164
  return __generator(this, function (_d) {
184
165
  switch (_d.label) {
185
166
  case 0:
186
167
  // Checking authorization for the requested resource
187
- this.checkAuthorization(config.endpoint);
168
+ this.checkAuthorization(config.url);
188
169
  // If not authenticated, use guest authentication
189
170
  _b = this;
190
171
  if (!((_a = this.cred) !== null && _a !== void 0)) return [3 /*break*/, 1];
191
172
  _c = _a;
192
173
  return [3 /*break*/, 3];
193
- case 1: return [4 /*yield*/, new rettiwt_auth_1.Auth().getGuestCredential()];
174
+ case 1: return [4 /*yield*/, new rettiwt_auth_1.Auth({ proxyUrl: this.authProxyUrl }).getGuestCredential()];
194
175
  case 2:
195
176
  _c = (_d.sent());
196
177
  _d.label = 3;
197
178
  case 3:
198
179
  // If not authenticated, use guest authentication
199
180
  _b.cred = _c;
200
- axiosRequest = {
201
- url: config.url,
202
- method: config.type,
203
- data: config.payload,
204
- headers: JSON.parse(JSON.stringify(this.cred.toHeader())),
205
- httpsAgent: this.httpsAgent,
206
- };
207
- return [4 /*yield*/, (0, axios_1.default)(axiosRequest)
208
- .then(function (res) { return _this.handleHttpError(res); })
209
- .then(function (res) { return _this.handleApiError(res); })];
181
+ // Setting additional request parameters
182
+ config.headers = __assign(__assign({}, config.headers), this.cred.toHeader());
183
+ config.httpAgent = this.httpsAgent;
184
+ config.timeout = this.timeout;
185
+ return [4 /*yield*/, (0, axios_1.default)(config).catch(function (error) {
186
+ _this.errorHandler.handle(error);
187
+ throw error;
188
+ })];
210
189
  case 4:
211
190
  /**
212
- * After making the request, the response is then passed to HTTP error handling middleware for HTTP error handling.
191
+ * If Axios request results in an error, catch it and rethrow a more specific error.
213
192
  */
214
193
  return [2 /*return*/, _d.sent()];
215
194
  }
@@ -301,7 +280,7 @@ var FetcherService = /** @class */ (function () {
301
280
  case 0:
302
281
  // Logging
303
282
  this.logger.log(Logging_1.ELogActions.FETCH, { resourceType: resourceType, args: args });
304
- request = new rettiwt_core_1.Request(resourceType, args);
283
+ request = new rettiwt_core_1.Request(resourceType, args).toAxiosRequestConfig();
305
284
  return [4 /*yield*/, this.request(request).then(function (res) { return res.data; })];
306
285
  case 1:
307
286
  res = _a.sent();
@@ -327,7 +306,7 @@ var FetcherService = /** @class */ (function () {
327
306
  case 0:
328
307
  // Logging
329
308
  this.logger.log(Logging_1.ELogActions.POST, { resourceType: resourceType, args: args });
330
- request = new rettiwt_core_1.Request(resourceType, args);
309
+ request = new rettiwt_core_1.Request(resourceType, args).toAxiosRequestConfig();
331
310
  // Posting the data
332
311
  return [4 /*yield*/, this.request(request)];
333
312
  case 1:
@@ -338,6 +317,47 @@ var FetcherService = /** @class */ (function () {
338
317
  });
339
318
  });
340
319
  };
320
+ /**
321
+ * Uploads the given media file to Twitter
322
+ *
323
+ * @param media - The path to the media file to upload.
324
+ * @returns The id of the uploaded media.
325
+ */
326
+ FetcherService.prototype.upload = function (media) {
327
+ return __awaiter(this, void 0, void 0, function () {
328
+ var id;
329
+ return __generator(this, function (_a) {
330
+ switch (_a.label) {
331
+ case 0:
332
+ // INITIALIZE
333
+ // Logging
334
+ this.logger.log(Logging_1.ELogActions.UPLOAD, { step: rettiwt_core_1.EUploadSteps.INITIALIZE });
335
+ return [4 /*yield*/, this.request(new rettiwt_core_1.Request(rettiwt_core_1.EResourceType.MEDIA_UPLOAD, {
336
+ upload: { step: rettiwt_core_1.EUploadSteps.INITIALIZE, size: (0, fs_1.statSync)(media).size },
337
+ }).toAxiosRequestConfig())];
338
+ case 1:
339
+ id = (_a.sent()).data.media_id_string;
340
+ // APPEND
341
+ // Logging
342
+ this.logger.log(Logging_1.ELogActions.UPLOAD, { step: rettiwt_core_1.EUploadSteps.APPEND });
343
+ return [4 /*yield*/, this.request(new rettiwt_core_1.Request(rettiwt_core_1.EResourceType.MEDIA_UPLOAD, {
344
+ upload: { step: rettiwt_core_1.EUploadSteps.APPEND, id: id, media: media },
345
+ }).toAxiosRequestConfig())];
346
+ case 2:
347
+ _a.sent();
348
+ // FINALIZE
349
+ // Logging
350
+ this.logger.log(Logging_1.ELogActions.UPLOAD, { step: rettiwt_core_1.EUploadSteps.APPEND });
351
+ return [4 /*yield*/, this.request(new rettiwt_core_1.Request(rettiwt_core_1.EResourceType.MEDIA_UPLOAD, {
352
+ upload: { step: rettiwt_core_1.EUploadSteps.FINALIZE, id: id },
353
+ }).toAxiosRequestConfig())];
354
+ case 3:
355
+ _a.sent();
356
+ return [2 /*return*/, id];
357
+ }
358
+ });
359
+ });
360
+ };
341
361
  return FetcherService;
342
362
  }());
343
363
  exports.FetcherService = FetcherService;
@@ -1 +1 @@
1
- {"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../../src/services/internal/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAWsB;AACtB,gDAAsF;AACtF,gDAAqC;AACrC,6CAAoD;AACpD,uDAAoD;AAEpD,WAAW;AACX,2CAA0C;AAE1C,QAAQ;AACR,yCAA+C;AAC/C,mDAAmD;AACnD,+CAAkD;AAIlD,iEAAgE;AAChE,mDAAkD;AAClD,iDAAgD;AAEhD,UAAU;AACV,oDAAsE;AAEtE;;;;GAIG;AACH;IAaC;;OAEG;IACH,wBAAmB,MAAsB;QACxC,yBAAyB;QACzB,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;YACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SAClD;QACD,2BAA2B;aACtB,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,EAAE;YAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SACrD;QACD,wBAAwB;aACnB;YACJ,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AmD;wBAGzD,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;wBAGpD,gBAAgB,GAAG,IAAI,CAAC,eAAe,CAAU,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;wBAEnG,sBAAO,gBAAgB,EAAC;;;;KACxB;IAED;;;;;;OAMG;IACa,6BAAI,GAApB,UAAqB,YAA2B,EAAE,IAAU;;;;;;wBAC3D,UAAU;wBACV,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAW,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;wBAGxE,OAAO,GAAY,IAAI,sBAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;wBAEzD,mBAAmB;wBACnB,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAA;;wBAD3B,mBAAmB;wBACnB,SAA2B,CAAC;wBAE5B,sBAAO,IAAI,EAAC;;;;KACZ;IACF,qBAAC;AAAD,CAAC,AArTD,IAqTC;AArTY,wCAAc"}
1
+ {"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../../src/services/internal/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAasB;AACtB,gDAAiE;AACjE,gDAAqC;AACrC,6CAAoD;AACpD,uDAAoD;AAEpD,WAAW;AACX,+CAA8C;AAC9C,2CAA0C;AAM1C,QAAQ;AACR,uCAA6C;AAC7C,+CAAkD;AAElD,SAAS;AACT,+DAA8D;AAC9D,iDAAgD;AAChD,+CAA8C;AAE9C,UAAU;AACV,oDAAsD;AACtD,yBAA8B;AAE9B;;;;GAIG;AACH;IAsBC;;OAEG;IACH,wBAAmB,MAAuB;;QACzC,yBAAyB;QACzB,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CA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,EAAE,KAAK,EAAE;6BAC3D,CAAC,CAAC,oBAAoB,EAAE,CACzB,EAAA;;wBAJD,SAIC,CAAC;wBAEF,WAAW;wBAEX,UAAU;wBACV,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAW,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,2BAAY,CAAC,MAAM,EAAE,CAAC,CAAC;wBAEnE,qBAAM,IAAI,CAAC,OAAO,CACjB,IAAI,sBAAO,CAAC,4BAAa,CAAC,YAAY,EAAE;gCACvC,MAAM,EAAE,EAAE,IAAI,EAAE,2BAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE;6BAC/C,CAAC,CAAC,oBAAoB,EAAE,CACzB,EAAA;;wBAJD,SAIC,CAAC;wBAEF,sBAAO,EAAE,EAAC;;;;KACV;IACF,qBAAC;AAAD,CAAC,AA7TD,IA6TC;AA7TY,wCAAc"}
@@ -0,0 +1,66 @@
1
+ import { FetcherService } from '../internal/FetcherService';
2
+ import { IRettiwtConfig } from '../../types/RettiwtConfig';
3
+ /**
4
+ * Handles authentication.
5
+ *
6
+ * @public
7
+ */
8
+ export declare class AuthService extends FetcherService {
9
+ /**
10
+ * @param config - The config object for configuring the Rettiwt instance.
11
+ *
12
+ * @internal
13
+ */
14
+ constructor(config?: IRettiwtConfig);
15
+ /**
16
+ * Login to twitter using account credentials.
17
+ *
18
+ * @param email - The email id associated with the Twitter account.
19
+ * @param userName - The username associated with the Twitter account.
20
+ * @param password - The password to the Twitter account.
21
+ * @returns The API_KEY for the Twitter account.
22
+ *
23
+ * @example
24
+ * ```
25
+ * import { Rettiwt } from 'rettiwt-api';
26
+ *
27
+ * // Creating a new Rettiwt instance
28
+ * const rettiwt = new Rettiwt();
29
+ *
30
+ * // Logging in an getting the API_KEY
31
+ * rettiwt.auth.login("email@domain.com", "username", "password")
32
+ * .then(apiKey => {
33
+ * // Use the API_KEY
34
+ * ...
35
+ * })
36
+ * .catch(err => {
37
+ * console.log(err);
38
+ * });
39
+ * ```
40
+ */
41
+ login(email: string, userName: string, password: string): Promise<string>;
42
+ /**
43
+ * Login to twitter as guest.
44
+ *
45
+ * @returns A new guest key.
46
+ *
47
+ * @example
48
+ * ```
49
+ * import { Rettiwt } from 'rettiwt-api';
50
+ *
51
+ * // Creating a new Rettiwt instance
52
+ * const rettiwt = new Rettiwt();
53
+ *
54
+ * // Logging in an getting a new guest key
55
+ * rettiwt.auth.guest()
56
+ * .then(guestKey => {
57
+ * // Use the guest key
58
+ * ...
59
+ * })
60
+ * .catch(err => {
61
+ * console.log(err);
62
+ * });
63
+ * ```
64
+ */
65
+ guest(): Promise<string>;
66
+ }
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.AuthService = void 0;
55
+ // PACKAGES
56
+ var rettiwt_auth_1 = require("rettiwt-auth");
57
+ // SERVICES
58
+ var FetcherService_1 = require("../internal/FetcherService");
59
+ /**
60
+ * Handles authentication.
61
+ *
62
+ * @public
63
+ */
64
+ var AuthService = /** @class */ (function (_super) {
65
+ __extends(AuthService, _super);
66
+ /**
67
+ * @param config - The config object for configuring the Rettiwt instance.
68
+ *
69
+ * @internal
70
+ */
71
+ function AuthService(config) {
72
+ return _super.call(this, config) || this;
73
+ }
74
+ /**
75
+ * Login to twitter using account credentials.
76
+ *
77
+ * @param email - The email id associated with the Twitter account.
78
+ * @param userName - The username associated with the Twitter account.
79
+ * @param password - The password to the Twitter account.
80
+ * @returns The API_KEY for the Twitter account.
81
+ *
82
+ * @example
83
+ * ```
84
+ * import { Rettiwt } from 'rettiwt-api';
85
+ *
86
+ * // Creating a new Rettiwt instance
87
+ * const rettiwt = new Rettiwt();
88
+ *
89
+ * // Logging in an getting the API_KEY
90
+ * rettiwt.auth.login("email@domain.com", "username", "password")
91
+ * .then(apiKey => {
92
+ * // Use the API_KEY
93
+ * ...
94
+ * })
95
+ * .catch(err => {
96
+ * console.log(err);
97
+ * });
98
+ * ```
99
+ */
100
+ AuthService.prototype.login = function (email, userName, password) {
101
+ var _a;
102
+ return __awaiter(this, void 0, void 0, function () {
103
+ var apiKey;
104
+ return __generator(this, function (_b) {
105
+ switch (_b.label) {
106
+ case 0: return [4 /*yield*/, new rettiwt_auth_1.Auth({ proxyUrl: this.authProxyUrl }).getUserCredential({
107
+ email: email,
108
+ userName: userName,
109
+ password: password,
110
+ })];
111
+ case 1:
112
+ apiKey = (_a = (_b.sent()).toHeader().cookie) !== null && _a !== void 0 ? _a : '';
113
+ // Converting the credentials to base64 string
114
+ apiKey = Buffer.from(apiKey).toString('base64');
115
+ return [2 /*return*/, apiKey];
116
+ }
117
+ });
118
+ });
119
+ };
120
+ /**
121
+ * Login to twitter as guest.
122
+ *
123
+ * @returns A new guest key.
124
+ *
125
+ * @example
126
+ * ```
127
+ * import { Rettiwt } from 'rettiwt-api';
128
+ *
129
+ * // Creating a new Rettiwt instance
130
+ * const rettiwt = new Rettiwt();
131
+ *
132
+ * // Logging in an getting a new guest key
133
+ * rettiwt.auth.guest()
134
+ * .then(guestKey => {
135
+ * // Use the guest key
136
+ * ...
137
+ * })
138
+ * .catch(err => {
139
+ * console.log(err);
140
+ * });
141
+ * ```
142
+ */
143
+ AuthService.prototype.guest = function () {
144
+ var _a;
145
+ return __awaiter(this, void 0, void 0, function () {
146
+ var guestKey;
147
+ return __generator(this, function (_b) {
148
+ switch (_b.label) {
149
+ case 0: return [4 /*yield*/, new rettiwt_auth_1.Auth().getGuestCredential()];
150
+ case 1:
151
+ guestKey = (_a = (_b.sent()).guestToken) !== null && _a !== void 0 ? _a : '';
152
+ return [2 /*return*/, guestKey];
153
+ }
154
+ });
155
+ });
156
+ };
157
+ return AuthService;
158
+ }(FetcherService_1.FetcherService));
159
+ exports.AuthService = AuthService;
160
+ //# sourceMappingURL=AuthService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthService.js","sourceRoot":"","sources":["../../../src/services/public/AuthService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAAoC;AAEpC,WAAW;AACX,6DAA4D;AAK5D;;;;GAIG;AACH;IAAiC,+BAAc;IAC9C;;;;OAIG;IACH,qBAAmB,MAAuB;eACzC,kBAAM,MAAM,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,2BAAK,GAAlB,UAAmB,KAAa,EAAE,QAAgB,EAAE,QAAgB;;;;;;4BAIjE,qBAAM,IAAI,mBAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,iBAAiB,CAAC;4BACjE,KAAK,EAAE,KAAK;4BACZ,QAAQ,EAAE,QAAQ;4BAClB,QAAQ,EAAE,QAAQ;yBAClB,CAAC,EAAA;;wBANA,MAAM,GACT,MAAC,CACA,SAIE,CACF,CAAC,QAAQ,EAAE,CAAC,MAAiB,mCAAI,EAAE;wBAErC,8CAA8C;wBAC9C,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;wBAEhD,sBAAO,MAAM,EAAC;;;;KACd;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACU,2BAAK,GAAlB;;;;;;4BAE2B,qBAAM,IAAI,mBAAI,EAAE,CAAC,kBAAkB,EAAE,EAAA;;wBAAzD,QAAQ,GAAW,MAAA,CAAC,SAAqC,CAAC,CAAC,UAAU,mCAAI,EAAE;wBAEjF,sBAAO,QAAQ,EAAC;;;;KAChB;IACF,kBAAC;AAAD,CAAC,AAlFD,CAAiC,+BAAc,GAkF9C;AAlFY,kCAAW"}
@@ -1,9 +1,10 @@
1
1
  import { TweetFilter } from 'rettiwt-core';
2
2
  import { FetcherService } from '../internal/FetcherService';
3
- import { RettiwtConfig } from '../../models/internal/RettiwtConfig';
4
- import { Tweet } from '../../models/public/Tweet';
5
- import { User } from '../../models/public/User';
6
- import { CursoredData } from '../../models/public/CursoredData';
3
+ import { IRettiwtConfig } from '../../types/RettiwtConfig';
4
+ import { Tweet } from '../../models/data/Tweet';
5
+ import { User } from '../../models/data/User';
6
+ import { CursoredData } from '../../models/data/CursoredData';
7
+ import { TweetMediaArgs } from '../../models/args/TweetArgs';
7
8
  /**
8
9
  * Handles fetching of data related to tweets.
9
10
  *
@@ -15,7 +16,7 @@ export declare class TweetService extends FetcherService {
15
16
  *
16
17
  * @internal
17
18
  */
18
- constructor(config?: RettiwtConfig);
19
+ constructor(config?: IRettiwtConfig);
19
20
  /**
20
21
  * Get the details of a tweet.
21
22
  *
@@ -159,10 +160,11 @@ export declare class TweetService extends FetcherService {
159
160
  /**
160
161
  * Post a tweet.
161
162
  *
162
- * @param tweetText - The text to be posted, length must be \<= 280 characters.
163
+ * @param text - The text to be posted, length must be \<= 280 characters.
164
+ * @param media - The list of media to post in the tweet, max number of media must be \<= 4.
163
165
  * @returns Whether posting was successful or not.
164
166
  *
165
- * @example
167
+ * @example Posting a simple text
166
168
  * ```
167
169
  * import { Rettiwt } from 'rettiwt-api';
168
170
  *
@@ -179,9 +181,26 @@ export declare class TweetService extends FetcherService {
179
181
  * });
180
182
  * ```
181
183
  *
184
+ * @example Posting a tweet with an image
185
+ * ```
186
+ * import { Rettiwt } from 'rettiwt-api';
187
+ *
188
+ * // Creating a new Rettiwt instance using the given 'API_KEY'
189
+ * const rettiwt = new Rettiwt({ apiKey: API_KEY });
190
+ *
191
+ * // Posting a tweet, containing an image called 'mountains.jpg', to twitter
192
+ * rettiwt.tweet.tweet('What a nice view!', [{ path: 'mountains.jpg' }])
193
+ * .then(res => {
194
+ * console.log(res);
195
+ * })
196
+ * .catch(err => {
197
+ * console.log(err);
198
+ * });
199
+ * ```
200
+ *
182
201
  * @public
183
202
  */
184
- tweet(tweetText: string): Promise<boolean>;
203
+ tweet(text: string, media?: TweetMediaArgs[]): Promise<boolean>;
185
204
  /**
186
205
  * Favorite the tweet with the given id.
187
206
  *
@@ -56,6 +56,7 @@ exports.TweetService = void 0;
56
56
  var rettiwt_core_1 = require("rettiwt-core");
57
57
  // SERVICES
58
58
  var FetcherService_1 = require("../internal/FetcherService");
59
+ var TweetArgs_1 = require("../../models/args/TweetArgs");
59
60
  /**
60
61
  * Handles fetching of data related to tweets.
61
62
  *
@@ -294,10 +295,11 @@ var TweetService = /** @class */ (function (_super) {
294
295
  /**
295
296
  * Post a tweet.
296
297
  *
297
- * @param tweetText - The text to be posted, length must be \<= 280 characters.
298
+ * @param text - The text to be posted, length must be \<= 280 characters.
299
+ * @param media - The list of media to post in the tweet, max number of media must be \<= 4.
298
300
  * @returns Whether posting was successful or not.
299
301
  *
300
- * @example
302
+ * @example Posting a simple text
301
303
  * ```
302
304
  * import { Rettiwt } from 'rettiwt-api';
303
305
  *
@@ -314,16 +316,51 @@ var TweetService = /** @class */ (function (_super) {
314
316
  * });
315
317
  * ```
316
318
  *
319
+ * @example Posting a tweet with an image
320
+ * ```
321
+ * import { Rettiwt } from 'rettiwt-api';
322
+ *
323
+ * // Creating a new Rettiwt instance using the given 'API_KEY'
324
+ * const rettiwt = new Rettiwt({ apiKey: API_KEY });
325
+ *
326
+ * // Posting a tweet, containing an image called 'mountains.jpg', to twitter
327
+ * rettiwt.tweet.tweet('What a nice view!', [{ path: 'mountains.jpg' }])
328
+ * .then(res => {
329
+ * console.log(res);
330
+ * })
331
+ * .catch(err => {
332
+ * console.log(err);
333
+ * });
334
+ * ```
335
+ *
317
336
  * @public
318
337
  */
319
- TweetService.prototype.tweet = function (tweetText) {
338
+ TweetService.prototype.tweet = function (text, media) {
320
339
  return __awaiter(this, void 0, void 0, function () {
321
- var data;
322
- return __generator(this, function (_a) {
323
- switch (_a.label) {
324
- case 0: return [4 /*yield*/, this.post(rettiwt_core_1.EResourceType.CREATE_TWEET, { tweetText: tweetText })];
340
+ var tweet, uploadedMedia, _i, _a, item, id, data;
341
+ return __generator(this, function (_b) {
342
+ switch (_b.label) {
343
+ case 0:
344
+ tweet = new TweetArgs_1.TweetArgs({ text: text, media: media });
345
+ uploadedMedia = [];
346
+ if (!tweet.media) return [3 /*break*/, 4];
347
+ _i = 0, _a = tweet.media;
348
+ _b.label = 1;
325
349
  case 1:
326
- data = _a.sent();
350
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
351
+ item = _a[_i];
352
+ return [4 /*yield*/, this.upload(item.path)];
353
+ case 2:
354
+ id = _b.sent();
355
+ // Storing the uploaded media item
356
+ uploadedMedia.push(new rettiwt_core_1.MediaArgs({ id: id, tags: item.tags }));
357
+ _b.label = 3;
358
+ case 3:
359
+ _i++;
360
+ return [3 /*break*/, 1];
361
+ case 4: return [4 /*yield*/, this.post(rettiwt_core_1.EResourceType.CREATE_TWEET, { tweet: { text: text, media: uploadedMedia } })];
362
+ case 5:
363
+ data = _b.sent();
327
364
  return [2 /*return*/, data];
328
365
  }
329
366
  });