daystar-verify 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "daystar-verify",
3
- "version": "1.0.0",
4
- "description": "",
3
+ "version": "1.0.1",
4
+ "description": "A library for verifying student status with Daystar University.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
7
10
  "scripts": {
8
11
  "build": "tsc"
9
12
  },
@@ -1,27 +0,0 @@
1
- name: Publish to npm
2
-
3
- on:
4
- push:
5
- tags:
6
- - "v*"
7
-
8
- jobs:
9
- publish:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v4
13
-
14
- - uses: actions/setup-node@v4
15
- with:
16
- node-version: 20
17
- registry-url: "https://registry.npmjs.org"
18
-
19
- - uses: pnpm/action-setup@v3
20
- with:
21
- version: 10
22
-
23
- - run: pnpm install
24
- - run: pnpm run build
25
- - run: npm publish
26
- env:
27
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/src/auth.ts DELETED
@@ -1,52 +0,0 @@
1
- import { config } from "./config";
2
-
3
- /**
4
- * Fetches a session token from the server.
5
- * @returns The session token as a string.
6
- * @throws If the request fails or the token cannot be retrieved.
7
- */
8
- export async function fetchSessionToken(): Promise<string> {
9
- const res = await fetch(`${config.baseUrl}/`);
10
- if (!res.ok) throw new Error("Failed to communicate with server");
11
-
12
- const cookie = res.headers.get("set-cookie") ?? "";
13
- const token = cookie.split(" ")[0];
14
- if (!token) throw new Error("Failed to retrieve session token");
15
-
16
- return token;
17
- }
18
-
19
- /**
20
- * Logs in a user and returns the session cookie.
21
- * @param sessionId
22
- * @param admno
23
- * @param password
24
- * @returns
25
- */
26
- export async function login(
27
- sessionId: string,
28
- admno: string,
29
- password: string,
30
- ): Promise<string> {
31
- if (!sessionId) throw new Error("sessionId is empty");
32
-
33
- const res = await fetch(`${config.baseUrl}/Login/LoginUser`, {
34
- method: "POST",
35
- headers: {
36
- "Content-Type": "application/json",
37
- Cookie: sessionId,
38
- },
39
- body: JSON.stringify({ Username: admno, Password: password }),
40
- });
41
-
42
- if (!res.ok) throw new Error(`Request failed with status ${res.status}`);
43
-
44
- const body = await res.json();
45
- if (!body.success) throw new Error(body.message ?? "Login failed");
46
-
47
- const newCookie = res.headers.get("set-cookie") ?? "";
48
- const userSession = `${sessionId} ${newCookie}`.trim();
49
- if (!userSession) throw new Error("Failed to retrieve user session");
50
-
51
- return userSession;
52
- }
package/src/config.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Configuration for the Daystar Verify package.
3
- */
4
- export const config = {
5
- baseUrl: process.env.DAYSTAR_PORTAL_URL ?? "",
6
- };
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- import { fetchSessionToken, login } from "./auth";
2
- import { config } from "./config";
3
-
4
- export { fetchSessionToken, login, config };
package/tsconfig.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "rootDir": "./src",
4
- "outDir": "./dist",
5
- "module": "commonjs",
6
- "moduleResolution": "node10",
7
- "ignoreDeprecations": "6.0",
8
- "target": "esnext",
9
- "types": [
10
- "node"
11
- ],
12
- "sourceMap": true,
13
- "declaration": true,
14
- "declarationMap": true,
15
- "noUncheckedIndexedAccess": true,
16
- "exactOptionalPropertyTypes": true,
17
- "strict": true,
18
- "isolatedModules": true,
19
- "moduleDetection": "force",
20
- "skipLibCheck": true
21
- },
22
- "include": [
23
- "src"
24
- ]
25
- }