tokens

package
v0.0.0-...-b2c4e65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func B64ToInterface

func B64ToInterface(input string, output interface{}) error

func CurrentTimestamp

func CurrentTimestamp() uint64

func InterfaceToB64

func InterfaceToB64(artifact interface{}) (string, error)

func JwtToB64

func JwtToB64(jwt interface{}) (string, string, error)

func SplitJWT

func SplitJWT(signedJWT string) (string, string, string, error)

func ValidateAICPayload

func ValidateAICPayload(payload *AICPayload) error

Validates the AIC according to the specification https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#03-alastria-identity-creation-aic Sets default values if they are empty and they are required

func ValidateASPayload

func ValidateASPayload(payload *ASPayload) error

Validates the AlastriaSession according to the specification https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#02-alastria-session-as Sets default values if they are empty and they are required

func ValidateATPayload

func ValidateATPayload(payload *ATPayload) error

Validates the AlastriaToken according to the specification https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#01-alastria-token-at Sets default values if they are empty and they are required

func ValidateCredentialPayload

func ValidateCredentialPayload(payload *CredentialPayload) error

Validates the Credential according to the specification https://github.com/alastria/alastria-identity/wiki/Alastria-DID-Method-Specification-(Quorum-version)#3-credentials Sets default values if they are empty and they are required

func ValidateExpiresAt

func ValidateExpiresAt(exp *uint64) error

func ValidateHeader

func ValidateHeader(header *alaTypes.Header) error

Validates that the header is valid following the specification found here: https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#0-artifacts-definition Sets default values to header.Type and header.Algorithm if they are empty. If header.Type or header.Algorithm are invalid also throws an error.

func ValidateIssuedAt

func ValidateIssuedAt(iat *uint64) error

func ValidateNotBefore

func ValidateNotBefore(nbf *uint64) error

func ValidatePRPayload

func ValidatePRPayload(payload *PRPayload) error

Validates the PresentationRequest according to the specification https://github.com/alastria/alastria-identity/wiki/Alastria-DID-Method-Specification-(Quorum-version)#5-presentation-request Sets default values if they are empty and they are required

func ValidatePresentationPayload

func ValidatePresentationPayload(payload *PresentationPayload) error

Validates the Presentation according to the specification https://github.com/alastria/alastria-identity/wiki/Alastria-DID-Method-Specification-(Quorum-version)#4-presentation Sets default values if they are empty and they are required

func ValidateTimestamps

func ValidateTimestamps(iat *uint64, exp *uint64, nbf *uint64) error

Types

type AIC

type AIC struct {
	Header  *alaTypes.Header `json:"header,omitempty"`
	Payload *AICPayload      `json:"payload,omitempty"`
}

func CreateAlastriaIdentityCreation

func CreateAlastriaIdentityCreation(header *alaTypes.Header, payload *AICPayload) (*AIC, error)

Validates the AIC according to the specification Header: https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#0-artifacts-definition Payload: https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#03-alastria-identity-creation-aic The validation with timestamp will be done with the machine timestamp. This can cause a problem, if the time is not syncronize. Sets default values if they are empty and they are required Returns an error if a mandatory field is empty Mandatory fields are: payload.AlastriaToken, payload.CreateAlastriaTX and payload.PublicKey

func DecodeAIC

func DecodeAIC(signedAIC string) (*AIC, error)

Decodes an AIC from a signed JWT

type AICPayload

type AICPayload struct {
	IssuedAt         uint64   `json:"iat,omitempty"`
	ExpiresAt        uint64   `json:"exp,omitempty"`
	NotBefore        uint64   `json:"nbf,omitempty"`
	PublicKey        string   `json:"publicKey,omitempty"`
	JSONTokenId      string   `json:"jti,omitempty"`
	CreateAlastriaTX string   `json:"createAlastriaTX,omitempty"` // ! Not the best name
	AlastriaToken    string   `json:"alastriaToken,omitempty"`
	Contexts         []string `json:"@context,omitempty"`
	Types            []string `json:"type,omitempty"`
}

type AS

type AS struct {
	Header  *alaTypes.Header `json:"header,omitempty"`
	Payload *ASPayload       `json:"payload,omitempty"`
}

func CreateAlastriaSession

func CreateAlastriaSession(header *alaTypes.Header, payload *ASPayload) (*AS, error)

Validates the AlastriaSession according to the specification Header: https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#0-artifacts-definition Payload: https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#02-alastria-session-as The validation with timestamp will be done with the machine timestamp. This can cause a problem, if the time is not syncronize. Sets default values if they are empty and they are required Returns an error if a mandatory field is empty Mandatory fields are: payload.AlastriaToken and AlastriaToken.Issuer

