actionauthor

package
v1.334.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package actionauthor binds local authoring sessions to authorized Credimi builds.

Index

Constants

View Source
const (
	PlatformAndroid = "android"
	PlatformIOS     = "ios"
)

Supported authoring platforms; each selects the wallet version installer field.

View Source
const (
	SourceInstaller = "installer"
	SourceStore     = "store"
	// StoreVersionTag labels store builds in the build options.
	StoreVersionTag = "store install"
)

Build sources: an installer uploaded to a wallet version, or the wallet's Play Store app installed at session start (Android only: the iOS simulator has no App Store).

View Source
const (
	ReferenceCredimiRecord   = "credimi_record"
	ReferenceCredentialOffer = "credential_offer_deeplink"
	ReferencePresentation    = "presentation_deeplink"
	ReferenceUnknown         = "unknown"
)

Kinds of a ReferenceResolution.

View Source
const (
	OutcomeSuccess   = "success"
	OutcomeRejection = "rejection"
	OutcomeWait      = "wait"
)

Outcomes of an authored action.

View Source
const (
	SourceCredentialOffer     = "credential_offer"
	SourceUseCaseVerification = "use_case_verification"
	SourceHTTP                = "http"
	SourceLiteral             = "literal"
)

Parameter source kinds.

View Source
const (

	// ApprovalLifetime bounds how long a signed approval can be used by Save.
	ApprovalLifetime = 30 * time.Minute
)
View Source
const ExternalSourceVersion = "installed_from_external_source"

ExternalSourceVersion is the version_id of a pipeline step whose wallet was installed outside Credimi, as from the store.

View Source
const MaxWaitSeconds = 600

MaxWaitSeconds bounds the wait of a wait action.

View Source
const PlayStoreAppID = "com.android.vending"

PlayStoreAppID is the store app an Android install-app action may target besides the wallet.

View Source
const SlotInstallApp = "install-app"

SlotInstallApp is the slot, and category, of the action installing a store wallet.

View Source
const SourceBodyLimit = 1 << 20

SourceBodyLimit bounds the bodies Credimi reads from the http sources and credential offer URIs the agent names.

View Source
const (
	StepUseMobileAutomation = "mobile-automation"
)

Step uses and `with` keys of the pipeline steps a failed run's plan is suggested from, as in the workflow payload structs (workflows.MobileAutomationWorkflowPipelinePayload, workflows.GetCredentialOfferWorkflowPayload, workflows.GetUseCaseVerificationDeeplinkWorkflowPayload, activities.HTTPActivityPayload), which this package cannot import.

Variables

View Source
var (
	ErrForbidden = errors.New("authoring access denied")
	ErrInvalid   = errors.New("invalid authoring request")
	ErrConflict  = errors.New("authoring approval is stale or conflicts with an existing action")
)

ErrForbidden denies unauthorized actors or organization namespaces. ErrInvalid rejects malformed authoring input. ErrConflict rejects stale approvals and unconfirmed replacements.

View Source
var ErrSessionNotVisible = errors.New("action author session is not visible in Temporal yet")

ErrSessionNotVisible reports that Temporal does not list a run of a session workflow (yet: its visibility record can lag behind its start).

View Source
var Slots = map[string]SlotRule{
	"onboarding":   {Category: "onboarding", Prerequisites: PrereqForbidden},
	SlotInstallApp: {Category: SlotInstallApp, Prerequisites: PrereqForbidden},
	"get-credential": {
		Category:      "get-credential-generic",
		Prerequisites: PrereqRequired,
		Rejection:     true,
	},
	"get-credential-specific": {
		Category:      "get-credential-specific",
		Prerequisites: PrereqRequired,
		Rejection:     true,
	},
	"verify-credential": {
		Category:      "verify-credential",
		Prerequisites: PrereqRequired,
		Rejection:     true,
	},
	"other": {
		Category:      "other",
		Prerequisites: PrereqOptional,
		Rejection:     true,
		Wait:          true,
	},
}

Slots lists the action categories the agent can author. install-app: the agent installs a store wallet; only for wallets selected from the Play Store, so Android only.

Functions

func ActionParameters

