Skip to content

Remove User Id header #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 24, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.0.0-BETA32

* Added `onChange` method to the PowerSync client. This allows for observing table changes.
* Removed unnecessary `User-Id` header from internal PowerSync service requests.

## 1.0.0-BETA31

Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ Current limitations:

- Integration with SQLDelight schema and API generation (ORM) is not yet supported.

Future work/ideas:
- Attachments helper package.

## Installation

Add the PowerSync Kotlin Multiplatform SDK to your project by adding the following to your `build.gradle.kts` file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,9 @@ public class SupabaseConnector(

check(session.user != null) { "No user data" }

// userId is for debugging purposes only
PowerSyncCredentials(
endpoint = powerSyncEndpoint,
token = session.accessToken, // Use the access token to authenticate against PowerSync
userId = session.user!!.id,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ internal class ActiveDatabaseTest(
everySuspend { getCredentialsCached() } returns
PowerSyncCredentials(
token = "test-token",
userId = "test-user",
endpoint = "https://test.com",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ public data class PowerSyncCredentials(
/**
* User ID.
*/
@SerialName("user_id") val userId: String?,
@Deprecated(
message = "This property is no longer used and should be removed.",
level = DeprecationLevel.WARNING,
)
@SerialName("user_id")
val userId: String? = null,
) {
override fun toString(): String = "PowerSyncCredentials<endpoint: $endpoint userId: $userId>"

Expand Down
2 changes: 0 additions & 2 deletions core/src/commonMain/kotlin/com/powersync/sync/SyncStream.kt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ internal class SyncStream(
contentType(ContentType.Application.Json)
headers {
append(HttpHeaders.Authorization, "Token ${credentials.token}")
append("User-Id", credentials.userId ?: "")
}
}
if (response.status.value == 401) {
Expand Down Expand Up @@ -202,7 +201,6 @@ internal class SyncStream(
contentType(ContentType.Application.Json)
headers {
append(HttpHeaders.Authorization, "Token ${credentials.token}")
append("User-Id", credentials.userId ?: "")
}
timeout { socketTimeoutMillis = Long.MAX_VALUE }
setBody(bodyJson)
Expand Down
1 change: 0 additions & 1 deletion core/src/commonTest/kotlin/com/powersync/TestConnector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class TestConnector : PowerSyncBackendConnector() {
var fetchCredentialsCallback: suspend () -> PowerSyncCredentials? = {
PowerSyncCredentials(
token = "test-token",
userId = "test-user",
endpoint = "https://test.com",
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class SyncStreamTest {
everySuspend { getCredentialsCached() } returns
PowerSyncCredentials(
token = "test-token",
userId = "test-user",
endpoint = "https://test.com",
)
}
Expand Down