Skip to content

Commit

Permalink
squash me: Use new appstraction release and pin subtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
zner0L committed Jun 7, 2024
1 parent 614d334 commit c9596c6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Here's an example of what such a HAR might look like (the actual requests in the
"md5": "4f4cf346a050ea23da0da60328a4dd10"
}
],
"metaVersion": 1
"metaVersion": "1.0"
}
}
}
Expand Down
68 changes: 34 additions & 34 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ cyanoacrylate
- [App](README.md#app)
- [AppAnalysis](README.md#appanalysis)
- [AppAnalysisResult](README.md#appanalysisresult)
- [Device](README.md#device)
- [DeviceAttribute](README.md#deviceattribute)
- [DeviceV1](README.md#devicev1)
- [GetDeviceAttributeOptions](README.md#getdeviceattributeoptions)
- [IosPermission](README.md#iospermission)
- [MitmproxyCertificate](README.md#mitmproxycertificate)
Expand All @@ -28,7 +28,7 @@ cyanoacrylate
- [SupportedCapability](README.md#supportedcapability)
- [SupportedPlatform](README.md#supportedplatform)
- [SupportedRunTarget](README.md#supportedruntarget)
- [TrafficCollectionOptions](README.md#trafficcollectionoptions)
- [TrafficCollectionOptionsV1](README.md#trafficcollectionoptionsv1)
- [TweaselHar](README.md#tweaselhar)
- [TweaselHarMetaV1](README.md#tweaselharmetav1)

Expand Down Expand Up @@ -67,13 +67,13 @@ Functions that can be used to instrument the device and analyze apps.
| `platform` | [`PlatformApi`](README.md#platformapi)<`Platform`, `RunTarget`, `Capabilities`\> | A raw platform API object as returned by [appstraction](https://github.com/tweaselORG/appstraction). |
| `resetDevice` | () => `Promise`<`void`\> | Reset the specified device to the snapshot specified in `targetOptions.snapshotName`. |
| `startAppAnalysis` | (`appIdOrPath`: `string` \| `AppPath`<`Platform`\>, `options?`: { `noSigint?`: `boolean` ; `resetApp?`: `boolean` }) => `Promise`<[`AppAnalysis`](README.md#appanalysis)<`Platform`, `RunTarget`, `Capabilities`\>\> | Start an app analysis. The app analysis is controlled through the returned object. Remember to call `stop()` on the object when you are done with the app to clean up and retrieve the analysis data. |
| `startTrafficCollection` | (`options?`: `Platform` extends ``"android"`` ? [`TrafficCollectionOptions`](README.md#trafficcollectionoptions) : `never`) => `Promise`<`void`\> | Start collecting the device's traffic. On Android, this will start a WireGuard proxy on the host computer on port `51820`. It will automatically configure the target to use the WireGuard proxy and trust the mitmproxy TLS certificate. You can configure which apps to include using the `options` parameter. On iOS, this will start a mitmproxy HTTP(S) proxy on the host computer on port `8080`. It will automatically configure the target to use the proxy and trust the mitmproxy TLS certificate. You can not restrict the traffic collection to specific apps. Only one traffic collection can be active at a time. |
| `startTrafficCollection` | (`options?`: `Platform` extends ``"android"`` ? `TrafficCollectionOptions` : `never`) => `Promise`<`void`\> | Start collecting the device's traffic. On Android, this will start a WireGuard proxy on the host computer on port `51820`. It will automatically configure the target to use the WireGuard proxy and trust the mitmproxy TLS certificate. You can configure which apps to include using the `options` parameter. On iOS, this will start a mitmproxy HTTP(S) proxy on the host computer on port `8080`. It will automatically configure the target to use the proxy and trust the mitmproxy TLS certificate. You can not restrict the traffic collection to specific apps. Only one traffic collection can be active at a time. |
| `stop` | () => `Promise`<`void`\> | Stop the analysis. This is important for clean up, e.g. stopping the emulator if it is managed by this library. |
| `stopTrafficCollection` | () => `Promise`<[`TweaselHar`](README.md#tweaselhar)\> | Stop collecting the device's traffic. This will stop the proxy on the host computer. |

#### Defined in

[src/index.ts:102](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L102)
[src/index.ts:104](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L104)

___

Expand All @@ -93,7 +93,7 @@ The options for the `startAnalysis()` function.

#### Defined in

[src/index.ts:326](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L326)
[src/index.ts:328](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L328)

___

Expand Down Expand Up @@ -163,7 +163,7 @@ Functions that can be used to control an app analysis.

#### Defined in

[src/index.ts:175](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L175)
[src/index.ts:177](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L177)

___

Expand All @@ -183,13 +183,31 @@ The result of an app analysis.

#### Defined in

[src/index.ts:262](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L262)
[src/index.ts:264](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L264)

___

### Device
### DeviceAttribute

Ƭ **DeviceAttribute**<`Platform`\>: `Platform` extends ``"android"`` ? ``"apiLevel"`` \| ``"architectures"`` \| ``"manufacturer"`` \| ``"model"`` \| ``"modelCodeName"`` \| ``"name"`` \| ``"osBuild"`` \| ``"osVersion"`` : ``"architectures"`` \| ``"idfv"`` \| ``"manufacturer"`` \| ``"modelCodeName"`` \| ``"name"`` \| ``"osBuild"`` \| ``"osVersion"``

A supported attribute for the `getDeviceAttribute()` function, depending on the platform.

#### Type parameters

| Name | Type |
| :------ | :------ |
| `Platform` | extends [`SupportedPlatform`](README.md#supportedplatform) |

#### Defined in

node_modules/appstraction/dist/index.d.ts:445

___

### DeviceV1

Ƭ **Device**: `Object`
Ƭ **DeviceV1**: `Object`

Metadata about the device the analysis was run on.

Expand All @@ -212,24 +230,6 @@ Metadata about the device the analysis was run on.

___

### DeviceAttribute

Ƭ **DeviceAttribute**<`Platform`\>: `Platform` extends ``"android"`` ? ``"apiLevel"`` \| ``"architectures"`` \| ``"manufacturer"`` \| ``"model"`` \| ``"modelCodeName"`` \| ``"name"`` \| ``"osBuild"`` \| ``"osVersion"`` : ``"architectures"`` \| ``"idfv"`` \| ``"manufacturer"`` \| ``"modelCodeName"`` \| ``"name"`` \| ``"osBuild"`` \| ``"osVersion"``

A supported attribute for the `getDeviceAttribute()` function, depending on the platform.

#### Type parameters

| Name | Type |
| :------ | :------ |
| `Platform` | extends [`SupportedPlatform`](README.md#supportedplatform) |

#### Defined in

node_modules/appstraction/dist/index.d.ts:445

___

### GetDeviceAttributeOptions

Ƭ **GetDeviceAttributeOptions**: `Object`
Expand Down Expand Up @@ -512,7 +512,7 @@ The options for a specific platform/run target combination.

#### Defined in

[src/index.ts:280](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L280)
[src/index.ts:282](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L282)

___

Expand Down Expand Up @@ -564,9 +564,9 @@ node_modules/appstraction/dist/index.d.ts:66

___

### TrafficCollectionOptions
### TrafficCollectionOptionsV1

Ƭ **TrafficCollectionOptions**: { `mode`: ``"all-apps"`` } \| { `apps`: `string`[] ; `mode`: ``"allowlist"`` \| ``"denylist"`` }
Ƭ **TrafficCollectionOptionsV1**: { `mode`: ``"all-apps"`` } \| { `apps`: `string`[] ; `mode`: ``"allowlist"`` \| ``"denylist"`` }

Options for a traffic collection that specifies which apps to collect traffic from.

Expand All @@ -576,7 +576,7 @@ Options for a traffic collection that specifies which apps to collect traffic fr

#### Defined in

[src/index.ts:100](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L100)
[src/index.ts:101](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L101)

___

Expand Down Expand Up @@ -604,10 +604,10 @@ Metadata about the traffic collection as included in a [TweaselHar](README.md#tw
| Name | Type | Description |
| :------ | :------ | :------ |
| `apps?` | [`App`](README.md#app)[] | Details about the app(s) that was/were analyzed. Currently only populated if the traffic was recorded through an app analysis. |
| `device` | [`Device`](README.md#device) | Details about the device that the analysis was run on. |
| `device` | [`DeviceV1`](README.md#devicev1) | Details about the device that the analysis was run on. |
| `endDate` | `string` | The time and date at which the traffic collection was stopped. |
| `metaVersion` | ``"1.0"`` | The version of the tweasel-specific metadata format. Currently, `1.0` is the only version. If the format is ever changed or extended in the future, this version will be incremented. |
| `options` | [`TrafficCollectionOptions`](README.md#trafficcollectionoptions) | The options that were used for the traffic collection. |
| `options` | [`TrafficCollectionOptionsV1`](README.md#trafficcollectionoptionsv1) | The options that were used for the traffic collection. |
| `startDate` | `string` | The time and date at which the traffic collection was started. |
| `versions` | `Record`<`string`, `string`\> | The versions of the dependencies used in the analysis. |

Expand Down Expand Up @@ -692,4 +692,4 @@ An object that can be used to instrument the device and analyze apps.

#### Defined in

[src/index.ts:360](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L360)
[src/index.ts:362](https://github.com/tweaselORG/cyanoacrylate/blob/main/src/index.ts#L362)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"dependencies": {
"@types/har-format": "^1.2.10",
"andromatic": "^1.1.1",
"appstraction": "file:.yalc/appstraction",
"appstraction": "^1.2.0",
"autopy": "^1.1.1",
"cross-fetch": "^3.1.5",
"ctrlc-windows": "^2.1.0",
Expand Down
12 changes: 7 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type SupportedCapability<Platform extends SupportedPlatform> = Platform e
: never;

/** Metadata about the device the analysis was run on. */
export type Device = {
export type DeviceV1 = {
/** The device's operating system. */
platform: SupportedPlatform;
/** The type of device (emulator, physical device). */
Expand Down Expand Up @@ -73,9 +73,9 @@ export type TweaselHarMetaV1 = {
/** The time and date at which the traffic collection was stopped. */
endDate: string;
/** The options that were used for the traffic collection. */
options: TrafficCollectionOptions;
options: TrafficCollectionOptionsV1;
/** Details about the device that the analysis was run on. */
device: Device;
device: DeviceV1;
/** The versions of the dependencies used in the analysis. */
versions: Record<string, string>;
/**
Expand All @@ -90,14 +90,16 @@ export type TweaselHarMetaV1 = {
metaVersion: '1.0';
};

export type TrafficCollectionOptions = TrafficCollectionOptionsV1;
/**
* Options for a traffic collection that specifies which apps to collect traffic from.
*
* - `mode: 'all-apps'`: Collect traffic from all apps.
* - `mode: 'allowlist'`: Collect traffic only from the apps with the app IDs in the `apps` array.
* - `mode: 'denylist'`: Collect traffic from all apps except the apps with the app IDs in the `apps` array.
*/
export type TrafficCollectionOptions = { mode: 'all-apps' } | { mode: 'allowlist' | 'denylist'; apps: string[] };
export type TrafficCollectionOptionsV1 = { mode: 'all-apps' } | { mode: 'allowlist' | 'denylist'; apps: string[] };

/** Functions that can be used to instrument the device and analyze apps. */
export type Analysis<
Platform extends SupportedPlatform,
Expand Down Expand Up @@ -381,7 +383,7 @@ export async function startAnalysis<

const platform = platformApi(platformOptions);

let device: Device;
let device: DeviceV1;
const versions = {
appstraction: appstractionVersion,
cyanoacrylate: cyanoacrylateVersion,
Expand Down
6 changes: 4 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1585,8 +1585,10 @@ ap@~0.2.0:
resolved "https://registry.yarnpkg.com/ap/-/ap-0.2.0.tgz#ae0942600b29912f0d2b14ec60c45e8f330b6110"
integrity sha512-ImdvquIuBSVpWRWhB441UjvTcZqic1RL+lTQaUKGdGEp1aiTvt/phAvY8Vvs32qya5FJBI8U+tzNBYzFDQY/lQ==

"appstraction@file:.yalc/appstraction":
version "1.0.0"
appstraction@^1.2.0yarn:
version "1.2.0"
resolved "https://registry.yarnpkg.com/appstraction/-/appstraction-1.2.0.tgz#9c47c861109ee7e193e4a38d69e24fb3e5d18081"
integrity sha512-Ow7Sa0O06Y5LltgIWwKhz4lXkgmZu4q9T1jhCkdjx97Q+HCFLVhhbwIsSwdE47l5VA/oA8ZeT+U7Jn1x2OLATw==
dependencies:
"@napi-rs/lzma" "^1.1.2"
andromatic "^1.1.1"
Expand Down

0 comments on commit c9596c6

Please sign in to comment.