gater

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: GPL-3.0 Imports: 58 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxExpiryAgeInSec         int32  = commonhttp.MaxExpiryAgeInSec // 7 days
	ExpiryDateFormat          string = time.RFC3339
	ExpectedEddsaPubKeyLength int    = 64
)
View Source
const (
	// ContentTypeHeader is used to indicate the media type of the resource
	ContentTypeHeader = "Content-Type"
	// ContentLengthHeader indicates the size of the message body, in bytes
	ContentLengthHeader = "Content-Length"
	// RangeHeader asks the server to send only a portion of an HTTP message back to a client
	RangeHeader = "Range"
	// ContentRangeHeader response HTTP header indicates where in a full body message a partial message belongs
	ContentRangeHeader = "Content-Range"
	// OctetStream is used to indicate the binary files
	OctetStream = "application/octet-stream"
	// ContentTypeJSONHeaderValue is used to indicate json
	ContentTypeJSONHeaderValue = "application/json"
	// ContentTypeXMLHeaderValue is used to indicate xml
	ContentTypeXMLHeaderValue = "application/xml"
	// ContentDispositionHeader is used to indicate the media disposition of the resource
	ContentDispositionHeader = "Content-Disposition"
	// ContentDispositionAttachmentValue is used to indicate attachment
	ContentDispositionAttachmentValue = "attachment"
	// ContentDispositionInlineValue is used to indicate inline
	ContentDispositionInlineValue = "inline"

	// SignedMsg is the request hash
	SignedMsg = "SignedMsg"
	// Signature is the request signature
	Signature = "Signature"

	// GetApprovalPath defines get-approval path style suffix
	GetApprovalPath = "/greenfield/admin/v1/get-approval"
	// ActionQuery defines get-approval's type, currently include create bucket and create object
	ActionQuery = "action"
	// UploadProgressQuery defines upload progress query, which is used to route request
	UploadProgressQuery = "upload-progress"
	// UploadContextQuery defines an upload context query, which is used to route request, it includes upload offset,
	UploadContextQuery      = "upload-context"
	ResumableUploadComplete = "complete"
	ResumableUploadOffset   = "offset"
	GetSecondaryPieceData   = "get-piece"
	// GetBucketReadQuotaQuery defines bucket read quota query, which is used to route request
	GetBucketReadQuotaQuery = "read-quota"
	// GetBucketReadQuotaMonthQuery defines bucket read quota query month
	GetBucketReadQuotaMonthQuery = "year-month"
	// ListBucketReadRecordQuery defines list bucket read record query, which is used to route request
	ListBucketReadRecordQuery = "list-read-record"
	// ListBucketReadRecordMaxRecordsQuery defines list read record max num
	ListBucketReadRecordMaxRecordsQuery = "max-records"
	// ListObjectsMaxKeysQuery defines the maximum number of keys returned to the response
	ListObjectsMaxKeysQuery = "max-keys"
	// ListObjectsStartAfterQuery defines where you want to start listing from
	ListObjectsStartAfterQuery = "start-after"
	// ListObjectsContinuationTokenQuery indicates that the list is being continued on this bucket with a token
	ListObjectsContinuationTokenQuery = "continuation-token"
	// SpOperatorAddressQuery defines sp operator address
	SpOperatorAddressQuery = "sp-operator-address"
	// StartBlockNumberQuery defines start block number
	StartBlockNumberQuery = "start-block-number"
	// EndBlockNumberQuery defines end block number
	EndBlockNumberQuery = "end-block-number"
	// ListObjectsDelimiterQuery defines a character you use to group keys
	ListObjectsDelimiterQuery = "delimiter"
	// ListObjectsPrefixQuery defines limits the response to keys that begin with the specified prefix
	ListObjectsPrefixQuery = "prefix"
	// ListObjectsIncludeRemovedQuery defines whether include removed objects
	ListObjectsIncludeRemovedQuery = "include-removed"
	// GetBucketMetaQuery defines get bucket metadata query, which is used to route request
	GetBucketMetaQuery = "bucket-meta"
	// GetBucketMigrationProgressQuery defines get bucket metadata query, which is used to route request
	GetBucketMigrationProgressQuery = "bucket-migration-progress"
	// GetObjectMetaQuery defines get object metadata query, which is used to route request
	GetObjectMetaQuery = "object-meta"
	// GetGroupListSourceTypeQuery defines get group list source type query, which is used to route request
	GetGroupListSourceTypeQuery = "source-type"
	// GetGroupListLimitQuery defines get group list limit query, which is used to route request
	GetGroupListLimitQuery = "limit"
	// PaymentAccountQuery defines payment account query
	PaymentAccountQuery = "payment-account"
	// GetGroupListOffsetQuery defines get group list offset query, which is used to route request
	GetGroupListOffsetQuery = "offset"
	// IDsQuery defines ids of storage metadata value
	IDsQuery = "ids"
	// GetGroupListGroupQuery defines get group list group query, which is used to route request
	GetGroupListGroupQuery = "group-query"
	// ListBucketsByIDsQuery defines list buckets by bucket ids, which is used to route request
	ListBucketsByIDsQuery = "buckets-query"
	// ListObjectsByIDsQuery defines list objects by object ids, which is used to route request
	ListObjectsByIDsQuery = "objects-query"
	// ListGroupsByIDsQuery defines list groups by group ids, which is used to route request
	ListGroupsByIDsQuery = "groups-query"
	// GetPaymentByBucketIDQuery defines get payment by bucket id, which is used to route request
	GetPaymentByBucketIDQuery = "payment-id"
	// GetPaymentByBucketNameQuery defines get payment by bucket name, which is used to route request
	GetPaymentByBucketNameQuery = "payment-name"
	// GetBucketByBucketNameQuery defines get bucket by bucket name query, which is used to route request
	GetBucketByBucketNameQuery = "bucket-name"
	// GetBucketByBucketIDQuery defines get bucket by bucket id, which is used to route request
	GetBucketByBucketIDQuery = "bucket-id-query"
	// ListDeletedObjectsQuery defines list deleted objects info by a block number range, which is used to route request
	ListDeletedObjectsQuery = "deleted-objects"
	// GetUserBucketsCountQuery defines get user buckets count, which is used to route request
	GetUserBucketsCountQuery = "buckets-count"
	// ListExpiredBucketsBySpQuery defines list buckets that are expired by specific sp, which is used to route request
	ListExpiredBucketsBySpQuery = "expired-buckets"
	// ListVirtualGroupFamiliesBySpIDQuery defines list virtual group families by sp id, which is used to route request
	ListVirtualGroupFamiliesBySpIDQuery = "vgf-sp-id"
	// GetVirtualGroupFamilyQuery defines get virtual group families by vgf id, which is used to route request
	GetVirtualGroupFamilyQuery = "vgf-id-query"
	// GetGlobalVirtualGroupByGvgIDQuery defines get global virtual group by gvg id, which is used to route request
	GetGlobalVirtualGroupByGvgIDQuery = "gvg-id-query"
	// GetGlobalVirtualGroupQuery defines get global virtual group by lvg id and bucket id, which is used to route request
	GetGlobalVirtualGroupQuery = "gvg-query"
	// ListGlobalVirtualGroupsBySecondarySPQuery defines list global virtual group by secondary sp id, which is used to route request
	ListGlobalVirtualGroupsBySecondarySPQuery = "gvg-secondary-sp"
	// ListGlobalVirtualGroupsByBucketQuery defines list global virtual group by bucket id, which is used to route request
	ListGlobalVirtualGroupsByBucketQuery = "gvg-bucket-id"
	// ListObjectsInGVGAndBucketQuery defines list objects by gvg and bucket id, which is used to route request
	ListObjectsInGVGAndBucketQuery = "objects-gvg-bucket"
	// ListObjectsByGVGAndBucketForGCQuery defines list objects by gvg and bucket for gc, which is used to route request
	ListObjectsByGVGAndBucketForGCQuery = "objects-gvg-gc"
	// ListObjectsInGVGQuery defines list objects by gvg id, which is used to route request
	ListObjectsInGVGQuery = "objects-gvg"
	// ListMigrateBucketEventsQuery defines list migrate bucket events, which is used to route request
	ListMigrateBucketEventsQuery = "migrate-bucket-events"
	// GetSPMigratingBucketNumberQuery defines get the latest active migrating bucket by specific sp, which is used to route request
	GetSPMigratingBucketNumberQuery = "migrate-bucket-count"
	// ListSwapOutEventsQuery defines list swap out events, which is used to route request
	ListSwapOutEventsQuery = "swap-out-events"
	// ListSpExitEventsQuery defines list swap out events, which is used to route request
	ListSpExitEventsQuery = "sp-exit-events"
	// VerifyPermissionByIDQuery defines verify permission by resource id, which is used to route request
	VerifyPermissionByIDQuery = "verify-id"
	// GetSPInfoQuery defines query sp info, which is used to route request
	GetSPInfoQuery = "query-sp"
	// VerifyMigrateGVGPermissionQuery defines verify the destination sp id of bucket migration & swap out, which is used to route request
	VerifyMigrateGVGPermissionQuery = "gvg-permission"
	// GetBucketSizeQuery defines get bucket total object size, which is used to route request
	GetBucketSizeQuery = "bucket-size"
	// GetUserGroupsQuery defines get groups info by a user address, which is used to route request
	GetUserGroupsQuery = "user-groups"
	// GetUserOwnedGroupsQuery defines retrieve groups where the user is the owner, which is used to route request
	GetUserOwnedGroupsQuery = "owned-groups"
	// ListObjectPoliciesQuery defines list policies by object info, which is used to route request
	ListObjectPoliciesQuery = "object-policies"
	// ListPaymentAccountStreamsQuery defines list payment account streams, which is used to route request
	ListPaymentAccountStreamsQuery = "payment-buckets"
	// ListUserPaymentAccountsQuery defines list payment accounts by owner address, which is used to route request
	ListUserPaymentAccountsQuery = "user-payments"
	// GetGroupMembersQuery defines query sp info, which is used to route request
	GetGroupMembersQuery = "group-members"
	// ResourceIDQuery defines the bucket/object/group id of the resource that grants permission for
	ResourceIDQuery = "resource-id"
	// GroupIDQuery defines the unique id of group
	GroupIDQuery = "group-id"
	// ResourceTypeQuery defines the type of resource that grants permission for
	ResourceTypeQuery = "resource-type"
	// GetGroupListNameQuery defines get group list name query, which is used to route request
	GetGroupListNameQuery = "name"
	// GetGroupListPrefixQuery defines get group list prefix query, which is used to route request
	GetGroupListPrefixQuery = "prefix"
	// StartTimestampUs defines start timestamp in microsecond, which is used by list read record, [start_ts,end_ts)
	StartTimestampUs = "start-timestamp"
	// EndTimestampUs defines end timestamp in microsecond, which is used by list read record, [start_ts,end_ts)
	EndTimestampUs = "end-timestamp"
	// VerifyPermissionObjectQuery defines verify permission object name
	VerifyPermissionObjectQuery = "object"
	// VerifyPermissionOperator defines verify permission operator address
	VerifyPermissionOperator = "operator"
	// VerifyPermissionActionType defines verify permission action type
	VerifyPermissionActionType = "action-type"
	// BucketIDQuery defines bucket id
	BucketIDQuery = "bucket-id"
	// LimitQuery defines limit of results
	LimitQuery = "limit"
	// CreateAtQuery defines the created timestamp
	CreateAtQuery = "create-at"
	// PrimarySpIDQuery defines the primary sp id
	PrimarySpIDQuery = "primary-sp-id"
	// SpIDQuery defines the sp id
	SpIDQuery = "sp-id"
	// VgfIDQuery defines the vgf id
	VgfIDQuery = "vgf-id"
	// GvgIDQuery defines the gvg id
	GvgIDQuery = "gvg-id"
	// LvgIDQuery defines the lvg id
	LvgIDQuery = "lvg-id"
	// BlockIDQuery defines the block id
	BlockIDQuery         = "block-id"
	OperatorAddressQuery = "operator-address"
	// OffChainAuthAuthorizationQuery defines the authorization query used by offchain-auth
	OffChainAuthAuthorizationQuery = "authorization"
	// OffChainAuthUserAddressQuery defines the user address query used by offchain-auth
	OffChainAuthUserAddressQuery = "user-address"
	// OffChainAuthAppDomainQuery defines the app domain query used by offchain-auth
	OffChainAuthAppDomainQuery = "app-domain"
	// OffChainAuthViewQuery defines the view query used by offchain-auth
	OffChainAuthViewQuery = "view"
	// GetChallengeInfoPath defines get challenge info path style suffix
	GetChallengeInfoPath = "/greenfield/admin/v1/challenge"
	// GetChallengeInfoV2Path defines get challenge info path style suffix
	GetChallengeInfoV2Path = "/greenfield/admin/v2/challenge"
	// ReplicateObjectPiecePath defines replicate-object path style
	ReplicateObjectPiecePath = "/greenfield/receiver/v1/replicate-piece"
	// RecoverObjectPiecePath defines recovery-object path style
	RecoverObjectPiecePath = "/greenfield/recovery/v1/get-piece"
	// AuthRequestNoncePath defines path to request auth nonce
	AuthRequestNoncePath = "/auth/request_nonce"
	// AuthUpdateKeyPath defines path to update user public key
	AuthUpdateKeyPath = "/auth/update_key"
	// GnfdRequestIDHeader defines trace-id, trace request in sp
	GnfdRequestIDHeader = "X-Gnfd-Request-ID"
	// GnfdAuthorizationHeader defines authorization, verify signature and check authorization
	GnfdAuthorizationHeader = "Authorization"
	// GnfdReceiveMsgHeader defines receive piece data meta
	GnfdReceiveMsgHeader = "X-Gnfd-Receive-Msg"
	// GnfdRecoveryMsgHeader defines receive piece data meta
	GnfdRecoveryMsgHeader = "X-Gnfd-Recovery-Msg"
	// GnfdReplicatePieceApprovalHeader defines secondary approved msg for replicating piece
	GnfdReplicatePieceApprovalHeader = "X-Gnfd-Replicate-Piece-Approval-Msg"
	// GnfdObjectIDHeader defines object id
	GnfdObjectIDHeader = "X-Gnfd-Object-ID"
	// GnfdPieceIndexHeader defines piece idx, which is used by challenge
	GnfdPieceIndexHeader = "X-Gnfd-Piece-Index"
	// GnfdRedundancyIndexHeader defines redundancy idx, which is used by challenge and receiver
	GnfdRedundancyIndexHeader = "X-Gnfd-Redundancy-Index"
	// GnfdIntegrityHashHeader defines integrity hash, which is used by challenge and receiver
	GnfdIntegrityHashHeader = "X-Gnfd-Integrity-Hash"
	// GnfdPieceHashHeader defines piece hash list, which is used by challenge
	GnfdPieceHashHeader = "X-Gnfd-Piece-Hash"
	// GnfdQuotaInfoHeader defines quota info, which is used by sp
	GnfdQuotaInfoHeader = "X-Gnfd-Quota-Info"
	// GnfdUnsignedApprovalMsgHeader defines unsigned msg, which is used by get-approval
	GnfdUnsignedApprovalMsgHeader = "X-Gnfd-Unsigned-Msg"
	// GnfdSignedApprovalMsgHeader defines signed msg, which is used by get-approval
	GnfdSignedApprovalMsgHeader = "X-Gnfd-Signed-Msg"
	// GnfdPieceSizeHeader defines piece size, which is used to split by receiver
	GnfdPieceSizeHeader = "X-Gnfd-Piece-Size"
	// GnfdReplicateApproval defines SP approval that allow to replicate piece data, which is used by receiver
	GnfdReplicateApproval = "X-Gnfd-Replicate-Approval"
	// GnfdIntegrityHashSignatureHeader defines integrity hash signature, which is used by receiver
	GnfdIntegrityHashSignatureHeader = "X-Gnfd-Integrity-Hash-Signature"
	// GnfdUserAddressHeader defines the user address
	GnfdUserAddressHeader = "X-Gnfd-User-Address"
	// GnfdResponseXMLVersion defines the response xml version
	GnfdResponseXMLVersion = "1.0"

	// GnfdBuiltInUniversalEndpointDappHtml  a html code which works as a dapp, help users sign with their wallet.
	GnfdBuiltInUniversalEndpointDappHtml = "" /* 51405-byte string literal not displayed */
	// GnfdBuiltInDappSignedContentTemplate defines the template which users will sign against with their wallet.
	GnfdBuiltInDappSignedContentTemplate = "Sign this message to access the file:\n%s\nThis signature will not cost you any fees.\nExpiration Time: %s"
	// GnfdBuiltInUniversalEndpointDappErrorPage html code for an error page representing the error message to end users
	GnfdBuiltInUniversalEndpointDappErrorPage = "" /* 74609-byte string literal not displayed */

	// off-chain-auth headers
	// GnfdOffChainAuthAppDomainHeader defines the app domain from where user is trying to do the EDDSA auth interactions
	GnfdOffChainAuthAppDomainHeader = "X-Gnfd-App-Domain"
	// GnfdOffChainAuthAppRegNonceHeader defines nonce for which user is trying to register his/her EDDSA public key
	GnfdOffChainAuthAppRegNonceHeader = "X-Gnfd-App-Reg-Nonce"
	// GnfdOffChainAuthAppRegPublicKeyHeader defines the EDDSA public key for which user is trying to register
	GnfdOffChainAuthAppRegPublicKeyHeader = "X-Gnfd-App-Reg-Public-Key"
	// GnfdOffChainAuthAppRegExpiryDateHeader defines the Expiry-Date is the ISO 8601 datetime string (e.g. 2021-09-30T16:25:24Z), used to register the EDDSA public key
	GnfdOffChainAuthAppRegExpiryDateHeader = commonhttp.HTTPHeaderExpiryTimestamp

	RecoveryTimeOutSeconds  = 15
	RecoveryCheckInterval   = 2
	RecoveryMinMilliseconds = 500
	RecoveryMinEcIndex      = -1
	ErrPieceStoreInnerCode  = 35101

	// MigratePiecePath defines migrate-data path which is used in SP exiting case.
	MigratePiecePath = "/greenfield/migrate/v1/migrate-piece"
	// GnfdMigratePieceMsgHeader defines migrate piece msg header.
	GnfdMigratePieceMsgHeader = "X-Gnfd-Migrate-Piece-Msg"
	// GnfdMigrateGVGMsgHeader defines migrate gvg msg header.
	GnfdMigrateGVGMsgHeader = "X-Gnfd-Migrate-GVG-Msg"
	// NotifyMigrateSwapOutTaskPath defines dispatch swap out from src sp to dest sp.
	NotifyMigrateSwapOutTaskPath = "/greenfield/migrate/v1/notify-migrate-swap-out-task"
	// GnfdMigrateSwapOutMsgHeader = "X-Gnfd-Migrate-Swap-Out-Msg" defines migrate gvg msg header.
	GnfdMigrateSwapOutMsgHeader = "X-Gnfd-Migrate-Swap-Out-Msg"
	// SecondarySPMigrationBucketApprovalPath defines secondary sp sign migration bucket approval.
	SecondarySPMigrationBucketApprovalPath = "/greenfield/migrate/v1/migration-bucket-approval"
	// GnfdSecondarySPMigrationBucketMsgHeader defines secondary sp migration bucket sign doc header.
	GnfdSecondarySPMigrationBucketMsgHeader = "X-Gnfd-Secondary-Migration-Bucket-Msg"
	// GnfdSecondarySPMigrationBucketApprovalHeader defines secondary sp migration bucket bls approval header.
	GnfdSecondarySPMigrationBucketApprovalHeader = "X-Gnfd-Secondary-Migration-Bucket-Approval"
	// SwapOutApprovalPath defines get swap out approval path.
	SwapOutApprovalPath = "/greenfield/migrate/v1/get-swap-out-approval"
	// MigrateQueryBucketQuotaPath defines query bucket quota from src sp
	MigrateQueryBucketQuotaPath = "/greenfield/migrate/v1/migrate-query-bucket-quota"
	// MigrateQueryBucketQuotaHasEnoughQuotaPath defines query bucket quota from src sp
	MigrateQueryBucketQuotaHasEnoughQuotaPath = "/greenfield/migrate/v1/migrate-query-bucket-has-enough-quota"
	// PreMigrateBucketPath defines pre migrate bucket, can lock quota for migrate bucket
	PreMigrateBucketPath = "/greenfield/migrate/v1/pre-migrate-bucket"
	// PostMigrateBucketPath defines notifying the source sp about the completion of migration bucket
	PostMigrateBucketPath = "/greenfield/migrate/v1/post-migrate-bucket"
	// GnfdMigrateBucketMsgHeader defines migrate bucket msg header
	GnfdMigrateBucketMsgHeader = "X-Gnfd-Migrate-Bucket-Msg"
	// ObjectXmlSuffix defines the object has xml suffix
	ObjectXmlSuffix = "xml"
	// ObjectPdfSuffix defines the object has pdf suffix
	ObjectPdfSuffix = "pdf"
	// UniversalEndpointSpecialSuffixQuery defines the query of universal endpoint with special suffix
	UniversalEndpointSpecialSuffixQuery = "objectPath"

	// StatusPath defines the path for sp status
	StatusPath = "/status"
)