func ActionParameters(code string) []string

ActionParameters returns the sorted unique bare ${name} references of an action YAML, minus the keys of its header env map.

func AllowedAppIDs

func AllowedAppIDs(packageID, slot, platform string) []string

AllowedAppIDs returns the app IDs an action may target (header appId, launchApp, setPermissions): the package under test and, for an Android install-app action, the Play Store app. Web flows open the device's default browser with openLink instead of targeting it.

func CheckRecordAccess

func CheckRecordAccess(app core.App, collection, path, orgID string) (*core.Record, error)

CheckRecordAccess resolves a canonified path to a record of the collection that is published or owned by the organization.

func CheckReplaceTarget

func CheckReplaceTarget(app core.App, selection Selection, spec *Spec) (*core.Record, error)

CheckReplaceTarget checks the action the spec replaces, if any, and returns its record; nil without Replaces. The target must be an action of the selected wallet owned by the selected organization (a published action of another organization is refused), of the slot's category and not one of the spec's prerequisites. An empty CodeSHA256 is filled with the hash of the target's current code; another hash must still match it, unless the record holds exactly what a save replacing that hash wrote, so Save can recognize its own retry.

func CheckSpecRecords

func CheckSpecRecords(app core.App, selection Selection, spec *Spec) ([]*core.Record, error)

CheckSpecRecords checks that every record the spec names is accessible to the selected organization, and returns the prerequisite actions in order. Prerequisites must be actions of the selected wallet and receive exactly the parameters their code references.

func CodeSHA256

func CodeSHA256(code string) string

CodeSHA256 hashes the exact YAML bytes reviewed by the human.

func IsSessionID

func IsSessionID(id string) bool

IsSessionID reports whether id has the form of the session workflow IDs Credimi starts: ActionAuthorSession-<runner record id>-<lowercase ticket uuid>.

func LookupPath

func LookupPath(v any, path string) (string, bool)

LookupPath reads a dot-separated path in decoded JSON; numeric segments index arrays. It returns strings and numbers only.

func MaestroFailure

func MaestroFailure(stdout string) (string, string)

MaestroFailure returns the first command Maestro reports as FAILED in stdout (empty without one) and the last 40 non-empty lines that are not JVM noise, at most 4000 characters, keeping the end.

func ParameterDescription

func ParameterDescription(src SourceSpec) string

ParameterDescription tells the agent what a parameter's values are, without revealing them.

func ParameterNames

func ParameterNames(parameters []ParameterSpec) []string

ParameterNames returns the names of a parameter list, in order.

func PlanSHA256

func PlanSHA256(s Spec) string

PlanSHA256 hashes the JSON encoding of a normalized spec.

func PlanSummary

func PlanSummary(
	s Spec,
	prerequisites []ResolvedPrerequisite,
	replaces *ReplaceTarget,
) []string

PlanSummary describes a normalized plan in lines for the agent: every parameter source in full, so it can tell the user what each run will call. Indented lines detail the line above them. replaces is the action the plan replaces, nil without one.

func SessionNamespace

func SessionNamespace(sessionID string) (string, bool)

SessionNamespace returns the Temporal namespace sessionID runs in: its runner's agent namespace.

func SessionRunnerID

func SessionRunnerID(sessionID string) (string, bool)

SessionRunnerID returns the record ID of the runner sessionID runs on.

func SessionWallet

func SessionWallet(walletVersionIdentifier string) string

SessionWallet returns the wallet (organization/wallet) of a session's wallet_version_identifier: its first two segments.

func SessionWorkflowID

func SessionWorkflowID(runnerID, ticketID string) string

SessionWorkflowID is the workflow ID of the session that ticketID starts on a device of runnerID.

func SignApproval

func SignApproval(app core.App, a Approval) (string, error)

SignApproval returns the token base64url(json).base64url(hmac).

func SignRun

func SignRun(app core.App, g RunGrant) (string, error)

SignRun returns the token base64url(json).base64url(hmac) of g.

func SignSession

func SignSession(app core.App, g SessionGrant) (string, error)

SignSession returns the token base64url(json).base64url(hmac) of g.

func SignTicket

