module

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SUCCESS is the success code
	SUCCESS = 200000

	// ErrorParamNullCode is the error code for null parameter
	ErrorParamNullCode = 301000
	// ErrorParamNullMsg is the error message for null parameter
	ErrorParamNullMsg = "param is null"
	// ErrorParamFmtCode is the error code for parameter format error
	ErrorParamFmtCode = 301001
	// ErrorParamFmtMsg is the error message for parameter format error
	ErrorParamFmtMsg = "param fmt error"
	// ErrorDataExpirationCode is the error code for time expiration error
	ErrorDataExpirationCode = 301002
	// ErrorDataExpirationMsg is the error message for time expiration error
	ErrorDataExpirationMsg = "The expiration time has passed"
	// ErrorNetworkCode is the error code for network error
	ErrorNetworkCode = 303000
	// ErrorNetworkMsg is the error message for network error
	ErrorNetworkMsg = "network error"
)
View Source
const (
	// SM2VerificationKey2023 is the default msgVerify algorithm
	SM2VerificationKey2023 = "SM2VerificationKey2023"
	// SM2Signature is the default msgSign algorithm
	SM2Signature = "SM2Signature"
	// SM2C1C3C2 is the default msgEncrypt and msgDecrypt algorithm
	SM2C1C3C2 = "SM2C1C3C2"
)
View Source
const (
	ProofPurpose = "authentication"
	VPType       = "VerifiablePresentation"

	BusinessLicenseVCTCode = "100001"

	ApplyLoginUsage             = "DID_LOGIN_REQUEST"
	LoginResp                   = "DID_LOGIN_RESPONSE"
	GetVcReq                    = "DID_GET_VC_REQUEST"
	GetVcResp                   = "DID_GET_VC_RESPONSE"
	ApplyBusinessLicenseUsage   = "DID_GET_IDENTITY_VC_REQUEST"
	GetIdentityVcResp           = "DID_GET_IDENTITY_VC_RESPONSE"
	TdhApplyAuth                = "TDH_APPLY_AUTH_REQUEST"
	TdhGetAuthTo                = "TDH_GET_AUTH_TO_REQUEST"
	ApplyInvitationCodeCallback = "DID_APPLY_INVITATION_CODE_CALLBACK"
)
View Source
const (
	LoginUrl             = apiPrefix + "/login"
	DocumentGetUrl       = apiPrefix + "/document/get"
	MsgVerifyUrl         = apiPrefix + "/msg/verify"
	VpVerifyUrl          = apiPrefix + "/vp/verify"
	HealthUrl            = apiPrefix + "/health"
	VcIssueUrl           = apiPrefix + "/vc/issue"
	VcRevokeUrl          = apiPrefix + "/vc/revoke"
	VcListIssuedUrl      = apiPrefix + "/vc/list/issued"
	VcListRevokedUrl     = apiPrefix + "/vc/list/revoked"
	VcGetUrl             = apiPrefix + "/vc/get"
	VcListUrl            = apiPrefix + "/vc/list"
	VcTemplateCreateUrl  = apiPrefix + "/vctemplate/create"
	VcTemplateListUrl    = apiPrefix + "/vctemplate/list"
	VpSignUrl            = apiPrefix + "/vp/sign"
	MsgSignUrl           = apiPrefix + "/msg/sign"
	MsgEncryptUrl        = apiPrefix + "/msg/encrypt"
	MsgDecryptUrl        = apiPrefix + "/msg/decrypt"
	VcListLatestUrl      = apiPrefix + "/vc/list/latest"
	VcListLocalUrl       = apiPrefix + "/vc/list/local"
	FindDidByCompanyName = apiDidPrefix + "/vc/find-did-by-company-name"
	FindCompanyNameByDid = apiDidPrefix + "/vc/find-company-name-by-did"
)
View Source
const (
	// IdentityCredential is the default type of VCTemplate
	IdentityCredential = "IdentityCredential"
)
View Source
const (
	// TimeFormat is the time format
	TimeFormat = time.RFC3339
)

Variables

This section is empty.

Functions

func CreateExpirationDate

func CreateExpirationDate() string

CreateExpirationDate create expiration date, the default expiration time is 5 minutes

func CreateId

func CreateId() string

CreateId create id, the default id is the current time + 8 random characters

func NewApplyBusinessLicenseVP

func NewApplyBusinessLicenseVP(vc []*core.VerifiableCredential, proof []*core.Proof, extend *ApplyBusinessLicenseExtend) *core.VerifiablePresentation

NewApplyBusinessLicenseVP create a new VerifiablePresentation for the ApplyBusinessLicense request.

func NewApplyLoginVP

func NewApplyLoginVP(vc []*core.VerifiableCredential, proof []*core.Proof, extend interface{}) *core.VerifiablePresentation

NewApplyLoginVP create a new VerifiablePresentation for the ApplyLogin request.

func NewSignProof

func NewSignProof(proofType, created, verificationMethod string) *core.Proof

NewSignProof create a new Proof with the given type, created, creator and domain.

func NewSignVP

func NewSignVP(vc []*core.VerifiableCredential, proof []*core.Proof, extend interface{}) *core.VerifiablePresentation

NewSignVP create a new VerifiablePresentation with the given VerifiableCredential and Proof.

Types

type ApplyBusinessLicenseExtend

type ApplyBusinessLicenseExtend struct {
	AuthorizedName   string   `json:"authorizedName"`   // 请求授权的平台的名称
	AuthorizedNameEn string   `json:"authorizedNameEn"` // 请求授权的平台的名称
	CallbackUrl      string   `json:"callbackUrl"`      // 回调地址
	Issuer           []string `json:"issuer,omitempty"` // 发行者
	Method           string   `json:"method"`           // http方式, GET/POST 默认GET
	RequestId        string   `json:"requestId"`        // 请求ID
	VctId            []string `json:"vctId,omitempty"`  // 凭证类型ID
}

ApplyBusinessLicenseExtend is the extend field of the VerifiablePresentation for the ApplyBusinessLicense request.

func NewApplyBusinessLicenseExtend

func NewApplyBusinessLicenseExtend(vctId, issuer []string, authorizedName, authorizedNameEn, requestId, method, callbackUrl string) *ApplyBusinessLicenseExtend

NewApplyBusinessLicenseExtend create a new ApplyBusinessLicenseExtend with the given vctId, issuer, callbackUrl and requestId.

func (*ApplyBusinessLicenseExtend) GetAuthorizedName

func (e *ApplyBusinessLicenseExtend) GetAuthorizedName() string

GetAuthorizedName get the authorizedName field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) GetAuthorizedNameEn

func (e *ApplyBusinessLicenseExtend) GetAuthorizedNameEn() string

GetAuthorizedNameEn get the authorizedNameEn field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) GetCallBackUrl

func (e *ApplyBusinessLicenseExtend) GetCallBackUrl() string

GetCallBackUrl get the callBackUrl field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) GetIssuer

func (e *ApplyBusinessLicenseExtend) GetIssuer() []string

GetIssuer get the issuer field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) GetMethod

func (e *ApplyBusinessLicenseExtend) GetMethod() string

GetMethod get the method field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) GetRequestId

func (e *ApplyBusinessLicenseExtend) GetRequestId() string

GetRequestId get the requestId field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) GetVctId

func (e *ApplyBusinessLicenseExtend) GetVctId() []string

GetVctId get the vctId field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) SetAuthorizedName

func (e *ApplyBusinessLicenseExtend) SetAuthorizedName(authorizedName string)

SetAuthorizedName set the authorizedName field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) SetAuthorizedNameEn

func (e *ApplyBusinessLicenseExtend) SetAuthorizedNameEn(authorizedNameEn string)

SetAuthorizedNameEn set the authorizedNameEn field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) SetCallBackUrl

func (e *ApplyBusinessLicenseExtend) SetCallBackUrl(callBackUrl string)

SetCallBackUrl set the callBackUrl field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) SetIssuer

func (e *ApplyBusinessLicenseExtend) SetIssuer(issuer []string)

SetIssuer set the issuer field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) SetMethod

func (e *ApplyBusinessLicenseExtend) SetMethod(method string)

SetMethod set the method field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) SetRequestId

func (e *ApplyBusinessLicenseExtend) SetRequestId(requestId string)

SetRequestId set the requestId field of the ApplyBusinessLicenseExtend.

func (*ApplyBusinessLicenseExtend) SetVctId

func (e *ApplyBusinessLicenseExtend) SetVctId(vctId []string)

SetVctId set the vctId field of the ApplyBusinessLicenseExtend.

type ApplyLoginExtend

type ApplyLoginExtend struct {
	AuthorizedName   string `json:"authorizedName"`        // 请求授权的平台的名称
	AuthorizedNameEn string `json:"authorizedNameEn"`      // 请求授权的平台的名称
	CallbackUrl      string `json:"callbackUrl,omitempty"` // 回调地址
	Method           string `json:"method"`                // http方式, GET/POST 默认GET
	RequestId        string `json:"requestId,omitempty"`   // 请求ID
}

ApplyLoginExtend is the extend field of the VerifiablePresentation for the ApplyLogin request.

func NewApplyLoginExtend

func NewApplyLoginExtend(authorizedName, authorizedNameEn, requestId, method, callbackUrl string) *ApplyLoginExtend

NewApplyLoginExtend create a new ApplyLoginExtend with the given requestId, method and callbackUrl.

func (*ApplyLoginExtend) GetAuthorizedName

func (e *ApplyLoginExtend) GetAuthorizedName() string

GetAuthorizedName get the authorizedName field of the ApplyLoginExtend.

func (*ApplyLoginExtend) GetAuthorizedNameEn

func (e *ApplyLoginExtend) GetAuthorizedNameEn() string

GetAuthorizedNameEn get the authorizedNameEn field of the ApplyLoginExtend.

func (*ApplyLoginExtend) GetCallBackUrl

func (e *ApplyLoginExtend) GetCallBackUrl() string

GetCallBackUrl get the callBackUrl field of the ApplyLoginExtend.

func (*ApplyLoginExtend) GetMethod

func (e *ApplyLoginExtend) GetMethod() string

GetMethod get the method field of the ApplyLoginExtend.

func (*ApplyLoginExtend) GetRequestId

func (e *ApplyLoginExtend) GetRequestId() string

GetRequestId get the requestId field of the ApplyLoginExtend.

func (*ApplyLoginExtend) SetAuthorizedName

func (e *ApplyLoginExtend) SetAuthorizedName(authorizedName string)

SetAuthorizedName set the authorizedName field of the ApplyLoginExtend.

func (*ApplyLoginExtend) SetAuthorizedNameEn

func (e *ApplyLoginExtend) SetAuthorizedNameEn(authorizedNameEn string)

SetAuthorizedNameEn set the authorizedNameEn field of the ApplyLoginExtend.

func (*ApplyLoginExtend) SetCallBackUrl

func (e *ApplyLoginExtend) SetCallBackUrl(callbackUrl string)

SetCallBackUrl set the callBackUrl field of the ApplyLoginExtend.

func (*ApplyLoginExtend) SetMethod

func (e *ApplyLoginExtend) SetMethod(method string)

SetMethod set the method field of the ApplyLoginExtend.

func (*ApplyLoginExtend) SetRequestId

func (e *ApplyLoginExtend) SetRequestId(requestId string)

SetRequestId set the requestId field of the ApplyLoginExtend.

type Ciphertext

type Ciphertext struct {
	Ciphertext         string `json:"ciphertext"`         // 密文
	VerificationMethod string `json:"verificationMethod"` // 公钥地址
	Type               string `json:"type,omitempty"`     // 算法类型
	Created            string `json:"created,omitempty"`  // 创建时间
}

Ciphertext define Ciphertext

func NewMsgDecrypt

func NewMsgDecrypt(ciphertext, verificationMethod, decryptType string) *Ciphertext

NewMsgDecrypt return Ciphertext, the default Type is SM2C1C3C2

func (*Ciphertext) GetCiphertext

func (c *Ciphertext) GetCiphertext() string

GetCiphertext return ciphertext

func (*Ciphertext) GetCreated

func (c *Ciphertext) GetCreated() string

GetCreated return created

func (*Ciphertext) GetType

func (c *Ciphertext) GetType() string

GetType return type

func (*Ciphertext) GetVerificationMethod

func (c *Ciphertext) GetVerificationMethod() string

GetVerificationMethod return verification method

func (*Ciphertext) SetCiphertext

func (c *Ciphertext) SetCiphertext(ciphertext string)

SetCiphertext set ciphertext

func (*Ciphertext) SetCreated

func (c *Ciphertext) SetCreated(created string)

SetCreated set created

func (*Ciphertext) SetType

func (c *Ciphertext) SetType(t string)

SetType set type

func (*Ciphertext) SetVerificationMethod

func (c *Ciphertext) SetVerificationMethod(verificationMethod string)

SetVerificationMethod set verification method

type CompanyInfo

type CompanyInfo struct {
	CompanyName string `json:"companyName"` // companyName
}

CompanyInfo define the request structure of DocumentGet, used to get did

func (*CompanyInfo) GetCompanyName

func (c *CompanyInfo) GetCompanyName() string

GetCompanyName return companyName

func (*CompanyInfo) SetCompanyName

func (c *CompanyInfo) SetCompanyName(companyName string)

SetCompanyName set companyName

type DidInfo

type DidInfo struct {
	Did string `json:"did"` // DID
}

DidInfo define the request structure of DocumentGet, used to get companyName

func (*DidInfo) GetDid

func (d *DidInfo) GetDid() string

GetDid return did

func (*DidInfo) SetDid

func (d *DidInfo) SetDid(did string)

SetDid set did

type Page

type Page struct {
	Page  int `json:"page,omitempty"`  // 页数,从1开始 默认1
	Size  int `json:"size,omitempty"`  // 每页数量 1~100 默认20
	Total int `json:"total,omitempty"` // 总数
}

Page define the structure of page

func NewPage

func NewPage(page, size int) *Page

NewPage create a new page

func (*Page) GetPage

func (p *Page) GetPage() int

GetPage return number of page

func (*Page) GetSize

func (p *Page) GetSize() int

GetSize return size of page

func (*Page) GetTotal

func (p *Page) GetTotal() int

GetTotal return total number

func (*Page) SetPage

func (p *Page) SetPage(page int)

SetPage set number of page

func (*Page) SetSize

func (p *Page) SetSize(size int)

SetSize set size of page

func (*Page) SetTotal

func (p *Page) SetTotal(total int)

SetTotal set total number

type Plaintext

type Plaintext struct {
	Plaintext          string `json:"plaintext"`          // 明文,签名原文
	Signature          string `json:"signature"`          // 签名
	VerificationMethod string `json:"verificationMethod"` // 公钥地址
	Type               string `json:"type,omitempty"`     // 算法类型
	Created            string `json:"created,omitempty"`  // 创建时间
}

Plaintext define Plaintext

func NewMsgEncrypt

func NewMsgEncrypt(plaintext, verificationMethod, encryptType string) *Plaintext

NewMsgEncrypt create MsgEncrypt, the default Type is SM2C1C3C2

func NewMsgEncryptWithBase64

func NewMsgEncryptWithBase64(plaintext, verificationMethod, encryptType string) *Plaintext

NewMsgEncryptWithBase64 create MsgEncrypt, the default Type is SM2C1C3C2

func NewMsgSign

func NewMsgSign(plaintext, verificationMethod, signType string) *Plaintext

NewMsgSign create MsgSign, the default Type is SM2Signature

func NewMsgSignWithBase64

func NewMsgSignWithBase64(plaintext, verificationMethod, signType string) *Plaintext

NewMsgSignWithBase64 create MsgSign, the default Type is SM2Signature

func NewMsgVerifyReq

func NewMsgVerifyReq(plaintext, signature, verificationMethod, verifyType string) *Plaintext

NewMsgVerifyReq create MsgVerifyReq, the default Type is SM2VerificationKey2023

func (*Plaintext) GetCreated

func (p *Plaintext) GetCreated() string

GetCreated return created

func (*Plaintext) GetPlaintext

func (p *Plaintext) GetPlaintext() string

GetPlaintext return plaintext

func (*Plaintext) GetSignature

func (p *Plaintext) GetSignature() string

GetSignature return signature

func (*Plaintext) GetType

func (p *Plaintext) GetType() string

GetType return type

func (*Plaintext) GetVerificationMethod

func (p *Plaintext) GetVerificationMethod() string

GetVerificationMethod return verification method

func (*Plaintext) SetCreated

func (p *Plaintext) SetCreated(created string)

SetCreated set created

func (*Plaintext) SetPlaintext

func (p *Plaintext) SetPlaintext(plaintext string)

SetPlaintext set plaintext

func (*Plaintext) SetSignature

func (p *Plaintext) SetSignature(signature string)

SetSignature set signature

func (*Plaintext) SetType

func (p *Plaintext) SetType(t string)

SetType set type

func (*Plaintext) SetVerificationMethod

func (p *Plaintext) SetVerificationMethod(verificationMethod string)

SetVerificationMethod set verification method

type VcListExtend

type VcListExtend struct {
	Issuer     string `json:"issuer,omitempty"`     // 发行者
	Page       *Page  `json:"page,omitempty"`       // 分页结构
	Status     string `json:"status"`               // 状态
	TemplateId string `json:"templateId,omitempty"` // 模板ID
}

VcListExtend is the extend field of the VerifiablePresentation for the VC list request.

func NewVcListExtend

func NewVcListExtend(page *Page, issuer, templateId, status string) *VcListExtend

NewVcListExtend create a new VcListExtend with the given Page, issuer, templateId and status.

func (*VcListExtend) GetIssuer

func (e *VcListExtend) GetIssuer() string

GetIssuer get the issuer field of the VcListExtend.

func (*VcListExtend) GetPage

func (e *VcListExtend) GetPage() *Page

GetPage get the page field of the VcListExtend.

func (*VcListExtend) GetStatus

func (e *VcListExtend) GetStatus() string

GetStatus get the status field of the VcListExtend.

func (*VcListExtend) GetTemplateId

func (e *VcListExtend) GetTemplateId() string

GetTemplateId get the templateId field of the VcListExtend.

func (*VcListExtend) SetIssuer

func (e *VcListExtend) SetIssuer(issuer string)

SetIssuer set the issuer field of the VcListExtend.

func (*VcListExtend) SetPage

func (e *VcListExtend) SetPage(page *Page)

SetPage set the page field of the VcListExtend.

func (*VcListExtend) SetStatus

func (e *VcListExtend) SetStatus(status string)

SetStatus set the status field of the VcListExtend.

func (*VcListExtend) SetTemplateId

func (e *VcListExtend) SetTemplateId(templateId string)

SetTemplateId set the templateId field of the VcListExtend.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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