@mulverse/mulguard-core 1.0.0 → 1.0.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/LICENSE ADDED
@@ -0,0 +1,70 @@
1
+
2
+ ---
3
+
4
+ **Mulverse M.U.V GENERAL PUBLIC LICENSE**
5
+
6
+ **Version 1.0**
7
+
8
+ **Copyright (C) [2022] Mulverse Inc.**
9
+
10
+ **1. Definitions**
11
+
12
+ 1.1 **"Software"** refers to the Mulverse software distributed under this license, including all associated files, documentation, and any updates or modifications.
13
+
14
+ 1.2 **"You"** means the individual or entity who receives or uses the Software.
15
+
16
+ 1.3 **"Distribution"** refers to any form of sharing or redistribution of the Software, including copies or derivative works.
17
+
18
+ **2. Permissions**
19
+
20
+ 2.1 **Use**: You are granted the right to use the Software for any purpose.
21
+
22
+ 2.2 **Copy and Distribution**: You may distribute copies of the Software, either in its original form or as modified, provided that all copies include the same license terms.
23
+
24
+ 2.3 **Modification**: You may modify the Software and distribute the modified versions, provided that the modified Software is also licensed under this Mulverse M.U.V General Public License and that you include a prominent notice stating the changes made.
25
+
26
+ **3. Copyleft**
27
+
28
+ 3.1 **Source Code**: If you distribute the Software or any derivative works, you must either include the source code or make it available in a manner specified by this license.
29
+
30
+ 3.2 **License Continuity**: All copies and derivative works of the Software must be distributed under the terms of this Mulverse M.U.V General Public License. You must include a copy of this license with all distributions.
31
+
32
+ **4. Conditions**
33
+
34
+ 4.1 **Attribution**: You must provide appropriate credit to Mulverse Inc., including a notice that the Software is licensed under the Mulverse M.U.V General Public License.
35
+
36
+ 4.2 **No Warranty**: The Software is provided "as is," without any warranty of any kind. Mulverse Inc. disclaims all warranties and conditions, including but not limited to implied warranties of merchantability and fitness for a particular purpose.
37
+
38
+ 4.3 **No Additional Restrictions**: You may not impose any additional restrictions on the rights granted by this license. This includes, but is not limited to, additional licenses or agreements.
39
+
40
+ **5. Termination**
41
+
42
+ 5.1 **Automatic Termination**: If you breach any of the terms of this license, your rights under this license will be terminated automatically.
43
+
44
+ 5.2 **Reinstatement**: You may be reinstated if you cure the breach and notify Mulverse Inc. of the cure within 30 days of the termination.
45
+
46
+ **6. Patent Grant**
47
+
48
+ 6.1 **Patent License**: You grant to Mulverse Inc. a non-exclusive, royalty-free license to any patents you may hold that are necessary to use the Software.
49
+
50
+ **7. Indemnity**
51
+
52
+ 7.1 **Indemnification**: You agree to indemnify and hold Mulverse Inc. harmless from any claims, damages, or liabilities arising from your use or distribution of the Software.
53
+
54
+ **8. Governing Law**
55
+
56
+ 8.1 **Jurisdiction**: This license shall be governed by and construed in accordance with the laws of [Your Jurisdiction].
57
+
58
+ **9. Miscellaneous**
59
+
60
+ 9.1 **Severability**: If any provision of this license is held to be invalid or unenforceable, the remaining provisions will remain in effect.
61
+
62
+ 9.2 **Entire Agreement**: This license constitutes the entire agreement between you and Mulverse Inc. regarding the Software and supersedes all prior agreements and understandings.
63
+
64
+ **10. Contact**
65
+
66
+ 10.1 **Inquiries**: For any questions or concerns regarding this license, please contact Mulverse Inc. at [Contact Information].
67
+
68
+ **End of License**
69
+
70
+ ---
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Helper functions for Server Actions Adapter
3
+ *
4
+ * This module provides utilities to convert server actions into adapter format
5
+ * and handle server action responses.
6
+ */
7
+ import type { Adapter, ServerActionsAdapter } from "../adapters.js";
8
+ /**
9
+ * Creates an Adapter from Server Actions Adapter.
10
+ * This function wraps server actions to match the Adapter interface.
11
+ *
12
+ * @param serverActions - The server actions adapter configuration
13
+ * @returns An Adapter instance that uses the provided server actions
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const adapter = createServerActionsAdapter({
18
+ * getUser: async (id) => {
19
+ * const user = await getProfileApiV1AuthMeGet()
20
+ * return transformToAdapterUser(user)
21
+ * },
22
+ * })
23
+ * ```
24
+ */
25
+ export declare function createServerActionsAdapter(serverActions: ServerActionsAdapter): Adapter;
26
+ /**
27
+ * Checks if a Server Actions Adapter has all required methods for a specific feature.
28
+ *
29
+ * @param serverActions - The server actions adapter to check
30
+ * @param requiredMethods - Array of method names that are required
31
+ * @returns True if all required methods are present, false otherwise
32
+ */
33
+ export declare function hasRequiredServerActions(serverActions: ServerActionsAdapter, requiredMethods: (keyof ServerActionsAdapter)[]): boolean;
34
+ //# sourceMappingURL=server-actions-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-actions-helpers.d.ts","sourceRoot":"","sources":["../src/adapters/server-actions-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAGnE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,oBAAoB,GAClC,OAAO,CAiFT;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,oBAAoB,EACnC,eAAe,EAAE,CAAC,MAAM,oBAAoB,CAAC,EAAE,GAC9C,OAAO,CAET"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Helper functions for Server Actions Adapter
3
+ *
4
+ * This module provides utilities to convert server actions into adapter format
5
+ * and handle server action responses.
6
+ */
7
+ /**
8
+ * Creates an Adapter from Server Actions Adapter.
9
+ * This function wraps server actions to match the Adapter interface.
10
+ *
11
+ * @param serverActions - The server actions adapter configuration
12
+ * @returns An Adapter instance that uses the provided server actions
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const adapter = createServerActionsAdapter({
17
+ * getUser: async (id) => {
18
+ * const user = await getProfileApiV1AuthMeGet()
19
+ * return transformToAdapterUser(user)
20
+ * },
21
+ * })
22
+ * ```
23
+ */
24
+ export function createServerActionsAdapter(serverActions) {
25
+ const adapter = {};
26
+ // Map all server action methods to adapter methods
27
+ if (serverActions.createUser) {
28
+ adapter.createUser = serverActions.createUser;
29
+ }
30
+ if (serverActions.getUser) {
31
+ adapter.getUser = serverActions.getUser;
32
+ }
33
+ if (serverActions.getUserByEmail) {
34
+ adapter.getUserByEmail = serverActions.getUserByEmail;
35
+ }
36
+ if (serverActions.getUserByAccount) {
37
+ adapter.getUserByAccount = serverActions.getUserByAccount;
38
+ }
39
+ if (serverActions.updateUser) {
40
+ adapter.updateUser = serverActions.updateUser;
41
+ }
42
+ if (serverActions.deleteUser) {
43
+ adapter.deleteUser = serverActions.deleteUser;
44
+ }
45
+ if (serverActions.linkAccount) {
46
+ adapter.linkAccount = serverActions.linkAccount;
47
+ }
48
+ if (serverActions.unlinkAccount) {
49
+ adapter.unlinkAccount = serverActions.unlinkAccount;
50
+ }
51
+ if (serverActions.createSession) {
52
+ adapter.createSession = serverActions.createSession;
53
+ }
54
+ if (serverActions.getSessionAndUser) {
55
+ adapter.getSessionAndUser = serverActions.getSessionAndUser;
56
+ }
57
+ if (serverActions.updateSession) {
58
+ adapter.updateSession = serverActions.updateSession;
59
+ }
60
+ if (serverActions.deleteSession) {
61
+ adapter.deleteSession = serverActions.deleteSession;
62
+ }
63
+ if (serverActions.createVerificationToken) {
64
+ adapter.createVerificationToken = serverActions.createVerificationToken;
65
+ }
66
+ if (serverActions.useVerificationToken) {
67
+ adapter.useVerificationToken = serverActions.useVerificationToken;
68
+ }
69
+ if (serverActions.getAccount) {
70
+ adapter.getAccount = serverActions.getAccount;
71
+ }
72
+ if (serverActions.getAuthenticator) {
73
+ adapter.getAuthenticator = serverActions.getAuthenticator;
74
+ }
75
+ if (serverActions.createAuthenticator) {
76
+ adapter.createAuthenticator = serverActions.createAuthenticator;
77
+ }
78
+ if (serverActions.listAuthenticatorsByUserId) {
79
+ adapter.listAuthenticatorsByUserId = serverActions.listAuthenticatorsByUserId;
80
+ }
81
+ if (serverActions.updateAuthenticatorCounter) {
82
+ adapter.updateAuthenticatorCounter = serverActions.updateAuthenticatorCounter;
83
+ }
84
+ return adapter;
85
+ }
86
+ /**
87
+ * Checks if a Server Actions Adapter has all required methods for a specific feature.
88
+ *
89
+ * @param serverActions - The server actions adapter to check
90
+ * @param requiredMethods - Array of method names that are required
91
+ * @returns True if all required methods are present, false otherwise
92
+ */
93
+ export function hasRequiredServerActions(serverActions, requiredMethods) {
94
+ return requiredMethods.every((method) => method in serverActions && serverActions[method] !== undefined);
95
+ }
package/package.json CHANGED
@@ -1,118 +1,119 @@
1
- {
2
- "name": "@mulverse/mulguard-core",
3
- "version": "1.0.0",
4
- "description": "Authentication for the Web with Backend-First Architecture.",
5
- "keywords": [
6
- "authentication",
7
- "mulguard",
8
- "backend-first",
9
- "frontend-first",
10
- "mulverse",
11
- "jwt",
12
- "oauth",
13
- "oidc",
14
- "passwordless",
15
- "standard",
16
- "vanilla",
17
- "webapi"
18
- ],
19
- "homepage": "https://mulverse.com/packages/mulguard-core",
20
- "repository": "https://github.com/mulverse/mulverse.git",
21
- "author": "Mohamed Alhabob <info@mulverse.com>",
22
- "contributors": [
23
- "Mohamed Alhabob <info@mulverse.com>"
24
- ],
25
- "type": "module",
26
- "types": "./index.d.ts",
27
- "files": [
28
- "*.js",
29
- "*.d.ts*",
30
- "lib",
31
- "providers",
32
- "src"
33
- ],
34
- "exports": {
35
- ".": {
36
- "types": "./index.d.ts",
37
- "import": "./index.js",
38
- "default": "./index.js"
39
- },
40
- "./adapters": {
41
- "types": "./adapters.d.ts",
42
- "import": "./adapters.js",
43
- "default": "./adapters.js"
44
- },
45
- "./errors": {
46
- "types": "./errors.d.ts",
47
- "import": "./errors.js",
48
- "default": "./errors.js"
49
- },
50
- "./jwt": {
51
- "types": "./jwt.d.ts",
52
- "import": "./jwt.js",
53
- "default": "./jwt.js"
54
- },
55
- "./providers": {
56
- "types": "./providers/index.d.ts"
57
- },
58
- "./providers/*": {
59
- "types": "./providers/*.d.ts",
60
- "import": "./providers/*.js",
61
- "default": "./providers/*.js"
62
- },
63
- "./types": {
64
- "types": "./types.d.ts"
65
- }
66
- },
67
- "license": "ISC",
68
- "publishConfig": {
69
- "access": "public",
70
- "registry": "https://registry.npmjs.org/"
71
- },
72
- "dependencies": {
73
- "@panva/hkdf": "^1.2.1",
74
- "jose": "^6.0.6",
75
- "oauth4webapi": "^3.3.0",
76
- "preact": "10.24.3",
77
- "preact-render-to-string": "6.5.11"
78
- },
79
- "peerDependencies": {
80
- "@simplewebauthn/browser": "^9.0.1",
81
- "@simplewebauthn/server": "^9.0.2",
82
- "nodemailer": "^7.0.7"
83
- },
84
- "peerDependenciesMeta": {
85
- "@simplewebauthn/browser": {
86
- "optional": true
87
- },
88
- "@simplewebauthn/server": {
89
- "optional": true
90
- },
91
- "nodemailer": {
92
- "optional": true
93
- }
94
- },
95
- "scripts": {
96
- "build": "pnpm css && pnpm providers && node ../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsc",
97
- "clean": "node -e \"const fs = require('fs'); ['*.js', '*.d.ts*', 'lib', 'providers'].forEach(p => { try { if (fs.existsSync(p)) fs.rmSync(p, {recursive: true, force: true}); } catch(e) {} });\"",
98
- "css": "node scripts/generate-css",
99
- "dev": "pnpm css && pnpm providers && tsc -w",
100
- "test": "vitest run -c ../utils/vitest.config.ts",
101
- "test:watch": "vitest -c ../utils/vitest.config.ts",
102
- "providers": "node scripts/generate-providers"
103
- },
104
- "devDependencies": {
105
- "@simplewebauthn/browser": "9.0.1",
106
- "@simplewebauthn/server": "9.0.3",
107
- "@simplewebauthn/types": "^9.0.1",
108
- "@types/node": "18.11.10",
109
- "@types/nodemailer": "6.4.6",
110
- "@types/react": "18.0.37",
111
- "autoprefixer": "10.4.13",
112
- "postcss": "8.4.19",
113
- "postcss-nesting": "^12.1.5",
114
- "typedoc": "^0.25.12",
115
- "typedoc-plugin-markdown": "4.0.0-next.53",
116
- "typescript": "5.3.3"
117
- }
118
- }
1
+ {
2
+ "name": "@mulverse/mulguard-core",
3
+ "version": "1.0.2",
4
+ "description": "Authentication for the Web with Backend-First Architecture.",
5
+ "keywords": [
6
+ "authentication",
7
+ "mulguard",
8
+ "backend-first",
9
+ "frontend-first",
10
+ "mulverse",
11
+ "jwt",
12
+ "oauth",
13
+ "oidc",
14
+ "passwordless",
15
+ "standard",
16
+ "vanilla",
17
+ "webapi"
18
+ ],
19
+ "homepage": "https://mulverse.com/packages/mulguard-core",
20
+ "repository": "https://github.com/mulverse/mulverse.git",
21
+ "author": "Mohamed Alhabob <info@mulverse.com>",
22
+ "contributors": [
23
+ "Mohamed Alhabob <info@mulverse.com>"
24
+ ],
25
+ "type": "module",
26
+ "types": "./index.d.ts",
27
+ "files": [
28
+ "*.js",
29
+ "*.d.ts*",
30
+ "adapters",
31
+ "lib",
32
+ "providers",
33
+ "src"
34
+ ],
35
+ "exports": {
36
+ ".": {
37
+ "types": "./index.d.ts",
38
+ "import": "./index.js",
39
+ "default": "./index.js"
40
+ },
41
+ "./adapters": {
42
+ "types": "./adapters.d.ts",
43
+ "import": "./adapters.js",
44
+ "default": "./adapters.js"
45
+ },
46
+ "./errors": {
47
+ "types": "./errors.d.ts",
48
+ "import": "./errors.js",
49
+ "default": "./errors.js"
50
+ },
51
+ "./jwt": {
52
+ "types": "./jwt.d.ts",
53
+ "import": "./jwt.js",
54
+ "default": "./jwt.js"
55
+ },
56
+ "./providers": {
57
+ "types": "./providers/index.d.ts"
58
+ },
59
+ "./providers/*": {
60
+ "types": "./providers/*.d.ts",
61
+ "import": "./providers/*.js",
62
+ "default": "./providers/*.js"
63
+ },
64
+ "./types": {
65
+ "types": "./types.d.ts"
66
+ }
67
+ },
68
+ "license": "ISC",
69
+ "publishConfig": {
70
+ "access": "public",
71
+ "registry": "https://registry.npmjs.org/"
72
+ },
73
+ "dependencies": {
74
+ "@panva/hkdf": "^1.2.1",
75
+ "jose": "^6.0.6",
76
+ "oauth4webapi": "^3.3.0",
77
+ "preact": "10.24.3",
78
+ "preact-render-to-string": "6.5.11"
79
+ },
80
+ "peerDependencies": {
81
+ "@simplewebauthn/browser": "^9.0.1",
82
+ "@simplewebauthn/server": "^9.0.2",
83
+ "nodemailer": "^7.0.7"
84
+ },
85
+ "peerDependenciesMeta": {
86
+ "@simplewebauthn/browser": {
87
+ "optional": true
88
+ },
89
+ "@simplewebauthn/server": {
90
+ "optional": true
91
+ },
92
+ "nodemailer": {
93
+ "optional": true
94
+ }
95
+ },
96
+ "devDependencies": {
97
+ "@simplewebauthn/browser": "9.0.1",
98
+ "@simplewebauthn/server": "9.0.3",
99
+ "@simplewebauthn/types": "^9.0.1",
100
+ "@types/node": "18.11.10",
101
+ "@types/nodemailer": "6.4.6",
102
+ "@types/react": "18.0.37",
103
+ "autoprefixer": "10.4.13",
104
+ "postcss": "8.4.19",
105
+ "postcss-nesting": "^12.1.5",
106
+ "typedoc": "^0.25.12",
107
+ "typedoc-plugin-markdown": "4.0.0-next.53",
108
+ "typescript": "5.3.3"
109
+ },
110
+ "scripts": {
111
+ "build": "pnpm css && pnpm providers && node ../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/bin/tsc",
112
+ "clean": "node -e \"const fs = require('fs'); ['*.js', '*.d.ts*', 'lib', 'providers'].forEach(p => { try { if (fs.existsSync(p)) fs.rmSync(p, {recursive: true, force: true}); } catch(e) {} });\"",
113
+ "css": "node scripts/generate-css",
114
+ "dev": "pnpm css && pnpm providers && tsc -w",
115
+ "test": "vitest run -c ../utils/vitest.config.ts",
116
+ "test:watch": "vitest -c ../utils/vitest.config.ts",
117
+ "providers": "node scripts/generate-providers"
118
+ }
119
+ }