sonr/x/did/builder/options.go

83 lines
3.5 KiB
Go
Raw Normal View History

feature/ipfs vault allocation (#8) * refactor: move constants to genesis.proto * feat: add ipfs_active flag to genesis state * feat: add IPFS connection initialization to keeper * feat: add testnet process-compose * refactor: rename sonr-testnet docker image to sonr-runner * refactor: update docker-vm-release workflow to use 'latest' tag * feat: add permission to workflows * feat: add new service chain execution * feat: add abstract vault class to pkl * feat: use jetpackio/devbox image for runner * feat: introduce dwn for local service worker * refactor: remove unnecessary dockerfile layers * refactor(deploy): Update Dockerfile to copy go.mod and go.sum from the parent directory * build: move Dockerfile to root directory * build: Add Dockerfile for deployment * feat: Update Dockerfile to work with Go project in parent directory * build: Update docker-compose.yaml to use relative paths * feat: Update docker-compose to work with new image and parent git directory * refactor: remove unnecessary test script * <no value> * feat: add test_node script for running node tests * feat: add IPFS cluster to testnet * feat: add docker image for sonr-runner * fix: typo in export path * feat(did): Add Localhost Registration Enabled Genesis Option * feat: add support for Sqlite DB in vault * feat: improve vault model JSON serialization * feat: support querying HTMX endpoint for DID * feat: Add primary key, unique, default, not null, auto increment, and foreign key field types * feat: Add PublicKey model in pkl/vault.pkl * feat: add frontend server * refactor: move dwn.wasm to vfs directory * feat(frontend): remove frontend server implementation * feat: Add a frontend server and web auth protocol * feat: implement new key types for MPC and ZK proofs * fix: Update enum types and DefaultKeyInfos * fix: correct typo in KeyAlgorithm enum * feat(did): add attestation format validation * feat: Add x/did/builder/extractor.go * feat: Update JWK parsing in x/did/builder/extractor.go * feat: Use github.com/onsonr/sonr/x/did/types package * feat: Extract and format public keys from WebAuthn credentials * feat: Introduce a new `mapToJWK` function to convert a map to a `types.JWK` struct * feat: add support for extracting JWK public keys * feat: remove VerificationMethod struct * refactor: extract public key extraction logic * feat: add helper functions to map COSECurveID to JWK curve names * feat: pin initial vault
2024-09-07 18:12:58 -04:00
package builder
import (
"encoding/json"
"github.com/onsonr/sonr/x/did/types"
)
type AuthenticatorResponse struct {
// From the spec https://www.w3.org/TR/webauthn/#dom-authenticatorresponse-clientdatajson
// This attribute contains a JSON serialization of the client data passed to the authenticator
// by the client in its call to either create() or get().
ClientDataJSON URLEncodedBase64 `json:"clientDataJSON"`
}
type AuthenticatorAttestationResponse struct {
// The byte slice of clientDataJSON, which becomes CollectedClientData
AuthenticatorResponse
Transports []string `json:"transports,omitempty"`
AuthenticatorData URLEncodedBase64 `json:"authenticatorData"`
PublicKey URLEncodedBase64 `json:"publicKey"`
PublicKeyAlgorithm int64 `json:"publicKeyAlgorithm"`
// AttestationObject is the byte slice version of attestationObject.
// This attribute contains an attestation object, which is opaque to, and
// cryptographically protected against tampering by, the client. The
// attestation object contains both authenticator data and an attestation
// statement. The former contains the AAGUID, a unique credential ID, and
// the credential public key. The contents of the attestation statement are
// determined by the attestation statement format used by the authenticator.
// It also contains any additional information that the Relying Party's server
// requires to validate the attestation statement, as well as to decode and
// validate the authenticator data along with the JSON-serialized client data.
AttestationObject URLEncodedBase64 `json:"attestationObject"`
}
type PublicKeyCredentialCreationOptions struct {
RelyingParty RelyingPartyEntity `json:"rp"`
User UserEntity `json:"user"`
Challenge URLEncodedBase64 `json:"challenge"`
Parameters []CredentialParameter `json:"pubKeyCredParams,omitempty"`
Timeout int `json:"timeout,omitempty"`
CredentialExcludeList []CredentialDescriptor `json:"excludeCredentials,omitempty"`
AuthenticatorSelection AuthenticatorSelection `json:"authenticatorSelection,omitempty"`
Hints []PublicKeyCredentialHints `json:"hints,omitempty"`
Attestation ConveyancePreference `json:"attestation,omitempty"`
AttestationFormats []AttestationFormat `json:"attestationFormats,omitempty"`
Extensions AuthenticationExtensions `json:"extensions,omitempty"`
}
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
2024-09-11 15:10:54 -04:00
func GetPublicKeyCredentialCreationOptions(origin string, subject string, vaultCID string, params *types.Params) (*PublicKeyCredentialCreationOptions, error) {
feature/ipfs vault allocation (#8) * refactor: move constants to genesis.proto * feat: add ipfs_active flag to genesis state * feat: add IPFS connection initialization to keeper * feat: add testnet process-compose * refactor: rename sonr-testnet docker image to sonr-runner * refactor: update docker-vm-release workflow to use 'latest' tag * feat: add permission to workflows * feat: add new service chain execution * feat: add abstract vault class to pkl * feat: use jetpackio/devbox image for runner * feat: introduce dwn for local service worker * refactor: remove unnecessary dockerfile layers * refactor(deploy): Update Dockerfile to copy go.mod and go.sum from the parent directory * build: move Dockerfile to root directory * build: Add Dockerfile for deployment * feat: Update Dockerfile to work with Go project in parent directory * build: Update docker-compose.yaml to use relative paths * feat: Update docker-compose to work with new image and parent git directory * refactor: remove unnecessary test script * <no value> * feat: add test_node script for running node tests * feat: add IPFS cluster to testnet * feat: add docker image for sonr-runner * fix: typo in export path * feat(did): Add Localhost Registration Enabled Genesis Option * feat: add support for Sqlite DB in vault * feat: improve vault model JSON serialization * feat: support querying HTMX endpoint for DID * feat: Add primary key, unique, default, not null, auto increment, and foreign key field types * feat: Add PublicKey model in pkl/vault.pkl * feat: add frontend server * refactor: move dwn.wasm to vfs directory * feat(frontend): remove frontend server implementation * feat: Add a frontend server and web auth protocol * feat: implement new key types for MPC and ZK proofs * fix: Update enum types and DefaultKeyInfos * fix: correct typo in KeyAlgorithm enum * feat(did): add attestation format validation * feat: Add x/did/builder/extractor.go * feat: Update JWK parsing in x/did/builder/extractor.go * feat: Use github.com/onsonr/sonr/x/did/types package * feat: Extract and format public keys from WebAuthn credentials * feat: Introduce a new `mapToJWK` function to convert a map to a `types.JWK` struct * feat: add support for extracting JWK public keys * feat: remove VerificationMethod struct * refactor: extract public key extraction logic * feat: add helper functions to map COSECurveID to JWK curve names * feat: pin initial vault
2024-09-07 18:12:58 -04:00
chal, err := CreateChallenge()
if err != nil {
return nil, err
}
return &PublicKeyCredentialCreationOptions{
RelyingParty: NewRelayingParty(origin, subject),
User: NewUserEntity(subject, subject, vaultCID),
Parameters: ExtractCredentialParameters(params),
Timeout: 20,
CredentialExcludeList: nil,
Challenge: chal,
AuthenticatorSelection: AuthenticatorSelection{},
Hints: nil,
Attestation: ExtractConveyancePreference(params),
AttestationFormats: ExtractAttestationFormats(params),
Extensions: nil,
}, nil
}
func UnmarshalAuthenticatorResponse(data []byte) (*AuthenticatorResponse, error) {
var ar AuthenticatorResponse
err := json.Unmarshal(data, &ar)
if err != nil {
return nil, err
}
return &ar, nil
}