Add Extism JS Async Lib and State #1
31
db/db.go
Normal file
31
db/db.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
|
||||
PrepareContext(context.Context, string) (*sql.Stmt, error)
|
||||
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
|
||||
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
170
db/models.go
Normal file
170
db/models.go
Normal file
@@ -0,0 +1,170 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
ID int64 `json:"id"`
|
||||
DidID int64 `json:"did_id"`
|
||||
KeyShareID int64 `json:"key_share_id"`
|
||||
Address string `json:"address"`
|
||||
ChainID string `json:"chain_id"`
|
||||
CoinType int64 `json:"coin_type"`
|
||||
AccountIndex int64 `json:"account_index"`
|
||||
AddressIndex int64 `json:"address_index"`
|
||||
Label *string `json:"label"`
|
||||
IsDefault int64 `json:"is_default"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
type Credential struct {
|
||||
ID int64 `json:"id"`
|
||||
DidID int64 `json:"did_id"`
|
||||
CredentialID string `json:"credential_id"`
|
||||
PublicKey string `json:"public_key"`
|
||||
PublicKeyAlg int64 `json:"public_key_alg"`
|
||||
Aaguid *string `json:"aaguid"`
|
||||
SignCount int64 `json:"sign_count"`
|
||||
Transports json.RawMessage `json:"transports"`
|
||||
DeviceName string `json:"device_name"`
|
||||
DeviceType string `json:"device_type"`
|
||||
Authenticator *string `json:"authenticator"`
|
||||
IsDiscoverable int64 `json:"is_discoverable"`
|
||||
BackedUp int64 `json:"backed_up"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
LastUsed string `json:"last_used"`
|
||||
}
|
||||
|
||||
type Delegation struct {
|
||||
ID int64 `json:"id"`
|
||||
DidID int64 `json:"did_id"`
|
||||
UcanID int64 `json:"ucan_id"`
|
||||
Delegator string `json:"delegator"`
|
||||
Delegate string `json:"delegate"`
|
||||
Resource string `json:"resource"`
|
||||
Action string `json:"action"`
|
||||
Caveats json.RawMessage `json:"caveats"`
|
||||
ParentID *int64 `json:"parent_id"`
|
||||
Depth int64 `json:"depth"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
ExpiresAt *string `json:"expires_at"`
|
||||
}
|
||||
|
||||
type DidDocument struct {
|
||||
ID int64 `json:"id"`
|
||||
Did string `json:"did"`
|
||||
Controller string `json:"controller"`
|
||||
Document json.RawMessage `json:"document"`
|
||||
Sequence int64 `json:"sequence"`
|
||||
LastSynced string `json:"last_synced"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type Grant struct {
|
||||
ID int64 `json:"id"`
|
||||
DidID int64 `json:"did_id"`
|
||||
ServiceID int64 `json:"service_id"`
|
||||
UcanID *int64 `json:"ucan_id"`
|
||||
Scopes json.RawMessage `json:"scopes"`
|
||||
Accounts json.RawMessage `json:"accounts"`
|
||||
Status string `json:"status"`
|
||||
GrantedAt string `json:"granted_at"`
|
||||
LastUsed *string `json:"last_used"`
|
||||
ExpiresAt *string `json:"expires_at"`
|
||||
}
|
||||
|
||||
type KeyShare struct {
|
||||
ID int64 `json:"id"`
|
||||
DidID int64 `json:"did_id"`
|
||||
ShareID string `json:"share_id"`
|
||||
KeyID string `json:"key_id"`
|
||||
PartyIndex int64 `json:"party_index"`
|
||||
Threshold int64 `json:"threshold"`
|
||||
TotalParties int64 `json:"total_parties"`
|
||||
Curve string `json:"curve"`
|
||||
ShareData string `json:"share_data"`
|
||||
PublicKey string `json:"public_key"`
|
||||
ChainCode *string `json:"chain_code"`
|
||||
DerivationPath *string `json:"derivation_path"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
RotatedAt *string `json:"rotated_at"`
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
ID int64 `json:"id"`
|
||||
Origin string `json:"origin"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
LogoUrl *string `json:"logo_url"`
|
||||
Did *string `json:"did"`
|
||||
IsVerified int64 `json:"is_verified"`
|
||||
Metadata json.RawMessage `json:"metadata"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
ID int64 `json:"id"`
|
||||
DidID int64 `json:"did_id"`
|
||||
CredentialID int64 `json:"credential_id"`
|
||||
SessionID string `json:"session_id"`
|
||||
DeviceInfo json.RawMessage `json:"device_info"`
|
||||
IsCurrent int64 `json:"is_current"`
|
||||
LastActivity string `json:"last_activity"`
|
||||
ExpiresAt string `json:"expires_at"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
type SyncCheckpoint struct {
|
||||
ID int64 `json:"id"`
|
||||
DidID int64 `json:"did_id"`
|
||||
ResourceType string `json:"resource_type"`
|
||||
LastBlock int64 `json:"last_block"`
|
||||
LastTxHash *string `json:"last_tx_hash"`
|
||||
LastSynced string `json:"last_synced"`
|
||||
}
|
||||
|
||||
type UcanRevocation struct {
|
||||
ID int64 `json:"id"`
|
||||
UcanCid string `json:"ucan_cid"`
|
||||
RevokedBy string `json:"revoked_by"`
|
||||
Reason *string `json:"reason"`
|
||||
RevokedAt string `json:"revoked_at"`
|
||||
}
|
||||
|
||||
type UcanToken struct {
|
||||
ID int64 `json:"id"`
|
||||
DidID int64 `json:"did_id"`
|
||||
Cid string `json:"cid"`
|
||||
Issuer string `json:"issuer"`
|
||||
Audience string `json:"audience"`
|
||||
Subject *string `json:"subject"`
|
||||
Capabilities json.RawMessage `json:"capabilities"`
|
||||
ProofChain json.RawMessage `json:"proof_chain"`
|
||||
NotBefore *string `json:"not_before"`
|
||||
ExpiresAt string `json:"expires_at"`
|
||||
Nonce *string `json:"nonce"`
|
||||
Facts json.RawMessage `json:"facts"`
|
||||
Signature string `json:"signature"`
|
||||
RawToken string `json:"raw_token"`
|
||||
IsRevoked int64 `json:"is_revoked"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
type VerificationMethod struct {
|
||||
ID int64 `json:"id"`
|
||||
DidID int64 `json:"did_id"`
|
||||
MethodID string `json:"method_id"`
|
||||
MethodType string `json:"method_type"`
|
||||
Controller string `json:"controller"`
|
||||
PublicKey string `json:"public_key"`
|
||||
Purpose string `json:"purpose"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
118
db/querier.go
Normal file
118
db/querier.go
Normal file
@@ -0,0 +1,118 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type Querier interface {
|
||||
ArchiveKeyShare(ctx context.Context, id int64) error
|
||||
CleanExpiredUCANs(ctx context.Context) error
|
||||
CountActiveGrants(ctx context.Context, didID int64) (int64, error)
|
||||
CountCredentialsByDID(ctx context.Context, didID int64) (int64, error)
|
||||
CreateAccount(ctx context.Context, arg CreateAccountParams) (Account, error)
|
||||
CreateCredential(ctx context.Context, arg CreateCredentialParams) (Credential, error)
|
||||
CreateDID(ctx context.Context, arg CreateDIDParams) (DidDocument, error)
|
||||
CreateDelegation(ctx context.Context, arg CreateDelegationParams) (Delegation, error)
|
||||
CreateGrant(ctx context.Context, arg CreateGrantParams) (Grant, error)
|
||||
CreateKeyShare(ctx context.Context, arg CreateKeyShareParams) (KeyShare, error)
|
||||
CreateRevocation(ctx context.Context, arg CreateRevocationParams) error
|
||||
CreateService(ctx context.Context, arg CreateServiceParams) (Service, error)
|
||||
CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
|
||||
CreateUCAN(ctx context.Context, arg CreateUCANParams) (UcanToken, error)
|
||||
CreateVerificationMethod(ctx context.Context, arg CreateVerificationMethodParams) (VerificationMethod, error)
|
||||
DeleteAccount(ctx context.Context, arg DeleteAccountParams) error
|
||||
DeleteCredential(ctx context.Context, arg DeleteCredentialParams) error
|
||||
DeleteExpiredSessions(ctx context.Context) error
|
||||
DeleteKeyShare(ctx context.Context, arg DeleteKeyShareParams) error
|
||||
DeleteSession(ctx context.Context, id int64) error
|
||||
DeleteVerificationMethod(ctx context.Context, id int64) error
|
||||
GetAccountByAddress(ctx context.Context, address string) (Account, error)
|
||||
GetCredentialByID(ctx context.Context, credentialID string) (Credential, error)
|
||||
GetCurrentSession(ctx context.Context, didID int64) (Session, error)
|
||||
// =============================================================================
|
||||
// DID DOCUMENT QUERIES
|
||||
// =============================================================================
|
||||
GetDIDByDID(ctx context.Context, did string) (DidDocument, error)
|
||||
GetDIDByID(ctx context.Context, id int64) (DidDocument, error)
|
||||
GetDefaultAccount(ctx context.Context, arg GetDefaultAccountParams) (Account, error)
|
||||
GetDelegationChain(ctx context.Context, arg GetDelegationChainParams) ([]Delegation, error)
|
||||
GetGrantByService(ctx context.Context, arg GetGrantByServiceParams) (Grant, error)
|
||||
GetKeyShareByID(ctx context.Context, shareID string) (KeyShare, error)
|
||||
GetKeyShareByKeyID(ctx context.Context, arg GetKeyShareByKeyIDParams) (KeyShare, error)
|
||||
GetServiceByID(ctx context.Context, id int64) (Service, error)
|
||||
// =============================================================================
|
||||
// SERVICE QUERIES
|
||||
// =============================================================================
|
||||
GetServiceByOrigin(ctx context.Context, origin string) (Service, error)
|
||||
GetSessionByID(ctx context.Context, sessionID string) (Session, error)
|
||||
// =============================================================================
|
||||
// SYNC QUERIES
|
||||
// =============================================================================
|
||||
GetSyncCheckpoint(ctx context.Context, arg GetSyncCheckpointParams) (SyncCheckpoint, error)
|
||||
GetUCANByCID(ctx context.Context, cid string) (UcanToken, error)
|
||||
GetVerificationMethod(ctx context.Context, arg GetVerificationMethodParams) (VerificationMethod, error)
|
||||
IsUCANRevoked(ctx context.Context, ucanCid string) (int64, error)
|
||||
ListAccountsByChain(ctx context.Context, arg ListAccountsByChainParams) ([]Account, error)
|
||||
// =============================================================================
|
||||
// ACCOUNT QUERIES
|
||||
// =============================================================================
|
||||
ListAccountsByDID(ctx context.Context, didID int64) ([]ListAccountsByDIDRow, error)
|
||||
ListAllDIDs(ctx context.Context) ([]DidDocument, error)
|
||||
// =============================================================================
|
||||
// CREDENTIAL QUERIES
|
||||
// =============================================================================
|
||||
ListCredentialsByDID(ctx context.Context, didID int64) ([]Credential, error)
|
||||
ListDelegationsByDelegate(ctx context.Context, delegate string) ([]Delegation, error)
|
||||
// =============================================================================
|
||||
// DELEGATION QUERIES
|
||||
// =============================================================================
|
||||
ListDelegationsByDelegator(ctx context.Context, delegator string) ([]Delegation, error)
|
||||
ListDelegationsForResource(ctx context.Context, arg ListDelegationsForResourceParams) ([]Delegation, error)
|
||||
// =============================================================================
|
||||
// GRANT QUERIES
|
||||
// =============================================================================
|
||||
ListGrantsByDID(ctx context.Context, didID int64) ([]ListGrantsByDIDRow, error)
|
||||
// =============================================================================
|
||||
// KEY SHARE QUERIES
|
||||
// =============================================================================
|
||||
ListKeySharesByDID(ctx context.Context, didID int64) ([]KeyShare, error)
|
||||
// =============================================================================
|
||||
// SESSION QUERIES
|
||||
// =============================================================================
|
||||
ListSessionsByDID(ctx context.Context, didID int64) ([]ListSessionsByDIDRow, error)
|
||||
ListSyncCheckpoints(ctx context.Context, didID int64) ([]SyncCheckpoint, error)
|
||||
ListUCANsByAudience(ctx context.Context, audience string) ([]UcanToken, error)
|
||||
// =============================================================================
|
||||
// UCAN TOKEN QUERIES
|
||||
// =============================================================================
|
||||
ListUCANsByDID(ctx context.Context, didID int64) ([]UcanToken, error)
|
||||
// =============================================================================
|
||||
// VERIFICATION METHOD QUERIES
|
||||
// =============================================================================
|
||||
ListVerificationMethods(ctx context.Context, didID int64) ([]VerificationMethod, error)
|
||||
ListVerifiedServices(ctx context.Context) ([]Service, error)
|
||||
ReactivateGrant(ctx context.Context, id int64) error
|
||||
RenameCredential(ctx context.Context, arg RenameCredentialParams) error
|
||||
RevokeDelegation(ctx context.Context, id int64) error
|
||||
RevokeDelegationChain(ctx context.Context, arg RevokeDelegationChainParams) error
|
||||
RevokeGrant(ctx context.Context, id int64) error
|
||||
RevokeUCAN(ctx context.Context, cid string) error
|
||||
RotateKeyShare(ctx context.Context, id int64) error
|
||||
SetCurrentSession(ctx context.Context, arg SetCurrentSessionParams) error
|
||||
SetDefaultAccount(ctx context.Context, arg SetDefaultAccountParams) error
|
||||
SuspendGrant(ctx context.Context, id int64) error
|
||||
UpdateAccountLabel(ctx context.Context, arg UpdateAccountLabelParams) error
|
||||
UpdateCredentialCounter(ctx context.Context, arg UpdateCredentialCounterParams) error
|
||||
UpdateDIDDocument(ctx context.Context, arg UpdateDIDDocumentParams) error
|
||||
UpdateGrantLastUsed(ctx context.Context, id int64) error
|
||||
UpdateGrantScopes(ctx context.Context, arg UpdateGrantScopesParams) error
|
||||
UpdateService(ctx context.Context, arg UpdateServiceParams) error
|
||||
UpdateSessionActivity(ctx context.Context, id int64) error
|
||||
UpsertSyncCheckpoint(ctx context.Context, arg UpsertSyncCheckpointParams) error
|
||||
}
|
||||
|
||||
var _ Querier = (*Queries)(nil)
|
||||
16
db/query.sql
16
db/query.sql
@@ -293,13 +293,7 @@ WHERE did_id = ? AND resource = ? AND status = 'active'
|
||||
ORDER BY depth, created_at;
|
||||
|
||||
-- name: GetDelegationChain :many
|
||||
WITH RECURSIVE chain AS (
|
||||
SELECT * FROM delegations WHERE id = ?
|
||||
UNION ALL
|
||||
SELECT d.* FROM delegations d
|
||||
JOIN chain c ON d.id = c.parent_id
|
||||
)
|
||||
SELECT * FROM chain ORDER BY depth DESC;
|
||||
SELECT * FROM delegations WHERE id = ? OR parent_id = ? ORDER BY depth DESC;
|
||||
|
||||
-- name: CreateDelegation :one
|
||||
INSERT INTO delegations (
|
||||
@@ -312,13 +306,7 @@ RETURNING *;
|
||||
UPDATE delegations SET status = 'revoked' WHERE id = ?;
|
||||
|
||||
-- name: RevokeDelegationChain :exec
|
||||
WITH RECURSIVE chain AS (
|
||||
SELECT id FROM delegations WHERE id = ?
|
||||
UNION ALL
|
||||
SELECT d.id FROM delegations d
|
||||
JOIN chain c ON d.parent_id = c.id
|
||||
)
|
||||
UPDATE delegations SET status = 'revoked' WHERE id IN (SELECT id FROM chain);
|
||||
UPDATE delegations SET status = 'revoked' WHERE id = ? OR parent_id = ?;
|
||||
|
||||
-- =============================================================================
|
||||
-- SYNC QUERIES
|
||||
|
||||
1996
db/query.sql.go
Normal file
1996
db/query.sql.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user