@libreapps/auth 3.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.
Files changed (127) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/CHANGELOG.md +20 -0
  3. package/LICENSE.md +21 -0
  4. package/README.md +61 -0
  5. package/components/auth-widget.tsx +110 -0
  6. package/components/email-password-form.tsx +96 -0
  7. package/components/index.ts +4 -0
  8. package/components/login-panel.tsx +207 -0
  9. package/components/signup-panel.tsx +213 -0
  10. package/dist/components/auth-widget.d.ts +13 -0
  11. package/dist/components/auth-widget.js +33 -0
  12. package/dist/components/auth-widget.js.map +1 -0
  13. package/dist/components/email-password-form.d.ts +8 -0
  14. package/dist/components/email-password-form.js +25 -0
  15. package/dist/components/email-password-form.js.map +1 -0
  16. package/dist/components/index.d.ts +4 -0
  17. package/dist/components/index.js +5 -0
  18. package/dist/components/index.js.map +1 -0
  19. package/dist/components/login-panel.d.ts +13 -0
  20. package/dist/components/login-panel.js +104 -0
  21. package/dist/components/login-panel.js.map +1 -0
  22. package/dist/components/signup-panel.d.ts +13 -0
  23. package/dist/components/signup-panel.js +104 -0
  24. package/dist/components/signup-panel.js.map +1 -0
  25. package/dist/icons/ethereum.d.ts +4 -0
  26. package/dist/icons/ethereum.js +6 -0
  27. package/dist/icons/ethereum.js.map +1 -0
  28. package/dist/icons/facebook.d.ts +4 -0
  29. package/dist/icons/facebook.js +6 -0
  30. package/dist/icons/facebook.js.map +1 -0
  31. package/dist/icons/github.d.ts +4 -0
  32. package/dist/icons/github.js +6 -0
  33. package/dist/icons/github.js.map +1 -0
  34. package/dist/icons/google.d.ts +4 -0
  35. package/dist/icons/google.js +6 -0
  36. package/dist/icons/google.js.map +1 -0
  37. package/dist/icons/index.d.ts +6 -0
  38. package/dist/icons/index.js +7 -0
  39. package/dist/icons/index.js.map +1 -0
  40. package/dist/index.d.ts +24 -0
  41. package/dist/index.js +24 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/server/firebase-support.d.ts +8 -0
  44. package/dist/server/firebase-support.js +151 -0
  45. package/dist/server/firebase-support.js.map +1 -0
  46. package/dist/server/index.d.ts +4 -0
  47. package/dist/server/index.js +7 -0
  48. package/dist/server/index.js.map +1 -0
  49. package/dist/server/rest-api-handlers.d.ts +4 -0
  50. package/dist/server/rest-api-handlers.js +23 -0
  51. package/dist/server/rest-api-handlers.js.map +1 -0
  52. package/dist/server/stub-server.d.ts +14 -0
  53. package/dist/server/stub-server.js +23 -0
  54. package/dist/server/stub-server.js.map +1 -0
  55. package/dist/service/auth-service.d.ts +29 -0
  56. package/dist/service/auth-service.js +2 -0
  57. package/dist/service/auth-service.js.map +1 -0
  58. package/dist/service/context.d.ts +9 -0
  59. package/dist/service/context.js +16 -0
  60. package/dist/service/context.js.map +1 -0
  61. package/dist/service/get-singleton.d.ts +4 -0
  62. package/dist/service/get-singleton.js +24 -0
  63. package/dist/service/get-singleton.js.map +1 -0
  64. package/dist/service/impl/firebase-support.d.ts +34 -0
  65. package/dist/service/impl/firebase-support.js +190 -0
  66. package/dist/service/impl/firebase-support.js.map +1 -0
  67. package/dist/service/impl/index.d.ts +32 -0
  68. package/dist/service/impl/index.js +179 -0
  69. package/dist/service/impl/index.js.map +1 -0
  70. package/dist/service/impl/stub-auth-service.d.ts +42 -0
  71. package/dist/service/impl/stub-auth-service.js +97 -0
  72. package/dist/service/impl/stub-auth-service.js.map +1 -0
  73. package/dist/service/impl/wallet-support.d.ts +8 -0
  74. package/dist/service/impl/wallet-support.js +82 -0
  75. package/dist/service/impl/wallet-support.js.map +1 -0
  76. package/dist/service/index.d.ts +4 -0
  77. package/dist/service/index.js +4 -0
  78. package/dist/service/index.js.map +1 -0
  79. package/dist/service/provider-registry.d.ts +37 -0
  80. package/dist/service/provider-registry.js +58 -0
  81. package/dist/service/provider-registry.js.map +1 -0
  82. package/dist/types/api-response.d.ts +8 -0
  83. package/dist/types/api-response.js +2 -0
  84. package/dist/types/api-response.js.map +1 -0
  85. package/dist/types/auth-service-conf.d.ts +5 -0
  86. package/dist/types/auth-service-conf.js +2 -0
  87. package/dist/types/auth-service-conf.js.map +1 -0
  88. package/dist/types/index.d.ts +4 -0
  89. package/dist/types/index.js +2 -0
  90. package/dist/types/index.js.map +1 -0
  91. package/dist/types/libreapps-user-info-value.d.ts +6 -0
  92. package/dist/types/libreapps-user-info-value.js +2 -0
  93. package/dist/types/libreapps-user-info-value.js.map +1 -0
  94. package/dist/types/libreapps-user-info.d.ts +6 -0
  95. package/dist/types/libreapps-user-info.js +2 -0
  96. package/dist/types/libreapps-user-info.js.map +1 -0
  97. package/dist/util/analytics.d.ts +9 -0
  98. package/dist/util/analytics.js +10 -0
  99. package/dist/util/analytics.js.map +1 -0
  100. package/icons/ethereum.tsx +18 -0
  101. package/icons/facebook.tsx +11 -0
  102. package/icons/github.tsx +14 -0
  103. package/icons/google.tsx +13 -0
  104. package/icons/index.ts +16 -0
  105. package/index.ts +51 -0
  106. package/libreapps-ui.d.ts +23 -0
  107. package/package.json +57 -0
  108. package/server/firebase-support.ts +176 -0
  109. package/server/index.ts +14 -0
  110. package/server/rest-api-handlers.ts +33 -0
  111. package/server/stub-server.ts +28 -0
  112. package/service/auth-service.ts +21 -0
  113. package/service/context.tsx +46 -0
  114. package/service/get-singleton.ts +37 -0
  115. package/service/impl/firebase-support.ts +241 -0
  116. package/service/impl/index.ts +231 -0
  117. package/service/impl/stub-auth-service.ts +131 -0
  118. package/service/impl/wallet-support.ts +100 -0
  119. package/service/index.ts +11 -0
  120. package/service/provider-registry.ts +71 -0
  121. package/tsconfig.json +15 -0
  122. package/types/api-response.ts +5 -0
  123. package/types/auth-service-conf.ts +9 -0
  124. package/types/index.ts +6 -0
  125. package/types/libreapps-user-info-value.ts +9 -0
  126. package/types/libreapps-user-info.ts +9 -0
  127. package/util/analytics.ts +21 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-support.js","sourceRoot":"","sources":["../../../service/impl/wallet-support.ts"],"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AAA;YAChB,KAAK,GAAG,CAAC,CAAA;QACX,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,KAAK,GAAG,CAAC,CAAA;IACX,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AAC1B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,SAAiB;IAChE,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,OAAO,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,mCAAmC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;IACrF,CAAC;IAED,IAAI,MAAM,GAAG,SAAS,CAAA;IACtB,IAAI,KAAK,GAAG,IAAI,CAAA;IAChB,IAAI,CAAC;QACH,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAA;YACrE,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAG,CAAC,aAAuB,CAAC,CAAC,CAAC,SAAS,CAAA;QAC7E,CAAC;QACD,OAAO,CAAC,EAAE,CAAC;YACT,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YAChB,KAAK,GAAG,CAAC,CAAA;QACX,CAAC;IACH,CAAC;IACD,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,KAAK,GAAG,CAAC,CAAA;IACX,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AAC1B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export type { default as AuthService, AuthProvider } from './auth-service';
