firstly 0.0.3 → 0.0.5

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 (93) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/esm/{KitBaseEnum.d.ts → BaseEnum.d.ts} +18 -9
  3. package/esm/{KitBaseEnum.js → BaseEnum.js} +2 -13
  4. package/esm/{KitEntity.d.ts → FF_Entity.d.ts} +1 -1
  5. package/esm/{KitEntity.js → FF_Entity.js} +9 -9
  6. package/esm/{KitFields.d.ts → FF_Fields.d.ts} +4 -5
  7. package/esm/{KitFields.js → FF_Fields.js} +41 -55
  8. package/esm/ROUTES.d.ts +4 -2
  9. package/esm/ROUTES.js +4 -7
  10. package/esm/SqlDatabase/FF_LogToConsole.d.ts +1 -0
  11. package/esm/SqlDatabase/{LogToConsoleCustom.js → FF_LogToConsole.js} +1 -1
  12. package/esm/api/index.d.ts +1 -0
  13. package/esm/auth/Adapter.js +10 -8
  14. package/esm/auth/{AuthController.d.ts → AuthController.server.d.ts} +2 -2
  15. package/esm/auth/{AuthController.js → AuthController.server.js} +15 -51
  16. package/esm/auth/Entities.d.ts +18 -17
  17. package/esm/auth/Entities.js +66 -63
  18. package/esm/auth/README.md +13 -0
  19. package/esm/auth/{RoleController.d.ts → RoleHelpers.d.ts} +2 -4
  20. package/esm/auth/RoleHelpers.js +43 -0
  21. package/esm/auth/client/Auth.d.ts +69 -0
  22. package/esm/auth/client/Auth.js +121 -0
  23. package/esm/auth/client/index.d.ts +2 -0
  24. package/esm/auth/client/index.js +2 -0
  25. package/esm/auth/index.d.ts +10 -11
  26. package/esm/auth/index.js +37 -21
  27. package/esm/auth/providers/github.d.ts +22 -17
  28. package/esm/auth/providers/github.js +29 -15
  29. package/esm/auth/providers/strava.d.ts +22 -17
  30. package/esm/auth/providers/strava.js +23 -15
  31. package/esm/auth/static/assets/{Page-BwHye0GW.d.ts → Page-BYzkK4q3.d.ts} +1 -1
  32. package/esm/auth/static/assets/{Page-BwHye0GW.js → Page-BYzkK4q3.js} +1 -1
  33. package/esm/auth/static/assets/Page-ByIhtXVt.d.ts +5 -0
  34. package/esm/auth/static/assets/Page-ByIhtXVt.js +8190 -0
  35. package/esm/auth/static/assets/{Page-BMOLAIFx.d.ts → Page-Do7F0Mzd.d.ts} +1 -1
  36. package/esm/auth/static/assets/{Page-BMOLAIFx.js → Page-Do7F0Mzd.js} +1 -1
  37. package/esm/auth/static/assets/index-czJ1PA1n.js +2 -0
  38. package/esm/auth/static/index.html +1 -1
  39. package/esm/bin/cmd.js +182 -83
  40. package/esm/cellsBuildor.d.ts +45 -0
  41. package/esm/{kitCellsBuildor.js → cellsBuildor.js} +24 -14
  42. package/esm/feedback/ui/DialogIssue.svelte +2 -2
  43. package/esm/formats/dates.js +2 -2
  44. package/esm/formats/strings.js +0 -11
  45. package/esm/handle/index.d.ts +1 -0
  46. package/esm/helper.d.ts +8 -10
  47. package/esm/helper.js +13 -12
  48. package/esm/index.d.ts +37 -48
  49. package/esm/index.js +29 -20
  50. package/esm/{kitStoreItem.d.ts → storeItem.d.ts} +1 -1
  51. package/esm/{kitStoreItem.js → storeItem.js} +3 -3
  52. package/esm/{kitStoreList.d.ts → storeList.d.ts} +4 -4
  53. package/esm/{kitStoreList.js → storeList.js} +1 -1
  54. package/esm/ui/Button.svelte +7 -9
  55. package/esm/ui/Button.svelte.d.ts +2 -2
  56. package/esm/ui/Field.svelte +9 -8
  57. package/esm/ui/Field.svelte.d.ts +2 -2
  58. package/esm/ui/FieldGroup.svelte +5 -3
  59. package/esm/ui/FieldGroup.svelte.d.ts +4 -4
  60. package/esm/ui/Grid.svelte.d.ts +5 -5
  61. package/esm/ui/GridPaginate.svelte +3 -6
  62. package/esm/ui/Icon.svelte +6 -7
  63. package/esm/ui/LibIcon.js +0 -2
  64. package/esm/ui/dialog/DialogForm.svelte +5 -6
  65. package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +2 -2
  66. package/esm/ui/dialog/FormEditAction.svelte.d.ts +2 -2
  67. package/esm/ui/dialog/dialog.d.ts +7 -5
  68. package/esm/ui/dialog/dialog.js +1 -0
  69. package/esm/ui/index.d.ts +2 -2
  70. package/esm/ui/internals/FieldContainer.svelte +1 -1
  71. package/esm/ui/internals/Input.svelte +1 -1
  72. package/esm/ui/internals/select/MultiSelectMelt.svelte +16 -19
  73. package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +3 -3
  74. package/esm/ui/internals/select/SelectMelt.svelte +10 -14
  75. package/esm/ui/internals/select/SelectMelt.svelte.d.ts +3 -3
  76. package/esm/ui/internals/select/SelectRadio.svelte.d.ts +2 -2
  77. package/esm/ui/link/LinkPlus.svelte.d.ts +2 -2
  78. package/esm/utils/types.d.ts +0 -15
  79. package/esm/utils/types.js +1 -17
  80. package/esm/virtual/Customer.js +2 -2
  81. package/esm/virtual/FilterEntity.js +1 -1
  82. package/esm/virtual/StateDemoEnum.d.ts +4 -4
  83. package/esm/virtual/StateDemoEnum.js +2 -2
  84. package/esm/virtual/UIEntity.js +4 -4
  85. package/esm/vite/index.js +1 -1
  86. package/package.json +10 -5
  87. package/esm/SqlDatabase/LogToConsoleCustom.d.ts +0 -1
  88. package/esm/auth/RoleController.js +0 -57
  89. package/esm/auth/static/assets/Page-BMFREPjF.d.ts +0 -5
  90. package/esm/auth/static/assets/Page-BMFREPjF.js +0 -18
  91. package/esm/auth/static/assets/index-CKmKKRRL.js +0 -2
  92. package/esm/kitCellsBuildor.d.ts +0 -45
  93. /package/esm/auth/static/assets/{index-CKmKKRRL.d.ts → index-czJ1PA1n.d.ts} +0 -0
