@frigear-nu/oauth-server 0.0.0-stage → 0.0.3

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.
Files changed (73) hide show
  1. package/README.md +49 -2
  2. package/dist/module.d.mts +206 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +107 -0
  5. package/dist/runtime/app/composables/index.d.ts +1 -0
  6. package/dist/runtime/app/composables/index.js +1 -0
  7. package/dist/runtime/app/composables/useOAuthApplications.d.ts +19 -0
  8. package/dist/runtime/app/composables/useOAuthApplications.js +41 -0
  9. package/dist/runtime/app/pages/admin.d.vue.ts +3 -0
  10. package/dist/runtime/app/pages/admin.vue +384 -0
  11. package/dist/runtime/app/pages/admin.vue.d.ts +3 -0
  12. package/dist/runtime/app/pages/applications.d.vue.ts +3 -0
  13. package/dist/runtime/app/pages/applications.vue +50 -0
  14. package/dist/runtime/app/pages/applications.vue.d.ts +3 -0
  15. package/dist/runtime/app/pages/authorize.d.vue.ts +3 -0
  16. package/dist/runtime/app/pages/authorize.vue +108 -0
  17. package/dist/runtime/app/pages/authorize.vue.d.ts +3 -0
  18. package/dist/runtime/menus.d.ts +2 -0
  19. package/dist/runtime/menus.js +27 -0
  20. package/dist/runtime/server/db/schema.sqlite.d.ts +682 -0
  21. package/dist/runtime/server/db/schema.sqlite.js +60 -0
  22. package/dist/runtime/server/routes/api/admin/application-revoke.post.d.ts +2 -0
  23. package/dist/runtime/server/routes/api/admin/application-revoke.post.js +7 -0
  24. package/dist/runtime/server/routes/api/admin/application-secret.post.d.ts +2 -0
  25. package/dist/runtime/server/routes/api/admin/application-secret.post.js +5 -0
  26. package/dist/runtime/server/routes/api/admin/application.delete.d.ts +2 -0
  27. package/dist/runtime/server/routes/api/admin/application.delete.js +6 -0
  28. package/dist/runtime/server/routes/api/admin/application.get.d.ts +2 -0
  29. package/dist/runtime/server/routes/api/admin/application.get.js +6 -0
  30. package/dist/runtime/server/routes/api/admin/application.patch.d.ts +2 -0
  31. package/dist/runtime/server/routes/api/admin/application.patch.js +9 -0
  32. package/dist/runtime/server/routes/api/admin/applications.get.d.ts +2 -0
  33. package/dist/runtime/server/routes/api/admin/applications.get.js +11 -0
  34. package/dist/runtime/server/routes/api/admin/applications.post.d.ts +2 -0
  35. package/dist/runtime/server/routes/api/admin/applications.post.js +8 -0
  36. package/dist/runtime/server/routes/api/consent.get.d.ts +2 -0
  37. package/dist/runtime/server/routes/api/consent.get.js +19 -0
  38. package/dist/runtime/server/routes/api/me-applications.get.d.ts +2 -0
  39. package/dist/runtime/server/routes/api/me-applications.get.js +4 -0
  40. package/dist/runtime/server/routes/oidc/authorize.get.d.ts +2 -0
  41. package/dist/runtime/server/routes/oidc/authorize.get.js +15 -0
  42. package/dist/runtime/server/routes/oidc/authorize.post.d.ts +2 -0
  43. package/dist/runtime/server/routes/oidc/authorize.post.js +27 -0
  44. package/dist/runtime/server/routes/oidc/jwks.get.d.ts +2 -0
  45. package/dist/runtime/server/routes/oidc/jwks.get.js +4 -0
  46. package/dist/runtime/server/routes/oidc/openid-configuration.get.d.ts +2 -0
  47. package/dist/runtime/server/routes/oidc/openid-configuration.get.js +21 -0
  48. package/dist/runtime/server/routes/oidc/revoke.post.d.ts +2 -0
  49. package/dist/runtime/server/routes/oidc/revoke.post.js +13 -0
  50. package/dist/runtime/server/routes/oidc/token.post.d.ts +2 -0
  51. package/dist/runtime/server/routes/oidc/token.post.js +56 -0
  52. package/dist/runtime/server/routes/oidc/userinfo.get.d.ts +2 -0
  53. package/dist/runtime/server/routes/oidc/userinfo.get.js +18 -0
  54. package/dist/runtime/server/utils/oauth-access.d.ts +34 -0
  55. package/dist/runtime/server/utils/oauth-access.js +49 -0
  56. package/dist/runtime/server/utils/oauth-applications.d.ts +65 -0
  57. package/dist/runtime/server/utils/oauth-applications.js +126 -0
  58. package/dist/runtime/server/utils/oauth-authorize.d.ts +29 -0
  59. package/dist/runtime/server/utils/oauth-authorize.js +33 -0
  60. package/dist/runtime/server/utils/oauth-config.d.ts +16 -0
  61. package/dist/runtime/server/utils/oauth-config.js +20 -0
  62. package/dist/runtime/server/utils/oauth-crypto.d.ts +18 -0
  63. package/dist/runtime/server/utils/oauth-crypto.js +48 -0
  64. package/dist/runtime/server/utils/oauth-grants.d.ts +60 -0
  65. package/dist/runtime/server/utils/oauth-grants.js +70 -0
  66. package/dist/runtime/server/utils/oauth-keys.d.ts +41 -0
  67. package/dist/runtime/server/utils/oauth-keys.js +55 -0
  68. package/dist/runtime/server/utils/oauth-tokens.d.ts +25 -0
  69. package/dist/runtime/server/utils/oauth-tokens.js +34 -0
  70. package/dist/runtime/utils/index.d.ts +24 -0
  71. package/dist/runtime/utils/index.js +51 -0
  72. package/dist/types.d.mts +3 -0
  73. package/package.json +92 -3
