mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 01:41:44 +00:00
feature/refactor did state (#10)
* feat(did): remove account types * feat: Refactor Property to Proof in zkprop.go * feat: add ZKP proof mechanism for verifications * fix: return bool and error from pinInitialVault * feat: implement KeyshareSet for managing user and validator keyshares * feat: Update Credential type in protobuf * feat: update credential schema with sign count * feat: migrate and modules to middleware * refactor: rename vault module to ORM * chore(dwn): add service worker registration to index template * feat: integrate service worker for offline functionality * refactor(did): use DIDNamespace enum for verification method in proto reflection * refactor: update protobuf definitions to support Keyshare * feat: expose did keeper in app keepers * Add Motr Web App * refactor: rename motr/handlers/discovery.go to motr/handlers/openid.go * refactor: move session related code to middleware * feat: add database operations for managing assets, chains, and credentials * feat: add htmx support for UI updates * refactor: extract common helper scripts * chore: remove unused storage GUI components * refactor: Move frontend rendering to dedicated handlers * refactor: rename to * refactor: move alert implementation to templ * feat: add alert component with icon, title, and message * feat: add new RequestHeaders struct to store request headers * Feature/create home view (#9) * refactor: move view logic to new htmx handler * refactor: remove unnecessary dependencies * refactor: remove unused dependencies * feat(devbox): integrate air for local development * feat: implement openid connect discovery document * refactor: rename to * refactor(did): update service handling to support DNS discovery * feat: add support for user and validator keyshares * refactor: move keyshare signing logic to signer
This commit is contained in:
+72
-85
@@ -1,42 +1,14 @@
|
||||
@go.Package { name = "github.com/onsonr/sonr/gen/vault" }
|
||||
@go.Package { name = "github.com/onsonr/sonr/internal/db/orm" }
|
||||
|
||||
module vault
|
||||
module orm
|
||||
|
||||
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
|
||||
|
||||
|
||||
abstract class Client {
|
||||
chainId: String
|
||||
keyringBackend: String
|
||||
output: String
|
||||
node: String
|
||||
broadcastMode: String
|
||||
apiUrl: String
|
||||
addressPrefix: String
|
||||
}
|
||||
|
||||
class Sonr extends Client {
|
||||
chainId = "sonr-testnet-1"
|
||||
keyringBackend = "test"
|
||||
output = "json"
|
||||
rpcUrl = "tcp://localhost:26657"
|
||||
broadcastMode = "async"
|
||||
apiUrl = "http://localhost:1317"
|
||||
addressPrefix = "idx"
|
||||
}
|
||||
|
||||
abstract class DB {
|
||||
filename: String
|
||||
}
|
||||
|
||||
class Sqlite extends DB {
|
||||
filename = "vault.db"
|
||||
}
|
||||
|
||||
class PrimaryKey extends go.Field {
|
||||
structTags {
|
||||
["gorm"] = "primaryKey"
|
||||
["gorm"] = "primaryKey,autoIncrement"
|
||||
["json"] = "%{name},omitempty"
|
||||
["query"] = "%{name}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,12 +33,6 @@ class NotNull extends go.Field {
|
||||
}
|
||||
}
|
||||
|
||||
class AutoIncrement extends go.Field {
|
||||
structTags {
|
||||
["gorm"] = "autoIncrement"
|
||||
}
|
||||
}
|
||||
|
||||
class ForeignKey extends go.Field {
|
||||
references: String
|
||||
structTags {
|
||||
@@ -74,19 +40,14 @@ class ForeignKey extends go.Field {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Model {
|
||||
table: String
|
||||
}
|
||||
|
||||
class JsonField extends go.Field {
|
||||
structTags {
|
||||
["json"] = "%{name},omitempty"
|
||||
["param"] = "%{name}"
|
||||
}
|
||||
}
|
||||
|
||||
class Account extends Model {
|
||||
table = "accounts"
|
||||
|
||||
class Account {
|
||||
@PrimaryKey
|
||||
id: UInt
|
||||
|
||||
@@ -97,15 +58,13 @@ class Account extends Model {
|
||||
address: String
|
||||
|
||||
@JsonField
|
||||
publicKey: Dynamic
|
||||
publicKey: String
|
||||
|
||||
@JsonField
|
||||
createdAt: String?
|
||||
}
|
||||
|
||||
class Asset extends Model {
|
||||
table = "assets"
|
||||
|
||||
class Asset {
|
||||
@PrimaryKey
|
||||
id: UInt
|
||||
|
||||
@@ -125,9 +84,7 @@ class Asset extends Model {
|
||||
createdAt: String?
|
||||
}
|
||||
|
||||
class Chain extends Model {
|
||||
table = "chains"
|
||||
|
||||
class Chain {
|
||||
@PrimaryKey
|
||||
id: UInt
|
||||
|
||||
@@ -141,9 +98,7 @@ class Chain extends Model {
|
||||
createdAt: String?
|
||||
}
|
||||
|
||||
class Credential extends Model {
|
||||
table = "credentials"
|
||||
|
||||
class Credential {
|
||||
@PrimaryKey
|
||||
id: UInt
|
||||
|
||||
@@ -160,10 +115,10 @@ class Credential extends Model {
|
||||
origin: String
|
||||
|
||||
@JsonField
|
||||
credentialId: Dynamic
|
||||
credentialId: String
|
||||
|
||||
@JsonField
|
||||
publicKey: Dynamic
|
||||
publicKey: String
|
||||
|
||||
@JsonField
|
||||
transport: String
|
||||
@@ -193,9 +148,7 @@ class Credential extends Model {
|
||||
updatedAt: String?
|
||||
}
|
||||
|
||||
class Profile extends Model {
|
||||
table = "profiles"
|
||||
|
||||
class Profile {
|
||||
@PrimaryKey
|
||||
id: String
|
||||
|
||||
@@ -221,9 +174,7 @@ class Profile extends Model {
|
||||
updatedAt: String?
|
||||
}
|
||||
|
||||
class Property extends Model {
|
||||
table = "properties"
|
||||
|
||||
class Property {
|
||||
@PrimaryKey
|
||||
id: UInt
|
||||
|
||||
@@ -234,15 +185,13 @@ class Property extends Model {
|
||||
key: String
|
||||
|
||||
@JsonField
|
||||
accumulator: Dynamic
|
||||
accumulator: String
|
||||
|
||||
@JsonField
|
||||
propertyKey: Dynamic
|
||||
propertyKey: String
|
||||
}
|
||||
|
||||
class Keyshare extends Model {
|
||||
table = "keyshares"
|
||||
|
||||
class Keyshare {
|
||||
@PrimaryKey
|
||||
id: UInt
|
||||
|
||||
@@ -256,7 +205,7 @@ class Keyshare extends Model {
|
||||
protocol: String
|
||||
|
||||
@JsonField
|
||||
publicKey: Dynamic
|
||||
publicKey: String
|
||||
|
||||
@JsonField
|
||||
role: Int
|
||||
@@ -268,9 +217,7 @@ class Keyshare extends Model {
|
||||
createdAt: String?
|
||||
}
|
||||
|
||||
class PublicKey extends Model {
|
||||
table = "public_keys"
|
||||
|
||||
class PublicKey {
|
||||
@PrimaryKey
|
||||
id: UInt
|
||||
|
||||
@@ -284,24 +231,13 @@ class PublicKey extends Model {
|
||||
encoding: Int
|
||||
|
||||
@JsonField
|
||||
raw: Dynamic
|
||||
|
||||
@JsonField
|
||||
hex: String
|
||||
|
||||
@JsonField
|
||||
multibase: String
|
||||
|
||||
@JsonField
|
||||
jwk: Dynamic
|
||||
jwk: String
|
||||
|
||||
@JsonField
|
||||
createdAt: String?
|
||||
}
|
||||
|
||||
class Permission extends Model {
|
||||
table = "permissions"
|
||||
|
||||
class Permission {
|
||||
@PrimaryKey
|
||||
id: UInt
|
||||
|
||||
@@ -320,3 +256,54 @@ class Permission extends Model {
|
||||
@JsonField
|
||||
updatedAt: String?
|
||||
}
|
||||
|
||||
//
|
||||
// OpenID Connect
|
||||
//
|
||||
|
||||
class DiscoveryDocument {
|
||||
@JsonField
|
||||
issuer: String
|
||||
|
||||
@JsonField
|
||||
authorization_endpoint: String
|
||||
|
||||
@JsonField
|
||||
token_endpoint: String
|
||||
|
||||
@JsonField
|
||||
userinfo_endpoint: String
|
||||
|
||||
@JsonField
|
||||
jwks_uri: String
|
||||
|
||||
@JsonField
|
||||
registration_endpoint: String
|
||||
|
||||
@JsonField
|
||||
scopes_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
response_types_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
response_modes_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
subject_types_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
id_token_signing_alg_values_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
claims_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
grant_types_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
acr_values_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
token_endpoint_auth_methods_supported: List<String>
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
@go.Package { name = "github.com/onsonr/sonr/gen/transactions" }
|
||||
@go.Package { name = "github.com/onsonr/sonr/txns" }
|
||||
|
||||
module transactions
|
||||
|
||||
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
@go.Package { name = "github.com/onsonr/sonr/gen/protocol" }
|
||||
|
||||
module protocol
|
||||
|
||||
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
|
||||
|
||||
class CredentialCreation {
|
||||
response: PublicKeyCredentialCreationOptions = new JsonField { name = "publicKey"; type = "PublicKeyCredentialCreationOptions" }
|
||||
}
|
||||
|
||||
class CredentialAssertion {
|
||||
response: PublicKeyCredentialRequestOptions = new JsonField { name = "publicKey"; type = "PublicKeyCredentialRequestOptions" }
|
||||
}
|
||||
|
||||
class PublicKeyCredentialCreationOptions {
|
||||
relyingParty: RelyingPartyEntity = new JsonField { name = "rp"; type = "RelyingPartyEntity" }
|
||||
user: UserEntity = new JsonField { name = "user"; type = "UserEntity" }
|
||||
challenge: URLEncodedBase64 = new JsonField { name = "challenge"; type = "URLEncodedBase64" }
|
||||
parameters: Listing[CredentialParameter]? = new JsonField { name = "pubKeyCredParams"; type = "[]CredentialParameter" }
|
||||
timeout: Int? = new JsonField { name = "timeout"; type = "int" }
|
||||
credentialExcludeList: Listing[CredentialDescriptor]? = new JsonField { name = "excludeCredentials"; type = "[]CredentialDescriptor" }
|
||||
authenticatorSelection: AuthenticatorSelection? = new JsonField { name = "authenticatorSelection"; type = "AuthenticatorSelection" }
|
||||
hints: Listing[PublicKeyCredentialHints]? = new JsonField { name = "hints"; type = "[]PublicKeyCredentialHints" }
|
||||
attestation: ConveyancePreference? = new JsonField { name = "attestation"; type = "ConveyancePreference" }
|
||||
attestationFormats: Listing[AttestationFormat]? = new JsonField { name = "attestationFormats"; type = "[]AttestationFormat" }
|
||||
extensions: AuthenticationExtensions? = new JsonField { name = "extensions"; type = "AuthenticationExtensions" }
|
||||
}
|
||||
|
||||
class PublicKeyCredentialRequestOptions {
|
||||
challenge: URLEncodedBase64 = new JsonField { name = "challenge"; type = "URLEncodedBase64" }
|
||||
timeout: Int? = new JsonField { name = "timeout"; type = "int" }
|
||||
relyingPartyID: String? = new JsonField { name = "rpId"; type = "string" }
|
||||
allowedCredentials: Listing[CredentialDescriptor]? = new JsonField { name = "allowCredentials"; type = "[]CredentialDescriptor" }
|
||||
userVerification: UserVerificationRequirement? = new JsonField { name = "userVerification"; type = "UserVerificationRequirement" }
|
||||
hints: Listing[PublicKeyCredentialHints]? = new JsonField { name = "hints"; type = "[]PublicKeyCredentialHints" }
|
||||
extensions: AuthenticationExtensions? = new JsonField { name = "extensions"; type = "AuthenticationExtensions" }
|
||||
|
||||
function getAllowedCredentialIDs(): Listing[Listing[Int8]] {
|
||||
this.allowedCredentials?.map((credential) -> credential.credentialID) ?? Listing()
|
||||
}
|
||||
}
|
||||
|
||||
class CredentialDescriptor {
|
||||
type: CredentialType = new JsonField { name = "type"; type = "CredentialType" }
|
||||
credentialID: URLEncodedBase64 = new JsonField { name = "id"; type = "URLEncodedBase64" }
|
||||
transport: Listing[AuthenticatorTransport]? = new JsonField { name = "transports"; type = "[]AuthenticatorTransport" }
|
||||
attestationType: String? = new JsonField { name = "-"; type = "string" }
|
||||
}
|
||||
|
||||
class CredentialParameter {
|
||||
type: CredentialType = new JsonField { name = "type"; type = "CredentialType" }
|
||||
algorithm: Int = new JsonField { name = "alg"; type = "int" }
|
||||
}
|
||||
|
||||
typealias CredentialType = String
|
||||
|
||||
const PublicKeyCredentialType: CredentialType = "public-key"
|
||||
|
||||
typealias AuthenticationExtensions = Mapping[String, Dynamic]
|
||||
|
||||
class AuthenticatorSelection {
|
||||
authenticatorAttachment: AuthenticatorAttachment? = new JsonField { name = "authenticatorAttachment"; type = "AuthenticatorAttachment" }
|
||||
requireResidentKey: Boolean? = new JsonField { name = "requireResidentKey"; type = "bool" }
|
||||
residentKey: ResidentKeyRequirement? = new JsonField { name = "residentKey"; type = "ResidentKeyRequirement" }
|
||||
userVerification: UserVerificationRequirement? = new JsonField { name = "userVerification"; type = "UserVerificationRequirement" }
|
||||
}
|
||||
|
||||
typealias ConveyancePreference = String
|
||||
|
||||
const PreferNoAttestation: ConveyancePreference = "none"
|
||||
const PreferIndirectAttestation: ConveyancePreference = "indirect"
|
||||
const PreferDirectAttestation: ConveyancePreference = "direct"
|
||||
const PreferEnterpriseAttestation: ConveyancePreference = "enterprise"
|
||||
|
||||
typealias AttestationFormat = String
|
||||
|
||||
const AttestationFormatPacked: AttestationFormat = "packed"
|
||||
const AttestationFormatTPM: AttestationFormat = "tpm"
|
||||
const AttestationFormatAndroidKey: AttestationFormat = "android-key"
|
||||
const AttestationFormatAndroidSafetyNet: AttestationFormat = "android-safetynet"
|
||||
const AttestationFormatFIDOUniversalSecondFactor: AttestationFormat = "fido-u2f"
|
||||
const AttestationFormatApple: AttestationFormat = "apple"
|
||||
const AttestationFormatNone: AttestationFormat = "none"
|
||||
|
||||
typealias PublicKeyCredentialHints = String
|
||||
|
||||
const PublicKeyCredentialHintSecurityKey: PublicKeyCredentialHints = "security-key"
|
||||
const PublicKeyCredentialHintClientDevice: PublicKeyCredentialHints = "client-device"
|
||||
const PublicKeyCredentialHintHybrid: PublicKeyCredentialHints = "hybrid"
|
||||
|
||||
typealias Extensions = Dynamic
|
||||
|
||||
class ServerResponse {
|
||||
status: ServerResponseStatus = new JsonField { name = "status"; type = "ServerResponseStatus" }
|
||||
message: String = new JsonField { name = "errorMessage"; type = "string" }
|
||||
}
|
||||
|
||||
typealias ServerResponseStatus = String
|
||||
|
||||
const StatusOk: ServerResponseStatus = "ok"
|
||||
const StatusFailed= ServerResponseStatus = "failed"
|
||||
Reference in New Issue
Block a user