define all kinds of http constants

View Source
const (
	GatewayTotalSuccess            = "gateway_total_success"
	GatewayTotalFailure            = "gateway_total_failure"
	GatewayGetObjectSize           = "gateway_get_object_size"
	GatewayPutObjectSize           = "gateway_put_object_size"
	GatewayChallengePieceSize      = "gateway_challenge_piece_size"
	GatewayReplicatePieceSize      = "gateway_replicate_piece_size"
	GatewaySuccessGetApproval      = "gateway_get_approval_success"
	GatewayFailureGetApproval      = "gateway_get_approval_failure"
	GatewaySuccessGetChallengeInfo = "gateway_get_challenge_info_success"
	GatewayFailureGetChallengeInfo = "gateway_get_challenge_info_failure"
	GatewaySuccessReplicatePiece   = "gateway_replicate_piece_success"
	GatewayFailureReplicatePiece   = "gateway_replicate_piece_failure"
	GatewaySuccessPutObject        = "gateway_put_object_success"
	GatewayFailurePutObject        = "gateway_put_object_failure"
	GatewaySuccessGetObject        = "gateway_get_object_success"
	GatewayFailureGetObject        = "gateway_get_object_failure"
)
View Source
const (
	DefaultGatewayDomainName = "localhost:9133"
	DefaultMaxListReadQuota  = 100
	DefaultMaxPayloadSize    = 2 * 1024 * 1024 * 1024
)
View Source
const (
	MaximumGetGroupListLimit         = 1000
	MaximumGetGroupListOffset        = 100000
	MaximumListObjectsAndBucketsSize = 1000
	MaximumIDSize                    = 100
	DefaultGetGroupListLimit         = 50
	DefaultGetGroupListOffset        = 0
	HandlerSuccess                   = "success"
	HandlerFailure                   = "failure"
	HandlerLevel                     = "handler"
)
View Source
const (
	ExpireIntervalSecond      = 30 * 60 * time.Second
	CheckExpireIntervalSecond = 60 * time.Second
)
View Source
const (
	PreMigrateBucketRouterName  = "PreMigrateBucket"
	PostMigrateBucketRouterName = "PostMigrateBucket"
)
View Source
const (
	MaxSpRequestExpiryAgeInSec int32 = 1000
)
View Source
const ReadHeaderTimeout = 20 * time.Minute

