@efffrida/frida-tools 0.0.27 → 0.0.29

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.
Files changed (38) hide show
  1. package/dist/FridaDevice.d.ts +9 -8
  2. package/dist/FridaDevice.d.ts.map +1 -1
  3. package/dist/FridaDevice.js.map +1 -1
  4. package/dist/FridaDeviceAcquisitionError.d.ts +3 -18
  5. package/dist/FridaDeviceAcquisitionError.d.ts.map +1 -1
  6. package/dist/FridaDeviceAcquisitionError.js +2 -13
  7. package/dist/FridaDeviceAcquisitionError.js.map +1 -1
  8. package/dist/FridaScript.d.ts +12 -13
  9. package/dist/FridaScript.d.ts.map +1 -1
  10. package/dist/FridaScript.js +10 -9
  11. package/dist/FridaScript.js.map +1 -1
  12. package/dist/FridaSession.d.ts +21 -7
  13. package/dist/FridaSession.d.ts.map +1 -1
  14. package/dist/FridaSession.js.map +1 -1
  15. package/dist/FridaSessionError.d.ts +1 -16
  16. package/dist/FridaSessionError.d.ts.map +1 -1
  17. package/dist/FridaSessionError.js +2 -13
  18. package/dist/FridaSessionError.js.map +1 -1
  19. package/dist/internal/compiler.d.ts +2 -0
  20. package/dist/internal/compiler.d.ts.map +1 -0
  21. package/dist/internal/compiler.js +82 -0
  22. package/dist/internal/compiler.js.map +1 -0
  23. package/dist/internal/device.js +33 -32
  24. package/dist/internal/device.js.map +1 -1
  25. package/dist/internal/script.js +56 -105
  26. package/dist/internal/script.js.map +1 -1
  27. package/dist/internal/session.js +92 -48
  28. package/dist/internal/session.js.map +1 -1
  29. package/package.json +9 -16
  30. package/src/FridaDevice.ts +11 -10
  31. package/src/FridaDeviceAcquisitionError.ts +4 -29
  32. package/src/FridaScript.ts +22 -23
  33. package/src/FridaSession.ts +25 -7
  34. package/src/FridaSessionError.ts +2 -24
  35. package/src/internal/compiler.ts +125 -0
  36. package/src/internal/device.ts +85 -67
  37. package/src/internal/script.ts +209 -292
  38. package/src/internal/session.ts +118 -52
@@ -1,7 +1,9 @@
1
1
  import * as Context from "effect/Context";
2
+ import * as Deferred from "effect/Deferred";
2
3
  import * as Effect from "effect/Effect";
3
4
  import * as Layer from "effect/Layer";
4
5
  import * as Match from "effect/Match";
6
+ import * as Option from "effect/Option";
5
7
  import * as Predicate from "effect/Predicate";
6
8
  import * as Frida from "frida";
7
9
  import * as FridaDevice from "../FridaDevice.js";
@@ -9,23 +11,47 @@ import * as FridaSessionError from "../FridaSessionError.js";
9
11
  /** @internal */
10
12
  export const FridaSessionTypeId = /*#__PURE__*/Symbol.for("@efffrida/frida-tools/FridaSession");
11
13
  /** @internal */
12
- export const Tag = /*#__PURE__*/Context.GenericTag("@efffrida/frida-tools/FridaSession");
14
+ export const Tag = /*#__PURE__*/Context.Service("@efffrida/frida-tools/FridaSession");
13
15
  /** @internal */
14
16
  export const isFridaSession = u => Predicate.hasProperty(u, FridaSessionTypeId);
15
17
  /** @internal */
18
+ export const resume = session => Effect.tryPromise({
19
+ try: signal => {
20
+ const cancellable = new Frida.Cancellable();
21
+ signal.onabort = () => cancellable.cancel();
22
+ return session.resume(cancellable);
23
+ },
24
+ catch: cause => new FridaSessionError.FridaSessionError({
25
+ when: "resume",
26
+ cause
27
+ })
28
+ });
29
+ /** @internal */
30
+ export const detach = session => Effect.tryPromise({
31
+ try: signal => {
32
+ const cancellable = new Frida.Cancellable();
33
+ signal.onabort = () => cancellable.cancel();
34
+ return session.detach(cancellable);
35
+ },
36
+ catch: cause => new FridaSessionError.FridaSessionError({
37
+ when: "detach",
38
+ cause
39
+ })
40
+ });
41
+ /** @internal */
16
42
  export const frontmost = options => Effect.flatMap(FridaDevice.FridaDevice, ({
17
43
  device
18
44
  }) => Effect.tryPromise(signal => {
19
45
  const cancellable = new Frida.Cancellable();
20
46
  signal.onabort = () => cancellable.cancel();
21
47
  return device.getFrontmostApplication(options, cancellable);
22
- })).pipe(Effect.flatMap(Effect.fromNullable), Effect.mapError(cause => new FridaSessionError.FridaSessionError({
48
+ })).pipe(Effect.flatMap(Effect.fromNullishOr), Effect.mapError(cause => new FridaSessionError.FridaSessionError({
23
49
  when: "attach",
24
50
  cause
25
51
  })));
26
52
  /** @internal */
27
53
  export const spawn = (program, options) => {
28
- const spawnEffect = Effect.flatMap(FridaDevice.FridaDevice, ({
54
+ const acquire = Effect.flatMap(FridaDevice.FridaDevice, ({
29
55
  device
30
56
  }) => Effect.tryPromise({
31
57
  try: signal => {
@@ -38,19 +64,6 @@ export const spawn = (program, options) => {
38
64
  cause
39
65
  })
40
66
  }));
41
- const resumeEffect = pid => Effect.flatMap(FridaDevice.FridaDevice, ({
42
- device
43
- }) => Effect.tryPromise({
44
- try: signal => {
45
- const cancellable = new Frida.Cancellable();
46
- signal.onabort = () => cancellable.cancel();
47
- return device.resume(pid, cancellable);
48
- },
49
- catch: cause => new FridaSessionError.FridaSessionError({
50
- when: "resume",
51
- cause
52
- })
53
- }));
54
67
  const release = pid => Effect.flatMap(FridaDevice.FridaDevice, ({
55
68
  device
56
69
  }) => Effect.promise(signal => {
@@ -58,12 +71,24 @@ export const spawn = (program, options) => {
58
71
  signal.onabort = () => cancellable.cancel();
59
72
  return device.kill(pid, cancellable);
60
73
  }));
61
- const acquire = Effect.tap(spawnEffect, resumeEffect);
62
74
  const resource = Effect.acquireRelease(acquire, release);
63
75
  return resource;
64
76
  };
65
77
  /** @internal */
66
78
  export const attach = (target, options) => {
79
+ const detached = Deferred.makeUnsafe();
80
+ const onDetached = (reason, crash) => {
81
+ Deferred.doneUnsafe(detached, Effect.succeed({
82
+ reason,
83
+ crash: Option.fromNullOr(crash).pipe(Option.map(c => ({
84
+ pid: c.pid,
85
+ processName: c.processName,
86
+ summary: c.summary,
87
+ report: c.report,
88
+ parameters: c.parameters
89
+ })))
90
+ }));
91
+ };
67
92
  const acquire = Effect.flatMap(FridaDevice.FridaDevice, ({
68
93
  device
69
94
  }) => Effect.tryPromise({
@@ -80,45 +105,64 @@ export const attach = (target, options) => {
80
105
  const release = session => Effect.promise(signal => {
81
106
  const cancellable = new Frida.Cancellable();
82
107
  signal.onabort = () => cancellable.cancel();
108
+ session.detached.disconnect(onDetached);
83
109
  return session.detach(cancellable);
84
110
  });
85
111
  const resource = Effect.acquireRelease(acquire, release);
86
- return Effect.map(resource, session => ({
87
- session,
88
- resume: Effect.tryPromise(signal => {
89
- const cancellable = new Frida.Cancellable();
90
- signal.onabort = () => cancellable.cancel();
91
- return session.resume(cancellable);
92
- }),
93
- enableChildGating: Effect.tryPromise(signal => {
94
- const cancellable = new Frida.Cancellable();
95
- signal.onabort = () => cancellable.cancel();
96
- return session.enableChildGating(cancellable);
97
- }),
98
- disableChildGating: Effect.tryPromise(signal => {
99
- const cancellable = new Frida.Cancellable();
100
- signal.onabort = () => cancellable.cancel();
101
- return session.disableChildGating(cancellable);
102
- }),
103
- setupPeerConnection: opts => Effect.tryPromise(signal => {
104
- const cancellable = new Frida.Cancellable();
105
- signal.onabort = () => cancellable.cancel();
106
- return session.setupPeerConnection(opts, cancellable);
107
- }),
108
- joinPortal: (address, opts) => Effect.tryPromise(signal => {
109
- const cancellable = new Frida.Cancellable();
110
- signal.onabort = () => cancellable.cancel();
111
- return session.joinPortal(address, opts, cancellable);
112
- }),
113
- [FridaSessionTypeId]: FridaSessionTypeId
114
- }));
112
+ return Effect.map(resource, session => {
113
+ session.detached.connect(onDetached);
114
+ return {
115
+ session,
116
+ pid: session.pid,
117
+ detached: detached,
118
+ resume: resume(session),
119
+ detach: detach(session),
120
+ enableChildGating: Effect.tryPromise(signal => {
121
+ const cancellable = new Frida.Cancellable();
122
+ signal.onabort = () => cancellable.cancel();
123
+ return session.enableChildGating(cancellable);
124
+ }),
125
+ disableChildGating: Effect.tryPromise(signal => {
126
+ const cancellable = new Frida.Cancellable();
127
+ signal.onabort = () => cancellable.cancel();
128
+ return session.disableChildGating(cancellable);
129
+ }),
130
+ setupPeerConnection: opts => Effect.tryPromise(signal => {
131
+ const cancellable = new Frida.Cancellable();
132
+ signal.onabort = () => cancellable.cancel();
133
+ return session.setupPeerConnection(opts, cancellable);
134
+ }),
135
+ joinPortal: (address, opts) => Effect.tryPromise(signal => {
136
+ const cancellable = new Frida.Cancellable();
137
+ signal.onabort = () => cancellable.cancel();
138
+ return session.joinPortal(address, opts, cancellable);
139
+ }),
140
+ [FridaSessionTypeId]: FridaSessionTypeId
141
+ };
142
+ });
115
143
  };
116
144
  /** @internal */
117
- export const layer = (target, options) => Layer.scoped(Tag, Effect.gen(function* () {
145
+ export const layer = (target, options) => Layer.effect(Tag, Effect.gen(function* () {
146
+ const {
147
+ device
148
+ } = yield* FridaDevice.FridaDevice;
118
149
  const pid = yield* Match.value(target).pipe(Match.when(Match.number, proc => Effect.succeed(proc)), Match.when(Match.string, proc => spawn(proc)), Match.orElse(proc => spawn(proc)));
119
150
  const session = yield* attach(pid, options);
151
+ if (typeof target !== "number") {
152
+ yield* Effect.tryPromise({
153
+ try: signal => {
154
+ const cancellable = new Frida.Cancellable();
155
+ signal.onabort = () => cancellable.cancel();
156
+ return device.resume(session.pid, cancellable);
157
+ },
158
+ catch: cause => new FridaSessionError.FridaSessionError({
159
+ when: "resume",
160
+ cause
161
+ })
162
+ });
163
+ }
120
164
  return session;
121
165
  }));
122
166
  /** @internal */
123
- export const layerFrontmost = options => Layer.unwrapEffect(Effect.map(frontmost(options), app => layer(app.pid)));
167
+ export const layerFrontmost = options => Layer.unwrap(Effect.map(frontmost(options), app => layer(app.pid)));
124
168
  //# sourceMappingURL=session.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","names":["Context","Effect","Layer","Match","Predicate","Frida","FridaDevice","FridaSessionError","FridaSessionTypeId","Symbol","for","Tag","GenericTag","isFridaSession","u","hasProperty","frontmost","options","flatMap","device","tryPromise","signal","cancellable","Cancellable","onabort","cancel","getFrontmostApplication","pipe","fromNullable","mapError","cause","when","spawn","program","spawnEffect","try","catch","resumeEffect","pid","resume","release","promise","kill","acquire","tap","resource","acquireRelease","attach","target","session","detach","map","enableChildGating","disableChildGating","setupPeerConnection","opts","joinPortal","address","layer","scoped","gen","value","number","proc","succeed","string","orElse","layerFrontmost","unwrapEffect","app"],"sources":["../../src/internal/session.ts"],"sourcesContent":[null],"mappings":"AAEA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAKC,KAAK,MAAM,OAAO;AAI9B,OAAO,KAAKC,WAAW,MAAM,mBAAmB;AAChD,OAAO,KAAKC,iBAAiB,MAAM,yBAAyB;AAE5D;AACA,OAAO,MAAMC,kBAAkB,gBAAoCC,MAAM,CAACC,GAAG,CACzE,oCAAoC,CACJ;AAEpC;AACA,OAAO,MAAMC,GAAG,gBAAGX,OAAO,CAACY,UAAU,CAA4B,oCAAoC,CAAC;AAEtG;AACA,OAAO,MAAMC,cAAc,GAAIC,CAAU,IACrCV,SAAS,CAACW,WAAW,CAACD,CAAC,EAAEN,kBAAkB,CAAC;AAEhD;AACA,OAAO,MAAMQ,SAAS,GAClBC,OAAiD,IAEjDhB,MAAM,CAACiB,OAAO,CAACZ,WAAW,CAACA,WAAW,EAAE,CAAC;EAAEa;AAAM,CAAE,KAC/ClB,MAAM,CAACmB,UAAU,CAAEC,MAAM,IAAI;EACzB,MAAMC,WAAW,GAAG,IAAIjB,KAAK,CAACkB,WAAW,EAAE;EAC3CF,MAAM,CAACG,OAAO,GAAG,MAAMF,WAAW,CAACG,MAAM,EAAE;EAC3C,OAAON,MAAM,CAACO,uBAAuB,CAACT,OAAO,EAAEK,WAAW,CAAC;AAC/D,CAAC,CAAC,CACL,CAACK,IAAI,CACF1B,MAAM,CAACiB,OAAO,CAACjB,MAAM,CAAC2B,YAAY,CAAC,EACnC3B,MAAM,CAAC4B,QAAQ,CACVC,KAAK,IACF,IAAIvB,iBAAiB,CAACA,iBAAiB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AACnC,SAAS,CAACC,OAAO,CAAC,EAAGoD,GAAG,IAAKX,KAAK,CAACW,GAAG,CAAC/B,GAAG,CAAC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"session.js","names":["Context","Deferred","Effect","Layer","Match","Option","Predicate","Frida","FridaDevice","FridaSessionError","FridaSessionTypeId","Symbol","for","Tag","Service","isFridaSession","u","hasProperty","resume","session","tryPromise","try","signal","cancellable","Cancellable","onabort","cancel","catch","cause","when","detach","frontmost","options","flatMap","device","getFrontmostApplication","pipe","fromNullishOr","mapError","spawn","program","acquire","release","pid","promise","kill","resource","acquireRelease","attach","target","detached","makeUnsafe","onDetached","reason","crash","doneUnsafe","succeed","fromNullOr","map","c","processName","summary","report","parameters","disconnect","connect","enableChildGating","disableChildGating","setupPeerConnection","opts","joinPortal","address","layer","effect","gen","value","number","proc","string","orElse","layerFrontmost","unwrap","app"],"sources":["../../src/internal/session.ts"],"sourcesContent":[null],"mappings":"AAEA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAI7C,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,OAAO,KAAKC,WAAW,MAAM,mBAAmB;AAChD,OAAO,KAAKC,iBAAiB,MAAM,yBAAyB;AAE5D;AACA,OAAO,MAAMC,kBAAkB,gBAAoCC,MAAM,CAACC,GAAG,CACzE,oCAAoC,CACJ;AAEpC;AACA,OAAO,MAAMC,GAAG,gBAAGb,OAAO,CAACc,OAAO,CAA4B,oCAAoC,CAAC;AAEnG;AACA,OAAO,MAAMC,cAAc,GAAIC,CAAU,IACrCV,SAAS,CAACW,WAAW,CAACD,CAAC,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,IAAI,CAAC,CAAC,CACtC;EAED,MAAM1D,OAAO,GAAG,OAAO6B,MAAM,CAACL,GAAG,EAAEX,OAAO,CAAC;EAE3C,IAAI,OAAOiB,MAAM,KAAK,QAAQ,EAAE;IAC5B,OAAO/C,MAAM,CAACkB,UAAU,CAAC;MACrBC,GAAG,EAAGC,MAAM,IAAI;QACZ,MAAMC,WAAW,GAAG,IAAIhB,KAAK,CAACiB,WAAW,EAAE;QAC3CF,MAAM,CAACG,OAAO,GAAG,MAAMF,WAAW,CAACG,MAAM,EAAE;QAC3C,OAAOQ,MAAM,CAAChB,MAAM,CAACC,OAAO,CAACwB,GAAG,EAAEpB,WAAW,CAAC;MAClD,CAAC;MACDI,KAAK,EAAGC,KAAK,IACT,IAAInB,iBAAiB,CAACA,iBAAiB,CAAC;QACpCoB,IAAI,EAAE,QAAQ;QACdD;OACH;KACR,CAAC;EACN;EAEA,OAAOT,OAAO;AAClB,CAAC,CAAC,CACL;AAEL;AACA,OAAO,MAAM6D,cAAc,GACvBhD,OAAiD,IAEjD7B,KAAK,CAAC8E,MAAM,CAAC/E,MAAM,CAACwD,GAAG,CAAC3B,SAAS,CAACC,OAAO,CAAC,EAAGkD,GAAG,IAAKV,KAAK,CAACU,GAAG,CAACvC,GAAG,CAAC,CAAC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efffrida/frida-tools",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "description": "Frida with effect-ts",
5
5
  "keywords": [
6
6
  "effect-ts",
@@ -35,26 +35,19 @@
35
35
  "provenance": true
36
36
  },
37
37
  "dependencies": {
38
- "frida": "17.9.8"
38
+ "frida": "17.9.10"
39
39
  },
40
40
  "devDependencies": {
41
- "@effect/cluster": "0.58.2",
42
- "@effect/experimental": "0.60.0",
43
- "@effect/platform": "0.96.1",
44
- "@effect/platform-node": "0.106.0",
45
- "@effect/rpc": "0.75.1",
46
- "@effect/sql": "0.51.1",
47
- "@effect/vitest": "0.29.0",
48
- "@effect/workflow": "0.18.1",
41
+ "@effect/platform-node": "4.0.0-beta.69",
42
+ "@effect/vitest": "4.0.0-beta.69",
49
43
  "@types/frida-gum": "19.1.0",
50
- "@types/node": "25.7.0",
51
- "effect": "3.21.2",
52
- "vitest": "4.1.6",
53
- "@efffrida/polyfills": "0.0.6"
44
+ "@types/node": "25.9.0",
45
+ "effect": "4.0.0-beta.69",
46
+ "ioredis": "5.10.1",
47
+ "vitest": "4.1.6"
54
48
  },
55
49
  "peerDependencies": {
56
- "@effect/platform": "0.96.1",
57
- "effect": "3.21.2"
50
+ "effect": "4.0.0-beta.69"
58
51
  },
59
52
  "tags": [
60
53
  "frida.re",
@@ -4,15 +4,16 @@
4
4
  * @since 1.0.0
5
5
  */
6
6
 
7
- import type * as CommandExecutor from "@effect/platform/CommandExecutor";
8
- import type * as ConfigError from "effect/ConfigError";
7
+ import type * as Config from "effect/Config";
9
8
  import type * as Context from "effect/Context";
10
9
  import type * as Effect from "effect/Effect";
11
10
  import type * as Layer from "effect/Layer";
11
+ import type * as Path from "effect/Path";
12
12
  import type * as Scope from "effect/Scope";
13
- import type * as Frida from "frida";
13
+ import type * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner";
14
14
 
15
15
  import type * as FridaDeviceAcquisitionError from "./FridaDeviceAcquisitionError.ts";
16
+ import type * as Frida from "frida";
16
17
 
17
18
  import * as internal from "./internal/device.ts";
18
19
 
@@ -42,7 +43,7 @@ export interface FridaDevice {
42
43
  * @since 1.0.0
43
44
  * @category Tags
44
45
  */
45
- export const FridaDevice: Context.Tag<FridaDevice, FridaDevice> = internal.Tag;
46
+ export const FridaDevice: Context.Service<FridaDevice, FridaDevice> = internal.Tag;
46
47
 
47
48
  /**
48
49
  * @since 1.0.0
@@ -97,7 +98,7 @@ export const acquireAndroidEmulatorDevice: (
97
98
  ) => Effect.Effect<
98
99
  FridaDevice,
99
100
  FridaDeviceAcquisitionError.FridaDeviceAcquisitionError,
100
- CommandExecutor.CommandExecutor | Scope.Scope
101
+ ChildProcessSpawner.ChildProcessSpawner | Scope.Scope
101
102
  > = internal.acquireAndroidEmulatorDevice;
102
103
 
103
104
  /**
@@ -115,8 +116,8 @@ export const acquireAndroidEmulatorDeviceConfig: (
115
116
  | undefined
116
117
  ) => Effect.Effect<
117
118
  FridaDevice,
118
- ConfigError.ConfigError | FridaDeviceAcquisitionError.FridaDeviceAcquisitionError,
119
- CommandExecutor.CommandExecutor | Scope.Scope
119
+ Config.ConfigError | FridaDeviceAcquisitionError.FridaDeviceAcquisitionError,
120
+ ChildProcessSpawner.ChildProcessSpawner | Path.Path | Scope.Scope
120
121
  > = internal.acquireAndroidEmulatorDeviceConfig;
121
122
 
122
123
  /**
@@ -165,7 +166,7 @@ export const layerAndroidEmulatorDevice: (
165
166
  ) => Layer.Layer<
166
167
  FridaDevice,
167
168
  FridaDeviceAcquisitionError.FridaDeviceAcquisitionError,
168
- CommandExecutor.CommandExecutor
169
+ ChildProcessSpawner.ChildProcessSpawner
169
170
  > = internal.layerAndroidEmulatorDevice;
170
171
 
171
172
  /**
@@ -183,6 +184,6 @@ export const layerAndroidEmulatorDeviceConfig: (
183
184
  | undefined
184
185
  ) => Layer.Layer<
185
186
  FridaDevice,
186
- ConfigError.ConfigError | FridaDeviceAcquisitionError.FridaDeviceAcquisitionError,
187
- CommandExecutor.CommandExecutor
187
+ Config.ConfigError | FridaDeviceAcquisitionError.FridaDeviceAcquisitionError,
188
+ ChildProcessSpawner.ChildProcessSpawner | Path.Path
188
189
  > = internal.layerAndroidEmulatorDeviceConfig;
@@ -4,41 +4,16 @@
4
4
  * @since 1.0.0
5
5
  */
6
6
 
7
- import * as PlatformError from "@effect/platform/Error";
8
- import * as Predicate from "effect/Predicate";
7
+ import * as Data from "effect/Data";
9
8
 
10
9
  /**
11
10
  * @since 1.0.0
12
11
  * @category Errors
13
12
  */
14
- export const FridaDeviceAcquisitionErrorTypeId: unique symbol = Symbol.for(
15
- "@efffrida/FridaError/FridaDeviceAcquisitionError"
16
- ) as FridaDeviceAcquisitionErrorTypeId;
17
-
18
- /**
19
- * @since 1.0.0
20
- * @category Errors
21
- */
22
- export type FridaDeviceAcquisitionErrorTypeId = typeof FridaDeviceAcquisitionErrorTypeId;
23
-
24
- /**
25
- * @since 1.0.0
26
- * @category Errors
27
- */
28
- export const isFridaDeviceAcquisitionError = (u: unknown): u is FridaDeviceAcquisitionError =>
29
- Predicate.hasProperty(u, FridaDeviceAcquisitionErrorTypeId);
30
-
31
- /**
32
- * @since 1.0.0
33
- * @category Errors
34
- */
35
- export class FridaDeviceAcquisitionError extends PlatformError.TypeIdError(
36
- FridaDeviceAcquisitionErrorTypeId,
37
- "FridaDeviceAcquisitionError"
38
- )<{
39
- cause: unknown;
40
- attempts: number;
13
+ export class FridaDeviceAcquisitionError extends Data.TaggedError("FridaDeviceAcquisitionError")<{
41
14
  acquisitionMethod: "usb" | "remote" | "local" | "android-emulator";
15
+ attempts: number;
16
+ cause: unknown;
42
17
  }> {
43
18
  public override get message(): string {
44
19
  return `Failed to acquire ${this.acquisitionMethod} Frida device after ${this.attempts} attempt(s)`;
@@ -4,32 +4,32 @@
4
4
  * @since 1.0.0
5
5
  */
6
6
 
7
- import type * as FileSystem from "@effect/platform/FileSystem";
8
- import type * as Path from "@effect/platform/Path";
9
7
  import type * as Context from "effect/Context";
10
8
  import type * as Deferred from "effect/Deferred";
11
9
  import type * as Duration from "effect/Duration";
12
10
  import type * as Effect from "effect/Effect";
13
11
  import type * as Exit from "effect/Exit";
12
+ import type * as FileSystem from "effect/FileSystem";
14
13
  import type * as Layer from "effect/Layer";
15
14
  import type * as Option from "effect/Option";
16
- import type * as ParseResult from "effect/ParseResult";
15
+ import type * as Path from "effect/Path";
17
16
  import type * as Schema from "effect/Schema";
18
17
  import type * as Scope from "effect/Scope";
19
18
  import type * as Sink from "effect/Sink";
20
19
  import type * as Stream from "effect/Stream";
21
- import type * as Frida from "frida";
22
20
 
23
21
  import type * as FridaSession from "./FridaSession.ts";
24
22
  import type * as FridaSessionError from "./FridaSessionError.ts";
23
+ import type * as Frida from "frida";
25
24
 
26
- import * as internal from "./internal/script.ts";
25
+ import * as internalCompiler from "./internal/compiler.ts";
26
+ import * as internalScript from "./internal/script.ts";
27
27
 
28
28
  /**
29
29
  * @since 1.0.0
30
30
  * @category Type ids
31
31
  */
32
- export const FridaScriptTypeId: unique symbol = internal.FridaScriptTypeId;
32
+ export const FridaScriptTypeId: unique symbol = internalScript.FridaScriptTypeId;
33
33
 
34
34
  /**
35
35
  * @since 1.0.0
@@ -58,23 +58,23 @@ export interface FridaScript {
58
58
  FridaSessionError.FridaSessionError,
59
59
  never
60
60
  >;
61
- readonly callExport: <A, I, R>(
61
+ readonly callExport: <A = unknown, R = never>(
62
62
  exportName: string,
63
- schema: Schema.Schema<A, I, R>
64
- ) => (...args: Array<any>) => Effect.Effect<A, FridaSessionError.FridaSessionError | ParseResult.ParseError, R>;
63
+ schema?: Schema.Decoder<A, R> | undefined
64
+ ) => (...args: Array<any>) => Effect.Effect<A, FridaSessionError.FridaSessionError | Schema.SchemaError, R>;
65
65
  }
66
66
 
67
67
  /**
68
68
  * @since 1.0.0
69
69
  * @category Tags
70
70
  */
71
- export const FridaScript: Context.Tag<FridaScript, FridaScript> = internal.Tag;
71
+ export const FridaScript: Context.Service<FridaScript, FridaScript> = internalScript.Tag;
72
72
 
73
73
  /**
74
74
  * @since 1.0.0
75
75
  * @category Predicates
76
76
  */
77
- export const isFridaScript: (u: unknown) => u is FridaScript = internal.isFridaScript;
77
+ export const isFridaScript: (u: unknown) => u is FridaScript = internalScript.isFridaScript;
78
78
 
79
79
  /**
80
80
  * @since 1.0.0
@@ -82,23 +82,22 @@ export const isFridaScript: (u: unknown) => u is FridaScript = internal.isFridaS
82
82
  */
83
83
  export interface LoadOptions extends Frida.ScriptOptions, Frida.CompilerOptions {
84
84
  readonly messageMailboxCapacity?:
85
- | number
86
85
  | {
87
- readonly capacity?: number;
88
- readonly strategy?: "suspend" | "dropping" | "sliding";
86
+ readonly capacity?: number | undefined;
87
+ readonly strategy?: "suspend" | "dropping" | "sliding" | undefined;
89
88
  }
90
89
  | undefined;
91
90
  readonly streamShareOptions?:
92
91
  | {
93
92
  readonly capacity: "unbounded";
94
93
  readonly replay?: number | undefined;
95
- readonly idleTimeToLive?: Duration.DurationInput | undefined;
94
+ readonly idleTimeToLive?: Duration.Input | undefined;
96
95
  }
97
96
  | {
98
97
  readonly capacity: number;
99
98
  readonly strategy?: "sliding" | "dropping" | "suspend" | undefined;
100
99
  readonly replay?: number | undefined;
101
- readonly idleTimeToLive?: Duration.DurationInput | undefined;
100
+ readonly idleTimeToLive?: Duration.Input | undefined;
102
101
  }
103
102
  | undefined;
104
103
  }
@@ -111,11 +110,11 @@ export const compile: {
111
110
  (
112
111
  entrypoint: string,
113
112
  options?: Frida.CompilerOptions | undefined
114
- ): Effect.Effect<string, FridaSessionError.FridaSessionError, Scope.Scope>;
113
+ ): Effect.Effect<string, FridaSessionError.FridaSessionError>;
115
114
  (
116
115
  options?: Frida.CompilerOptions | undefined
117
- ): (entrypoint: string) => Effect.Effect<string, FridaSessionError.FridaSessionError, Scope.Scope>;
118
- } = internal.compile;
116
+ ): (entrypoint: string) => Effect.Effect<string, FridaSessionError.FridaSessionError>;
117
+ } = internalCompiler.compile;
119
118
 
120
119
  /**
121
120
  * @since 1.0.0
@@ -139,7 +138,7 @@ export const load: {
139
138
  FridaSessionError.FridaSessionError,
140
139
  Path.Path | FridaSession.FridaSession | Scope.Scope
141
140
  >;
142
- } = internal.load;
141
+ } = internalScript.load;
143
142
 
144
143
  /**
145
144
  * @since 1.0.0
@@ -153,7 +152,7 @@ export const layer: {
153
152
  (
154
153
  options?: LoadOptions | undefined
155
154
  ): (entrypoint: URL) => Layer.Layer<FridaScript, FridaSessionError.FridaSessionError, FridaSession.FridaSession>;
156
- } = internal.layer;
155
+ } = internalScript.layer;
157
156
 
158
157
  /**
159
158
  * @since 1.0.0
@@ -179,7 +178,7 @@ export const watch: {
179
178
  FridaSessionError.FridaSessionError,
180
179
  FileSystem.FileSystem | FridaSession.FridaSession | Exclude<R, FridaScript>
181
180
  >;
182
- } = internal.watch;
181
+ } = internalScript.watch;
183
182
 
184
183
  /**
185
184
  * Successes will be logged with info, failures with warning, defects with
@@ -190,4 +189,4 @@ export const watch: {
190
189
  */
191
190
  export const logWatchErrors: <A, E1, E2, R>(
192
191
  watchStream: Stream.Stream<Exit.Exit<A, E1>, E2, R>
193
- ) => Stream.Stream<Exit.Exit<A, E1>, E2, R> = internal.logWatchErrors;
192
+ ) => Stream.Stream<Exit.Exit<A, E1>, E2, R> = internalScript.logWatchErrors;
@@ -6,13 +6,15 @@
6
6
 
7
7
  import type * as Cause from "effect/Cause";
8
8
  import type * as Context from "effect/Context";
9
+ import type * as Deferred from "effect/Deferred";
9
10
  import type * as Effect from "effect/Effect";
10
11
  import type * as Layer from "effect/Layer";
12
+ import type * as Option from "effect/Option";
11
13
  import type * as Scope from "effect/Scope";
12
- import type * as Frida from "frida";
13
14
 
14
15
  import type * as FridaDevice from "./FridaDevice.ts";
15
16
  import type * as FridaSessionError from "./FridaSessionError.ts";
17
+ import type * as Frida from "frida";
16
18
 
17
19
  import * as internal from "./internal/session.ts";
18
20
 
@@ -33,23 +35,39 @@ export type FridaSessionTypeId = typeof FridaSessionTypeId;
33
35
  * @category Models
34
36
  */
35
37
  export interface FridaSession {
38
+ readonly pid: number;
36
39
  readonly session: Frida.Session;
40
+
37
41
  readonly [FridaSessionTypeId]: typeof FridaSessionTypeId;
38
- readonly resume: Effect.Effect<void, Cause.UnknownException>;
39
- readonly enableChildGating: Effect.Effect<void, Cause.UnknownException>;
40
- readonly disableChildGating: Effect.Effect<void, Cause.UnknownException>;
41
- setupPeerConnection(options?: Frida.PeerOptions | undefined): Effect.Effect<void, Cause.UnknownException>;
42
+ readonly detached: Deferred.Deferred<
43
+ {
44
+ reason: Frida.SessionDetachReason;
45
+ crash: Option.Option<{
46
+ pid: number;
47
+ processName: string;
48
+ summary: string;
49
+ report: string;
50
+ parameters: unknown;
51
+ }>;
52
+ },
53
+ FridaSessionError.FridaSessionError
54
+ >;
55
+ readonly resume: Effect.Effect<void, FridaSessionError.FridaSessionError, never>;
56
+ readonly detach: Effect.Effect<void, FridaSessionError.FridaSessionError, never>;
57
+ readonly enableChildGating: Effect.Effect<void, Cause.UnknownError, never>;
58
+ readonly disableChildGating: Effect.Effect<void, Cause.UnknownError, never>;
59
+ setupPeerConnection(options?: Frida.PeerOptions | undefined): Effect.Effect<void, Cause.UnknownError, never>;
42
60
  joinPortal(
43
61
  address: string,
44
62
  options?: Frida.PortalOptions | undefined
45
- ): Effect.Effect<Frida.PortalMembership, Cause.UnknownException>;
63
+ ): Effect.Effect<Frida.PortalMembership, Cause.UnknownError, never>;
46
64
  }
47
65
 
48
66
  /**
49
67
  * @since 1.0.0
50
68
  * @category Tags
51
69
  */
52
- export const FridaSession: Context.Tag<FridaSession, FridaSession> = internal.Tag;
70
+ export const FridaSession: Context.Service<FridaSession, FridaSession> = internal.Tag;
53
71
 
54
72
  /**
55
73
  * @since 1.0.0
@@ -4,35 +4,13 @@
4
4
  * @since 1.0.0
5
5
  */
6
6
 
7
- import * as PlatformError from "@effect/platform/Error";
8
- import * as Predicate from "effect/Predicate";
7
+ import * as Data from "effect/Data";
9
8
 
10
9
  /**
11
10
  * @since 1.0.0
12
11
  * @category Errors
13
12
  */
14
- export const FridaSessionErrorTypeId: unique symbol = Symbol.for(
15
- "@efffrida/FridaError/FridaSessionError"
16
- ) as FridaSessionErrorTypeId;
17
-
18
- /**
19
- * @since 1.0.0
20
- * @category Errors
21
- */
22
- export type FridaSessionErrorTypeId = typeof FridaSessionErrorTypeId;
23
-
24
- /**
25
- * @since 1.0.0
26
- * @category Errors
27
- */
28
- export const isFridaSessionError = (u: unknown): u is FridaSessionError =>
29
- Predicate.hasProperty(u, FridaSessionErrorTypeId);
30
-
31
- /**
32
- * @since 1.0.0
33
- * @category Errors
34
- */
35
- export class FridaSessionError extends PlatformError.TypeIdError(FridaSessionErrorTypeId, "FridaSessionError")<{
13
+ export class FridaSessionError extends Data.TaggedError("FridaSessionError")<{
36
14
  cause: unknown;
37
15
  when:
38
16
  | "spawn"