node

package
v1.2.0-pre.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TOTPCode      = "totp_code"
	TOTPSecretKey = "totp_secret_key"
	TOTPQR        = "totp_qr"
	TOTPUnlink    = "totp_unlink"
)
View Source
const (
	LookupReveal     = "lookup_secret_reveal"
	LookupRegenerate = "lookup_secret_regenerate"
	LookupDisable    = "lookup_secret_disable"
	LookupCodes      = "lookup_secret_codes"
	LookupConfirm    = "lookup_secret_confirm"
	LookupCodeEnter  = "lookup_secret"
)
View Source
const (
	WebAuthnRegisterTrigger     = "webauthn_register_trigger"
	WebAuthnRegister            = "webauthn_register"
	WebAuthnLogin               = "webauthn_login"
	WebAuthnLoginTrigger        = "webauthn_login_trigger"
	WebAuthnRegisterDisplayName = "webauthn_register_displayname"
	WebAuthnRemove              = "webauthn_remove"
	WebAuthnScript              = "webauthn_script"
)
View Source
const (
	PasskeyRegisterTrigger  = "passkey_register_trigger"
	PasskeyRegister         = "passkey_register"
	PasskeySettingsRegister = "passkey_settings_register"
	PasskeyCreateData       = "passkey_create_data"
	PasskeyLogin            = "passkey_login"
	PasskeyChallenge        = "passkey_challenge"
	PasskeyLoginTrigger     = "passkey_login_trigger" //#nosec G101 -- Not a credential
	PasskeyRemove           = "passkey_remove"
)
View Source
const DisableFormField = "disableFormField"
View Source
const (
	ProfileChooseCredentials = "profile_choose_credentials"
)

Variables

This section is empty.

Functions

func PasswordLoginOrder

func PasswordLoginOrder(in []string) []string

func SortByGroups

func SortByGroups(orderByGroups []UiNodeGroup) func(*sortOptions)

func SortBySchema

func SortBySchema(schemaRef string) func(*sortOptions)

func SortUpdateOrder

func SortUpdateOrder(f func([]string) []string) func(*sortOptions)

func SortUseOrder

func SortUseOrder(keysInOrder []string) func(*sortOptions)

func SortUseOrderAppend

func SortUseOrderAppend(keysInOrder []string) func(*sortOptions)

func WithImageAttributes

func WithImageAttributes(f func(a *ImageAttributes)) func(a *ImageAttributes)

func WithInputAttributes

func WithInputAttributes(f func(a *InputAttributes)) func(a *InputAttributes)

func WithRequiredInputAttribute

func WithRequiredInputAttribute(a *InputAttributes)

Types

type AnchorAttributes

type AnchorAttributes struct {
	// The link's href (destination) URL.
	//
	// format: uri
	// required: true
	HREF string `json:"href"`

	// The link's title.
	//
	// required: true
	Title *text.Message `json:"title"`

	// A unique identifier
	//
	// required: true
	Identifier string `json:"id"`

	// NodeType represents this node's types. It is a mirror of `node.type` and
	// is primarily used to allow compatibility with OpenAPI 3.0.  In this struct it technically always is "a".
	//
	// required: true
	NodeType UiNodeType `json:"node_type"`
}

AnchorAttributes represents the attributes of an anchor node.

swagger:model uiNodeAnchorAttributes

func (*AnchorAttributes) GetNodeType

func (a *AnchorAttributes) GetNodeType() UiNodeType

func (*AnchorAttributes) GetValue

func (a *AnchorAttributes) GetValue() interface{}

func (*AnchorAttributes) ID

func (a *AnchorAttributes) ID() string

func (*AnchorAttributes) Reset

func (a *AnchorAttributes) Reset()

func (*AnchorAttributes) SetValue

func (a *AnchorAttributes) SetValue(value interface{})

type Attributes

type Attributes interface {
	// swagger:ignore
	ID() string

	// swagger:ignore
	Reset()

	// swagger:ignore
	SetValue(value interface{})

	// swagger:ignore
	GetValue() interface{}

	// swagger:ignore
	GetNodeType() UiNodeType
}

Attributes represents a list of attributes (e.g. `href="foo"` for links).

swagger:model uiNodeAttributes

type ImageAttributes