Variables

View Source
var (
	ErrUnsupportedSignType       = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50001, "unsupported sign type")
	ErrAuthorizationHeaderFormat = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50002, "authorization header format error")
	ErrRequestConsistent         = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50003, "request is tampered")
	ErrNoPermission              = gfsperrors.Register(module.GateModularName, http.StatusUnauthorized, 50004, "no permission")
	ErrDecodeMsg                 = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50005, "gnfd msg decoding error")
	ErrValidateMsg               = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50006, "gnfd msg validate error")
	ErrRefuseApproval            = gfsperrors.Register(module.GateModularName, http.StatusOK, 50007, "approval request is refused")
	ErrUnsupportedRequestType    = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50008, "unsupported request type")
	ErrInvalidHeader             = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50009, "invalid request header")
	ErrInvalidQuery              = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50010, "invalid request params for query")
	ErrInvalidRange              = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50012, "invalid range params")
	ErrExceptionStream           = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50013, "stream exception")
	ErrMismatchSp                = gfsperrors.Register(module.GateModularName, http.StatusNotAcceptable, 50014, "mismatch sp")
	ErrSignature                 = gfsperrors.Register(module.GateModularName, http.StatusNotAcceptable, 50015, "signature is invalid")
	ErrInvalidPayloadSize        = gfsperrors.Register(module.GateModularName, http.StatusForbidden, 50016, "invalid payload")
	ErrInvalidDomainHeader       = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50017, "The "+GnfdOffChainAuthAppDomainHeader+" header is incorrect.")
	ErrInvalidPublicKeyHeader    = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50018, "The "+GnfdOffChainAuthAppRegPublicKeyHeader+" header is incorrect.")
	ErrInvalidRegNonceHeader     = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50019, "The "+GnfdOffChainAuthAppRegNonceHeader+" header is incorrect.")
	ErrSignedMsgNotMatchHeaders  = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50020, "The signed message in "+GnfdAuthorizationHeader+" does not match the content in headers.")
	ErrSignedMsgNotMatchSPAddr   = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50021, "The SP addr in the signed message in "+GnfdAuthorizationHeader+" is not for the this SP.")
	ErrSignedMsgNotMatchSPNonce  = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50040, "The SP Nonce in the signed message in "+GnfdAuthorizationHeader+" is not for the this SP.")
	ErrSignedMsgNotMatchDomain   = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50037, "The domain in the signed message in "+GnfdAuthorizationHeader+" does not match this website.")
	ErrSignedMsgNotMatchExpiry   = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50038, "The expiry time in signed message in "+GnfdAuthorizationHeader+" does not match the expiry time in the header "+GnfdOffChainAuthAppRegExpiryDateHeader+".")
	ErrSignedMsgNotMatchPubKey   = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50039, "The public key in signed message in "+GnfdAuthorizationHeader+" does not match the expiry time in the header "+GnfdOffChainAuthAppRegPublicKeyHeader+".")
	ErrSignedMsgNotMatchTemplate = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50022, "The signed message in "+GnfdAuthorizationHeader+" does not match the template.")
	ErrInvalidExpiryDateHeader   = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50023, "The "+commonhttp.HTTPHeaderExpiryTimestamp+" header is incorrect. "+
		"The expiry date is expected to be within "+strconv.Itoa(int(MaxExpiryAgeInSec))+" seconds and formatted in RFC3339, e.g. 2006-01-02T15:04:05Z07:00 . ")
	ErrInvalidExpiryDateParam = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50024, "The "+commonhttp.HTTPHeaderExpiryTimestamp+" parameter is incorrect. "+
		"The expiry date is expected to be within "+strconv.Itoa(int(MaxExpiryAgeInSec))+" seconds and formatted in RFC3339, e.g. 2006-01-02T15:04:05Z07:00 . ")
	ErrNoSuchObject           = gfsperrors.Register(module.AuthenticationModularName, http.StatusNotFound, 50025, "no such object")
	ErrForbidden              = gfsperrors.Register(module.GateModularName, http.StatusForbidden, 50026, "Forbidden to access")
	ErrInvalidComplete        = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50027, "invalid complete")
	ErrInvalidOffset          = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50028, "invalid offset")
	ErrSPUnavailable          = gfsperrors.Register(module.GateModularName, http.StatusForbidden, 50029, "sp is not in service status")
	ErrRecoverySP             = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50030, "The SP is not the correct SP to recovery")
	ErrRecoveryRedundancyType = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50031, "The redundancy type of the recovering piece is not EC")
	ErrRecoveryTimeout        = gfsperrors.Register(module.GateModularName, http.StatusInternalServerError, 50032, "System busy, try to request later")
	ErrInvalidRedundancyIndex = gfsperrors.Register(module.GateModularName, http.StatusInternalServerError, 50035, "invalid redundancy index")
	ErrBucketUnavailable      = gfsperrors.Register(module.GateModularName, http.StatusForbidden, 50036, "bucket is not in service status")
	ErrReplyData              = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50037, "reply the downloaded data to client failed")
	ErrTaskMsgExpired         = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50038, "the update time of the task has exceed the expire time")
	ErrSecondaryMismatch      = gfsperrors.Register(module.GateModularName, http.StatusNotAcceptable, 50039, "secondary sp mismatch")
	ErrPrimaryMismatch        = gfsperrors.Register(module.GateModularName, http.StatusNotAcceptable, 50041, "primary sp mismatch")
	ErrNotCreatedState        = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50042, "object has not been created state")
	ErrNotSealedState         = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50043, "object has not been sealed state")
	// ErrInvalidObjectName is triggered in the following cases, indicating the object name is not compliant:
	// 1. Contains "..": Suggests potential directory traversal.
	// 2. Equals "/": Direct reference to the root directory, which is usually unsafe.
	// 3. Contains "\": May indicate an attempt at illegal path or file operations, especially in Windows systems.
	// 4. Fails SQL Injection Test (util.IsSQLInjection): Object name contains patterns that might be used for SQL injection, like ';select', 'xxx;insert', etc., or SQL comment patterns.
	ErrInvalidObjectName = gfsperrors.Register(module.GateModularName, http.StatusBadRequest, 50044, "invalid object name")
)