func SignTicket(app core.App, g SessionGrant) (string, error)

SignTicket returns Credimi's signature of the session g that POST /api/action-author/sessions enqueues after its checks. Its key differs from SignSession's, so a ticket token copied from the semaphore's history is never a session grant.

func SlotCategory

func SlotCategory(slot string) string

SlotCategory returns the wallet_actions category of a slot.

func SlotForCategory

func SlotForCategory(category string) (string, bool)

SlotForCategory returns the slot whose actions are saved with category.

func StatusTemplateHost

func StatusTemplateHost(template string) (string, error)

StatusTemplateHost returns the host of a status URL template, its ${capture} references replaced by a placeholder. Validation refuses a host that contains the placeholder, so the check activity can require the filled URL to keep exactly this host.

func StoreLinks(slot, platform, packageID, storeURL string) []string

StoreLinks returns the store pages an install-app action may open with openLink: none for another slot or platform; on Android the Play Store page of packageID in its two forms plus the wallet's own storeURL. An empty storeURL adds nothing.

func ValidateCode

func ValidateCode(code string, scope CodeScope) []string

ValidateCode returns every reason a Maestro action cannot be accepted, once each and in discovery order; an empty result means the action is valid.

func VerifyRun

func VerifyRun(app core.App, token string, want RunGrant) error

VerifyRun accepts only a run token Credimi signed for exactly want.

func VerifySession

func VerifySession(app core.App, token string, want SessionGrant) error

VerifySession accepts only a token Credimi signed for exactly want. It has no expiry: the grant names the ticket's unique session workflow, and every caller also requires that session to be running.

func VerifyTicket

func VerifyTicket(app core.App, token string, want SessionGrant) error

VerifyTicket accepts only a ticket token Credimi signed for exactly want: the start activity signs a session only for a ticket Credimi enqueued.

Types

type Actor

type Actor struct {
	ActorID string `json:"actor_id"`
}

Actor identifies the authenticated Credimi user that started the workflow.

type Allowance

type Allowance struct {
	Pool   Pool
	Tokens int
}

Allowance is a runner's daily token limit for one pool: 0 is no limit for PoolOwn and not offered for PoolOthers.

func AllowanceFor

func AllowanceFor(runner *core.Record, orgID string) Allowance

AllowanceFor returns the runner's allowance for sessions of orgID: the own pool when the runner belongs to orgID, the others pool otherwise.

func (Allowance) Exhausted

func (a Allowance) Exhausted(runner *core.Record, now time.Time) bool

Exhausted reports whether the usage the runner reported for today's UTC day reached the pool's limit. A pool without a limit is never exhausted.

func (Allowance) Limited

func (a Allowance) Limited() bool

Limited reports whether the pool has a daily token limit.

func (Allowance) Offered

func (a Allowance) Offered() bool

Offered reports whether the runner offers the agent to the pool at all.

type Approval

type Approval struct {
	AuthorWorkflowID string `json:"author_workflow_id"`
	CandidateSHA256  string `json:"candidate_sha256"`
	ApproverID       string `json:"approver_id"`
	ApprovedAt       int64  `json:"approved_at"`
	// PlanSHA256 binds the approval to the plan the session saves with.
	PlanSHA256 string `json:"plan_sha256"`
}

Approval is a human's acceptance of one candidate of one ActionAuthor workflow, signed by Credimi.

func VerifyApproval

func VerifyApproval(
	app core.App,
	token, authorWorkflowID, candidateSHA256 string,
	now time.Time,
) (Approval, error)

VerifyApproval accepts only an unexpired token Credimi signed for this workflow and candidate; every other token is ErrForbidden.

type Build

type Build struct {
	WalletID          string `json:"wallet_id"`
	VersionID         string `json:"version_id"`
	VersionIdentifier string `json:"version_identifier"`
	OwnerNamespace    string `json:"owner_namespace"`
	Platform          string `json:"platform"`
	InstallerSHA256   string `json:"installer_sha256"`
	Source            string `json:"source"`
	PackageID         string `json:"package_id,omitempty"`
	StoreURL          string `json:"store_url,omitempty"`
}

