Public
Script
  • easrng avatar
    getCaller
    @easrng
    An interactive, runnable TypeScript val by easrng
    Script
  • stevekrouse avatar
    runValAPIAuth
    @stevekrouse
    // Make an authenticated request to another user's val
    Script
  • easrng avatar
    valSign
    @easrng
    secure signatures with vals setup you'll need to make 2 new vals: generate a keypair (keep this val private) let vsExportedKeys = @easrng.generateKeys(); publish your public key (make this val public) const vsPublicKey = () => @me.exportedKeys.publicKey; usage sign call @easrng.valSign to get a signature. const signature = await @easrng.valSign({ keys: @me.vsExportedKeys, data: {hello: "world"}}) the result will look something like this: @easrng.htVgaVWWtvnz5AK0DnDaNON5gar5qJeaorfsTCiIr7ua_-D4HPmFrIrPMfwmCaMvI0CxKlYCUe9XTGm7r5s5C3siZGF0YSI6eyJoZWxsbyI6IndvcmxkIn0sInVzZXIiOiJlYXNybmciLCJleHByIjpudWxsfQ you can also set an expiration date: const signature = await @easrng.valSign({ keys: @me.vsExportedKeys, data: "this expires in 1 second", expireIn: 1000 }) verify call @easrng.valSignVerify to verify a signature const { data, handle, expiresAt } = await @easrng.valSignVerify(signature) with the example signature from earlier, data would be {hello: "world"} , handle would be easrng , and expiresAt would be null
    Script
  • stevekrouse avatar
    myHandle
    @stevekrouse
    An interactive, runnable TypeScript val by stevekrouse
    Script
  • stevekrouse avatar
    r2
    @stevekrouse
    r2 wrapper Save blobs without leaving Val Town! Only for Val Town Pro users to limit abuse. We get 10gb free, so as long as nobody abuses this, I won't put any strict limits on it. If you want to use more than 10gb, let me know, and we can bill you for it. All data in this bucket is public if you know it's name! This val, @stevekrouse.r2, is the "SDK" for @stevekrouse.r2Proxy . Setup This val requires you to setup public key auth, which is really just three clicks here: https://blog.val.town/public-key-auth-val-town-users-can-be-your-users [Optional] You can setup a helper function so you don't have to pass your keys every time: let blob = (key, value) => @stevekrouse.r2(key, value, @me.exportedKeys) Warning: Do not make your blob function public or unlisted. That would allow anyone to use it. Usage await @me.blob("demo", { hello: "world" }); return @me.blob("demo"); // {hello: "world"} Example usage: https://www.val.town/v/stevekrouse.r2Demo
    Script
1
Next
October 23, 2023