package/esm/auth/index.js CHANGED
@@ -3,21 +3,22 @@ import { DEV } from 'esm-env';
3
3
  import { Lucia, TimeSpan } from 'lucia';
4
4
  import { remult } from 'remult';
5
5
  import { Log, red } from '@kitql/helpers';
6
- import { read } from '@kitql/internals';
7
- import { KitRole } from '../';
6
+ import { getRelativePackagePath, read } from '@kitql/internals';
7
+ import { env } from '$env/dynamic/private';
8
+ import { FF_Role } from '../';
8
9
  import { RemultLuciaAdapter } from './Adapter';
9
- import { AuthController } from './AuthController';
10
- import { AuthProvider, KitAuthAccount, KitAuthRole, KitAuthUser, KitAuthUserSession, } from './Entities';
10
+ import { AuthControllerServer } from './AuthController.server';
11
+ import { Auth } from './client';
12
+ import { FF_Auth_Role, FFAuthAccount, FFAuthProvider, FFAuthUser, FFAuthUserSession, } from './Entities';
11
13
  import { createSession } from './helper';
12
- import { RoleController } from './RoleController';
13
- export { KitAuthUser, KitAuthAccount, AuthProvider, KitAuthUserSession } from './Entities';
14
- export { AuthController } from './AuthController';
14
+ import { initRoleFromEnv } from './RoleHelpers';
15
+ export { FFAuthUser, FFAuthAccount, FFAuthProvider, FFAuthUserSession };
15
16
  export const logAuth = new Log('firstly | auth');