Build binds an authorized wallet version to its platform installer digest, or an authorized wallet to its store app. VersionID and InstallerSHA256 are empty for store builds.

func Resolve

func Resolve(app core.App, organization string, in BuildRequest) (Build, error)

Resolve hashes the authorized platform installer, the provenance Save checks. The runner installs the installer itself, through the pipeline device code. Store builds have no installer: the session installs their app from the store. organization is the caller's organization, as for Select. OwnerNamespace is the wallet owner's namespace, which owns the build.

type BuildOption

type BuildOption struct {
	Identifier       string   `json:"identifier"`
	WalletName       string   `json:"wallet_name"`
	OrganizationName string   `json:"organization_name"`
	VersionTag       string   `json:"version_tag"`
	Platforms        []string `json:"platforms"`
	Source           string   `json:"source"`
}

BuildOption describes one build the actor can select for authoring and its platforms.

func ListBuildOptions

func ListBuildOptions(app core.App, in Actor) ([]BuildOption, error)

ListBuildOptions returns the builds Select authorizes for the actor: builds of the caller's organization's wallets and of published wallets of other organizations (store builds, and downloadable versions). A user without an organization gets none.

type BuildRequest

type BuildRequest struct {
	Actor
	WalletVersionIdentifier string `json:"wallet_version_identifier"`
	Platform                string `json:"platform"`
}

BuildRequest selects an existing wallet version and platform on behalf of its authenticated actor.

type CodeScope

type CodeScope struct {
	AppIDs      []string
	Parameters  []string
	StoreLinks  []string
	WaitSeconds int
}

CodeScope is what an action may use: AppIDs are the apps it may target, Parameters the session parameter names it may reference as `${name}`, and StoreLinks the store pages it may open. WaitSeconds is the wait of a wait action (0 for any other action): its last command must wait that long instead of asserting an outcome.

type HTTPSourceRequest

type HTTPSourceRequest struct {
	Method  string            `json:"method"`
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers,omitempty"`
	Body    any               `json:"body,omitempty"`
}

HTTPSourceRequest is the HTTP call of an http source.

type ParameterInfo

type ParameterInfo struct {
	Name        string `json:"name"`
	Kind        string `json:"kind"`
	Description string `json:"description"`
	HasStatus   bool   `json:"has_status"`
}

ParameterInfo describes a runtime parameter of the authored action; its values are generated by Credimi, never shown to the agent.

func ParameterInfos

func ParameterInfos(s Spec) []ParameterInfo

ParameterInfos describes the spec's own parameters, in order.

type ParameterSpec

type ParameterSpec struct {
	Name   string     `json:"name"`
	Source SourceSpec `json:"source"`
}

ParameterSpec names a runtime parameter and the source of its fresh values.

type PipelineRunFailure

type PipelineRunFailure struct {
	StepID          string   `json:"step_id"`
	Action          string   `json:"action"`
	ActionName      string   `json:"action_name"`
	Candidates      []string `json:"candidates"`
	Owned           bool     `json:"owned"`
	InSessionWallet bool     `json:"in_session_wallet"`
	Version         string   `json:"version"`
	Code            string   `json:"code"`
	Message         string   `json:"message"`
	FailedCommand   string   `json:"failed_command"`
	OutputTail      string   `json:"output_tail"`
	Plan            *Spec    `json:"plan"`
	Notes           []string `json:"notes"`
}

PipelineRunFailure is a failed mobile-automation step of a pipeline run: the action it ran, why it failed and a suggested plan to fix it.

func DescribeFailedStep

func DescribeFailedStep(
	app core.App,
	selection Selection,
	definition *pipeline.WorkflowDefinition,
	stepIndex int,
	failure StepFailure,
) (PipelineRunFailure, error)

DescribeFailedStep describes the failed mobile-automation step definition.Steps[stepIndex] for the session's selection: the stored action it ran (accessible to the session's organization), its owner and wallet, the version it ran and, for one stored action, a suggested plan.

type PipelineRunRef

type PipelineRunRef struct {
	WorkflowID string
	RunID      string
	Pipeline   string
}

