cli: change the module name of the cli (#1431)

This commit is contained in:
eball
2025-06-11 23:06:24 +08:00
committed by GitHub
parent f9072c9312
commit d484e41bbd
301 changed files with 6680 additions and 1059 deletions

View File

@@ -0,0 +1,79 @@
# `jwt` <!-- omit in toc -->
# Table of Contents
- [Table of Contents](#table-of-contents)
- [Usage](#usage)
- [Signing](#signing)
- [Verifying](#verifying)
- [Directory Structure](#directory-structure)
- [Rationale](#rationale)
# Usage
## Signing
```go
package main
import (
"fmt"
"github.com/beclab/Olares/cli/pkg/web5/didjwk"
"github.com/beclab/Olares/cli/pkg/web5/jwt"
)
func main() {
did, err := didjwk.Create()
if err != nil {
panic(err)
}
claims := jwt.Claims{
Issuer: did.URI,
Misc: map[string]interface{}{"c_nonce": "abcd123"},
}
jwt, err := jwt.Sign(claims, did)
if err != nil {
panic(err)
}
}
```
## Verifying
```go
package main
import (
"fmt"
"github.com/beclab/Olares/cli/pkg/web5/dids"
"github.com/beclab/Olares/cli/pkg/web5/jwt"
)
func main() {
someJWT := "SOME_JWT"
ok, err := jwt.Verify(signedJWT)
if err != nil {
panic(err)
}
if (!ok) {
fmt.Printf("dookie JWT")
}
}
```
specifying a specific category of key to use relative to the did provided can be done in the same way shown with `jws.Sign`
# Directory Structure
```
jwt
├── jwt.go
└── jwt_test.go
```
### Rationale
same as `jws`.