type ImageAttributes struct {
	// The image's source URL.
	//
	// format: uri
	// required: true
	Source string `json:"src"`

	// A unique identifier
	//
	// required: true
	Identifier string `json:"id"`

	// Width of the image
	//
	// required: true
	Width int `json:"width"`

	// Height of the image
	//
	// required: true
	Height int `json:"height"`

	// NodeType represents this node's types. It is a mirror of `node.type` and
	// is primarily used to allow compatibility with OpenAPI 3.0.  In this struct it technically always is "img".
	//
	// required: true
	NodeType UiNodeType `json:"node_type"`
}

ImageAttributes represents the attributes of an image node.

swagger:model uiNodeImageAttributes

func (*ImageAttributes) GetNodeType

func (a *ImageAttributes) GetNodeType() UiNodeType

func (*ImageAttributes) GetValue

func (a *ImageAttributes) GetValue() interface{}

func (*ImageAttributes) ID

func (a *ImageAttributes) ID() string

func (*ImageAttributes) Reset

func (a *ImageAttributes) Reset()

func (*ImageAttributes) SetValue

func (a *ImageAttributes) SetValue(value interface{})

type ImageAttributesModifier

type ImageAttributesModifier func(attributes *ImageAttributes)

type ImageAttributesModifiers

type ImageAttributesModifiers []ImageAttributesModifier

type InputAttributes

type InputAttributes struct {
	// The input's element name.
	//
	// required: true
	Name string `json:"name"`

	// The input's element type.
	//
	// required: true
	Type UiNodeInputAttributeType `json:"type" faker:"-"`

	// The input's value.
	FieldValue interface{} `json:"value,omitempty" faker:"string"`

	// Mark this input field as required.
	Required bool `json:"required,omitempty"`

	// The autocomplete attribute for the input.
	Autocomplete UiNodeInputAttributeAutocomplete `json:"autocomplete,omitempty"`

	// The input's label text.
	Label *text.Message `json:"label,omitempty"`

	// The input's pattern.
	Pattern string `json:"pattern,omitempty"`

	// Sets the input's disabled field to true or false.
	//
	// required: true
	Disabled bool `json:"disabled"`

	// OnClick may contain javascript which should be executed on click. This is primarily
	// used for WebAuthn.
	OnClick string `json:"onclick,omitempty"`

	// OnLoad may contain javascript which should be executed on load. This is primarily
	// used for WebAuthn.
	OnLoad string `json:"onload,omitempty"`

	// NodeType represents this node's types. It is a mirror of `node.type` and
	// is primarily used to allow compatibility with OpenAPI 3.0.  In this struct it technically always is "input".
	//
	// required: true
	NodeType UiNodeType `json:"node_type"`
}

InputAttributes represents the attributes of an input node

swagger:model uiNodeInputAttributes

func (*InputAttributes) GetNodeType

func (a *InputAttributes) GetNodeType() UiNodeType

func (*InputAttributes) GetValue

func (a *InputAttributes) GetValue() interface{}

func (*InputAttributes) ID

func (a *InputAttributes) ID() string

func (*InputAttributes) Reset

func (a *InputAttributes) Reset()

func (*InputAttributes) SetValue

func (a *InputAttributes) SetValue(value interface{})

type InputAttributesModifier

type InputAttributesModifier func(attributes *InputAttributes)

type InputAttributesModifiers

type InputAttributesModifiers []InputAttributesModifier

type Meta

type Meta struct {
	// Label represents the node's label.
	//
	// Keep in mind that these values are autogenerated and can not be changed.
	// If you wish to use other titles or labels implement that directly in
	// your UI.
	Label *text.Message `json:"label,omitempty"`
}

A Node's Meta Information

This might include a label and other information that can optionally be used to render UIs.

swagger:model uiNodeMeta

type Node

type Node struct {
	// The node's type
	//
	// required: true
	Type UiNodeType `json:"type" faker:"-"`

	// Group specifies which group (e.g. password authenticator) this node belongs to.
	//
	// required: true
	Group UiNodeGroup `json:"group"`

	// The node's attributes.
	//
	// required: true
	// swagger:type uiNodeAttributes
	Attributes Attributes `json:"attributes" faker:"ui_node_attributes"`

	// The node's messages
	//
	// Contains error, validation, or other messages relevant to this node.
	//
	// required: true
	Messages text.Messages `json:"messages"`

	// Meta contains a node meta information
	//
	// This might include a label and other information that can optionally
	// be used to render UIs.
	//
	// required: true
	Meta *Meta `json:"meta"`
}

Node represents a flow's nodes