PipelineRunRef names a pipeline run (WorkflowID, with RunID empty for its latest run) or a pipeline (Pipeline) whose latest failed run is meant.

func ParsePipelineRunReference

func ParsePipelineRunReference(text string) (PipelineRunRef, error)

ParsePipelineRunReference reads a run URL (/my/tests/runs/<workflow>[/<run>]), a pipeline URL (/my/pipelines/<org>/<pipeline>, /hub/pipelines/<org>/<pipeline>), a bare pipeline workflow ID or a bare org/pipeline path. Only the path of a URL counts.

type Pool

type Pool string

Pool is whose sessions a runner's usage counts: the runner's own organization, or every other organization together.

const (
	PoolOwn    Pool = "own"
	PoolOthers Pool = "others"
)

Usage pools of a runner.

type PrereqRule

type PrereqRule int

PrereqRule says whether a slot's action starts from prerequisite actions.

const (
	PrereqForbidden PrereqRule = iota
	PrereqRequired
	PrereqOptional
)

Prerequisite rules of the slots.

type PrerequisiteSpec

type PrerequisiteSpec struct {
	Action     string          `json:"action"` // canonified wallet action path org/wallet/action
	Parameters []ParameterSpec `json:"parameters,omitempty"`
}

PrerequisiteSpec is a stored action that builds the starting state, with values for its own parameters.

type Provenance

type Provenance struct {
	WalletVersionID         string                `json:"wallet_version_id"`
	WalletVersionIdentifier string                `json:"wallet_version_identifier"`
	Platform                string                `json:"platform"`
	Source                  string                `json:"source"`
	InstallerSHA256         string                `json:"installer_sha256"`
	PackageID               string                `json:"package_id"`
	InstalledVersion        string                `json:"installed_version,omitempty"`
	YAMLSHA256              string                `json:"yaml_sha256"`
	WorkflowID              string                `json:"workflow_id"`
	RunID                   string                `json:"run_id"`
	ReplayCount             int                   `json:"replay_count"`
	Slot                    string                `json:"slot"`
	Outcome                 string                `json:"outcome"`
	WaitSeconds             int                   `json:"wait_seconds,omitempty"`
	Prerequisites           []string              `json:"prerequisites"`
	Parameters              []ProvenanceParameter `json:"parameters"`
	ApproverID              string                `json:"approver_id"`
	ApprovedAt              string                `json:"approved_at"`
	// ReplacedCodeSHA256 is the hash of the code a replacing save overwrote.
	ReplacedCodeSHA256 string `json:"replaced_code_sha256,omitempty"`
}

Provenance identifies the exact build, spec, workflow and human approval that validated an action. Store builds have no version or installer digest: InstalledVersion is the store app version the session reported.

type ProvenanceParameter

type ProvenanceParameter struct {
	Name string `json:"name"`
	Kind string `json:"kind"`
}

ProvenanceParameter records a parameter's name and source kind, never its values.

type Receipt

type Receipt struct {
	RecordID   string     `json:"record_id"`
	Name       string     `json:"name"`
	Created    bool       `json:"created"`
	Replaced   bool       `json:"replaced"`
	Published  bool       `json:"published"`
	Provenance Provenance `json:"provenance"`
}

Receipt describes the saved record and its validation provenance.

func Save

func Save(
	app core.App,
	organization, workflowID, runID string,
	in SaveRequest,
	approval Approval,
) (Receipt, error)

Save stores the accepted action and its provenance in one transaction. Without Replaces it creates the action: a name already in use by the wallet is a conflict, except for a retry of the same workflow run that wrote it. With Replaces it rewrites the target's name, code, category and provenance in place, keeping its id and published flag, when the target still has the code the plan was checked against. The caller is the trusted workflow's explicit human-confirmation handler, after verifying the approval; organization is the session's organization, as for Select.

type ReferenceResolution

type ReferenceResolution struct {
	Kind    string            `json:"kind"`
	Sources []ReferenceSource `json:"sources"`
	Decoded map[string]string `json:"decoded,omitempty"`
	Note    string            `json:"note,omitempty"`
}

ReferenceResolution classifies a reference the user gave the agent and the parameter sources it maps to.

