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 |
|---|---|---|---|---|---|---|---|
bits-ui | github_2023 | typescript | 277 | huntabyte | AdrianGonz97 | @@ -0,0 +1,18 @@
+export declare const BOOLEAN = "boolean";
+export declare const STRING = "string";
+export declare const NUMBER = "number";
+export declare const FUNCTION = "function";
+export declare const ENUM = "enum";
+export declare const UNDEFINED = "undefined";
+export declare const UNION = "union";
+export de... | Why was this added? |
bits-ui | github_2023 | others | 277 | huntabyte | AdrianGonz97 | @@ -0,0 +1,5 @@
+---
+"bits-ui": patch
+---
+
+Fix internal import paths to be ESM compliant | ```suggestion
fix: Changed import paths to support modern module resolution strategies
``` |
bits-ui | github_2023 | typescript | 277 | huntabyte | AdrianGonz97 | @@ -1,4 +1,4 @@
-import type { PropType } from "@/types";
+import type { PropType } from "@/types/index.js"; | This file also seems like it shouldn't be here either, though, it wasn't added in this PR. |
bits-ui | github_2023 | others | 342 | huntabyte | huntabyte | @@ -32,32 +32,49 @@
$: Object.assign(builder, attrs);
</script>
-{#if asChild && $isSelected(props)}
- <slot {builder} />
-{:else if transition && $isSelected(props)}
- <div bind:this={el} transition:transition={transitionConfig} use:melt={builder} {...$$restProps}>
+{#if $isSelected(props)}
+ {#if asChild} | Pretty sure this messes with local transitions (if applied when using `asChild` so they need to stay in the same statement. |
bits-ui | github_2023 | typescript | 229 | huntabyte | AdrianGonz97 | @@ -0,0 +1,8 @@
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export function arraysAreEqual(arr1: any[], arr2: any[]): boolean { | This can be changed to use `unknown[]` instead:
```suggestion
export function arraysAreEqual(arr1: unknown[], arr2: unknown[]): boolean {
```
or we can also use a generic instead to ensure that the types are the same too:
```suggestion
export function arraysAreEqual<T extends Array<unknown>>(arr1: T, arr2: T): ... |
bits-ui | github_2023 | others | 229 | huntabyte | AdrianGonz97 | @@ -78,9 +80,15 @@
},
onValueChange: ({ next }: { next: $$Props["value"] }) => {
if (Array.isArray(next)) {
- if (JSON.stringify(next) !== JSON.stringify(value)) {
+ if (!Array.isArray(value)) {
+ onValueChange?.(next);
+ value = next;
+ return next;
+ }
+ if (!arraysAreEqual(value, ne... | This could probably just be simplified to this:
```suggestion
if (!Array.isArray(value) || !arraysAreEqual(value, next)) {
onValueChange?.(next);
value = next;
return next;
``` |
bits-ui | github_2023 | others | 229 | huntabyte | AdrianGonz97 | @@ -26,9 +28,15 @@
orientation,
onValueChange: (({ next }: { next: $$Props["value"] }) => {
if (Array.isArray(next)) {
- if (JSON.stringify(next) !== JSON.stringify(value)) {
+ if (!Array.isArray(value)) {
+ onValueChange?.(next);
+ value = next;
+ return next;
+ }
+ if (!arraysAreEqua... | ```suggestion
if (!Array.isArray(value) || !arraysAreEqual(value, next)) {
onValueChange?.(next);
value = next;
return next;
}
``` |
bits-ui | github_2023 | others | 229 | huntabyte | AdrianGonz97 | @@ -47,9 +49,15 @@
defaultOpen: open,
onSelectedChange: (({ next }: { next: $$Props["selected"] }) => {
if (Array.isArray(next)) {
- if (JSON.stringify(next) !== JSON.stringify(selected)) {
+ if (!Array.isArray(selected)) {
+ onSelectedChange?.(next);
+ selected = next;
+ return next;
+ }... | ```suggestion
if (!Array.isArray(selected) || !arraysAreEqual(selected, next)) {
onSelectedChange?.(next);
selected = next;
return next;
}
``` |
bits-ui | github_2023 | others | 229 | huntabyte | AdrianGonz97 | @@ -22,9 +24,15 @@
defaultValue: value,
onValueChange: (({ next }: { next: $$Props["value"] }) => {
if (Array.isArray(next)) {
- if (JSON.stringify(next) !== JSON.stringify(value)) {
+ if (!Array.isArray(value)) {
+ onValueChange?.(next);
+ value = next;
+ return next;
+ }
+ if (!array... | ```suggestion
if (!Array.isArray(value) || !arraysAreEqual(value, next)) {
onValueChange?.(next);
value = next;
return next;
}
``` |
bits-ui | github_2023 | others | 238 | huntabyte | tmarnet | @@ -12,7 +12,7 @@
<div
style:position="relative"
style:width="100%"
- style:padding-bottom="{100 / ratio}%"
+ style:padding-bottom="{ratio ? 100 / ratio : 0}%" | Is there a reason why this component's implementation relies on the old `padding-bottom` trick instead of leveraging the [`aspect-ratio` property](https://caniuse.com/mdn-css_properties_aspect-ratio) ? |
bits-ui | github_2023 | others | 227 | huntabyte | NDOY3M4N | @@ -0,0 +1,32 @@
+---
+title: PIN Input
+description: Allows users to input a sequence of one-character alphanumeric inputs.
+---
+
+<script>
+ import { APISection, ComponentPreview, PinInputDemo } from '@/components'
+ export let schemas;
+</script>
+
+<ComponentPreview name="pin-input-demo" comp="PinInput">
+
+<PinIn... | I think it's okay to repeat the `PinInput.Input` component since the pin is composed of multiple characters and each character is represented by an input field. |
bits-ui | github_2023 | others | 227 | huntabyte | huntabyte | @@ -0,0 +1,70 @@
+<script lang="ts">
+ import { melt } from "@melt-ui/svelte";
+ import { setCtx, getAttrs } from "../ctx.js";
+ import type { Props } from "../types.js";
+ import { derived } from "svelte/store";
+
+ type $$Props = Props;
+
+ export let placeholder: $$Props["placeholder"] = undefined;
+ export let valu... | In Melt, each Id is its own store, and we want the `ids` slot prop object to always have the latest IDs. So we're deriving a new store from all the individual ID stores so as the individual ids update, so does this! |
bits-ui | github_2023 | others | 223 | huntabyte | huntabyte | @@ -0,0 +1,51 @@
+<script lang="ts">
+ import { melt } from "@melt-ui/svelte";
+ import { getAttrs, setCtx } from "../ctx.js";
+ import type { Props } from "../types.js";
+
+ type $$Props = Props;
+
+ export let count: $$Props["count"];
+ export let page: $$Props["page"] = undefined;
+ export let onPageChange: $$Props[... | ```suggestion
```
I recently ran into some painful bugs due to not considering all the implications of putting these inside the same reactive statement.
So let's just pass them as slot props directly rather than spreading the object! |
bits-ui | github_2023 | others | 219 | huntabyte | huntabyte | @@ -0,0 +1,26 @@
+<script lang="ts">
+ import { melt } from "@melt-ui/svelte";
+ import { getAttrs, getCtx } from "../ctx.js";
+ import type { SeparatorProps } from "../types.js";
+
+ type $$Props = SeparatorProps;
+
+ export let asChild: $$Props["asChild"] = false;
+
+ const {
+ elements: { link }
+ } = getCtx();
+
+... | ```suggestion
$: builder = $separator;
``` |
bits-ui | github_2023 | others | 219 | huntabyte | huntabyte | @@ -0,0 +1,26 @@
+<script lang="ts">
+ import { melt } from "@melt-ui/svelte";
+ import { getAttrs, getCtx } from "../ctx.js";
+ import type { SeparatorProps } from "../types.js";
+
+ type $$Props = SeparatorProps;
+
+ export let asChild: $$Props["asChild"] = false;
+
+ const {
+ elements: { link } | ```suggestion
elements: { separator }
``` |
bits-ui | github_2023 | others | 219 | huntabyte | huntabyte | @@ -0,0 +1,36 @@
+---
+title: Toolbar
+description: A container for grouping a set of controls, such as buttons, links or toggle groups.
+---
+
+<script>
+ import { APISection, ComponentPreview, ToolbarDemo } from '@/components'
+ export let schemas;
+</script>
+
+<ComponentPreview name="toolbar-demo" comp="Toolbar">
+... | ```suggestion
``` |
bits-ui | github_2023 | others | 219 | huntabyte | huntabyte | @@ -0,0 +1,53 @@
+<script lang="ts">
+ import { Toolbar } from "$lib";
+ import { TextB, TextItalic, TextStrikethrough } from "phosphor-svelte";
+
+ let value: string[] | undefined = ["bold"];
+</script>
+
+<Toolbar.Root
+ class="flex h-input min-w-max items-center gap-4 rounded-card-sm border border-border bg-backgrou... | ```suggestion
<Toolbar.GroupItem
```
Same for the rest of the items |
bits-ui | github_2023 | others | 219 | huntabyte | huntabyte | @@ -0,0 +1,36 @@
+<script lang="ts">
+ import { melt } from "@melt-ui/svelte";
+ import { getGroupCtx, getAttrs } from "../ctx.js";
+ import type { ItemProps, ItemEvents } from "../types.js";
+ import { createDispatcher } from "$lib/internal";
+
+ type $$Props = ItemProps;
+ type $$Events = ItemEvents;
+
+ export let v... | ```suggestion
const attrs = getAttrs("item");
$: attrs = {
...getAttrs("group-item"),
...disabledAttrs(disabled)
}
```
For some reason disabled behavior isn't always applied through Melt properly, so we do it here based on the `disabled` prop. |
bits-ui | github_2023 | others | 219 | huntabyte | huntabyte | @@ -0,0 +1,36 @@
+<script lang="ts">
+ import { melt } from "@melt-ui/svelte";
+ import { getGroupCtx, getAttrs } from "../ctx.js";
+ import type { ItemProps, ItemEvents } from "../types.js";
+ import { createDispatcher } from "$lib/internal"; |
```suggestion
import { createDispatcher, disabledAttrs } from "$lib/internal/index.js";
``` |
bits-ui | github_2023 | typescript | 219 | huntabyte | huntabyte | @@ -0,0 +1,45 @@
+import type { HTMLDivAttributes } from "$lib/internal/index.js";
+import type { HTMLAnchorAttributes, HTMLButtonAttributes } from "svelte/elements";
+import type * as I from "$lib/bits/toolbar/_types.js";
+import type { CustomEventHandler } from "$lib";
+
+type Props = I.Props & HTMLDivAttributes;
+
+... |
```suggestion
``` |
bits-ui | github_2023 | typescript | 219 | huntabyte | huntabyte | @@ -0,0 +1,45 @@
+import type { HTMLDivAttributes } from "$lib/internal/index.js";
+import type { HTMLAnchorAttributes, HTMLButtonAttributes } from "svelte/elements";
+import type * as I from "$lib/bits/toolbar/_types.js";
+import type { CustomEventHandler } from "$lib"; |
```suggestion
import type { CustomEventHandler } from "$lib/index.js";
``` |
bits-ui | github_2023 | others | 150 | huntabyte | huntabyte | @@ -7,6 +7,7 @@
type $$Props = TriggerProps;
type $$Events = TriggerEvents;
export let asChild = false;
+ export let type: $$Props["type"] = "button"; | ```suggestion
``` |
bits-ui | github_2023 | others | 150 | huntabyte | huntabyte | @@ -22,6 +23,7 @@
use:melt={builder}
{...$$restProps}
{...attrs}
+ {type} | ```suggestion
type="button"
``` |
bits-ui | github_2023 | others | 150 | huntabyte | huntabyte | @@ -23,6 +23,7 @@
use:melt={builder}
{...$$restProps}
{...attrs}
+ type="button" | ```suggestion
```
I think we leave this up to the dev to add here if they wish. Imagine you wanted to add a tooltip to a button that submits a form, with the tooltip saying "Submit form" or something. We don't want to prevent the user from doing something like this. |
bits-ui | github_2023 | typescript | 150 | huntabyte | huntabyte | @@ -30,7 +30,7 @@ type ContentProps<
> &
HTMLDivAttributes;
-type TriggerProps = AsChild & HTMLButtonAttributes;
+type TriggerProps = AsChild & Omit<HTMLButtonAttributes, "type">; | ```suggestion
type TriggerProps = AsChild & HTMLButtonAttributes;
``` |
bits-ui | github_2023 | others | 150 | huntabyte | huntabyte | @@ -24,6 +24,7 @@
use:melt={builder}
{...$$restProps}
{...attrs}
+ type="button" | For the rest of the buttons, I think we should do something like this:
```suggestion
type="button"
{...$$restProps}
{...attrs}
```
That way, if for some reason or another someone wants to submit the form when they close the dialog, or toggle a switch, or whatever, they are able to override the `type="bu... |
cmdk-sv | github_2023 | others | 38 | huntabyte | huntabyte | @@ -86,13 +86,13 @@
</script>
{#if asChild}
- <slot {root} label={{ attrs: labelAttrs }} /> | We should move these into a reactive `slotProps` prop, so something like:
```svelte
<script lang="ts">
$: slotProps = {
root,
label: { attrs: labelAttrs },
stateStore,
state: $stateStore,
}
</script>
```
If we're going to pass stores as slot props I think they should be suffixed with `Store` an... |
TF-via-PR | github_2023 | others | 447 | OP5dev | github-advanced-security[bot] | @@ -251,8 +251,8 @@
# Both plan files are normalized by sorting JSON keys, removing timestamps and ${{ steps.arg.outputs.arg-detailed-exitcode }} to avoid false-positives.
if [[ -n "$PLAN_FILE" ]]; then mv --force --verbose "$PLAN_FILE" "$path" 2>/dev/null; fi
${{ inputs.tool }}${{ steps.arg.... | ## Code injection
Potential code injection in [${{ inputs.tool }}](1), which may be controlled by an external user.
[Show more details](https://github.com/OP5dev/TF-via-PR/security/code-scanning/269) |
TF-via-PR | github_2023 | others | 447 | OP5dev | github-advanced-security[bot] | @@ -251,8 +251,8 @@
# Both plan files are normalized by sorting JSON keys, removing timestamps and ${{ steps.arg.outputs.arg-detailed-exitcode }} to avoid false-positives.
if [[ -n "$PLAN_FILE" ]]; then mv --force --verbose "$PLAN_FILE" "$path" 2>/dev/null; fi
${{ inputs.tool }}${{ steps.arg.... | ## Code injection
Potential code injection in [${{ inputs.tool }}](1), which may be controlled by an external user.
[Show more details](https://github.com/OP5dev/TF-via-PR/security/code-scanning/270) |
TF-via-PR | github_2023 | javascript | 272 | OP5dev | rdhar | @@ -5,7 +5,7 @@ module.exports = async ({ context, core, exec, github }) => {
const fmt_result_limit = 6e3;
// Get PR number from event trigger for unique identifier.
- let pr_number = 0;
+ let pr_number = '0'; | I totally get the intent of converting this number to a string, given its use as a string identifier.
However, leaving it as a number allows boolean conditions further down the file, like [here](https://github.com/DevSecTop/TF-via-PR/blob/8dda3051767cab1a4a8cad26fe4dd171ccb2696d/action.js#L202) and [there](https://g... |
TF-via-PR | github_2023 | javascript | 272 | OP5dev | rdhar | @@ -22,6 +22,8 @@ module.exports = async ({ context, core, exec, github }) => {
pr_number = pr.number;
} else if (context.eventName === "merge_group") {
pr_number = parseInt(context.ref.split("/pr-")[1]);
+ } else {
+ pr_number = context.issue.number; | This is a great call-out, thank you!
An `else {}` here would be ideal to capture any cases I didn't think of. Though, unfortunately, we can't reliably rely on `context.issue.number` alone since it's not available in all event payloads, such as `push` and `merge_group` event triggers.
Let's see if we can make this... |
emojis | github_2023 | typescript | 13 | pondorasti | ankur-arch | @@ -1,7 +1,10 @@
import { cache } from "react"
import "server-only"
import { prisma } from "./db"
+import ms from "ms"
-export const revalidate = 1_800 // revalidate the data at most every 30 minute
-
-export const getEmojisCount = cache(async () => prisma.emoji.count())
+export const getEmojisCount = cache(async ... | ```suggestion
cacheStrategy: { ttl: ms("5m")/1000, swr: ms("5m")/1000 },
``` |
emojis | github_2023 | typescript | 13 | pondorasti | ankur-arch | @@ -2,14 +2,14 @@ import { Prisma } from "@prisma/client"
import { cache } from "react"
import "server-only"
import { prisma } from "./db"
-
-export const revalidate = 60 // revalidate the data at most every 1 minute
+import ms from "ms"
export const getEmojis = cache(async (take: number = 100) =>
prisma.emoji... | ```suggestion
cacheStrategy: { ttl: ms("30s")/1000, swr: ms("60s")/1000 },
```
Same case for here 😄 |
waltid-identity | github_2023 | others | 960 | walt-id | mikeplotean | @@ -96,6 +97,7 @@ class SilentClaimStrategyTest {
}
@Test
+ @Ignore | I'd suggest to either fix the tests or replace them with others that fit the new implementation
rather than removing |
waltid-identity | github_2023 | others | 960 | walt-id | mikeplotean | @@ -47,10 +50,12 @@ class SilentClaimStrategy(
val issuerDid = WalletCredential.parseIssuerDid(credential, manifest) ?: "n/a"
val type = credentialTypeSeeker.get(credential)
val egfUri = "test"
- //TODO: improve for same issuer - type values
- if (validateIssuer(issuerDid, type,... | not sure I understand the meaning of this check, could you please elaborate on it |
waltid-identity | github_2023 | others | 960 | walt-id | mikeplotean | @@ -60,7 +65,9 @@ class SilentClaimStrategy(
storeCredentials(entry.key, credentials).getOrNull()?.let {
accountService.getAccountForWallet(entry.key)?.run {
createEvents("", this, entry.value, EventType.Credential.Receive)
- createNotifications(this, credentials, E... | I understand that notification and trust configs are both part of the silent-exchange feature in the catalog, but I'd still avoid calling them directly, without checking if feature is enabled and generally speaking, I'd avoid their dependency unless explicitly required for the scope of the entity, e.g. [trust-config](h... |
waltid-identity | github_2023 | others | 851 | walt-id | waltkb | @@ -36,22 +36,35 @@ import love.forte.plugin.suspendtrans.annotation.JvmAsync
import love.forte.plugin.suspendtrans.annotation.JvmBlocking
import org.kotlincrypto.hash.sha2.SHA256
import org.kotlincrypto.macs.hmac.sha2.HmacSHA256
-import kotlin.collections.component1
-import kotlin.collections.component2
import kot... | access key is global variable |
waltid-identity | github_2023 | others | 777 | walt-id | mikeplotean | @@ -65,17 +69,18 @@ data class ServiceMap(
) {
init {
- require(id.isNotBlank()) { "Service property id cannot be blank" }
+ require(id.isNotBlank()) { throw InvalidServiceIdException("Service property id cannot be blank") } | `require` already throws an `IllegalArgumentException` and within that lambda function you provide the message which the exception should be constructed with

so, what happens when you throw within the lambda `lazyMessage` fu... |
waltid-identity | github_2023 | others | 923 | walt-id | mikeplotean | @@ -0,0 +1,62 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: opa
+ labels:
+ app: opa
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: opa
+ template:
+ metadata:
+ labels:
+ app: opa
+ spec:
+ containers:
+ - name: opa
+ image: openpolicyagent/... | please update the host to `.test.waltid.cloud` |
waltid-identity | github_2023 | others | 923 | walt-id | mikeplotean | @@ -0,0 +1,62 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: opa
+ labels:
+ app: opa
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: opa
+ template:
+ metadata:
+ labels:
+ app: opa
+ spec:
+ containers:
+ - name: opa
+ image: openpolicyagent/... | I think the exposed port should be 80 |
waltid-identity | github_2023 | others | 923 | walt-id | mikeplotean | @@ -0,0 +1,62 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: opa
+ labels:
+ app: opa
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: opa
+ template:
+ metadata:
+ labels:
+ app: opa
+ spec:
+ containers:
+ - name: opa
+ image: openpolicyagent/... | here the container port could be referenced by name, in this case http - line:26 |
waltid-identity | github_2023 | others | 923 | walt-id | mikeplotean | @@ -0,0 +1,62 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: opa
+ labels:
+ app: opa
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: opa
+ template:
+ metadata:
+ labels:
+ app: opa
+ spec:
+ containers:
+ - name: opa
+ image: openpolicyagent/... | I think the tls is handled differently for the dev environment, no need for the annotations part |
waltid-identity | github_2023 | others | 920 | walt-id | mikeplotean | @@ -180,6 +183,18 @@ services:
volumes:
- ./vault/init.sh:/vault/scripts/init.sh
+ opa-server:
+ image: openpolicyagent/opa:latest
+ container_name: opa-server
+ profiles:
+ - identity | I would create a separate profile name for it, e.g. opa and replace identity with it
so that, as a user, I don't put additional burden on my machine if I don't use dynamic policies |
waltid-identity | github_2023 | others | 920 | walt-id | mikeplotean | @@ -52,10 +52,13 @@ services:
dockerfile: waltid-services/waltid-verifier-api/Dockerfile
depends_on:
- caddy
+ - opa-server | I understand the dependency, but perhaps there's a way to make it conditionally, based on profile or anything else
because currently, as a user, I am forced to use opa server, although I might not need dynamic policies for my use case |
waltid-identity | github_2023 | others | 920 | walt-id | mikeplotean | @@ -180,6 +183,18 @@ services:
volumes:
- ./vault/init.sh:/vault/scripts/init.sh
+ opa-server:
+ image: openpolicyagent/opa:latest
+ container_name: opa-server
+ profiles:
+ - identity
+ - all
+ ports:
+ - "8181:8181" | perhaps the exposed port could be a variable in the .env file |
waltid-identity | github_2023 | others | 837 | walt-id | waltkb | @@ -394,153 +388,235 @@ const { status, data, signIn } = useAuth();
const signInRedirectUrl = ref("/");
async function connectOidc() {
- navigateTo("/wallet-api/auth/oidc-login", { external: true });
+ navigateTo("/wallet-api/auth/oidc-login", { external: true });
}
async function login() {
- console.log("... | `http://localhost:7001` |
waltid-identity | github_2023 | others | 837 | walt-id | waltkb | @@ -394,153 +388,235 @@ const { status, data, signIn } = useAuth();
const signInRedirectUrl = ref("/");
async function connectOidc() {
- navigateTo("/wallet-api/auth/oidc-login", { external: true });
+ navigateTo("/wallet-api/auth/oidc-login", { external: true });
}
async function login() {
- console.log("... | `http://localhost:7001` |
waltid-identity | github_2023 | others | 837 | walt-id | waltkb | @@ -81,7 +84,7 @@ object Db {
SchemaUtils.drop(*(tables.reversedArray()))
SchemaUtils.create(*tables)
-
+ SchemaUtils.create(AuthnzUsers, AuthnzAccountIdentifiers, AuthnzStoredData) | if FeatureManager.isFeatureEnabled FeatureCatalog.authnzFeature |
waltid-identity | github_2023 | others | 882 | walt-id | mikeplotean | @@ -550,16 +580,28 @@ class SSIKit2WalletService(
kmsType = EventDataNotAvailable
)
)
- } else {
- logger.warn { "Key delete operation not performed for alias: $alias" }
- throw WebException(HttpStatusCode.BadRequest, "Failed to delete key: $alias")
- ... | "alias" looks misleading here, since it should be the actual public key jwk, maybe change it to smth. e.g. "jwk" |
waltid-identity | github_2023 | others | 882 | walt-id | mikeplotean | @@ -550,16 +580,28 @@ class SSIKit2WalletService(
kmsType = EventDataNotAvailable
)
)
- } else {
- logger.warn { "Key delete operation not performed for alias: $alias" }
- throw WebException(HttpStatusCode.BadRequest, "Failed to delete key: $alias")
- ... | this has the same name as the parameter:

not a problem here, since the parameter is not referenced below, but still can be confusing |
waltid-identity | github_2023 | others | 882 | walt-id | mikeplotean | @@ -181,6 +181,40 @@ fun Application.keys() = walletRoute {
}
}
+ post("verify", {
+ summary = "Verify a signature with a specific key"
+ request {
+ queryParameter<String>("JWK") {
+ description = "The public key to verify the s... | this looks more like a private key |
waltid-identity | github_2023 | others | 882 | walt-id | mikeplotean | @@ -181,6 +181,40 @@ fun Application.keys() = walletRoute {
}
}
+ post("verify", {
+ summary = "Verify a signature with a specific key"
+ request {
+ queryParameter<String>("JWK") { | this also works
but why not provide it as part of the body payload?
the body would look like:
```json
{
"public-key":
{
"kty": "OKP",
"crv": "Ed25519",
"kid": "X2oQ9lmT7j0IeMEF1aiXQ8va7lu9PNSe2AT9orxYyHg",
"x": "7kAIEmWZkFfdwCyWQwWw3zdfGaHwl3FcYdLDYm8Lecs"
},
... |
waltid-identity | github_2023 | others | 882 | walt-id | mikeplotean | @@ -181,6 +181,40 @@ fun Application.keys() = walletRoute {
}
}
+ post("verify", {
+ summary = "Verify a signature with a specific key"
+ request {
+ queryParameter<String>("JWK") {
+ description = "The public key to verify the s... | this could be done with:
```kotlin
val jwk = context.request.queryParameters.getOrFail("JWK")
```
similar to keyId from the "sign" endpoint below |
waltid-identity | github_2023 | others | 882 | walt-id | mikeplotean | @@ -270,6 +304,25 @@ fun Application.keys() = walletRoute {
val success = getWalletService().removeKey(keyId)
context.respond(if (success) HttpStatusCode.Accepted else HttpStatusCode.BadRequest)
}
+
+ post("sign", {
+ summary = "Sign a message wit... | not sure about the implications and its worthiness
but this could be `JsonElement`
and this would support additionally json-string and json-array for signing |
waltid-identity | github_2023 | others | 835 | walt-id | mikeplotean | @@ -51,21 +52,30 @@ data class W3CVC(
@JsExport.Ignore
suspend fun signSdJwt(
issuerKey: Key,
- issuerKeyId: String,
+ issuerId: String,
+ issuerKid: String?,
subjectDid: String,
disclosureMap: SDMap,
/** Set additional options in the JWT header */
... | <del>this looks very similar to the `toPayload` method from above
is there a way to use it here?</del> |
waltid-identity | github_2023 | others | 831 | walt-id | chsavvaidis | @@ -66,23 +67,25 @@ object Base64Utils {
}
object StreamUtils {
- fun getBitValue(inputStream: InputStream, index: ULong, bitSize: Int) =
- inputStream.bufferedReader().use { buffer ->
- buffer.skip((index * bitSize.toULong()).toLong())
- extractBitValue(buffer, index, bitSize.toULong())
+ fun getB... | Perhaps consider defining some private constants for these values to improve clarity, e.g., BITS_PER_BYTE |
waltid-identity | github_2023 | others | 831 | walt-id | chsavvaidis | @@ -66,23 +67,25 @@ object Base64Utils {
}
object StreamUtils {
- fun getBitValue(inputStream: InputStream, index: ULong, bitSize: Int) =
- inputStream.bufferedReader().use { buffer ->
- buffer.skip((index * bitSize.toULong()).toLong())
- extractBitValue(buffer, index, bitSize.toULong())
+ fun getB... | Maybe the TODO is worth addressing, as validating the bitSize can prevent potential out-of-bounds errors, also in extractBitValue |
waltid-identity | github_2023 | others | 819 | walt-id | mikeplotean | @@ -230,7 +230,22 @@ fun Application.keys() = walletRoute {
val keyId = context.parameters["keyId"] ?: throw IllegalArgumentException("No key id provided.")
val success = getWalletService().deleteKey(keyId)
+ context.respond(if (success) HttpStatusCode.Accepted else Ht... | this could be done also using [getOrFail](https://api.ktor.io/older/1.6.8/ktor-server/ktor-server-core/io.ktor.util/get-or-fail.html):
```kotlin
val keyId = context.parameters.getOrFail("keyId")
```
it throws a [MissingRequestParameterException](https://api.ktor.io/older/1.6.8/ktor-server/ktor-server-core/io.ktor.f... |
waltid-identity | github_2023 | others | 819 | walt-id | mikeplotean | @@ -513,25 +517,65 @@ class SSIKit2WalletService(
}
override suspend fun deleteKey(alias: String): Boolean = runCatching {
- KeysService.get(walletId, alias)?.let { Json.parseToJsonElement(it.document) }?.run {
+ val key = KeysService.get(walletId, alias) | if I may suggest a refactoring for `deleteKey` and `removeKey` like following:
- pull the common logic in a separate method - performKeyDelete
- here I used the `getKey` method already available in the class to retrieve the key
- then I perform the actions according to inputs
- I check the operation result an... |
waltid-identity | github_2023 | others | 816 | walt-id | waltkb | @@ -40,9 +41,21 @@ import kotlin.collections.component2
import kotlin.io.encoding.ExperimentalEncodingApi
import kotlin.js.ExperimentalJsExport
import kotlin.js.JsExport
+import kotlin.time.Duration.Companion.seconds
private val logger = KotlinLogging.logger { }
+data class AWSauth( | Rename (Shift+F6) to AWSAuth or AWSAuthConfiguration |
waltid-identity | github_2023 | others | 816 | walt-id | waltkb | @@ -40,9 +41,21 @@ import kotlin.collections.component2
import kotlin.io.encoding.ExperimentalEncodingApi
import kotlin.js.ExperimentalJsExport
import kotlin.js.JsExport
+import kotlin.time.Duration.Companion.seconds
private val logger = KotlinLogging.logger { }
+data class AWSauth(
+ val accessKeyId: String... | switch to `String?` |
waltid-identity | github_2023 | others | 816 | walt-id | waltkb | @@ -40,9 +41,21 @@ import kotlin.collections.component2
import kotlin.io.encoding.ExperimentalEncodingApi
import kotlin.js.ExperimentalJsExport
import kotlin.js.JsExport
+import kotlin.time.Duration.Companion.seconds
private val logger = KotlinLogging.logger { }
+data class AWSauth(
+ val accessKeyId: String... | switch to `String?` |
waltid-identity | github_2023 | others | 816 | walt-id | waltkb | @@ -249,10 +262,34 @@ class AWSKey(
@JsExport.Ignore
override suspend fun getMeta(): AwsKeyMeta = AwsKeyMeta(getKeyId())
+
companion object : AWSKeyCreator {
val client = HttpClient()
+ suspend fun authAccess(config: AWSKeyMetadata) {
+ val isAccessDataProvided = config.a... | switch `"null"` to `null` |
waltid-identity | github_2023 | others | 816 | walt-id | waltkb | @@ -360,6 +397,56 @@ ${sha256Hex(canonicalRequest)}
)
}
+
+ // Function to get IMDSv2 token
+ suspend fun getIMDSv2Token(ttlSeconds: Int = 21600): String {
+ val url = "http://169.254.169.254/latest/api/token"
+ val token = client.put(url) {
+ h... | switch debug to trace (token is valuable secret) |
waltid-identity | github_2023 | others | 816 | walt-id | waltkb | @@ -360,6 +397,56 @@ ${sha256Hex(canonicalRequest)}
)
}
+
+ // Function to get IMDSv2 token
+ suspend fun getIMDSv2Token(ttlSeconds: Int = 21600): String {
+ val url = "http://169.254.169.254/latest/api/token"
+ val token = client.put(url) {
+ h... | these are `String?` (nullable) right now, I suppose they should always have these fields. So add ` ?: throw ...` to make sure they exist |
waltid-identity | github_2023 | others | 816 | walt-id | waltkb | @@ -360,6 +397,56 @@ ${sha256Hex(canonicalRequest)}
)
}
+
+ // Function to get IMDSv2 token
+ suspend fun getIMDSv2Token(ttlSeconds: Int = 21600): String {
+ val url = "http://169.254.169.254/latest/api/token"
+ val token = client.put(url) {
+ h... | then they will be `String` instead of `String?` and the .toString() is no longer required |
waltid-identity | github_2023 | others | 804 | walt-id | philpotisk | @@ -0,0 +1,325 @@
+package id.walt.oid4vc
+
+import id.walt.crypto.keys.Key
+import id.walt.crypto.keys.jwk.JWKKey
+import id.walt.crypto.utils.Base64Utils.base64UrlDecode
+import id.walt.crypto.utils.Base64Utils.decodeFromBase64Url
+import id.walt.crypto.utils.JsonUtils.toJsonElement
+import id.walt.did.dids.DidServic... | could probably be removed |
waltid-identity | github_2023 | others | 804 | walt-id | philpotisk | @@ -0,0 +1,325 @@
+package id.walt.oid4vc
+
+import id.walt.crypto.keys.Key
+import id.walt.crypto.keys.jwk.JWKKey
+import id.walt.crypto.utils.Base64Utils.base64UrlDecode
+import id.walt.crypto.utils.Base64Utils.decodeFromBase64Url
+import id.walt.crypto.utils.JsonUtils.toJsonElement
+import id.walt.did.dids.DidServic... | no "println" should be in production code -> introduce logger or remove |
waltid-identity | github_2023 | others | 804 | walt-id | philpotisk | @@ -0,0 +1,325 @@
+package id.walt.oid4vc
+
+import id.walt.crypto.keys.Key
+import id.walt.crypto.keys.jwk.JWKKey
+import id.walt.crypto.utils.Base64Utils.base64UrlDecode
+import id.walt.crypto.utils.Base64Utils.decodeFromBase64Url
+import id.walt.crypto.utils.JsonUtils.toJsonElement
+import id.walt.did.dids.DidServic... | no "println" should be in production code -> introduce logger or remove |
waltid-identity | github_2023 | others | 804 | walt-id | chsavvaidis | @@ -130,11 +140,10 @@ object OidcApi : CIProvider() {
AuthenticationMethod.ID_TOKEN -> {
val idTokenRequestJwtKid = issuanceSessionData.first().issuerKey.key.getKeyId() | OIDC lib offers functions that are not used by the lib tests. e.g processCodeFlowAuthorization() for handling authorization code flow. Example:
a. OIDC lib test cases uses the
val authCodeResponse: AuthorizationCodeResponse = AuthorizationCodeResponse.success("test-code") val redirectUri = authCodeResponse.toR... |
waltid-identity | github_2023 | others | 804 | walt-id | chsavvaidis | @@ -98,7 +100,7 @@ open class CIProvider : OpenIDCredentialIssuer(
// TODO: make configurable
// private val CI_TOKEN_KEY by lazy { KeyManager.resolveSerializedKeyBlocking("""""") }
- private val CI_TOKEN_KEY =
+ val CI_TOKEN_KEY = | The `CI_TOKEN_KEY` either comes from the config file or is a random key that we cannot view or manipulate. This should be added to the JWKS endpoint. Currently, signing the ID and VP token requests without providing any resolving method (e.g., JWKS or jwks_uri) makes it impossible to verify the tokens. |
waltid-identity | github_2023 | others | 804 | walt-id | chsavvaidis | @@ -0,0 +1,707 @@
+package id.walt.oid4vc
+
+import id.walt.credentials.CredentialBuilder
+import id.walt.credentials.CredentialBuilderType
+import id.walt.credentials.issuance.Issuer.baseIssue
+import id.walt.crypto.keys.KeyType
+import id.walt.crypto.keys.jwk.JWKKey
+import id.walt.did.dids.DidService
+import id.walt... | The test case only covers W3C with NONE authentication method. See also testCredentialIssuanceIsolatedFunctions() in CI_JVM_Test |
waltid-identity | github_2023 | others | 804 | walt-id | chsavvaidis | @@ -0,0 +1,325 @@
+package id.walt.oid4vc
+
+import id.walt.crypto.keys.Key
+import id.walt.crypto.keys.jwk.JWKKey
+import id.walt.crypto.utils.Base64Utils.base64UrlDecode
+import id.walt.crypto.utils.Base64Utils.decodeFromBase64Url
+import id.walt.crypto.utils.JsonUtils.toJsonElement
+import id.walt.did.dids.DidServic... | readme.md is outdated
|
waltid-identity | github_2023 | others | 804 | walt-id | waltkb | @@ -130,6 +130,8 @@ kotlin {
val jvmMain by getting {
dependencies {
implementation("io.ktor:ktor-client-okhttp:$ktor_version")
+ implementation("com.augustcellars.cose:cose-java:1.1.0") | cose-java 1.1.0 has the following CVEs:
[CVE-2024-30172](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-30172)
[CVE-2024-30171](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-30171)
[CVE-2024-29857](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-29857)
[CVE-2024-23684](https://cve.mitre.o... |
waltid-identity | github_2023 | others | 673 | walt-id | SuperBatata | @@ -28,15 +34,41 @@ cd docker-compose && docker compose up
- Visit the web wallet hosted under [localhost:7101](http://localhost:7101).
- Visit the wallet-api hosted under [localhost:7001](http://localhost:7001).
-Update the containers by running the following commands from the root folder:
+#### Running the Walle... | Maybe improve this phrase to something with better clarity :
> Note that this project only includes the frontend of the web wallet |
waltid-identity | github_2023 | others | 761 | walt-id | mikeplotean | @@ -378,40 +517,266 @@ class ExchangeExternalSignatures {
) {
matchedCredentialList = it
}
+ val prepareRequest = PrepareOID4VPRequest(
+ did = holderDID,
+ presentationRequest = presentationRequestURL,
+ selectedCredentialIdList = matchedCredential... | although it's used only in 2 places, maybe still worth having it as a constant, e.g.
```kotlin
private val issuerUrl = "http://localhost:22222"
```
then the caller would look like:
```kotlin
vct = "$issuerUrl/identity_credential",
``` |
waltid-identity | github_2023 | others | 761 | walt-id | mikeplotean | @@ -0,0 +1,148 @@
+package id.walt.webwallet.service.exchange
+
+import cbor.Cbor
+import id.walt.crypto.utils.Base64Utils.base64UrlDecode
+import id.walt.crypto.utils.JwsUtils.decodeJwsOrSdjwt
+import id.walt.mdoc.dataelement.toDataElement
+import id.walt.mdoc.doc.MDoc
+import id.walt.mdoc.issuersigned.IssuerSigned
+i... | I would suggest (my usual way), maybe this could be extracted into 2 separate methods, e.g.:
```kotlin
@OptIn(ExperimentalSerializationApi::class)
private fun getMdocCredentialDataResult(
processedOffer: ProcessedCredentialOffer,
credential: String
): CredentialDataResult {
val credentialEncoding =
... |
waltid-identity | github_2023 | others | 761 | walt-id | mikeplotean | @@ -1,16 +1,115 @@
package id.walt.webwallet.web.controllers.exchange
+import id.walt.crypto.utils.JsonUtils.toJsonElement
+import id.walt.oid4vc.data.CredentialFormat
+import id.walt.sdjwt.KeyBindingJwt
+import id.walt.sdjwt.KeyBindingJwt.Companion.getSdHash
+import id.walt.webwallet.db.models.WalletCredential
+imp... | maybe this could be a separate method, e.g. getDisclosures:
```kotlin
private fun getDisclosures(
disclosures: Map<String, List<String>>?,
credentialId: String
) = if (disclosures?.containsKey(credentialId) == true) {
"~${disclosures[credentialId]!!.joinToString("~")}~"
} else "~"
``` |
waltid-identity | github_2023 | others | 761 | walt-id | mikeplotean | @@ -0,0 +1,480 @@
+package id.walt.webwallet.web.controllers.exchange.openapi.examples
+
+import id.walt.crypto.utils.JsonUtils.toJsonElement
+import id.walt.oid4vc.data.*
+import id.walt.oid4vc.data.dif.DescriptorMapping
+import id.walt.oid4vc.data.dif.PresentationSubmission
+import id.walt.oid4vc.data.dif.VCFormat
+i... | I think localhost:22222 won't work out-of-the-box when running docker or from ide. It probably needs to be set up to `baseUrl` from _issuer-service.conf_ (or verifier, accordingly).
Also, there are several instances of them, maybe worth extracting them into a constant. |
waltid-identity | github_2023 | others | 761 | walt-id | mikeplotean | @@ -79,111 +84,148 @@ fun Application.exchangeExternalSignatures() = walletRoute {
"vpTokenParams object that is contained within."
body<PrepareOID4VPResponse> {
required = true
+ example(
+ "W3C... | I don't think `runCatching` is required here, since any exception would be caught by [StatusPages](https://github.com/walt-id/waltid-identity/blob/de6ebe904f0c6516b35fdc2988e1f7d33f3e90f7/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/plugins/StatusPages.kt#L26) from service-commons and hand... |
waltid-identity | github_2023 | others | 761 | walt-id | mikeplotean | @@ -192,163 +234,182 @@ fun Application.exchangeExternalSignatures() = walletRoute {
request {
body<SubmitOID4VPRequest> {
+ required = true
+ example(
+ "W3C Verifiable Credential",
+ ExchangeExternalSig... | same here
however, this being the final step of the presentation, there probably has to be a distinction in the cause of the exception
and since there is an instance of incorrect logic mentioned, maybe have a separate ticket for solving it |
waltid-identity | github_2023 | others | 756 | walt-id | chsavvaidis | @@ -293,18 +294,20 @@ open class CIProvider : OpenIDCredentialIssuer(
val vc = data.request.credentialData ?: throw MissingFieldException(listOf("credentialData"), "credentialData")
data.run {
- var issuerKid = issuerDid ?: data.issuerKey.key.getKeyId()
- if(!is... | . |
waltid-identity | github_2023 | others | 756 | walt-id | chsavvaidis | @@ -575,58 +524,66 @@ open class CIProvider : OpenIDCredentialIssuer(
private suspend fun IssuanceSessionData.sdJwtVc(
holderKey: JWKKey?,
- vc: W3CVC,
- data: IssuanceSessionData,
- holderDid: String?,
- format: CredentialFormat,
- ) = vc.mergingSdJwtIssue(
- issue... | do we needs this? |
waltid-identity | github_2023 | others | 764 | walt-id | waltkb | @@ -18,16 +19,26 @@ kotlin {
}
pod("JOSESwift") {
- version = "2.4.0"
+ version = "3.0.0"
}
}
sourceSets {
+ val ktor_version = "2.3.12"
+
commonMain.dependencies {
implementation(project(":waltid-libraries:sdjwt:waltid-sdjwt"))... | `implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")` is available |
waltid-identity | github_2023 | others | 762 | walt-id | cpatsonakis | @@ -0,0 +1,9 @@
+package id.walt.commons.exceptions
+
+import io.ktor.http.HttpStatusCode
+
+open class CryptoException( val status: HttpStatusCode,message: String) : Exception(message) | format code block |
waltid-identity | github_2023 | others | 762 | walt-id | cpatsonakis | @@ -0,0 +1,9 @@
+package id.walt.commons.exceptions
+
+import io.ktor.http.HttpStatusCode
+
+open class CryptoException( val status: HttpStatusCode,message: String) : Exception(message)
+
+
+class KeyTypeNotSupportedException(type: String) : CryptoException(HttpStatusCode.BadRequest, "Key type $type not Registered") | NotSupported on type declaration, not registered on error message. Should be on or the other for the sake of consistency |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -273,14 +278,14 @@ class OCIKeyRestApi(
private fun keyTypeToOciKeyMapping(type: KeyType) = when (type) {
KeyType.secp256r1 -> "ECDSA"
KeyType.RSA -> "RSA"
- KeyType.secp256k1 -> throw IllegalArgumentException("Not supported: $type")
- KeyType.Ed25519 -> throw... | this could be replaced with else, similar to how it's done below in `ociKeyToKeyTypeMapping`:
```kotlin
private fun keyTypeToOciKeyMapping(type: KeyType) = when (type) {
KeyType.secp256r1 -> "ECDSA"
KeyType.RSA -> "RSA"
else -> throw KeyTypeNotSupportedException(type.name)
}
``` |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -293,10 +298,10 @@ class OCIKeyRestApi(
val vaultKeyId = "${config.tenancyOcid}/${config.userOcid}/${config.fingerprint}"
val host = config.managementEndpoint
val length = when (type) {
- KeyType.Ed25519 -> throw IllegalArgumentException("Not supp... | same here:
```kotlin
val length = when (type) {
KeyType.secp256r1 -> 32
KeyType.RSA -> 256
else -> throw KeyTypeNotSupportedException(type.name)
}
``` |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -0,0 +1,207 @@
+import love.forte.plugin.suspendtrans.ClassInfo
+import love.forte.plugin.suspendtrans.SuspendTransformConfiguration
+import love.forte.plugin.suspendtrans.TargetPlatform
+import love.forte.plugin.suspendtrans.gradle.SuspendTransPluginConstants
+import love.forte.plugin.suspendtrans.gradle.SuspendTra... | maybe clean up these comments |
waltid-identity | github_2023 | others | 762 | walt-id | cpatsonakis | @@ -0,0 +1,27 @@
+package id.walt.commons.exceptions
+
+import io.ktor.http.HttpStatusCode
+
+open class CryptoException(val status: HttpStatusCode, message: String) : Exception(message)
+
+
+class KeyTypeNotSupportedException(type: String) : | minor detail:
"not supported" without the capital "S"
|
waltid-identity | github_2023 | others | 762 | walt-id | cpatsonakis | @@ -0,0 +1,27 @@
+package id.walt.commons.exceptions
+
+import io.ktor.http.HttpStatusCode
+
+open class CryptoException(val status: HttpStatusCode, message: String) : Exception(message)
+
+
+class KeyTypeNotSupportedException(type: String) :
+ CryptoException(HttpStatusCode.BadRequest, "Key type $type not Supported... | maybe rename it to KeyTypeMissingException so that it can be more easily found when searching for exceptions? |
waltid-identity | github_2023 | others | 762 | walt-id | cpatsonakis | @@ -168,9 +179,10 @@ class TSEKey(
override suspend fun signRaw(plaintext: ByteArray): Any {
val body = mapOf("input" to plaintext.encodeBase64())
val signatureBase64 = httpRequest(HttpMethod.Post, "sign/$id", body)
- .tseJsonDataBody().jsonObject["signature"]?.jsonPrimitive?.content?.... | Maybe modify the error message here to be a little more informative:
"No signature value provided as part of the response to the raw signing request to the TSE."
Just a suggestion! Feel free to modify :) |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -388,7 +393,8 @@ class OCIKeyRestApi(
else -> throw IllegalArgumentException("Unsupported HTTP method: $method")
}
- val privateOciApiKey = signingKey ?: error("No private key provided for OCI signing. Please provide a private key.")
+ val privateOciApiKey = sign... | this feels more like `KeyNotFoundException` |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -217,7 +222,7 @@ class OCIKeyRestApi(
setBody(requestBody)
}.ociJsonDataBody().jsonObject["isSignatureValid"]?.jsonPrimitive?.boolean ?: false
return if (response) Result.success(detachedPlaintext)
- else Result.failure(Exception("Signature is not valid"))
+ else Result.f... | ide says 'not reachable'
I think it should be:
```kotlin
Result.failure(VerificationException("Signature is not valid"))
``` |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -438,7 +444,8 @@ class OCIKeyRestApi(
header("Host", host)
}
- val publicKeyPem = response.body<JsonObject>()["publicKey"]?.jsonPrimitive?.content ?: error("No public key returned from OCI.")
+ val publicKeyPem = response.body<JsonObject>()["publicKey"]?.jsonPrim... | not sure how oci kms works, maybe it can tell if it cannot return the public key for a given key-id (i.e. have a key identifiable by ociKeyId, but it has no public key)
but I think this could be `KeyNotFoundException` |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -70,10 +72,11 @@ data class TSEAuth(
private suspend fun HttpResponse.getClientToken() =
body<JsonObject>().let {
if (it.containsKey("errors")) {
- error("Errors occurred at TSE login: " + it["errors"]!!.jsonArray.map { it.jsonPrimitive.content }.joinToString())
+ ... | maybe have it in a separate method, e.g. `checkNoErrors`:
```kotlin
private fun checkNoErrors(json: JsonObject) = json["errors"]?.let {
throw TSELoginException("Errors occurred at TSE login: " + it.jsonArray.joinToString { it.jsonPrimitive.content })
}
```
then `getClientToken` would become:
```kotlin
priva... |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -53,7 +58,9 @@ class TSEKey(
@Suppress("DEPRECATION")
@Transient
- private val effectiveAuth: TSEAuth = auth ?: TSEAuth(accessKey = accessKey ?: throw IllegalArgumentException("Either auth or accessKey must be provided"))
+ private val effectiveAuth: TSEAuth = auth ?: TSEAuth( | I think `auth` is a leftover, or part of deprecation
maybe this could be removed whatsoever (!! need to check the consequences) |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -218,10 +230,10 @@ class TSEKey(
)
val valid = httpRequest(HttpMethod.Post, "verify/$id", body)
.tseJsonDataBody().jsonObject["valid"]?.jsonPrimitive?.boolean
- ?: throwTSEError("No (verification) valid response in data response")
+ ?: throw VerificationException(... | here as well, feels more like `MissingSignatureException` |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -218,10 +230,10 @@ class TSEKey(
)
val valid = httpRequest(HttpMethod.Post, "verify/$id", body)
.tseJsonDataBody().jsonObject["valid"]?.jsonPrimitive?.boolean
- ?: throwTSEError("No (verification) valid response in data response")
+ ?: throw VerificationException(... | while here feels more like `VerificationException` |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -258,7 +270,7 @@ class TSEKey(
lazyOf(
httpRequest()
.tseJsonDataBody().jsonObject["keys"]?.jsonObject?.get("1")?.jsonObject?.get("public_key")?.jsonPrimitive?.content
- ?: throwTSEError("No keys/1/public_key in data response")
+ ?: throw PublicKey... | I'd probably have here just a `KeyNotFoundException`, not sure if it matters at this stage to explicitly mention the public key |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.