bedrock-ts-sdk 0.0.6 → 0.0.7
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/README.md +3 -3
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ const signature = await wallet.signMessage({ message: 'Bedrock.im' });
|
|
|
109
109
|
const client = await BedrockClient.fromSignature(
|
|
110
110
|
signature,
|
|
111
111
|
window.ethereum,
|
|
112
|
-
{ apiServer: 'https://
|
|
112
|
+
{ apiServer: 'https://poc-aleph-ccn.reza.dev' }
|
|
113
113
|
);
|
|
114
114
|
```
|
|
115
115
|
|
|
@@ -427,13 +427,13 @@ Bedrock uses a dual encryption approach:
|
|
|
427
427
|
```typescript
|
|
428
428
|
const client = await BedrockClient.fromPrivateKey(privateKey, {
|
|
429
429
|
channel: 'MY_CUSTOM_CHANNEL', // Default: 'bedrock'
|
|
430
|
-
apiServer: 'https://
|
|
430
|
+
apiServer: 'https://poc-aleph-ccn.reza.dev', // Default: 'https://poc-aleph-ccn.reza.dev'
|
|
431
431
|
});
|
|
432
432
|
```
|
|
433
433
|
|
|
434
434
|
**Configuration Options:**
|
|
435
435
|
- `channel`: Aleph channel for data isolation (default: `'bedrock'`)
|
|
436
|
-
- `apiServer`: Aleph API server URL (default: `'https://
|
|
436
|
+
- `apiServer`: Aleph API server URL (default: `'https://poc-aleph-ccn.reza.dev'`)
|
|
437
437
|
|
|
438
438
|
## Development
|
|
439
439
|
|
package/dist/index.d.mts
CHANGED
|
@@ -80,7 +80,9 @@ declare class BedrockCore {
|
|
|
80
80
|
* @param provider - EIP-1193 provider (for MetaMask/Rabby)
|
|
81
81
|
* @param config - Optional configuration
|
|
82
82
|
*/
|
|
83
|
-
static fromSignature(signatureHash: string, provider: any, config?: BedrockCoreConfig
|
|
83
|
+
static fromSignature(signatureHash: string, provider: any, config?: BedrockCoreConfig & {
|
|
84
|
+
providerSignature?: string;
|
|
85
|
+
}): Promise<BedrockCore>;
|
|
84
86
|
/**
|
|
85
87
|
* Create BedrockCore from a private key (for testing/CLI)
|
|
86
88
|
* @param privateKey - Ethereum private key (hex string with or without 0x prefix)
|
package/dist/index.d.ts
CHANGED
|
@@ -80,7 +80,9 @@ declare class BedrockCore {
|
|
|
80
80
|
* @param provider - EIP-1193 provider (for MetaMask/Rabby)
|
|
81
81
|
* @param config - Optional configuration
|
|
82
82
|
*/
|
|
83
|
-
static fromSignature(signatureHash: string, provider: any, config?: BedrockCoreConfig
|
|
83
|
+
static fromSignature(signatureHash: string, provider: any, config?: BedrockCoreConfig & {
|
|
84
|
+
providerSignature?: string;
|
|
85
|
+
}): Promise<BedrockCore>;
|
|
84
86
|
/**
|
|
85
87
|
* Create BedrockCore from a private key (for testing/CLI)
|
|
86
88
|
* @param privateKey - Ethereum private key (hex string with or without 0x prefix)
|
package/dist/index.js
CHANGED
|
@@ -286,7 +286,7 @@ var import_client = require("@aleph-sdk/client");
|
|
|
286
286
|
var import_message = require("@aleph-sdk/message");
|
|
287
287
|
var import_zod2 = require("zod");
|
|
288
288
|
var AlephService = class {
|
|
289
|
-
constructor(account, channel = ALEPH_GENERAL_CHANNEL, apiServer = "https://
|
|
289
|
+
constructor(account, channel = ALEPH_GENERAL_CHANNEL, apiServer = "https://poc-aleph-ccn.reza.dev") {
|
|
290
290
|
this.account = account;
|
|
291
291
|
this.channel = channel;
|
|
292
292
|
this.subAccountClient = new import_client.AuthenticatedAlephHttpClient(account, apiServer);
|
|
@@ -480,7 +480,7 @@ var BedrockCore = class _BedrockCore {
|
|
|
480
480
|
try {
|
|
481
481
|
const cfg = {
|
|
482
482
|
channel: config?.channel || ALEPH_GENERAL_CHANNEL,
|
|
483
|
-
apiServer: config?.apiServer || "https://
|
|
483
|
+
apiServer: config?.apiServer || "https://poc-aleph-ccn.reza.dev"
|
|
484
484
|
};
|
|
485
485
|
const privateKey = import_web3.default.utils.sha3(signatureHash);
|
|
486
486
|
if (!privateKey) {
|
|
@@ -494,8 +494,14 @@ var BedrockCore = class _BedrockCore {
|
|
|
494
494
|
} else {
|
|
495
495
|
throw new AuthenticationError("window.ethereum not available");
|
|
496
496
|
}
|
|
497
|
+
} else if (config?.providerSignature === void 0) {
|
|
498
|
+
throw new AuthenticationError("Invalid provider");
|
|
497
499
|
} else {
|
|
498
|
-
|
|
500
|
+
const externalWalletPrivateKey = import_web3.default.utils.sha3(config.providerSignature);
|
|
501
|
+
if (externalWalletPrivateKey === void 0) {
|
|
502
|
+
throw new AuthenticationError("Failed to derive private key from signature");
|
|
503
|
+
}
|
|
504
|
+
mainAccount = (0, import_ethereum.importAccountFromPrivateKey)(externalWalletPrivateKey);
|
|
499
505
|
}
|
|
500
506
|
const subAccount = (0, import_ethereum.importAccountFromPrivateKey)(privateKey);
|
|
501
507
|
await _BedrockCore.setupSecurityPermissions(mainAccount, subAccount, cfg);
|
|
@@ -514,7 +520,7 @@ var BedrockCore = class _BedrockCore {
|
|
|
514
520
|
try {
|
|
515
521
|
const cfg = {
|
|
516
522
|
channel: config?.channel || ALEPH_GENERAL_CHANNEL,
|
|
517
|
-
apiServer: config?.apiServer || "https://
|
|
523
|
+
apiServer: config?.apiServer || "https://poc-aleph-ccn.reza.dev"
|
|
518
524
|
};
|
|
519
525
|
const key = privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`;
|
|
520
526
|
const mainAccount = (0, import_ethereum.importAccountFromPrivateKey)(key);
|
|
@@ -1352,7 +1358,7 @@ var FileService = class {
|
|
|
1352
1358
|
*/
|
|
1353
1359
|
static async fetchPublicFileMeta(postHash) {
|
|
1354
1360
|
try {
|
|
1355
|
-
const client = new import_client3.AlephHttpClient("https://
|
|
1361
|
+
const client = new import_client3.AlephHttpClient("https://poc-aleph-ccn.reza.dev");
|
|
1356
1362
|
const post = await client.getPost({
|
|
1357
1363
|
channels: [ALEPH_GENERAL_CHANNEL],
|
|
1358
1364
|
types: [POST_TYPES.PUBLIC_FILE],
|
|
@@ -1370,7 +1376,7 @@ var FileService = class {
|
|
|
1370
1376
|
*/
|
|
1371
1377
|
static async downloadPublicFile(storeHash) {
|
|
1372
1378
|
try {
|
|
1373
|
-
const client = new import_client3.AlephHttpClient("https://
|
|
1379
|
+
const client = new import_client3.AlephHttpClient("https://poc-aleph-ccn.reza.dev");
|
|
1374
1380
|
return await client.downloadFile(storeHash);
|
|
1375
1381
|
} catch (error) {
|
|
1376
1382
|
throw new FileError(`Failed to download public file: ${error.message}`);
|