func ResolveReference

func ResolveReference(
	ctx context.Context,
	app core.App,
	orgID, text string,
	client *http.Client,
) (ReferenceResolution, error)

ResolveReference turns a Credimi URL, canonified path or deeplink into the parameter sources the organization can use. client fetches an https credential_offer_uri within ctx; a raw deeplink is never opened.

type ReferenceSource

type ReferenceSource struct {
	Label  string     `json:"label"`
	Source SourceSpec `json:"source"`
}

ReferenceSource is a parameter source a reference maps to.

type ReplaceSpec

type ReplaceSpec struct {
	Action     string `json:"action"`                // canonified org/wallet/action path
	CodeSHA256 string `json:"code_sha256,omitempty"` // CodeSHA256 of the action's code when the plan was checked
}

ReplaceSpec is the existing action a plan rewrites in place, and the hash of its code when the plan was checked: the approval binds both.

type ReplaceTarget

type ReplaceTarget struct {
	Action   string `json:"action"`
	Name     string `json:"name"`
	Category string `json:"category"`
	Code     string `json:"code"`
}

ReplaceTarget is the action a checked plan replaces, with its current code.

type ResolvedPrerequisite

type ResolvedPrerequisite struct {
	Action     string   `json:"action"`
	Name       string   `json:"name"`
	Code       string   `json:"code"`
	Parameters []string `json:"parameters"`
}

ResolvedPrerequisite is a prerequisite action the agent runs before exploring and before every replay.

func ResolvePrerequisites

func ResolvePrerequisites(
	app core.App,
	selection Selection,
	spec *Spec,
) ([]ResolvedPrerequisite, error)

ResolvePrerequisites checks the spec's records like CheckSpecRecords, requires each prerequisite's own starting actions (its recorded starts_from) before it, in the same order, and returns its prerequisite actions in order, with their code. Only direct chains are checked: each prerequisite's own chain was checked when it was saved.

type RunGrant

type RunGrant struct {
	SessionWorkflowID string `json:"session_workflow_id"`
	RunID             string `json:"run_id"`
}

RunGrant is Credimi's signature of the run it started for a session: the start activity signals it to that run, so a run started later under the same ID with a copied start input never carries a valid one.

type SaveRequest

type SaveRequest struct {
	BuildRequest
	Name             string `json:"name"`
	Code             string `json:"code"`
	CandidateSHA256  string `json:"candidate_sha256"`
	InstallerSHA256  string `json:"installer_sha256"`
	PackageID        string `json:"package_id"`
	InstalledVersion string `json:"installed_version,omitempty"`
	ReplayCount      int    `json:"replay_count"`
	Approval         string `json:"approval"`
	Spec             Spec   `json:"plan"`
}

SaveRequest carries the trusted workflow's accepted candidate, the Credimi-signed approval of its human review and the plan Check action author plan returned, which the activity checks again for the session.

type Selection

type Selection struct {
	Version      *core.Record
	Wallet       *core.Record
	Organization *core.Record
	WalletOwner  *core.Record
	Actor        Actor
	Identifier   string
	Platform     string
	Source       string
	PackageID    string
	StoreURL     string
}

Selection holds the records reauthorized for a build operation. Version is nil for store selections, whose app is PackageID on the store page StoreURL. Organization is the caller's organization, which owns saved actions and whose records the session may use; WalletOwner owns the wallet and its build, and differs from Organization for published wallets of other organizations.

func Select

func Select(app core.App, organization string, in BuildRequest) (Selection, error)

Select authorizes members of an organization, the same rule as pipeline runs: the actor's organization is its first one. The wallet must be its own, or a published wallet of another organization, whose versions are accepted only when their installer is downloadable. `organization/wallet/version` selects an uploaded installer and `organization/wallet` the wallet's Play Store app (Android only). organization is the canonified_name of the caller's organization, the one the session acts for. An empty organization skips that check; activities must pass the organization of their verified session, never a value from their payload.

func (Selection) Installer

func (s Selection) Installer() string

Installer returns the stored filename of the selected platform's installer, empty for store selections.

type SessionGrant

