playcademy 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +23 -16
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3119,18 +3119,23 @@ async function startCallbackServer(timeoutMs) {
|
|
|
3119
3119
|
return new Promise((resolve10) => {
|
|
3120
3120
|
let server = null;
|
|
3121
3121
|
let timeoutId = null;
|
|
3122
|
-
const cleanup = () => {
|
|
3122
|
+
const cleanup = (callback) => {
|
|
3123
3123
|
if (timeoutId) clearTimeout(timeoutId);
|
|
3124
3124
|
if (server) {
|
|
3125
|
-
server.close()
|
|
3126
|
-
|
|
3125
|
+
server.close(() => {
|
|
3126
|
+
server = null;
|
|
3127
|
+
callback?.();
|
|
3128
|
+
});
|
|
3129
|
+
} else {
|
|
3130
|
+
callback?.();
|
|
3127
3131
|
}
|
|
3128
3132
|
};
|
|
3129
3133
|
timeoutId = setTimeout(() => {
|
|
3130
|
-
cleanup()
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
+
cleanup(() => {
|
|
3135
|
+
resolve10({
|
|
3136
|
+
success: false,
|
|
3137
|
+
error: "Authentication timed out. Please try again."
|
|
3138
|
+
});
|
|
3134
3139
|
});
|
|
3135
3140
|
}, timeoutMs);
|
|
3136
3141
|
server = createServer((req, res) => {
|
|
@@ -3140,22 +3145,24 @@ async function startCallbackServer(timeoutMs) {
|
|
|
3140
3145
|
const email = url.searchParams.get("email");
|
|
3141
3146
|
const userId = url.searchParams.get("userId");
|
|
3142
3147
|
if (!sessionToken || !email || !userId) {
|
|
3143
|
-
cleanup()
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3148
|
+
cleanup(() => {
|
|
3149
|
+
resolve10({
|
|
3150
|
+
success: false,
|
|
3151
|
+
error: "Invalid callback data received"
|
|
3152
|
+
});
|
|
3147
3153
|
});
|
|
3148
3154
|
res.writeHead(400, { "Content-Type": "text/html" });
|
|
3149
3155
|
res.end(getErrorHtml("Invalid authentication data"));
|
|
3150
3156
|
return;
|
|
3151
3157
|
}
|
|
3152
|
-
cleanup();
|
|
3153
|
-
resolve10({
|
|
3154
|
-
success: true,
|
|
3155
|
-
data: { sessionToken, email, userId }
|
|
3156
|
-
});
|
|
3157
3158
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
3158
3159
|
res.end(SUCCESS_HTML);
|
|
3160
|
+
cleanup(() => {
|
|
3161
|
+
resolve10({
|
|
3162
|
+
success: true,
|
|
3163
|
+
data: { sessionToken, email, userId }
|
|
3164
|
+
});
|
|
3165
|
+
});
|
|
3159
3166
|
return;
|
|
3160
3167
|
}
|
|
3161
3168
|
res.writeHead(404, { "Content-Type": "text/plain" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playcademy",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@hono/node-server": "^1.19.5",
|
|
32
32
|
"@inquirer/prompts": "^7.8.6",
|
|
33
|
-
"@playcademy/sdk": "0.0
|
|
33
|
+
"@playcademy/sdk": "0.1.0",
|
|
34
34
|
"chokidar": "^4.0.3",
|
|
35
35
|
"colorette": "^2.0.20",
|
|
36
36
|
"commander": "^14.0.1",
|