@@ -0,0 +1,51 @@
1
+ export const DEFAULT_SCOPES = ["openid", "profile", "email"];
2
+ export const DEFAULT_CALLBACK_PATH = "/auth/frigear";
3
+ export function matchesAllowedRoles(allowedRoles, roles) {
4
+ if (!allowedRoles || allowedRoles.length === 0) return true;
5
+ return allowedRoles.some((role) => roles.includes(role));
6
+ }
7
+ export function parseScope(scope) {
8
+ return [...new Set((scope ?? "").split(/\s+/).filter(Boolean))];
9
+ }
10
+ export function resolveScope(requested, supported) {
11
+ const asked = parseScope(requested);
12
+ if (asked.length === 0) return [...DEFAULT_SCOPES];
13
+ return asked.filter((scope) => supported.includes(scope));
14
+ }
15
+ export function isSecureOrigin(url) {
16
+ if (url.protocol === "https:") return true;
17
+ return url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
18
+ }
19
+ export function normalizeWebsiteUrl(value) {
20
+ let url;
21
+ try {
22
+ url = new URL(value);
23
+ } catch {
24
+ throw new Error("The website URL is not a valid URL.");
25
+ }
26
+ if (!isSecureOrigin(url)) throw new Error("The website URL must use https (http is only allowed for localhost).");
27
+ if (url.pathname !== "/" || url.search || url.hash) throw new Error("The website URL must be an origin without a path.");
28
+ return url.origin;
29
+ }
30
+ export function previewPatternToRegExp(pattern, callbackPath) {
31
+ const escaped = pattern.replace(/\/+$/, "").split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join("[^/.]+");
32
+ const callback = callbackPath.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
33
+ return new RegExp(`^${escaped}${callback}$`);
34
+ }
35
+ export function validateRedirectUri(redirectUri, rules) {
36
+ const callbackPath = rules.callbackPath ?? DEFAULT_CALLBACK_PATH;
37
+ let url;
38
+ try {
39
+ url = new URL(redirectUri);
40
+ } catch {
41
+ return false;
42
+ }
43
+ if (url.hash || !isSecureOrigin(url)) return false;
44
+ if (redirectUri === `${rules.websiteUrl.replace(/\/+$/, "")}${callbackPath}`) return true;
45
+ if (rules.redirectUris?.includes(redirectUri)) return true;
46
+ if (rules.previewUrlPattern) return previewPatternToRegExp(rules.previewUrlPattern, callbackPath).test(redirectUri);
47
+ return false;
48
+ }
49
+ export function newId(prefix) {
50
+ return `${prefix}_${crypto.randomUUID().replaceAll("-", "")}`;
51
+ }
@@ -0,0 +1,3 @@
1
+ export { default } from './module.mjs'
2
+
3
+ export { type AdminApplicationDto, type ApplicationAccessContext, type ApplicationInput, type AuthorizeContext, type ClaimsContext, type ConsentDto, type CreatedApplicationDto, type ModuleOptions, type OAuthApplication, type OAuthServerRuntimeConfig, type OAuthUser, type PublicModuleOptions, type TokenIssuedContext, type TokenRevokedContext, type TokenType, type UserApplicationDto, type UserRolesContext } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,95 @@
1
1
  {
2
2
  "name": "@frigear-nu/oauth-server",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.3",
4
+ "description": "OAuth 2.0 / OpenID Connect server for the frigear ecosystem: register applications that users with certain roles may sign in to.",
5
+ "url": "https://docs.frigear.nu/modules/oauth-server",
6
+ "author": {
7
+ "name": "Frigear",
8
+ "email": "kontakt@frigear.nu",
9
+ "url": "https://frigear.nu"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/frigear-nu/frigear-nu.git",
14
+ "directory": "packages/oauth-server"
15
+ },
16
+ "license": "MIT",
17
+ "type": "module",
18
+ "private": false,
19
+ "main": "./dist/module.mjs",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/types.d.mts",
23
+ "import": "./dist/module.mjs",
24
+ "default": "./dist/module.mjs"
25
+ },
26
+ "./utils": {
27
+ "types": "./dist/runtime/utils/index.d.ts",
28
+ "import": "./dist/runtime/utils/index.js",
29
+ "default": "./dist/runtime/utils/index.js"
30
+ }
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "workspaces": [
36
+ "playground"
37
+ ],
38
+ "dependencies": {
39
+ "@frigear-nu/menu": "0.0.4",
40
+ "@frigear-nu/module-kit": "0.1.2",
41
+ "@frigear-nu/users": "1.0.4",
42
+ "@libsql/client": "^0.18.0",
43
+ "@nuxt/kit": "^4.6.0",
44
+ "drizzle-kit": "^0.31.11",
45
+ "drizzle-orm": "^0.45.3",
46
+ "h3": "^1.15.11",
47
+ "jose": "^6.1.0",
48
+ "zod": "^4.6.5"
49
+ },
50
+ "peerDependencies": {
51
+ "@nuxt/ui": "^4.10.0",
52
+ "@nuxthub/core": "^0.10.8"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "@nuxt/ui": {
56
+ "optional": true
57
+ }
58
+ },
59
+ "devDependencies": {
60
+ "@nuxt/devtools": "^3.4.2",
61
+ "@nuxt/eslint-config": "^1.17.0",
62
+ "@nuxt/module-builder": "^1.0.3",
63
+ "@nuxt/schema": "^4.6.0",
64
+ "@nuxt/test-utils": "^4.3.2",
65
+ "@nuxt/ui": "^4.11.0",
66
+ "@nuxthub/core": "^0.10.8",
67
+ "@types/node": "latest",
68
+ "changelogen": "^0.6.2",
69
+ "eslint": "^10.10.0",
70
+ "nuxt": "^4.6.0",
71
+ "typescript": "^6.0.3",
72
+ "vitest": "^5.0.1",
73
+ "vue-tsc": "^3.3.11"
74
+ },
75
+ "scripts": {
76
+ "postinstall": "nuxt-module-build build --stub && nuxt prepare",
77
+ "build": "nuxt-module-build build",
78
+ "dev": "npm run dev:prepare && nuxt dev playground",
79
+ "dev:build": "nuxt build playground",
80
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
81
+ "release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
82
+ "lint": "eslint .",
83
+ "lint:fix": "eslint . --fix",
84
+ "test": "vitest run",
85
+ "test:watch": "vitest watch",
86
+ "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
87
+ },
88
+ "typesVersions": {
89
+ "*": {
90
+ ".": [
91
+ "./dist/types.d.mts"
92
+ ]
93
+ }
94
+ }
6
95
  }