repo_name stringlengths 1 62 | dataset stringclasses 1
value | lang stringclasses 11
values | pr_id int64 1 20.1k | owner stringlengths 2 34 | reviewer stringlengths 2 39 | diff_hunk stringlengths 15 262k | code_review_comment stringlengths 1 99.6k |
|---|---|---|---|---|---|---|---|
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -3,6 +3,9 @@ plugins {
kotlin("plugin.serialization")
id("maven-publish")
id("com.github.ben-manes.versions")
+ id("java")
+ // Apply the application plugin to add support for building a CLI application in Java.
+ application | Just application should be required |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -51,6 +54,12 @@ kotlin {
// Logging
implementation("io.github.oshai:kotlin-logging:5.1.0")
+
+ // JOSE
+ implementation("com.nimbusds:nimbus-jose-jwt:9.37.3") | Is a JVM library, add to jvmMain; same for bouncycastle |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,164 @@
+package id.walt.cli
+
+import com.github.ajalt.clikt.core.BadParameterValue
+import com.github.ajalt.clikt.core.IncorrectOptionValueCount
+import com.github.ajalt.clikt.core.PrintHelpMessage
+import com.github.ajalt.clikt.testing.test
+import id.walt.cli.commands.KeyGenerateCmd
+import kotlinx.corout... | replace jupiter with kotlin.test as explained by mikerichardson in https://matrix.to/#/!TDHVHVCyINevPJXOgr:matrix.org/$1UVrfrHorE8TWKvxxrxDp5fRv8HD7PwiTVd8Hpw6AJ4?via=matrix.org |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,220 @@
+package id.walt.cli
+
+import com.github.ajalt.clikt.core.IncorrectOptionValueCount
+import com.github.ajalt.clikt.core.MissingOption
+import com.github.ajalt.clikt.core.MultiUsageError
+import com.github.ajalt.clikt.core.PrintHelpMessage
+import com.github.ajalt.clikt.testing.test
+import id.walt.cl... | if you don't want to escape so much, you can do strings with triple quotation marks, e.g.
```kotlin
"""("kid":".*")*"""
```
instead of
```kotlin
"(\"kid\":\".*\")*"
``` |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,66 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.BadParameterValue
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.default
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.optio... | We haven't tried this yet (it's still experimental), but it would be interesting if the [kotlinx-io](https://github.com/Kotlin/kotlinx-io) multiplatform APIs can already be used instead of java.io.File (for file writes -> last line) |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,203 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.option
+import com.github.ajalt.clikt.parameters.options.required
+import com.github.ajalt.clikt.parameters.types.fi... | instead of trying and failing, I would simply have a "header" check, e.g.
- PEM files start with `-----BEGIN RSA PRIVATE KEY-----` or `-----BEGIN PRIVATE KEY-----` etc.
- JWK files are JSON (= start with `{`) |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,203 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.option
+import com.github.ajalt.clikt.parameters.options.required
+import com.github.ajalt.clikt.parameters.types.fi... | use `val key = LocalKey.importJWK(jwkString)` |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,203 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.option
+import com.github.ajalt.clikt.parameters.options.required
+import com.github.ajalt.clikt.parameters.types.fi... | use `val key = LocalKey.importPEM(pemString)` |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,203 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.option
+import com.github.ajalt.clikt.parameters.options.required
+import com.github.ajalt.clikt.parameters.types.fi... | no lateinit var in functions / avoid in general if possible |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,203 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.option
+import com.github.ajalt.clikt.parameters.options.required
+import com.github.ajalt.clikt.parameters.types.fi... | ```kotlin
enum EncodedKeyType {
JWK,
PEM
}
val fileContent = readFile(xyz)
val keyType = determineKeyType(fileContent)
val key = when (keyType) {
EncodedKeyType.JWK -> LocalKey.importJWK(fileContent)
EncodedKeyType.PEM -> LocalKey.importPEM(fileContent)
else -> error("Unknown key type fo... |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,203 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.option
+import com.github.ajalt.clikt.parameters.options.required
+import com.github.ajalt.clikt.parameters.types.fi... | `val outputFile = output ?: File(input.parent, "${input.nameWithoutExtension}.${outputFileExtension}")`
edit: nvm actually just take the opposite of `val keyType = determineKeyType(fileContent)` as written in comment above -> files might not have a file extension, but keys are nonetheless readable & type can be de... |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,203 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.option
+import com.github.ajalt.clikt.parameters.options.required
+import com.github.ajalt.clikt.parameters.types.fi... | ```kotlin
val outputContent: String = when (outputType) {
EncodedKeyType.JWK -> key.exportJWK()
EncodedKeyType.PEM -> key.exportPEM()
} |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,203 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.option
+import com.github.ajalt.clikt.parameters.options.required
+import com.github.ajalt.clikt.parameters.types.fi... | encrypted PEM stuff not required for now |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,66 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.BadParameterValue
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.default
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.optio... | ```kotlin
val keyType by option().enum<id.walt.crypto.keys.KeyType>()
```
> Enum parameters accept case-insensitive values by default. This can be configured by passing ignoreCase = false |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,66 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.BadParameterValue
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.default
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.optio... | `by option("-o", "--output").file()` or `by option("-o", "--output").path()` |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,66 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.BadParameterValue
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.default
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.optio... | for enum: `keyType.name` |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,66 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.BadParameterValue
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.default
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.optio... | block should not be required with option().enum() |
waltid-identity | github_2023 | others | 148 | walt-id | waltkb | @@ -0,0 +1,66 @@
+package id.walt.cli.commands
+
+import com.github.ajalt.clikt.core.BadParameterValue
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.default
+import com.github.ajalt.clikt.parameters.options.help
+import com.github.ajalt.clikt.parameters.options.optio... | error will probably already be generated by clikt with option().enum() |
waltid-identity | github_2023 | others | 148 | walt-id | philpotisk | @@ -1 +1,202 @@
# walt.id CLI
+
+Manage keys, DIDs, issue Verifiable Credentials, and verify them using the WaltId command line tool.
+
+# How to use
+
+## In development
+
+* `git clone https://github.com/walt-id/waltid-identity.git`
+* `cd waltid-identity/waltid-cli`
+* Run one of the following commands
+
+| Command... | [Ed25519 | secp256k1 | secp256r1 | RSA}]
The curly bracket after RSA seems to be a typo |
waltid-identity | github_2023 | others | 144 | walt-id | waltkb | @@ -130,13 +128,15 @@ class SSIKit2WalletService(
CredentialsService.get(walletId, credentialId)
?: throw IllegalArgumentException("WalletCredential not found for credentialId: $credentialId")
- override suspend fun attachCategory(credentialId: String, category: String): Boolean =
- ca... | ```kotlin
object WalletCategory : Table("category") {
val wallet = reference("wallet", Wallets)
val name = varchar("name", 128)
override val primaryKey = PrimaryKey(wallet, name)
}
@Serializable
data class WalletCategoryData(
val name: String,
// <--
) {
constructor(row: ResultRow... |
waltid-identity | github_2023 | others | 144 | walt-id | waltkb | @@ -130,13 +128,15 @@ class SSIKit2WalletService(
CredentialsService.get(walletId, credentialId)
?: throw IllegalArgumentException("WalletCredential not found for credentialId: $credentialId")
- override suspend fun attachCategory(credentialId: String, category: String): Boolean =
- ca... | Why is this substring matching actually required? |
waltid-identity | github_2023 | others | 144 | walt-id | WaltId-MikeRichardson | @@ -170,9 +170,9 @@ class WalletKitWalletService(tenant: String, accountId: UUID, walletId: UUID) :
) | I can't see where this class is used. The only place that references it is in the `getWalletService` of `WalletServiceManager `and that line is commented out. |
waltid-identity | github_2023 | others | 153 | walt-id | philpotisk | @@ -11,6 +11,7 @@ import io.github.smiley4.ktorswaggerui.dsl.route
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.response.*
+import io.ktor.server.util.*
import kotlinx.serialization.json.JsonObject
fun Application.manifest() = walletRoute { | remove redundant code |
waltid-identity | github_2023 | others | 153 | walt-id | philpotisk | @@ -22,7 +26,8 @@ object WalletCredentials : Table("credentials") {
val addedOn = timestamp("added_on")
val manifest = text("manifest").nullable()
-// val delete = bool("delete").default(false)
+
+ // val delete = bool("delete").default(false) | remove commented code |
waltid-identity | github_2023 | others | 153 | walt-id | philpotisk | @@ -143,36 +142,31 @@ object CredentialsService {
additionalConstraint = {
WalletCredentials.wallet eq wallet and (WalletCredentialCategoryMap.wallet eq wallet) and deletedCondition(
deleted
- )
+ ) and (WalletCredentials.pending eq false)... | elaborate what needs to be done, or remove TODO |
waltid-identity | github_2023 | javascript | 163 | walt-id | philpotisk | @@ -1,6 +1,7 @@
/** @type {import('next').NextConfig} */ | please consider removing commented code |
waltid-identity | github_2023 | javascript | 163 | walt-id | philpotisk | @@ -1,6 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: false,
+ output: 'standalone',
//TODO: fix env | remove or fix this one |
waltid-identity | github_2023 | others | 109 | walt-id | philpotisk | @@ -519,75 +519,20 @@ class SSIKit2WalletService(
throw IllegalStateException("No credential was returned from credentialEndpoint: $credentialResponses")
}
- val addableCredentials: List<WalletCredential> = credentialResponses.map { credentialResp ->
- val credential = credenti... | refactor & remove todo |
waltid-identity | github_2023 | others | 109 | walt-id | philpotisk | @@ -879,4 +824,78 @@ class SSIKit2WalletService(
val itemIndex = afterItemIndex + pageSize
itemIndex.takeIf { it < count }?.toString()
}
+
+ private fun getCredentialData(
+ credentialResp: CredentialResponse, manifest: JsonObject?, silent: Boolean
+ ) = let {
+ val credential... | use logging instead of println |
waltid-identity | github_2023 | others | 109 | walt-id | philpotisk | @@ -0,0 +1,56 @@
+package id.walt.webwallet.service.trust
+
+import id.walt.webwallet.config.TrustConfig
+import io.ktor.client.*
+import io.ktor.client.request.*
+import io.ktor.client.statement.*
+import kotlinx.datetime.Clock
+import kotlinx.datetime.Instant
+import kotlinx.serialization.json.Json
+
+class EntraIssu... | Remove Entra, where it is not used aligned with MS documentation |
waltid-identity | github_2023 | others | 109 | walt-id | github-advanced-security[bot] | @@ -355,49 +363,49 @@
credentialOfferRequest: CredentialOfferRequest,
credentialWallet: TestCredentialWallet
): List<CredentialResponse> {
- println("// get issuer metadata")
+ logger.debug("// get issuer metadata")
val providerMetadataUri =
credentialWallet.ge... | ## Insertion of sensitive information into log files
This [potentially sensitive information](1) is written to a log file.
[Show more details](https://github.com/walt-id/waltid-identity/security/code-scanning/13) |
waltid-identity | github_2023 | others | 109 | walt-id | github-advanced-security[bot] | @@ -355,49 +363,49 @@
credentialOfferRequest: CredentialOfferRequest,
credentialWallet: TestCredentialWallet
): List<CredentialResponse> {
- println("// get issuer metadata")
+ logger.debug("// get issuer metadata")
val providerMetadataUri =
credentialWallet.ge... | ## Insertion of sensitive information into log files
This [potentially sensitive information](1) is written to a log file.
[Show more details](https://github.com/walt-id/waltid-identity/security/code-scanning/14) |
waltid-identity | github_2023 | others | 110 | walt-id | waltkb | @@ -433,5 +434,9 @@ class WalletKitWalletService(tenant: String, accountId: UUID, walletId: UUID) :
override suspend fun deleteCategory(name: String): Boolean {
TODO("Not yet implemented") | Please replace the `TODO("")` with `throw NotImplementedError("")` here (it is not TODO as we will not add this for the old WalletKitWalletService - we will remove it soon) |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -0,0 +1,21 @@
+package id.walt.webwallet.db.models
+
+import kotlinx.serialization.Serializable
+import org.jetbrains.exposed.sql.ResultRow
+import org.jetbrains.exposed.sql.Table
+
+object WalletCategory : Table("category") { | Maybe refer to category by ID to allow for easier category renaming? -> Add `val id = kotlinUUID("id")` & change primaryKey: `primaryKey = PrimaryKey(wallet, id)` |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -0,0 +1,21 @@
+package id.walt.webwallet.db.models
+
+import kotlinx.serialization.Serializable
+import org.jetbrains.exposed.sql.ResultRow
+import org.jetbrains.exposed.sql.Table
+
+object WalletCategory : Table("category") {
+ val wallet = reference("wallet", Wallets)
+ val name = varchar("name", 128)
+
+ ... | WalletCategoryData(val wallet: String, val id: String, val name: String) |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -0,0 +1,21 @@
+package id.walt.webwallet.db.models
+
+import kotlinx.serialization.Serializable
+import org.jetbrains.exposed.sql.ResultRow
+import org.jetbrains.exposed.sql.Table
+
+object WalletCategory : Table("category") {
+ val wallet = reference("wallet", Wallets)
+ val name = varchar("name", 128)
+
+ ... | wallet: String
id: String
name: String |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -0,0 +1,20 @@
+package id.walt.webwallet.db.models
+
+import kotlinx.uuid.exposed.kotlinxUUID
+import org.jetbrains.exposed.sql.Table
+
+object WalletCredentialCategoryMap : Table("credential_category") {
+ //TODO: validate wallet is consistent for both category and credential
+ val wallet = kotlinxUUID("walle... | val category = kotlinUUID("category") |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -22,6 +23,8 @@ object WalletCredentials : Table("credentials") {
val addedOn = timestamp("added_on")
val manifest = text("manifest")
+ val delete = bool("delete").default(false)
+ val deletedOn = timestamp("deleted_on").nullable().default(null) | both boolean and nullable date required? |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -34,6 +37,8 @@ data class WalletCredential(
val disclosures: String?,
val addedOn: Instant,
val manifest: String,
+ @Transient val delete: Boolean = false,
+ val deletedOn: Instant?, | `val deletedOn: Instant? = null` should be enough (instead of transient boolean) |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -84,25 +94,38 @@ class SSIKit2WalletService(tenant: String, accountId: UUID, walletId: UUID) :
}
}
- override fun listCredentials(): List<WalletCredential> = CredentialsService.list(walletId)
+ override fun listCredentials(filter: CredentialFilterObject): List<WalletCredential> =
+ Crede... | fyi: you can write `throw IllegalArgumentException("...")` shorter with `error("...")` -> same thing internally |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -125,11 +126,18 @@ class WalletKitWalletService(tenant: String, accountId: UUID, walletId: UUID) :
/* WalletCredentials */
- override fun listCredentials() = runBlocking {
+ override fun listCredentials(filter: CredentialFilterObject) = runBlocking {
authenticatedJsonGet("/api/wallet/credenti... | please add argument names for long lists like this (Alt+Enter -> "add argument names to all call arguments") |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -0,0 +1,33 @@
+package id.walt.webwallet.service.category
+
+import id.walt.webwallet.db.models.WalletCategory
+import id.walt.webwallet.db.models.WalletCategoryData
+import kotlinx.uuid.UUID
+import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
+import org.jetbrains.exposed.sql.and
+import org.jetbrains.exposed... | `WalletCategory.select { (WalletCategory.wallet eq wallet) and (WalletCategory.name eq name) }` / or better refer to category it by ID |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -18,14 +19,27 @@ fun Application.credentials() = walletRoute {
}) {
get({
summary = "List credentials"
+ request {
+ queryParameter<List<String>>("category"){
+ description = "list of category names"
+ required = false
+ ... | just `val showDeleted = call.request.queryParameters["showDeleted"].toBoolean()` is fine (String?.toBoolean() can be used on nullable strings, and returns false when it's null) |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -53,27 +67,109 @@ fun Application.credentials() = walletRoute {
}
}
}) {
- val credentialId =
- call.parameters["credentialId"] ?: throw IllegalArgumentException("No credentialId provided")
-
+ val credentialId = enfo... | this is the same as `parameters.getOrFail(name)`
> Get parameters value associated with this name or fail with MissingRequestParameterException |
waltid-identity | github_2023 | others | 80 | walt-id | philpotisk | @@ -0,0 +1,20 @@
+package id.walt.webwallet.db.models
+
+import kotlinx.uuid.exposed.kotlinxUUID
+import org.jetbrains.exposed.sql.Table
+
+object WalletCredentialCategoryMap : Table("credential_category") { | I hope you can get rid of the TODOs. We should allow updating of names, which should be fine if we only refer to the IDs, which are not supposed to be updated. |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -0,0 +1,21 @@
+package id.walt.webwallet.service.category
+
+import id.walt.webwallet.db.models.WalletCategoryData
+import kotlinx.uuid.UUID
+import kotlin.random.Random
+
+object MockCategoryService : CategoryService {
+ override fun list(wallet: UUID): List<WalletCategoryData> = listOfCategories
+ override f... | ```kotlin
private fun generate(length: Int) = CharArray(length) { charPool.random() }.concatToString()
``` |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -0,0 +1,21 @@
+package id.walt.webwallet.service.category
+
+import id.walt.webwallet.db.models.WalletCategoryData
+import kotlinx.uuid.UUID
+import kotlin.random.Random
+
+object MockCategoryService : CategoryService {
+ override fun list(wallet: UUID): List<WalletCategoryData> = listOfCategories
+ override f... | ```kotlin
val charPool: CharArray = (('a'..'z') + ('A'..'Z') + ('0'..'9')).toCharArray()
``` |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -18,14 +20,27 @@ fun Application.credentials() = walletRoute {
}) {
get({
summary = "List credentials"
+ request {
+ queryParameter<List<String>>("category"){
+ description = "list of category names"
+ required = false
+ ... | null and empty list have a different meaning attached to them. From an API standpoint I would have expected the API request without the category parameter to not engage the category filter (as a default), but filtering on an empty list of categories only returning the credentials that do not have an category attached t... |
waltid-identity | github_2023 | others | 80 | walt-id | waltkb | @@ -53,27 +68,106 @@ fun Application.credentials() = walletRoute {
}
}
}) {
- val credentialId =
- call.parameters["credentialId"] ?: throw IllegalArgumentException("No credentialId provided")
-
+ val credentialId = call... | I would combine the POST delete/soft and POST delete/hard to a single DELETE route, with the distinction soft & hard being done with a query parameter (with soft being the default) - thus replacing the "true" in deleteCredential(...) with `context.request.queryParameters["permanent"].toBoolean()` and being able to full... |
clashtui | github_2023 | others | 2 | JohanChane | JohanChane | @@ -77,6 +77,12 @@ fn run_app<B: Backend>(
) -> Result<()> {
let mut last_tick = Instant::now();
let mut last_ev = EventState::NotConsumed;
+ if app.clashtui_util.err_code != 0
+ {
+ app.popup_txt_msg("The config.yaml might be broken, the progrem will try to fix it".to_string());
+ app.ms... | You can delete it. `popup msg` method has called the `show` method. |
clashtui | github_2023 | others | 2 | JohanChane | JohanChane | @@ -75,7 +75,7 @@ impl App {
PathBuf::from(&clashtui_config_dir_str)
};
- if !clashtui_config_dir.join("basic_clash_config.yaml").exists() {
+ if !clashtui_config_dir.exists(){ //.join("basic_clash_config.yaml").exists() { // weird, shouldn`t we check the dir rather the single file... | Because of supporting the portable mode, users can simply create a 'data' directory in the program's directory. it would be better to check if the directory is not empty. Checking for file existing is just for convenience, which is not reasonable. |
clashtui | github_2023 | others | 2 | JohanChane | JohanChane | @@ -0,0 +1,111 @@
+pub struct ClashUtil{
+ client: reqwest::blocking::Client,
+ api: String,
+ proxy_addr: String,
+ default_payload: String,
+}
+
+impl ClashUtil {
+ pub fn new(controller_api:String, proxy_addr:String) -> Self{
+ let default_payload = "'{\"path\": \"\", \"payload\": \"\"}'".to_st... | In ClashUtil, it might be better to add an `Option<reqwest::blocking::Client>` as a cache. Since users' configurations might include multiple proxy and rule file links, some users might open ClashTui just to switch configurations without updating the profile. |
clashtui | github_2023 | others | 2 | JohanChane | JohanChane | @@ -38,7 +38,8 @@ impl Default for Symbols {
j/k/h/l OR Up/Down/Left/Right: Scroll
## Global
- R: Start clash service
+ R: Restart clash service
+ r: Restart clash core | Using uppercase for global hotkeys would make it more consistent. How about `E` (rEstart). |
Low-Cost-Mocap | github_2023 | python | 19 | jyjblrd | jyjblrd | @@ -11,15 +11,51 @@
import copy
import time
import serial
+import sys
+import glob
import threading
from ruckig import InputParameter, OutputParameter, Result, Ruckig
from flask_cors import CORS
import json
+def serial_ports():
+ """ https://stackoverflow.com/questions/12090503/listing-available-com-ports-w... | please rename to more descriptive names. ie. `list` --> `available_serial_ports`, and `serial_ports()` --> `get_serial_ports()` |
Low-Cost-Mocap | github_2023 | python | 19 | jyjblrd | jyjblrd | @@ -11,15 +11,51 @@
import copy
import time
import serial
+import sys
+import glob
import threading
from ruckig import InputParameter, OutputParameter, Result, Ruckig
from flask_cors import CORS
import json
+def serial_ports(): | Please move function to helpers.py |
Low-Cost-Mocap | github_2023 | python | 19 | jyjblrd | jyjblrd | @@ -11,15 +11,51 @@
import copy
import time
import serial
+import sys
+import glob
import threading
from ruckig import InputParameter, OutputParameter, Result, Ruckig
from flask_cors import CORS
import json
+def serial_ports():
+ """ https://stackoverflow.com/questions/12090503/listing-available-com-ports-w... | change to `print(f"Available ports: {available_serial_ports} \nConnecting to port: {available_serial_ports[0]}")`, and place above the serial.Serial(...) function call. |
Low-Cost-Mocap | github_2023 | others | 8 | jyjblrd | jyjblrd | @@ -9,8 +9,17 @@ This project requires the sfm (structure from motion) OpenCV module, which requi
`cv.sfm` is only used 3 times in the codebase for the following functions: `fundamentalFromProjections`, `essentialFromFundamental`, `motionFromEssential`. So really, those functions should just be reimplemented in Pyth... | probably remove these pip commands, since there are a lot more python libraries that need to be installed than just these. |
Low-Cost-Mocap | github_2023 | others | 8 | jyjblrd | jyjblrd | @@ -9,8 +9,17 @@ This project requires the sfm (structure from motion) OpenCV module, which requi
`cv.sfm` is only used 3 times in the codebase for the following functions: `fundamentalFromProjections`, `essentialFromFundamental`, `motionFromEssential`. So really, those functions should just be reimplemented in Pyth... | Replace this with a generic statement like "install [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) and [yarn](https://classic.yarnpkg.com/lang/en/docs/install)" |
threads-api | github_2023 | typescript | 189 | junhoyeo | aleclarson | @@ -934,9 +1070,229 @@ export class ThreadsAPI {
if (this.verbose) {
console.debug('[UNREPOST]', res.data);
}
+ return res.data.status === 'ok';
+ };
+ mute = async (muteOptions: {postID?: string, userID?: string}, options?: AxiosRequestConfig): Promise<boolean> => {
+ const url = `${BASE_API_U... | `target_posts_author_id` is required even when a post ID is given |
threads-api | github_2023 | typescript | 189 | junhoyeo | junhoyeo | @@ -934,9 +1070,229 @@ export class ThreadsAPI {
if (this.verbose) {
console.debug('[UNREPOST]', res.data);
}
+ return res.data.status === 'ok';
+ };
+ mute = async (muteOptions: {postID?: string, userID?: string}, options?: AxiosRequestConfig): Promise<boolean> => {
+ const url = `${BASE_API_U... | Can we have the `timezone_offset` from the user locale, as in #50?
https://github.com/junhoyeo/threads-api/blob/200ad48d33dc8afe6d14a6e627ac36b1fe711820/threads-api/src/threads-api.ts#L1328-L1333
We should manage this value as an memoized getter... |
threads-api | github_2023 | typescript | 189 | junhoyeo | junhoyeo | @@ -1006,7 +1147,7 @@ export class ThreadsAPI {
if (this.verbose) {
console.debug('[FOLLOW]', res.data);
}
- return res.data;
+ return res.data.status === 'ok'; | Reverting those to return `res.data` — the `friendship` response can really come in handy :) |
threads-api | github_2023 | typescript | 242 | junhoyeo | junhoyeo | @@ -70,6 +70,17 @@ export const APPS: AppRegistry[] = [
github_username: 'AayushGithub',
},
},
+ {
+ name: 'Threads Discord Bot',
+ tags: ['bot', 'discord'], | ```suggestion
tags: ['app', 'client'],
``` |
threads-api | github_2023 | typescript | 110 | junhoyeo | junhoyeo | @@ -111,7 +111,9 @@ export type ThreadsAPIPublishOptions =
| {
text?: string;
parentPostID?: string;
- } & ({ url?: string } | { image?: string });
+ } & ({ url?: string } | { image?: string | ThreadsAPIImage });
+
+export type ThreadsAPIImage = { name: string; data: Buffer }; | Since `name` is totally useless in that case, I would like to rename that to `type`/`mimeType`/`ext`(I'll put a 👍 to here) or whatever, and define `ThreadsAPIImage` like this:
```suggestion
export type ThreadsAPIImage = (
{ ext: string; data: Buffer } |
{ path: string; }
);
``` |
threads-api | github_2023 | typescript | 203 | junhoyeo | junhoyeo | @@ -1,19 +1,24 @@
import { ThreadsAPI } from '../src/threads-api';
import { TIMEOUT, rawCredentials as credentials } from './utils/constants';
import { describeIf } from './utils/describeIf';
-import * as HttpsProxyAgent from "https-proxy-agent";
+import * as HttpsProxyAgent from 'https-proxy-agent';
+import dotenv ... | Nice catch, thanks! |
threads-api | github_2023 | typescript | 203 | junhoyeo | junhoyeo | @@ -25,4 +35,8 @@ describeIf(!!credentials)('getToken', () => {
TIMEOUT,
);
});
+
+ it('should use the correct agent/proxy URL', () => {
+ expect(HttpsProxyAgentSpy).toHaveBeenCalledWith(proxy); | Wait I think this test is still wrong, this have no effect since we're not calling `getToken` here.
And we have to mock `HttpsProxyAgent` & reinit `ThreadsAPI` separated from the previous test, or it'll not work either. |
threads-api | github_2023 | typescript | 198 | junhoyeo | junhoyeo | @@ -1141,3 +1206,14 @@ export class ThreadsAPI {
}
};
}
+
+type Simplify<T> = {} & { [P in keyof T]: T[P] };
+
+type StrictUnion<T> = CombineUnion<T> extends infer U
+ ? T extends any
+ ? Simplify<T & { [K in Exclude<keyof U, keyof T>]?: undefined }>
+ : never
+ : never;
+
+type CombineUnion<T> = Pick<... | Have a feeling that we'll use this handy! Can we move this to `types/utils.ts` or some other separate file besides `threads-api.ts`? |
threads-api | github_2023 | typescript | 198 | junhoyeo | junhoyeo | @@ -979,29 +1023,48 @@ export class ThreadsAPI {
throw new Error('Token not found');
}
- const now = new Date();
- const timezoneOffset = -now.getTimezoneOffset() * 60;
-
let data: any = {
+ ...this._createUploadMetadata(),
text_post_app_info: {
- reply_control: REPLY_CONTROL... | 👍👍 |
threads-api | github_2023 | typescript | 198 | junhoyeo | junhoyeo | @@ -148,23 +149,50 @@ export type ThreadsAPIOptions = {
maxRetries?: number;
};
-export type ThreadsAPIPostReplyControl = 'everyone' | 'accounts_you_follow' | 'mentioned_only';
-
-const REPLY_CONTROL_IDS: Record<ThreadsAPIPostReplyControl, number> = {
+const REPLY_CONTROL_OPTIONS = {
everyone: 0,
accounts_y... | Nice tagging! 👍👍 |
threads-api | github_2023 | others | 163 | junhoyeo | junhoyeo | @@ -235,7 +235,7 @@ const threadsAPI = new ThreadsAPI({
});
```
-</details>
+</> | um this shouldn't be deleted |
threads-api | github_2023 | typescript | 158 | junhoyeo | junhoyeo | @@ -45,11 +49,21 @@ export type GetUserProfileThreadsResponse = {
};
export type GetUserProfileThreadsPaginatedResponse = {
status: 'ok';
- next_max_id: string;
+ next_max_id?: string; | oh my god I missed this 🤣 Thanks 👍👍 |
threads-api | github_2023 | typescript | 150 | junhoyeo | junhoyeo | @@ -351,7 +355,12 @@ export class ThreadsAPI {
_getAppHeaders = () => ({
'User-Agent': `Barcelona ${LATEST_ANDROID_APP_VERSION} Android`,
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
- ...(this.token ? { Authorization: `Bearer IGT:2:${this.token}` } : undefined),
+ ...(this.tok... | 👍👍👍 |
threads-api | github_2023 | typescript | 150 | junhoyeo | junhoyeo | @@ -133,6 +133,10 @@ interface UserIDQuerier<T extends any> {
(username: string, userID: string, options?: AxiosRequestConfig): Promise<T>;
}
+interface PaginationUserIDQuerier<T extends any> { | Awesome Type Wrapper 👍 |
threads-api | github_2023 | typescript | 151 | junhoyeo | junhoyeo | @@ -166,10 +167,20 @@ export class ThreadsAPI {
this.httpAgent = options?.httpAgent;
this.httpsAgent = options?.httpsAgent;
- this.username = options?.username;
- this.password = options?.password;
+ this.username = options?.username ?? process.env.THREADS_USERNAME;
+ this.password = options?.pa... | 👍👍👍 |
threads-api | github_2023 | others | 116 | junhoyeo | junhoyeo | @@ -25,10 +25,11 @@ yarn-debug.log*
yarn-error.log*
# local env files
-.env.local
-.env.development.local
-.env.test.local
-.env.production.local
+.env*.local
# vercel
.vercel
+
+# typescript
+*.tsbuildinfo
+next-env.d.ts | ```suggestion
next-env.d.ts
```
Why are you ignoring this file from version control? |
threads-api | github_2023 | typescript | 116 | junhoyeo | junhoyeo | @@ -0,0 +1,87 @@
+import Image from "next/image";
+import React from "react";
+import { Thread, ThreadsIcons } from "react-threads";
+import { ThreadsAPI } from "threads-api";
+
+const UserProfilePage = async ({
+ params,
+}: {
+ params: { username: string };
+}) => {
+ const threadsAPI = new ThreadsAPI();
+ const ... | ```suggestion
const params: [string, string] = [username, userID];
const [userProfile, userThreads] = await Promise.all([
threadsAPI.getUserProfile(...params),
threadsAPI.getUserProfileThreads(...params),
]);
```
`values` is way too general |
threads-api | github_2023 | others | 116 | junhoyeo | junhoyeo | @@ -0,0 +1,108 @@
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
+
+@layer base {
+ :root {
+ --background: 0 0% 100%;
+ --foreground: 222.2 84% 4.9%;
+
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9... | can you format this file? maybe `yarn format` will handle this for u |
threads-api | github_2023 | typescript | 116 | junhoyeo | junhoyeo | @@ -0,0 +1,23 @@
+import { GlobalStyle } from "@/components/GlobalStyle";
+import "./globals.css";
+import type { Metadata } from "next";
+import { Inter } from "next/font/google"; | `yarn format` should order imports |
threads-api | github_2023 | javascript | 116 | junhoyeo | junhoyeo | @@ -1,18 +1,12 @@
-module.exports = {
- reactStrictMode: true,
- compiler: {
- emotion: true,
- },
+/** @type {import('next').NextConfig} */
+const nextConfig = {
images: {
remotePatterns: [
{
- protocol: 'https',
- hostname: '**.cdninstagram.com',
- },
- {
- protocol... | Can we roll back this? Some CDN hosts are different |
threads-api | github_2023 | others | 116 | junhoyeo | junhoyeo | @@ -2,7 +2,7 @@
"name": "threads-web-ui",
"version": "1.0.0",
"private": true,
- "repository": "https://github.com/junhoyeo/threads-web-ui",
+ "repository": "", | can we revert this bro? |
threads-api | github_2023 | others | 116 | junhoyeo | junhoyeo | @@ -15,8 +15,9 @@
"class-variance-authority": "^0.6.1",
"clsx": "^1.2.1",
"emotion-reset": "^3.0.1",
+ "fs": "^0.0.1-security", | I dont think we need this |
threads-api | github_2023 | typescript | 116 | junhoyeo | junhoyeo | @@ -0,0 +1,77 @@
+import Image from 'next/image';
+import React from 'react';
+import { Thread, ThreadsIcons } from 'react-threads';
+import { ThreadsAPI } from 'threads-api';
+
+const UserProfilePage = async ({ params }: { params: { username: string } }) => {
+ const threadsAPI = new ThreadsAPI();
+ const username =... | - Super nit I still think it should be `params`
- But this is unnecessary anymore, I changed the interface in #121, so we can just change `userID` now. 😁
- So I'll just pass this. 👍 |
threads-api | github_2023 | javascript | 116 | junhoyeo | junhoyeo | @@ -4,7 +4,7 @@ const nextConfig = {
remotePatterns: [
{
protocol: 'https',
- hostname: '**.cdninstagram.com',
+ hostname: '**.cdninstagram.com, **.fbcdn.net', | I dont think this will work |
threads-api | github_2023 | typescript | 130 | junhoyeo | junhoyeo | @@ -166,6 +169,13 @@ export class ThreadsAPI {
if (options?.deviceID) this.deviceID = options.deviceID;
this.device = options?.device;
this.userID = options?.userID;
+
+ if (options?.locale) {
+ this.locale = options.locale;
+ } else {
+ const detectedLocale: string = Intl.DateTimeFormat(... | can this value also be empty? (just asking, i dunno) |
threads-api | github_2023 | others | 130 | junhoyeo | junhoyeo | @@ -2449,13 +2449,6 @@ __metadata:
languageName: node
linkType: hard
-"@types/tough-cookie@npm:^4.0.2": | oh nice catch 🤣 thanks for cleaning the lockfile too |
threads-api | github_2023 | typescript | 119 | junhoyeo | junhoyeo | @@ -2,90 +2,86 @@ import { program } from 'commander';
import { ThreadsAPI } from './threads-api';
const Threads = new ThreadsAPI();
-
-program.version(require('../package.json').version, '-v, --version', 'output the current version');
-program.helpOption('-h, --help', 'display help for command');
+const timeout = ... | was out of my mind to merge this without looking more... sorry |
threads-api | github_2023 | typescript | 53 | junhoyeo | junhoyeo | @@ -1,6 +1,14 @@
import axios, { AxiosRequestConfig } from 'axios';
+import { LATEST_ANDROID_APP_VERSION } from 'dynamic-data'; | ```suggestion
import { LATEST_ANDROID_APP_VERSION } from './dynamic-data';
```
does it make sence to add `./`? |
threads-api | github_2023 | typescript | 53 | junhoyeo | junhoyeo | @@ -56,10 +64,17 @@ export type ThreadsAPIOptions = {
httpAgent?: HTTPAgentType;
username?: string;
password?: string;
+ device?: AndroidDevice;
};
export const DEFAULT_LSD_TOKEN = 'NjppQDEgONsU_1LCzrmp6q';
export const DEFAULT_DEVICE_ID = `android-${(Math.random() * 1e24).toString(36)}`;
+export const D... | 👍👍👍 |
threads-api | github_2023 | typescript | 53 | junhoyeo | junhoyeo | @@ -0,0 +1 @@
+export const LATEST_ANDROID_APP_VERSION = '289.0.0.77.109'; | Can you run `yarn format` in project root to add eof newlines |
threads-api | github_2023 | typescript | 43 | junhoyeo | junhoyeo | @@ -286,4 +296,101 @@ export class ThreadsAPI {
const likers = res.data.data.likers;
return likers;
};
+
+ getToken = async (): Promise<string | undefined> => {
+ if (!this.username || !this.password) {
+ return;
+ }
+
+ const base = 'https://i.instagram.com/api/v1/';
+ const url = `${bas... | Wanna add the `device-` prefix to `this.androidId` itself? Think it's being used together in all cases.
ref: https://github.com/m1guelpf/threads-re#authentication |
threads-api | github_2023 | typescript | 37 | junhoyeo | junhoyeo | @@ -182,22 +177,21 @@ export class ThreadsAPI {
return threads;
};
- getUserProfileReplies = async (username: string, userId: string, options?: {
- proxy?: { host: string, port: number },
- }) => {
+ getUserProfileReplies = async (username: string, userID: string, options?: AxiosRequestConfig) => {
... | nice catch! 👍 👍 |
threads-api | github_2023 | typescript | 30 | junhoyeo | junhoyeo | @@ -0,0 +1,15 @@
+import { ThreadsAPI } from '../src/threads-api';
+
+test('getThreadLikers', async () => {
+ // given
+ const threadsAPI = new ThreadsAPI();
+ const postID = '3141675920411513399';
+
+ // when
+ const likers = await threadsAPI.getThreadLikers(postID);
+
+ // then
+ expect(Array.isA... | Can you run `yarn format`? |
threads-api | github_2023 | typescript | 30 | junhoyeo | junhoyeo | @@ -236,4 +245,26 @@ export class ThreadsAPI {
const thread = res.data.data.data;
return thread;
};
+
+ getThreadLikers = async (postID: string) => {
+ if (this.verbose) {
+ console.debug('[fbLSDToken] USING', this.fbLSDToken);
+ }
+ const res = await axios.post<GetThreadLikersResponse>(
+ ... | ```suggestion
```
nit, but I think the query name is wrong. Please remove this if you are not familiar with it! |
threads-api | github_2023 | others | 14 | junhoyeo | junhoyeo | @@ -540,6 +543,12 @@ main();
yarn add threads-api
# or with npm
npm install threads-api
+# or with pnpm
+pnpm install threads-api
+```
+```typescript
+//or in Deno 🦖 | ```suggestion
// or in Deno 🦖
``` |
threads-api | github_2023 | others | 14 | junhoyeo | junhoyeo | @@ -540,6 +543,12 @@ main();
yarn add threads-api
# or with npm
npm install threads-api
+# or with pnpm
+pnpm install threads-api
+```
+```typescript | Can you add newline between line 548 and 549? |
threads-api | github_2023 | typescript | 8 | junhoyeo | junhoyeo | @@ -30,19 +30,6 @@ export class ThreadsAPI {
origin: 'https://www.threads.net',
pragma: 'no-cache',
referer: `https://www.threads.net/@${username}`,
- 'sec-ch-prefers-color-scheme': 'dark',
- 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
- 'sec-ch-ua-full-versi... | Can't we remove this(`x-asbd-id`, `x-fb-lsd`, and `x-ig-app-id`) and add those headers back?
context: https://github.com/junhoyeo/threads-api/pull/4#discussion_r1254573262 |
threads-api | github_2023 | typescript | 4 | junhoyeo | junhoyeo | @@ -0,0 +1,19 @@
+import { ThreadsAPI } from '../src/threads-api';
+
+test("UserName Unit test", async () => { | Can we rename this and the filename to be more descriptive?
Also I think we should separate tests for each method.
|
threads-api | github_2023 | typescript | 4 | junhoyeo | junhoyeo | @@ -0,0 +1,19 @@
+import { ThreadsAPI } from '../src/threads-api';
+
+test("UserName Unit test", async () => {
+ const threadsAPI = new ThreadsAPI();
+
+ const username = '_junhoyeo';
+ const id = await threadsAPI.getUserIDfromUsername(username);
+
+ if (!id) {
+ return;
+ }
+ expect(typeof id).toBe("string");... | Can you mind running `yarn format` before you commit your work?
If you're using VSCode, it should format automatically each time you save a file - if not, I must have messed up with the formatter settings... Will love if you could take a look! |
threads-api | github_2023 | typescript | 4 | junhoyeo | junhoyeo | @@ -55,16 +41,6 @@ export class ThreadsAPI {
accept:
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'accept-language': 'ko,en;q=0.9,ko-KR;q=0.8,ja;q=0.7',
- pragma: 'no-cache',
- refere... | Just a quick question - why are we removing HTTP headers?
This was for stability in case Threads adds some bot checks like LinkedIn. |
BetterOCR | github_2023 | python | 3 | junhoyeo | junhoyeo | @@ -137,7 +142,7 @@ def detect_boxes(
boxes_1_json = json.dumps(boxes_1, ensure_ascii=False, default=int)
boxes_2_json = json.dumps(boxes_2, ensure_ascii=False, default=int)
- prompt = f"""Combine and correct OCR data [0] and [1]. Include many items as possible. Langauge is in {'+'.join(options['lang'])}... | Can you rebase your commit? This line had been changed |
BetterOCR | github_2023 | python | 3 | junhoyeo | junhoyeo | @@ -169,18 +179,16 @@ def detect_boxes(
items = extract_list(output)
for idx, item in enumerate(items):
- box = item["box"]
-
# [x,y,w,h]
- if len(box) == 4 and isinstance(box[0], int):
- rect = rectangle_corners(box)
- items[idx]["box"] = rect
+ if len(it... | This line had also been changed |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.