-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloudflare Worker support #169
Comments
Yep, definitely planed. However, it's more work than just replace the 'crypto' with 'node: crypto' ... |
Only thing that was getting in the way of using the ebayApi in a Cloudflare Worker was the digitalSignature, which I locally patched to account for environment and use the appropriate crypto API. XML parsing is not an issue since you can set compatibility flags in a worker to make it work. |
@lukasjaronis |
Here's my diff: diff --git a/node_modules/ebay-api/dist/api/digitalSignature.js b/node_modules/ebay-api/dist/api/digitalSignature.js
index 6f544dc..566e884 100644
--- a/node_modules/ebay-api/dist/api/digitalSignature.js
+++ b/node_modules/ebay-api/dist/api/digitalSignature.js
@@ -1,4 +1,4 @@
-import { createHash, sign } from 'crypto';
+import { createHash } from 'node:crypto';
import { EBayError } from '../errors/index.js';
const beginPrivateKey = '-----BEGIN PRIVATE KEY-----';
const endPrivateKey = '-----END PRIVATE KEY-----';
@@ -60,7 +60,7 @@ export function generateSignature(headers, privateKey, signatureComponents, payl
if (!privateKey.startsWith(beginPrivateKey)) {
privateKey = beginPrivateKey + '\n' + privateKey + '\n' + endPrivateKey;
}
- const signatureBuffer = sign(undefined, Buffer.from(baseString), privateKey);
+ const signatureBuffer = crypto.subtle.sign(undefined, privateKey, Buffer.from(baseString));
const signature = signatureBuffer.toString('base64');
return `sig1=:${signature}:`;
} |
Can we add support for CF workers? Would need to use
node:crypto
instead ofcrypto
.The text was updated successfully, but these errors were encountered: