-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Xe Iaso <[email protected]>
- Loading branch information
Showing
9 changed files
with
647 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.keys | ||
did.json | ||
atproto-did |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# didweb | ||
|
||
This is a heavily forked and modified version of [didweb](https://github.com/afternooncurry/bsky-did-web), but made to be much more understandable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"net/http" | ||
|
||
"github.com/bluesky-social/indigo/xrpc" | ||
"github.com/whyrusleeping/go-did" | ||
"within.website/x/web" | ||
) | ||
|
||
type RecommendedCredentials struct { | ||
AlsoKnownAs []string `json:"alsoKnownAs"` | ||
VerificationMethods struct { | ||
Atproto did.DID `json:"atproto"` | ||
} `json:"verificationMethods"` | ||
RotationKeys []string `json:"rotationKeys"` | ||
Services struct { | ||
AtprotoPds struct { | ||
Type string `json:"type"` | ||
Endpoint string `json:"endpoint"` | ||
} `json:"atproto_pds"` | ||
} `json:"services"` | ||
} | ||
|
||
func IdentityGetRecommendedDidCredentials(ctx context.Context, cli *xrpc.Client) (*RecommendedCredentials, error) { | ||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, cli.Host+"/xrpc/com.atproto.identity.getRecommendedDidCredentials", nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
req.Header.Add("Authorization", "Bearer "+cli.Auth.AccessJwt) | ||
req.Header.Add("Accept", "application/json") | ||
|
||
resp, err := http.DefaultClient.Do(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
return nil, web.NewError(http.StatusOK, resp) | ||
} | ||
|
||
var result RecommendedCredentials | ||
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import "github.com/whyrusleeping/go-did" | ||
|
||
type Document struct { | ||
Context []string `json:"@context"` | ||
Id did.DID `json:"id"` | ||
AlsoKnownAs []string `json:"alsoKnownAs"` | ||
VerificationMethod []*VerificationMethod `json:"verificationMethod"` | ||
Service []*Service `json:"service"` | ||
} | ||
|
||
type VerificationMethod struct { | ||
ID string `json:"id"` | ||
Type string `json:"type"` | ||
Controller string `json:"controller"` | ||
PublicKeyMultibase string `json:"publicKeyMultibase"` | ||
} | ||
|
||
type Service struct { | ||
ID did.DID `json:"id"` | ||
Type string `json:"type"` | ||
ServiceEndpoint string `json:"serviceEndpoint"` | ||
} |
Oops, something went wrong.