insta-api-wrapper 1.0.0 → 1.1.4

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/lib/index.d.ts CHANGED
@@ -4,3 +4,6 @@ export declare function getCookie(username: string, password: string, withLoginD
4
4
  }>;
5
5
  export { InstaService } from './lib/client.service.js';
6
6
  export { LoginService } from './lib/login.service.js';
7
+ export type { LoginServiceConfig } from './lib/login.service.js';
8
+ export { BloksLoginService } from './lib/login.bloks.js';
9
+ export type { BloksLoginResult, BloksDeviceParams } from './lib/login.bloks.js';
package/lib/index.js CHANGED
@@ -4,3 +4,4 @@ export function getCookie(username, password, withLoginData = false) {
4
4
  }
5
5
  export { InstaService } from './lib/client.service.js';
6
6
  export { LoginService } from './lib/login.service.js';
7
+ export { BloksLoginService } from './lib/login.bloks.js';
@@ -45,6 +45,9 @@ export declare class InstaService {
45
45
  getUserDetails(username: string, headers?: {
46
46
  [key: string]: string;
47
47
  }): Promise<UserGraphQlV2>;
48
+ getUserInfoV1(userId: string, headers?: {
49
+ [key: string]: string;
50
+ }): Promise<any>;
48
51
  /**
49
52
  * fetch profile by username. including email, phone number and posts
50
53
  * @param {username} username
@@ -15,20 +15,13 @@ export class InstaService {
15
15
  this.cookie = cookie;
16
16
  this.buildHeaders = (options) => {
17
17
  const baseHeaders = {
18
- 'User-Agent': config.iPhone,
19
- 'authority': 'www.instagram.com',
18
+ 'User-Agent': 'Instagram 428.0.0.47.67 Android (34/14; 480dpi; 1344x2992; Google/google; Pixel 8 Pro; husky; husky; en_US; 961145276)',
20
19
  'content-type': 'application/x-www-form-urlencoded',
21
- 'origin': 'https://www.instagram.com',
22
- 'accept-language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
23
- 'sec-fetch-site': 'same-origin',
24
- 'sec-fetch-mode': 'cors',
25
- 'sec-fetch-dest': 'empty',
26
- 'x-ig-app-id': 936619743392459,
27
- 'x-ig-www-claim': 'hmac.AR3W0DThY2Mu5Fag4sW5u3RhaR3qhFD_5wvYbOJOD9qaPjIf',
28
- 'x-instagram-ajax': 1,
29
- 'x-requested-with': 'XMLHttpRequest',
20
+ 'accept-language': 'en-US',
21
+ 'x-ig-app-id': '567067343352427',
22
+ 'X-Bloks-Version-Id': '7189b949425f9bf80ea8bd880cf5a3080b292d9b1c4b38a18d112f7c4b71e7a8',
23
+ 'X-FB-HTTP-Engine': 'Liger',
30
24
  };
31
- // Merge mit options und zwinge alle Werte zu Strings
32
25
  const merged = { ...baseHeaders, ...options };
33
26
  Object.keys(merged).forEach(key => {
34
27
  merged[key] = String(merged[key]);
@@ -99,6 +92,10 @@ export class InstaService {
99
92
  const graphql = res?.data;
100
93
  return graphql.data?.user;
101
94
  }
95
+ async getUserInfoV1(userId, headers = {}) {
96
+ const res = await this.fetchAPI(config.instagram_api_v1, `/users/${userId}/info/`, { headers, method: 'GET', params: { is_prefetch: 'false', entry_point: 'self_profile', from_module: 'self_profile' } });
97
+ return res?.data?.user ?? {};
98
+ }
102
99
  /**
103
100
  * fetch profile by username. including email, phone number and posts
104
101
  * @param {username} username
@@ -0,0 +1,51 @@
1
+ export interface BloksLoginResult {
2
+ twoFactorRequired?: boolean;
3
+ authorization?: string;
4
+ userId?: string;
5
+ }
6
+ export interface BloksDeviceParams {
7
+ version?: string;
8
+ defaultCodeName?: string;
9
+ defaultManufacturer?: string;
10
+ defaultModel?: string;
11
+ defaultAndroidVersion?: string;
12
+ defaultAndroidRelease?: string;
13
+ defaultScreenDpi?: string;
14
+ defaultResolution?: string;
15
+ defaultAppVersionCode?: string;
16
+ bloksVersioningId?: string;
17
+ }
18
+ export declare class BloksLoginService {
19
+ private readonly uuid;
20
+ private readonly phoneId;
21
+ private readonly androidDeviceId;
22
+ private pubKey;
23
+ private pubKeyId;
24
+ private bloks2FAContext;
25
+ private bloks2FAScreenID;
26
+ private bloksVersionId;
27
+ private userAgent;
28
+ constructor(uuid: string, phoneId: string, androidDeviceId: string);
29
+ setDeviceParams(p: BloksDeviceParams): void;
30
+ login(username: string, password: string): Promise<BloksLoginResult>;
31
+ verify2FA(username: string, code: string): Promise<BloksLoginResult>;
32
+ private preLoginFlow;
33
+ private fetchPubKey;
34
+ private bloksRequest;
35
+ private callEntrypoint;
36
+ private callMethodPicker;
37
+ private callMethodPickerNavigation;
38
+ private callVerifyCode;
39
+ private callVerifyCodeTOTP;
40
+ private baseHeaders;
41
+ private signedBody;
42
+ private bkCtx;
43
+ private save2FACtx;
44
+ private load2FACtx;
45
+ private clear2FACtx;
46
+ private encryptPassword;
47
+ }
48
+ export declare function bloksExtract2FAContext(rawStr: string): string;
49
+ export declare function bloksExtractScreenID(rawStr: string): string;
50
+ export declare function bloksDetectAirwave(rawStr: string): boolean;
51
+ export declare function bloksExtractSession(rawStr: string): BloksLoginResult | null;
@@ -0,0 +1,365 @@
1
+ // Bloks CAA login client — direct Instagram Bloks protocol (Node.js / got).
2
+ //
3
+ // Port of instlytics/backend/pkg/instago/auth.go + auth_bloks2fa.go.
4
+ // Same logic as ionic-insta-api-wrapper/login.bloks.ts but uses `got` instead of Cordova HTTP.
5
+ import { v4 as uuidv4 } from 'uuid';
6
+ import forge from 'node-forge';
7
+ import got from 'got';
8
+ import { LocalStorage } from 'node-localstorage';
9
+ const localStorage = new LocalStorage('./scratch');
10
+ const DEFAULT_BLOKS_VERSION_ID = '7189b949425f9bf80ea8bd880cf5a3080b292d9b1c4b38a18d112f7c4b71e7a8';
11
+ const DEFAULT_ANDROID_UA = 'Instagram 428.0.0.47.67 Android (34/14; 480dpi; 1344x2992; Google/google; Pixel 8 Pro; husky; husky; en_US; 961145276)';
12
+ const APP_ID = '567067343352427';
13
+ const IG_API = 'https://i.instagram.com/api/v1';
14
+ const BLOKS_API = 'https://b.i.instagram.com/api/v1';
15
+ export class BloksLoginService {
16
+ constructor(uuid, phoneId, androidDeviceId) {
17
+ this.uuid = uuid;
18
+ this.phoneId = phoneId;
19
+ this.androidDeviceId = androidDeviceId;
20
+ this.pubKey = '';
21
+ this.pubKeyId = -1;
22
+ this.bloks2FAContext = '';
23
+ this.bloks2FAScreenID = '';
24
+ this.bloksVersionId = DEFAULT_BLOKS_VERSION_ID;
25
+ this.userAgent = DEFAULT_ANDROID_UA;
26
+ }
27
+ setDeviceParams(p) {
28
+ if (p.bloksVersioningId)
29
+ this.bloksVersionId = p.bloksVersioningId;
30
+ if (p.version) {
31
+ const res = p.defaultResolution || '1344x2992';
32
+ const mfr = p.defaultManufacturer || 'Google/google';
33
+ this.userAgent =
34
+ `Instagram ${p.version} Android ` +
35
+ `(${p.defaultAndroidVersion || '34'}/${p.defaultAndroidRelease || '14'}; ` +
36
+ `${p.defaultScreenDpi || '480dpi'}; ${res}; ${mfr}; ` +
37
+ `${p.defaultModel || 'Pixel 8 Pro'}; ${p.defaultCodeName || 'husky'}; ${p.defaultCodeName || 'husky'}; ` +
38
+ `en_US; ${p.defaultAppVersionCode || '961145276'})`;
39
+ }
40
+ }
41
+ // ─── Public API ────────────────────────────────────────────────────────────
42
+ async login(username, password) {
43
+ await this.preLoginFlow();
44
+ if (!this.pubKey || this.pubKeyId < 0)
45
+ await this.fetchPubKey();
46
+ const encPass = this.encryptPassword(password, this.pubKey, this.pubKeyId);
47
+ const params = {
48
+ client_input_params: {
49
+ contact_point: username, password: encPass,
50
+ device_id: this.androidDeviceId, family_device_id: this.phoneId, machine_id: uuidv4(),
51
+ },
52
+ server_params: {
53
+ waterfall_id: uuidv4(), login_entry_point: 'logged_out', two_step_login_type: 'one_step_login',
54
+ },
55
+ };
56
+ const resp = await this.bloksRequest('bloks/apps/com.bloks.www.bloks.caa.login.async.send_login_request/', params, 'IgApi: bloks/async_action/com.bloks.www.bloks.caa.login.async.send_login_request/');
57
+ const rawStr = JSON.stringify(resp);
58
+ const twoFACtx = bloksExtract2FAContext(rawStr);
59
+ if (twoFACtx) {
60
+ this.bloks2FAContext = twoFACtx;
61
+ this.bloks2FAScreenID = bloksExtractScreenID(rawStr);
62
+ this.save2FACtx(username);
63
+ return { twoFactorRequired: true };
64
+ }
65
+ const session = bloksExtractSession(rawStr);
66
+ if (!session)
67
+ throw new Error('ig: bloks login — no session in response');
68
+ this.clear2FACtx(username);
69
+ return session;
70
+ }
71
+ async verify2FA(username, code) {
72
+ if (!this.bloks2FAContext && !this.load2FACtx(username)) {
73
+ throw new Error('ig: no 2FA context — start login first');
74
+ }
75
+ try {
76
+ const r1 = await this.callVerifyCode(code);
77
+ const s1 = bloksExtractSession(JSON.stringify(r1));
78
+ if (s1) {
79
+ this.clear2FACtx(username);
80
+ return s1;
81
+ }
82
+ }
83
+ catch (_) { }
84
+ const epResult = await this.callEntrypoint();
85
+ if (epResult) {
86
+ const epStr = JSON.stringify(epResult);
87
+ const updCtx = bloksExtract2FAContext(epStr);
88
+ if (updCtx) {
89
+ this.bloks2FAContext = updCtx;
90
+ this.save2FACtx(username);
91
+ }
92
+ const updSID = bloksExtractScreenID(epStr);
93
+ if (updSID)
94
+ this.bloks2FAScreenID = updSID;
95
+ if (bloksDetectAirwave(epStr)) {
96
+ await this.callMethodPicker();
97
+ const navResult = await this.callMethodPickerNavigation();
98
+ if (navResult) {
99
+ const navStr = JSON.stringify(navResult);
100
+ const navCtx = bloksExtract2FAContext(navStr);
101
+ if (navCtx) {
102
+ this.bloks2FAContext = navCtx;
103
+ this.save2FACtx(username);
104
+ }
105
+ const navSID = bloksExtractScreenID(navStr);
106
+ if (navSID)
107
+ this.bloks2FAScreenID = navSID;
108
+ }
109
+ }
110
+ }
111
+ try {
112
+ const r3a = await this.callVerifyCodeTOTP(code);
113
+ const s3a = bloksExtractSession(JSON.stringify(r3a));
114
+ if (s3a) {
115
+ this.clear2FACtx(username);
116
+ return s3a;
117
+ }
118
+ }
119
+ catch (_) { }
120
+ const r3b = await this.callVerifyCode(code);
121
+ const s3b = bloksExtractSession(JSON.stringify(r3b));
122
+ if (!s3b)
123
+ throw new Error('ig: 2FA verify failed — no session in response');
124
+ this.clear2FACtx(username);
125
+ return s3b;
126
+ }
127
+ // ─── Pre-login & key fetch ─────────────────────────────────────────────────
128
+ async preLoginFlow() {
129
+ try {
130
+ await got.post(`${IG_API}/launcher/sync/`, {
131
+ headers: this.baseHeaders(),
132
+ body: new URLSearchParams(this.signedBody({ id: this.uuid, server_config_retrieval: '1' })).toString(),
133
+ });
134
+ }
135
+ catch (_) { }
136
+ }
137
+ async fetchPubKey() {
138
+ const resp = await got.post(`${IG_API}/launcher/sync/`, {
139
+ headers: this.baseHeaders(),
140
+ body: new URLSearchParams(this.signedBody({ id: this.uuid, server_config_retrieval: '1' })).toString(),
141
+ });
142
+ const k = resp.headers['ig-set-password-encryption-pub-key'] || '';
143
+ const i = resp.headers['ig-set-password-encryption-key-id'];
144
+ if (k && i) {
145
+ this.pubKey = k;
146
+ this.pubKeyId = parseInt(i, 10);
147
+ }
148
+ }
149
+ // ─── Bloks HTTP ────────────────────────────────────────────────────────────
150
+ async bloksRequest(endpoint, params, friendlyName) {
151
+ const body = this.signedBody({
152
+ params: JSON.stringify(params), _uuid: this.uuid,
153
+ bk_client_context: this.bkCtx(), bloks_versioning_id: this.bloksVersionId,
154
+ });
155
+ const headers = { ...this.baseHeaders(), 'X-FB-Friendly-Name': friendlyName };
156
+ try {
157
+ const resp = await got.post(`${BLOKS_API}/${endpoint}`, {
158
+ headers, body: new URLSearchParams(body).toString(), throwHttpErrors: false,
159
+ });
160
+ return JSON.parse(resp.body);
161
+ }
162
+ catch (err) {
163
+ try {
164
+ return JSON.parse(err.response?.body ?? '{}');
165
+ }
166
+ catch (_) {
167
+ return null;
168
+ }
169
+ }
170
+ }
171
+ // ─── 2FA sub-calls ─────────────────────────────────────────────────────────
172
+ callEntrypoint() {
173
+ const screenID = this.bloks2FAScreenID || 'qdnv2w:3';
174
+ return this.bloksRequest('bloks/apps/com.bloks.www.two_step_verification.entrypoint/', {
175
+ client_input_params: { device_id: this.androidDeviceId, is_whatsapp_installed: 0, machine_id: uuidv4() },
176
+ server_params: {
177
+ two_step_verification_context: this.bloks2FAContext, flow_source: 'two_factor_login',
178
+ device_id: this.androidDeviceId, family_device_id: this.phoneId, INTERNAL_INFRA_screen_id: screenID,
179
+ },
180
+ }, 'IgApi: bloks/async_action/com.bloks.www.two_step_verification.entrypoint/');
181
+ }
182
+ callMethodPicker() {
183
+ return this.bloksRequest('bloks/apps/com.bloks.www.two_step_verification.method_picker/', {
184
+ client_input_params: { device_id: this.androidDeviceId, is_whatsapp_installed: 0, machine_id: uuidv4() },
185
+ server_params: {
186
+ two_step_verification_context: this.bloks2FAContext, flow_source: 'two_factor_login',
187
+ device_id: this.androidDeviceId, family_device_id: this.phoneId, INTERNAL_INFRA_screen_id: this.bloks2FAScreenID,
188
+ },
189
+ }, 'IgApi: bloks/async_action/com.bloks.www.two_step_verification.method_picker/');
190
+ }
191
+ callMethodPickerNavigation() {
192
+ return this.bloksRequest('bloks/apps/com.bloks.www.two_step_verification.method_picker.navigation.async/', {
193
+ client_input_params: { selected_method: 'totp', cloud_trust_token: null, network_bssid: null },
194
+ server_params: {
195
+ two_step_verification_context: this.bloks2FAContext, flow_source: 'two_factor_login',
196
+ should_fallback_to_sms: false, device_id: this.androidDeviceId, family_device_id: this.phoneId,
197
+ INTERNAL_INFRA_screen_id: this.bloks2FAScreenID,
198
+ },
199
+ }, 'IgApi: bloks/async_action/com.bloks.www.two_step_verification.method_picker.navigation.async/');
200
+ }
201
+ callVerifyCode(code) {
202
+ return this.bloksRequest('bloks/apps/com.bloks.www.two_step_verification.verify_code.async/', {
203
+ client_input_params: {
204
+ code, device_id: this.androidDeviceId, family_device_id: this.phoneId, machine_id: uuidv4(),
205
+ should_trust_device: 0, cloud_trust_token: null, network_bssid: null,
206
+ auth_secure_device_id: '', block_store_machine_id: '',
207
+ },
208
+ server_params: {
209
+ two_step_verification_context: this.bloks2FAContext, flow_source: 'two_factor_login',
210
+ device_id: this.androidDeviceId, INTERNAL_INFRA_screen_id: this.bloks2FAScreenID,
211
+ },
212
+ }, 'IgApi: bloks/async_action/com.bloks.www.two_step_verification.verify_code.async/');
213
+ }
214
+ callVerifyCodeTOTP(code) {
215
+ return this.bloksRequest('bloks/apps/com.bloks.www.two_step_verification.verify_code.async/', {
216
+ client_input_params: {
217
+ code, machine_id: uuidv4(), device_id: this.androidDeviceId, cloud_trust_token: null,
218
+ block_store_machine_id: '', should_trust_device: false, family_device_id: this.phoneId,
219
+ auth_secure_device_id: '', network_bssid: null,
220
+ },
221
+ server_params: {
222
+ two_step_verification_context: this.bloks2FAContext, flow_source: 'two_factor_login',
223
+ challenge: 'totp', device_id: this.androidDeviceId, spectra_reg_login_data: null,
224
+ },
225
+ }, 'IgApi: bloks/async_action/com.bloks.www.two_step_verification.verify_code.async/');
226
+ }
227
+ // ─── Headers ───────────────────────────────────────────────────────────────
228
+ baseHeaders() {
229
+ return {
230
+ 'User-Agent': this.userAgent, 'X-Bloks-Version-Id': this.bloksVersionId,
231
+ 'X-Bloks-Is-Layout-RTL': 'false', 'X-Bloks-Is-Panorama-Enabled': 'true',
232
+ 'X-IG-App-ID': APP_ID, 'X-IG-Device-ID': this.uuid,
233
+ 'X-IG-Family-Device-ID': this.phoneId, 'X-IG-Android-ID': this.androidDeviceId,
234
+ 'X-IG-WWW-Claim': '0', 'X-IG-Connection-Type': 'WIFI', 'X-IG-Capabilities': '3brTv10=',
235
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
236
+ 'Accept-Language': 'en-US', 'X-FB-HTTP-Engine': 'Liger',
237
+ 'X-FB-Client-IP': 'True', 'X-FB-Server-Cluster': 'True',
238
+ };
239
+ }
240
+ signedBody(data) {
241
+ return { signed_body: `SIGNATURE.${JSON.stringify(data)}` };
242
+ }
243
+ bkCtx() {
244
+ return JSON.stringify({ bloks_version: this.bloksVersionId, styles_id: 'instagram' });
245
+ }
246
+ // ─── 2FA context storage ──────────────────────────────────────────────────
247
+ save2FACtx(username) {
248
+ try {
249
+ localStorage.setItem(`ig_2fa_${username}`, JSON.stringify({
250
+ ctx: this.bloks2FAContext, sid: this.bloks2FAScreenID, exp: Date.now() + 30 * 60 * 1000,
251
+ }));
252
+ }
253
+ catch (_) { }
254
+ }
255
+ load2FACtx(username) {
256
+ try {
257
+ const raw = localStorage.getItem(`ig_2fa_${username}`);
258
+ if (!raw)
259
+ return false;
260
+ const e = JSON.parse(raw);
261
+ if (Date.now() > e.exp) {
262
+ localStorage.removeItem(`ig_2fa_${username}`);
263
+ return false;
264
+ }
265
+ this.bloks2FAContext = e.ctx;
266
+ this.bloks2FAScreenID = e.sid;
267
+ return true;
268
+ }
269
+ catch (_) {
270
+ return false;
271
+ }
272
+ }
273
+ clear2FACtx(username) {
274
+ try {
275
+ localStorage.removeItem(`ig_2fa_${username}`);
276
+ }
277
+ catch (_) { }
278
+ }
279
+ // ─── Password encryption ──────────────────────────────────────────────────
280
+ encryptPassword(password, pubKeyBase64, pubKeyVersion) {
281
+ const timestamp = Math.floor(Date.now() / 1000).toString();
282
+ const pemText = forge.util.decode64(pubKeyBase64);
283
+ const publicKey = forge.pki.publicKeyFromPem(pemText);
284
+ const aesKey = forge.random.getBytesSync(32);
285
+ const encKey = publicKey.encrypt(aesKey, 'RSAES-PKCS1-V1_5');
286
+ const iv = forge.random.getBytesSync(12);
287
+ // @ts-ignore
288
+ const aad = forge.util.createBuffer(timestamp, 'raw');
289
+ const cipher = forge.cipher.createCipher('AES-GCM', aesKey);
290
+ // @ts-ignore
291
+ cipher.start({ iv, additionalData: aad, tagLength: 128 });
292
+ cipher.update(forge.util.createBuffer(password, 'utf8'));
293
+ cipher.finish();
294
+ const full = cipher.output.getBytes() + cipher.mode.tag.getBytes();
295
+ const ct = full.slice(0, full.length - 16);
296
+ const tag = full.slice(full.length - 16);
297
+ const lsb = String.fromCharCode(encKey.length & 0xff, (encKey.length >> 8) & 0xff);
298
+ const payload = String.fromCharCode(1) + String.fromCharCode(pubKeyVersion) + iv + lsb + encKey + tag + ct;
299
+ return `#PWD_INSTAGRAM:4:${timestamp}:${forge.util.encode64(payload)}`;
300
+ }
301
+ }
302
+ // ─── Parse helpers ───────────────────────────────────────────────────────────
303
+ export function bloksExtract2FAContext(rawStr) {
304
+ const marker = 'two_step_verification_context';
305
+ const idx = rawStr.indexOf(marker);
306
+ if (idx === -1)
307
+ return '';
308
+ const search = rawStr.slice(idx + marker.length);
309
+ for (let i = 0; i < search.length - 100; i++) {
310
+ if (search[i] !== '"')
311
+ continue;
312
+ const end = search.indexOf('"', i + 1);
313
+ if (end > i + 50) {
314
+ const val = search.slice(i + 1, end).replace(/\\$/, '');
315
+ if (val.startsWith('AW'))
316
+ return val;
317
+ }
318
+ }
319
+ return '';
320
+ }
321
+ export function bloksExtractScreenID(rawStr) {
322
+ const marker = 'INTERNAL_INFRA_screen_id';
323
+ const idx = rawStr.indexOf(marker);
324
+ if (idx === -1)
325
+ return '';
326
+ const search = rawStr.slice(idx + marker.length);
327
+ for (let i = 0; i < search.length - 20; i++) {
328
+ if (search[i] !== '"')
329
+ continue;
330
+ const end = search.indexOf('"', i + 1);
331
+ if (end > i + 2 && end < i + 30) {
332
+ const val = search.slice(i + 1, end).replace(/\\$/, '');
333
+ if (val.includes(':'))
334
+ return val;
335
+ }
336
+ }
337
+ return '';
338
+ }
339
+ export function bloksDetectAirwave(rawStr) {
340
+ return rawStr.includes('has_been_allowed') || rawStr.includes('approve_from_another_device') ||
341
+ rawStr.includes('AIRWAVE') || rawStr.includes('airwave');
342
+ }
343
+ export function bloksExtractSession(rawStr) {
344
+ const idx = rawStr.indexOf('IGT:2:');
345
+ if (idx === -1)
346
+ return null;
347
+ let end = rawStr.length;
348
+ for (let i = idx; i < rawStr.length; i++) {
349
+ if (rawStr[i] === '"' || rawStr[i] === '\\') {
350
+ end = i;
351
+ break;
352
+ }
353
+ }
354
+ const authorization = `Bearer ${rawStr.slice(idx, end)}`;
355
+ const uidMarker = '"ds_user_id":"';
356
+ const uidIdx = rawStr.indexOf(uidMarker);
357
+ let userId = '';
358
+ if (uidIdx !== -1) {
359
+ const uStart = uidIdx + uidMarker.length;
360
+ const uEnd = rawStr.indexOf('"', uStart);
361
+ if (uEnd > uStart)
362
+ userId = rawStr.slice(uStart, uEnd);
363
+ }
364
+ return { authorization, userId };
365
+ }
@@ -1,19 +1,24 @@
1
+ import { BloksDeviceParams } from './login.bloks.js';
2
+ export interface LoginServiceConfig {
3
+ /** Base URL of the backend. Used only for verify (follow/like on login). No trailing slash. */
4
+ backendUrl?: string;
5
+ /** Path to the verify endpoint. Defaults to /v2/insta/verify */
6
+ verifyPath?: string;
7
+ }
1
8
  export declare class LoginService {
2
- private pubKey;
3
- private pubKeyId;
9
+ private cfg;
4
10
  uuid: string;
5
11
  deviceId: string;
6
12
  private phoneId;
7
- constructor();
8
- private getOrCreate;
9
- private generateDeviceId;
10
- private sync;
11
- private sendRequestCordova;
12
- generateSignature(data: string | Record<string, any>, extra?: Record<string, string>): Record<string, string>;
13
- login2FA(pass: string, code: string, twoFactorIdentifier: string, username: string, reqHeaders?: {
13
+ private readonly backendUrl;
14
+ private readonly verifyPath;
15
+ private readonly bloksSvc;
16
+ constructor(cfg?: LoginServiceConfig);
17
+ setDeviceParams(p: BloksDeviceParams): void;
18
+ login(username: string, pass: string, reqHeaders?: {
14
19
  [key: string]: string;
15
20
  }): Promise<any>;
16
- login(username: string, pass: string, reqHeaders?: {
21
+ login2FA(pass: string, code: string, twoFactorIdentifier: string, username: string, reqHeaders?: {
17
22
  [key: string]: string;
18
23
  }): Promise<any>;
19
24
  verifyAccount(resHeaders?: {
@@ -21,6 +26,7 @@ export declare class LoginService {
21
26
  }, defaultHeaders?: {
22
27
  [key: string]: string;
23
28
  }): Promise<void>;
24
- private jazoest;
25
- private encryptInstagramPassword;
29
+ generateSignature(data: string | Record<string, any>, extra?: Record<string, string>): Record<string, string>;
30
+ private getOrCreate;
31
+ private generateDeviceId;
26
32
  }