kian
03/08/2023, 6:52 PMsubtle
and see what's on itkian
03/08/2023, 6:52 PMkian
03/08/2023, 6:52 PMdave
03/08/2023, 6:53 PMkian
03/08/2023, 6:54 PMSkye
03/08/2023, 6:54 PMlib
in it?dave
03/08/2023, 6:54 PMdave
03/08/2023, 6:56 PMPato
03/08/2023, 7:03 PMPato
03/08/2023, 7:04 PMWalshy | Pages
03/08/2023, 7:05 PMPato
03/08/2023, 7:09 PMBREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "crypto": false }
Pato
03/08/2023, 7:15 PMPato
03/08/2023, 7:15 PMjs
const path = require('path')
module.exports = {
entry: './src/index.ts',
output: {
filename: 'worker.js',
path: path.join(__dirname, 'dist'),
},
devtool: 'cheap-module-source-map',
mode: 'development',
resolve: {
extensions: ['.ts', '.tsx', '.js'],
fallback: {
"fs": false,
"tls": false,
"net": false,
"path": false,
"zlib": false,
"http": false,
"https": false,
"stream": false,
"crypto": false,
// "crypto-browserify": require.resolve('crypto-browserify'), //if you want to use this module also don't forget npm i crypto-browserify
}
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
// transpileOnly is useful to skip typescript checks occasionally:
// transpileOnly: true,
},
},
],
},
}
Crazy Rabbit
03/08/2023, 7:46 PMjs
import * as path from 'path';
Crazy Rabbit
03/08/2023, 7:46 PM\ ឵឵឵
03/08/2023, 7:57 PMwrangler publish
? Occasionally I'm hitting old code up to 20m after deployment.Skye
03/08/2023, 7:58 PMdave
03/08/2023, 8:20 PMHardAtWork
03/08/2023, 8:58 PMts
const enc = new TextEncoder();
let key: CryptoKey;
async function generateToken(message: string, separator: string, secret: string) {
if(!key) {
key = await crypto.subtle.importKey(
"raw",
enc.encode(secret),
{
name: "HMAC",
hash: {
name: "SHA-256"
}
},
false,
["sign"]
);
}
const timestamp = Math.floor(Date.now() / 1000).toString();
return `${message}${separator}${timestamp}-${encodeURI(btoa(Array.from(new Uint8Array(crypto.subtle.sign(
"HMAC",
key,
enc.encode(message + timestamp)
))).join((a, b) => a + String.fromCharCode(b), "")))}`;
}
dave
03/08/2023, 8:59 PMdave
03/08/2023, 8:59 PMMath.floor(Date.now() / 1000).toString();
for the timestampHardAtWork
03/08/2023, 9:01 PMdave
03/08/2023, 9:03 PMkian
03/08/2023, 9:06 PMHardAtWork
03/08/2023, 9:09 PMenc
.HardAtWork
03/08/2023, 9:10 PMHardAtWork
03/08/2023, 9:10 PM