pakstr 0.3.4 → 0.4.0
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/android-template/app/src/main/AndroidManifest.xml +17 -0
- package/android-template/app/src/main/java/com/pakstr/app/LocalServer.kt +80 -21
- package/android-template/app/src/main/java/com/pakstr/app/MainActivity.kt +46 -9
- package/android-template/app/src/main/java/com/pakstr/app/RuntimeConfig.kt +81 -37
- package/android-template/app/src/main/java/com/pakstr/app/ShellRuntime.kt +99 -8
- package/android-template/app/src/main/java/com/pakstr/app/WebViewController.kt +145 -20
- package/android-template/app/src/main/java/com/pakstr/app/crypto/Bip340Verifier.kt +0 -5
- package/android-template/app/src/main/java/com/pakstr/app/debug/AppDebugLogger.kt +275 -3
- package/android-template/app/src/main/java/com/pakstr/app/debug/DebugConfig.kt +11 -0
- package/android-template/app/src/main/java/com/pakstr/app/debug/DebugConfigLoader.kt +36 -0
- package/android-template/app/src/main/java/com/pakstr/app/debug/DebugConfigProvider.kt +24 -0
- package/android-template/app/src/main/java/com/pakstr/app/debug/DebugLogStorage.kt +107 -0
- package/android-template/app/src/main/java/com/pakstr/app/debug/DebugReportExporter.kt +139 -0
- package/android-template/app/src/main/java/com/pakstr/app/debug/DebugReportShare.kt +52 -0
- package/android-template/app/src/main/java/com/pakstr/app/debug/DebugRuntimeOverride.kt +29 -0
- package/android-template/app/src/main/java/com/pakstr/app/debug/DeveloperToolsManager.kt +34 -0
- package/android-template/app/src/main/java/com/pakstr/app/signer/AmberSigner.kt +1 -10
- package/android-template/app/src/main/java/com/pakstr/app/signer/NostrBridge.kt +163 -11
- package/android-template/app/src/main/java/com/pakstr/app/signer/SignerManager.kt +71 -0
- package/android-template/app/src/main/res/xml/file_paths.xml +9 -0
- package/dist/runners/LocalGradleRunner.js +12 -2
- package/dist/runtime/runtimeConfig.js +6 -1
- package/package.json +1 -1
|
@@ -30,7 +30,15 @@ class NostrBridge(
|
|
|
30
30
|
callbackId: String,
|
|
31
31
|
payload: String?
|
|
32
32
|
) {
|
|
33
|
+
AppDebugLogger.log(
|
|
34
|
+
|
|
35
|
+
webView.context,
|
|
36
|
+
|
|
37
|
+
"SIGNER",
|
|
38
|
+
|
|
39
|
+
"Request: $method"
|
|
33
40
|
|
|
41
|
+
)
|
|
34
42
|
when (method) {
|
|
35
43
|
|
|
36
44
|
"getPublicKey" -> {
|
|
@@ -47,6 +55,17 @@ class NostrBridge(
|
|
|
47
55
|
pk
|
|
48
56
|
)
|
|
49
57
|
} catch (e: SignerUnavailableException) {
|
|
58
|
+
AppDebugLogger.error(
|
|
59
|
+
|
|
60
|
+
webView.context,
|
|
61
|
+
|
|
62
|
+
"SIGNER",
|
|
63
|
+
|
|
64
|
+
"getPublicKey failed",
|
|
65
|
+
|
|
66
|
+
e
|
|
67
|
+
|
|
68
|
+
)
|
|
50
69
|
resolve(
|
|
51
70
|
callbackId,
|
|
52
71
|
errorResponse(
|
|
@@ -56,6 +75,17 @@ class NostrBridge(
|
|
|
56
75
|
)
|
|
57
76
|
|
|
58
77
|
} catch (e: Exception) {
|
|
78
|
+
AppDebugLogger.error(
|
|
79
|
+
|
|
80
|
+
webView.context,
|
|
81
|
+
|
|
82
|
+
"SIGNER",
|
|
83
|
+
|
|
84
|
+
"getPublicKey failed",
|
|
85
|
+
|
|
86
|
+
e
|
|
87
|
+
|
|
88
|
+
)
|
|
59
89
|
resolve(
|
|
60
90
|
callbackId,
|
|
61
91
|
errorResponse(
|
|
@@ -68,11 +98,6 @@ class NostrBridge(
|
|
|
68
98
|
}
|
|
69
99
|
|
|
70
100
|
"signEvent" -> {
|
|
71
|
-
AppDebugLogger.log(
|
|
72
|
-
"NOSTR_SIGN",
|
|
73
|
-
"Signing event request"
|
|
74
|
-
)
|
|
75
|
-
|
|
76
101
|
scope.launch {
|
|
77
102
|
|
|
78
103
|
try {
|
|
@@ -87,13 +112,22 @@ class NostrBridge(
|
|
|
87
112
|
payload
|
|
88
113
|
)
|
|
89
114
|
|
|
115
|
+
AppDebugLogger.log(
|
|
116
|
+
|
|
117
|
+
webView.context,
|
|
118
|
+
|
|
119
|
+
"SIGNER",
|
|
120
|
+
|
|
121
|
+
"signEvent success"
|
|
122
|
+
|
|
123
|
+
)
|
|
124
|
+
|
|
90
125
|
resolve(
|
|
91
126
|
callbackId,
|
|
92
127
|
result
|
|
93
128
|
)
|
|
94
129
|
|
|
95
130
|
} catch (e: SignerUnavailableException) {
|
|
96
|
-
|
|
97
131
|
resolve(
|
|
98
132
|
callbackId,
|
|
99
133
|
errorResponse(
|
|
@@ -103,6 +137,17 @@ class NostrBridge(
|
|
|
103
137
|
)
|
|
104
138
|
|
|
105
139
|
} catch (e: Exception) {
|
|
140
|
+
AppDebugLogger.error(
|
|
141
|
+
|
|
142
|
+
webView.context,
|
|
143
|
+
|
|
144
|
+
"SIGNER",
|
|
145
|
+
|
|
146
|
+
"signEvent failed",
|
|
147
|
+
|
|
148
|
+
e
|
|
149
|
+
|
|
150
|
+
)
|
|
106
151
|
resolve(
|
|
107
152
|
callbackId,
|
|
108
153
|
errorResponse(
|
|
@@ -141,7 +186,15 @@ class NostrBridge(
|
|
|
141
186
|
plaintext
|
|
142
187
|
)
|
|
143
188
|
|
|
189
|
+
AppDebugLogger.log(
|
|
190
|
+
|
|
191
|
+
webView.context,
|
|
192
|
+
|
|
193
|
+
"SIGNER",
|
|
144
194
|
|
|
195
|
+
"nip04_encrypt success"
|
|
196
|
+
|
|
197
|
+
)
|
|
145
198
|
resolve(
|
|
146
199
|
callbackId,
|
|
147
200
|
result
|
|
@@ -158,7 +211,17 @@ class NostrBridge(
|
|
|
158
211
|
)
|
|
159
212
|
|
|
160
213
|
} catch (e: Exception) {
|
|
214
|
+
AppDebugLogger.error(
|
|
215
|
+
|
|
216
|
+
webView.context,
|
|
161
217
|
|
|
218
|
+
"SIGNER",
|
|
219
|
+
|
|
220
|
+
"nip04_encrypt failed",
|
|
221
|
+
|
|
222
|
+
e
|
|
223
|
+
|
|
224
|
+
)
|
|
162
225
|
resolve(
|
|
163
226
|
callbackId,
|
|
164
227
|
errorResponse(
|
|
@@ -197,7 +260,15 @@ class NostrBridge(
|
|
|
197
260
|
ciphertext
|
|
198
261
|
)
|
|
199
262
|
|
|
263
|
+
AppDebugLogger.log(
|
|
264
|
+
|
|
265
|
+
webView.context,
|
|
266
|
+
|
|
267
|
+
"SIGNER",
|
|
200
268
|
|
|
269
|
+
"nip04_decrypt success"
|
|
270
|
+
|
|
271
|
+
)
|
|
201
272
|
resolve(
|
|
202
273
|
callbackId,
|
|
203
274
|
result
|
|
@@ -214,7 +285,17 @@ class NostrBridge(
|
|
|
214
285
|
)
|
|
215
286
|
|
|
216
287
|
} catch (e: Exception) {
|
|
288
|
+
AppDebugLogger.error(
|
|
289
|
+
|
|
290
|
+
webView.context,
|
|
291
|
+
|
|
292
|
+
"SIGNER",
|
|
293
|
+
|
|
294
|
+
"nip04_decrypt failed",
|
|
295
|
+
|
|
296
|
+
e
|
|
217
297
|
|
|
298
|
+
)
|
|
218
299
|
resolve(
|
|
219
300
|
callbackId,
|
|
220
301
|
errorResponse(
|
|
@@ -242,14 +323,32 @@ class NostrBridge(
|
|
|
242
323
|
json.getString("pubkey"),
|
|
243
324
|
json.getString("plaintext")
|
|
244
325
|
)
|
|
326
|
+
AppDebugLogger.log(
|
|
327
|
+
|
|
328
|
+
webView.context,
|
|
329
|
+
|
|
330
|
+
"SIGNER",
|
|
331
|
+
|
|
332
|
+
"nip44_encrypt success"
|
|
245
333
|
|
|
334
|
+
)
|
|
246
335
|
resolve(
|
|
247
336
|
callbackId,
|
|
248
337
|
result
|
|
249
338
|
)
|
|
250
339
|
|
|
251
340
|
} catch (e: Exception) {
|
|
341
|
+
AppDebugLogger.error(
|
|
342
|
+
|
|
343
|
+
webView.context,
|
|
344
|
+
|
|
345
|
+
"SIGNER",
|
|
252
346
|
|
|
347
|
+
"nip44_encrypt failed",
|
|
348
|
+
|
|
349
|
+
e
|
|
350
|
+
|
|
351
|
+
)
|
|
253
352
|
resolve(
|
|
254
353
|
callbackId,
|
|
255
354
|
errorResponse(
|
|
@@ -277,14 +376,32 @@ class NostrBridge(
|
|
|
277
376
|
json.getString("pubkey"),
|
|
278
377
|
json.getString("ciphertext")
|
|
279
378
|
)
|
|
379
|
+
AppDebugLogger.log(
|
|
380
|
+
|
|
381
|
+
webView.context,
|
|
382
|
+
|
|
383
|
+
"SIGNER",
|
|
384
|
+
|
|
385
|
+
"nip44_decrypt success"
|
|
280
386
|
|
|
387
|
+
)
|
|
281
388
|
resolve(
|
|
282
389
|
callbackId,
|
|
283
390
|
result
|
|
284
391
|
)
|
|
285
392
|
|
|
286
393
|
} catch (e: Exception) {
|
|
394
|
+
AppDebugLogger.error(
|
|
395
|
+
|
|
396
|
+
webView.context,
|
|
397
|
+
|
|
398
|
+
"SIGNER",
|
|
287
399
|
|
|
400
|
+
"nip44_decrypt failed",
|
|
401
|
+
|
|
402
|
+
e
|
|
403
|
+
|
|
404
|
+
)
|
|
288
405
|
resolve(
|
|
289
406
|
callbackId,
|
|
290
407
|
errorResponse(
|
|
@@ -306,16 +423,51 @@ class NostrBridge(
|
|
|
306
423
|
}
|
|
307
424
|
}
|
|
308
425
|
|
|
426
|
+
@JavascriptInterface
|
|
427
|
+
fun debugLog(
|
|
428
|
+
level: String,
|
|
429
|
+
message: String
|
|
430
|
+
) {
|
|
431
|
+
|
|
432
|
+
when (level.uppercase()) {
|
|
433
|
+
|
|
434
|
+
"ERROR" -> {
|
|
435
|
+
|
|
436
|
+
AppDebugLogger.error(
|
|
437
|
+
webView.context,
|
|
438
|
+
"WEB",
|
|
439
|
+
message
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
"WARN" -> {
|
|
445
|
+
|
|
446
|
+
AppDebugLogger.log(
|
|
447
|
+
webView.context,
|
|
448
|
+
"WEB-WARN",
|
|
449
|
+
message
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
else -> {
|
|
455
|
+
|
|
456
|
+
AppDebugLogger.log(
|
|
457
|
+
webView.context,
|
|
458
|
+
"WEB",
|
|
459
|
+
message
|
|
460
|
+
)
|
|
461
|
+
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
309
466
|
private fun resolve(
|
|
310
467
|
callbackId: String,
|
|
311
468
|
result: String
|
|
312
469
|
) {
|
|
313
470
|
|
|
314
|
-
AppDebugLogger.log(
|
|
315
|
-
"NOSTR_BRIDGE",
|
|
316
|
-
"Bridge response received"
|
|
317
|
-
)
|
|
318
|
-
|
|
319
471
|
mainHandler.post {
|
|
320
472
|
|
|
321
473
|
val js =
|
|
@@ -6,6 +6,7 @@ import androidx.activity.result.ActivityResult
|
|
|
6
6
|
import androidx.activity.result.ActivityResultLauncher
|
|
7
7
|
import com.pakstr.app.signer.interfaces.NostrSigner
|
|
8
8
|
import androidx.core.content.edit
|
|
9
|
+
import com.pakstr.app.debug.AppDebugLogger
|
|
9
10
|
import com.pakstr.app.signer.exceptions.SignerUnavailableException
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -46,6 +47,20 @@ class SignerManager(
|
|
|
46
47
|
|
|
47
48
|
private var currentUserPubkey: String? = null
|
|
48
49
|
|
|
50
|
+
init {
|
|
51
|
+
|
|
52
|
+
AppDebugLogger.log(
|
|
53
|
+
|
|
54
|
+
context,
|
|
55
|
+
|
|
56
|
+
"SIGNER",
|
|
57
|
+
|
|
58
|
+
"SignerManager initialized. Active type: ${getActiveType()}"
|
|
59
|
+
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
49
64
|
fun getActiveType(): SignerType? {
|
|
50
65
|
|
|
51
66
|
val value =
|
|
@@ -78,6 +93,16 @@ class SignerManager(
|
|
|
78
93
|
|
|
79
94
|
currentUserPubkey = pk
|
|
80
95
|
|
|
96
|
+
AppDebugLogger.log(
|
|
97
|
+
|
|
98
|
+
context,
|
|
99
|
+
|
|
100
|
+
"SIGNER",
|
|
101
|
+
|
|
102
|
+
"Public key received: ${pk.take(12)}..."
|
|
103
|
+
|
|
104
|
+
)
|
|
105
|
+
|
|
81
106
|
return pk
|
|
82
107
|
|
|
83
108
|
}
|
|
@@ -85,7 +110,15 @@ class SignerManager(
|
|
|
85
110
|
fun setActiveType(
|
|
86
111
|
type: SignerType
|
|
87
112
|
) {
|
|
113
|
+
AppDebugLogger.log(
|
|
88
114
|
|
|
115
|
+
context,
|
|
116
|
+
|
|
117
|
+
"SIGNER",
|
|
118
|
+
|
|
119
|
+
"Changing active signer to: ${type.name}"
|
|
120
|
+
|
|
121
|
+
)
|
|
89
122
|
prefs.edit {
|
|
90
123
|
putString(
|
|
91
124
|
"type",
|
|
@@ -108,12 +141,41 @@ class SignerManager(
|
|
|
108
141
|
return it
|
|
109
142
|
}
|
|
110
143
|
|
|
144
|
+
val activeType = getActiveType()
|
|
145
|
+
|
|
146
|
+
AppDebugLogger.log(
|
|
147
|
+
|
|
148
|
+
context,
|
|
149
|
+
|
|
150
|
+
"SIGNER",
|
|
151
|
+
|
|
152
|
+
"Creating signer instance: $activeType"
|
|
153
|
+
|
|
154
|
+
)
|
|
155
|
+
|
|
111
156
|
val signer =
|
|
112
157
|
when (getActiveType()) {
|
|
113
158
|
|
|
114
159
|
SignerType.AMBER -> {
|
|
160
|
+
AppDebugLogger.log(
|
|
161
|
+
|
|
162
|
+
context,
|
|
163
|
+
|
|
164
|
+
"AMBER",
|
|
115
165
|
|
|
166
|
+
"Creating Amber signer"
|
|
167
|
+
|
|
168
|
+
)
|
|
116
169
|
if (!isAmberInstalled()) {
|
|
170
|
+
AppDebugLogger.error(
|
|
171
|
+
|
|
172
|
+
context,
|
|
173
|
+
|
|
174
|
+
"AMBER",
|
|
175
|
+
|
|
176
|
+
"Amber signer app is not installed"
|
|
177
|
+
|
|
178
|
+
)
|
|
117
179
|
throw SignerUnavailableException(
|
|
118
180
|
"Amber signer application is not installed"
|
|
119
181
|
)
|
|
@@ -172,6 +234,15 @@ class SignerManager(
|
|
|
172
234
|
* Activity Result API.
|
|
173
235
|
*/
|
|
174
236
|
fun handleAmberResult(result: ActivityResult) {
|
|
237
|
+
AppDebugLogger.log(
|
|
238
|
+
|
|
239
|
+
context,
|
|
240
|
+
|
|
241
|
+
"AMBER",
|
|
242
|
+
|
|
243
|
+
"Activity result received: ${result.resultCode}"
|
|
244
|
+
|
|
245
|
+
)
|
|
175
246
|
(activeSigner as? AmberSigner)
|
|
176
247
|
?.onResult(result)
|
|
177
248
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.LocalGradleRunner = void 0;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
10
|
class LocalGradleRunner {
|
|
10
11
|
async build(androidRoot, mode) {
|
|
11
12
|
const gradleTask = mode === "release" ? "assembleRelease" : "assembleDebug";
|
|
@@ -31,8 +32,17 @@ class LocalGradleRunner {
|
|
|
31
32
|
}
|
|
32
33
|
exports.LocalGradleRunner = LocalGradleRunner;
|
|
33
34
|
function findApk(androidRoot, mode) {
|
|
34
|
-
const
|
|
35
|
-
|
|
35
|
+
const apkDir = path_1.default.join(androidRoot, "app", "build", "outputs", "apk", mode);
|
|
36
|
+
if (!fs_1.default.existsSync(apkDir)) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const files = fs_1.default.readdirSync(apkDir);
|
|
40
|
+
const apk = files.find(file => file.endsWith(".apk") &&
|
|
41
|
+
!file.includes("metadata"));
|
|
42
|
+
if (!apk) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return path_1.default.join(apkDir, apk);
|
|
36
46
|
}
|
|
37
47
|
function fsExists(file) {
|
|
38
48
|
const fs = require("fs");
|
|
@@ -7,7 +7,12 @@ exports.generateRuntimeConfig = generateRuntimeConfig;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
function generateRuntimeConfig(webRoot, manifest) {
|
|
10
|
-
const runtime =
|
|
10
|
+
const runtime = {
|
|
11
|
+
...(manifest.runtime ?? {}),
|
|
12
|
+
...(manifest.debug
|
|
13
|
+
? { debug: manifest.debug }
|
|
14
|
+
: {})
|
|
15
|
+
};
|
|
11
16
|
const jsContent = `
|
|
12
17
|
window.PAKSTR_CONFIG = ${JSON.stringify(runtime, null, 2)};
|
|
13
18
|
`;
|