Functions

func ErrConsensusWithDetail added in v0.2.4

func ErrConsensusWithDetail(detail string) *gfsperrors.GfSpError

func ErrEncodeResponseWithDetail added in v0.2.4

func ErrEncodeResponseWithDetail(detail string) *gfsperrors.GfSpError

func ErrMigrateApprovalWithDetail added in v0.2.4

func ErrMigrateApprovalWithDetail(detail string) *gfsperrors.GfSpError

func ErrNotifySwapOutWithDetail added in v0.2.4

func ErrNotifySwapOutWithDetail(detail string) *gfsperrors.GfSpError

func MetadataHandlerFailureMetrics added in v0.2.3

func MetadataHandlerFailureMetrics(err error, startTime time.Time, handlerName string)

func MetadataHandlerSuccessMetrics added in v0.2.3

func MetadataHandlerSuccessMetrics(startTime time.Time, handlerName string)

func VerifyPersonalSignature

func VerifyPersonalSignature(signedMsg string, sigString string) (sdk.AccAddress, error)

Types

type GateModular

type GateModular struct {
	// contains filtered or unexported fields
}

func (*GateModular) Name

func (g *GateModular) Name() string

func (*GateModular) RegisterHandler

func (g *GateModular) RegisterHandler(router *mux.Router)

