Add Extism JS Async Lib and State #1

Merged
pn merged 22 commits from feat/sdk into main 2026-01-08 01:06:58 +00:00
6 changed files with 107 additions and 0 deletions
Showing only changes of commit 82a82f6ada - Show all commits

16
internal/types/exec.go Normal file
View File

@@ -0,0 +1,16 @@
package types
import "encoding/json"
// ExecInput represents the input for the exec function
type ExecInput struct {
Filter string `json:"filter"` // GitHub-style filter: "resource:accounts action:sign"
Token string `json:"token"` // UCAN token for authorization
}
// ExecOutput represents the output of the exec function
type ExecOutput struct {
Success bool `json:"success"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}

View File

@@ -0,0 +1,9 @@
// Package types contains the types used by the enclave.
package types
// FilterParams parsed from GitHub-style filter syntax
type FilterParams struct {
Resource string
Action string
Subject string
}

View File

@@ -0,0 +1,12 @@
package types
// GenerateInput represents the input for the generate function
type GenerateInput struct {
Credential string `json:"credential"` // Base64-encoded PublicKeyCredential
}
// GenerateOutput represents the output of the generate function
type GenerateOutput struct {
DID string `json:"did"`
Database []byte `json:"database"`
}

13
internal/types/load.go Normal file
View File

@@ -0,0 +1,13 @@
package types
// LoadInput represents the input for the load function
type LoadInput struct {
Database []byte `json:"database"`
}
// LoadOutput represents the output of the load function
type LoadOutput struct {
Success bool `json:"success"`
DID string `json:"did,omitempty"`
Error string `json:"error,omitempty"`
}

11
internal/types/ping.go Normal file
View File

@@ -0,0 +1,11 @@
package types
type PingInput struct {
Message string `json:"message"`
}
type PingOutput struct {
Success bool `json:"success"`
Message string `json:"message"`
Echo string `json:"echo"`
}

46
internal/types/query.go Normal file
View File

@@ -0,0 +1,46 @@
package types
// QueryInput represents the input for the query function
type QueryInput struct {
DID string `json:"did"`
}
// QueryOutput represents the output of the query function
type QueryOutput struct {
DID string `json:"did"`
Controller string `json:"controller"`
VerificationMethods []VerificationMethod `json:"verification_methods"`
Accounts []Account `json:"accounts"`
Credentials []Credential `json:"credentials"`
}
// VerificationMethod represents a DID verification method
type VerificationMethod struct {
ID string `json:"id"`
Type string `json:"type"`
Controller string `json:"controller"`
PublicKey string `json:"public_key"`
Purpose string `json:"purpose"`
}
// Account represents a derived blockchain account
type Account struct {
Address string `json:"address"`
ChainID string `json:"chain_id"`
CoinType int `json:"coin_type"`
AccountIndex int `json:"account_index"`
AddressIndex int `json:"address_index"`
Label string `json:"label"`
IsDefault bool `json:"is_default"`
}
// Credential represents a WebAuthn credential
type Credential struct {
CredentialID string `json:"credential_id"`
DeviceName string `json:"device_name"`
DeviceType string `json:"device_type"`
Authenticator string `json:"authenticator"`
Transports []string `json:"transports"`
CreatedAt string `json:"created_at"`
LastUsed string `json:"last_used"`
}