From ff49510a73c48620e6ce4e59f2babf26dd7d7f64 Mon Sep 17 00:00:00 2001 From: Dominic Wong Date: Mon, 13 Dec 2021 17:02:59 +0000 Subject: [PATCH 1/3] docs --- space/proto/space.pb.go | 14 +++++--------- space/proto/space.proto | 8 ++------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/space/proto/space.pb.go b/space/proto/space.pb.go index d3f6a10..8d2c401 100644 --- a/space/proto/space.pb.go +++ b/space/proto/space.pb.go @@ -20,15 +20,13 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// Create an object. Returns error if object with this name already exists. If you want to update an existing object use the `Update` endpoint -// You need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. +// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint type CreateRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The contents of the object + // The contents of the object. Either base64 encoded if sending request as application/json or raw bytes if using multipart/form-data format Object []byte `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` // The name of the object. Use forward slash delimiter to implement a nested directory-like structure e.g. images/foo.jpg Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` @@ -138,14 +136,12 @@ func (x *CreateResponse) GetUrl() string { } // Update an object. If an object with this name does not exist, creates a new one. -// You need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. type UpdateRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The contents of the object + // The contents of the object. Either base64 encoded if sending request as application/json or raw bytes if using multipart/form-data format Object []byte `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` // The name of the object. Use forward slash delimiter to implement a nested directory-like structure e.g. images/foo.jpg Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` @@ -984,7 +980,7 @@ func (x *DownloadResponse) GetUrl() string { return "" } -// Upload a large object. Returns a time limited presigned URL to be used for uploading the object +// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object type UploadRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1046,7 +1042,7 @@ type UploadResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // a presigned url to be used for uploading + // a presigned url to be used for uploading. To use the URL call it with HTTP PUT and pass the object as the request data Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` } diff --git a/space/proto/space.proto b/space/proto/space.proto index 857c441..1b6693c 100644 --- a/space/proto/space.proto +++ b/space/proto/space.proto @@ -16,10 +16,8 @@ service Space { } // Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint -// You need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. message CreateRequest { - // The contents of the object + // The contents of the object. Either base64 encoded if sending request as application/json or raw bytes if using multipart/form-data format bytes object = 1; // The name of the object. Use forward slash delimiter to implement a nested directory-like structure e.g. images/foo.jpg string name = 2; @@ -33,10 +31,8 @@ message CreateResponse { } // Update an object. If an object with this name does not exist, creates a new one. -// You need to send the request as a multipart/form-data rather than the usual application/json -// with each parameter as a form field. message UpdateRequest { - // The contents of the object + // The contents of the object. Either base64 encoded if sending request as application/json or raw bytes if using multipart/form-data format bytes object = 1; // The name of the object. Use forward slash delimiter to implement a nested directory-like structure e.g. images/foo.jpg string name = 2; From 5220d7fadeba503263e783f8f97b071a35ebe357 Mon Sep 17 00:00:00 2001 From: Daniel Joudat Date: Mon, 13 Dec 2021 21:47:24 +0300 Subject: [PATCH 2/3] fix an error when calling VerifyToken with valid Token (#327) * add two rpcs to User service: - Passwordless: endpoint that receives an email, topic and an optional message - PasswordlessML: endpoint that receives token and topic via MagicLink. * Proposal to add Passwordless login feature to the endpoint user. * remove currency run check * Commit from GitHub Actions (Publish APIs & Clients) * Create downstream.yml * Commit from GitHub Actions (Publish APIs & Clients) * update todo * Commit from GitHub Actions (Publish APIs & Clients) * Update publish.yml * Commit from GitHub Actions (Publish APIs & Clients) * Update publish.yml * Commit from GitHub Actions (Publish APIs & Clients) * Update and rename publish.yml to generate.yml * Update generate.yml * Commit from GitHub Actions (Generate Clients & Examples) * Commit from GitHub Actions (Generate Clients & Examples) * add comments * Commit from GitHub Actions (Generate Clients & Examples) * move otp to auth category * charge for user verification * Commit from GitHub Actions (Generate Clients & Examples) * Update user.proto * Commit from GitHub Actions (Generate Clients & Examples) * Commit from GitHub Actions (Generate Clients & Examples) * Change js client git repo url (#249) * Commit from GitHub Actions (Generate Clients & Examples) * use tableName func for Count * Commit from GitHub Actions (Generate Clients & Examples) * update notes example * Commit from GitHub Actions (Generate Clients & Examples) * Update .gitignore * Update .gitignore * Commit from GitHub Actions (Generate Clients & Examples) * add new endpoints SendMagicLink and VerifyToken to M3O user serivce Signed-off-by: Daniel Joudat * fix an error in user.VerifyToken Signed-off-by: Daniel Joudat * OSD add another check for err in user CacheReadToken Signed-off-by: Daniel Joudat Co-authored-by: Asim Aslam Co-authored-by: asim Co-authored-by: Janos Dobronszki Co-authored-by: crufter --- user/domain/domain.go | 2 +- user/handler/handler.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/user/domain/domain.go b/user/domain/domain.go index 8a42fd5..4cbd14d 100644 --- a/user/domain/domain.go +++ b/user/domain/domain.go @@ -501,7 +501,7 @@ func (domain *Domain) CacheReadToken(ctx context.Context, token string) (string, expires, err := cache.Context(ctx).Get(token, email) - if err == cache.ErrNotFound { + if err != nil && err == cache.ErrNotFound { return "", errors.New("token not found") } else if time.Until(expires).Seconds() < 0 { return "", errors.New("token expired") diff --git a/user/handler/handler.go b/user/handler/handler.go index cac0129..14a1f34 100644 --- a/user/handler/handler.go +++ b/user/handler/handler.go @@ -437,15 +437,15 @@ func (s *User) VerifyToken(ctx context.Context, req *pb.VerifyTokenRequest, rsp // check if token is valid email, err := s.domain.CacheReadToken(ctx, token) - if err.Error() == "token not found" { + if err != nil && err.Error() == "token not found" { rsp.IsValid = false rsp.Message = err.Error() return nil - } else if err.Error() == "token expired" { + } else if err != nil && err.Error() == "token expired" { rsp.IsValid = false rsp.Message = err.Error() return nil - } else if err.Error() == "token empty" { + } else if err != nil && err.Error() == "token empty" { rsp.IsValid = false rsp.Message = err.Error() return nil From 09d6f9f615879ff2597d50d33cd1842d1040117f Mon Sep 17 00:00:00 2001 From: Daniel Joudat Date: Tue, 14 Dec 2021 12:10:45 +0300 Subject: [PATCH 3/3] Add missing '&' (#329) --- user/domain/domain.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/user/domain/domain.go b/user/domain/domain.go index 4cbd14d..454019a 100644 --- a/user/domain/domain.go +++ b/user/domain/domain.go @@ -499,15 +499,17 @@ func (domain *Domain) CacheReadToken(ctx context.Context, token string) (string, var email string - expires, err := cache.Context(ctx).Get(token, email) + expires, err := cache.Context(ctx).Get(token, &email) if err != nil && err == cache.ErrNotFound { return "", errors.New("token not found") - } else if time.Until(expires).Seconds() < 0 { - return "", errors.New("token expired") } else if err != nil { return "", microerr.InternalServerError("CacheReadToken", err.Error()) } + if time.Until(expires).Seconds() < 0 { + return "", errors.New("token expired") + } + return email, nil }