orm

package
v6.2.13 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DIDChangeCreated     = "created"
	DIDChangeUpdated     = "updated"
	DIDChangeDeactivated = "deactivated"
)

Variables

This section is empty.

Functions

func NewTestDatabase

func NewTestDatabase(t *testing.T) *gorm.DB

Types

type DID

type DID struct {
	ID      string `gorm:"primaryKey"`
	Subject string `gorm:"column:subject"`
}

DID is the gorm representation of the DID table

func (DID) TableName

func (d DID) TableName() string

type DIDChangeLog

type DIDChangeLog struct {
	DIDDocumentVersionID string `gorm:"primaryKey;column:did_document_version_id"`
	Type                 string
	TransactionID        string      `gorm:"column:transaction_id"`
	DIDDocumentVersion   DidDocument `gorm:"foreignKey:DIDDocumentVersionID;references:ID"`
}

DIDChangeLog represents a log of changes to a DID document It is used as a 2-phase commit log to keep did:nuts/did:web/others in sync.

func (DIDChangeLog) DID

func (d DIDChangeLog) DID() did.DID

DID returns the did.DID of the DID Document

func (DIDChangeLog) Method

func (d DIDChangeLog) Method() string

Method returns the DID method of the DID without the did: prefix

func (DIDChangeLog) TableName

func (d DIDChangeLog) TableName() string

type DIDKeyFlags

type DIDKeyFlags uint

DIDKeyFlags is a bitmask used for specifying for what purposes a key in a DID document can be used (a.k.a. Verification Method relationships).

const (
	// AssertionMethodUsage indicates if the generated key pair can be used for assertions.
	AssertionMethodUsage DIDKeyFlags = 1 << iota
	// AuthenticationUsage indicates if the generated key pair can be used for authentication.
	AuthenticationUsage
	// CapabilityDelegationUsage indicates if the generated key pair can be used for altering DID Documents.
	CapabilityDelegationUsage
	// CapabilityInvocationUsage indicates if the generated key pair can be used for capability invocations.
	CapabilityInvocationUsage
	// KeyAgreementUsage indicates if the generated key pair can be used for Key agreements.
	KeyAgreementUsage
)

func AssertionKeyUsage

func AssertionKeyUsage() DIDKeyFlags

func EncryptionKeyUsage

func EncryptionKeyUsage() DIDKeyFlags

func (DIDKeyFlags) Is

func (k DIDKeyFlags) Is(other DIDKeyFlags) bool

Is returns whether the specified DIDKeyFlags is enabled.

type DidDocument

type DidDocument struct {
	ID        string `gorm:"primaryKey"`
	DidID     string `gorm:"column:did"`
	DID       DID    `gorm:"foreignKey:DidID;references:ID"`
	CreatedAt int64  `gorm:"autoCreateTime"` // auto set unix timestamp iff 0; i.e., when DID is being created
	// UpdatedAt is the (unix) timestamp when the document was updated (and this version was thus created)
	// Also used to purge DID document changes that haven't been committed within a certain time frame
	UpdatedAt           int64 `gorm:"autoUpdateTime:false"`
	Version             int
	VerificationMethods []VerificationMethod `gorm:"many2many:did_document_to_verification_method"`
	Services            []Service            `gorm:"many2many:did_document_to_service"`
	// Raw contains the DID Document as generated by the specific method, important for hashing.
	Raw string
}

DidDocument is the gorm representation of the did_document_version table

func (DidDocument) GenerateDIDDocument

func (sqlDoc DidDocument) GenerateDIDDocument() (did.Document, error)

func (DidDocument) TableName

func (d DidDocument) TableName() string

func (DidDocument) ToDIDDocument

func (sqlDoc DidDocument) ToDIDDocument() (did.Document, error)

type KeyReference

type KeyReference struct {
	KID     string `gorm:"column:kid;primaryKey"`
	KeyName string
	Version string
}

func (KeyReference) TableName

func (d KeyReference) TableName() string

type MigrationDocument

type MigrationDocument struct {
	// Raw contains the did.Document in bytes. For did:nuts this is must be equal to the payload in the network transaction.
	Raw     []byte
	Created time.Time
	Updated time.Time
	Version int
}

MigrationDocument is used to convert a did.Document + metadata to a DidDocument. DEPRECATED: only intended to migrate owned did:nuts to SQL storage.

func (MigrationDocument) ToORMDocument

func (migration MigrationDocument) ToORMDocument(subject string) (DidDocument, error)

ToORMDocument converts the Raw document to a DidDocument. Generates a new DidDocument.ID

type Service

type Service struct {
	ID   string `gorm:"primaryKey"`
	Data []byte
}

Service is the gorm representation of the did_service table

func (Service) TableName

func (v Service) TableName() string

type VerificationMethod

type VerificationMethod struct {
	ID       string `gorm:"primaryKey"`
	KeyTypes VerificationMethodKeyType
	Weight   int16
	Data     []byte
}

VerificationMethod is the gorm representation of the did_verificationmethod table

func (VerificationMethod) TableName

func (v VerificationMethod) TableName() string

type VerificationMethodKeyType

type VerificationMethodKeyType int16

VerificationMethodKeyType is used to marshal and unmarshal the key type to the DB SQL databases use SMALLINT for this type

Jump to

Keyboard shortcuts

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