bedrock-ts-sdk 0.0.8 → 0.0.9
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/dist/index.js +18 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -678,6 +678,7 @@ var BedrockCore = class _BedrockCore {
|
|
|
678
678
|
|
|
679
679
|
// src/services/file-service.ts
|
|
680
680
|
var import_client3 = require("@aleph-sdk/client");
|
|
681
|
+
var import_zod3 = require("zod");
|
|
681
682
|
|
|
682
683
|
// src/crypto/encryption.ts
|
|
683
684
|
var import_eciesjs2 = require("eciesjs");
|
|
@@ -1372,12 +1373,13 @@ var FileService = class {
|
|
|
1372
1373
|
static async fetchPublicFileMeta(postHash) {
|
|
1373
1374
|
try {
|
|
1374
1375
|
const client = new import_client3.AlephHttpClient("https://poc-aleph-ccn.reza.dev");
|
|
1375
|
-
const
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1376
|
+
const message = await client.getMessage(postHash);
|
|
1377
|
+
try {
|
|
1378
|
+
return PublicFileMetaSchema.parse(message.content);
|
|
1379
|
+
} catch {
|
|
1380
|
+
const postContent = message.content;
|
|
1381
|
+
return PublicFileMetaSchema.parse(postContent.content);
|
|
1382
|
+
}
|
|
1381
1383
|
} catch {
|
|
1382
1384
|
return null;
|
|
1383
1385
|
}
|
|
@@ -1390,7 +1392,16 @@ var FileService = class {
|
|
|
1390
1392
|
static async downloadPublicFile(storeHash) {
|
|
1391
1393
|
try {
|
|
1392
1394
|
const client = new import_client3.AlephHttpClient("https://poc-aleph-ccn.reza.dev");
|
|
1393
|
-
|
|
1395
|
+
const storeMessage = await client.getMessage(storeHash);
|
|
1396
|
+
const ContentSchema = import_zod3.z.object({
|
|
1397
|
+
address: import_zod3.z.string(),
|
|
1398
|
+
item_type: import_zod3.z.string(),
|
|
1399
|
+
item_hash: import_zod3.z.string(),
|
|
1400
|
+
time: import_zod3.z.number()
|
|
1401
|
+
});
|
|
1402
|
+
const { success, data } = ContentSchema.safeParse(storeMessage.content);
|
|
1403
|
+
if (!success) throw new Error("Invalid STORE message structure");
|
|
1404
|
+
return await client.downloadFile(data.item_hash);
|
|
1394
1405
|
} catch (error) {
|
|
1395
1406
|
throw new FileError(`Failed to download public file: ${error.message}`);
|
|
1396
1407
|
}
|