Nodes are represented as HTML elements or their native UI equivalents. For example, a node can be an `<img>` tag, or an `<input element>` but also `some plain text`.

swagger:model uiNode

func NewAnchorField

func NewAnchorField(id string, href string, group UiNodeGroup, title *text.Message) *Node

func NewCSRFNode

func NewCSRFNode(token string) *Node

func NewImageField

func NewImageField(id string, src string, group UiNodeGroup, opts ...ImageAttributesModifier) *Node

func NewInputField

func NewInputField(name string, value interface{}, group UiNodeGroup, inputType UiNodeInputAttributeType, opts ...InputAttributesModifier) *Node

func NewInputFieldFromJSON

func NewInputFieldFromJSON(name string, value interface{}, group UiNodeGroup, opts ...InputAttributesModifier) *Node

func NewInputFieldFromSchema

func NewInputFieldFromSchema(name string, group UiNodeGroup, p jsonschemax.Path, opts ...InputAttributesModifier) *Node

func NewScriptField

func NewScriptField(name string, src string, group UiNodeGroup, integrity string, opts ...ScriptAttributesModifier) *Node

func NewTextField

func NewTextField(id string, text *text.Message, group UiNodeGroup) *Node

func (*Node) GetValue

func (n *Node) GetValue() interface{}

func (*Node) ID

func (n *Node) ID() string

func (*Node) MarshalJSON

func (n *Node) MarshalJSON() ([]byte, error)

func (*Node) Reset

func (n *Node) Reset()

func (*Node) UnmarshalJSON

func (n *Node) UnmarshalJSON(data []byte) error

func (*Node) WithMetaLabel

func (n *Node) WithMetaLabel(label *text.Message) *Node

type Nodes

type Nodes []*Node

swagger:model uiNodes

func (*Nodes) Append

func (n *Nodes) Append(node *Node)

Append appends a node.

func (Nodes) Find

func (n Nodes) Find(id string) *Node

func (*Nodes) Remove

func (n *Nodes) Remove(ids ...string)

Remove removes one or more nodes by their IDs.

func (Nodes) Reset

func (n Nodes) Reset(exclude ...string)

func (Nodes) ResetNodes

func (n Nodes) ResetNodes(reset ...string)

func (Nodes) ResetNodesWithPrefix

func (n Nodes) ResetNodesWithPrefix(prefix string)

func (*Nodes) SetValueAttribute

func (n *Nodes) SetValueAttribute(id string, value interface{}) bool

SetValueAttribute sets a node's attribute's value or returns false if no node is found.

func (Nodes) SortBySchema

func (n Nodes) SortBySchema(ctx context.Context, opts ...SortOption) error

func (*Nodes) Upsert

func (n *Nodes) Upsert(node *Node)

Upsert updates or appends a node.

type ScriptAttributes

type ScriptAttributes struct {
	// The script source
	//
	// required: true
	Source string `json:"src"`

	// The script async type
	//
	// required: true
	Async bool `json:"async"`

	// The script referrer policy
	//
	// required: true
	ReferrerPolicy string `json:"referrerpolicy"`

	// The script cross origin policy
	//
	// required: true
	CrossOrigin string `json:"crossorigin"`

	// The script's integrity hash
	//
	// required: true
	Integrity string `json:"integrity"`

	// The script MIME type
	//
	// required: true
	Type string `json:"type"`

	// A unique identifier
	//
	// required: true
	Identifier string `json:"id"`

	// Nonce for CSP
	//
	// A nonce you may want to use to improve your Content Security Policy.
	// You do not have to use this value but if you want to improve your CSP
	// policies you may use it. You can also choose to use your own nonce value!
	//
	// required: true
	Nonce string `json:"nonce"`

	// NodeType represents this node's types. It is a mirror of `node.type` and
	// is primarily used to allow compatibility with OpenAPI 3.0. In this struct it technically always is "script".
	//
	// required: true
	NodeType UiNodeType `json:"node_type"`
}

ScriptAttributes represent script nodes which load javascript.

swagger:model uiNodeScriptAttributes

func (*ScriptAttributes) GetNodeType

func (a *ScriptAttributes) GetNodeType() UiNodeType

func (*ScriptAttributes) GetValue

func (a *ScriptAttributes) GetValue() interface{}

func (*ScriptAttributes) ID

func (a *ScriptAttributes) ID() string

func (*ScriptAttributes) Reset

func (a *ScriptAttributes) Reset()

