skyllful-auth-integration 1.0.0

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/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # skyllful-auth-integration
2
+
3
+ Get user information from the current browser URL including userId, firstName, lastName, and permission flags.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install skyllful-auth-integration
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { getUserInfo } from 'skyllful-auth-integration';
15
+
16
+ // In browser environment
17
+ // Current URL: https://app.example.com/?userId=456&firstName=Jane&lastName=Smith&permissions=simulator,iq
18
+ const userInfo = await getUserInfo();
19
+
20
+ console.log(userInfo);
21
+ // {
22
+ // userId: '456',
23
+ // firstName: 'Jane',
24
+ // lastName: 'Smith',
25
+ // hasSimulatorPermission: true,
26
+ // hasIqPermission: true,
27
+ // hasStudioPermission: false
28
+ // }
29
+ ```
30
+
31
+ Or use the default export:
32
+
33
+ ```typescript
34
+ import getUserInfo from 'skyllful-auth-integration';
35
+
36
+ const userInfo = await getUserInfo();
37
+ ```
38
+
39
+ ## API
40
+
41
+ ### `getUserInfo()`
42
+
43
+ Get user information from the current browser URL.
44
+
45
+ **Returns:** `Promise<UserInfo>` that resolves to an object with:
46
+ - `userId` (string): The user ID from the `userId` URL parameter
47
+ - `firstName` (string): The user's first name from the `firstName` URL parameter
48
+ - `lastName` (string): The user's last name from the `lastName` URL parameter
49
+ - `hasSimulatorPermission` (boolean): True if `permissions` includes "simulator"
50
+ - `hasIqPermission` (boolean): True if `permissions` includes "iq"
51
+ - `hasStudioPermission` (boolean): True if `permissions` includes "studio"
52
+
53
+ **Note:** This function only works in browser environments and will throw an error in Node.js.
54
+
55
+ **Expected URL parameters:**
56
+ - `userId` - The user ID
57
+ - `firstName` - The user's first name
58
+ - `lastName` - The user's last name
59
+ - `permissions` - Comma-separated list of permissions (e.g., `simulator,iq,studio`)
60
+
61
+ ## TypeScript
62
+
63
+ This package includes TypeScript definitions. The following type is exported:
64
+
65
+ ```typescript
66
+ interface UserInfo {
67
+ userId: string;
68
+ firstName: string;
69
+ lastName: string;
70
+ hasSimulatorPermission: boolean;
71
+ hasIqPermission: boolean;
72
+ hasStudioPermission: boolean;
73
+ }
74
+ ```
75
+
76
+ ## License
77
+
78
+ ISC
@@ -0,0 +1,15 @@
1
+ export interface UserInfo {
2
+ userId: string;
3
+ firstName: string;
4
+ lastName: string;
5
+ hasSimulatorPermission: boolean;
6
+ hasIqPermission: boolean;
7
+ hasStudioPermission: boolean;
8
+ }
9
+ /**
10
+ * Get user information from the current browser URL
11
+ * Note: This function only works in browser environments
12
+ * @returns Promise resolving to UserInfo object with parsed authentication data
13
+ */
14
+ export declare function getUserInfo(): Promise<UserInfo>;
15
+ export default getUserInfo;
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUserInfo = getUserInfo;
4
+ /**
5
+ * Get user information from the current browser URL
6
+ * Note: This function only works in browser environments
7
+ * @returns Promise resolving to UserInfo object with parsed authentication data
8
+ */
9
+ async function getUserInfo() {
10
+ if (typeof window === 'undefined' || !window.location) {
11
+ throw new Error('getUserInfo can only be used in browser environments');
12
+ }
13
+ const params = new URL(window.location.href).searchParams;
14
+ const userId = params.get('userId') || '';
15
+ const firstName = params.get('firstName') || '';
16
+ const lastName = params.get('lastName') || '';
17
+ const permissionsStr = params.get('permissions') || '';
18
+ const permissions = permissionsStr
19
+ ? permissionsStr.split(',').map(p => p.trim().toLowerCase()).filter(p => p)
20
+ : [];
21
+ return {
22
+ userId,
23
+ firstName,
24
+ lastName,
25
+ hasSimulatorPermission: permissions.includes('simulator'),
26
+ hasIqPermission: permissions.includes('iq'),
27
+ hasStudioPermission: permissions.includes('studio')
28
+ };
29
+ }
30
+ exports.default = getUserInfo;
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "skyllful-auth-integration",
3
+ "version": "1.0.0",
4
+ "description": "Parse authentication parameters from URL and extract user information",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "prepublishOnly": "npm run build"
10
+ },
11
+ "keywords": [
12
+ "authentication",
13
+ "auth",
14
+ "url-params",
15
+ "user-info"
16
+ ],
17
+ "author": "",
18
+ "license": "ISC",
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "devDependencies": {
23
+ "typescript": "^5.9.3"
24
+ }
25
+ }