Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.98.0"
".": "0.98.1"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.98.1 (2025-12-12)

Full Changelog: [v0.98.0...v0.98.1](https://github.com/lithic-com/lithic-go/compare/v0.98.0...v0.98.1)

### Bug Fixes

* **api:** include schema and base URL in GetEmbedURL ([09f2a83](https://github.com/lithic-com/lithic-go/commit/09f2a83e006afa2339f0dd388c564779e1dc0511))

## 0.98.0 (2025-12-10)

Full Changelog: [v0.97.0...v0.98.0](https://github.com/lithic-com/lithic-go/compare/v0.97.0...v0.98.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/lithic-com/lithic-go@v0.98.0'
go get -u 'github.com/lithic-com/lithic-go@v0.98.1'
```

<!-- x-release-please-end -->
Expand Down
10 changes: 9 additions & 1 deletion card.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func (r *CardService) GetEmbedHTML(ctx context.Context, params CardGetEmbedHTMLP
// but **do not ever embed your API key into front end code, as doing so introduces
// a serious security vulnerability**.
func (r *CardService) GetEmbedURL(ctx context.Context, params CardGetEmbedURLParams, opts ...option.RequestOption) (res *url.URL, err error) {
opts = slices.Concat(r.Options, opts)
buf, err := params.MarshalJSON()
if err != nil {
return nil, err
Expand All @@ -240,7 +241,14 @@ func (r *CardService) GetEmbedURL(ctx context.Context, params CardGetEmbedURLPar
if err != nil {
return nil, err
}
return cfg.Request.URL, nil
baseURL := cfg.BaseURL
if baseURL == nil {
baseURL = cfg.DefaultBaseURL
}
if baseURL == nil {
return nil, errors.New("base url is not set")
}
return baseURL.Parse(cfg.Request.URL.String())
}

// Allow your cardholders to directly add payment cards to the device's digital
Expand Down
65 changes: 46 additions & 19 deletions card_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,31 +259,58 @@ func TestCardGetEmbedHTMLWithOptionalParams(t *testing.T) {
}
}

func TestCardGetEmbedURLWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
func TestCardGetEmbedURL_URLConstruction(t *testing.T) {
// Use fixed inputs to verify URL construction and signature
client := lithic.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My Lithic API Key"),
option.WithBaseURL("https://sandbox.lithic.com"),
option.WithAPIKey("test-api-key-12345"),
)
_, err := client.Cards.GetEmbedURL(context.TODO(), lithic.CardGetEmbedURLParams{
Token: lithic.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
Css: lithic.F("string"),
Expiration: lithic.F(time.Now()),
TargetOrigin: lithic.F("string"),

expiration, err := time.Parse(time.RFC3339, "2025-01-01T00:00:00Z")
if err != nil {
t.Fatalf("failed to parse expiration: %s", err.Error())
}

url, err := client.Cards.GetEmbedURL(context.TODO(), lithic.CardGetEmbedURLParams{
Token: lithic.F("test-card-token-abc123"),
Css: lithic.F("https://example.com/style.css"),
Expiration: lithic.F(expiration),
TargetOrigin: lithic.F("https://example.com"),
})
if err != nil {
var apierr *lithic.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}

// Verify URL structure
if url.Scheme != "https" {
t.Errorf("expected scheme 'https', got '%s'", url.Scheme)
}
if url.Host != "sandbox.lithic.com" {
t.Errorf("expected host 'sandbox.lithic.com', got '%s'", url.Host)
}
if url.Path != "/v1/embed/card" {
t.Errorf("expected path '/v1/embed/card', got '%s'", url.Path)
}

// Verify query params exist
query := url.Query()
if query.Get("embed_request") == "" {
t.Error("expected 'embed_request' query param to be present")
}
if query.Get("hmac") == "" {
t.Error("expected 'hmac' query param to be present")
}

// Verify exact values to prevent signature regressions
expectedEmbedRequest := "eyJjc3MiOiJodHRwczovL2V4YW1wbGUuY29tL3N0eWxlLmNzcyIsImV4cGlyYXRpb24iOiIyMDI1LTAxLTAxVDAwOjAwOjAwWiIsInRhcmdldF9vcmlnaW4iOiJodHRwczovL2V4YW1wbGUuY29tIiwidG9rZW4iOiJ0ZXN0LWNhcmQtdG9rZW4tYWJjMTIzIn0="
expectedHmac := "tHf1AsLDIO7gHDA+N/3d5RT446tSmorVbjELGXF/UKQ="

if query.Get("embed_request") != expectedEmbedRequest {
t.Errorf("embed_request mismatch:\n got: %s\n want: %s", query.Get("embed_request"), expectedEmbedRequest)
}
if query.Get("hmac") != expectedHmac {
t.Errorf("hmac mismatch:\n got: %s\n want: %s", query.Get("hmac"), expectedHmac)
}
}

func TestCardProvisionWithOptionalParams(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "0.98.0" // x-release-please-version
const PackageVersion = "0.98.1" // x-release-please-version