Documentation ¶
Index ¶
- type APIClient
- func (auth *APIClient) ChallengeGet(credential map[string]interface{}) (resp *http.Response, body *ChallengeGetResponse, err error)
- func (auth *APIClient) ChallengeVerify(challengeJWT JWT, proof map[string]interface{}) (resp *http.Response, err error)
- func (auth *APIClient) CredentialCreate(verifiedCredential map[string]interface{}) (resp *http.Response, body *CredentialCreateResponse, err error)
- func (auth *APIClient) CredentialGet(nuid string) (resp *http.Response, body *CredentialGetResponse, err error)
- type ChallengeGetResponse
- type CredentialCreateResponse
- type CredentialGetResponse
- type JWT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIClient ¶ added in v0.2.0
type APIClient struct { // The ApiKey can be found in your free portal account at https://portal.nuid.io ApiKey string // The Host name of the auth API (you probably want https://auth.nuid.io) Host string }
The APIClient struct contains the API Key and Host. Methods are callable from this type to interact with the API and parse responses.
func NewAPIClient ¶ added in v0.2.0
func (*APIClient) ChallengeGet ¶ added in v0.2.0
func (auth *APIClient) ChallengeGet(credential map[string]interface{}) (resp *http.Response, body *ChallengeGetResponse, err error)
Get a credential challenge from the API, usually during login flow. The returned challenge can be used to generate a proof from the user's secret. Used in conjunction with auth.ChallengeVerify().
The credential is usually retrieved by calling the auth.CredentialGet() method.
func (*APIClient) ChallengeVerify ¶ added in v0.2.0
func (auth *APIClient) ChallengeVerify(challengeJWT JWT, proof map[string]interface{}) (resp *http.Response, err error)
Verify a credential challenge with a proof generated from the challenge claims and the user's secret. Generated proof from the claims contained in the challengeJWT and the user's secret. This proof is generated by `Zk.proofFromSecretAndChallenge(secret, challenge)` available in the npm package `@nuid/zk`.
See https://www.npmjs.com/package/@nuid/zk See https://www.npmjs.com/package/@nuid/cli
func (*APIClient) CredentialCreate ¶ added in v0.2.0
func (auth *APIClient) CredentialCreate(verifiedCredential map[string]interface{}) (resp *http.Response, body *CredentialCreateResponse, err error)
Create a credential from a verified credential (meaning a credential generated from the user's secret), usually during user registration. The response body contains the new Credential and the user's unique NuID which should be used as a reference to the user's credential for later authentication attempts.
The verifiedCredential is a map[string]interface{} returned by calling `Zk.verifiableFromSecret(secret)`
See auth.CredentialGet(nuid) See https://www.npmjs.com/package/@nuid/zk See https://www.npmjs.com/package/@nuid/cli
func (*APIClient) CredentialGet ¶ added in v0.2.0
func (auth *APIClient) CredentialGet(nuid string) (resp *http.Response, body *CredentialGetResponse, err error)
Fetch a credential by it's unique NuID which can be extracted from the response to auth.CredentialCreate().
Generally you will end up storing the NuID with your user record during registration. Later during login use the NuID to fetch the credential using this method, passing the returned credential from the response body to auth.ChallengeGet().
type ChallengeGetResponse ¶
type ChallengeGetResponse struct { // The Challenge JWT contains the challenge as its claims, to be // used when generating proofs in addition to the user's secret. ChallengeJWT JWT `json:"nuid.credential.challenge/jwt"` }
The response body for valid auth.ChallengeGet() responses.
type CredentialCreateResponse ¶
type CredentialCreateResponse struct { // An encoded string unique to each credential. This value should be stored // alongside your user record during registration and referenced during // the login challenge and verify stages. NuID string `json:"nu/id"` // The user's credential. This value can be fetched from the API at any // time using auth.CredentialGet(nuid). Credential map[string]interface{} `json:"nuid/credential"` }
The response body for valid auth.CredentialCreate() responses.
type CredentialGetResponse ¶
type CredentialGetResponse struct { // The user's credential. Credential map[string]interface{} `json:"nuid/credential"` }
The response body for valid auth.CredentialGet() responses.