func DecodeAlastriaSession

func DecodeAlastriaSession(signedAS string) (*AS, error)

Decodes an AlastriaSession from a signed JWT

type ASPayload

type ASPayload struct {
	JSONTokenId   string   `json:"jti,omitempty"`
	IssuedAt      uint64   `json:"iat,omitempty"`
	ExpiresAt     uint64   `json:"exp,omitempty"`
	NotBefore     uint64   `json:"nbf,omitempty"`
	Issuer        string   `json:"iss,omitempty"`
	AlastriaToken string   `json:"alastriaToken,omitempty"`
	Contexts      []string `json:"@context,omitempty"`
	Types         []string `json:"type,omitempty"`
}

type AT

type AT struct {
	Header  *alaTypes.Header `json:"header,omitempty"`
	Payload *ATPayload       `json:"payload,omitempty"`
}

func CreateAlastriaToken

func CreateAlastriaToken(header *alaTypes.Header, payload *ATPayload) (*AT, error)

Validates the AlastriaToken according to the specification Header: https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#0-artifacts-definition Payload: https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#01-alastria-token-at The validation with timestamp will be done with the machine timestamp. This can cause a problem, if the time is not syncronize. Sets default values if they are empty and they are required Returns an error if a mandatory field is empty Mandatory fields are: AlastriaToken.GatewayURL, AlastriaToken.Issuer, AlastriaToken.CallbackURL, AlastriaToken.AlastriaNetworkId

func DecodeAlastriaToken

func DecodeAlastriaToken(signedAT string) (*AT, error)

Decodes an AlastriaToken from a signed JWT

type ATPayload

type ATPayload struct {
	// ! AT lacks of `@context` field
	JSONTokenId               string   `json:"jti,omitempty"`
	IssuedAt                  uint64   `json:"iat,omitempty"`
	ExpiresAt                 uint64   `json:"exp,omitempty"`
	NotBefore                 uint64   `json:"nbf,omitempty"`
	Issuer                    string   `json:"iss,omitempty"`
	Types                     []string `json:"type,omitempty"`
	AlastriaNetworkId         string   `json:"ani,omitempty"`
	CallbackURL               string   `json:"cbu,omitempty"`
	GatewayURL                string   `json:"gwu,omitempty"`
	MultiFactorAuthentication string   `json:"mfau,omitempty"` // ! probably better with just 3 letter "mfa" as the rest of properties
}

type AlastriaJWT

type AlastriaJWT struct {
	AlastriaToken   AT
	AlastriaSession AS
	AIC             AIC
	Credential      Credential
	Presentation    Presentation
	PR              PR
}

type Credential

type Credential struct {
	Header  *alaTypes.Header   `json:"header,omitempty"`
	Payload *CredentialPayload `json:"payload,omitempty"`
}

func CreateCredential

func CreateCredential(header *alaTypes.Header, payload *CredentialPayload) (*Credential, error)

Validates the VerifiableCredential(aka Credential) according to the specification Header: https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#0-artifacts-definition Payload: https://github.com/alastria/alastria-identity/wiki/Alastria-DID-Method-Specification-(Quorum-version)#3-credentials The validation with timestamp will be done with the machine timestamp. This can cause a problem, if the time is not syncronize. Sets default values if they are empty and they are required Returns an error if a mandatory field is empty Mandatory fields are: payload.AlastriaToken, payload.CreateAlastriaTX and payload.PublicKey

func DecodeCredential

func DecodeCredential(signedCredential string) (*Credential, error)

Decodes an Credential from a signed JWT

type CredentialPayload

type CredentialPayload struct {
	JSONTokenId          string               `json:"jti,omitempty"`
	IssuedAt             uint64               `json:"iat,omitempty"`
	ExpiresAt            uint64               `json:"exp,omitempty"`
	NotBefore            uint64               `json:"nbf,omitempty"`
	Issuer               string               `json:"iss,omitempty"`
	Subject              string               `json:"sub,omitempty"`
	VerifiableCredential *CredentialPayloadVC `json:"vc,omitempty"`
}

type CredentialPayloadVC

type CredentialPayloadVC struct {
	Contexts          []string                `json:"@context,omitempty"`
	Types             []string                `json:"type,omitempty"`
	CredentialSubject *map[string]interface{} `json:"credentialSubject,omitempty"`
}

type PR

type PR struct {
	Header  *alaTypes.Header `json:"header,omitempty"`
	Payload *PRPayload       `json:"payload,omitempty"`
}

