-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add user prop to Layout; title to totp issuer (#64)
- Loading branch information
1 parent
23ff7ee
commit fe28be5
Showing
11 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"gboost-common": minor | ||
--- | ||
|
||
- Add `mergeDeep` utility function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"gboost-ui": minor | ||
--- | ||
|
||
- Optional user prop for Layout | ||
- Authenticator updates TOTP issuer with title by default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./convertCase.js"; | ||
export * from "./user-management.js"; | ||
export * from "./mergeDeep.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Simple object check. | ||
* @param item | ||
* @returns {boolean} | ||
*/ | ||
export function isObject(item: object | undefined): boolean | undefined { | ||
return item && typeof item === "object" && !Array.isArray(item); | ||
} | ||
|
||
/** | ||
* Deep merge two objects. | ||
* @param target | ||
* @param ...sources | ||
* @link https://stackoverflow.com/a/34749873/9658768 | ||
*/ | ||
export function mergeDeep(target: object, ...sources: object[]): object { | ||
if (!sources.length) return target; | ||
const source = sources.shift(); | ||
|
||
if (isObject(target) && isObject(source)) { | ||
for (const key in source) { | ||
const typedKey = key as keyof typeof source; | ||
if (isObject(source[typedKey])) { | ||
if (!target[typedKey]) Object.assign(target, { [typedKey]: {} }); | ||
mergeDeep(target[typedKey], source[typedKey]); | ||
} else { | ||
Object.assign(target, { [key]: source[typedKey] }); | ||
} | ||
} | ||
} | ||
|
||
return mergeDeep(target, ...sources); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters