mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc191fdbba | ||
|
|
875c410443 | ||
|
|
bcf5dfa70c | ||
|
|
77d76938a3 | ||
|
|
1267bc426a | ||
|
|
5e74045f3d | ||
|
|
3adf42925d | ||
|
|
f95fa2c906 | ||
|
|
ac2f65844c | ||
|
|
546dd7b4ad | ||
|
|
fcf4ab5b4f | ||
|
|
c57d5e8f1a | ||
|
|
cd57226a45 | ||
|
|
f5a11061ac | ||
|
|
93a3d814d6 | ||
|
|
a0e24880c3 | ||
|
|
e63ec7f22a |
@@ -2,6 +2,6 @@
|
||||
name = "cz_conventional_commits"
|
||||
tag_format = "v$version"
|
||||
version_scheme = "semver"
|
||||
version = "0.5.5"
|
||||
version = "0.5.7"
|
||||
update_changelog_on_bump = true
|
||||
major_version_zero = true
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
name: Bug Report
|
||||
description: File a bug report.
|
||||
title: "ERROR: "
|
||||
labels: ["#BUG", "#HELP"]
|
||||
projects: ["onsonr/39"]
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Operating System
|
||||
description: What operating system are you using?
|
||||
placeholder: "Example: macOS Big Sur"
|
||||
value: operating system
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: Network
|
||||
description: What network are you using?
|
||||
multiple: false
|
||||
options:
|
||||
- LocalNet
|
||||
- TestNet
|
||||
- MainNet
|
||||
default: 0
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Code of Conduct
|
||||
description:
|
||||
The Code of Conduct helps create a safe space for everyone. We require
|
||||
that everyone agrees to it.
|
||||
options:
|
||||
- label: I agree to follow this project's [Code of Conduct](link/to/coc)
|
||||
required: true
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "Thanks for completing our form!"
|
||||
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Community Discussions
|
||||
url: https://github.com/orgs/onsonr/discussions
|
||||
about: Please submit ideas and suggestions here.
|
||||
@@ -0,0 +1,30 @@
|
||||
name: Tracking issue
|
||||
description: Use this template for tracking new features.
|
||||
title: "(v0.6): FEATURE NAME"
|
||||
labels: ["#TRACK", "#OKR"]
|
||||
assignees: ["prnk28"]
|
||||
projects: ["onsonr/37"]
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Is this associated with a milestone?
|
||||
description: This is a tracking issue for tracking a new feature for a given milestone.
|
||||
options:
|
||||
- label: I have confirmed this is an OKR tracking issue
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Objective
|
||||
description: Explain the objective of the feature and add any relevant links.
|
||||
render: markdown
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Task List
|
||||
description: |
|
||||
Break down the objective into a list of tasks to be completed.
|
||||
value: |
|
||||
- [ ]
|
||||
validations:
|
||||
required: false
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: Default Todo
|
||||
about: Break down feature requirements into tasks.
|
||||
title: "Name of the new task"
|
||||
labels:
|
||||
- "#TODO"
|
||||
- "#OKR"
|
||||
assignees: "prnk28"
|
||||
projects: "onsonr/37"
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
The expected deliverable of the task.
|
||||
|
||||
### Associated Files
|
||||
|
||||
These files will be modified by this task.
|
||||
|
||||
### References
|
||||
|
||||
Use these documents to help you complete the task.
|
||||
@@ -1,3 +1,26 @@
|
||||
## v0.5.7 (2024-10-04)
|
||||
|
||||
### Feat
|
||||
|
||||
- **devbox**: use process-compose for testnet services
|
||||
- remove motr.mjs dependency
|
||||
- add markdown rendering to issue templates
|
||||
- update issue templates for better clarity
|
||||
- add issue templates for tracking and task issues
|
||||
- add issue templates for bug report and tracking
|
||||
- introduce docker-compose based setup
|
||||
|
||||
### Refactor
|
||||
|
||||
- update issue template headings
|
||||
- rename bug-report issue template to bug
|
||||
|
||||
## v0.5.6 (2024-10-03)
|
||||
|
||||
### Feat
|
||||
|
||||
- add hway and sonr processes to dev environment
|
||||
|
||||
## v0.5.5 (2024-10-03)
|
||||
|
||||
### Feat
|
||||
|
||||
@@ -13,13 +13,14 @@ processes:
|
||||
namespace: testnet
|
||||
command: "devbox run start:testnet"
|
||||
restart: on_failure
|
||||
env:
|
||||
max_restarts: 1
|
||||
depends:
|
||||
- ipfs
|
||||
|
||||
motr:
|
||||
hway:
|
||||
namespace: testnet
|
||||
command: "devbox run start:motr"
|
||||
command: "hway start"
|
||||
restart: on_failure
|
||||
max_restarts: 1
|
||||
depends:
|
||||
|
||||
+60
-17
@@ -13,7 +13,7 @@
|
||||
],
|
||||
"env": {
|
||||
"GOPATH": "$HOME/go",
|
||||
"PATH": "$HOME/go/bin:$PATH",
|
||||
"PATH": "./build:$HOME/go/bin:$PATH",
|
||||
"CHAIN_ID": "sonr-testnet-1",
|
||||
"DENOM": "usnr",
|
||||
"KEYRING": "test",
|
||||
@@ -30,22 +30,65 @@
|
||||
},
|
||||
"shell": {
|
||||
"scripts": {
|
||||
"dev": ["air"],
|
||||
"build:docker": ["make local-image"],
|
||||
"build:hway": ["make nebula", "make hway"],
|
||||
"build:nebula": ["make nebula"],
|
||||
"build:sonrd": ["make motr", "make build"],
|
||||
"build": ["make motr", "make build", "make hway"],
|
||||
"gen:proto": ["make proto-gen"],
|
||||
"gen:pkl": ["make pkl"],
|
||||
"gen:templ": ["make templ"],
|
||||
"start:hway": ["make templ", "make hway", "make start-hway"],
|
||||
"start:testnet": ["make templ", "make install", "make sh-testnet"],
|
||||
"start": ["process-compose up -d"],
|
||||
"stop": ["process-compose down"],
|
||||
"test:e2e": ["make templ", "make test-e2e"],
|
||||
"test:unit": ["make templ", "make test-unit"],
|
||||
"test": ["make templ", "make test"]
|
||||
"dev": [
|
||||
"air"
|
||||
],
|
||||
"build:docker": [
|
||||
"make local-image"
|
||||
],
|
||||
"build:hway": [
|
||||
"make nebula",
|
||||
"make hway"
|
||||
],
|
||||
"build:nebula": [
|
||||
"make nebula"
|
||||
],
|
||||
"build:sonrd": [
|
||||
"make motr",
|
||||
"make build"
|
||||
],
|
||||
"build": [
|
||||
"make motr",
|
||||
"make build",
|
||||
"make hway"
|
||||
],
|
||||
"gen:proto": [
|
||||
"make proto-gen"
|
||||
],
|
||||
"gen:pkl": [
|
||||
"make pkl"
|
||||
],
|
||||
"gen:templ": [
|
||||
"make templ"
|
||||
],
|
||||
"start:hway": [
|
||||
"make templ",
|
||||
"make hway",
|
||||
"make start-hway"
|
||||
],
|
||||
"start:testnet": [
|
||||
"make templ",
|
||||
"make install",
|
||||
"make sh-testnet"
|
||||
],
|
||||
"start": [
|
||||
"process-compose up -f ./deploy/testnet/process-compose.yaml"
|
||||
],
|
||||
"stop": [
|
||||
"process-compose down -f ./deploy/testnet/process-compose.yaml"
|
||||
],
|
||||
"test:e2e": [
|
||||
"make templ",
|
||||
"make test-e2e"
|
||||
],
|
||||
"test:unit": [
|
||||
"make templ",
|
||||
"make test-unit"
|
||||
],
|
||||
"test": [
|
||||
"make templ",
|
||||
"make test"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+48
@@ -193,6 +193,54 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"gum@latest": {
|
||||
"last_modified": "2024-09-10T15:01:03Z",
|
||||
"resolved": "github:NixOS/nixpkgs/5ed627539ac84809c78b2dd6d26a5cebeb5ae269#gum",
|
||||
"source": "devbox-search",
|
||||
"version": "0.14.5",
|
||||
"systems": {
|
||||
"aarch64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/n1gqffrwdzr3vpsmwmwx3hmw814c1k6g-gum-0.14.5",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/n1gqffrwdzr3vpsmwmwx3hmw814c1k6g-gum-0.14.5"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/ggp10jr3l6higs0gqibp6ypjlf7yakpc-gum-0.14.5",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/ggp10jr3l6higs0gqibp6ypjlf7yakpc-gum-0.14.5"
|
||||
},
|
||||
"x86_64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/jq8shghha81s1wg67fcjrfnf4hbliimn-gum-0.14.5",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/jq8shghha81s1wg67fcjrfnf4hbliimn-gum-0.14.5"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/f199acwir08z47f3d5kf1fhmhajmd1ig-gum-0.14.5",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/f199acwir08z47f3d5kf1fhmhajmd1ig-gum-0.14.5"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ipfs@latest": {
|
||||
"last_modified": "2023-02-24T09:01:09Z",
|
||||
"resolved": "github:NixOS/nixpkgs/7d0ed7f2e5aea07ab22ccb338d27fbe347ed2f11#ipfs",
|
||||
|
||||
Binary file not shown.
@@ -13,15 +13,11 @@ import (
|
||||
//go:embed app.wasm
|
||||
var dwnWasmData []byte
|
||||
|
||||
//go:embed motr.mjs
|
||||
var motrMJSData []byte
|
||||
|
||||
//go:embed sw.js
|
||||
var swJSData []byte
|
||||
|
||||
var (
|
||||
dwnWasmFile = files.NewBytesFile(dwnWasmData)
|
||||
motrMJSFile = files.NewBytesFile(motrMJSData)
|
||||
swJSFile = files.NewBytesFile(swJSData)
|
||||
)
|
||||
|
||||
@@ -43,7 +39,6 @@ func NewVaultDirectory(cnfg *Config) (files.Node, error) {
|
||||
}
|
||||
fileMap := map[string]files.Node{
|
||||
"config.json": files.NewBytesFile(dwnJSON),
|
||||
"motr.mjs": motrMJSFile,
|
||||
"sw.js": swJSFile,
|
||||
"app.wasm": dwnWasmFile,
|
||||
"index.html": files.NewBytesFile(w.Bytes()),
|
||||
|
||||
@@ -1,253 +0,0 @@
|
||||
// motr.mjs
|
||||
|
||||
import Dexie from "dexie";
|
||||
|
||||
export class Motr {
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
this.vault = null;
|
||||
this.initializeVault();
|
||||
}
|
||||
|
||||
initializeVault() {
|
||||
const { schema } = this.config;
|
||||
this.vault = new Dexie("Vault");
|
||||
this.vault.version(schema.version).stores(schema);
|
||||
}
|
||||
|
||||
// Account methods
|
||||
async insertAccount(accountData) {
|
||||
return this.vault.account.add(accountData);
|
||||
}
|
||||
|
||||
async getAccount(id) {
|
||||
return this.vault.account.get(id);
|
||||
}
|
||||
|
||||
async updateAccount(id, accountData) {
|
||||
return this.vault.account.update(id, accountData);
|
||||
}
|
||||
|
||||
async deleteAccount(id) {
|
||||
return this.vault.account.delete(id);
|
||||
}
|
||||
|
||||
// Asset methods
|
||||
async insertAsset(assetData) {
|
||||
return this.vault.asset.add(assetData);
|
||||
}
|
||||
|
||||
async getAsset(id) {
|
||||
return this.vault.asset.get(id);
|
||||
}
|
||||
|
||||
async updateAsset(id, assetData) {
|
||||
return this.vault.asset.update(id, assetData);
|
||||
}
|
||||
|
||||
async deleteAsset(id) {
|
||||
return this.vault.asset.delete(id);
|
||||
}
|
||||
|
||||
// Chain methods
|
||||
async insertChain(chainData) {
|
||||
return this.vault.chain.add(chainData);
|
||||
}
|
||||
|
||||
async getChain(id) {
|
||||
return this.vault.chain.get(id);
|
||||
}
|
||||
|
||||
async updateChain(id, chainData) {
|
||||
return this.vault.chain.update(id, chainData);
|
||||
}
|
||||
|
||||
async deleteChain(id) {
|
||||
return this.vault.chain.delete(id);
|
||||
}
|
||||
|
||||
// Credential methods
|
||||
async insertCredential(credentialData) {
|
||||
const publicKey = await this.createPublicKeyCredential(credentialData);
|
||||
credentialData.credentialId = publicKey.id;
|
||||
credentialData.publicKey = publicKey.publicKey;
|
||||
return this.vault.credential.add(credentialData);
|
||||
}
|
||||
|
||||
async getCredential(id) {
|
||||
return this.vault.credential.get(id);
|
||||
}
|
||||
|
||||
async updateCredential(id, credentialData) {
|
||||
return this.vault.credential.update(id, credentialData);
|
||||
}
|
||||
|
||||
async deleteCredential(id) {
|
||||
return this.vault.credential.delete(id);
|
||||
}
|
||||
|
||||
// JWK methods
|
||||
async insertJwk(jwkData) {
|
||||
return this.vault.jwk.add(jwkData);
|
||||
}
|
||||
|
||||
async getJwk(id) {
|
||||
return this.vault.jwk.get(id);
|
||||
}
|
||||
|
||||
async updateJwk(id, jwkData) {
|
||||
return this.vault.jwk.update(id, jwkData);
|
||||
}
|
||||
|
||||
async deleteJwk(id) {
|
||||
return this.vault.jwk.delete(id);
|
||||
}
|
||||
|
||||
// Grant methods
|
||||
async insertGrant(grantData) {
|
||||
return this.vault.grant.add(grantData);
|
||||
}
|
||||
|
||||
async getGrant(id) {
|
||||
return this.vault.grant.get(id);
|
||||
}
|
||||
|
||||
async updateGrant(id, grantData) {
|
||||
return this.vault.grant.update(id, grantData);
|
||||
}
|
||||
|
||||
async deleteGrant(id) {
|
||||
return this.vault.grant.delete(id);
|
||||
}
|
||||
|
||||
// Keyshare methods
|
||||
async insertKeyshare(keyshareData) {
|
||||
return this.vault.keyshare.add(keyshareData);
|
||||
}
|
||||
|
||||
async getKeyshare(id) {
|
||||
return this.vault.keyshare.get(id);
|
||||
}
|
||||
|
||||
async updateKeyshare(id, keyshareData) {
|
||||
return this.vault.keyshare.update(id, keyshareData);
|
||||
}
|
||||
|
||||
async deleteKeyshare(id) {
|
||||
return this.vault.keyshare.delete(id);
|
||||
}
|
||||
|
||||
// PublicKey methods
|
||||
async insertPublicKey(publicKeyData) {
|
||||
return this.vault.publicKey.add(publicKeyData);
|
||||
}
|
||||
|
||||
async getPublicKey(id) {
|
||||
return this.vault.publicKey.get(id);
|
||||
}
|
||||
|
||||
async updatePublicKey(id, publicKeyData) {
|
||||
return this.vault.publicKey.update(id, publicKeyData);
|
||||
}
|
||||
|
||||
async deletePublicKey(id) {
|
||||
return this.vault.publicKey.delete(id);
|
||||
}
|
||||
|
||||
// Profile methods
|
||||
async insertProfile(profileData) {
|
||||
return this.vault.profile.add(profileData);
|
||||
}
|
||||
|
||||
async getProfile(id) {
|
||||
return this.vault.profile.get(id);
|
||||
}
|
||||
|
||||
async updateProfile(id, profileData) {
|
||||
return this.vault.profile.update(id, profileData);
|
||||
}
|
||||
|
||||
async deleteProfile(id) {
|
||||
return this.vault.profile.delete(id);
|
||||
}
|
||||
|
||||
// WebAuthn methods
|
||||
async createPublicKeyCredential(options) {
|
||||
const publicKeyCredentialCreationOptions = {
|
||||
challenge: new Uint8Array(32),
|
||||
rp: {
|
||||
name: this.config.motr.origin,
|
||||
id: new URL(this.config.motr.origin).hostname,
|
||||
},
|
||||
user: {
|
||||
id: new TextEncoder().encode(options.subject),
|
||||
name: options.subject,
|
||||
displayName: options.label,
|
||||
},
|
||||
pubKeyCredParams: [
|
||||
{ alg: -7, type: "public-key" },
|
||||
{ alg: -257, type: "public-key" },
|
||||
],
|
||||
authenticatorSelection: {
|
||||
authenticatorAttachment: "platform",
|
||||
userVerification: "required",
|
||||
},
|
||||
timeout: 60000,
|
||||
attestation: "direct",
|
||||
};
|
||||
|
||||
try {
|
||||
const credential = await navigator.credentials.create({
|
||||
publicKey: publicKeyCredentialCreationOptions,
|
||||
});
|
||||
|
||||
const publicKeyJwk = await crypto.subtle.exportKey(
|
||||
"jwk",
|
||||
credential.response.getPublicKey(),
|
||||
);
|
||||
|
||||
return {
|
||||
id: credential.id,
|
||||
publicKey: publicKeyJwk,
|
||||
type: credential.type,
|
||||
transports: credential.response.getTransports(),
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error creating credential:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async getPublicKeyCredential(options) {
|
||||
const publicKeyCredentialRequestOptions = {
|
||||
challenge: new Uint8Array(32),
|
||||
rpId: new URL(this.config.motr.origin).hostname,
|
||||
allowCredentials: options.allowCredentials || [],
|
||||
userVerification: "required",
|
||||
timeout: 60000,
|
||||
};
|
||||
|
||||
try {
|
||||
const assertion = await navigator.credentials.get({
|
||||
publicKey: publicKeyCredentialRequestOptions,
|
||||
});
|
||||
|
||||
return {
|
||||
id: assertion.id,
|
||||
type: assertion.type,
|
||||
rawId: new Uint8Array(assertion.rawId),
|
||||
response: {
|
||||
authenticatorData: new Uint8Array(
|
||||
assertion.response.authenticatorData,
|
||||
),
|
||||
clientDataJSON: new Uint8Array(assertion.response.clientDataJSON),
|
||||
signature: new Uint8Array(assertion.response.signature),
|
||||
userHandle: new Uint8Array(assertion.response.userHandle),
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error getting credential:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -41,9 +41,9 @@ templ SectionHero(hero *models.Hero) {
|
||||
|
||||
templ heroImage(hero *models.Hero) {
|
||||
<!-- Image -->
|
||||
<div class="max-w-5xl mx-auto px-4 sm:px-6 flex justify-center pb-12 md:pb-20 relative before:absolute before:-top-12 before:w-96 before:h-96 before:bg-zinc-900 before:opacity-[.15] before:rounded-full before:blur-3xl before:-z-10 from-zinc-100 to-white">
|
||||
<div class="max-w-5xl motion-preset-slide-up mx-auto px-4 sm:px-6 flex justify-center pb-12 md:pb-20 relative before:absolute before:-top-12 before:w-96 before:h-96 before:bg-zinc-900 before:opacity-[.15] before:rounded-full before:blur-3xl before:-z-10 from-zinc-100 to-white">
|
||||
<img
|
||||
class="rounded-lg"
|
||||
class="rounded-lg "
|
||||
src={ hero.Image.Src }
|
||||
width={ hero.Image.Width }
|
||||
height={ hero.Image.Height }
|
||||
|
||||
@@ -139,7 +139,7 @@ func heroImage(hero *models.Hero) templ.Component {
|
||||
templ_7745c5c3_Var6 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!-- Image --><div class=\"max-w-5xl mx-auto px-4 sm:px-6 flex justify-center pb-12 md:pb-20 relative before:absolute before:-top-12 before:w-96 before:h-96 before:bg-zinc-900 before:opacity-[.15] before:rounded-full before:blur-3xl before:-z-10 from-zinc-100 to-white\"><img class=\"rounded-lg\" src=\"")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!-- Image --><div class=\"max-w-5xl motion-preset-slide-up mx-auto px-4 sm:px-6 flex justify-center pb-12 md:pb-20 relative before:absolute before:-top-12 before:w-96 before:h-96 before:bg-zinc-900 before:opacity-[.15] before:rounded-full before:blur-3xl before:-z-10 from-zinc-100 to-white\"><img class=\"rounded-lg \" src=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
"watch": "bun run watch:ts & bun run watch:css"
|
||||
},
|
||||
"devDependencies": {
|
||||
"htmx.org": "^1.9.12",
|
||||
"alpinejs": "^3.14.1",
|
||||
"@tailwindcss/typography": "^0.5.15",
|
||||
"@tailwindcss/forms": "^0.5.7",
|
||||
"@tailwindcss/typography": "^0.5.15",
|
||||
"alpinejs": "^3.14.1",
|
||||
"htmx.org": "^1.9.12",
|
||||
"tailwindcss": "^3.3.0",
|
||||
"tailwindcss-motion": "^0.3.0-beta",
|
||||
"typescript": "^4.9.0"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -41,5 +41,5 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [require("@tailwindcss/typography"), require("@tailwindcss/forms")],
|
||||
plugins: [require("@tailwindcss/typography"), require("@tailwindcss/forms"), require('tailwindcss-motion')],
|
||||
};
|
||||
|
||||
+30
-30
@@ -1,39 +1,39 @@
|
||||
package orm
|
||||
|
||||
const SCHEMA_VERSION = 1
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func AccountSchema() string {
|
||||
return "++, id, name, address, publicKey, chainCode, index, controller, createdAt"
|
||||
const SchemaVersion = 1
|
||||
|
||||
func toCamelCase(s string) string {
|
||||
if s == "" {
|
||||
return s
|
||||
}
|
||||
if len(s) == 1 {
|
||||
return strings.ToLower(s)
|
||||
}
|
||||
return strings.ToLower(s[:1]) + s[1:]
|
||||
}
|
||||
|
||||
func AssetSchema() string {
|
||||
return "++, id, name, symbol, decimals, chainCode, createdAt"
|
||||
}
|
||||
func GetSchema(structType interface{}) string {
|
||||
t := reflect.TypeOf(structType)
|
||||
if t.Kind() == reflect.Ptr {
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
func ChainSchema() string {
|
||||
return "++, id, name, networkId, chainCode, createdAt"
|
||||
}
|
||||
if t.Kind() != reflect.Struct {
|
||||
return ""
|
||||
}
|
||||
|
||||
func CredentialSchema() string {
|
||||
return "++, id, subject, controller, attestationType, origin, label, deviceId, credentialId, publicKey, transport, signCount, userPresent, userVerified, backupEligible, backupState, cloneWarning, createdAt, updatedAt"
|
||||
}
|
||||
var fields []string
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
field := t.Field(i)
|
||||
fieldName := toCamelCase(field.Name)
|
||||
fields = append(fields, fieldName)
|
||||
}
|
||||
|
||||
func DIDSchema() string {
|
||||
return "++, id, role, algorithm, encoding, curve, key_type, raw, jwk"
|
||||
}
|
||||
|
||||
func JwkSchema() string {
|
||||
return "++, kty, crv, x, y, n, e"
|
||||
}
|
||||
|
||||
func GrantSchema() string {
|
||||
return "++, subject, controller, origin, token, scopes, createdAt, updatedAt"
|
||||
}
|
||||
|
||||
func KeyshareSchema() string {
|
||||
return "++, id, data, role, createdAt, lastRefreshed"
|
||||
}
|
||||
|
||||
func ProfileSchema() string {
|
||||
return "++, id, subject, controller, originUri, publicMetadata, privateMetadata, createdAt, updatedAt"
|
||||
// Add "++" at the beginning, separated by a comma
|
||||
return "++, " + strings.Join(fields, ", ")
|
||||
}
|
||||
|
||||
@@ -34,14 +34,13 @@ func (p Params) Validate() error {
|
||||
// DefaultSchema returns the default schema
|
||||
func DefaultSchema() *Schema {
|
||||
return &Schema{
|
||||
Version: orm.SCHEMA_VERSION,
|
||||
Account: orm.AccountSchema(),
|
||||
Asset: orm.AssetSchema(),
|
||||
Chain: orm.ChainSchema(),
|
||||
Credential: orm.CredentialSchema(),
|
||||
Jwk: orm.JwkSchema(),
|
||||
Grant: orm.GrantSchema(),
|
||||
Keyshare: orm.KeyshareSchema(),
|
||||
Profile: orm.ProfileSchema(),
|
||||
Version: orm.SchemaVersion,
|
||||
Account: orm.GetSchema(&orm.Account{}),
|
||||
Asset: orm.GetSchema(&orm.Asset{}),
|
||||
Chain: orm.GetSchema(&orm.Chain{}),
|
||||
Credential: orm.GetSchema(&orm.Credential{}),
|
||||
Grant: orm.GetSchema(&orm.Grant{}),
|
||||
Keyshare: orm.GetSchema(&orm.Keyshare{}),
|
||||
Profile: orm.GetSchema(&orm.Profile{}),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user