16
- export { KitAuthRole } from './Entities';
17
+ export { FF_Auth_Role } from './Entities';
17
18
  export let AUTH_OPTIONS = {};
18
19
  export const getSafeOptions = () => {
19
20
  const signUp = AUTH_OPTIONS.signUp ?? true;
20
- const base = AUTH_OPTIONS.ui === false ? 'NO_BASE_PATH' : AUTH_OPTIONS.ui?.paths?.base ?? '/kit/auth';
21
+ const base = AUTH_OPTIONS.ui === false ? 'NO_BASE_PATH' : AUTH_OPTIONS.ui?.paths?.base ?? '/ff/auth';
21
22
  const oAuths = AUTH_OPTIONS.providers?.oAuths?.map((o) => {
22
23
  return o.name;
23
24
  }) ?? [];
@@ -59,9 +60,9 @@ export const getSafeOptions = () => {
59
60
  redirectUrl = '/';
60
61
  }
61
62
  return {
62
- User: AUTH_OPTIONS.customEntities?.User ?? KitAuthUser,
63
- Session: AUTH_OPTIONS.customEntities?.Session ?? KitAuthUserSession,
64
- Account: AUTH_OPTIONS.customEntities?.Account ?? KitAuthAccount,
63
+ User: AUTH_OPTIONS.customEntities?.User ?? FFAuthUser,
64
+ Session: AUTH_OPTIONS.customEntities?.Session ?? FFAuthUserSession,
65
+ Account: AUTH_OPTIONS.customEntities?.Account ?? FFAuthAccount,
65
66
  signUp,
66
67
  password_enabled: AUTH_OPTIONS.providers?.password ? true : false,
67
68
  otp_enabled: AUTH_OPTIONS.providers?.otp ? true : false,
@@ -77,11 +78,22 @@ export const getSafeOptions = () => {
77
78
  export const auth = (o) => {
78
79
  AUTH_OPTIONS = o;
79
80
  const oSafe = getSafeOptions();
81
+ // abstract the call
82
+ Auth.signOutFn = AuthControllerServer.signOut;
83
+ Auth.signInDemoFn = AuthControllerServer.signInDemo;
84
+ Auth.inviteFn = AuthControllerServer.invite;
85
+ Auth.signUpPasswordFn = AuthControllerServer.signUpPassword;
86
+ Auth.signInPasswordFn = AuthControllerServer.signInPassword;
87
+ Auth.forgotPasswordFn = AuthControllerServer.forgotPassword;
88
+ Auth.resetPasswordFn = AuthControllerServer.resetPassword;
89
+ Auth.signInOTPFn = AuthControllerServer.signInOTP;
90
+ Auth.verifyOtpFn = AuthControllerServer.verifyOtp;
91
+ Auth.signInOAuthGetUrlFn = AuthControllerServer.signInOAuthGetUrl;
80
92
  return {
81
93
  name: 'auth',
82
94
  index: -777,
83
95
  entities: [oSafe.User, oSafe.Session, oSafe.Account],
84
- controllers: [AuthController],
96
+ controllers: [Auth],
85
97
  initRequest: async (event) => {
86
98
  // std session
87
99
  const sessionId = event.cookies.get(lucia.sessionCookieName);
@@ -103,15 +115,13 @@ export const auth = (o) => {
103
115
  }
104
116
  const oSafe = getSafeOptions();
105
117
  if (event.url.pathname === oSafe.firstlyData.props.ui.providers.password.paths.verify_email) {
106
- // TODO need to verify the token and set the verifiedAt in the database and we are good.
107
- // It's 2 minutes, but I'll be it later :D
108
118
  const token = event.url.searchParams.get('token') ?? '';
109
119
  if (!oSafe.password_enabled) {
110
120
  throw Error('Password is not enabled!');
111
121
  }
112
122
  const account = await remult
113
123
  .repo(oSafe.Account)
114
- .findFirst({ token, provider: AuthProvider.PASSWORD.id });
124
+ .findFirst({ token, provider: FFAuthProvider.PASSWORD.id });
115
125
  if (!account) {
116
126
  throw new Error('Invalid token');
117
127
  }
@@ -127,9 +137,15 @@ export const auth = (o) => {
127
137
  await createSession(account.userId);
128
138
  redirect(302, oSafe.redirectUrl);
129
139
  }
140
+ // For lib author (us), it's good to have this local path.
141
+ let staticPath = './src/lib/auth/static/';
142
+ // For users, let's serve the static files from the installed package
143
+ const installedFirstlyPath = getRelativePackagePath('firstly');
144
+ if (installedFirstlyPath) {
145
+ staticPath = `${installedFirstlyPath}/esm/auth/static/`;
146
+ }
130
147
  if (event.url.pathname.startsWith(oSafe.firstlyData.props.ui.paths.base)) {
131
- const content = read('src/lib/auth/static/index.html') ??
132
- read('node_modules/firstly/esm/auth/static/index.html');
148
+ const content = read(`${staticPath}index.html`);
133
149
  return {
134
150
  early: true,
135
151
  resolve: new Response(content + `<script>const firstlyData = ${JSON.stringify(oSafe.firstlyData)}</script>`, {
@@ -138,7 +154,7 @@ export const auth = (o) => {
138
154
  };
139
155
  }
140
156
  if (event.url.pathname.startsWith('/api/static')) {
141
- const content = read(`src/lib/auth/static/${event.url.pathname.replaceAll('/api/static/', '')}`);
157
+ const content = read(`${staticPath}${event.url.pathname.replaceAll('/api/static/', '')}`);
142
158
  if (content) {
143
159
  const seg = event.url.pathname.split('.');
144
160
  const map = {
@@ -238,8 +254,8 @@ export const auth = (o) => {
238
254
  return { early: false };
239
255
  },
240
256
  initApi: async () => {
241
- await RoleController.initRoleFromEnv(logAuth, oSafe.User, 'KIT_ADMIN', KitRole.Admin);
242
- await RoleController.initRoleFromEnv(logAuth, oSafe.User, 'KIT_AUTH_ADMIN', KitAuthRole.Admin);
257
+ await initRoleFromEnv(logAuth, oSafe.User, env.FF_ADMIN, FF_Role.Admin);
258
+ await initRoleFromEnv(logAuth, oSafe.User, env.FF_AUTH_ADMIN, FF_Auth_Role.Admin);
243
259
  },
244
260
  };
245
261
  };
@@ -1,25 +1,30 @@
1
1
  import { GitHub } from 'arctic';
2
- import { type KitOAuth2Provider } from '../';
2
+ import { type FFOAuth2Provider } from '../';
3
3
  /**
4
- * GitHub OAuth2 provider
4
+ * ## GitHub OAuth2 provider
5
5
  *
6
- * In GitHub, set your callback url to
7
- * - dev: `http://localhost:5173/api/auth_callback`
8
- * - prod: `https://MY_SUPER_SITE/api/auth_callback`
9
- *
10
- * In your project add a `.env` file with the following:
11
- *
12
- * ```env
13
- * GITHUB_CLIENT_ID= 'your-client-id'
14
- * GITHUB_CLIENT_SECRET= 'your-client-secret'
6
+ * 1. Get your **id** & **secret** from [GitHub (direct link)](https://github.com/settings/developers).
7
+ * 2. In GitHub, set your callback url to
8
+ * - [ ] dev: `http://localhost:5173/api/auth_callback`
9
+ * - [ ] prod: `https://MY_SUPER_SITE/api/auth_callback`
10
+ * 3. In your project add a `.env` file with the following:
11
+ * ```bash
12
+ * GITHUB_CLIENT_ID = 'your-client-id'
13
+ * GITHUB_CLIENT_SECRET = 'your-client-secret'
14
+ * # GITHUB_REDIRECT_URI = '' # optional, will default to "${origin}/api/auth_callback"
15
15
  * ```
16
- *
17
- * _FYI: GITHUB_REDIRECT_URI is optional as auth module will default to "${origin}/api/auth_callback"._
16
+ * 4. In your frontend, under a button click call something like:
17
+ * ```ts
18
+ * async function oauth() {
19
+ * window.location.href = await Auth.signInOAuthGetUrl({ provider: 'github', redirect: window.location.pathname })
20
+ * }
21
+ * ```
22
+ * 5. Enjoy 🥳
18
23
  */
19
24
  export declare function github(options?: {
20
- GITHUB_CLIENT_ID: string;
21
- GITHUB_CLIENT_SECRET: string;
25
+ GITHUB_CLIENT_ID?: string;
26
+ GITHUB_CLIENT_SECRET?: string;
22
27
  GITHUB_REDIRECT_URI?: string;
23
- authorizationURLOptions?: ReturnType<KitOAuth2Provider<'github', GitHub>['authorizationURLOptions']>;
28
+ authorizationURLOptions?: ReturnType<FFOAuth2Provider<'github', GitHub>['authorizationURLOptions']>;
24
29
  log?: boolean;
25
- }): KitOAuth2Provider<'github', GitHub>;
30
+ }): FFOAuth2Provider<'github', GitHub>;
@@ -1,34 +1,48 @@
1
1
  import { GitHub } from 'arctic';
2
2
  import { remult } from 'remult';
3
+ import { env } from '$env/dynamic/private';
3
4
  import { checkOAuthConfig } from '.';
4
5
  import { logAuth } from '../';
6
+ //------------------------------
7
+ // For developers (future me ?), To do another OAuth2 provider:
8
+ // Replace GITHUB / Github / github
9
+ // update "https://github.com/settings/developers" to the correct URL (2 places)
10
+ // update "https://api.github.com/user" the fetch user info
11
+ //------------------------------
5
12
  /**
6
- * GitHub OAuth2 provider
13
+ * ## GitHub OAuth2 provider
7
14
  *
8
- * In GitHub, set your callback url to
9
- * - dev: `http://localhost:5173/api/auth_callback`
10
- * - prod: `https://MY_SUPER_SITE/api/auth_callback`
11
- *
12
- * In your project add a `.env` file with the following:
13
- *
14
- * ```env
15
- * GITHUB_CLIENT_ID= 'your-client-id'
16
- * GITHUB_CLIENT_SECRET= 'your-client-secret'
15
+ * 1. Get your **id** & **secret** from [GitHub (direct link)](https://github.com/settings/developers).
16
+ * 2. In GitHub, set your callback url to
17
+ * - [ ] dev: `http://localhost:5173/api/auth_callback`
18
+ * - [ ] prod: `https://MY_SUPER_SITE/api/auth_callback`
19
+ * 3. In your project add a `.env` file with the following:
20
+ * ```bash
21
+ * GITHUB_CLIENT_ID = 'your-client-id'
22
+ * GITHUB_CLIENT_SECRET = 'your-client-secret'
23
+ * # GITHUB_REDIRECT_URI = '' # optional, will default to "${origin}/api/auth_callback"
17
24
  * ```
18
- *
19
- * _FYI: GITHUB_REDIRECT_URI is optional as auth module will default to "${origin}/api/auth_callback"._
25
+ * 4. In your frontend, under a button click call something like:
26
+ * ```ts
27
+ * async function oauth() {
28
+ * window.location.href = await Auth.signInOAuthGetUrl({ provider: 'github', redirect: window.location.pathname })
29
+ * }
30
+ * ```
31
+ * 5. Enjoy 🥳
20
32
  */
21
33
  export function github(options) {
22
34
  const name = 'github';
23
- const clientID = options?.GITHUB_CLIENT_ID ?? '';
24
- const secret = options?.GITHUB_CLIENT_SECRET ?? '';
35
+ const clientID = options?.GITHUB_CLIENT_ID ?? env.GITHUB_CLIENT_ID ?? '';
36
+ const secret = options?.GITHUB_CLIENT_SECRET ?? env.GITHUB_CLIENT_SECRET ?? '';
25
37
  const urlForKeys = 'https://github.com/settings/developers';
26
38
  checkOAuthConfig(name, clientID, secret, urlForKeys, false);
27
39
  return {
28
40
  name,
29
41
  isPKCE: false,
30
42
  getArcticProvider: () => {
31
- const redirectURI = options?.GITHUB_REDIRECT_URI || `${remult.context.url.origin}/api/auth_callback`;
43
+ const redirectURI = options?.GITHUB_REDIRECT_URI ??
44
+ env.GITHUB_REDIRECT_URI ??
45
+ `${remult.context.url.origin}/api/auth_callback`;
32
46
  checkOAuthConfig(name, clientID, secret, urlForKeys, true);
33
47
  return new GitHub(clientID, secret, { redirectURI });
34
48
  },
@@ -1,25 +1,30 @@
1
1
  import { Strava } from 'arctic';
2
- import { type KitOAuth2Provider } from '../';
2
+ import { type FFOAuth2Provider } from '../';
3
3
  /**
4
- * Strava OAuth2 provider
4
+ * ## Strava OAuth2 provider
5
5
  *
6
- * In Strava, set your callback url to
7
- * - dev: `http://localhost:5173/api/auth_callback`
8
- * - prod: `https://MY_SUPER_SITE/api/auth_callback`
9
- *
10
- * In your project add a `.env` file with the following:
11
- *
12
- * ```env
13
- * STRAVA_CLIENT_ID= 'your-client-id'
14
- * STRAVA_CLIENT_SECRET= 'your-client-secret'
6
+ * 1. Get your **id** & **secret** from [Strava (direct link)](https://www.strava.com/settings/api).
7
+ * 2. In Strava, set your callback url to
8
+ * - [ ] dev: `http://localhost:5173/api/auth_callback`
9
+ * - [ ] prod: `https://MY_SUPER_SITE/api/auth_callback`
10
+ * 3. In your project add a `.env` file with the following:
11
+ * ```bash
12
+ * STRAVA_CLIENT_ID = 'your-client-id'
13
+ * STRAVA_CLIENT_SECRET = 'your-client-secret'
14
+ * # STRAVA_REDIRECT_URI = '' # optional, will default to "${origin}/api/auth_callback"
15
15
  * ```
16
- *
17
- * _FYI: STRAVA_REDIRECT_URI is optional as auth module will default to "${origin}/api/auth_callback"._
16
+ * 4. In your frontend, under a button click call something like:
17
+ * ```ts
18
+ * async function oauth() {
19
+ * window.location.href = await Auth.signInOAuthGetUrl({ provider: 'strava', redirect: window.location.pathname })
20
+ * }
21
+ * ```
22
+ * 5. Enjoy 🥳
18
23
  */
19
24
  export declare function strava(options?: {
20
- STRAVA_CLIENT_ID: string;
21
- STRAVA_CLIENT_SECRET: string;
25
+ STRAVA_CLIENT_ID?: string;
26
+ STRAVA_CLIENT_SECRET?: string;
22
27
  STRAVA_REDIRECT_URI?: string;
23
- authorizationURLOptions?: ReturnType<KitOAuth2Provider<'strava', Strava>['authorizationURLOptions']>;
28
+ authorizationURLOptions?: ReturnType<FFOAuth2Provider<'strava', Strava>['authorizationURLOptions']>;
24
29
  log?: boolean;
25
- }): KitOAuth2Provider<'strava', Strava>;
30
+ }): FFOAuth2Provider<'strava', Strava>;
@@ -1,34 +1,42 @@
1
1
  import { Strava } from 'arctic';
2
2
  import { remult } from 'remult';
3
+ import { env } from '$env/dynamic/private';
3
4
  import { checkOAuthConfig } from '.';
4
5
  import { logAuth } from '../';
5
6
  /**
6
- * Strava OAuth2 provider
7
+ * ## Strava OAuth2 provider
7
8
  *
8
- * In Strava, set your callback url to
9
- * - dev: `http://localhost:5173/api/auth_callback`
10
- * - prod: `https://MY_SUPER_SITE/api/auth_callback`
11
- *
12
- * In your project add a `.env` file with the following:
13
- *
14
- * ```env
15
- * STRAVA_CLIENT_ID= 'your-client-id'
16
- * STRAVA_CLIENT_SECRET= 'your-client-secret'
9
+ * 1. Get your **id** & **secret** from [Strava (direct link)](https://www.strava.com/settings/api).
10
+ * 2. In Strava, set your callback url to
11
+ * - [ ] dev: `http://localhost:5173/api/auth_callback`
12
+ * - [ ] prod: `https://MY_SUPER_SITE/api/auth_callback`
13
+ * 3. In your project add a `.env` file with the following:
14
+ * ```bash
15
+ * STRAVA_CLIENT_ID = 'your-client-id'
16
+ * STRAVA_CLIENT_SECRET = 'your-client-secret'
17
+ * # STRAVA_REDIRECT_URI = '' # optional, will default to "${origin}/api/auth_callback"
17
18
  * ```
18
- *
19
- * _FYI: STRAVA_REDIRECT_URI is optional as auth module will default to "${origin}/api/auth_callback"._
19
+ * 4. In your frontend, under a button click call something like:
20
+ * ```ts
21
+ * async function oauth() {
22
+ * window.location.href = await Auth.signInOAuthGetUrl({ provider: 'strava', redirect: window.location.pathname })
23
+ * }
24
+ * ```
25
+ * 5. Enjoy 🥳
20
26
  */
21
27
  export function strava(options) {
22
28
  const name = 'strava';
23
- const clientID = options?.STRAVA_CLIENT_ID ?? '';
24
- const secret = options?.STRAVA_CLIENT_SECRET ?? '';
29
+ const clientID = options?.STRAVA_CLIENT_ID ?? env.STRAVA_CLIENT_ID ?? '';
30
+ const secret = options?.STRAVA_CLIENT_SECRET ?? env.STRAVA_CLIENT_SECRET ?? '';
25
31
  const urlForKeys = 'https://www.strava.com/settings/api';
26
32
  checkOAuthConfig(name, clientID, secret, urlForKeys, false);
27
33
  return {
28
34
  name,
29
35
  isPKCE: false,
30
36
  getArcticProvider: () => {
31
- const redirectURI = options?.STRAVA_REDIRECT_URI || `${remult.context.url.origin}/api/auth_callback`;
37
+ const redirectURI = options?.STRAVA_REDIRECT_URI ??
38
+ env.STRAVA_REDIRECT_URI ??
39
+ `${remult.context.url.origin}/api/auth_callback`;
32
40
  checkOAuthConfig(name, clientID, secret, urlForKeys, true);
33
41
  return new Strava(clientID, secret, redirectURI);
34
42
  },
@@ -2,4 +2,4 @@ export { d as default };
2
2
  declare class d extends o {
3
3
  constructor(t: any);
4
4
  }
5
- import { S as o } from "./index-CKmKKRRL.js";
5
+ import { S as o } from "./index-czJ1PA1n.js";
@@ -1 +1 @@
1
- import{S as o,b as r,a as i,H as l,d as c,n as a,k as f}from"./index-CKmKKRRL.js";function m(s){let t;return{c(){t=l("Hello from admin")},m(e,n){c(e,t,n)},p:a,i:a,o:a,d(e){e&&f(t)}}}class d extends o{constructor(t){super(),r(this,t,null,m,i,{})}}export{d as default};
1
+ import{S as o,b as r,a as i,H as l,d as c,n as a,k as f}from"./index-czJ1PA1n.js";function m(s){let t;return{c(){t=l("Hello from admin")},m(e,n){c(e,t,n)},p:a,i:a,o:a,d(e){e&&f(t)}}}class d extends o{constructor(t){super(),r(this,t,null,m,i,{})}}export{d as default};
@@ -0,0 +1,5 @@
1
+ export { oo as default };
2
+ declare class oo extends Je {
3
+ constructor(e: any);
4
+ }
5
+ import { S as Je } from './index-czJ1PA1n.js';