2
+ export { useAuth, AuthServiceProvider } from './context';
3
+ export { registerAuthProvider, setActiveProvider, getActiveProvider, hasAuthProvider, getRegisteredProviders, type AuthServiceFactory } from './provider-registry';
4
+ export { StubAuthService } from './impl/stub-auth-service';
@@ -0,0 +1,4 @@
1
+ export { useAuth, AuthServiceProvider } from './context';
2
+ export { registerAuthProvider, setActiveProvider, getActiveProvider, hasAuthProvider, getRegisteredProviders } from './provider-registry';
3
+ export { StubAuthService } from './impl/stub-auth-service';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../service/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EAEvB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Auth Provider Registry
3
+ *
4
+ * Allows registration of pluggable auth providers.
5
+ * Firebase support is available via @libreapps/auth-firebase (optional).
6
+ */
7
+ import type AuthService from './auth-service';
8
+ import type { AuthServiceConf, LibreAppsUserInfoValue } from '../types';
9
+ export type AuthServiceFactory = new (conf: AuthServiceConf, user: LibreAppsUserInfoValue | null) => AuthService;
10
+ /**
11
+ * Register an auth provider
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { FirebaseAuthService } from '@libreapps/auth-firebase'
16
+ * import { registerAuthProvider } from '@libreapps/auth'
17
+ *
18
+ * registerAuthProvider('firebase', FirebaseAuthService)
19
+ * ```
20
+ */
21
+ export declare function registerAuthProvider(name: string, factory: AuthServiceFactory): void;
22
+ /**
23
+ * Set the active auth provider by name
24
+ */
25
+ export declare function setActiveProvider(name: string): void;
26
+ /**
27
+ * Get the active auth provider factory
28
+ */
29
+ export declare function getActiveProvider(): AuthServiceFactory | null;
30
+ /**
31
+ * Check if any auth provider is registered
32
+ */
33
+ export declare function hasAuthProvider(): boolean;
34
+ /**
35
+ * Get list of registered provider names
36
+ */
37
+ export declare function getRegisteredProviders(): string[];
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Auth Provider Registry
3
+ *
4
+ * Allows registration of pluggable auth providers.
5
+ * Firebase support is available via @libreapps/auth-firebase (optional).
6
+ */
7
+ // Registry of available auth providers
8
+ const providers = new Map();
9
+ // Current active provider
10
+ let activeProvider = null;
11
+ /**
12
+ * Register an auth provider
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { FirebaseAuthService } from '@libreapps/auth-firebase'
17
+ * import { registerAuthProvider } from '@libreapps/auth'
18
+ *
19
+ * registerAuthProvider('firebase', FirebaseAuthService)
20
+ * ```
21
+ */
22
+ export function registerAuthProvider(name, factory) {
23
+ providers.set(name, factory);
24
+ // Auto-activate if this is the first provider
25
+ if (!activeProvider) {
26
+ activeProvider = name;
27
+ }
28
+ }
29
+ /**
30
+ * Set the active auth provider by name
31
+ */
32
+ export function setActiveProvider(name) {
33
+ if (!providers.has(name)) {
34
+ throw new Error(`Auth provider '${name}' is not registered`);
35
+ }
36
+ activeProvider = name;
37
+ }
38
+ /**
39
+ * Get the active auth provider factory
40
+ */
41
+ export function getActiveProvider() {
42
+ if (!activeProvider)
43
+ return null;
44
+ return providers.get(activeProvider) ?? null;
45
+ }
46
+ /**
47
+ * Check if any auth provider is registered
48
+ */
49
+ export function hasAuthProvider() {
50
+ return providers.size > 0;
51
+ }
52
+ /**
53
+ * Get list of registered provider names
54
+ */
55
+ export function getRegisteredProviders() {
56
+ return Array.from(providers.keys());
57
+ }
58
+ //# sourceMappingURL=provider-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-registry.js","sourceRoot":"","sources":["../../service/provider-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,uCAAuC;AACvC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA8B,CAAA;AAEvD,0BAA0B;AAC1B,IAAI,cAAc,GAAkB,IAAI,CAAA;AAExC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,OAA2B;IAC5E,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC5B,8CAA8C;IAC9C,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,CAAA;IACvB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,qBAAqB,CAAC,CAAA;IAC9D,CAAC;IACD,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,IAAI,CAAC,cAAc;QAAE,OAAO,IAAI,CAAA;IAChC,OAAO,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,IAAI,CAAA;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,SAAS,CAAC,IAAI,GAAG,CAAC,CAAA;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAA;AACrC,CAAC"}
@@ -0,0 +1,8 @@
1
+ type APIResponse<T = object> = {
2
+ success: true;
3
+ data: T;
4
+ } | {
5
+ success: false;
6
+ error: string;
7
+ };
8
+ export { type APIResponse as default };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=api-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-response.js","sourceRoot":"","sources":["../../types/api-response.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,CAAA"}
@@ -0,0 +1,5 @@
1
+ interface AuthServiceConf {
2
+ firestoreDB: string;
3
+ userInfoCollection: string;
4
+ }
5
+ export { type AuthServiceConf as default };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=auth-service-conf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-service-conf.js","sourceRoot":"","sources":["../../types/auth-service-conf.ts"],"names":[],"mappings":"AAMA,OAAO,EAEN,CAAA"}
@@ -0,0 +1,4 @@
1
+ export type { default as LibreAppsUserInfo } from './libreapps-user-info';
2
+ export type { default as APIResponse } from './api-response';
3
+ export type { default as AuthServiceConf } from './auth-service-conf';
4
+ export type { default as LibreAppsUserInfoValue } from './libreapps-user-info-value';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ type LibreAppsUserInfoValue = {
2
+ email: string;
3
+ displayName: string | null;
4
+ walletAddress: string | null;
5
+ };
6
+ export { type LibreAppsUserInfoValue as default };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=libreapps-user-info-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"libreapps-user-info-value.js","sourceRoot":"","sources":["../../types/libreapps-user-info-value.ts"],"names":[],"mappings":"AAMA,OAAO,EAEN,CAAA"}
@@ -0,0 +1,6 @@
1
+ interface LibreAppsUserInfo {
2
+ get email(): string;
3
+ get displayName(): string | null;
4
+ get walletAddress(): string | null;
5
+ }
6
+ export { type LibreAppsUserInfo as default };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=libreapps-user-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"libreapps-user-info.js","sourceRoot":"","sources":["../../types/libreapps-user-info.ts"],"names":[],"mappings":"AAMA,OAAO,EAEN,CAAA"}
@@ -0,0 +1,9 @@
1
+ declare global {
2
+ interface Window {
3
+ fbq: Function;
4
+ gtag: Function;
5
+ }
6
+ }
7
+ declare const sendFBEvent: (name: string, options?: {}) => void;
8
+ declare const sendGAEvent: (name: string, options?: {}) => void;
9
+ export { sendFBEvent, sendGAEvent, };
@@ -0,0 +1,10 @@
1
+ // https://developers.facebook.com/docs/meta-pixel/reference
2
+ const sendFBEvent = (name, options = {}) => {
3
+ window.fbq('track', name, options);
4
+ };
5
+ // https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtag
6
+ const sendGAEvent = (name, options = {}) => {
7
+ window.gtag('event', name, options);
8
+ };
9
+ export { sendFBEvent, sendGAEvent, };
10
+ //# sourceMappingURL=analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../util/analytics.ts"],"names":[],"mappings":"AAOA,4DAA4D;AAC5D,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE;IACjD,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC,CAAA;AAED,8FAA8F;AAC9F,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE;IACjD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AACrC,CAAC,CAAA;AAED,OAAO,EACL,WAAW,EACX,WAAW,GACZ,CAAA"}
@@ -0,0 +1,18 @@
1
+ import React from 'react'
2
+ import { type LucideProps } from 'lucide-react'
3
+
4
+
5
+ const Ethereum: React.FC<LucideProps> = (props: LucideProps) => (
6
+ <svg viewBox="-80.5 0 417 417" preserveAspectRatio="xMidYMid" {...props}>
7
+ <g>
8
+ <polygon fill="#343434" points="127.9611 0 125.1661 9.5 125.1661 285.168 127.9611 287.958 255.9231 212.32"></polygon>
9
+ <polygon fill="#8C8C8C" points="127.962 0 0 212.32 127.962 287.959 127.962 154.158"></polygon>
10
+ <polygon fill="#3C3C3B" points="127.9611 312.1866 126.3861 314.1066 126.3861 412.3056 127.9611 416.9066 255.9991 236.5866"></polygon>
11
+ <polygon fill="#8C8C8C" points="127.962 416.9052 127.962 312.1852 0 236.5852"></polygon>
12
+ <polygon fill="#141414" points="127.9611 287.9577 255.9211 212.3207 127.9611 154.1587"></polygon>
13
+ <polygon fill="#393939" points="0.0009 212.3208 127.9609 287.9578 127.9609 154.1588"></polygon>
14
+ </g>
15
+ </svg>
16
+ )
17
+
18
+ export default Ethereum
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import { type LucideProps } from 'lucide-react'
3
+
4
+ const Facebook: React.FC<LucideProps> = (props: LucideProps) => (
5
+ <svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="none" {...props}>
6
+ <path fill="#1877F2" d="M15 8a7 7 0 00-7-7 7 7 0 00-1.094 13.915v-4.892H5.13V8h1.777V6.458c0-1.754 1.045-2.724 2.644-2.724.766 0 1.567.137 1.567.137v1.723h-.883c-.87 0-1.14.54-1.14 1.093V8h1.941l-.31 2.023H9.094v4.892A7.001 7.001 0 0015 8z"/>
7
+ <path fill="#ffffff" d="M10.725 10.023L11.035 8H9.094V6.687c0-.553.27-1.093 1.14-1.093h.883V3.87s-.801-.137-1.567-.137c-1.6 0-2.644.97-2.644 2.724V8H5.13v2.023h1.777v4.892a7.037 7.037 0 002.188 0v-4.892h1.63z"/>
8
+ </svg>
9
+ )
10
+
11
+ export default Facebook
@@ -0,0 +1,14 @@
1
+ import React from 'react'
2
+ import { type LucideProps } from 'lucide-react'
3
+
4
+
5
+ const GitHub: React.FC<LucideProps> = (props: LucideProps) => (
6
+ <svg viewBox="0 0 438.549 438.549" {...props}>
7
+ <path
8
+ fill="currentColor"
9
+ d="M409.132 114.573c-19.608-33.596-46.205-60.194-79.798-79.8-33.598-19.607-70.277-29.408-110.063-29.408-39.781 0-76.472 9.804-110.063 29.408-33.596 19.605-60.192 46.204-79.8 79.8C9.803 148.168 0 184.854 0 224.63c0 47.78 13.94 90.745 41.827 128.906 27.884 38.164 63.906 64.572 108.063 79.227 5.14.954 8.945.283 11.419-1.996 2.475-2.282 3.711-5.14 3.711-8.562 0-.571-.049-5.708-.144-15.417a2549.81 2549.81 0 01-.144-25.406l-6.567 1.136c-4.187.767-9.469 1.092-15.846 1-6.374-.089-12.991-.757-19.842-1.999-6.854-1.231-13.229-4.086-19.13-8.559-5.898-4.473-10.085-10.328-12.56-17.556l-2.855-6.57c-1.903-4.374-4.899-9.233-8.992-14.559-4.093-5.331-8.232-8.945-12.419-10.848l-1.999-1.431c-1.332-.951-2.568-2.098-3.711-3.429-1.142-1.331-1.997-2.663-2.568-3.997-.572-1.335-.098-2.43 1.427-3.289 1.525-.859 4.281-1.276 8.28-1.276l5.708.853c3.807.763 8.516 3.042 14.133 6.851 5.614 3.806 10.229 8.754 13.846 14.842 4.38 7.806 9.657 13.754 15.846 17.847 6.184 4.093 12.419 6.136 18.699 6.136 6.28 0 11.704-.476 16.274-1.423 4.565-.952 8.848-2.383 12.847-4.285 1.713-12.758 6.377-22.559 13.988-29.41-10.848-1.14-20.601-2.857-29.264-5.14-8.658-2.286-17.605-5.996-26.835-11.14-9.235-5.137-16.896-11.516-22.985-19.126-6.09-7.614-11.088-17.61-14.987-29.979-3.901-12.374-5.852-26.648-5.852-42.826 0-23.035 7.52-42.637 22.557-58.817-7.044-17.318-6.379-36.732 1.997-58.24 5.52-1.715 13.706-.428 24.554 3.853 10.85 4.283 18.794 7.952 23.84 10.994 5.046 3.041 9.089 5.618 12.135 7.708 17.705-4.947 35.976-7.421 54.818-7.421s37.117 2.474 54.823 7.421l10.849-6.849c7.419-4.57 16.18-8.758 26.262-12.565 10.088-3.805 17.802-4.853 23.134-3.138 8.562 21.509 9.325 40.922 2.279 58.24 15.036 16.18 22.559 35.787 22.559 58.817 0 16.178-1.958 30.497-5.853 42.966-3.9 12.471-8.941 22.457-15.125 29.979-6.191 7.521-13.901 13.85-23.131 18.986-9.232 5.14-18.182 8.85-26.84 11.136-8.662 2.286-18.415 4.004-29.263 5.146 9.894 8.562 14.842 22.077 14.842 40.539v60.237c0 3.422 1.19 6.279 3.572 8.562 2.379 2.279 6.136 2.95 11.276 1.995 44.163-14.653 80.185-41.062 108.068-79.226 27.88-38.161 41.825-81.126 41.825-128.906-.01-39.771-9.818-76.454-29.414-110.049z"
10
+ ></path>
11
+ </svg>
12
+ )
13
+
14
+ export default GitHub
@@ -0,0 +1,13 @@
1
+ import React from 'react'
2
+ import { type LucideProps } from 'lucide-react'
3
+
4
+ const Google: React.FC<LucideProps> = (props: LucideProps) => (
5
+ <svg viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
6
+ <path d="M30.0014 16.3109C30.0014 15.1598 29.9061 14.3198 29.6998 13.4487H16.2871V18.6442H24.1601C24.0014 19.9354 23.1442 21.8798 21.2394 23.1864L21.2127 23.3604L25.4536 26.58L25.7474 26.6087C28.4458 24.1665 30.0014 20.5731 30.0014 16.3109Z" fill="#4285F4"/>
7
+ <path d="M16.2863 29.9998C20.1434 29.9998 23.3814 28.7553 25.7466 26.6086L21.2386 23.1863C20.0323 24.0108 18.4132 24.5863 16.2863 24.5863C12.5086 24.5863 9.30225 22.1441 8.15929 18.7686L7.99176 18.7825L3.58208 22.127L3.52441 22.2841C5.87359 26.8574 10.699 29.9998 16.2863 29.9998Z" fill="#34A853"/>
8
+ <path d="M8.15964 18.769C7.85806 17.8979 7.68352 16.9645 7.68352 16.0001C7.68352 15.0356 7.85806 14.1023 8.14377 13.2312L8.13578 13.0456L3.67083 9.64746L3.52475 9.71556C2.55654 11.6134 2.00098 13.7445 2.00098 16.0001C2.00098 18.2556 2.55654 20.3867 3.52475 22.2845L8.15964 18.769Z" fill="#FBBC05"/>
9
+ <path d="M16.2864 7.4133C18.9689 7.4133 20.7784 8.54885 21.8102 9.4978L25.8419 5.64C23.3658 3.38445 20.1435 2 16.2864 2C10.699 2 5.8736 5.1422 3.52441 9.71549L8.14345 13.2311C9.30229 9.85555 12.5086 7.4133 16.2864 7.4133Z" fill="#EB4335"/>
10
+ </svg>
11
+ )
12
+
13
+ export default Google
package/icons/index.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { ArrowLeft } from 'lucide-react'
2
+
3
+ import Google from './google'
4
+ import Facebook from './facebook'
5
+ import GitHub from './github'
6
+ import Ethereum from './ethereum'
7
+
8
+ export {
9
+ Google,
10
+ Facebook,
11
+ GitHub,
12
+ ArrowLeft,
13
+ Ethereum
14
+ }
15
+
16
+
package/index.ts ADDED
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @libreapps/auth
3
+ *
4
+ * Pluggable authentication library.
5
+ * Firebase support available via @libreapps/auth-firebase (optional).
6
+ *
7
+ * Usage without Firebase:
8
+ * The auth system works out of the box with a stub implementation.
9
+ * All auth operations will return graceful failures.
10
+ *
11
+ * Usage with Firebase:
12
+ * ```ts
13
+ * import { FirebaseAuthService } from '@libreapps/auth-firebase'
14
+ * import { registerAuthProvider } from '@libreapps/auth'
15
+ *
16
+ * registerAuthProvider('firebase', FirebaseAuthService)
17
+ * ```
18
+ */
19
+
20
+ // Types
21
+ export type {
22
+ LibreAppsUserInfo,
23
+ LibreAppsUserInfoValue,
24
+ AuthServiceConf,
25
+ APIResponse
26
+ } from './types'
27
+
28
+ // Service
29
+ export type { AuthService, AuthProvider } from './service'
30
+ export {
31
+ useAuth,
32
+ AuthServiceProvider,
33
+ registerAuthProvider,
34
+ setActiveProvider,
35
+ getActiveProvider,
36
+ hasAuthProvider,
37
+ getRegisteredProviders,
38
+ StubAuthService
39
+ } from './service'
40
+ export type { AuthServiceFactory } from './service'
41
+
42
+ // Components
43
+ export {
44
+ LoginPanel,
45
+ EmailPasswordForm,
46
+ AuthWidget,
47
+ SignupPanel
48
+ } from './components'
49
+
50
+ // Icons
51
+ export * from './icons'
@@ -0,0 +1,23 @@
1
+ // Temporary type declarations for @libreapps/ui imports
2
+ // Until proper .d.ts files are generated
3
+ declare module '@libreapps/ui/primitives' {
4
+ export const Button: any
5
+ export const Separator: any
6
+ export const toast: any
7
+ export const Toaster: any
8
+ export const ApplyTypography: any
9
+ export const LinkElement: any
10
+ export const Popover: any
11
+ export const PopoverContent: any
12
+ export const PopoverTrigger: any
13
+ export const Input: any
14
+ export const Label: any
15
+ }
16
+
17
+ declare module '@libreapps/ui/types' {
18
+ export type LinkDef = any
19
+ }
20
+
21
+ declare module '@libreapps/ui/util' {
22
+ export function cn(...inputs: any[]): string
23
+ }
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@libreapps/auth",
3
+ "version": "3.0.1",
4
+ "description": "Pluggable authentication library. Firebase support via @libreapps/auth-firebase (optional).",
5
+ "publishConfig": {
6
+ "registry": "https://registry.npmjs.org/",
7
+ "access": "public",
8
+ "scope": "@libreapps"
9
+ },
10
+ "author": "LibreApps Contributors",
11
+ "license": "BSD-3-Clause",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/libre-apps/UI.git",
15
+ "directory": "pkg/auth"
16
+ },
17
+ "keywords": [
18
+ "auth",
19
+ "libreapps",
20
+ "libreapps"
21
+ ],
22
+ "main": "index.ts",
23
+ "dependencies": {},
24
+ "peerDependencies": {
25
+ "@hookform/resolvers": "^3.3.4",
26
+ "lucide-react": ">=0.456.0",
27
+ "mobx": "^6.12.3",
28
+ "mobx-react-lite": "^4.0.7",
29
+ "next": ">=14.2.16",
30
+ "react": "^18.0.0 || ^19.0.0",
31
+ "react-hook-form": ">=7.51.4",
32
+ "zod": "^3.23.8",
33
+ "@libreapps/ui": "5.4.1"
34
+ },
35
+ "peerDependenciesMeta": {
36
+ "firebase": {
37
+ "optional": true
38
+ },
39
+ "firebase-admin": {
40
+ "optional": true
41
+ }
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^24.4.0",
45
+ "@types/react": "^19.0.0",
46
+ "cross-fetch": "^4.0.0",
47
+ "firebase": "^10.8.0",
48
+ "firebase-admin": "^12.1.0",
49
+ "typescript": "5.6.3"
50
+ },
51
+ "scripts": {
52
+ "lat": "npm show @libreapps/auth version",
53
+ "pub": "npm publish",
54
+ "tc": "tsc",
55
+ "build": "tsc --outDir dist --declaration --emitDeclarationOnly false --module ESNext --esModuleInterop true --skipLibCheck true --sourceMap true"
56
+ }
57
+ }
@@ -0,0 +1,176 @@
1
+ // Server-side Firebase authentication
2
+ // For static builds, these functions return null/false
3
+
4
+ import type { LibreAppsUserInfoValue } from '../types'
5
+
6
+ // These functions require server-side environment (not available in static export)
7
+ // They will return null/false gracefully when running in static context
8
+
9
+ export async function getUserServerSide(): Promise<LibreAppsUserInfoValue | null> {
10
+ // Check if we're in a server environment with the required modules
11
+ if (typeof window !== 'undefined') {
12
+ // Client-side: auth should be handled via client-side Firebase
13
+ return null
14
+ }
15
+
16
+ try {
17
+ // Dynamic imports to prevent bundling issues in static export
18
+ const { cookies } = await import('next/headers')
19
+ const { initializeApp, getApps, cert } = await import('firebase-admin/app')
20
+ type App = Awaited<ReturnType<typeof initializeApp>>
21
+ const { getAuth } = await import('firebase-admin/auth')
22
+ const { getFirestore } = await import('firebase-admin/firestore')
23
+
24
+ const hasValidCredentials = process.env.FIREBASE_CLIENT_EMAIL &&
25
+ process.env.FIREBASE_PROJECT_ID &&
26
+ process.env.FIREBASE_PRIVATE_KEY
27
+
28
+ if (!hasValidCredentials) {
29
+ console.warn('Firebase credentials not configured')
30
+ return null
31
+ }
32
+
33
+ const firebaseApp = getApps().find((it) => it.name === 'firebase-admin-app') ||
34
+ initializeApp({
35
+ credential: cert({
36
+ clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
37
+ projectId: process.env.FIREBASE_PROJECT_ID,
38
+ privateKey: process.env.FIREBASE_PRIVATE_KEY!.replace(/\\n/g, '\n')
39
+ }),
40
+ }, 'firebase-admin-app')
41
+
42
+ const auth = getAuth(firebaseApp)
43
+ const db = getFirestore(firebaseApp as App, 'accounts')
44
+
45
+ const c = await cookies()
46
+ const session = c.get('__session')?.value
47
+
48
+ if (!session) return null
49
+
50
+ try {
51
+ const isRevoked = !(await auth.verifySessionCookie(session, true))
52
+ if (isRevoked) return null
53
+ } catch {
54
+ return null
55
+ }
56
+
57
+ const decodedIdToken = await auth.verifySessionCookie(session)
58
+ const currentUser = await auth.getUser(decodedIdToken.uid)
59
+ const walletAddress = await db.collection('USER_INFO').doc(currentUser.email ?? '').get()
60
+
61
+ return {
62
+ email: currentUser.email ?? '',
63
+ displayName: currentUser.displayName ?? null,
64
+ walletAddress: walletAddress.get('walletAddress') ?? null,
65
+ }
66
+ } catch (error) {
67
+ console.warn('Server-side auth not available:', error)
68
+ return null
69
+ }
70
+ }
71
+
72
+ export const generateCustomToken = async (): Promise<{success: boolean, token: string | null}> => {
73
+ // For static builds, this functionality is not available
74
+ if (typeof window !== 'undefined') {
75
+ return { success: false, token: null }
76
+ }
77
+
78
+ try {
79
+ const { cookies } = await import('next/headers')
80
+ const { initializeApp, getApps, cert } = await import('firebase-admin/app')
81
+ const { getAuth } = await import('firebase-admin/auth')
82
+
83
+ const hasValidCredentials = process.env.FIREBASE_CLIENT_EMAIL &&
84
+ process.env.FIREBASE_PROJECT_ID &&
85
+ process.env.FIREBASE_PRIVATE_KEY
86
+
87
+ if (!hasValidCredentials) {
88
+ return { success: false, token: null }
89
+ }
90
+
91
+ const firebaseApp = getApps().find((it) => it.name === 'firebase-admin-app') ||
92
+ initializeApp({
93
+ credential: cert({
94
+ clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
95
+ projectId: process.env.FIREBASE_PROJECT_ID,
96
+ privateKey: process.env.FIREBASE_PRIVATE_KEY!.replace(/\\n/g, '\n')
97
+ }),
98
+ }, 'firebase-admin-app')
99
+
100
+ const auth = getAuth(firebaseApp)
101
+ const c = await cookies()
102
+ const session = c.get('__session')?.value
103
+
104
+ if (!session) return { success: false, token: null }
105
+
106
+ const decodedIdToken = await auth.verifySessionCookie(session)
107
+ const currentUser = await auth.getUser(decodedIdToken.uid)
108
+ const token = await auth.createCustomToken(currentUser.uid)
109
+
110
+ return { success: true, token }
111
+ } catch (error) {
112
+ console.warn('Token generation not available:', error)
113
+ return { success: false, token: null }
114
+ }
115
+ }
116
+
117
+ export async function createSessionCookie(idToken: string, sessionCookieOptions: any) {
118
+ try {
119
+ const { initializeApp, getApps, cert } = await import('firebase-admin/app')
120
+ const { getAuth } = await import('firebase-admin/auth')
121
+
122
+ const hasValidCredentials = process.env.FIREBASE_CLIENT_EMAIL &&
123
+ process.env.FIREBASE_PROJECT_ID &&
124
+ process.env.FIREBASE_PRIVATE_KEY
125
+
126
+ if (!hasValidCredentials) {
127
+ throw new Error('Firebase not configured')
128
+ }
129
+
130
+ const firebaseApp = getApps().find((it) => it.name === 'firebase-admin-app') ||
131
+ initializeApp({
132
+ credential: cert({
133
+ clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
134
+ projectId: process.env.FIREBASE_PROJECT_ID,
135
+ privateKey: process.env.FIREBASE_PRIVATE_KEY!.replace(/\\n/g, '\n')
136
+ }),
137
+ }, 'firebase-admin-app')
138
+
139
+ const auth = getAuth(firebaseApp)
140
+ return auth.createSessionCookie(idToken, sessionCookieOptions)
141
+ } catch (error) {
142
+ console.warn('Session cookie creation not available:', error)
143
+ throw error
144
+ }
145
+ }
146
+
147
+ export async function revokeAllSessions(session: string) {
148
+ try {
149
+ const { initializeApp, getApps, cert } = await import('firebase-admin/app')
150
+ const { getAuth } = await import('firebase-admin/auth')
151
+
152
+ const hasValidCredentials = process.env.FIREBASE_CLIENT_EMAIL &&
153
+ process.env.FIREBASE_PROJECT_ID &&
154
+ process.env.FIREBASE_PRIVATE_KEY
155
+
156
+ if (!hasValidCredentials) {
157
+ throw new Error('Firebase not configured')
158
+ }
159
+
160
+ const firebaseApp = getApps().find((it) => it.name === 'firebase-admin-app') ||
161
+ initializeApp({
162
+ credential: cert({
163
+ clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
164
+ projectId: process.env.FIREBASE_PROJECT_ID,
165
+ privateKey: process.env.FIREBASE_PRIVATE_KEY!.replace(/\\n/g, '\n')
166
+ }),
167
+ }, 'firebase-admin-app')
168
+
169
+ const auth = getAuth(firebaseApp)
170
+ const decodedIdToken = await auth.verifySessionCookie(session)
171
+ return await auth.revokeRefreshTokens(decodedIdToken.sub)
172
+ } catch (error) {
173
+ console.warn('Session revocation not available:', error)
174
+ throw error
175
+ }
176
+ }
@@ -0,0 +1,14 @@
1
+ // Server-side auth functions - use Firebase if configured, otherwise stub
2
+ // For Firebase support, also install @libreapps/auth-firebase
3
+ export { getUserServerSide, generateCustomToken, createSessionCookie, revokeAllSessions } from './firebase-support'
4
+ export {
5
+ handleLogin as handleLoginApiRequest,
6
+ handleLogout as handleLogoutApiRequest
7
+ } from './rest-api-handlers'
8
+ export type { APIResponse } from '../types'
9
+
10
+ // Re-export stub for explicit use
11
+ export {
12
+ getUserServerSide as stubGetUserServerSide,
13
+ generateCustomToken as stubGenerateCustomToken
14
+ } from './stub-server'