feat(module,auth): authentication module with arbitrary claims support

This commit is contained in:
2023-02-24 14:40:28 +01:00
parent 7f07e52ae0
commit 640f429580
25 changed files with 558 additions and 261 deletions

View File

@ -60,7 +60,7 @@ func (m *Module) refreshDevices(call goja.FunctionCall, rt *goja.Runtime) goja.V
timeout, err := m.parseTimeout(rawTimeout)
if err != nil {
panic(errors.WithStack(err))
panic(rt.ToValue(errors.WithStack(err)))
}
promise := m.server.NewPromise()
@ -106,7 +106,7 @@ func (m *Module) getDevices(call goja.FunctionCall, rt *goja.Runtime) goja.Value
func (m *Module) loadUrl(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
if len(call.Arguments) < 2 {
panic(errors.WithStack(module.ErrUnexpectedArgumentsNumber))
panic(rt.ToValue(errors.WithStack(module.ErrUnexpectedArgumentsNumber)))
}
deviceUUID := call.Argument(0).String()
@ -116,7 +116,7 @@ func (m *Module) loadUrl(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
timeout, err := m.parseTimeout(rawTimeout)
if err != nil {
panic(errors.WithStack(err))
panic(rt.ToValue(errors.WithStack(err)))
}
promise := m.server.NewPromise()
@ -144,9 +144,9 @@ func (m *Module) loadUrl(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
return m.server.ToValue(promise)
}
func (m *Module) stopCast(call goja.FunctionCall) goja.Value {
func (m *Module) stopCast(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
if len(call.Arguments) < 1 {
panic(errors.WithStack(module.ErrUnexpectedArgumentsNumber))
panic(rt.ToValue(errors.WithStack(module.ErrUnexpectedArgumentsNumber)))
}
deviceUUID := call.Argument(0).String()
@ -154,7 +154,7 @@ func (m *Module) stopCast(call goja.FunctionCall) goja.Value {
timeout, err := m.parseTimeout(rawTimeout)
if err != nil {
panic(errors.WithStack(err))
panic(rt.ToValue(errors.WithStack(err)))
}
promise := m.server.NewPromise()
@ -182,9 +182,9 @@ func (m *Module) stopCast(call goja.FunctionCall) goja.Value {
return m.server.ToValue(promise)
}
func (m *Module) getStatus(call goja.FunctionCall) goja.Value {
func (m *Module) getStatus(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
if len(call.Arguments) < 1 {
panic(errors.WithStack(module.ErrUnexpectedArgumentsNumber))
panic(rt.ToValue(errors.WithStack(module.ErrUnexpectedArgumentsNumber)))
}
deviceUUID := call.Argument(0).String()
@ -192,7 +192,7 @@ func (m *Module) getStatus(call goja.FunctionCall) goja.Value {
timeout, err := m.parseTimeout(rawTimeout)
if err != nil {
panic(errors.WithStack(err))
panic(rt.ToValue(errors.WithStack(err)))
}
promise := m.server.NewPromise()