func CreatePresentationRequest

func CreatePresentationRequest(header *alaTypes.Header, payload *PRPayload) (*PR, error)

Validates the VerifiablePresentationRequest(aka PresentationRequest) according to the specification Header: https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#0-artifacts-definition Payload: https://github.com/alastria/alastria-identity/wiki/Alastria-DID-Method-Specification-(Quorum-version)#5-presentation-request The validation with timestamp will be done with the machine timestamp. This can cause a problem, if the time is not syncronize. Sets default values if they are empty and they are required Returns an error if a mandatory field is empty Mandatory fields are: payload.Issuer, payload.CallbackURL, payload.VerifiableCredential.ProcessHash, payload.VerifiablePresentation.ProcessUrl and payload.VerifiablePresentation.Data

func DecodePR

func DecodePR(signedPr string) (*PR, error)

Decodes an PR from a signed JWT

type PRPayload

type PRPayload struct {
	JSONTokenId            string       `json:"jti,omitempty"`
	IssuedAt               uint64       `json:"iat,omitempty"`
	ExpiresAt              uint64       `json:"exp,omitempty"`
	NotBefore              uint64       `json:"nbf,omitempty"`
	Issuer                 string       `json:"iss,omitempty"`
	CallbackURL            string       `json:"cbu,omitempty"`
	VerifiablePresentation *PRPayloadVP `json:"vp,omitempty"`
}

type PRPayloadVP

type PRPayloadVP struct {
	Contexts           []string           `json:"@context,omitempty"`
	Types              []string           `json:"type,omitempty"`
	ProcessHash        string             `json:"procHash,omitempty"`
	ProcessUrl         string             `json:"procUrl,omitempty"`
	ProcessDescription string             `json:"procDescription,omitempty"`
	Data               *[]PRPayloadVPData `json:"data,omitempty"` // ! in a presentation is 'verifiableCredentials', and here data. It's not consistent
}

type PRPayloadVPData

type PRPayloadVPData struct {
	Contexts         []string `json:"@context,omitempty"` // ! Not type?
	LevelOfAssurance int      `json:"levelOfAssurance,omitempty"`
	Required         bool     `json:"required,omitempty"`
	FieldName        string   `json:"field_name,omitempty"` // ! maybe credential_name is better than field_name
}

type Presentation

type Presentation struct {
	Header  *alaTypes.Header     `json:"header,omitempty"`
	Payload *PresentationPayload `json:"payload,omitempty"`
}

func CreatePresentation

func CreatePresentation(header *alaTypes.Header, payload *PresentationPayload) (*Presentation, error)

Validates the VerifiablePresentation(aka Presentation) according to the specification Header: https://github.com/alastria/alastria-identity/wiki/Artifacts-and-User-Stories-Definitions#0-artifacts-definition Payload: https://github.com/alastria/alastria-identity/wiki/Alastria-DID-Method-Specification-(Quorum-version)#4-presentation The validation with timestamp will be done with the machine timestamp. This can cause a problem, if the time is not syncronize. Sets default values if they are empty and they are required Returns an error if a mandatory field is empty Mandatory fields are: payload.Issuer, payload.Audience, payload.VerifiablePresentation.ProcessHash, payload.VerifiablePresentation.ProcessUrl and payload.VerifiableCredential.VerifiableCredentials

func DecodePresentation

func DecodePresentation(signedPresenation string) (*Presentation, error)

Decodes an Presentation from a signed JWT

type PresentationPayload

type PresentationPayload struct {
	JSONTokenId                    string                 `json:"jti,omitempty"`
	IssuedAt                       uint64                 `json:"iat,omitempty"`
	ExpiresAt                      uint64                 `json:"exp,omitempty"`
	NotBefore                      uint64                 `json:"nbf,omitempty"`
	Issuer                         string                 `json:"iss,omitempty"`
	Audience                       string                 `json:"aud,omitempty"`
	PresentationRequestJSONTokenId string                 `json:"jtipr,omitempty"`
	VerifiablePresentation         *PresentationPayloadVP `json:"vp,omitempty"`
}

type PresentationPayloadVP

type PresentationPayloadVP struct {
	Contexts              []string `json:"@context,omitempty"`
	Types                 []string `json:"type,omitempty"`
	ProcessHash           string   `json:"procHash,omitempty"`
	ProcessUrl            string   `json:"procUrl,omitempty"`
	ProcessDescription    string   `json:"procDescription,omitempty"`
	VerifiableCredentials []string `json:"verifiableCredential,omitempty"` // ! Should be plural: 'verifiableCredentials'
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL