-
-
Notifications
You must be signed in to change notification settings - Fork 9
lib.resources.network manager.NetworkManager
lib/resources/network-manager.NetworkManager
This class is responsible for keeping track of the shared network connection
- applyPCSResponse
- applyPhotosSetupResponse
- applySetupResponse
- applySigninResponse
- applyTrustResponse
- downloadData
- get
- iCloudRegionUrl
- post
- put
- resetHarTracker
- resetSession
- settleCCYLimiter
- settleQueue
- settleRateLimiter
- writeHarFile
• new NetworkManager(resources
)
Creates a new network manager Should not be called directly, but through the static setup function.
Name | Type | Description |
---|---|---|
resources |
iCPSAppOptions |
The global configuration resources - because Resources Singleton is not yet available, but required for setup |
lib/resources/network-manager.ts:208
• _axios: AxiosInstance
Local axios instance to handle network requests
lib/resources/network-manager.ts:175
• Optional
_harTracker: AxiosHarTracker
Axios HAR tracker to capture network requests
lib/resources/network-manager.ts:201
• _headerJar: HeaderJar
Collection of header values and cookies that are applied based on the request
lib/resources/network-manager.ts:196
• _rateLimiter: default
<default
, QueueAddOptions
>
Queue to enable metadata rate limiting. Applied to regular (non-streaming) requests
lib/resources/network-manager.ts:180
• _streamingAxios: AxiosInstance
A separate axios instance to handle stream based downloads of assets This allows us to bypass har files for those big files - additionally HarTracker is not handling the stream correctly
lib/resources/network-manager.ts:186
• _streamingCCYLimiter: default
<default
, QueueAddOptions
>
Queue to enable CCY rate limiting. Applied to streaming requests
lib/resources/network-manager.ts:191
• set
photosUrl(url
): void
Sets the photos URL including the default path to be the default base url going forward
Name | Type | Description |
---|---|---|
url |
string |
The url to set, including the protocol and port. |
void
lib/resources/network-manager.ts:382
• set
scnt(scnt
): void
Persists the scnt header required for the MFA flow and adds the relevant header to the header jar
Name | Type | Description |
---|---|---|
scnt |
string |
The scnt value to use |
void
lib/resources/network-manager.ts:345
• set
sessionId(sessionId
): void
Persists the X-Apple-Id-Session-Id header required for the MFA flow, stores it as sessionSecret and adds the relevant header to the header jar
Name | Type | Description |
---|---|---|
sessionId |
string |
The session id value to use |
void
lib/resources/network-manager.ts:354
• set
sessionToken(sessionToken
): void
Persist the session token as session secret, required for setup
Name | Type |
---|---|
sessionToken |
string |
void
lib/resources/network-manager.ts:363
▸ applyPCSResponse(pcsResponse
): void
Applies the acquired PCS cookies received from the PCS request to the header jar.
Name | Type | Description |
---|---|---|
pcsResponse |
PCSResponse |
The response received from the server |
void
lib/resources/network-manager.ts:433
▸ applyPhotosSetupResponse(photosSetupResponse
): void
Applies configurations from the response received after the photos setup request. This includes information about the available zones.
Name | Type | Description |
---|---|---|
photosSetupResponse |
PhotosSetupResponse |
The response received from the server |
void
lib/resources/network-manager.ts:441
▸ applySetupResponse(setupResponse
): boolean
Applies configurations from the response received after the setup request. This includes setting the photos URL and persisting the iCloud authentication cookies.
Name | Type | Description |
---|---|---|
setupResponse |
SetupResponse |
The response received from the server |
boolean
True if necessary PCS cookies were found, false otherwise
lib/resources/network-manager.ts:418
▸ applySigninResponse(signinResponse
): void
Applies configurations from the response received if the MFA code is required. This includes setting the AASP cookie, the scnt header and session token.
Name | Type |
---|---|
signinResponse |
SigninResponse |
void
lib/resources/network-manager.ts:391
▸ applyTrustResponse(trustResponse
): void
Applies configurations from the response received after the device was trusted. This includes setting the trust and session token.
Name | Type | Description |
---|---|---|
trustResponse |
TrustResponse |
The response received from the server |
void
lib/resources/network-manager.ts:408
▸ downloadData(url
, location
): Promise
<void
>
Downloads the provided url's content and writes it to the provided location Uses the CCY limiter to ensure that the network is not overwhelmed
Name | Type | Description |
---|---|---|
url |
string |
The url to download |
location |
string |
The location to write the file to (existing files will be overwritten) |
Promise
<void
>
A promise, that resolves once the download has been completed, or rejects if the download was not successful.
lib/resources/network-manager.ts:501
▸ get<T
, R
, D
>(url
, config?
): Promise
<R
>
Perform a GET request using the local axios instance and configuration Uses metadata rate limiting to ensure that the request is not sent too often
Name | Type |
---|---|
T |
any |
R |
AxiosResponse <T , any > |
D |
any |
Name | Type | Description |
---|---|---|
url |
string |
The url to request |
config? |
AxiosRequestConfig <D > |
Additional configuration |
Promise
<R
>
A promise, that resolves once the request has been completed, or rejects if the request was not successful.
lib/resources/network-manager.ts:478
▸ iCloudRegionUrl(region?
): "icloud.com.cn"
| "icloud.com"
Name | Type | Description |
---|---|---|
region |
Region |
The region to use, currently set region in resource manager is set as default |
"icloud.com.cn"
| "icloud.com"
'icloud.com.cn' if region is set to 'china', 'icloud.com' otherwise
lib/resources/network-manager.ts:372
▸ post<T
, R
, D
>(url
, data?
, config?
): Promise
<R
>
Perform a POST request using the local axios instance and configuration Uses metadata rate limiting to ensure that the request is not sent too often
Name | Type |
---|---|
T |
any |
R |
AxiosResponse <T , any > |
D |
any |
Name | Type | Description |
---|---|---|
url |
string |
The url to request |
data? |
D |
The data to send |
config? |
AxiosRequestConfig <D > |
Additional configuration |
Promise
<R
>
A promise, that resolves once the request has been completed, or rejects if the request was not successful.
lib/resources/network-manager.ts:467
▸ put<T
, R
, D
>(url
, data?
, config?
): Promise
<R
>
Perform a PUT request using the local axios instance and configuration Uses metadata rate limiting to ensure that the request is not sent too often
Name | Type |
---|---|
T |
any |
R |
AxiosResponse <T , any > |
D |
any |
Name | Type | Description |
---|---|---|
url |
string |
The url to request |
data? |
D |
The data to send |
config? |
AxiosRequestConfig <D > |
Additional configuration |
Promise
<R
>
A promise, that resolves once the request has been completed.
lib/resources/network-manager.ts:490
▸ resetHarTracker(tracker
): void
Resets the generated HAR file to make sure it does not grow too much while reusing the same instance Unfortunately the relevant members are private, so we have to cast it to any
Name | Type | Description |
---|---|---|
tracker |
AxiosHarTracker |
The AxiosHarTracker instance to reset |
void
lib/resources/network-manager.ts:260
▸ resetSession(): Promise
<void
>
This closes the current session, clears resources that are not persisted and writes the HAR file to disk, in case network capture is enabled
Promise
<void
>
lib/resources/network-manager.ts:240
▸ settleCCYLimiter(): Promise
<void
>
Settles the CCY limiter queue
Promise
<void
>
See
lib/resources/network-manager.ts:288
▸ settleQueue(queue
, clearQueuedJobs?
): Promise
<void
>
Makes sure that the queue is settled before continuing (no more pending or running jobs) Pending jobs will be cancelled and running jobs will be awaited
Name | Type | Default value | Description |
---|---|---|---|
queue |
default <default , QueueAddOptions > |
undefined |
The queue to settle |
clearQueuedJobs |
boolean |
true |
- |
Promise
<void
>
lib/resources/network-manager.ts:298
▸ settleRateLimiter(): Promise
<void
>
Settles the rate limiter queue
Promise
<void
>
See
lib/resources/network-manager.ts:279
▸ writeHarFile(): Promise
<boolean
>
Writes the HAR file to disk, if network capture was enabled
Promise
<boolean
>
- Returns a promise that resolves to false, if network capture was disabled or no entries were captured, true if a file was written
- app/error/codes/app
- app/error/codes/archive
- app/error/codes/icloud-auth
- app/error/codes/icloud-photos
- app/error/codes/icloud-query-parser
- app/error/codes/library
- app/error/codes/mfa
- app/error/codes/resources
- app/error/codes/sync
- app/error/codes/validator
- app/error/error
- app/error/error-codes
- app/event/cli
- app/event/error-handler
- app/event/log
- app/event/metrics-exporter
- app/factory
- app/icloud-app
- lib/archive-engine/archive-engine
- lib/icloud/icloud
- lib/icloud/icloud-photos/icloud-photos
- lib/icloud/icloud-photos/query-builder
- lib/icloud/icloud-photos/query-parser
- crypto
- lib/icloud/mfa/mfa-method
- lib/icloud/mfa/mfa-server
- lib/photos-library/constants
- lib/photos-library/model/album
- lib/photos-library/model/asset
- lib/photos-library/model/file-type
- lib/photos-library/model/photos-entity
- lib/photos-library/photos-library
- lib/resources/event-manager
- lib/resources/events-types
- lib/resources/main
- lib/resources/network-manager
- lib/resources/network-types
- lib/resources/resource-manager
- lib/resources/resource-types
- lib/resources/validator
- lib/sync-engine/helper
- lib/sync-engine/sync-engine
- main