You've already forked pocketbase
mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-11-24 23:24:00 +02:00
aliased and soft-deprecated NewToken with NewJWT, added encrypt/decrypt goja bindings and other minor doc changes
This commit is contained in:
@@ -1,19 +1,3 @@
|
||||
// Package jsvm implements optional utilities for binding a JS goja runtime
|
||||
// to the PocketBase instance (loading migrations, attaching to app hooks, etc.).
|
||||
//
|
||||
// Currently it provides the following plugins:
|
||||
//
|
||||
// 1. JS Migrations loader:
|
||||
//
|
||||
// jsvm.MustRegisterMigrations(app, jsvm.MigrationsConfig{
|
||||
// Dir: "/custom/js/migrations/dir", // default to "pb_data/../pb_migrations"
|
||||
// })
|
||||
//
|
||||
// 2. JS app hooks:
|
||||
//
|
||||
// jsvm.MustRegisterHooks(app, jsvm.HooksConfig{
|
||||
// Dir: "/custom/js/hooks/dir", // default to "pb_data/../pb_hooks"
|
||||
// })
|
||||
package jsvm
|
||||
|
||||
import (
|
||||
@@ -216,9 +200,21 @@ func securityBinds(vm *goja.Runtime) {
|
||||
obj.Set("pseudorandomStringWithAlphabet", security.PseudorandomStringWithAlphabet)
|
||||
|
||||
// jwt
|
||||
obj.Set("parseUnverifiedToken", security.ParseUnverifiedJWT)
|
||||
obj.Set("parseToken", security.ParseJWT)
|
||||
obj.Set("createToken", security.NewToken)
|
||||
obj.Set("parseUnverifiedJWT", security.ParseUnverifiedJWT)
|
||||
obj.Set("parseJWT", security.ParseJWT)
|
||||
obj.Set("createJWT", security.NewJWT)
|
||||
|
||||
// encryption
|
||||
obj.Set("encrypt", security.Encrypt)
|
||||
obj.Set("decrypt", func(cipherText, key string) (string, error) {
|
||||
result, err := security.Decrypt(cipherText, key)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(result), err
|
||||
})
|
||||
}
|
||||
|
||||
func filesystemBinds(vm *goja.Runtime) {
|
||||
|
||||
Reference in New Issue
Block a user