-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 코인 어드민 로그인 로직 추가 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d8d970f
8ef0464
d5a90be
c77b08a
ca36900
38d9423
80bb158
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| interface KoinAdminLoginResponse { | ||
| token: string; | ||
| } | ||
|
|
||
| export async function loginKoinAdmin(): Promise<string> { | ||
| const baseURL = import.meta.env.KOIN_API_BASE_URL; | ||
| const email = import.meta.env.KOIN_ADMIN_EMAIL; | ||
| const password = import.meta.env.KOIN_ADMIN_PASSWORD; | ||
|
Comment on lines
+6
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Expect: loginKoinAdmin is server-only and the project defines an intentional
# runtime configuration or envPrefix strategy for the Koin variables.
rg -n -C 4 \
'loginKoinAdmin|KOIN_(API_BASE_URL|ADMIN_EMAIL|ADMIN_PASSWORD)|runtimeConfig|useRuntimeConfig|envPrefix|import\.meta\.env|process\.env' . || trueRepository: BCSDLab/B_BOT Length of output: 18449 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== repository files relevant to build/deploy config =="
git ls-files | rg '(^|/)(package\.json|pnpm-lock\.yaml|\.nite|\.nitro|nitro\.config\.(ts|js|mjs|cjs)|nuxt\.config\.(ts|js|mjs|cjs)|wrangler\.toml|vercel\.json|netlify\.toml|package-lock\.json|yarn\.lock|\.env|\.output)' || true
echo
echo "== package scripts and deps =="
python3 - <<'PY'
import json
from pathlib import Path
p=Path('package.json')
if p.exists():
data=json.loads(p.read_text())
print("scripts:")
print(json.dumps(data.get("scripts", {}), indent=2, sort_keys=True))
print("\ndependencies:")
for k,v in sorted((data.get("dependencies",{})|data.get("devDependencies",{})).items()):
if any(s in k.lower() for s in ("nitro","nuxt","vite","ofetch","nuxi")):
print(f" {k}: {v}")
PY
echo
echo "== loginKoinAdmin definitions and call sites =="
rg -n -C 6 '\bloginKoinAdmin\b|import\s+.*\bkoin/adminLogin\b|from\s+["\']\s*~\s*(/koin/adminLogin|/services/koin/adminLogin|services/koin/adminLogin)\s?["\']' . || true
echo
echo "== nitro/nuxt config occurrences =="
rg -n -C 4 'envPrefix|runtimeConfig|import\.meta\.env\.KOIN|KOIN_(API_BASE_URL|ADMIN_EMAIL|ADMIN_PASSWORD)|srcDir|serverDir|compatibilityDate' . --glob '!pnpm-lock.yaml' || trueRepository: BCSDLab/B_BOT Length of output: 514 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== nitro.config.ts =="
cat -n nitro.config.ts
echo
echo "== package.json =="
cat -n package.json
echo
echo "== relevant env example entries =="
rg -n -C 4 'KOIN_(API_BASE_URL|ADMIN_EMAIL|ADMIN_PASSWORD)' .env.example || true
echo
echo "== loginKoinAdmin usage =="
rg -n -C 6 '\bloginKoinAdmin\b|from ["\']\s*~(/koin/adminLogin|/services/koin/adminLogin|services/koin/adminLogin)\s?["\']' . || true
echo
echo "== runtimeConfig/envPrefix occurrences (excluding lockfile) =="
rg -n -C 4 'runtimeConfig|envPrefix|import\.meta\.env\.KOIN|KOIN_(API_BASE_URL|ADMIN_EMAIL|ADMIN_PASSWORD)|process\.env\.KOIN' --glob '!pnpm-lock.yaml' . || trueRepository: BCSDLab/B_BOT Length of output: 2436 Use private nitro runtime config for Koin admin credentials.
🤖 Prompt for AI AgentsSource: MCP tools |
||
|
|
||
| const response = await $fetch<KoinAdminLoginResponse>("admin/user/login", { | ||
|
Comment on lines
+6
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | rg '(^|/)adminLogin\.ts$|env\.d\.ts$|admin.*login|Koin|koin' || true
echo "== target file =="
if [ -f src/services/koin/adminLogin.ts ]; then
cat -n src/services/koin/adminLogin.ts
fi
echo "== env declarations =="
for f in $(git ls-files '*.d.ts' | rg 'env|types'); do
echo "--- $f"
sed -n '1,220p' "$f"
done
echo "== other Koin env usage =="
rg -n "import\.meta\.env\.(KOIN_API_BASE_URL|KOIN_ADMIN_EMAIL|KOIN_ADMIN_PASSWORD|Koin|KOIN)" . || true
echo "== fetch behavior probe (Node) =="
node - <<'JS'
const values = [undefined, "", " ", null, "ok"];
console.log(
JSON.stringify(
values.map(v => ({
value: v,
valueAsItWouldBeSent: v,
trimResult: v && typeof v === "string" ? v.trim() : undefined,
filtered: !v?.trim()
})),
null,
2
)
);
JSRepository: BCSDLab/B_BOT Length of output: 2654 Reject missing Koin configuration before the request.
🤖 Prompt for AI AgentsSource: MCP tools |
||
| baseURL, | ||
| method: "POST", | ||
| body: { | ||
| email, | ||
| password, | ||
| } | ||
| }); | ||
|
Comment on lines
+10
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== locate relevant files =="
git ls-files | rg '(^|/)adminLogin\.ts$|(^|/)(package\.json|pnpm-lock\.yaml|package-lock\.json|yarn\.lock)$|nuxt\.config|nuxt\.config\.' || true
echo
echo "== adminLogin.ts =="
if [ -f src/services/koin/adminLogin.ts ]; then
nl -ba src/services/koin/adminLogin.ts | sed -n '1,120p'
fi
echo
echo "== package/lock references =="
for f in package.json pnpm-lock.yaml package-lock.json yarn.lock; do
if [ -f "$f" ]; then
echo "--- $f ---"
rg -n '"?ofetch"?\s*|ofetch@|/ofetch/@|node_modules/ofetch' "$f" -C 2 || true
fi
done
echo
echo "== fetch implementations =="
rg -n '\$fetch\(|$fetch\(|timeout\s*:' src -S || trueRepository: BCSDLab/B_BOT Length of output: 301 🌐 Web query:
💡 Result: In unjs/ofetch, the timeout feature is disabled by default [1][2][3]. You can enable request timeouts by providing a Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== adminLogin.ts =="
awk '{printf "%6d %s\n", NR, $0}' src/services/koin/adminLogin.ts | sed -n '1,120p'
echo
echo "== package.json relevant deps =="
node - <<'JS'
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const keys = ['dependencies','devDependencies','peerDependencies','optionalDependencies'];
for (const k of keys) {
console.log(`-- ${k} --`);
if (pkg[k]) {
for (const name of Object.keys(pkg[k]).filter(n => /nuxt|ofetch|fetch/i.test(n))) {
console.log(`${name}: ${pkg[k][name]}`);
}
}
}
JS
echo
echo "== lockfile ofetch versions =="
awk '{printf "%6d %s\n", NR, $0}' pnpm-lock.yaml | rg -n -C 3 '(^|/npm/ofetch|/ofetch@|/@nuxt/deeplink:|ofetch)' || true
echo
echo "== fetch and timeout usage in src =="
rg -n '\$fetch\(|fetch\(|\.timeout\(|timeout\s*:' src -S || trueRepository: BCSDLab/B_BOT Length of output: 50370 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== git diff focused on adminLogin =="
git diff -- src/services/koin/adminLogin.ts | sed -n '1,160p'
echo
echo "== any ofetch lock entries =="
arg {printf "%6d %s\n", NR, $0}' pnpm-lock.yaml | rg -n -C 2 'ofetch@|/npm/ofetch|unjs/ofetch|^ /:|^ npm:|^ file:' || true
echo
echo "== local timeout usage =="
rg -n '\btimeout\s*:\s*[0-9]+|AbortSignal\.timeout|timeout' src package.json pnpm-lock.yaml -S || trueRepository: BCSDLab/B_BOT Length of output: 280 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== focused git diff for adminLogin =="
git diff -- src/services/koin/adminLogin.ts | sed -n '1,160p' || true
echo
echo "== focused lockfile entries for ofetch =="
rg -n -C 3 'ofetch@|/npm/ofetch|unjs/ofetch|`@nuxt/deep`' pnpm-lock.yaml || true
echo
echo "== focused timeout usage =="
rg -n '\btimeout\s*:\s*[0-9]+|AbortSignal\.timeout|timeout' src package.json pnpm-lock.yaml -S || trueRepository: BCSDLab/B_BOT Length of output: 1141 Bound the Koin login request.
🤖 Prompt for AI AgentsSource: MCP tools |
||
|
|
||
| if (typeof response.token !== "string" || response.token.length === 0) { | ||
| throw new Error("KOIN 관리자 로그인 응답에 액세스 토큰이 없습니다."); | ||
| } | ||
|
|
||
| return response.token; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: BCSDLab/B_BOT
Length of output: 1463
🏁 Script executed:
Repository: BCSDLab/B_BOT
Length of output: 234
🏁 Script executed:
Repository: BCSDLab/B_BOT
Length of output: 6385
🌐 Web query:
ofetch 1.4.1 $fetch default parseResponse JSON response null documentation💡 Result:
In ofetch (including version 1.4.1), the default response parsing mechanism handles responses as follows when a JSON response is received [1]: 1. Parsing Logic: When the response type is resolved to "json" (which is the default if no Content-Type header is present or if the header indicates JSON) [2][3][1], ofetch calls response.text to get the response body as a string [1]. 2. Handling Empty/Null Responses: If the resulting string is empty or falsy, ofetch skips the parsing step [1]. Specifically, the implementation checks
if (data)(wheredatais the text content) before attempting to parse it with theparseResponsefunction or the defaultJSON.parse[1]. 3. Result: Consequently, if the response body is empty, the_dataproperty of the response remains undefined or is not assigned a parsed object, avoiding attempts to callJSON.parse()on an empty string, which would otherwise throw a SyntaxError [1]. If you are encountering anullresponse and need to ensure it is handled gracefully, you can provide a customparseResponsefunction to override this default behavior [4][2][1]: await ofetch('/api/endpoint', { parseResponse: (text) => text? JSON.parse(text): null }) Additionally, note that for specific HTTP status codes (such as 204 No Content), ofetch intentionally excludes the body from being processed [1].Citations:
🌐 Web query:
ofetch parseResponse JSON parsing response body type JSON.parse default null💡 Result:
In
ofetch, the default behavior for parsing JSON response bodies is to usedestr(a secure, optimized JSON parser) rather thanJSON.parsedirectly [1][2]. When the response type isjson(which is the default when theContent-Typeisapplication/jsonor missing),ofetchreads the response body as text [1][3]. It then checks if the response body text is non-empty [3]. If the text is present, it passes the string to the configured parser [3]. Regarding your query onnull: 1. Default behavior: If the response body is empty or nullish,ofetchtypically avoids attempting to parse it as JSON [3]. 2. Custom parsing: If you provide a customparseResponsefunction,ofetchwill use that function to handle the text [4][5]. If you explicitly setparseResponse: JSON.parse, and the response body is an empty string,JSON.parse('')will throw a SyntaxError. Therefore, if you are providing a custom parser, you should ensure it handles empty or null body scenarios appropriately [4][5]. In summary,ofetchinternally usesdestrby default for robustness [2], and only attempts to parse the text if it is not empty [3]. If you override this withJSON.parse, ensure your implementation accounts for empty response bodies [4][5].Citations:
Guard the response before reading
response.token.$fetch<KoinAdminLoginResponse>is a type assertion and does not validate the returned JSON. Ifadmin/user/loginreturns an unexpected payload,response.tokencan throwTypeErrorbefore the intended login error. Handle the value asunknown, check that it is a non-null object with a non-empty stringtoken, then returnresponse.token.trim().🤖 Prompt for AI Agents