func (*ScriptAttributes) SetValue

func (a *ScriptAttributes) SetValue(value interface{})

type ScriptAttributesModifier

type ScriptAttributesModifier func(attributes *ScriptAttributes)

type ScriptAttributesModifiers

type ScriptAttributesModifiers []ScriptAttributesModifier

type SortOption

type SortOption func(*sortOptions)

type TextAttributes

type TextAttributes struct {
	// The text of the text node.
	//
	// required: true
	Text *text.Message `json:"text"`

	// A unique identifier
	//
	// required: true
	Identifier string `json:"id"`

	// NodeType represents this node's types. It is a mirror of `node.type` and
	// is primarily used to allow compatibility with OpenAPI 3.0.  In this struct it technically always is "text".
	//
	// required: true
	NodeType UiNodeType `json:"node_type"`
}

TextAttributes represents the attributes of a text node.

swagger:model uiNodeTextAttributes

func (*TextAttributes) GetNodeType

func (a *TextAttributes) GetNodeType() UiNodeType

func (*TextAttributes) GetValue

func (a *TextAttributes) GetValue() interface{}

func (*TextAttributes) ID

func (a *TextAttributes) ID() string

func (*TextAttributes) Reset

func (a *TextAttributes) Reset()

func (*TextAttributes) SetValue

func (a *TextAttributes) SetValue(value interface{})

type UiNodeGroup

type UiNodeGroup string

swagger:enum UiNodeGroup

const (
	DefaultGroup       UiNodeGroup = "default"
	PasswordGroup      UiNodeGroup = "password"
	OpenIDConnectGroup UiNodeGroup = "oidc"
	ProfileGroup       UiNodeGroup = "profile"
	LinkGroup          UiNodeGroup = "link"
	CodeGroup          UiNodeGroup = "code"
	TOTPGroup          UiNodeGroup = "totp"
	LookupGroup        UiNodeGroup = "lookup_secret"
	WebAuthnGroup      UiNodeGroup = "webauthn"
	PasskeyGroup       UiNodeGroup = "passkey"
)

func (UiNodeGroup) String

func (g UiNodeGroup) String() string

type UiNodeInputAttributeAutocomplete added in v0.11.0

type UiNodeInputAttributeAutocomplete string

swagger:enum UiNodeInputAttributeAutocomplete

const (
	InputAttributeAutocompleteEmail           UiNodeInputAttributeAutocomplete = "email"
	InputAttributeAutocompleteTel             UiNodeInputAttributeAutocomplete = "tel"
	InputAttributeAutocompleteUrl             UiNodeInputAttributeAutocomplete = "url"
	InputAttributeAutocompleteCurrentPassword UiNodeInputAttributeAutocomplete = "current-password"
	InputAttributeAutocompleteNewPassword     UiNodeInputAttributeAutocomplete = "new-password"
	InputAttributeAutocompleteOneTimeCode     UiNodeInputAttributeAutocomplete = "one-time-code"
)

type UiNodeInputAttributeType added in v0.11.0

type UiNodeInputAttributeType string

swagger:enum UiNodeInputAttributeType

const (
	InputAttributeTypeText          UiNodeInputAttributeType = "text"
	InputAttributeTypePassword      UiNodeInputAttributeType = "password"
	InputAttributeTypeNumber        UiNodeInputAttributeType = "number"
	InputAttributeTypeCheckbox      UiNodeInputAttributeType = "checkbox"
	InputAttributeTypeHidden        UiNodeInputAttributeType = "hidden"
	InputAttributeTypeEmail         UiNodeInputAttributeType = "email"
	InputAttributeTypeTel           UiNodeInputAttributeType = "tel"
	InputAttributeTypeSubmit        UiNodeInputAttributeType = "submit"
	InputAttributeTypeButton        UiNodeInputAttributeType = "button"
	InputAttributeTypeDateTimeLocal UiNodeInputAttributeType = "datetime-local"
	InputAttributeTypeDate          UiNodeInputAttributeType = "date"
	InputAttributeTypeURI           UiNodeInputAttributeType = "url"
)

type UiNodeType

type UiNodeType string

swagger:enum UiNodeType

const (
	Text   UiNodeType = "text"
	Input  UiNodeType = "input"
	Image  UiNodeType = "img"
	Anchor UiNodeType = "a"
	Script UiNodeType = "script"
)

func (UiNodeType) String

func (t UiNodeType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL