this repo has no description
1// adapted from https://github.com/haileyok/atproto-oauth-golang
2
3package main
4
5import (
6 "crypto/ecdsa"
7 "crypto/elliptic"
8 "crypto/rand"
9 "encoding/json"
10 "fmt"
11 "os"
12 "time"
13
14 "github.com/lestrrat-go/jwx/v2/jwk"
15)
16
17func main() {
18 privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
19 if err != nil {
20 panic(err)
21 }
22
23 key, err := jwk.FromRaw(privKey)
24 if err != nil {
25 panic(err)
26 }
27
28 kid := fmt.Sprintf("%d", time.Now().Unix())
29
30 if err := key.Set(jwk.KeyIDKey, kid); err != nil {
31 panic(err)
32 }
33
34 b, err := json.Marshal(key)
35 if err != nil {
36 panic(err)
37 }
38
39 if err := os.WriteFile("./jwks.json", b, 0644); err != nil {
40 panic(err)
41 }
42}