mirror of
https://github.com/onsonr/nebula.git
synced 2025-03-10 17:29:11 +00:00
feat: add Taskfile for templating and improve build process
This commit is contained in:
parent
e5737f2c73
commit
6f77ed1c9c
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@ -33,6 +33,7 @@ jobs:
|
|||||||
publish_dir: _site
|
publish_dir: _site
|
||||||
publish_branch: gh-pages
|
publish_branch: gh-pages
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
cname: nebulaui.org
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
needs: deploy-docs
|
needs: deploy-docs
|
||||||
|
11
Taskfile.yml
Normal file
11
Taskfile.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# https://taskfile.dev
|
||||||
|
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
vars:
|
||||||
|
GREETING: Hello, World!
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
templ-gen:
|
||||||
|
cmd: templ generate
|
||||||
|
silent: true
|
16
go.mod
16
go.mod
@ -3,6 +3,18 @@ module github.com/onsonr/nebula
|
|||||||
go 1.23.3
|
go 1.23.3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/a-h/templ v0.2.793 // indirect
|
github.com/a-h/templ v0.2.793
|
||||||
github.com/go-webauthn/webauthn v0.11.2 // indirect
|
github.com/go-webauthn/webauthn v0.11.2
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||||
|
github.com/go-webauthn/x v0.1.14 // indirect
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
|
||||||
|
github.com/google/go-tpm v0.9.1 // indirect
|
||||||
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
|
github.com/x448/float16 v0.8.4 // indirect
|
||||||
|
golang.org/x/crypto v0.26.0 // indirect
|
||||||
|
golang.org/x/sys v0.23.0 // indirect
|
||||||
)
|
)
|
||||||
|
28
go.sum
28
go.sum
@ -1,4 +1,32 @@
|
|||||||
github.com/a-h/templ v0.2.793 h1:Io+/ocnfGWYO4VHdR0zBbf39PQlnzVCVVD+wEEs6/qY=
|
github.com/a-h/templ v0.2.793 h1:Io+/ocnfGWYO4VHdR0zBbf39PQlnzVCVVD+wEEs6/qY=
|
||||||
github.com/a-h/templ v0.2.793/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w=
|
github.com/a-h/templ v0.2.793/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
|
||||||
|
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
|
||||||
github.com/go-webauthn/webauthn v0.11.2 h1:Fgx0/wlmkClTKlnOsdOQ+K5HcHDsDcYIvtYmfhEOSUc=
|
github.com/go-webauthn/webauthn v0.11.2 h1:Fgx0/wlmkClTKlnOsdOQ+K5HcHDsDcYIvtYmfhEOSUc=
|
||||||
github.com/go-webauthn/webauthn v0.11.2/go.mod h1:aOtudaF94pM71g3jRwTYYwQTG1KyTILTcZqN1srkmD0=
|
github.com/go-webauthn/webauthn v0.11.2/go.mod h1:aOtudaF94pM71g3jRwTYYwQTG1KyTILTcZqN1srkmD0=
|
||||||
|
github.com/go-webauthn/x v0.1.14 h1:1wrB8jzXAofojJPAaRxnZhRgagvLGnLjhCAwg3kTpT0=
|
||||||
|
github.com/go-webauthn/x v0.1.14/go.mod h1:UuVvFZ8/NbOnkDz3y1NaxtUN87pmtpC1PQ+/5BBQRdc=
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||||
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/google/go-tpm v0.9.1 h1:0pGc4X//bAlmZzMKf8iz6IsDo1nYTbYJ6FZN/rg4zdM=
|
||||||
|
github.com/google/go-tpm v0.9.1/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
|
||||||
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||||
|
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||||
|
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
|
||||||
|
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
|
||||||
|
golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
|
||||||
|
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package form
|
package form
|
||||||
|
|
||||||
import "github.com/go-webauthn/webauthn/protocol"
|
|
||||||
|
|
||||||
var credentialsHandle = templ.NewOnceHandle()
|
var credentialsHandle = templ.NewOnceHandle()
|
||||||
|
|
||||||
// Base credentials script template
|
// Base credentials script template
|
||||||
@ -127,7 +125,7 @@ script CreatePasskey(id string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Template for creating credentials
|
// Template for creating credentials
|
||||||
templ CreateCredential(options *protocol.PublicKeyCredentialCreationOptions) {
|
templ CreateCredential(options *RegisterOptions) {
|
||||||
@CredentialsScripts()
|
@CredentialsScripts()
|
||||||
<script>
|
<script>
|
||||||
(async () => {
|
(async () => {
|
||||||
@ -151,7 +149,7 @@ templ CreateCredential(options *protocol.PublicKeyCredentialCreationOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Template for getting credentials
|
// Template for getting credentials
|
||||||
templ GetCredential(options *protocol.PublicKeyCredentialRequestOptions) {
|
templ GetCredential(options *LoginOptions) {
|
||||||
@CredentialsScripts()
|
@CredentialsScripts()
|
||||||
<script>
|
<script>
|
||||||
(async () => {
|
(async () => {
|
@ -8,8 +8,6 @@ package form
|
|||||||
import "github.com/a-h/templ"
|
import "github.com/a-h/templ"
|
||||||
import templruntime "github.com/a-h/templ/runtime"
|
import templruntime "github.com/a-h/templ/runtime"
|
||||||
|
|
||||||
import "github.com/go-webauthn/webauthn/protocol"
|
|
||||||
|
|
||||||
var credentialsHandle = templ.NewOnceHandle()
|
var credentialsHandle = templ.NewOnceHandle()
|
||||||
|
|
||||||
// Base credentials script template
|
// Base credentials script template
|
||||||
@ -46,7 +44,7 @@ func CredentialsScripts() templ.Component {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script type=\"text/javascript\">\n // Check if WebAuthn is supported\n async function isWebAuthnSupported() {\n return window.PublicKeyCredential !== undefined;\n }\n\n // Create credentials\n async function createCredential(options) {\n try {\n const publicKey = {\n challenge: base64URLDecode(options.challenge),\n rp: {\n name: options.rpName,\n id: options.rpId,\n },\n user: {\n id: base64URLDecode(options.userId),\n name: options.userName,\n displayName: options.userDisplayName,\n },\n pubKeyCredParams: [{alg: -7, type: \"public-key\"}],\n timeout: options.timeout || 60000,\n attestation: options.attestationType || \"none\",\n };\n \n const credential = await navigator.credentials.create({\n publicKey: publicKey\n });\n \n return {\n id: credential.id,\n rawId: arrayBufferToBase64URL(credential.rawId),\n type: credential.type,\n response: {\n attestationObject: arrayBufferToBase64URL(credential.response.attestationObject),\n clientDataJSON: arrayBufferToBase64URL(credential.response.clientDataJSON),\n }\n };\n } catch (err) {\n console.error('Error creating credential:', err);\n throw err;\n }\n }\n\n // Get credentials\n async function getCredential(options) {\n try {\n const publicKey = {\n challenge: base64URLDecode(options.challenge),\n rpId: options.rpId,\n timeout: options.timeout || 60000,\n userVerification: options.userVerification || \"preferred\",\n };\n\n if (options.allowCredentials) {\n publicKey.allowCredentials = options.allowCredentials.map(cred => ({\n type: cred.type,\n id: base64URLDecode(cred.id),\n }));\n }\n\n const assertion = await navigator.credentials.get({\n publicKey: publicKey\n });\n\n return {\n id: assertion.id,\n rawId: arrayBufferToBase64URL(assertion.rawId),\n type: assertion.type,\n response: {\n authenticatorData: arrayBufferToBase64URL(assertion.response.authenticatorData),\n clientDataJSON: arrayBufferToBase64URL(assertion.response.clientDataJSON),\n signature: arrayBufferToBase64URL(assertion.response.signature),\n userHandle: assertion.response.userHandle ? arrayBufferToBase64URL(assertion.response.userHandle) : null\n }\n };\n } catch (err) {\n console.error('Error getting credential:', err);\n throw err;\n }\n }\n\n // Utility functions for base64URL encoding/decoding\n function base64URLDecode(base64url) {\n const padding = '='.repeat((4 - base64url.length % 4) % 4);\n const base64 = (base64url + padding)\n .replace(/\\-/g, '+')\n .replace(/_/g, '/');\n const rawData = window.atob(base64);\n const array = new Uint8Array(rawData.length);\n for (let i = 0; i < rawData.length; i++) {\n array[i] = rawData.charCodeAt(i);\n }\n return array.buffer;\n }\n\n function arrayBufferToBase64URL(buffer) {\n let binary = '';\n const bytes = new Uint8Array(buffer);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n const base64 = window.btoa(binary);\n return base64\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=/g, '');\n }\n </script>")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script type=\"text/javascript\">\n // Check if WebAuthn is supported\n async function isWebAuthnSupported() {\n return window.PublicKeyCredential !== undefined;\n }\n\n // Create credentials\n async function createCredential(options) {\n try {\n const publicKey = {\n challenge: base64URLDecode(options.challenge),\n rp: {\n name: options.rpName,\n id: options.rpId,\n },\n user: {\n id: base64URLDecode(options.userId),\n name: options.userName,\n displayName: options.userDisplayName,\n },\n pubKeyCredParams: [{alg: -7, type: \"public-key\"}],\n timeout: options.timeout || 60000,\n attestation: options.attestationType || \"none\",\n };\n\n const credential = await navigator.credentials.create({\n publicKey: publicKey\n });\n\n return {\n id: credential.id,\n rawId: arrayBufferToBase64URL(credential.rawId),\n type: credential.type,\n response: {\n attestationObject: arrayBufferToBase64URL(credential.response.attestationObject),\n clientDataJSON: arrayBufferToBase64URL(credential.response.clientDataJSON),\n }\n };\n } catch (err) {\n console.error('Error creating credential:', err);\n throw err;\n }\n }\n\n // Get credentials\n async function getCredential(options) {\n try {\n const publicKey = {\n challenge: base64URLDecode(options.challenge),\n rpId: options.rpId,\n timeout: options.timeout || 60000,\n userVerification: options.userVerification || \"preferred\",\n };\n\n if (options.allowCredentials) {\n publicKey.allowCredentials = options.allowCredentials.map(cred => ({\n type: cred.type,\n id: base64URLDecode(cred.id),\n }));\n }\n\n const assertion = await navigator.credentials.get({\n publicKey: publicKey\n });\n\n return {\n id: assertion.id,\n rawId: arrayBufferToBase64URL(assertion.rawId),\n type: assertion.type,\n response: {\n authenticatorData: arrayBufferToBase64URL(assertion.response.authenticatorData),\n clientDataJSON: arrayBufferToBase64URL(assertion.response.clientDataJSON),\n signature: arrayBufferToBase64URL(assertion.response.signature),\n userHandle: assertion.response.userHandle ? arrayBufferToBase64URL(assertion.response.userHandle) : null\n }\n };\n } catch (err) {\n console.error('Error getting credential:', err);\n throw err;\n }\n }\n\n // Utility functions for base64URL encoding/decoding\n function base64URLDecode(base64url) {\n const padding = '='.repeat((4 - base64url.length % 4) % 4);\n const base64 = (base64url + padding)\n .replace(/\\-/g, '+')\n .replace(/_/g, '/');\n const rawData = window.atob(base64);\n const array = new Uint8Array(rawData.length);\n for (let i = 0; i < rawData.length; i++) {\n array[i] = rawData.charCodeAt(i);\n }\n return array.buffer;\n }\n\n function arrayBufferToBase64URL(buffer) {\n let binary = '';\n const bytes = new Uint8Array(buffer);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n const base64 = window.btoa(binary);\n return base64\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=/g, '');\n }\n </script>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -74,7 +72,7 @@ func CreatePasskey(id string) templ.ComponentScript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Template for creating credentials
|
// Template for creating credentials
|
||||||
func CreateCredential(options *protocol.PublicKeyCredentialCreationOptions) templ.Component {
|
func CreateCredential(options *RegisterOptions) templ.Component {
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||||
@ -108,7 +106,7 @@ func CreateCredential(options *protocol.PublicKeyCredentialCreationOptions) temp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Template for getting credentials
|
// Template for getting credentials
|
||||||
func GetCredential(options *protocol.PublicKeyCredentialRequestOptions) templ.Component {
|
func GetCredential(options *LoginOptions) templ.Component {
|
||||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
10
ui/form/model.go
Normal file
10
ui/form/model.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package form
|
||||||
|
|
||||||
|
import "github.com/go-webauthn/webauthn/protocol"
|
||||||
|
|
||||||
|
type (
|
||||||
|
CredentialDescriptor = protocol.CredentialDescriptor
|
||||||
|
AuthenticationExtensions = protocol.AuthenticationExtensions
|
||||||
|
LoginOptions = protocol.PublicKeyCredentialRequestOptions
|
||||||
|
RegisterOptions = protocol.PublicKeyCredentialCreationOptions
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user