RegisterHandler registers the handlers to the gateway router.

func (*GateModular) ReleaseResource

func (g *GateModular) ReleaseResource(ctx context.Context, span rcmgr.ResourceScopeSpan)

func (*GateModular) ReserveResource

func (g *GateModular) ReserveResource(ctx context.Context, state *rcmgr.ScopeStat) (rcmgr.ResourceScopeSpan, error)

func (*GateModular) Start

func (g *GateModular) Start(ctx context.Context) error

func (*GateModular) Stop

func (g *GateModular) Stop(ctx context.Context) error

type RequestContext

type RequestContext struct {
	// contains filtered or unexported fields
}

RequestContext generates from http request, it records the common info for handler to use.

func NewRequestContext

func NewRequestContext(r *http.Request, g *GateModular) (*RequestContext, error)

NewRequestContext returns an instance of RequestContext, and verify the request signature, returns the instance regardless of the success or failure of the verification.

func (*RequestContext) Account

func (r *RequestContext) Account() string

Account returns the account who send the request.

func (*RequestContext) Cancel

func (r *RequestContext) Cancel()

Cancel releases the runtime context.

func (*RequestContext) CheckIfSigExpiry added in v0.2.4

func (r *RequestContext) CheckIfSigExpiry() error

func (*RequestContext) Context

