@dignetwork/dig-sdk 0.0.1-alpha.56 → 0.0.1-alpha.57
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropagationServer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/PropagationServer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,qBAAa,iBAAiB;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,GAAG,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAQ;IAGpC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAYrB;gBAEU,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAY9C;;OAEG;IACG,gBAAgB;IAKtB;;OAEG;IACH,gBAAgB;IAQhB;;;;;OAKG;IACG,gBAAgB,CACpB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;QAAE,WAAW,EAAE,OAAO,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAE,CAAC;IA4C7D;;OAEG;IACG,kBAAkB;IAqCxB;;OAEG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBrD;;;OAGG;IACG,UAAU,CAAC,QAAQ,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"PropagationServer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/PropagationServer.ts"],"names":[],"mappings":"AAOA,OA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|
|
@@ -33,7 +33,7 @@ class PropagationServer {
|
|
|
33
33
|
*/
|
|
34
34
|
async initializeWallet() {
|
|
35
35
|
this.wallet = await blockchain_1.Wallet.load("default");
|
|
36
|
-
this.publicKey = await this.wallet.
|
|
36
|
+
this.publicKey = await this.wallet.getPublicSyntheticKey().toString('hex');
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Create an Axios HTTPS Agent with self-signed certificate allowance.
|
|
@@ -57,7 +57,7 @@ class PropagationServer {
|
|
|
57
57
|
const config = {
|
|
58
58
|
httpsAgent: this.createHttpsAgent(),
|
|
59
59
|
};
|
|
60
|
-
let url = `https://${this.ipAddress}:${PropagationServer.port}
|
|
60
|
+
let url = `https://${this.ipAddress}:${PropagationServer.port}/${this.storeId}`;
|
|
61
61
|
if (rootHash) {
|
|
62
62
|
url += `?hasRootHash=${rootHash}`;
|
|
63
63
|
}
|
|
@@ -66,10 +66,10 @@ class PropagationServer {
|
|
|
66
66
|
const storeExists = response.headers["x-store-exists"] === "true";
|
|
67
67
|
const rootHashExists = response.headers["x-has-root-hash"] === "true";
|
|
68
68
|
if (storeExists) {
|
|
69
|
-
spinner.success({ text: (0, colorette_1.green)(`Store ${this.storeId} exists!`) });
|
|
69
|
+
spinner.success({ text: (0, colorette_1.green)(`Store ${this.storeId} exists on peer!`) });
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
|
-
spinner.error({ text: (0, colorette_1.red)(`Store ${this.storeId} does not exist.`) });
|
|
72
|
+
spinner.error({ text: (0, colorette_1.red)(`Store ${this.storeId} does not exist. Credentials will be required to push.`) });
|
|
73
73
|
}
|
|
74
74
|
if (rootHash) {
|
|
75
75
|
if (rootHashExists) {
|
|
@@ -83,7 +83,7 @@ class PropagationServer {
|
|
|
83
83
|
}
|
|
84
84
|
catch (error) {
|
|
85
85
|
spinner.error({ text: (0, colorette_1.red)("Error checking if store exists:") });
|
|
86
|
-
console.error((0, colorette_1.red)(error));
|
|
86
|
+
console.error((0, colorette_1.red)(error.message));
|
|
87
87
|
throw error;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -112,7 +112,7 @@ class PropagationServer {
|
|
|
112
112
|
}
|
|
113
113
|
catch (error) {
|
|
114
114
|
spinner.error({ text: (0, colorette_1.red)("Error starting upload session:") });
|
|
115
|
-
console.error((0, colorette_1.red)(error));
|
|
115
|
+
console.error((0, colorette_1.red)(error.message));
|
|
116
116
|
throw error;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -131,7 +131,7 @@ class PropagationServer {
|
|
|
131
131
|
return nonce;
|
|
132
132
|
}
|
|
133
133
|
catch (error) {
|
|
134
|
-
console.error((0, colorette_1.red)(`Error generating nonce for file ${filename}:`), error);
|
|
134
|
+
console.error((0, colorette_1.red)(`Error generating nonce for file ${filename}:`), error.message);
|
|
135
135
|
throw error;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
@@ -142,7 +142,9 @@ class PropagationServer {
|
|
|
142
142
|
async uploadFile(filePath) {
|
|
143
143
|
const filename = path_1.default.basename(filePath);
|
|
144
144
|
const nonce = await this.getFileNonce(filename);
|
|
145
|
-
const
|
|
145
|
+
const wallet = await blockchain_1.Wallet.load("default");
|
|
146
|
+
const keyOwnershipSig = await wallet.createKeyOwnershipSignature(nonce);
|
|
147
|
+
const publicKey = await wallet.getPublicSyntheticKey();
|
|
146
148
|
const formData = new form_data_1.default();
|
|
147
149
|
formData.append("file", fs_1.default.createReadStream(filePath));
|
|
148
150
|
const fileSize = fs_1.default.statSync(filePath).size;
|
|
@@ -156,7 +158,7 @@ class PropagationServer {
|
|
|
156
158
|
headers: {
|
|
157
159
|
"Content-Type": "multipart/form-data",
|
|
158
160
|
"x-nonce": nonce,
|
|
159
|
-
"x-public-key":
|
|
161
|
+
"x-public-key": publicKey.toString("hex"),
|
|
160
162
|
"x-key-ownership-sig": keyOwnershipSig,
|
|
161
163
|
...formData.getHeaders(),
|
|
162
164
|
},
|
|
@@ -178,7 +180,7 @@ class PropagationServer {
|
|
|
178
180
|
return response.data;
|
|
179
181
|
}
|
|
180
182
|
catch (error) {
|
|
181
|
-
console.error((0, colorette_1.red)(`✖ Error uploading file ${filename}:`), error);
|
|
183
|
+
console.error((0, colorette_1.red)(`✖ Error uploading file ${filename}:`), error.message);
|
|
182
184
|
progressBar.stop(); // Stop the progress bar in case of error
|
|
183
185
|
throw error;
|
|
184
186
|
}
|
|
@@ -20,7 +20,7 @@ export declare class Wallet {
|
|
|
20
20
|
private static getWalletFromKeyring;
|
|
21
21
|
private static saveWalletToKeyring;
|
|
22
22
|
createKeyOwnershipSignature(nonce: string): Promise<string>;
|
|
23
|
-
verifyKeyOwnershipSignature(nonce: string, signature: string, publicKey: string): Promise<boolean>;
|
|
23
|
+
static verifyKeyOwnershipSignature(nonce: string, signature: string, publicKey: string): Promise<boolean>;
|
|
24
24
|
selectUnspentCoins(peer: Peer, coinAmount: bigint, feeBigInt: bigint, omitCoins?: Coin[]): Promise<Coin[]>;
|
|
25
25
|
static calculateFeeForCoinSpends(peer: Peer, coinSpends: CoinSpend[] | null): Promise<bigint>;
|
|
26
26
|
static isCoinSpendable(peer: Peer, coinId: Buffer): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Wallet.d.ts","sourceRoot":"","sources":["../../src/blockchain/Wallet.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EASL,IAAI,EACJ,IAAI,EAEJ,SAAS,EAEV,MAAM,8BAA8B,CAAC;AAMtC,eAAO,MAAM,qBAAqB,WAAa,CAAC;AAOhD,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO;WAKa,IAAI,CACtB,UAAU,GAAE,MAAkB,EAC9B,iBAAiB,GAAE,OAAc,GAChC,OAAO,CAAC,MAAM,CAAC;IAsBX,WAAW,IAAI,MAAM;WAOR,eAAe,CAAC,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M,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAShE,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA6BhE,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAKrC,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAMxC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;IAKzC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAMrC,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;WAK7B,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WASlD,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;mBAU/B,oBAAoB;mBAWpB,mBAAmB;IAM3B,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAOpD,2BAA2B,CAC7C,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC;IASN,kBAAkB,CAC7B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,IAAI,EAAO,GACrB,OAAO,CAAC,IAAI,EAAE,CAAC;WAwCE,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;WAItF,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAOlF"}
|
|
@@ -174,7 +174,7 @@ class Wallet {
|
|
|
174
174
|
const signature = (0, datalayer_driver_1.signMessage)(buffer_1.Buffer.from(message, "utf-8"), privateSyntheticKey);
|
|
175
175
|
return signature.toString("hex");
|
|
176
176
|
}
|
|
177
|
-
async verifyKeyOwnershipSignature(nonce, signature, publicKey) {
|
|
177
|
+
static async verifyKeyOwnershipSignature(nonce, signature, publicKey) {
|
|
178
178
|
const message = `Signing this message to prove ownership of key.\n\nNonce: ${nonce}`;
|
|
179
179
|
return (0, datalayer_driver_1.verifySignedMessage)(buffer_1.Buffer.from(signature, "hex"), buffer_1.Buffer.from(publicKey, "hex"), buffer_1.Buffer.from(message, "utf-8"));
|
|
180
180
|
}
|