Skip to content

Commit

Permalink
chore: more debugging for transient_payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Burtey committed Sep 21, 2023
1 parent b292a3f commit 4391065
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ junit.xml
.next

.direnv
.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { RegistrationPayloadValidator } from "@domain/authentication/registratio
import { ErrorLevel } from "@domain/shared"
import { InvalidPhoneNumber, InvalidUserId } from "@domain/errors"

import { recordExceptionInCurrentSpan } from "@services/tracing"
import {
addAttributesToCurrentSpan,
recordExceptionInCurrentSpan,
} from "@services/tracing"
import { SchemaIdType } from "@services/kratos"

import { createAccountWithPhoneIdentifier } from "@app/accounts"
Expand All @@ -21,6 +24,10 @@ export const createAccountFromRegistrationPayload = async ({
schema_id?: string
}
}): Promise<Account | ApplicationError> => {
addAttributesToCurrentSpan({
"registration.body": JSON.stringify(body),
})

const isValidKey = CallbackSecretValidator(KRATOS_CALLBACK_API_KEY).authorize(secret)
if (isValidKey instanceof Error) {
return isValidKey
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GT } from "@graphql/index"

import AccountUpdateNotificationSettingsPayload from "@graphql/public/types/payload/account-update-notification-settings"
import { Accounts } from "@app/index"
import { Accounts } from "@app"
import { mapAndParseErrorForGqlResponse } from "@graphql/error-map"
import NotificationChannel from "@graphql/shared/types/scalar/notification-channel"
import NotificationCategory from "@graphql/shared/types/scalar/notification-category"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GT } from "@graphql/index"

import AccountUpdateNotificationSettingsPayload from "@graphql/public/types/payload/account-update-notification-settings"
import { Accounts } from "@app/index"
import { Accounts } from "@app"
import { mapAndParseErrorForGqlResponse } from "@graphql/error-map"
import NotificationChannel from "@graphql/shared/types/scalar/notification-channel"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GT } from "@graphql/index"

import AccountUpdateNotificationSettingsPayload from "@graphql/public/types/payload/account-update-notification-settings"
import { Accounts } from "@app/index"
import { Accounts } from "@app"
import { mapAndParseErrorForGqlResponse } from "@graphql/error-map"
import NotificationChannel from "@graphql/shared/types/scalar/notification-channel"
import NotificationCategory from "@graphql/shared/types/scalar/notification-category"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GT } from "@graphql/index"

import AccountUpdateNotificationSettingsPayload from "@graphql/public/types/payload/account-update-notification-settings"
import { Accounts } from "@app/index"
import { Accounts } from "@app"
import { mapAndParseErrorForGqlResponse } from "@graphql/error-map"
import NotificationChannel from "@graphql/shared/types/scalar/notification-channel"

Expand Down
13 changes: 7 additions & 6 deletions src/servers/event-handlers/kratos.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import cors from "cors"
import express from "express"

import { addAttributesToCurrentSpan, wrapAsyncToRunInSpan } from "@services/tracing"
import { wrapAsyncToRunInSpan } from "@services/tracing"
import { baseLogger } from "@services/logger"

import { createAccountFromRegistrationPayload } from "@app/authentication"
import { Authentication } from "@app"

import {
SecretForAuthNCallbackError,
RegistrationPayloadValidationError,
Expand All @@ -31,11 +32,11 @@ kratosCallback.post(
fn: async (req: express.Request, res: express.Response) => {
const secret = req.headers.authorization
const body = req.body
addAttributesToCurrentSpan({
"registration.body": JSON.stringify(body),
})

const account = await createAccountFromRegistrationPayload({ secret, body })
const account = await Authentication.createAccountFromRegistrationPayload({
secret,
body,
})
if (account instanceof Error) {
const message = errorResponseMessages[account.name] || "unknown error"
switch (true) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Wallets } from "@app/index"
import { Wallets } from "@app"

import { ZERO_SATS } from "@domain/shared"
import { MultipleCurrenciesForSingleCurrencyOperationError } from "@domain/errors"
Expand Down

0 comments on commit 4391065

Please sign in to comment.