From 7bbba94e2a1f91d725a06ffc66159b79ea616548 Mon Sep 17 00:00:00 2001 From: Vaggelis Yfantis Date: Wed, 15 Jan 2025 19:31:51 +0200 Subject: [PATCH 1/2] fix: Remove createTOTP --- user/client.go | 12 ------------ user/client_test.go | 21 --------------------- 2 files changed, 33 deletions(-) diff --git a/user/client.go b/user/client.go index dd32b8a..14cfd48 100644 --- a/user/client.go +++ b/user/client.go @@ -524,18 +524,6 @@ func (c *Client) DeleteWeb3Wallet(ctx context.Context, userID, identificationID return resource, err } -// CreateTOTP creates a TOTP (Time-based One-Time Password) for the user. -func (c *Client) CreateTOTP(ctx context.Context, userID string) (*clerk.TOTP, error) { - path, err := clerk.JoinPath(path, userID, "/totp") - if err != nil { - return nil, err - } - req := clerk.NewAPIRequest(http.MethodPost, path) - resource := &clerk.TOTP{} - err = c.Backend.Call(ctx, req, resource) - return resource, err -} - // DeleteTOTP deletes all the TOTPs from a given user. func (c *Client) DeleteTOTP(ctx context.Context, userID string) (*MultifactorAuthentication, error) { path, err := clerk.JoinPath(path, userID, "/totp") diff --git a/user/client_test.go b/user/client_test.go index 2ee8f7a..0ecc449 100644 --- a/user/client_test.go +++ b/user/client_test.go @@ -511,27 +511,6 @@ func TestUserClientDeleteWeb3Wallet(t *testing.T) { require.Equal(t, web3WalletIdentificationID, web3Wallet.ID) } -func TestUserClientCreateTOTP(t *testing.T) { - t.Parallel() - userID := "user_123" - config := &clerk.ClientConfig{} - config.HTTPClient = &http.Client{ - Transport: &clerktest.RoundTripper{ - T: t, - Method: http.MethodPost, - Out: json.RawMessage(`{"backup_codes":[],"created_at":1725548779338,"id":"totp_id","object":"totp","secret":"secret","updated_at":1725548779338,"uri":"otpauth://totp/","verified":false}`), - Path: fmt.Sprintf("/v1/users/%s/totp", userID), - }, - } - client := NewClient(config) - totp, err := client.CreateTOTP(context.Background(), userID) - require.NoError(t, err) - require.NotNil(t, totp.ID) - require.NotNil(t, totp.Secret) - require.NotNil(t, totp.URI) - require.Equal(t, totp.Object, "totp") -} - func TestUserClientDeleteTOTP(t *testing.T) { t.Parallel() userID := "user_123" From 2213c81bdb2d7be02fe94355007665e77195b3f5 Mon Sep 17 00:00:00 2001 From: Vaggelis Yfantis Date: Wed, 15 Jan 2025 19:36:28 +0200 Subject: [PATCH 2/2] chore: Remove CreateTOTP from api and remove TOTP types --- totp.go | 14 -------------- user/api.go | 5 ----- 2 files changed, 19 deletions(-) delete mode 100644 totp.go diff --git a/totp.go b/totp.go deleted file mode 100644 index e545c69..0000000 --- a/totp.go +++ /dev/null @@ -1,14 +0,0 @@ -package clerk - -// Describes a Time-based One-time Password (TOTP) for a user. -type TOTP struct { - APIResource - Object string `json:"object"` - ID string `json:"id"` - Secret *string `json:"secret"` - URI *string `json:"uri" ` - Verified bool `json:"verified"` - BackupCodes []string `json:"backup_codes"` - CreatedAt int64 `json:"created_at"` - UpdatedAt int64 `json:"updated_at"` -} diff --git a/user/api.go b/user/api.go index 9b4938a..04c73cc 100644 --- a/user/api.go +++ b/user/api.go @@ -105,11 +105,6 @@ func DeleteWeb3Wallet(ctx context.Context, userID, identificationID string) (*cl return getClient().DeleteWeb3Wallet(ctx, userID, identificationID) } -// CreateTOTP creates a TOTP (Time-based One-Time Password) for the user. -func CreateTOTP(ctx context.Context, userID string) (*clerk.TOTP, error) { - return getClient().CreateTOTP(ctx, userID) -} - // DeleteTOTP deletes all the TOTPs from a given user. func DeleteTOTP(ctx context.Context, userID string) (*MultifactorAuthentication, error) { return getClient().DeleteTOTP(ctx, userID)