func (r *RequestContext) Context() context.Context

Context returns the RequestContext runtime context.

func (*RequestContext) SetError

func (r *RequestContext) SetError(err error)

SetError sets the request err to RequestContext for logging and debugging.

func (*RequestContext) SetHTTPCode added in v0.2.5

func (r *RequestContext) SetHTTPCode(code int)

SetHTTPCode sets the http status code for logging and debugging.

func (*RequestContext) String

func (r *RequestContext) String() string

String shows the detail result of the request for logging and debugging.

func (*RequestContext) VerifySignature

func (r *RequestContext) VerifySignature() (string, error)

type RequestNonceResp added in v0.2.4

type RequestNonceResp struct {
	CurrentNonce     int32  `xml:"CurrentNonce"`
	NextNonce        int32  `xml:"NextNonce"`
	CurrentPublicKey string `xml:"CurrentPublicKey"`
	ExpiryDate       int64  `xml:"ExpiryDate"`
}

type SPCacheItem added in v0.2.6

type SPCacheItem struct {
	SPInfo                *sptypes.StorageProvider
	ExpireTimestampSecond int64
}

type SPCachePool added in v0.2.6

type SPCachePool struct {
	// contains filtered or unexported fields
}

func NewSPCachePool added in v0.2.6

func NewSPCachePool(chainClient consensus.Consensus) *SPCachePool

func (*SPCachePool) QuerySPByAddress added in v0.2.6

func (s *SPCachePool) QuerySPByAddress(spAddr string) (*sptypes.StorageProvider, error)

type UpdateUserPublicKeyResp added in v0.2.4

type UpdateUserPublicKeyResp struct {
	Result bool `xml:"Result"`
}

Jump to

Keyboard shortcuts

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