Would you use a backend where you just define schema, access policy, and functions?
Basically something like making smart contracts on EVM, but instead they run on a hyperscaler, and have regular backend fundamentals.
Here's a mock frenchie made me, was thinking something like this:
schema User {
email: string @private(owner)
name: string @public
balance: number @private(owner, admin)
}
policy {
User.read: owner OR role("admin")
User.update.balance: role("admin")
}
function transfer(from: User, to: User, amount: number) {
assert(caller == from.owner OR caller.role == "admin")
assert(from.balance >= amount)
from.balance -= amount
to.balance += amount
}
Was playing with OpenFGA, and AWS Lambda stuff, and got me thinking about this.
So you would "deploy" this contract on a hyperscaler, which then let's users access it from your lean js front-end, via something like this:
const res = await fetch("https://api.hyperscaler-example.com/c/your-contract-id/transfer", {
method: "POST",
headers: {
"Authorization": "Bearer <user-jwt>",
"Content-Type": "application/json"
},
body: JSON.stringify({
from: "user_abc",
to: "user_xyz",
amount: 50
})
});The runtime resolves the caller identity from the JWT, checks the policy rules, runs the function, handles the encryption/decryption of fields and so your frontend never touches any of that.
That's it, would you use it? Is there something that does this exactly already? Feeling like building this.