@molecule/app-svelte 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.
Files changed (103) hide show
  1. package/LICENSE +115 -0
  2. package/README.md +2032 -0
  3. package/dist/context.d.ts +126 -0
  4. package/dist/context.d.ts.map +1 -0
  5. package/dist/context.js +217 -0
  6. package/dist/context.js.map +1 -0
  7. package/dist/index.d.ts +60 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +60 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/stores/async-state.d.ts +47 -0
  12. package/dist/stores/async-state.d.ts.map +1 -0
  13. package/dist/stores/async-state.js +89 -0
  14. package/dist/stores/async-state.js.map +1 -0
  15. package/dist/stores/auth.d.ts +54 -0
  16. package/dist/stores/auth.d.ts.map +1 -0
  17. package/dist/stores/auth.js +93 -0
  18. package/dist/stores/auth.js.map +1 -0
  19. package/dist/stores/capacitor-app.d.ts +46 -0
  20. package/dist/stores/capacitor-app.d.ts.map +1 -0
  21. package/dist/stores/capacitor-app.js +59 -0
  22. package/dist/stores/capacitor-app.js.map +1 -0
  23. package/dist/stores/change-password.d.ts +17 -0
  24. package/dist/stores/change-password.d.ts.map +1 -0
  25. package/dist/stores/change-password.js +17 -0
  26. package/dist/stores/change-password.js.map +1 -0
  27. package/dist/stores/device.d.ts +39 -0
  28. package/dist/stores/device.d.ts.map +1 -0
  29. package/dist/stores/device.js +51 -0
  30. package/dist/stores/device.js.map +1 -0
  31. package/dist/stores/forms.d.ts +121 -0
  32. package/dist/stores/forms.d.ts.map +1 -0
  33. package/dist/stores/forms.js +178 -0
  34. package/dist/stores/forms.js.map +1 -0
  35. package/dist/stores/http.d.ts +119 -0
  36. package/dist/stores/http.d.ts.map +1 -0
  37. package/dist/stores/http.js +206 -0
  38. package/dist/stores/http.js.map +1 -0
  39. package/dist/stores/i18n.d.ts +50 -0
  40. package/dist/stores/i18n.d.ts.map +1 -0
  41. package/dist/stores/i18n.js +67 -0
  42. package/dist/stores/i18n.js.map +1 -0
  43. package/dist/stores/index.d.ts +27 -0
  44. package/dist/stores/index.d.ts.map +1 -0
  45. package/dist/stores/index.js +27 -0
  46. package/dist/stores/index.js.map +1 -0
  47. package/dist/stores/logger.d.ts +83 -0
  48. package/dist/stores/logger.d.ts.map +1 -0
  49. package/dist/stores/logger.js +104 -0
  50. package/dist/stores/logger.js.map +1 -0
  51. package/dist/stores/login.d.ts +33 -0
  52. package/dist/stores/login.d.ts.map +1 -0
  53. package/dist/stores/login.js +32 -0
  54. package/dist/stores/login.js.map +1 -0
  55. package/dist/stores/oauth.d.ts +74 -0
  56. package/dist/stores/oauth.d.ts.map +1 -0
  57. package/dist/stores/oauth.js +183 -0
  58. package/dist/stores/oauth.js.map +1 -0
  59. package/dist/stores/password-reset.d.ts +31 -0
  60. package/dist/stores/password-reset.d.ts.map +1 -0
  61. package/dist/stores/password-reset.js +26 -0
  62. package/dist/stores/password-reset.js.map +1 -0
  63. package/dist/stores/platform.d.ts +41 -0
  64. package/dist/stores/platform.d.ts.map +1 -0
  65. package/dist/stores/platform.js +44 -0
  66. package/dist/stores/platform.js.map +1 -0
  67. package/dist/stores/promise.d.ts +41 -0
  68. package/dist/stores/promise.d.ts.map +1 -0
  69. package/dist/stores/promise.js +76 -0
  70. package/dist/stores/promise.js.map +1 -0
  71. package/dist/stores/push.d.ts +41 -0
  72. package/dist/stores/push.d.ts.map +1 -0
  73. package/dist/stores/push.js +73 -0
  74. package/dist/stores/push.js.map +1 -0
  75. package/dist/stores/router.d.ts +74 -0
  76. package/dist/stores/router.d.ts.map +1 -0
  77. package/dist/stores/router.js +131 -0
  78. package/dist/stores/router.js.map +1 -0
  79. package/dist/stores/signup.d.ts +18 -0
  80. package/dist/stores/signup.d.ts.map +1 -0
  81. package/dist/stores/signup.js +17 -0
  82. package/dist/stores/signup.js.map +1 -0
  83. package/dist/stores/state.d.ts +62 -0
  84. package/dist/stores/state.d.ts.map +1 -0
  85. package/dist/stores/state.js +74 -0
  86. package/dist/stores/state.js.map +1 -0
  87. package/dist/stores/storage.d.ts +76 -0
  88. package/dist/stores/storage.d.ts.map +1 -0
  89. package/dist/stores/storage.js +159 -0
  90. package/dist/stores/storage.js.map +1 -0
  91. package/dist/stores/theme.d.ts +68 -0
  92. package/dist/stores/theme.d.ts.map +1 -0
  93. package/dist/stores/theme.js +119 -0
  94. package/dist/stores/theme.js.map +1 -0
  95. package/dist/stores/version.d.ts +44 -0
  96. package/dist/stores/version.d.ts.map +1 -0
  97. package/dist/stores/version.js +73 -0
  98. package/dist/stores/version.js.map +1 -0
  99. package/dist/types.d.ts +46 -0
  100. package/dist/types.d.ts.map +1 -0
  101. package/dist/types.js +7 -0
  102. package/dist/types.js.map +1 -0
  103. package/package.json +59 -0
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Svelte stores for molecule.dev framework bindings.
3
+ *
4
+ * @module
5
+ */
6
+ export * from './async-state.js';
7
+ export * from './auth.js';
8
+ export * from './capacitor-app.js';
9
+ export * from './change-password.js';
10
+ export * from './device.js';
11
+ export * from './forms.js';
12
+ export * from './http.js';
13
+ export * from './i18n.js';
14
+ export * from './logger.js';
15
+ export * from './login.js';
16
+ export * from './oauth.js';
17
+ export * from './password-reset.js';
18
+ export * from './platform.js';
19
+ export * from './promise.js';
20
+ export * from './push.js';
21
+ export * from './router.js';
22
+ export * from './signup.js';
23
+ export * from './state.js';
24
+ export * from './storage.js';
25
+ export * from './theme.js';
26
+ export * from './version.js';
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Svelte stores for molecule.dev framework bindings.
3
+ *
4
+ * @module
5
+ */
6
+ export * from './async-state.js';
7
+ export * from './auth.js';
8
+ export * from './capacitor-app.js';
9
+ export * from './change-password.js';
10
+ export * from './device.js';
11
+ export * from './forms.js';
12
+ export * from './http.js';
13
+ export * from './i18n.js';
14
+ export * from './logger.js';
15
+ export * from './login.js';
16
+ export * from './oauth.js';
17
+ export * from './password-reset.js';
18
+ export * from './platform.js';
19
+ export * from './promise.js';
20
+ export * from './push.js';
21
+ export * from './router.js';
22
+ export * from './signup.js';
23
+ export * from './state.js';
24
+ export * from './storage.js';
25
+ export * from './theme.js';
26
+ export * from './version.js';
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Svelte utilities for logging.
3
+ *
4
+ * @module
5
+ */
6
+ import type { Logger, LoggerConfig, LoggerProvider, LogLevel } from '@molecule/app-logger';
7
+ /**
8
+ * Logger helper functions.
9
+ */
10
+ interface LoggerHelpers {
11
+ getLogger: (name?: string) => Logger;
12
+ createLogger: (config: LoggerConfig) => Logger;
13
+ setLevel: (level: LogLevel) => void;
14
+ getLevel: () => LogLevel;
15
+ enable: () => void;
16
+ disable: () => void;
17
+ isEnabled: () => boolean;
18
+ }
19
+ /**
20
+ * Get a logger instance.
21
+ *
22
+ * @param name - Logger name
23
+ * @returns Logger instance
24
+ *
25
+ * @example
26
+ * ```svelte
27
+ * <script>
28
+ * import { getLogger } from '@molecule/app-svelte'
29
+ * import { onMount, onDestroy } from 'svelte'
30
+ *
31
+ * const logger = getLogger('MyComponent')
32
+ *
33
+ * onMount(() => {
34
+ * logger.info('Component mounted')
35
+ * })
36
+ *
37
+ * onDestroy(() => {
38
+ * logger.debug('Component destroyed')
39
+ * })
40
+ *
41
+ * function handleError(error) {
42
+ * logger.error('Operation failed', error)
43
+ * }
44
+ * </script>
45
+ * ```
46
+ */
47
+ export declare function getLogger(name?: string): Logger;
48
+ /**
49
+ * Create a logger with custom configuration.
50
+ *
51
+ * @param config - Logger configuration
52
+ * @returns Logger instance
53
+ */
54
+ export declare function createLogger(config: LoggerConfig): Logger;
55
+ /**
56
+ * Get the root logger.
57
+ *
58
+ * @returns Root logger instance
59
+ */
60
+ export declare function getRootLogger(): Logger;
61
+ /**
62
+ * Create a child logger with additional context.
63
+ *
64
+ * @param name - Parent logger name
65
+ * @param context - Additional context
66
+ * @returns Child logger instance
67
+ */
68
+ export declare function getChildLogger(name: string, context: Record<string, unknown>): Logger;
69
+ /**
70
+ * Create logger helpers from context.
71
+ *
72
+ * @returns Logger helper functions
73
+ */
74
+ export declare function createLoggerHelpers(): LoggerHelpers;
75
+ /**
76
+ * Create logger helpers from a specific provider.
77
+ *
78
+ * @param provider - Logger provider
79
+ * @returns Logger helper functions
80
+ */
81
+ export declare function createLoggerHelpersFromProvider(provider: LoggerProvider): LoggerHelpers;
82
+ export {};
83
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/stores/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAI1F;;GAEG;AACH,UAAU,aAAa;IACrB,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IACpC,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,CAAA;IAC9C,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;IACnC,QAAQ,EAAE,MAAM,QAAQ,CAAA;IACxB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,SAAS,EAAE,MAAM,OAAO,CAAA;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAGzD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAGtC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAIrF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAanD;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,cAAc,GAAG,aAAa,CAWvF"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Svelte utilities for logging.
3
+ *
4
+ * @module
5
+ */
6
+ import { getLoggerProvider } from '../context.js';
7
+ /**
8
+ * Get a logger instance.
9
+ *
10
+ * @param name - Logger name
11
+ * @returns Logger instance
12
+ *
13
+ * @example
14
+ * ```svelte
15
+ * <script>
16
+ * import { getLogger } from '@molecule/app-svelte'
17
+ * import { onMount, onDestroy } from 'svelte'
18
+ *
19
+ * const logger = getLogger('MyComponent')
20
+ *
21
+ * onMount(() => {
22
+ * logger.info('Component mounted')
23
+ * })
24
+ *
25
+ * onDestroy(() => {
26
+ * logger.debug('Component destroyed')
27
+ * })
28
+ *
29
+ * function handleError(error) {
30
+ * logger.error('Operation failed', error)
31
+ * }
32
+ * </script>
33
+ * ```
34
+ */
35
+ export function getLogger(name) {
36
+ const provider = getLoggerProvider();
37
+ return provider.getLogger(name);
38
+ }
39
+ /**
40
+ * Create a logger with custom configuration.
41
+ *
42
+ * @param config - Logger configuration
43
+ * @returns Logger instance
44
+ */
45
+ export function createLogger(config) {
46
+ const provider = getLoggerProvider();
47
+ return provider.createLogger(config);
48
+ }
49
+ /**
50
+ * Get the root logger.
51
+ *
52
+ * @returns Root logger instance
53
+ */
54
+ export function getRootLogger() {
55
+ const provider = getLoggerProvider();
56
+ return provider.getLogger();
57
+ }
58
+ /**
59
+ * Create a child logger with additional context.
60
+ *
61
+ * @param name - Parent logger name
62
+ * @param context - Additional context
63
+ * @returns Child logger instance
64
+ */
65
+ export function getChildLogger(name, context) {
66
+ const provider = getLoggerProvider();
67
+ const parent = provider.getLogger(name);
68
+ return parent.withContext(context);
69
+ }
70
+ /**
71
+ * Create logger helpers from context.
72
+ *
73
+ * @returns Logger helper functions
74
+ */
75
+ export function createLoggerHelpers() {
76
+ const provider = getLoggerProvider();
77
+ return {
78
+ getLogger: (name) => provider.getLogger(name),
79
+ createLogger: (config) => provider.createLogger(config),
80
+ setLevel: (level) => provider.setLevel(level),
81
+ getLevel: () => provider.getLevel(),
82
+ enable: () => provider.enable(),
83
+ disable: () => provider.disable(),
84
+ isEnabled: () => provider.isEnabled(),
85
+ };
86
+ }
87
+ /**
88
+ * Create logger helpers from a specific provider.
89
+ *
90
+ * @param provider - Logger provider
91
+ * @returns Logger helper functions
92
+ */
93
+ export function createLoggerHelpersFromProvider(provider) {
94
+ return {
95
+ getLogger: (name) => provider.getLogger(name),
96
+ createLogger: (config) => provider.createLogger(config),
97
+ setLevel: (level) => provider.setLevel(level),
98
+ getLevel: () => provider.getLevel(),
99
+ enable: () => provider.enable(),
100
+ disable: () => provider.disable(),
101
+ isEnabled: () => provider.isEnabled(),
102
+ };
103
+ }
104
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/stores/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAejD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAA;IACpC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAoB;IAC/C,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAA;IACpC,OAAO,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;AACtC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,QAAQ,GAAG,iBAAi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AC5E,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC1B,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE;QACnC,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE;QAC/B,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE;QACjC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE;KACtC,CAAA;AACH,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Svelte store for login with async state tracking.
3
+ *
4
+ * @module
5
+ */
6
+ import type { AuthResult } from '@molecule/app-auth';
7
+ import { type PromiseStore } from './promise.js';
8
+ /**
9
+ * Login store type.
10
+ */
11
+ export type LoginStore<T = unknown> = PromiseStore<AuthResult<T>>;
12
+ /**
13
+ * Creates a login store with async state tracking.
14
+ *
15
+ * @returns Login promise store
16
+ *
17
+ * @example
18
+ * ```svelte
19
+ * <script>
20
+ * import { createLoginStore } from '@molecule/app-svelte'
21
+ * const login = createLoginStore()
22
+ * </script>
23
+ *
24
+ * <button
25
+ * on:click={() => login.call({ email, password })}
26
+ * disabled={$login.status === 'pending'}
27
+ * >
28
+ * {$login.status === 'pending' ? 'Logging in...' : 'Login'}
29
+ * </button>
30
+ * ```
31
+ */
32
+ export declare function createLoginStore<T = unknown>(): LoginStore<T>;
33
+ //# sourceMappingURL=login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/stores/login.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,oBAAoB,CAAA;AAGtE,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAEpE;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;AAEjE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,CAG7D"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Svelte store for login with async state tracking.
3
+ *
4
+ * @module
5
+ */
6
+ import { getAuthClient } from '../context.js';
7
+ import { createPromiseStore } from './promise.js';
8
+ /**
9
+ * Creates a login store with async state tracking.
10
+ *
11
+ * @returns Login promise store
12
+ *
13
+ * @example
14
+ * ```svelte
15
+ * <script>
16
+ * import { createLoginStore } from '@molecule/app-svelte'
17
+ * const login = createLoginStore()
18
+ * </script>
19
+ *
20
+ * <button
21
+ * on:click={() => login.call({ email, password })}
22
+ * disabled={$login.status === 'pending'}
23
+ * >
24
+ * {$login.status === 'pending' ? 'Logging in...' : 'Login'}
25
+ * </button>
26
+ * ```
27
+ */
28
+ export function createLoginStore() {
29
+ const client = getAuthClient();
30
+ return createPromiseStore((credentials) => client.login(credentials));
31
+ }
32
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/stores/login.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAqB,MAAM,cAAc,CAAA;AAOpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAG,aAAa,EAAK,CAAA;IACjC,OAAO,kBAAkB,CAAC,CAAC,WAA6B,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;AACzF,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Svelte OAuth helpers.
3
+ *
4
+ * Provides helpers to build OAuth URLs and start a login via a full-page
5
+ * redirect, and automatically handles the OAuth callback by detecting `code`
6
+ * and `state` URL parameters and exchanging them for a session (see
7
+ * {@link OAuthHelpers.handleCallback} for manual use).
8
+ *
9
+ * @module
10
+ */
11
+ import { type Readable } from 'svelte/store';
12
+ import type { AuthClient } from '@molecule/app-auth';
13
+ /**
14
+ * OAuth configuration options.
15
+ */
16
+ export interface OAuthOptions {
17
+ /** Base URL for the API server (e.g. `https://api.example.com`). */
18
+ baseURL?: string;
19
+ /** List of supported OAuth provider names (e.g. `['google', 'github']`). */
20
+ oauthProviders?: string[];
21
+ /** Path prefix for OAuth initiation routes. Defaults to `/oauth`. */
22
+ oauthEndpoint?: string;
23
+ /** Path for the OAuth login POST endpoint. Defaults to `/users/log-in/oauth`. */
24
+ loginEndpoint?: string;
25
+ /** Callback fired after a successful OAuth login. */
26
+ onSuccess?: () => void;
27
+ /** Callback fired with an error message when the OAuth login fails. */
28
+ onError?: (error: string) => void;
29
+ /**
30
+ * Explicit auth client used to establish the session after the callback
31
+ * exchange. Defaults to the client in Svelte context (only resolvable when
32
+ * called during component initialization) — pass one explicitly for
33
+ * callers/tests outside a component/context.
34
+ */
35
+ authClient?: AuthClient<unknown>;
36
+ }
37
+ /**
38
+ * OAuth helpers returned by {@link createOAuthHelpers}.
39
+ */
40
+ export interface OAuthHelpers {
41
+ /** Readable store of available OAuth provider names. */
42
+ providers: Readable<string[]>;
43
+ /** Builds the OAuth initiation URL for a provider. */
44
+ getOAuthUrl: (provider: string) => string;
45
+ /** Full-page redirect to the provider's OAuth initiation endpoint. */
46
+ redirect: (provider: string) => void;
47
+ /**
48
+ * Handles an OAuth callback: when the current URL carries a `code` param and
49
+ * a provider was stashed by {@link redirect}, exchanges the code for a
50
+ * session. A guarded no-op otherwise. Runs automatically when
51
+ * {@link createOAuthHelpers} is called in a browser; exposed for manual
52
+ * invocation (e.g. tests or custom callback screens).
53
+ */
54
+ handleCallback: () => Promise<void>;
55
+ }
56
+ /**
57
+ * Creates OAuth helpers for provider-based authentication flows.
58
+ *
59
+ * When created in a browser, automatically handles OAuth callbacks by
60
+ * detecting `code` and `state` URL parameters and exchanging them for a
61
+ * session (a guarded no-op when there is no callback code in the URL).
62
+ *
63
+ * Session establishment: the exchange result is applied to the resolved auth
64
+ * client (an explicit `options.authClient`, else the Svelte-context client
65
+ * when created during component initialization). When NO client is available,
66
+ * the server has already established the httpOnly-cookie session via the
67
+ * exchange, so a user-carrying response still counts as success —
68
+ * `options.onSuccess` fires; a response with no user fires `options.onError`.
69
+ *
70
+ * @param options - OAuth configuration (base URL, providers, endpoint paths, callbacks, auth client).
71
+ * @returns An object containing a readable providers store, URL builder, redirect function, and callback handler.
72
+ */
73
+ export declare function createOAuthHelpers(options?: OAuthOptions): OAuthHelpers;
74
+ //# sourceMappingURL=oauth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/stores/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAIpD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,uEAAuE;IACvE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IAC7B,sDAAsD;IACtD,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;IACzC,sEAAsE;IACtE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,YAAY,CA+JvE"}
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Svelte OAuth helpers.
3
+ *
4
+ * Provides helpers to build OAuth URLs and start a login via a full-page
5
+ * redirect, and automatically handles the OAuth callback by detecting `code`
6
+ * and `state` URL parameters and exchanging them for a session (see
7
+ * {@link OAuthHelpers.handleCallback} for manual use).
8
+ *
9
+ * @module
10
+ */
11
+ import { readable } from 'svelte/store';
12
+ import { getAuthClient } from '../context.js';
13
+ /**
14
+ * Creates OAuth helpers for provider-based authentication flows.
15
+ *
16
+ * When created in a browser, automatically handles OAuth callbacks by
17
+ * detecting `code` and `state` URL parameters and exchanging them for a
18
+ * session (a guarded no-op when there is no callback code in the URL).
19
+ *
20
+ * Session establishment: the exchange result is applied to the resolved auth
21
+ * client (an explicit `options.authClient`, else the Svelte-context client
22
+ * when created during component initialization). When NO client is available,
23
+ * the server has already established the httpOnly-cookie session via the
24
+ * exchange, so a user-carrying response still counts as success —
25
+ * `options.onSuccess` fires; a response with no user fires `options.onError`.
26
+ *
27
+ * @param options - OAuth configuration (base URL, providers, endpoint paths, callbacks, auth client).
28
+ * @returns An object containing a readable providers store, URL builder, redirect function, and callback handler.
29
+ */
30
+ export function createOAuthHelpers(options) {
31
+ const baseURL = options?.baseURL ?? '';
32
+ const oauthEndpoint = options?.oauthEndpoint ?? '/oauth';
33
+ const loginEndpoint = options?.loginEndpoint ?? '/users/log-in/oauth';
34
+ // Resolve the auth client AT CREATION TIME — Svelte context is only
35
+ // available during component initialization, never inside the async
36
+ // callback. An explicit `options.authClient` wins.
37
+ let authClient = options?.authClient ?? null;
38
+ if (!authClient) {
39
+ try {
40
+ authClient = getAuthClient();
41
+ }
42
+ catch (_error) {
43
+ /* Called outside component initialization or without an auth context —
44
+ handleCallback falls back to the httpOnly-cookie session path. */
45
+ }
46
+ }
47
+ const providers = readable(options?.oauthProviders ?? []);
48
+ const getOAuthUrl = (provider) => {
49
+ // Encode the provider as a single path segment so a (future) caller passing an
50
+ // untrusted value can never inject a path/query/scheme into the opened URL —
51
+ // defense-in-depth on top of the upstream static provider allowlist. Plain
52
+ // provider names ('github', 'google') pass through unchanged.
53
+ return `${baseURL}${oauthEndpoint}/${encodeURIComponent(provider)}`;
54
+ };
55
+ /** Stash which provider initiated the flow so the callback knows it's ours. */
56
+ const stashProvider = (provider) => {
57
+ try {
58
+ sessionStorage.setItem('oauth_provider', provider);
59
+ }
60
+ catch (_error) {
61
+ /* SSR-safe — sessionStorage is unavailable in SSR/sandboxed environments */
62
+ }
63
+ };
64
+ /**
65
+ * Append the current page's PATH as `redirect_to` so the api's initiation
66
+ * endpoint (`GET /users/oauth/:provider`) builds a provider `redirect_uri`
67
+ * that lands the callback back on THIS page — the one where the helpers are
68
+ * mounted (e.g. `/login`) — instead of the app root, where nothing may be
69
+ * listening for the `code` param. Path only (no origin/query): the server
70
+ * validates it as a same-origin absolute path, so it can never become an
71
+ * open redirect. Servers that predate the param simply ignore it.
72
+ */
73
+ const withReturnPath = (url) => {
74
+ const path = typeof window !== 'undefined' ? window.location.pathname : '';
75
+ if (!path || path === '/')
76
+ return url;
77
+ return `${url}${url.includes('?') ? '&' : '?'}redirect_to=${encodeURIComponent(path)}`;
78
+ };
79
+ const redirect = (provider) => {
80
+ stashProvider(provider);
81
+ window.location.href = withReturnPath(getOAuthUrl(provider));
82
+ };
83
+ const handleCallback = async () => {
84
+ if (typeof window === 'undefined')
85
+ return;
86
+ const params = new URLSearchParams(window.location.search);
87
+ const code = params.get('code');
88
+ const state = params.get('state');
89
+ if (!code)
90
+ return;
91
+ // Retrieve the provider that initiated the flow
92
+ let provider = null;
93
+ try {
94
+ provider = sessionStorage.getItem('oauth_provider');
95
+ }
96
+ catch (_error) {
97
+ /* SSR-safe — sessionStorage is unavailable in SSR/sandboxed environments */
98
+ }
99
+ if (!provider)
100
+ return;
101
+ // Clean up URL (remove code/state params) and sessionStorage
102
+ const cleanUrl = new URL(window.location.href);
103
+ cleanUrl.searchParams.delete('code');
104
+ cleanUrl.searchParams.delete('state');
105
+ window.history.replaceState({}, '', cleanUrl.toString());
106
+ try {
107
+ sessionStorage.removeItem('oauth_provider');
108
+ }
109
+ catch (_error) {
110
+ /* SSR-safe — sessionStorage is unavailable in SSR/sandboxed environments */
111
+ }
112
+ // Exchange code for session
113
+ try {
114
+ const response = await fetch(`${baseURL}${loginEndpoint}`, {
115
+ method: 'POST',
116
+ headers: { 'Content-Type': 'application/json' },
117
+ credentials: 'include', // Send cookies (oauth_state/oauth_verifier) for state validation
118
+ body: JSON.stringify({
119
+ server: provider,
120
+ code,
121
+ state: state || undefined,
122
+ redirect_uri: window.location.origin,
123
+ }),
124
+ });
125
+ if (!response.ok) {
126
+ const data = await response.json().catch(() => ({ error: 'OAuth login failed' }));
127
+ options?.onError?.(data.error || 'OAuth login failed');
128
+ return;
129
+ }
130
+ const data = await response.json().catch(() => null);
131
+ // Store the token from the response
132
+ const authHeader = response.headers.get('authorization') || response.headers.get('set-authorization');
133
+ const token = authHeader ? authHeader.replace('Bearer ', '') : null;
134
+ // The authenticated user is `props` (molecule resource convention) or `user`
135
+ // (generic AuthResult).
136
+ const user = data && typeof data === 'object'
137
+ ? (data.props ??
138
+ data.user ??
139
+ null)
140
+ : null;
141
+ if (authClient) {
142
+ // Seed the token + user via the auth client and let `initialize()` flip
143
+ // `authenticated` — mirrors what `authClient.login()` does for password
144
+ // login. A result with no user is not a real session.
145
+ if (token)
146
+ authClient.setAccessToken(token);
147
+ if (user && typeof user === 'object') {
148
+ authClient.setUser(user);
149
+ await authClient.initialize();
150
+ options?.onSuccess?.();
151
+ }
152
+ else {
153
+ options?.onError?.('OAuth login failed');
154
+ }
155
+ }
156
+ else if (user && typeof user === 'object') {
157
+ // No auth client available: the server has already established the
158
+ // httpOnly-cookie session via the exchange, so a user-carrying response
159
+ // still counts as success.
160
+ options?.onSuccess?.();
161
+ }
162
+ else {
163
+ options?.onError?.('OAuth login failed');
164
+ }
165
+ }
166
+ catch (err) {
167
+ options?.onError?.(err instanceof Error && err.message ? err.message : 'OAuth login failed');
168
+ }
169
+ };
170
+ // Auto-handle the OAuth callback at creation when in a browser — a guarded
171
+ // no-op unless the URL carries a callback `code` and a provider was stashed
172
+ // by `redirect`, so this is safe to run on every creation.
173
+ if (typeof window !== 'undefined') {
174
+ void handleCallback();
175
+ }
176
+ return {
177
+ providers,
178
+ getOAuthUrl,
179
+ redirect,
180
+ handleCallback,
181
+ };
182
+ }
183
+ //# sourceMappingURL=oauth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/stores/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAiB,QAAQ,EAAE,MAAM,cAAc,CAAA;AAItD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AA+C7C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAsB;IACvD,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,EAAE,CAAA;IACtC,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,QAAQ,CAAA;IACxD,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,qBAAqB,CAAA;IAErE,oEAAoE;IACpE,oEAAoE;IACpE,mDAAmD;IACnD,IAAI,UAAU,GAA+B,OAAO,EAAE,UAAU,IAAI,IAAI,CAAA;IACxE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,IAAI,CAAC;YACH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AAE,CAAC;gBACf,wEAAwE;gBACxE,wEAAwE;gBACxE,sDAAsD;gBACtD,IAAI,KAAK;oBAAE,UAAU,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;gBAC3C,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACrC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;oBACxB,MAAM,UAAU,CAAC,UAAU,EAAE,CAAA;oBAC7B,OAAO,EAAE,SAAS,EAAE,EAAE,CAAA;gBACxB,CAAC;qBAAM,CAAC;oBACN,OAAO,EAAE,OAAO,EAAE,CAAC,oBAAoB,CAAC,CAAA;gBAC1C,CAAC;YACH,CAAC;iBAAM,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC5C,mEAAmE;gBACnE,wEAAwE;gBACxE,2BAA2B;gBAC3B,OAAO,EAAE,SAAS,EAAE,EAAE,CAAA;YACxB,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,OAAO,EAAE,CAAC,oBAAoB,CAAC,CAAA;YAC1C,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAA;QAC9F,CAAC;IACH,CAAC,CAAA;IAED,2EAA2E;IAC3E,4EAA4E;IAC5E,2DAA2D;IAC3D,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,KAAK,cAAc,EAAE,CAAA;IACvB,CAAC;IAED,OAAO;QACL,SAAS;QACT,WAAW;QACX,QAAQ;QACR,cAAc;KACf,CAAA;AACH,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Svelte store for password reset with async state tracking.
3
+ *
4
+ * @module
5
+ */
6
+ import type { Readable } from 'svelte/store';
7
+ import type { PasswordResetConfirm, PasswordResetRequest } from '@molecule/app-auth';
8
+ import type { PromiseState } from '@molecule/app-utilities';
9
+ /**
10
+ * Password reset stores.
11
+ */
12
+ export interface PasswordResetStores {
13
+ request: Readable<PromiseState<void>> & {
14
+ call: (data: PasswordResetRequest) => Promise<void>;
15
+ cancel: (message?: string) => void;
16
+ reset: () => void;
17
+ };
18
+ confirm: Readable<PromiseState<void>> & {
19
+ call: (data: PasswordResetConfirm) => Promise<void>;
20
+ cancel: (message?: string) => void;
21
+ reset: () => void;
22
+ };
23
+ resetAll: () => void;
24
+ }
25
+ /**
26
+ * Creates password reset stores with async state tracking.
27
+ *
28
+ * @returns Password reset stores for request and confirm steps
29
+ */
30
+ export declare function createPasswordResetStores(): PasswordResetStores;
31
+ //# sourceMappingURL=password-reset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password-reset.d.ts","sourceRoot":"","sources":["../../src/stores/password-reset.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAK3D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG;QACtC,IAAI,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;QACnD,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;QAClC,KAAK,EAAE,MAAM,IAAI,CAAA;KAClB,CAAA;IACD,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG;QACtC,IAAI,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;QACnD,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;QAClC,KAAK,EAAE,MAAM,IAAI,CAAA;KAClB,CAAA;IACD,QAAQ,EAAE,MAAM,IAAI,CAAA;CACrB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,mBAAmB,CAmB/D"}