igpapi — Instagram private API Simulator for Node.js (API reference) 4.14.0
    Preparing search index...

    Function createClientInternals

    • Builds the client state from the options: a new device from seed, or the restored snapshot, plus the native transport client.

      Invalid options throw what they always threw (a RangeError for the request timeout, the native client's own error for a proxy or protocol mode it rejects); a snapshot that cannot be restored throws SnapshotDecodeError.

      Restored snapshots keep their stored application, with two exceptions. A snapshot whose app version equals the current defaultApplication version keeps its device and session — the platform's settleRestoredDevice hook fills the device facts a snapshot of the same build may predate (settleAndroidDeviceFacts), so a restored device reports what a fresh one of that build does; its application becomes the presented build's when the snapshot carries another released version (a restore is an app update), and a same-version snapshot adopts any version-bound field it omits — the GraphQL doc-id table, GRAPHQL_OMIT_PRETTY, the Direct inbox directInboxMode, the launch wire launchWire (the feed/timeline block, the feeds' appnetsession pair, the shared launch requests, the inbox-tray form, the save-credentials placement and the dictionary fan-out), the media wires mediaLikeWire and mediaRepostWire, the launch constants shoppingExperiments and directSearchGenAiBotsLimit, the Bloks prism palette, the Bloks theme bloksThemeParams, its INTERNAL_INFRA_THEME spelling and the bk_client_context shape bloksClientContext, and the zero-rating table ZERO_HEADERS (so snapshots made between a version bump and this change still resolve the new ids, form shape, inbox mode, feed wire, media wires, launch constants, palette and Bloks theme). The zero-rating table (ZERO_HEADERS), the Bloks theme and its context shape are wire-presence facts and are settled both ways: a stored table, theme or shape is dropped when the presented profile lacks it, so a restored client never sends the zero-rating pair or the zero device ids the current app stopped sending, nor a theme or key order the presented build does not carry. Every other application keeps its literals. See withDefaultVersionBoundFields.

      The platform app layers and the tests build a process through it.

      Parameters

      Returns Promise<
          {
              application: MobileApplicationState;
              client: Client;
              cookieJar: CookieJarLike;
              device: MobileDeviceState;
              protocolDiagnostics: () => readonly Readonly<ProtocolDiagnostic>[];
              requestTimeoutMs: number;
              session: {
                  appStartPhase?: "cold";
                  appStartTimeMs?: number;
                  authorization?: string;
                  bandwidth?: {
                      bytes: number;
                      carried?: true;
                      ms: number;
                      stack?: {
                          downloadBwAvgBps: number;
                          downloadBweMeanBps: number;
                          downloadBwStddevBps: number;
                          rttAvgMs: number;
                          rttStddevMs: number;
                          uploadBwAvgBps: number;
                          uploadBwe: {
                              bps: number;
                              buckets: readonly {
                                  lower: number;
                                  mean: number;
                                  p25: number;
                                  p50: number;
                                  p75: number;
                                  samples: number;
                                  upper: (...) | (...);
                              }[];
                              sampleCount: number;
                          };
                          uploadBwStddevBps: number;
                      };
                  };
                  challenge?: { readonly [key: string]: unknown };
                  checkpoint?: { readonly [key: string]: unknown };
                  clientSessionIdLifetime: number;
                  directInboxCache?: {
                      threads: readonly {
                          is_group: boolean;
                          items: readonly {
                              client_context?: string;
                              item_id: string;
                              item_type: string;
                              text?: string;
                              timestamp: string | number;
                              user_id: string;
                          }[];
                          last_activity_at: string
                          | number;
                          muted: boolean;
                          thread_id: string;
                          thread_title: string;
                          thread_v2_id: string;
                          users: readonly {
                              fbid_v2?: string;
                              full_name: string;
                              pk: string;
                              username: string;
                          }[];
                      }[];
                  };
                  directInboxSeqId?: number;
                  directLoadedThreads?: readonly string[];
                  dsUserId?: string;
                  familyDeviceIdBound?: boolean;
                  fbidV2?: string;
                  igWWWClaim?: string;
                  lastCreationMode?: "post"
                  | "reel"
                  | "story";
                  metaAiConsent?: {
                      cacheTimeSeconds: number;
                      fetchedAtSeconds: number;
                      nuxType: string;
                      requiresNux: boolean;
                      text: string;
                      version: string;
                  };
                  metaSubsEntrypointSessions?: {
                      readonly [key: string]: {
                          expiresAtMs: number;
                          refreshAtMs: number;
                          sessionId: string;
                      };
                  };
                  msgrRegion?: string;
                  noteCtasFetchedAtMs?: number;
                  passwordEncryptionKeyId?: string;
                  passwordEncryptionPubKey?: string;
                  pigeonSessionIdLifetime: number;
                  popularKeywordsRefreshedAtMs?: number;
                  profileInfoFetches?: {
                      readonly [key: string]: {
                          atMs: number;
                          userFbid?: string;
                          username: string;
                      };
                  };
                  quickPromotionCooldown?: {
                      defaultMs: number;
                      slots: { readonly [key: string]: number };
                  };
                  quickPromotionImpressions?: {
                      readonly [key: string]: {
                          lastSurface: string;
                          surfaces: { readonly [key: string]: number };
                      };
                  };
                  regionHint?: string;
                  rmdEvaluationStarted?: boolean;
                  rur?: string;
                  sessionStartPhase?: "starting";
                  shbid?: string;
                  shbts?: string;
                  thumbnailCacheBustingValue: number;
                  xMetaUsdid?: string;
                  xMid?: string;
                  zeroInterface?: boolean;
                  zeroPhase?: "logged-out"
                  | "authenticated"
                  | "rmd-evaluated";
              };
              startedWithSession: boolean;
          },
      >