rettiwt-api 1.0.4 → 1.0.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/README.md +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/queries/RootQuery.js +11 -0
- package/dist/queries/RootQuery.js.map +1 -1
- package/dist/resolvers/AccountResolver.d.ts +12 -0
- package/dist/resolvers/AccountResolver.js +84 -0
- package/dist/resolvers/AccountResolver.js.map +1 -0
- package/dist/server.js +3 -1
- package/dist/server.js.map +1 -1
- package/dist/services/AccountsService.d.ts +17 -0
- package/dist/services/AccountsService.js +171 -0
- package/dist/services/AccountsService.js.map +1 -0
- package/dist/services/FetcherService.d.ts +11 -2
- package/dist/services/FetcherService.js +47 -23
- package/dist/services/FetcherService.js.map +1 -1
- package/dist/services/accounting/AccountsService.d.ts +20 -0
- package/dist/services/accounting/AccountsService.js +147 -0
- package/dist/services/accounting/AccountsService.js.map +1 -0
- package/dist/services/accounting/Flows.d.ts +0 -0
- package/dist/services/accounting/Flows.js +2 -0
- package/dist/services/accounting/Flows.js.map +1 -0
- package/dist/services/accounting/LoginFlows.d.ts +20 -0
- package/dist/services/accounting/LoginFlows.js +70 -0
- package/dist/services/accounting/LoginFlows.js.map +1 -0
- package/dist/services/accounts/AccountService.d.ts +42 -0
- package/dist/services/accounts/AccountService.js +291 -0
- package/dist/services/accounts/AccountService.js.map +1 -0
- package/dist/services/accounts/LoginFlows.d.ts +77 -0
- package/dist/services/accounts/LoginFlows.js +92 -0
- package/dist/services/accounts/LoginFlows.js.map +1 -0
- package/dist/services/helper/Headers.d.ts +11 -1
- package/dist/services/helper/Headers.js +28 -2
- package/dist/services/helper/Headers.js.map +1 -1
- package/dist/services/helper/Urls.js +8 -8
- package/dist/services/helper/Urls.js.map +1 -1
- package/dist/types/HTTP.d.ts +0 -7
- package/dist/types/HTTP.js +1 -10
- package/dist/types/HTTP.js.map +1 -1
- package/dist/types/Service.d.ts +2 -0
- package/dist/types/Service.js.map +1 -1
- package/package.json +4 -2
- package/src/index.ts +3 -1
- package/src/queries/RootQuery.ts +11 -0
- package/src/resolvers/AccountResolver.ts +22 -0
- package/src/server.ts +3 -1
- package/src/services/FetcherService.ts +26 -8
- package/src/services/accounts/AccountService.ts +156 -0
- package/src/services/accounts/LoginFlows.ts +90 -0
- package/src/services/helper/Headers.ts +27 -1
- package/src/services/helper/Urls.ts +8 -8
- package/src/types/HTTP.ts +0 -8
- package/src/types/Service.ts +3 -1
package/README.md
CHANGED
|
@@ -36,8 +36,8 @@ This creates an instance of Rettiwt which can be used to fetch data from Twitter
|
|
|
36
36
|
|
|
37
37
|
If you wan't full functionality, you need to use the cookie of a logged in Twitter account, which can be retrieved from the browser.
|
|
38
38
|
|
|
39
|
-
- For GraphQL Server mode, pass the cookie-string in the header while making a request to the graphql server
|
|
40
|
-
- For npm library mode, pass the cookie-string to the constructor while creating instance of Rettiwt
|
|
39
|
+
- For GraphQL Server mode, you can get the cookie using the Login query and pass the received cookie-string in the header while making a request to the graphql server
|
|
40
|
+
- For npm library mode, you can get the cookie using the Rettiwt().account.login method and pass the received cookie-string to the constructor while creating instance of Rettiwt
|
|
41
41
|
|
|
42
42
|
### **If you don't want to risk your twitter account getting banned, using cookies is completely optional and you can omit passing cookie and use the API as guest**
|
|
43
43
|
### **No likes, followers, followings, retweets, replies, tweet likes, quotes can be fetched without using cookie!**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UserAccountService } from "./services/data/UserAccountService";
|
|
2
2
|
import { TweetService } from "./services/data/TweetService";
|
|
3
|
+
import { AccountService } from "./services/accounts/AccountService";
|
|
3
4
|
/**
|
|
4
5
|
* @param cookie The cookies string to use to fetch data
|
|
5
6
|
* @returns The API for fetching user and tweet data
|
|
@@ -7,4 +8,5 @@ import { TweetService } from "./services/data/TweetService";
|
|
|
7
8
|
export declare const Rettiwt: (cookie?: string) => {
|
|
8
9
|
users: UserAccountService;
|
|
9
10
|
tweets: TweetService;
|
|
11
|
+
account: AccountService;
|
|
10
12
|
};
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.Rettiwt = void 0;
|
|
|
5
5
|
var AuthService_1 = require("./services/AuthService");
|
|
6
6
|
var UserAccountService_1 = require("./services/data/UserAccountService");
|
|
7
7
|
var TweetService_1 = require("./services/data/TweetService");
|
|
8
|
+
var AccountService_1 = require("./services/accounts/AccountService");
|
|
8
9
|
/**
|
|
9
10
|
* @param cookie The cookies string to use to fetch data
|
|
10
11
|
* @returns The API for fetching user and tweet data
|
|
@@ -16,7 +17,8 @@ var Rettiwt = function (cookie) {
|
|
|
16
17
|
// Using the auth service instance to create data services instances
|
|
17
18
|
return {
|
|
18
19
|
users: new UserAccountService_1.UserAccountService(auth),
|
|
19
|
-
tweets: new TweetService_1.TweetService(auth)
|
|
20
|
+
tweets: new TweetService_1.TweetService(auth),
|
|
21
|
+
account: new AccountService_1.AccountService()
|
|
20
22
|
};
|
|
21
23
|
};
|
|
22
24
|
exports.Rettiwt = Rettiwt;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,WAAW;AACX,sDAAqD;AACrD,yEAAwE;AACxE,6DAA4D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,WAAW;AACX,sDAAqD;AACrD,yEAAwE;AACxE,6DAA4D;AAC5D,qEAAoE;AAEpE;;;GAGG;AACI,IAAM,OAAO,GAAG,UAAC,MAAmB;IAAnB,uBAAA,EAAA,WAAmB;IACvC,mEAAmE;IACnE,IAAM,IAAI,GAAgB,IAAI,yBAAW,CAAC,MAAM,CAAC,CAAC;IAElD,oEAAoE;IACpE,OAAO;QACH,KAAK,EAAE,IAAI,uCAAkB,CAAC,IAAI,CAAC;QACnC,MAAM,EAAE,IAAI,2BAAY,CAAC,IAAI,CAAC;QAC9B,OAAO,EAAE,IAAI,+BAAc,EAAE;KAChC,CAAC;AACN,CAAC,CAAA;AAVY,QAAA,OAAO,WAUnB"}
|
|
@@ -12,6 +12,7 @@ var TweetTypes_1 = require("../models/graphql/TweetTypes");
|
|
|
12
12
|
// RESOLVERS
|
|
13
13
|
var UserResolver_1 = __importDefault(require("../resolvers/UserResolver"));
|
|
14
14
|
var TweetResolver_1 = __importDefault(require("../resolvers/TweetResolver"));
|
|
15
|
+
var AccountResolver_1 = __importDefault(require("../resolvers/AccountResolver"));
|
|
15
16
|
exports.rootQuery = new graphql_1.GraphQLObjectType({
|
|
16
17
|
name: 'Root',
|
|
17
18
|
fields: {
|
|
@@ -53,6 +54,16 @@ exports.rootQuery = new graphql_1.GraphQLObjectType({
|
|
|
53
54
|
cursor: { type: graphql_1.GraphQLString, defaultValue: '' }
|
|
54
55
|
},
|
|
55
56
|
resolve: function (parent, args, context) { return new TweetResolver_1["default"](context).resolveTweets(args, args.count, args.cursor); }
|
|
57
|
+
},
|
|
58
|
+
Login: {
|
|
59
|
+
type: graphql_1.GraphQLString,
|
|
60
|
+
description: "Returns the cookies that can be used to fetch data from twitter",
|
|
61
|
+
args: {
|
|
62
|
+
email: { type: graphql_1.GraphQLString },
|
|
63
|
+
userName: { type: graphql_1.GraphQLString },
|
|
64
|
+
password: { type: graphql_1.GraphQLString }
|
|
65
|
+
},
|
|
66
|
+
resolve: function (parent, args, context) { return new AccountResolver_1["default"](context).resolveLogin(args.email, args.userName, args.password); }
|
|
56
67
|
}
|
|
57
68
|
}
|
|
58
69
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RootQuery.js","sourceRoot":"","sources":["../../src/queries/RootQuery.ts"],"names":[],"mappings":";;;;;;AAAA,UAAU;AACV,mCAAmG;AAEnG,QAAQ;AACR,yDAAmD;AACnD,2DAAgE;AAGhE,YAAY;AACZ,2EAAqD;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4BAAe,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAnF,CAAmF;SAC1H;KACJ;CACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ResolverBase from './ResolverBase';
|
|
2
|
+
import { DataContext } from '../types/Service';
|
|
3
|
+
export default class AccountResolver extends ResolverBase {
|
|
4
|
+
constructor(context: DataContext);
|
|
5
|
+
/**
|
|
6
|
+
* @param email The email of the account to be logged into
|
|
7
|
+
* @param userName The username associated with the account
|
|
8
|
+
* @param password The password to the account
|
|
9
|
+
* @returns The cookie string that can be used to authenticate against twitter
|
|
10
|
+
*/
|
|
11
|
+
resolveLogin(email: string, userName: string, password: string): Promise<string>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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 (_) 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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
+
};
|
|
56
|
+
exports.__esModule = true;
|
|
57
|
+
// RESOLVERS
|
|
58
|
+
var ResolverBase_1 = __importDefault(require("./ResolverBase"));
|
|
59
|
+
var AccountResolver = /** @class */ (function (_super) {
|
|
60
|
+
__extends(AccountResolver, _super);
|
|
61
|
+
// MEMBER METHODS
|
|
62
|
+
function AccountResolver(context) {
|
|
63
|
+
return _super.call(this, context) || this;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @param email The email of the account to be logged into
|
|
67
|
+
* @param userName The username associated with the account
|
|
68
|
+
* @param password The password to the account
|
|
69
|
+
* @returns The cookie string that can be used to authenticate against twitter
|
|
70
|
+
*/
|
|
71
|
+
AccountResolver.prototype.resolveLogin = function (email, userName, password) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0: return [4 /*yield*/, this.context.account.login(email, userName, password)];
|
|
76
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
return AccountResolver;
|
|
82
|
+
}(ResolverBase_1["default"]));
|
|
83
|
+
exports["default"] = AccountResolver;
|
|
84
|
+
//# sourceMappingURL=AccountResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountResolver.js","sourceRoot":"","sources":["../../src/resolvers/AccountResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAY;AACZ,gEAA0C;AAK1C;IAA6C,mCAAY;IACrD,iBAAiB;IACjB,yBAAY,OAAoB;eAC5B,kBAAM,OAAO,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACG,sCAAY,GAAlB,UAAmB,KAAa,EAAE,QAAgB,EAAE,QAAgB;;;;4BACzD,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAA;4BAAlE,sBAAO,SAA2D,EAAC;;;;KACtE;IACL,sBAAC;AAAD,CAAC,AAfD,CAA6C,yBAAY,GAexD"}
|
package/dist/server.js
CHANGED
|
@@ -46,6 +46,7 @@ var graphql_1 = require("graphql");
|
|
|
46
46
|
// Services
|
|
47
47
|
var UserAccountService_1 = require("./services/data/UserAccountService");
|
|
48
48
|
var TweetService_1 = require("./services/data/TweetService");
|
|
49
|
+
var AccountService_1 = require("./services/accounts/AccountService");
|
|
49
50
|
var AuthService_1 = require("./services/AuthService");
|
|
50
51
|
// SCHEMA
|
|
51
52
|
var RootQuery_1 = require("./queries/RootQuery");
|
|
@@ -60,7 +61,8 @@ app.use('/graphql', (0, express_graphql_1.graphqlHTTP)(function (req) { return (
|
|
|
60
61
|
}),
|
|
61
62
|
context: {
|
|
62
63
|
users: new UserAccountService_1.UserAccountService(new AuthService_1.AuthService(req.headers.cookie)),
|
|
63
|
-
tweets: new TweetService_1.TweetService(new AuthService_1.AuthService(req.headers.cookie))
|
|
64
|
+
tweets: new TweetService_1.TweetService(new AuthService_1.AuthService(req.headers.cookie)),
|
|
65
|
+
account: new AccountService_1.AccountService()
|
|
64
66
|
},
|
|
65
67
|
// If app is running in development environment, enable graphiql
|
|
66
68
|
graphiql: env_1.config.is_development
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,UAAU;AACV,oDAA8B;AAC9B,mDAA8C;AAC9C,mCAAwC;AAExC,WAAW;AACX,yEAAwE;AACxE,6DAA4D;AAC5D,sDAAqD;AAErD,SAAS;AACT,iDAAgD;AAEhD,UAAU;AACV,oCAAsC;AAEtC,gCAAgC;AAChC,IAAM,GAAG,GAAG,IAAA,oBAAO,GAAE,CAAC;AAEtB,8BAA8B;AAC9B,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,IAAA,6BAAW,EAAC,UAAA,GAAG,IAAI,OAAA,CAAC;IACpC,MAAM,EAAE,IAAI,uBAAa,CAAC;QACtB,KAAK,EAAE,qBAAS;KACnB,CAAC;IACF,OAAO,EAAE;QACL,KAAK,EAAE,IAAI,uCAAkB,CAAC,IAAI,yBAAW,CAAC,GAAG,CAAC,OAAO,CAAC,MAAgB,CAAC,CAAC;QAC5E,MAAM,EAAE,IAAI,2BAAY,CAAC,IAAI,yBAAW,CAAC,GAAG,CAAC,OAAO,CAAC,MAAgB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,UAAU;AACV,oDAA8B;AAC9B,mDAA8C;AAC9C,mCAAwC;AAExC,WAAW;AACX,yEAAwE;AACxE,6DAA4D;AAC5D,qEAAoE;AACpE,sDAAqD;AAErD,SAAS;AACT,iDAAgD;AAEhD,UAAU;AACV,oCAAsC;AAEtC,gCAAgC;AAChC,IAAM,GAAG,GAAG,IAAA,oBAAO,GAAE,CAAC;AAEtB,8BAA8B;AAC9B,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,IAAA,6BAAW,EAAC,UAAA,GAAG,IAAI,OAAA,CAAC;IACpC,MAAM,EAAE,IAAI,uBAAa,CAAC;QACtB,KAAK,EAAE,qBAAS;KACnB,CAAC;IACF,OAAO,EAAE;QACL,KAAK,EAAE,IAAI,uCAAkB,CAAC,IAAI,yBAAW,CAAC,GAAG,CAAC,OAAO,CAAC,MAAgB,CAAC,CAAC;QAC5E,MAAM,EAAE,IAAI,2BAAY,CAAC,IAAI,yBAAW,CAAC,GAAG,CAAC,OAAO,CAAC,MAAgB,CAAC,CAAC;QACvE,OAAO,EAAE,IAAI,+BAAc,EAAE;KAChC;IACD,gEAAgE;IAChE,QAAQ,EAAE,YAAM,CAAC,cAAc;CAClC,CAAC,EAXqC,CAWrC,CAAC,CAAC,CAAC;AAEL,4BAA4B;AAC5B,GAAG,CAAC,MAAM,CAAC,YAAM,CAAC,IAAI,EAAE;;QACpB,OAAO,CAAC,GAAG,CAAC,4BAAqB,YAAM,CAAC,IAAI,CAAE,CAAC,CAAC;;;KACnD,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class AccountsService {
|
|
2
|
+
private client;
|
|
3
|
+
private auth;
|
|
4
|
+
private guestCreds;
|
|
5
|
+
private headers;
|
|
6
|
+
private flowToken;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* @returns The axios client to use for login process
|
|
10
|
+
*/
|
|
11
|
+
private getClient;
|
|
12
|
+
/**
|
|
13
|
+
* @summary This method initiates the login process against twitter
|
|
14
|
+
* @returns The response received from twitter api
|
|
15
|
+
*/
|
|
16
|
+
initiateLogin(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.__esModule = true;
|
|
39
|
+
exports.AccountsService = void 0;
|
|
40
|
+
// PACKAGES
|
|
41
|
+
var axios_1 = require("axios");
|
|
42
|
+
// SERVICES
|
|
43
|
+
var AuthService_1 = require("./AuthService");
|
|
44
|
+
var AccountsService = /** @class */ (function () {
|
|
45
|
+
// MEMBER METHOD
|
|
46
|
+
function AccountsService() {
|
|
47
|
+
this.auth = new AuthService_1.AuthService();
|
|
48
|
+
this.guestCreds = { authToken: '', guestToken: '' };
|
|
49
|
+
this.headers = new axios_1.AxiosHeaders({
|
|
50
|
+
'sec-ch-ua': '"Not_A Brand";v="99", "Microsoft Edge";v="109", "Chromium";v="109"',
|
|
51
|
+
'x-twitter-client-language': 'en',
|
|
52
|
+
'sec-ch-ua-mobile': '?0',
|
|
53
|
+
'authorization': this.guestCreds.authToken,
|
|
54
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.78',
|
|
55
|
+
'content-type': 'application/json',
|
|
56
|
+
'x-guest-token': this.guestCreds.guestToken,
|
|
57
|
+
'x-twitter-active-user': 'yes',
|
|
58
|
+
'sec-ch-ua-platform': '"Windows"',
|
|
59
|
+
'Accept': '*/*',
|
|
60
|
+
'host': 'api.twitter.com',
|
|
61
|
+
'cookie': ''
|
|
62
|
+
});
|
|
63
|
+
this.flowToken = '';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @returns The axios client to use for login process
|
|
67
|
+
*/
|
|
68
|
+
AccountsService.prototype.getClient = function () {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var _a;
|
|
71
|
+
return __generator(this, function (_b) {
|
|
72
|
+
switch (_b.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
if (!!this.client) return [3 /*break*/, 2];
|
|
75
|
+
// Creating a new guest token
|
|
76
|
+
_a = this;
|
|
77
|
+
return [4 /*yield*/, this.auth.getGuestCredentials()];
|
|
78
|
+
case 1:
|
|
79
|
+
// Creating a new guest token
|
|
80
|
+
_a.guestCreds = _b.sent();
|
|
81
|
+
// Initialzing a new axios instance with the required config
|
|
82
|
+
this.client = new axios_1.Axios({
|
|
83
|
+
baseURL: 'https://api.twitter.com/1.1/onboarding/task.json',
|
|
84
|
+
headers: this.headers
|
|
85
|
+
});
|
|
86
|
+
_b.label = 2;
|
|
87
|
+
case 2: return [2 /*return*/, this.client];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* @summary This method initiates the login process against twitter
|
|
94
|
+
* @returns The response received from twitter api
|
|
95
|
+
*/
|
|
96
|
+
AccountsService.prototype.initiateLogin = function () {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
+
var _this = this;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0: return [4 /*yield*/, this.getClient()];
|
|
102
|
+
case 1: return [2 /*return*/, (_a.sent()).post('', JSON.stringify({
|
|
103
|
+
"input_flow_data": {
|
|
104
|
+
"flow_context": {
|
|
105
|
+
"debug_overrides": {},
|
|
106
|
+
"start_location": {
|
|
107
|
+
"location": "unknown"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"subtask_versions": {
|
|
112
|
+
"action_list": 2,
|
|
113
|
+
"alert_dialog": 1,
|
|
114
|
+
"app_download_cta": 1,
|
|
115
|
+
"check_logged_in_account": 1,
|
|
116
|
+
"choice_selection": 3,
|
|
117
|
+
"contacts_live_sync_permission_prompt": 0,
|
|
118
|
+
"cta": 7,
|
|
119
|
+
"email_verification": 2,
|
|
120
|
+
"end_flow": 1,
|
|
121
|
+
"enter_date": 1,
|
|
122
|
+
"enter_email": 2,
|
|
123
|
+
"enter_password": 5,
|
|
124
|
+
"enter_phone": 2,
|
|
125
|
+
"enter_recaptcha": 1,
|
|
126
|
+
"enter_text": 5,
|
|
127
|
+
"enter_username": 2,
|
|
128
|
+
"generic_urt": 3,
|
|
129
|
+
"in_app_notification": 1,
|
|
130
|
+
"interest_picker": 3,
|
|
131
|
+
"js_instrumentation": 1,
|
|
132
|
+
"menu_dialog": 1,
|
|
133
|
+
"notifications_permission_prompt": 2,
|
|
134
|
+
"open_account": 2,
|
|
135
|
+
"open_home_timeline": 1,
|
|
136
|
+
"open_link": 1,
|
|
137
|
+
"phone_verification": 4,
|
|
138
|
+
"privacy_options": 1,
|
|
139
|
+
"security_key": 3,
|
|
140
|
+
"select_avatar": 4,
|
|
141
|
+
"select_banner": 2,
|
|
142
|
+
"settings_list": 7,
|
|
143
|
+
"show_code": 1,
|
|
144
|
+
"sign_up": 2,
|
|
145
|
+
"sign_up_review": 4,
|
|
146
|
+
"tweet_selection_urt": 1,
|
|
147
|
+
"update_users": 1,
|
|
148
|
+
"upload_media": 1,
|
|
149
|
+
"user_recommendations_list": 4,
|
|
150
|
+
"user_recommendations_urt": 1,
|
|
151
|
+
"wait_spinner": 3,
|
|
152
|
+
"web_modal": 1
|
|
153
|
+
}
|
|
154
|
+
}), {
|
|
155
|
+
params: {
|
|
156
|
+
'flow_name': 'login'
|
|
157
|
+
}
|
|
158
|
+
}).then(function (res) {
|
|
159
|
+
// Setting the flow token
|
|
160
|
+
_this.flowToken = res.data.flow_token;
|
|
161
|
+
// Setting the cookies
|
|
162
|
+
_this.headers.set('cookie', _this.headers.get('cookie') + res.headers['set-cookie']);
|
|
163
|
+
})];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
return AccountsService;
|
|
169
|
+
}());
|
|
170
|
+
exports.AccountsService = AccountsService;
|
|
171
|
+
//# sourceMappingURL=AccountsService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountsService.js","sourceRoot":"","sources":["../../src/services/AccountsService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,+BAA2D;AAE3D,WAAW;AACX,6CAA4C;AAK5C;IAQI,gBAAgB;IAChB;QACI,IAAI,CAAC,IAAI,GAAG,IAAI,yBAAW,EAAE,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QACpD,IAAI,CAAC,OAAO,GAAG,IAAI,oBAAY,CAAC;YAC5B,WAAW,EAAE,oEAAoE;YACjF,2BAA2B,EAAE,IAAI;YACjC,kBAAkB,EAAE,IAAI;YACxB,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,SAAS;YAC1C,YAAY,EAAE,mIAAmI;YACjJ,cAAc,EAAE,kBAAkB;YAClC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU;YAC3C,uBAAuB,EAAE,KAAK;YAC9B,oBAAoB,EAAE,WAAW;YACjC,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,iBAAiB;YACzB,QAAQ,EAAE,EAAE;SACf,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACW,mCAAS,GAAvB;;;;;;6BAEQ,CAAC,IAAI,CAAC,MAAM,EAAZ,wBAAY;wBACZ,6BAA6B;wBAC7B,KAAA,IAAI,CAAA;wBAAc,qBAAM,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAA;;wBADvD,6BAA6B;wBAC7B,GAAK,UAAU,GAAG,SAAqC,CAAC;wBAExD,4DAA4D;wBAC5D,IAAI,CA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gCACjB,eAAe,EAAE,CAAC;gCAClB,eAAe,EAAE,CAAC;gCAClB,eAAe,EAAE,CAAC;gCAClB,WAAW,EAAE,CAAC;gCACd,SAAS,EAAE,CAAC;gCACZ,gBAAgB,EAAE,CAAC;gCACnB,qBAAqB,EAAE,CAAC;gCACxB,cAAc,EAAE,CAAC;gCACjB,cAAc,EAAE,CAAC;gCACjB,2BAA2B,EAAE,CAAC;gCAC9B,0BAA0B,EAAE,CAAC;gCAC7B,cAAc,EAAE,CAAC;gCACjB,WAAW,EAAE,CAAC;6BACjB;yBACJ,CAAC,EAAE;4BACA,MAAM,EAAE;gCACJ,WAAW,EAAE,OAAO;6BACvB;yBACJ,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG;4BACP,yBAAyB;4BACzB,KAAI,CAAC,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;4BAErC,sBAAsB;4BACtB,KAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAW,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;wBACjG,CAAC,CAAC,EAAC;;;;KACN;IACL,sBAAC;AAAD,CAAC,AArHD,IAqHC;AArHY,0CAAe"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { CurlyResult } from 'node-libcurl';
|
|
2
2
|
import { AuthService } from './AuthService';
|
|
3
|
+
/**
|
|
4
|
+
* @summary Stores all the different type of http requests
|
|
5
|
+
*/
|
|
6
|
+
export declare enum HttpMethods {
|
|
7
|
+
POST = "POST",
|
|
8
|
+
GET = "GET"
|
|
9
|
+
}
|
|
3
10
|
/**
|
|
4
11
|
* @service The base serivice from which all other data services derive their behaviour
|
|
5
12
|
*/
|
|
@@ -15,9 +22,11 @@ export declare class FetcherService {
|
|
|
15
22
|
/**
|
|
16
23
|
* @returns The absolute raw json data from give url
|
|
17
24
|
* @param url The url to fetch data from
|
|
18
|
-
* @param
|
|
25
|
+
* @param authenticate Whether to authenticate requests or not
|
|
26
|
+
* @param method The HTTP method to use
|
|
27
|
+
* @param data The data to be sent along with the request (works with only POST method)
|
|
19
28
|
*/
|
|
20
|
-
protected request<DataType>(url: string,
|
|
29
|
+
protected request<DataType>(url: string, authenticate?: boolean, method?: HttpMethods, data?: any): Promise<CurlyResult<DataType>>;
|
|
21
30
|
/**
|
|
22
31
|
* @summary Caches the extracted data
|
|
23
32
|
* @param data The extracted data to be cached
|
|
@@ -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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -59,7 +70,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
59
70
|
}
|
|
60
71
|
};
|
|
61
72
|
exports.__esModule = true;
|
|
62
|
-
exports.FetcherService = void 0;
|
|
73
|
+
exports.FetcherService = exports.HttpMethods = void 0;
|
|
63
74
|
// PACKAGES
|
|
64
75
|
var node_libcurl_1 = require("node-libcurl");
|
|
65
76
|
var CacheService_1 = require("./CacheService");
|
|
@@ -68,6 +79,15 @@ var HTTP_1 = require("../types/HTTP");
|
|
|
68
79
|
// HELPERS
|
|
69
80
|
var Headers = __importStar(require("./helper/Headers"));
|
|
70
81
|
var Deserializers = __importStar(require("./helper/Deserializers"));
|
|
82
|
+
/**
|
|
83
|
+
* @summary Stores all the different type of http requests
|
|
84
|
+
*/
|
|
85
|
+
var HttpMethods;
|
|
86
|
+
(function (HttpMethods) {
|
|
87
|
+
HttpMethods["POST"] = "POST";
|
|
88
|
+
HttpMethods["GET"] = "GET";
|
|
89
|
+
})(HttpMethods = exports.HttpMethods || (exports.HttpMethods = {}));
|
|
90
|
+
;
|
|
71
91
|
/**
|
|
72
92
|
* @service The base serivice from which all other data services derive their behaviour
|
|
73
93
|
*/
|
|
@@ -90,38 +110,42 @@ var FetcherService = /** @class */ (function () {
|
|
|
90
110
|
/**
|
|
91
111
|
* @returns The absolute raw json data from give url
|
|
92
112
|
* @param url The url to fetch data from
|
|
93
|
-
* @param
|
|
113
|
+
* @param authenticate Whether to authenticate requests or not
|
|
114
|
+
* @param method The HTTP method to use
|
|
115
|
+
* @param data The data to be sent along with the request (works with only POST method)
|
|
94
116
|
*/
|
|
95
|
-
FetcherService.prototype.request = function (url,
|
|
96
|
-
if (
|
|
117
|
+
FetcherService.prototype.request = function (url, authenticate, method, data) {
|
|
118
|
+
if (authenticate === void 0) { authenticate = true; }
|
|
119
|
+
if (method === void 0) { method = HttpMethods.GET; }
|
|
97
120
|
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
-
var
|
|
99
|
-
var
|
|
121
|
+
var config, _a, _b, _c, _d, _e;
|
|
122
|
+
var _f;
|
|
100
123
|
var _this = this;
|
|
101
|
-
return __generator(this, function (
|
|
102
|
-
switch (
|
|
124
|
+
return __generator(this, function (_g) {
|
|
125
|
+
switch (_g.label) {
|
|
103
126
|
case 0:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (!authenticated) return [3 /*break*/, 2];
|
|
108
|
-
_f = (_e = Headers).authorizedHeader;
|
|
127
|
+
_f = {};
|
|
128
|
+
if (!authenticate) return [3 /*break*/, 2];
|
|
129
|
+
_c = (_b = Headers).authorizedHeader;
|
|
109
130
|
return [4 /*yield*/, this.auth.getAuthCredentials()];
|
|
110
131
|
case 1:
|
|
111
|
-
|
|
132
|
+
_a = _c.apply(_b, [_g.sent()]);
|
|
112
133
|
return [3 /*break*/, 4];
|
|
113
134
|
case 2:
|
|
114
|
-
|
|
135
|
+
_e = (_d = Headers).guestHeader;
|
|
115
136
|
return [4 /*yield*/, this.auth.getGuestCredentials()];
|
|
116
137
|
case 3:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
case 4:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return [
|
|
138
|
+
_a = _e.apply(_d, [_g.sent()]);
|
|
139
|
+
_g.label = 4;
|
|
140
|
+
case 4:
|
|
141
|
+
config = (_f.httpHeader = _a,
|
|
142
|
+
_f.sslVerifyPeer = false,
|
|
143
|
+
_f);
|
|
144
|
+
if (!(method == HttpMethods.POST)) return [3 /*break*/, 6];
|
|
145
|
+
return [4 /*yield*/, node_libcurl_1.curly.post(url, __assign(__assign({}, config), { postFields: JSON.stringify(data) })).then(function (res) { return _this.handleHTTPError(res); })];
|
|
146
|
+
case 5: return [2 /*return*/, _g.sent()];
|
|
147
|
+
case 6: return [4 /*yield*/, node_libcurl_1.curly.get(url, config).then(function (res) { return _this.handleHTTPError(res); })];
|
|
148
|
+
case 7: return [2 /*return*/, _g.sent()];
|
|
125
149
|
}
|
|
126
150
|
});
|
|
127
151
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../src/services/FetcherService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../src/services/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAAkD;AAIlD,+CAA8C;AAE9C,QAAQ;AACR,sCAA2C;AAI3C,UAAU;AACV,wDAA2C;AAC3C,oEAAwD;AA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AA3ED,IA2EC;AA3EY,wCAAc"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AxiosResponseHeaders } from 'axios';
|
|
2
|
+
import { FetcherService } from '../FetcherService';
|
|
3
|
+
import { LoginCredentials } from '../../types/Authentication';
|
|
4
|
+
/**
|
|
5
|
+
* The service that handles all operations related to accounting
|
|
6
|
+
*/
|
|
7
|
+
export declare class AccountsService extends FetcherService {
|
|
8
|
+
/**
|
|
9
|
+
* @returns The response from Twitter after execution of the given flow
|
|
10
|
+
* @param flow The flow to be executed against Twitter API
|
|
11
|
+
* @param guestCredentials The guest credentials to use for making HTTP request
|
|
12
|
+
*/
|
|
13
|
+
private executeFlow;
|
|
14
|
+
/**
|
|
15
|
+
* @summary Logins into the given account and stores the cookies and store logged in credentials to database
|
|
16
|
+
* @returns The logged in account's cookies and other credentials
|
|
17
|
+
* @param cred The login credentials of the Twitter account to be logged into
|
|
18
|
+
*/
|
|
19
|
+
login(cred: LoginCredentials): Promise<AxiosResponseHeaders>;
|
|
20
|
+
}
|