type SessionGrant struct {
	SessionWorkflowID       string `json:"session_workflow_id"`
	Namespace               string `json:"namespace"`
	Organization            string `json:"organization"`
	DeviceID                string `json:"device_id"`
	Platform                string `json:"platform"`
	WalletVersionIdentifier string `json:"wallet_version_identifier"`
	ActorID                 string `json:"actor_id"`
}

SessionGrant is Credimi's signature of a session it started after its membership, device and allowance checks. Namespace is the Temporal namespace the session runs in (its runner's); Organization is the canonified_name of the organization it was started for.

type SlotRule

type SlotRule struct {
	Category      string
	Prerequisites PrereqRule
	Rejection     bool
	Wait          bool
}

SlotRule describes one action category the agent can author.

type SourceSpec

type SourceSpec struct {
	Kind       string             `json:"kind"` // credential_offer | use_case_verification | http | literal
	Identifier string             `json:"identifier,omitempty"`
	Value      string             `json:"value,omitempty"`
	Request    *HTTPSourceRequest `json:"request,omitempty"`
	ValuePath  string             `json:"value_path,omitempty"`
	Captures   map[string]string  `json:"captures,omitempty"`
	Status     *StatusSpec        `json:"status,omitempty"`
}

SourceSpec generates a parameter value: a Credimi credential offer, a use-case verification, a declared HTTP call or a fixed value.

type Spec

type Spec struct {
	Slot          string             `json:"slot"`
	Outcome       string             `json:"outcome,omitempty"` // "success" (default) | "rejection" | "wait"
	WaitSeconds   int                `json:"wait_seconds,omitempty"`
	Prerequisites []PrerequisiteSpec `json:"prerequisites,omitempty"`
	Parameters    []ParameterSpec    `json:"parameters,omitempty"`
	// Replaces names the caller's own action this plan rewrites in place.
	Replaces *ReplaceSpec `json:"replaces,omitempty"`
}

Spec describes the action a session authors: its slot, expected outcome, starting state and runtime parameters. A wait action keeps the device idle for WaitSeconds: its code ends with extendedWaitUntil on a visible condition, optional: true and timeout: WaitSeconds * 1000 (see ValidateCode).

func SuggestPlan

func SuggestPlan(
	app core.App,
	definition *pipeline.WorkflowDefinition,
	stepIndex int,
	action *core.Record,
	selection Selection,
) (Spec, []string, error)

SuggestPlan suggests the plan that fixes action, the stored action that definition.Steps[stepIndex] runs: the slot of its category, a success outcome, the action itself as replaced when the selection's organization owns it, the earlier steps' actions of its wallet as prerequisites and the step's parameters as sources. The notes say what could not be translated. The plan is not checked: describe_action checks it.

func (*Spec) Normalize

func (s *Spec) Normalize() error

Normalize sets the default outcome and validates the spec.

type StatusSpec

type StatusSpec struct {
	URL       string   `json:"url"` // may contain ${capture}
	Path      string   `json:"path"`
	Success   []string `json:"success,omitempty"`
	Rejection []string `json:"rejection,omitempty"`
}

StatusSpec is the protocol session status an http source's issuer or verifier must reach after the action ran.

type StepFailure

type StepFailure struct {
	Code    string
	Message string
	Stdout  string
}

StepFailure is the failure a pipeline recorded for one step.

type WalletAction

type WalletAction struct {
	Path       string   `json:"path"`
	Name       string   `json:"name"`
	Category   string   `json:"category"`
	Published  bool     `json:"published"`
	Owned      bool     `json:"owned"`
	Parameters []string `json:"parameters"`
	StartsFrom []string `json:"starts_from"`
}

WalletAction is one action a session can run as a prerequisite. StartsFrom lists the actions it was saved to start from, in order. Owned actions belong to the caller's organization: only they can be replaced.

func ListWalletActions

func ListWalletActions(app core.App, selection Selection, category string) ([]WalletAction, error)

ListWalletActions returns the selected wallet's actions that the caller's organization (selection.Organization, not the wallet's owner) owns or that are published, sorted by category then name. A non-empty category keeps only that category.

Jump to

Keyboard shortcuts

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