nitro-web 0.3.25 → 0.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/use-fetch.ts
CHANGED
|
@@ -39,7 +39,7 @@ export function useFetchDoc<T>(endpoint?: string, queryString?: string) {
|
|
|
39
39
|
|
|
40
40
|
/** Fetches a collection */
|
|
41
41
|
export function useFetchCol<T>(endpoint?: string, queryString?: string) {
|
|
42
|
-
return useFetchResource<T>(endpoint, queryString) as CollectionReturn<T>
|
|
42
|
+
return useFetchResource<T>(endpoint, queryString || '') as CollectionReturn<T>
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/** Fetches a shared collection (e.g. options), which is cached on the store */
|
|
@@ -12,6 +12,8 @@ import { isArray, pick, ucFirst, fullNameSplit, isEmail } from 'nitro-web/util'
|
|
|
12
12
|
// Todo: detect if the user is already invited to the company, instead of token error
|
|
13
13
|
|
|
14
14
|
const JWT_SECRET = process.env.JWT_SECRET || 'replace_this_with_secure_env_secret'
|
|
15
|
+
const resetMaxAge = 1000 * 60 * 60 * 48 // 48 hours
|
|
16
|
+
const inviteMaxAge = 1000 * 60 * 60 * 24 * 182 // 6 months
|
|
15
17
|
let authConfig = null
|
|
16
18
|
const resolveBaseUrlWarned = new Set()
|
|
17
19
|
const requiredConfigKeys = [...requiredEmailConfigKeys]
|
|
@@ -31,7 +33,7 @@ export const routes = {
|
|
|
31
33
|
'post /api/signin': [signin], // [todo: route gaurd basic limiter]
|
|
32
34
|
'post /api/signup': [signup], // [todo: route gaurd Altcha]
|
|
33
35
|
'post /api/reset-instructions': [resetInstructions],
|
|
34
|
-
'post /api/reset-confirm': [resetConfirm], // was reset-password
|
|
36
|
+
'post /api/reset-confirm/:token': [resetConfirm], // was reset-password
|
|
35
37
|
'post /api/invite-instructions': [inviteInstructions],
|
|
36
38
|
'post /api/resend-instructions': [resendInstructions],
|
|
37
39
|
'get /api/invite-pre-confirm/:token': [invitePreConfirm],
|
|
@@ -555,7 +557,7 @@ export function tokenCreate(modelName, id) {
|
|
|
555
557
|
})
|
|
556
558
|
}
|
|
557
559
|
|
|
558
|
-
export function tokenParse(token, modelName, maxAgeMs =
|
|
560
|
+
export function tokenParse(token, modelName, maxAgeMs = resetMaxAge) {
|
|
559
561
|
let [hash, modelNameParsed, id, time] = (token || '').split(':')
|
|
560
562
|
if (!hash || !id || !time) {
|
|
561
563
|
throw { title: 'error', detail: 'Sorry your code is invalid.' }
|
|
@@ -597,7 +599,7 @@ export async function tokenConfirmForSingleTenant(req, isReset) {
|
|
|
597
599
|
const { password, password2, ...userData } = req.body
|
|
598
600
|
const tokenName = isReset ? 'resetToken' : 'inviteToken'
|
|
599
601
|
const desktop = req.query.desktop
|
|
600
|
-
const _id = db.id(auth.tokenParse(token, 'user'))
|
|
602
|
+
const _id = db.id(auth.tokenParse(token, 'user', isReset ? resetMaxAge : inviteMaxAge))
|
|
601
603
|
await auth.passwordValidate(password, password2)
|
|
602
604
|
|
|
603
605
|
// Find the inviteToken, but bypass hooks because inviteToken may = true in a potential afterFind hook.
|
|
@@ -622,7 +624,7 @@ export async function tokenConfirmForSingleTenant(req, isReset) {
|
|
|
622
624
|
export async function tokenConfirmForMultiTenant(req) {
|
|
623
625
|
const token = req.params.token
|
|
624
626
|
const desktop = req.query.desktop
|
|
625
|
-
const companyId = db.id(auth.tokenParse(token, 'company'))
|
|
627
|
+
const companyId = db.id(auth.tokenParse(token, 'company', inviteMaxAge))
|
|
626
628
|
|
|
627
629
|
// Find the invite (we need to bypass hooks as inviteToken maybe true in an afterFind hook)
|
|
628
630
|
const company = await db.company._findOne({ _id: companyId, 'invites.inviteToken': token }, { projection: { invites: 1, users: 1 } })
|
|
@@ -65,7 +65,6 @@ export function ResetPassword({ className, elements, redirectTo, config }: reset
|
|
|
65
65
|
const [state, setState] = useState(() => ({
|
|
66
66
|
password: '',
|
|
67
67
|
password2: '',
|
|
68
|
-
token: params.token,
|
|
69
68
|
errors: [] as Errors,
|
|
70
69
|
}))
|
|
71
70
|
|
|
@@ -77,7 +76,7 @@ export function ResetPassword({ className, elements, redirectTo, config }: reset
|
|
|
77
76
|
async function onSubmit (event: React.FormEvent<HTMLFormElement>) {
|
|
78
77
|
try {
|
|
79
78
|
if (isLoading) return
|
|
80
|
-
const data = await request(
|
|
79
|
+
const data = await request(`post /api/reset-confirm/${params.token}`, state, event, setIsLoading, setState)
|
|
81
80
|
setStore((s) => ({ ...getSignoutStoreFn(s, getInitialStore()), ...data }))
|
|
82
81
|
setTimeout(() => navigate(redirectTo || '/'), 10) // wait for setStore
|
|
83
82
|
} catch (e) {
|
|
@@ -70,7 +70,7 @@ export function Table<T extends TableRow>({
|
|
|
70
70
|
addOverflowScroll,
|
|
71
71
|
checkboxSize=16,
|
|
72
72
|
columnGap=11,
|
|
73
|
-
columnPaddingX=
|
|
73
|
+
columnPaddingX=20,
|
|
74
74
|
generateCheckboxActions,
|
|
75
75
|
headerHeightMin=40,
|
|
76
76
|
rowContentHeightMax,
|
|
@@ -166,11 +166,11 @@ export function Table<T extends TableRow>({
|
|
|
166
166
|
|
|
167
167
|
const getColumnPadding = useCallback((j: number, row: T|undefined, rowType: TableRowType) => {
|
|
168
168
|
const sideColor = j == 0 && rowSideColor ? rowSideColor(row, rowType) : undefined
|
|
169
|
-
|
|
170
|
-
const pl =
|
|
171
|
-
const pr = j == columns.length - 1 ? columnPaddingX : columnGap
|
|
169
|
+
// Checkboxes and actions sit tighter to the edge, a side color needs the full padding
|
|
170
|
+
const pl = j == 0 && (columns[j].value != 'checkbox' || sideColor) ? columnPaddingX : columnGap
|
|
171
|
+
const pr = j == columns.length - 1 && columns[j].value != 'actions' ? columnPaddingX : columnGap
|
|
172
172
|
return { pl, pr, sideColor }
|
|
173
|
-
}, [rowSideColor, columnPaddingX, columnGap])
|
|
173
|
+
}, [rowSideColor, columnPaddingX, columnGap, columns]) // columns recently added as a dependency, maybe keep an eye on this
|
|
174
174
|
|
|
175
175
|
return (
|
|
176
176
|
<div className={className}>
|
|
@@ -296,7 +296,7 @@ export function Table<T extends TableRow>({
|
|
|
296
296
|
style={{ maxHeight: rowContentHeightMax }}
|
|
297
297
|
className={twMerge(
|
|
298
298
|
rowContentHeightMax ? 'overflow-hidden' : '',
|
|
299
|
-
getLineClampClassName(col.rowLinesMax),
|
|
299
|
+
col.value == 'checkbox' ? '' : getLineClampClassName(col.rowLinesMax), // clamping clips the checkbox hitbox
|
|
300
300
|
col.overflow ? 'overflow-visible' : '',
|
|
301
301
|
col.innerClassName
|
|
302
302
|
)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-web",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.27",
|
|
4
4
|
"repository": "github:boycce/nitro-web",
|
|
5
5
|
"homepage": "https://boycce.github.io/nitro-web/",
|
|
6
6
|
"description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"passport-jwt": "^4.0.1",
|
|
58
58
|
"passport-local": "^1.0.0",
|
|
59
59
|
"sort-route-addresses-nodeps": "0.0.4",
|
|
60
|
-
"standard-version": "github:boycce/standard-version",
|
|
61
60
|
"tailwind-merge": "^2.6.0",
|
|
62
61
|
"tldts": "^7.0.30"
|
|
63
62
|
},
|
|
64
63
|
"devDependencies": {
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "^8.18.1"
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^8.18.1",
|
|
65
|
+
"standard-version": "github:boycce/standard-version"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@stripe/stripe-js": "^1.34.0",
|
|
@@ -115,7 +115,7 @@ export const routes: {
|
|
|
115
115
|
'post /api/signin': (typeof signin)[];
|
|
116
116
|
'post /api/signup': (typeof signup)[];
|
|
117
117
|
'post /api/reset-instructions': (typeof resetInstructions)[];
|
|
118
|
-
'post /api/reset-confirm': (typeof resetConfirm)[];
|
|
118
|
+
'post /api/reset-confirm/:token': (typeof resetConfirm)[];
|
|
119
119
|
'post /api/invite-instructions': (typeof inviteInstructions)[];
|
|
120
120
|
'post /api/resend-instructions': (typeof resendInstructions)[];
|
|
121
121
|
'get /api/invite-pre-confirm/:token': (typeof invitePreConfirm)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.api.d.ts","sourceRoot":"","sources":["../../../components/auth/auth.api.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.api.d.ts","sourceRoot":"","sources":["../../../components/auth/auth.api.js"],"names":[],"mappings":"AAuLA,qEAUC;AAED,qEAwEC;AAED,qEAGC;AAED,gEAMC;AAED,iEAgBC;AAED,oEAGC;AAED,oEA8BC;AAED,gEAgCC;AAID,qGAkDC;AAED;;;GAOC;AAED;;GAKC;AAED;;;;GAIG;AACH,qCAHW,MAAM,GACJ,MAAM,GAAC,SAAS,CAI5B;AAID;;;;;;;;;GASG;AACH,8EAPG;IAA0B,QAAQ,GAA1B,MAAM;IACY,SAAS,GAA3B,MAAM;IACY,OAAO,GAAzB,MAAM;CACd,YAAQ,MAAM,+BACN,OAAO,GACL,OAAO,CAAC,MAAM,CAAC,CAqE3B;AAED,kFAiBC;AAED,mEAOC;AAED,+EAWC;AAED,sHAiBC;AAED;;;GAEC;AAED;;;GA0BC;AAED;;;;;;;;;GAmCC;AAED;;;;;;;;;;;;;;GAcG;AACH,mGAZG;IAAsD,IAAI,EAAlD,OAAO,GAAG,QAAQ,GAAG,eAAe;IACpB,EAAE,EAAlB,MAAM;IAKH,OAAO,EAJV;QACN,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QACtB,CAAK,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB;IAC0B,YAAY;IACZ,eAAe;IACjB,OAAO,GAAxB,MAAM;CACd,GAAU,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;CAAC,CAAC,CAmEtE;AAED,0CAEC;AAED,8DA8BC;AAED,gFAKC;;;;;;;;;;;;;;;;;;;;AAnvBD;;;;;;;;;;;;;;;EAiBC;AA0ED,0DAEC;AAgCD,mDAEC;AAtBD,iDAkBC;AA5BD,2DAQC;AA0BD,2DAwBC;AAtID,0EAsEC"}
|