Skip to content

Commit

Permalink
Merge pull request #111 from ardriveapp/alpha
Browse files Browse the repository at this point in the history
chore: release v1.7.1
  • Loading branch information
fedellen authored Apr 25, 2024
2 parents 6717d38 + 6640bd0 commit 684cdef
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# [1.7.0-alpha.2](https://github.com/ardriveapp/turbo-sdk/compare/v1.7.0-alpha.1...v1.7.0-alpha.2) (2024-04-25)


### Bug Fixes

* **signer:** use web signer if .window exists PE-6055 ([90cbd56](https://github.com/ardriveapp/turbo-sdk/commit/90cbd5624da8c63ab56a4ef516120df4a8831b65))
# [1.7.0](https://github.com/ardriveapp/turbo-sdk/compare/v1.6.0...v1.7.0) (2024-04-25)


Expand Down
1 change: 1 addition & 0 deletions bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const bundle = () => {
polyfillNode({
polyfills: {
crypto: true,
buffer: true,
},
}),
],
Expand Down
6 changes: 5 additions & 1 deletion src/common/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ export class ArweaveToken implements TokenTools {
tx.setOwner(publicKeyB64Url);

const dataToSign = await tx.getSignatureData();
const signatureBuffer = Buffer.from(await signer.signData(dataToSign));

const signatureUint8Array = await signer.signData(dataToSign);

const signatureBuffer = Buffer.from(signatureUint8Array);

const id = sha256B64Url(signatureBuffer);

tx.setSignature({
Expand Down
17 changes: 13 additions & 4 deletions src/node/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
TurboAuthenticatedUploadService,
} from '../common/index.js';
import { TurboAuthenticatedConfiguration, TurboSigner } from '../types.js';
import { TurboWebArweaveSigner } from '../web/signer.js';
import { TurboNodeSigner } from './signer.js';

export class TurboFactory extends TurboBaseFactory {
Expand Down Expand Up @@ -51,10 +52,18 @@ export class TurboFactory extends TurboBaseFactory {
throw new Error('A privateKey or signer must be provided.');
}

const turboSigner = new TurboNodeSigner({
signer,
logger: this.logger,
});
// when in browser, we use TurboWebArweaveSigner
const turboSigner =
typeof window !== 'undefined'
? new TurboWebArweaveSigner({
signer,
logger: this.logger,
})
: new TurboNodeSigner({
signer,
logger: this.logger,
});

const paymentService = new TurboAuthenticatedPaymentService({
...paymentServiceConfig,
signer: turboSigner,
Expand Down

0 comments on commit 684cdef

Please sign in to comment.