diff --git a/package-lock.json b/package-lock.json index 14bf48c..01fb29c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2613,6 +2613,19 @@ "dev": true, "license": "MIT" }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -2820,6 +2833,278 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar-cli": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chokidar-cli/-/chokidar-cli-3.0.0.tgz", + "integrity": "sha512-xVW+Qeh7z15uZRxHOkP93Ux8A0xbPzwK4GaqD8dQOYc34TlkqUhVSS59fK36DOp5WdJlrRzlYSy02Ht99FjZqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^3.5.2", + "lodash.debounce": "^4.0.8", + "lodash.throttle": "^4.1.1", + "yargs": "^13.3.0" + }, + "bin": { + "chokidar": "index.js" + }, + "engines": { + "node": ">= 8.10.0" + } + }, + "node_modules/chokidar-cli/node_modules/ansi-regex": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/chokidar-cli/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chokidar-cli/node_modules/cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, + "node_modules/chokidar-cli/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/chokidar-cli/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true, + "license": "MIT" + }, + "node_modules/chokidar-cli/node_modules/emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true, + "license": "MIT" + }, + "node_modules/chokidar-cli/node_modules/find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/chokidar-cli/node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/chokidar-cli/node_modules/locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/chokidar-cli/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chokidar-cli/node_modules/p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/chokidar-cli/node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/chokidar-cli/node_modules/string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/chokidar-cli/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/chokidar-cli/node_modules/wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/chokidar-cli/node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/chokidar-cli/node_modules/yargs": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.2" + } + }, + "node_modules/chokidar-cli/node_modules/yargs-parser": { + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", + "dev": true, + "license": "ISC", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/ci-info": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", @@ -3092,6 +3377,16 @@ } } }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/decimal.js": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", @@ -4845,6 +5140,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/is-boolean-object": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.0.tgz", @@ -6194,6 +6502,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash.debounce": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -6208,6 +6523,13 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash.throttle": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", + "integrity": "sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==", + "dev": true, + "license": "MIT" + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -7150,6 +7472,32 @@ "dev": true, "license": "MIT" }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/readdirp/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/reflect.getprototypeof": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.7.tgz", @@ -7228,6 +7576,13 @@ "node": ">=0.10.0" } }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true, + "license": "ISC" + }, "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", @@ -7497,6 +7852,13 @@ "randombytes": "^2.1.0" } }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "dev": true, + "license": "ISC" + }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", @@ -8646,6 +9008,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", + "dev": true, + "license": "ISC" + }, "node_modules/which-typed-array": { "version": "1.1.16", "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.16.tgz", @@ -8853,6 +9222,7 @@ "@types/jest": "^29.5.12", "@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/parser": "^7.18.0", + "chokidar-cli": "^3.0.0", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-import-resolver-typescript": "^3.6.3", diff --git a/packages/auth0-acul-js/.eslintrc.json b/packages/auth0-acul-js/.eslintrc.json index 46cfdaa..0b15609 100644 --- a/packages/auth0-acul-js/.eslintrc.json +++ b/packages/auth0-acul-js/.eslintrc.json @@ -33,7 +33,6 @@ "@typescript-eslint/explicit-function-return-type": "error", "@typescript-eslint/no-non-null-assertion": "error", "@typescript-eslint/no-misused-promises": "error", - // TODO: enable all the following "off" "@typescript-eslint/no-explicit-any": "error", "@typescript-eslint/strict-boolean-expressions": "error", "@typescript-eslint/no-unsafe-member-access": "error", @@ -42,7 +41,8 @@ "import/order": [ "error", { - "groups": ["builtin", "external", "internal"], + "groups": ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"], + "newlines-between": "always", "alphabetize": { "order": "asc", "caseInsensitive": true } } ], diff --git a/packages/auth0-acul-js/interfaces/common/index.ts b/packages/auth0-acul-js/interfaces/common/index.ts index ed18bc9..9a9fcc3 100644 --- a/packages/auth0-acul-js/interfaces/common/index.ts +++ b/packages/auth0-acul-js/interfaces/common/index.ts @@ -1,3 +1,3 @@ export interface CustomOptions { [key: string]: string | number | boolean; -} \ No newline at end of file +} diff --git a/packages/auth0-acul-js/interfaces/export/base-properties.ts b/packages/auth0-acul-js/interfaces/export/base-properties.ts index c4540e9..6016871 100644 --- a/packages/auth0-acul-js/interfaces/export/base-properties.ts +++ b/packages/auth0-acul-js/interfaces/export/base-properties.ts @@ -6,4 +6,4 @@ export type { OrganizationMembers } from '../models/organization'; export type { ScreenMembers } from '../models/screen'; export type { TenantMembers } from '../models/tenant'; export type { TransactionMembers } from '../models/transaction'; -export type { UntrustedDataMembers } from '../models/untrusted-data'; \ No newline at end of file +export type { UntrustedDataMembers } from '../models/untrusted-data'; diff --git a/packages/auth0-acul-js/interfaces/export/common.ts b/packages/auth0-acul-js/interfaces/export/common.ts index 83a7910..5a27de2 100644 --- a/packages/auth0-acul-js/interfaces/export/common.ts +++ b/packages/auth0-acul-js/interfaces/export/common.ts @@ -1,9 +1,3 @@ export type { CaptchaContext } from '../models/screen'; export type { Connection, EnterpriseConnection, PasswordPolicy, UsernamePolicy, Error } from '../models/transaction'; export type { BrandingSettings, BrandingThemes } from '../models/branding'; - - - - - - diff --git a/packages/auth0-acul-js/interfaces/export/extended-types.ts b/packages/auth0-acul-js/interfaces/export/extended-types.ts index 1bca56d..2130da6 100644 --- a/packages/auth0-acul-js/interfaces/export/extended-types.ts +++ b/packages/auth0-acul-js/interfaces/export/extended-types.ts @@ -1,6 +1,9 @@ export type { ScreenMembersOnLoginId, TransactionMembersOnLoginId } from '../screens/login-id'; export type { ScreenMembersOnLoginPassword, TransactionMembersOnLoginPassword } from '../screens/login-password'; -export type { ScreenMembersOnLoginPasswordlessEmailCode, TransactionMembersOnLoginPasswordlessEmailCode } from '../screens/login-passwordless-email-code'; +export type { + ScreenMembersOnLoginPasswordlessEmailCode, + TransactionMembersOnLoginPasswordlessEmailCode, +} from '../screens/login-passwordless-email-code'; export type { ScreenMembersOnLoginPasswordlessSmsOtp, TransactionMembersOnLoginPasswordlessSmsOtp } from '../screens/login-passwordless-sms-otp'; export type { ScreenMembersOnPasskeyEnrollment } from '../screens/passkey-enrollment'; export type { ScreenMembersOnPasskeyEnrollmentLocal } from '../screens/passkey-enrollment-local'; @@ -8,4 +11,4 @@ export type { ScreenMembersOnEmailIdentifierChallenge } from '../screens/email-i export type { ScreenMembersOnPhoneIdentifierChallenge } from '../screens/phone-identifier-challenge'; export type { ScreenMembersOnPhoneIdentifierEnrollment } from '../screens/phone-identifier-enrollment'; export type { ScreenMembersOnSignupId, TransactionMembersOnSignupId } from '../screens/signup-id'; -export type { ScreenMembersOnSignupPassword, TransactionMembersOnSignupPassword} from '../screens/signup-password'; \ No newline at end of file +export type { ScreenMembersOnSignupPassword, TransactionMembersOnSignupPassword } from '../screens/signup-password'; diff --git a/packages/auth0-acul-js/interfaces/export/options.ts b/packages/auth0-acul-js/interfaces/export/options.ts index 3e10428..9134572 100644 --- a/packages/auth0-acul-js/interfaces/export/options.ts +++ b/packages/auth0-acul-js/interfaces/export/options.ts @@ -9,4 +9,4 @@ export type { PhoneChallengeOptions } from '../screens/phone-identifier-challeng export type { PhoneEnrollmentOptions } from '../screens/phone-identifier-enrollment'; export type { SignupOptions, SocialSignupOptions } from '../screens/signup-id'; export type { SignupPasswordOptions } from '../screens/signup-password'; -export type { CustomOptions } from '../common'; \ No newline at end of file +export type { CustomOptions } from '../common'; diff --git a/packages/auth0-acul-js/interfaces/index.ts b/packages/auth0-acul-js/interfaces/index.ts index 4f76162..eba70ec 100644 --- a/packages/auth0-acul-js/interfaces/index.ts +++ b/packages/auth0-acul-js/interfaces/index.ts @@ -2,4 +2,4 @@ export * as Base from './export/base-properties'; export * as Screen from './export/screen-properties'; export * as Payload from './export/options'; export * as Extended from './export/extended-types'; -export * as Common from './export/common'; \ No newline at end of file +export * as Common from './export/common'; diff --git a/packages/auth0-acul-js/interfaces/models/branding.ts b/packages/auth0-acul-js/interfaces/models/branding.ts index 59b9f71..2a4da2c 100644 --- a/packages/auth0-acul-js/interfaces/models/branding.ts +++ b/packages/auth0-acul-js/interfaces/models/branding.ts @@ -2,12 +2,14 @@ export interface BrandingContext { settings?: { colors?: { primary?: string; - page_background?: string | { - type: string; - start: string; - end: string; - angle_deg: number; - }; + page_background?: + | string + | { + type: string; + start: string; + end: string; + angle_deg: number; + }; }; favicon_url?: string; logo_url?: string; @@ -25,24 +27,26 @@ export interface BrandingContext { widget: Record; }; }; -}; +} export interface BrandingSettings { colors?: { primary?: string; - pageBackground?: string | { - type: string; - start: string; - end: string; - angleDeg: number; - }; + pageBackground?: + | string + | { + type: string; + start: string; + end: string; + angleDeg: number; + }; }; faviconUrl?: string; logoUrl?: string; fontUrl?: string; -}; +} -export interface BrandingThemes{ +export interface BrandingThemes { default: { borders: Record; colors: Record; @@ -51,8 +55,7 @@ export interface BrandingThemes{ pageBackground: Record; widget: Record; }; -}; - +} /* @namespace Client */ export interface BrandingMembers { diff --git a/packages/auth0-acul-js/interfaces/models/organization.ts b/packages/auth0-acul-js/interfaces/models/organization.ts index 3b9500b..b837b59 100644 --- a/packages/auth0-acul-js/interfaces/models/organization.ts +++ b/packages/auth0-acul-js/interfaces/models/organization.ts @@ -20,14 +20,12 @@ export interface OrganizationMembers { name: string | null; usage: string | null; displayName: string | null; - branding: - | { - logoUrl?: string | undefined; - colors?: { - primary?: string | undefined; - pageBackground?: string; - }; - } - | null; + branding: { + logoUrl?: string | undefined; + colors?: { + primary?: string | undefined; + pageBackground?: string; + }; + } | null; metadata: { [key: string]: string } | null; } diff --git a/packages/auth0-acul-js/interfaces/models/screen.ts b/packages/auth0-acul-js/interfaces/models/screen.ts index 191259a..126fe33 100644 --- a/packages/auth0-acul-js/interfaces/models/screen.ts +++ b/packages/auth0-acul-js/interfaces/models/screen.ts @@ -2,13 +2,13 @@ export interface CaptchaContext { provider: string; image?: string; siteKey?: string; -}; +} export interface PasskeyRead { public_key: { challenge: string; }; -}; +} export interface PasskeyCreate { public_key: { @@ -22,16 +22,18 @@ export interface PasskeyCreate { name: string; }; challenge: string; - pubKeyCredParams: [{ - type: string, - alg: number - }]; + pubKeyCredParams: [ + { + type: string; + alg: number; + }, + ]; authenticatorSelection: { residentKey: string; userVerification: string; }; }; -}; +} export interface ScreenData { [key: string]: string | PasskeyRead | PasskeyCreate | undefined; @@ -41,9 +43,9 @@ export interface ScreenContext { name: string; links?: Record; captcha?: CaptchaContext; - data?: ScreenData + data?: ScreenData; texts?: Record; -}; +} export interface ScreenMembers { name: string; @@ -55,4 +57,4 @@ export interface ScreenMembers { links: Record | null; texts: Record | null; captcha: CaptchaContext | null; -} \ No newline at end of file +} diff --git a/packages/auth0-acul-js/interfaces/models/transaction.ts b/packages/auth0-acul-js/interfaces/models/transaction.ts index 6cfb02b..49774d1 100644 --- a/packages/auth0-acul-js/interfaces/models/transaction.ts +++ b/packages/auth0-acul-js/interfaces/models/transaction.ts @@ -8,11 +8,11 @@ export interface Passkey { enabled: boolean; } -export interface PasskeyLogin extends Passkey{ +export interface PasskeyLogin extends Passkey { public_key: { challenge: ArrayBuffer; }; -}; +} export interface PasskeyEnroll extends Passkey { public_key: { @@ -26,21 +26,23 @@ export interface PasskeyEnroll extends Passkey { name: string; }; challenge: ArrayBuffer; - pubKeyCredParams: [{ - type: string, - alg: Number - }]; + pubKeyCredParams: [ + { + type: string; + alg: number; + }, + ]; authenticatorSelection: { residentKey: string; userVerification: string; }; }; -}; +} interface CountryCode { code: string; prefix: string; -}; +} export interface UsernamePolicy { maxLength: number; @@ -48,7 +50,7 @@ export interface UsernamePolicy { allowedFormats: { usernameInEmailFormat: boolean; usernameInPhoneFormat: boolean; - } + }; } export interface PasswordPolicy { @@ -91,7 +93,7 @@ export interface DBConnection extends Connection { }; }; }; -}; +} export interface PasswordlessConnection extends Connection { options: { @@ -105,7 +107,7 @@ export interface EnterpriseConnectionContext extends Connection { display_name?: string; show_as_button: boolean; }; -}; +} export interface EnterpriseConnection extends Connection { options: { @@ -113,7 +115,7 @@ export interface EnterpriseConnection extends Connection { displayName?: string; showAsButton: boolean; }; -}; +} export interface SocialConnection extends Connection {} @@ -128,7 +130,7 @@ export interface TransactionContext { locale: string; errors?: Error[]; country_code?: CountryCode; - connection: DBConnection | PasswordlessConnection; + connection?: DBConnection | PasswordlessConnection; alternate_connections?: (Connection | EnterpriseConnectionContext)[]; } diff --git a/packages/auth0-acul-js/interfaces/models/untrusted-data.ts b/packages/auth0-acul-js/interfaces/models/untrusted-data.ts index 85a86fd..945597b 100644 --- a/packages/auth0-acul-js/interfaces/models/untrusted-data.ts +++ b/packages/auth0-acul-js/interfaces/models/untrusted-data.ts @@ -12,7 +12,7 @@ export interface UntrustedDataContext { } export interface UntrustedDataMembers { - submittedFormData: { [key: string]: any } | null; + submittedFormData: { [key: string]: string | number | boolean | undefined } | null; authorizationParams: { login_hint?: string; screen_hint?: string; diff --git a/packages/auth0-acul-js/interfaces/screens/email-identifier-challenge.ts b/packages/auth0-acul-js/interfaces/screens/email-identifier-challenge.ts index ba32f4d..206e45f 100644 --- a/packages/auth0-acul-js/interfaces/screens/email-identifier-challenge.ts +++ b/packages/auth0-acul-js/interfaces/screens/email-identifier-challenge.ts @@ -1,6 +1,6 @@ -import { CustomOptions } from '../common'; +import type { CustomOptions } from '../common'; import type { BaseMembers } from '../models/base-context'; -import { ScreenMembers } from '../models/screen'; +import type { ScreenMembers } from '../models/screen'; export interface EmailChallengeOptions { code: string; diff --git a/packages/auth0-acul-js/interfaces/screens/login-id.ts b/packages/auth0-acul-js/interfaces/screens/login-id.ts index 0e52b3b..9428594 100644 --- a/packages/auth0-acul-js/interfaces/screens/login-id.ts +++ b/packages/auth0-acul-js/interfaces/screens/login-id.ts @@ -1,4 +1,4 @@ -import { CustomOptions } from '../common'; +import type { CustomOptions } from '../common'; import type { BaseContext, BaseMembers } from '../models/base-context'; import type { ScreenContext, ScreenMembers, PasskeyRead } from '../models/screen'; import type { TransactionMembers, UsernamePolicy } from '../models/transaction'; @@ -12,7 +12,7 @@ export interface ExtendedScreenContext extends ScreenContext { data?: { passkey?: PasskeyRead; - } + }; } export interface ExtendedUntrustedDataContext extends UntrustedDataContext { diff --git a/packages/auth0-acul-js/interfaces/screens/login-passwordless-email-code.ts b/packages/auth0-acul-js/interfaces/screens/login-passwordless-email-code.ts index fe6535d..3d52eb5 100644 --- a/packages/auth0-acul-js/interfaces/screens/login-passwordless-email-code.ts +++ b/packages/auth0-acul-js/interfaces/screens/login-passwordless-email-code.ts @@ -1,8 +1,7 @@ -import { CustomOptions } from '../common'; +import type { TransactionMembers } from '../../interfaces/models'; +import type { BaseMembers } from '../../interfaces/models/base-context'; import type { ScreenMembers } from '../../interfaces/models/screen'; -import { BaseMembers } from '../../interfaces/models/base-context'; -import { TransactionMembers } from '../../interfaces/models'; - +import type { CustomOptions } from '../common'; export interface ScreenMembersOnLoginPasswordlessEmailCode extends ScreenMembers { editIdentifierLink: string | null; diff --git a/packages/auth0-acul-js/interfaces/screens/login-passwordless-sms-otp.ts b/packages/auth0-acul-js/interfaces/screens/login-passwordless-sms-otp.ts index e2ceb37..150d52d 100644 --- a/packages/auth0-acul-js/interfaces/screens/login-passwordless-sms-otp.ts +++ b/packages/auth0-acul-js/interfaces/screens/login-passwordless-sms-otp.ts @@ -1,6 +1,6 @@ -import { CustomOptions } from '../common'; +import type { TransactionMembers } from '../../interfaces/models/transaction'; +import type { CustomOptions } from '../common'; import type { ScreenMembers, ScreenContext } from '../models/screen'; -import { TransactionMembers } from '../../interfaces/models/transaction'; export interface ScreenContextOnLoginPasswordlessSmsOtp extends ScreenContext { links: { @@ -15,7 +15,7 @@ export interface ScreenMembersOnLoginPasswordlessSmsOtp extends ScreenMembers { backLink: string | null; data: { username: string; - } + }; } export interface TransactionMembersOnLoginPasswordlessSmsOtp extends TransactionMembers { diff --git a/packages/auth0-acul-js/interfaces/screens/passkey-enrollment-local.ts b/packages/auth0-acul-js/interfaces/screens/passkey-enrollment-local.ts index 58bd7a7..7b82f2e 100644 --- a/packages/auth0-acul-js/interfaces/screens/passkey-enrollment-local.ts +++ b/packages/auth0-acul-js/interfaces/screens/passkey-enrollment-local.ts @@ -1,4 +1,4 @@ -import { CustomOptions } from '../common'; +import type { CustomOptions } from '../common'; import type { BaseContext, BaseMembers } from '../models/base-context'; import type { ScreenContext, PasskeyCreate, ScreenMembers } from '../models/screen'; @@ -9,7 +9,7 @@ export interface ExtendedScreenContext extends ScreenContext { payload: { passkeys: PasskeyCreate; - } + }; } export interface PasskeyEnrollmentLocal extends BaseContext { @@ -29,4 +29,4 @@ export interface PasskeyEnrollmentLocalMembers extends BaseMembers { screen: ScreenMembersOnPasskeyEnrollmentLocal; continuePasskeyEnrollment(payload?: CustomOptions): Promise; abortPasskeyEnrollment(payload: AbortEnrollmentOptions): Promise; -} \ No newline at end of file +} diff --git a/packages/auth0-acul-js/interfaces/screens/passkey-enrollment.ts b/packages/auth0-acul-js/interfaces/screens/passkey-enrollment.ts index 7031ef5..76a75f5 100644 --- a/packages/auth0-acul-js/interfaces/screens/passkey-enrollment.ts +++ b/packages/auth0-acul-js/interfaces/screens/passkey-enrollment.ts @@ -1,6 +1,6 @@ -import { CustomOptions } from '../common'; +import type { CustomOptions } from '../common'; import type { BaseContext, BaseMembers } from '../models/base-context'; -import type { ScreenContext, PasskeyCreate, ScreenMembers, PasskeyRead } from '../models/screen'; +import type { ScreenContext, PasskeyCreate, ScreenMembers } from '../models/screen'; export interface ExtendedScreenContext extends ScreenContext { links: { @@ -9,7 +9,7 @@ export interface ExtendedScreenContext extends ScreenContext { data: { passkeys: PasskeyCreate; - } + }; } export interface PasskeyEnrollment extends BaseContext { @@ -26,4 +26,4 @@ export interface PasskeyEnrollmentMembers extends BaseMembers { screen: ScreenMembersOnPasskeyEnrollment; continuePasskeyEnrollment(payload?: CustomOptions): Promise; abortPasskeyEnrollment(payload?: CustomOptions): Promise; -} \ No newline at end of file +} diff --git a/packages/auth0-acul-js/interfaces/screens/phone-identifier-challenge.ts b/packages/auth0-acul-js/interfaces/screens/phone-identifier-challenge.ts index b41fbcc..2317935 100644 --- a/packages/auth0-acul-js/interfaces/screens/phone-identifier-challenge.ts +++ b/packages/auth0-acul-js/interfaces/screens/phone-identifier-challenge.ts @@ -1,4 +1,4 @@ -import { CustomOptions } from '../common'; +import type { CustomOptions } from '../common'; import type { BaseMembers } from '../models/base-context'; import type { ScreenContext, ScreenMembers, ScreenData } from '../models/screen'; @@ -28,7 +28,7 @@ export interface ScreenMembersOnPhoneIdentifierChallenge extends ScreenMembers { } export interface PhoneIdentifierChallengeMembers extends BaseMembers { - screen: ScreenMembersOnPhoneIdentifierChallenge + screen: ScreenMembersOnPhoneIdentifierChallenge; submitPhoneChallenge(payload: PhoneChallengeOptions): Promise; resendCode(payload?: CustomOptions): Promise; returnToPrevious(payload?: CustomOptions): Promise; diff --git a/packages/auth0-acul-js/interfaces/screens/phone-identifier-enrollment.ts b/packages/auth0-acul-js/interfaces/screens/phone-identifier-enrollment.ts index 3fcdebc..59c4caa 100644 --- a/packages/auth0-acul-js/interfaces/screens/phone-identifier-enrollment.ts +++ b/packages/auth0-acul-js/interfaces/screens/phone-identifier-enrollment.ts @@ -1,4 +1,4 @@ -import { CustomOptions } from '../common'; +import type { CustomOptions } from '../common'; import type { BaseMembers } from '../models/base-context'; import type { ScreenData, ScreenMembers } from '../models/screen'; @@ -21,7 +21,7 @@ export interface PhoneEnrollmentOptions { } export interface PhoneIdentifierEnrollmentMembers extends BaseMembers { - screen: ScreenMembersOnPhoneIdentifierEnrollment, + screen: ScreenMembersOnPhoneIdentifierEnrollment; continuePhoneEnrollment(payload: PhoneEnrollmentOptions): Promise; returnToPrevious(payload?: CustomOptions): Promise; } diff --git a/packages/auth0-acul-js/interfaces/screens/signup-id.ts b/packages/auth0-acul-js/interfaces/screens/signup-id.ts index 1ee09fb..3057fb6 100644 --- a/packages/auth0-acul-js/interfaces/screens/signup-id.ts +++ b/packages/auth0-acul-js/interfaces/screens/signup-id.ts @@ -1,7 +1,7 @@ import type { BaseContext } from '../models/base-context'; import type { ScreenContext, ScreenMembers } from '../models/screen'; -import type { UntrustedDataContext } from '../models/untrusted-data'; import type { TransactionMembers, UsernamePolicy } from '../models/transaction'; +import type { UntrustedDataContext } from '../models/untrusted-data'; interface ExtendedScreenContext extends ScreenContext { links: { @@ -51,5 +51,5 @@ export interface SignupIdMembers { screen: ScreenMembersOnSignupId; transaction: TransactionMembersOnSignupId; signup(payload: SignupOptions): Promise; - socialSignup(payload: SocialSignupOptions): Promise; + socialSignup(payload: SocialSignupOptions): Promise; } diff --git a/packages/auth0-acul-js/interfaces/screens/signup-password.ts b/packages/auth0-acul-js/interfaces/screens/signup-password.ts index 7f8c3ff..5324f47 100644 --- a/packages/auth0-acul-js/interfaces/screens/signup-password.ts +++ b/packages/auth0-acul-js/interfaces/screens/signup-password.ts @@ -1,6 +1,6 @@ import type { BaseContext, BaseMembers } from '../models/base-context'; import type { ScreenContext, ScreenMembers } from '../models/screen'; -import type { TransactionContext, PasswordPolicy, TransactionMembers } from '../models/transaction'; +import type { PasswordPolicy, TransactionMembers } from '../models/transaction'; export interface ScreenContextOnSignupPassword extends ScreenContext { links: { @@ -45,7 +45,7 @@ export interface SignupPasswordOptions { [key: string]: string | number | boolean | undefined; } -export interface SignupPasswordMembers extends BaseMembers{ +export interface SignupPasswordMembers extends BaseMembers { screen: ScreenMembersOnSignupPassword; transaction: TransactionMembersOnSignupPassword; signup(payload: SignupPasswordOptions): Promise; diff --git a/packages/auth0-acul-js/interfaces/utils/passkeys.ts b/packages/auth0-acul-js/interfaces/utils/passkeys.ts index 82c5f28..3941f71 100644 --- a/packages/auth0-acul-js/interfaces/utils/passkeys.ts +++ b/packages/auth0-acul-js/interfaces/utils/passkeys.ts @@ -25,4 +25,3 @@ export interface PasskeyCreateResponse { authenticatorAttachment: string | null; response: CredentialResponse; } - diff --git a/packages/auth0-acul-js/package.json b/packages/auth0-acul-js/package.json index 72164d0..20291e8 100644 --- a/packages/auth0-acul-js/package.json +++ b/packages/auth0-acul-js/package.json @@ -59,15 +59,19 @@ }, "scripts": { "clean": "rimraf dist", - "build": "npm run clean && npm run lint:screens && npm run test && npm run docs && rollup -c rollup.config.js --bundleConfigAsCjs", + "build": "npm run clean && npm run lint && npm run test && npm run docs && rollup -c rollup.config.js --bundleConfigAsCjs", "test": "jest --verbose tests/unit/**/*", "test:e2e": "cypress open", "docs": "typedoc --options typedoc.json", - "lint": "eslint 'src/**/*.{js,ts,tsx}'", - "lint:screens": "eslint 'src/screens/*' --config .eslintrc.json", - "lint:screens:fix": "eslint 'src/screens/*' --config .eslintrc.json --fix", - "lint:fix": "eslint 'src/**/*.{js,ts,tsx}' --fix", - "format": "prettier --write 'src/**/*.{js,ts,tsx,json,css,md}'" + "lint": "npm run lint:interfaces && npm run lint:src", + "lint:src": "eslint 'src/**/*.{js,ts}' --config .eslintrc.json", + "lint:interfaces": "eslint 'interfaces/**/*.ts' --config .eslintrc.json", + "lint:src:fix": "eslint 'src/**/*.{js,ts}' --config .eslintrc.json --fix", + "lint:interfaces:fix": "eslint 'interfaces/**/*.ts' --config .eslintrc.json --fix", + "lint:watch": "chokidar 'src/**/*.{js,ts}' 'interfaces/**/*.ts' -c 'npm run lint'", + "format:src": "prettier --write 'src/**/*.{js,ts,tsx,json,css,md}'", + "format:interfaces": "prettier --write 'src/**/*.{js,ts,tsx,json,css,md}'", + "format": "npm run format:src && npm run format:interfaces" }, "author": "Auth0", "license": "MIT", @@ -90,7 +94,6 @@ "README.md", "LICENSE" ], - "devDependencies": { "@rollup/plugin-alias": "^5.1.1", "@rollup/plugin-node-resolve": "^15.3.0", @@ -103,6 +106,7 @@ "@types/jest": "^29.5.12", "@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/parser": "^7.18.0", + "chokidar-cli": "^3.0.0", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-import-resolver-typescript": "^3.6.3", diff --git a/packages/auth0-acul-js/src/models/base-context.ts b/packages/auth0-acul-js/src/models/base-context.ts index 0a6acef..7908dbe 100644 --- a/packages/auth0-acul-js/src/models/base-context.ts +++ b/packages/auth0-acul-js/src/models/base-context.ts @@ -1,3 +1,5 @@ +import { Branding, Client, Prompt, Screen, Organization, User, Transaction, Tenant, UntrustedData } from '../models'; + import type { ClientMembers, PromptMembers, @@ -11,8 +13,6 @@ import type { } from '../../interfaces/models'; import type { BaseContext as UniversalLoginContext, BaseMembers } from '../../interfaces/models/base-context'; -import { Branding, Client, Prompt, Screen, Organization, User, Transaction, Tenant, UntrustedData } from '../models'; - export class BaseContext implements BaseMembers { branding: BrandingMembers; screen: ScreenMembers; @@ -28,11 +28,16 @@ export class BaseContext implements BaseMembers { constructor() { if (!BaseContext.context) { - BaseContext.context = (window as any).universal_login_context as UniversalLoginContext; + const globalWindow = window as unknown as { universal_login_context?: UniversalLoginContext }; + BaseContext.context = globalWindow.universal_login_context ?? null; } const context = BaseContext.context; + if (!context) { + throw new Error('Universal Login Context is not available on the global window object.'); + } + this.branding = new Branding(context.branding); this.screen = new Screen(context.screen); this.tenant = new Tenant(context.tenant); @@ -47,7 +52,12 @@ export class BaseContext implements BaseMembers { /** @ignore */ getContext(model: K): UniversalLoginContext[K] | undefined { if (!BaseContext.context) { - BaseContext.context = (window as any).universal_login_context as UniversalLoginContext; + const globalWindow = window as unknown as { universal_login_context?: UniversalLoginContext }; + BaseContext.context = globalWindow.universal_login_context ?? null; + } + + if (!BaseContext.context) { + return undefined; } return BaseContext.context[model]; diff --git a/packages/auth0-acul-js/src/models/branding.ts b/packages/auth0-acul-js/src/models/branding.ts index 8895c63..d20ae47 100644 --- a/packages/auth0-acul-js/src/models/branding.ts +++ b/packages/auth0-acul-js/src/models/branding.ts @@ -1,7 +1,7 @@ import type { BrandingContext, BrandingMembers } from '../../interfaces/models/branding'; export class Branding implements BrandingMembers { - settings: BrandingMembers['settings']; + settings: BrandingMembers['settings']; themes: BrandingMembers['themes']; constructor(branding: BrandingContext | undefined) { @@ -29,14 +29,14 @@ export class Branding implements BrandingMembers { }, }, }), - ...(favicon_url ? { faviconUrl: favicon_url } : {}), - ...(logo_url ? { logoUrl: logo_url } : {}), - ...(font ? { fontUrl: font.url } : {}), + ...(typeof favicon_url === 'string' && favicon_url.length > 0 ? { faviconUrl: favicon_url } : {}), + ...(typeof logo_url === 'string' && logo_url.length > 0 ? { logoUrl: logo_url } : {}), + ...(typeof font?.url === 'string' && font.url.length > 0 ? { fontUrl: font.url } : {}), }; } static getThemes(branding: BrandingContext | undefined): BrandingMembers['themes'] { - if (!branding || !branding?.themes) return null; + if (!branding?.themes) return null; const { default: { borders = {}, colors = {}, displayName = '', fonts = {}, page_background: pageBackground = {}, widget = {} } = {} } = branding.themes; diff --git a/packages/auth0-acul-js/src/models/transaction.ts b/packages/auth0-acul-js/src/models/transaction.ts index 552d70b..6d6cd9b 100644 --- a/packages/auth0-acul-js/src/models/transaction.ts +++ b/packages/auth0-acul-js/src/models/transaction.ts @@ -13,7 +13,7 @@ export class Transaction implements TransactionMembers { constructor(transaction: TransactionContext) { this.state = transaction.state; - this.hasErrors = !!transaction.errors?.length; + this.hasErrors = !!(transaction.errors && transaction.errors.length > 0); this.locale = transaction.locale; this.countryCode = transaction.country_code?.code ?? null; this.countryPrefix = transaction.country_code?.prefix ?? null; @@ -24,19 +24,21 @@ export class Transaction implements TransactionMembers { } static getErrors(transaction: TransactionContext): TransactionMembers['errors'] { - if (!transaction.errors?.length) return null; + if (!transaction.errors || transaction.errors.length === 0) { + return null; + } - return transaction.errors.map((error) => { - return { - code: error.code, - field: error.field, - message: error.message, - }; - }); + return transaction.errors.map((error) => ({ + code: error.code, + field: error.field, + message: error.message, + })); } static getCurrentConnection(transaction: TransactionContext): TransactionMembers['currentConnection'] { - if (!transaction?.connection) return null; + if (!transaction?.connection) { + return null; + } const { name, strategy, metadata } = transaction.connection; return { @@ -47,8 +49,11 @@ export class Transaction implements TransactionMembers { } static getAlternateConnections(transaction: TransactionContext): TransactionMembers['alternateConnections'] { - const alternateConnections = transaction.alternate_connections; - if (!alternateConnections || !Array.isArray(alternateConnections)) return null; + const alternateConnections = transaction?.alternate_connections; + + if (!alternateConnections || !Array.isArray(alternateConnections)) { + return null; + } return alternateConnections.map((connection) => { const { name, strategy, metadata } = connection; diff --git a/packages/auth0-acul-js/src/screens/email-identifier-challenge/index.ts b/packages/auth0-acul-js/src/screens/email-identifier-challenge/index.ts index 6f947ba..13b6460 100644 --- a/packages/auth0-acul-js/src/screens/email-identifier-challenge/index.ts +++ b/packages/auth0-acul-js/src/screens/email-identifier-challenge/index.ts @@ -1,4 +1,8 @@ +import { BaseContext } from '../../models/base-context'; +import { FormHandler } from '../../utils/form-handler'; + import { ScreenOverride } from './screen-override'; + import type { CustomOptions } from '../../../interfaces/common'; import type { ScreenContext } from '../../../interfaces/models/screen'; import type { @@ -7,8 +11,6 @@ import type { ScreenMembersOnEmailIdentifierChallenge as ScreenOptions, } from '../../../interfaces/screens/email-identifier-challenge'; import type { FormOptions } from '../../../interfaces/utils/form-handler'; -import { BaseContext } from '../../models/base-context'; -import { FormHandler } from '../../utils/form-handler'; export default class EmailIdentifierChallenge extends BaseContext implements EmailIdentifierChallengeMembers { screen: ScreenOptions; @@ -64,8 +66,4 @@ export default class EmailIdentifierChallenge extends BaseContext implements Ema } } -export { - EmailIdentifierChallengeMembers, - EmailChallengeOptions, - ScreenOptions, -} +export { EmailIdentifierChallengeMembers, EmailChallengeOptions, ScreenOptions }; diff --git a/packages/auth0-acul-js/src/screens/email-identifier-challenge/screen-override.ts b/packages/auth0-acul-js/src/screens/email-identifier-challenge/screen-override.ts index 8d67119..3c1661a 100644 --- a/packages/auth0-acul-js/src/screens/email-identifier-challenge/screen-override.ts +++ b/packages/auth0-acul-js/src/screens/email-identifier-challenge/screen-override.ts @@ -1,6 +1,7 @@ +import { Screen } from '../../models/screen'; + import type { ScreenContext } from '../../../interfaces/models/screen'; import type { ScreenMembersOnEmailIdentifierChallenge as OverrideOptions } from '../../../interfaces/screens/email-identifier-challenge'; -import { Screen } from '../../models/screen'; export class ScreenOverride extends Screen implements OverrideOptions { constructor(screenContext: ScreenContext) { @@ -11,7 +12,7 @@ export class ScreenOverride extends Screen implements OverrideOptions { static getScreenData = (screenContext: ScreenContext): OverrideOptions['data'] => { const data = screenContext.data; if (!data) return null; - + return { ...data, email: data.email, diff --git a/packages/auth0-acul-js/src/screens/interstitial-captcha/index.ts b/packages/auth0-acul-js/src/screens/interstitial-captcha/index.ts index e338bf3..f753bd1 100644 --- a/packages/auth0-acul-js/src/screens/interstitial-captcha/index.ts +++ b/packages/auth0-acul-js/src/screens/interstitial-captcha/index.ts @@ -1,8 +1,9 @@ -import type { InterstitialCaptchaMembers, SubmitCaptchaOptions } from '../../../interfaces/screens/interstitial-captcha'; -import type { FormOptions } from '../../../interfaces/utils/form-handler'; import { BaseContext } from '../../models/base-context'; import { FormHandler } from '../../utils/form-handler'; +import type { InterstitialCaptchaMembers, SubmitCaptchaOptions } from '../../../interfaces/screens/interstitial-captcha'; +import type { FormOptions } from '../../../interfaces/utils/form-handler'; + export default class InterstitialCaptcha extends BaseContext implements InterstitialCaptchaMembers { constructor() { super(); @@ -13,7 +14,7 @@ export default class InterstitialCaptcha extends BaseContext implements Intersti * * @example * import InterstitialCaptcha from "@auth0/auth0-acul-js/interstitial-captcha"; - * + * * const interstitialCaptcha = new InterstitialCaptcha(); * interstitialCaptcha.submitCaptcha({ * captcha: "captchaValue", @@ -27,7 +28,4 @@ export default class InterstitialCaptcha extends BaseContext implements Intersti } } -export { - InterstitialCaptchaMembers, - SubmitCaptchaOptions -} +export { InterstitialCaptchaMembers, SubmitCaptchaOptions }; diff --git a/packages/auth0-acul-js/src/screens/login-id/index.ts b/packages/auth0-acul-js/src/screens/login-id/index.ts index 72f1f65..f654eda 100644 --- a/packages/auth0-acul-js/src/screens/login-id/index.ts +++ b/packages/auth0-acul-js/src/screens/login-id/index.ts @@ -1,5 +1,11 @@ +import { BaseContext } from '../../models/base-context'; +import { Errors } from '../../utils/errors'; +import { FormHandler } from '../../utils/form-handler'; +import { getPasskeyCredentials } from '../../utils/passkeys'; + import { ScreenOverride } from './screen-override'; import { TransactionOverride } from './transaction-override'; + import type { CustomOptions } from '../../../interfaces/common'; import type { ScreenContext } from '../../../interfaces/models/screen'; import type { TransactionContext } from '../../../interfaces/models/transaction'; @@ -11,10 +17,6 @@ import type { SocialLoginOptions, } from '../../../interfaces/screens/login-id'; import type { FormOptions } from '../../../interfaces/utils/form-handler'; -import { BaseContext } from '../../models/base-context'; -import { Errors } from '../../utils/errors'; -import { FormHandler } from '../../utils/form-handler'; -import { getPasskeyCredentials } from '../../utils/passkeys'; export default class LoginId extends BaseContext implements LoginIdMembers { screen: ScreenOptions; @@ -124,8 +126,4 @@ export default class LoginId extends BaseContext implements LoginIdMembers { } } -export { - LoginIdMembers, - LoginOptions, - SocialLoginOptions, -} +export { LoginIdMembers, LoginOptions, SocialLoginOptions }; diff --git a/packages/auth0-acul-js/src/screens/login-id/screen-override.ts b/packages/auth0-acul-js/src/screens/login-id/screen-override.ts index 6e4bc0f..6fa868c 100644 --- a/packages/auth0-acul-js/src/screens/login-id/screen-override.ts +++ b/packages/auth0-acul-js/src/screens/login-id/screen-override.ts @@ -1,8 +1,9 @@ -import type { ScreenContext } from '../../../interfaces/models/screen'; -import type { ScreenMembersOnLoginId as OverrideOptions } from '../../../interfaces/screens/login-id'; import { Screen } from '../../../src/models/screen'; import { getSignupLink, getResetPasswordLink, getPublicKey } from '../../shared/screen'; +import type { ScreenContext } from '../../../interfaces/models/screen'; +import type { ScreenMembersOnLoginId as OverrideOptions } from '../../../interfaces/screens/login-id'; + export class ScreenOverride extends Screen implements OverrideOptions { signupLink: OverrideOptions['signupLink']; resetPasswordLink: OverrideOptions['resetPasswordLink']; diff --git a/packages/auth0-acul-js/src/screens/login-id/transaction-override.ts b/packages/auth0-acul-js/src/screens/login-id/transaction-override.ts index c22ceff..94dfa5f 100644 --- a/packages/auth0-acul-js/src/screens/login-id/transaction-override.ts +++ b/packages/auth0-acul-js/src/screens/login-id/transaction-override.ts @@ -1,5 +1,3 @@ -import type { TransactionContext } from '../../../interfaces/models/transaction'; -import type { TransactionMembersOnLoginId as OverrideMembers } from '../../../interfaces/screens/login-id'; import { Transaction } from '../../../src/models/transaction'; import { isUsernameRequired, @@ -10,6 +8,9 @@ import { isPasskeyEnabled, } from '../../shared/transaction'; +import type { TransactionContext } from '../../../interfaces/models/transaction'; +import type { TransactionMembersOnLoginId as OverrideMembers } from '../../../interfaces/screens/login-id'; + export class TransactionOverride extends Transaction implements OverrideMembers { isSignupEnabled: OverrideMembers['isSignupEnabled']; isForgotPasswordEnabled: OverrideMembers['isForgotPasswordEnabled']; @@ -28,10 +29,7 @@ export class TransactionOverride extends Transaction implements OverrideMembers this.allowedIdentifiers = TransactionOverride.getAllowedIdentifiers(transactionContext, this.connectionStrategy); } - static getAllowedIdentifiers( - transactionContext: TransactionContext, - connectionStrategy: string | null - ): OverrideMembers['allowedIdentifiers'] { + static getAllowedIdentifiers(transactionContext: TransactionContext, connectionStrategy: string | null): OverrideMembers['allowedIdentifiers'] { if (connectionStrategy === 'sms') return ['phone']; if (connectionStrategy === 'email') return ['email']; return getAllowedIdentifiers(transactionContext); diff --git a/packages/auth0-acul-js/src/screens/login-password/index.ts b/packages/auth0-acul-js/src/screens/login-password/index.ts index c63efdb..0ca2617 100644 --- a/packages/auth0-acul-js/src/screens/login-password/index.ts +++ b/packages/auth0-acul-js/src/screens/login-password/index.ts @@ -1,5 +1,9 @@ +import { BaseContext } from '../../models/base-context'; +import { FormHandler } from '../../utils/form-handler'; + import { ScreenOverride } from './screen-override'; import { TransactionOverride } from './transaction-override'; + import type { ScreenContext } from '../../../interfaces/models/screen'; import type { TransactionContext } from '../../../interfaces/models/transaction'; import type { @@ -9,8 +13,6 @@ import type { TransactionMembersOnLoginPassword as TransactionOptions, } from '../../../interfaces/screens/login-password'; import type { FormOptions } from '../../../interfaces/utils/form-handler'; -import { BaseContext } from '../../models/base-context'; -import { FormHandler } from '../../utils/form-handler'; export default class LoginPassword extends BaseContext implements LoginPasswordMembers { screen: ScreenOptions; @@ -43,7 +45,4 @@ export default class LoginPassword extends BaseContext implements LoginPasswordM } } -export { - LoginPasswordMembers, - LoginPasswordOptions -} +export { LoginPasswordMembers, LoginPasswordOptions }; diff --git a/packages/auth0-acul-js/src/screens/login-password/screen-override.ts b/packages/auth0-acul-js/src/screens/login-password/screen-override.ts index 5c55de1..d74726f 100644 --- a/packages/auth0-acul-js/src/screens/login-password/screen-override.ts +++ b/packages/auth0-acul-js/src/screens/login-password/screen-override.ts @@ -1,8 +1,9 @@ -import type { ScreenContext } from '../../../interfaces/models/screen'; -import type { ScreenMembersOnLoginPassword as OverrideOptions } from '../../../interfaces/screens/login-password'; import { Screen } from '../../models/screen'; import { getSignupLink, getResetPasswordLink, getEditIdentifierLink } from '../../shared/screen'; +import type { ScreenContext } from '../../../interfaces/models/screen'; +import type { ScreenMembersOnLoginPassword as OverrideOptions } from '../../../interfaces/screens/login-password'; + export class ScreenOverride extends Screen implements OverrideOptions { signupLink: OverrideOptions['signupLink']; resetPasswordLink: OverrideOptions['resetPasswordLink']; diff --git a/packages/auth0-acul-js/src/screens/login-password/transaction-override.ts b/packages/auth0-acul-js/src/screens/login-password/transaction-override.ts index 55f4c7f..a711550 100644 --- a/packages/auth0-acul-js/src/screens/login-password/transaction-override.ts +++ b/packages/auth0-acul-js/src/screens/login-password/transaction-override.ts @@ -1,5 +1,3 @@ -import type { TransactionContext } from '../../../interfaces/models/transaction'; -import type { TransactionMembersOnLoginPassword as OverrideMembers } from '../../../interfaces/screens/login-password'; import { Transaction } from '../../models/transaction'; import { isSignupEnabled, @@ -10,6 +8,9 @@ import { getAllowedIdentifiers, } from '../../shared/transaction'; +import type { TransactionContext } from '../../../interfaces/models/transaction'; +import type { TransactionMembersOnLoginPassword as OverrideMembers } from '../../../interfaces/screens/login-password'; + export class TransactionOverride extends Transaction implements OverrideMembers { constructor(transactionContext: TransactionContext) { super(transactionContext); diff --git a/packages/auth0-acul-js/src/screens/login-passwordless-email-code/index.ts b/packages/auth0-acul-js/src/screens/login-passwordless-email-code/index.ts index 2a33845..393a5e7 100644 --- a/packages/auth0-acul-js/src/screens/login-passwordless-email-code/index.ts +++ b/packages/auth0-acul-js/src/screens/login-passwordless-email-code/index.ts @@ -1,5 +1,9 @@ +import { BaseContext } from '../../models/base-context'; +import { FormHandler } from '../../utils/form-handler'; + import { ScreenOverride } from './screen-override'; import { TransactionOverride } from './transaction-override'; + import type { CustomOptions } from '../../../interfaces/common'; import type { ScreenContext } from '../../../interfaces/models/screen'; import type { TransactionContext } from '../../../interfaces/models/transaction'; @@ -10,8 +14,6 @@ import type { SubmitCodeOptions, } from '../../../interfaces/screens/login-passwordless-email-code'; import type { FormOptions } from '../../../interfaces/utils/form-handler'; -import { BaseContext } from '../../models/base-context'; -import { FormHandler } from '../../utils/form-handler'; export default class LoginPasswordlessEmailCode extends BaseContext implements LoginPasswordlessEmailCodeMembers { screen: ScreenOptions; @@ -63,7 +65,4 @@ export default class LoginPasswordlessEmailCode extends BaseContext implements L } } -export { - LoginPasswordlessEmailCodeMembers, - SubmitCodeOptions -} +export { LoginPasswordlessEmailCodeMembers, SubmitCodeOptions }; diff --git a/packages/auth0-acul-js/src/screens/login-passwordless-email-code/screen-override.ts b/packages/auth0-acul-js/src/screens/login-passwordless-email-code/screen-override.ts index e90eda0..de9c433 100644 --- a/packages/auth0-acul-js/src/screens/login-passwordless-email-code/screen-override.ts +++ b/packages/auth0-acul-js/src/screens/login-passwordless-email-code/screen-override.ts @@ -1,8 +1,9 @@ -import type { ScreenContext } from '../../../interfaces/models/screen'; -import type { ScreenMembersOnLoginPasswordlessEmailCode as OverrideOptions } from '../../../interfaces/screens/login-passwordless-email-code'; import { Screen } from '../../models/screen'; import { getSignupLink, getResetPasswordLink, getEditIdentifierLink } from '../../shared/screen'; +import type { ScreenContext } from '../../../interfaces/models/screen'; +import type { ScreenMembersOnLoginPasswordlessEmailCode as OverrideOptions } from '../../../interfaces/screens/login-passwordless-email-code'; + export class ScreenOverride extends Screen implements OverrideOptions { signupLink: OverrideOptions['signupLink']; resetPasswordLink: OverrideOptions['resetPasswordLink']; diff --git a/packages/auth0-acul-js/src/screens/login-passwordless-email-code/transaction-override.ts b/packages/auth0-acul-js/src/screens/login-passwordless-email-code/transaction-override.ts index e927673..9039963 100644 --- a/packages/auth0-acul-js/src/screens/login-passwordless-email-code/transaction-override.ts +++ b/packages/auth0-acul-js/src/screens/login-passwordless-email-code/transaction-override.ts @@ -1,8 +1,9 @@ -import type { TransactionContext } from '../../../interfaces/models/transaction'; -import type { TransactionMembersOnLoginPasswordlessEmailCode as OverrideOptions } from '../../../interfaces/screens/login-passwordless-email-code'; import { Transaction } from '../../models/transaction'; import { isSignupEnabled } from '../../shared/transaction'; +import type { TransactionContext } from '../../../interfaces/models/transaction'; +import type { TransactionMembersOnLoginPasswordlessEmailCode as OverrideOptions } from '../../../interfaces/screens/login-passwordless-email-code'; + export class TransactionOverride extends Transaction implements OverrideOptions { isSignupEnabled: OverrideOptions['isSignupEnabled']; diff --git a/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/index.ts b/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/index.ts index 74268d9..f84bf6b 100644 --- a/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/index.ts +++ b/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/index.ts @@ -1,5 +1,9 @@ +import { BaseContext } from '../../models/base-context'; +import { FormHandler } from '../../utils/form-handler'; + import { ScreenOverride } from './screen-override'; import { TransactionOverride } from './transaction-override'; + import type { CustomOptions } from '../../../interfaces/common'; import type { ScreenContext } from '../../../interfaces/models/screen'; import type { TransactionContext } from '../../../interfaces/models/transaction'; @@ -10,8 +14,6 @@ import type { SubmitOTPOptions, } from '../../../interfaces/screens/login-passwordless-sms-otp'; import type { FormOptions } from '../../../interfaces/utils/form-handler'; -import { BaseContext } from '../../models/base-context'; -import { FormHandler } from '../../utils/form-handler'; export default class LoginPasswordlessSmsOtp extends BaseContext implements LoginPasswordlessSmsOtpMembers { screen: ScreenOptions; @@ -60,7 +62,4 @@ export default class LoginPasswordlessSmsOtp extends BaseContext implements Logi } } -export { - LoginPasswordlessSmsOtpMembers, - SubmitOTPOptions, -} +export { LoginPasswordlessSmsOtpMembers, SubmitOTPOptions }; diff --git a/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/screen-override.ts b/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/screen-override.ts index 404df1b..8312eb2 100644 --- a/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/screen-override.ts +++ b/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/screen-override.ts @@ -1,8 +1,9 @@ -import type { ScreenContext } from '../../../interfaces/models/screen'; -import type { ScreenMembersOnLoginPasswordlessSmsOtp as OverrideOptions } from '../../../interfaces/screens/login-passwordless-sms-otp'; import { Screen } from '../../models/screen'; import { getSignupLink, getResetPasswordLink, getBackLink } from '../../shared/screen'; +import type { ScreenContext } from '../../../interfaces/models/screen'; +import type { ScreenMembersOnLoginPasswordlessSmsOtp as OverrideOptions } from '../../../interfaces/screens/login-passwordless-sms-otp'; + export class ScreenOverride extends Screen implements OverrideOptions { signupLink: OverrideOptions['signupLink']; resetPasswordLink: OverrideOptions['resetPasswordLink']; @@ -15,5 +16,5 @@ export class ScreenOverride extends Screen implements OverrideOptions { this.resetPasswordLink = getResetPasswordLink(screenContext); this.backLink = getBackLink(screenContext); this.data = Screen.getScreenData(screenContext) as OverrideOptions['data']; - } + } } diff --git a/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/transaction-override.ts b/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/transaction-override.ts index 5bbbb79..6a48feb 100644 --- a/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/transaction-override.ts +++ b/packages/auth0-acul-js/src/screens/login-passwordless-sms-otp/transaction-override.ts @@ -1,8 +1,9 @@ -import type { TransactionContext } from '../../../interfaces/models/transaction'; -import type { TransactionMembersOnLoginPasswordlessSmsOtp as OverrideOptions } from '../../../interfaces/screens/login-passwordless-sms-otp'; import { Transaction } from '../../models/transaction'; import { isSignupEnabled } from '../../shared/transaction'; +import type { TransactionContext } from '../../../interfaces/models/transaction'; +import type { TransactionMembersOnLoginPasswordlessSmsOtp as OverrideOptions } from '../../../interfaces/screens/login-passwordless-sms-otp'; + export class TransactionOverride extends Transaction implements OverrideOptions { isSignupEnabled: OverrideOptions['isSignupEnabled']; diff --git a/packages/auth0-acul-js/src/screens/passkey-enrollment-local/index.ts b/packages/auth0-acul-js/src/screens/passkey-enrollment-local/index.ts index 560b0ae..7dcc53d 100644 --- a/packages/auth0-acul-js/src/screens/passkey-enrollment-local/index.ts +++ b/packages/auth0-acul-js/src/screens/passkey-enrollment-local/index.ts @@ -1,4 +1,9 @@ +import { BaseContext } from '../../models/base-context'; +import { FormHandler } from '../../utils/form-handler'; +import { createPasskeyCredentials } from '../../utils/passkeys'; + import { ScreenOverride } from './screen-override'; + import type { CustomOptions } from '../../../interfaces/common'; import type { ScreenContext } from '../../../interfaces/models/screen'; import type { @@ -7,9 +12,6 @@ import type { AbortEnrollmentOptions, } from '../../../interfaces/screens/passkey-enrollment-local'; import type { FormOptions } from '../../../interfaces/utils/form-handler'; -import { BaseContext } from '../../models/base-context'; -import { FormHandler } from '../../utils/form-handler'; -import { createPasskeyCredentials } from '../../utils/passkeys'; export default class PasskeyEnrollmentLocal extends BaseContext implements PasskeyEnrollmentLocalMembers { screen: ScreenOptions; @@ -62,7 +64,4 @@ export default class PasskeyEnrollmentLocal extends BaseContext implements Passk } } -export { - PasskeyEnrollmentLocalMembers, - AbortEnrollmentOptions -} +export { PasskeyEnrollmentLocalMembers, AbortEnrollmentOptions }; diff --git a/packages/auth0-acul-js/src/screens/passkey-enrollment-local/screen-override.ts b/packages/auth0-acul-js/src/screens/passkey-enrollment-local/screen-override.ts index 5955c22..ab65a08 100644 --- a/packages/auth0-acul-js/src/screens/passkey-enrollment-local/screen-override.ts +++ b/packages/auth0-acul-js/src/screens/passkey-enrollment-local/screen-override.ts @@ -1,8 +1,9 @@ -import type { ScreenContext } from '../../../interfaces/models/screen'; -import type { ScreenMembersOnPasskeyEnrollmentLocal as OverrideOptions } from '../../../interfaces/screens/passkey-enrollment-local'; import { Screen } from '../../models/screen'; import { getPublicKey } from '../../shared/screen'; +import type { ScreenContext } from '../../../interfaces/models/screen'; +import type { ScreenMembersOnPasskeyEnrollmentLocal as OverrideOptions } from '../../../interfaces/screens/passkey-enrollment-local'; + export class ScreenOverride extends Screen implements OverrideOptions { publicKey: OverrideOptions['publicKey']; diff --git a/packages/auth0-acul-js/src/screens/passkey-enrollment/index.ts b/packages/auth0-acul-js/src/screens/passkey-enrollment/index.ts index 4263a9c..ca5b583 100644 --- a/packages/auth0-acul-js/src/screens/passkey-enrollment/index.ts +++ b/packages/auth0-acul-js/src/screens/passkey-enrollment/index.ts @@ -1,11 +1,13 @@ +import { BaseContext } from '../../models/base-context'; +import { FormHandler } from '../../utils/form-handler'; +import { createPasskeyCredentials } from '../../utils/passkeys'; + import { ScreenOverride } from './screen-override'; + import type { CustomOptions } from '../../../interfaces/common'; import type { ScreenContext } from '../../../interfaces/models/screen'; import type { PasskeyEnrollmentMembers, ScreenMembersOnPasskeyEnrollment as ScreenOptions } from '../../../interfaces/screens/passkey-enrollment'; import type { FormOptions } from '../../../interfaces/utils/form-handler'; -import { BaseContext } from '../../models/base-context'; -import { FormHandler } from '../../utils/form-handler'; -import { createPasskeyCredentials } from '../../utils/passkeys'; export default class PasskeyEnrollment extends BaseContext implements PasskeyEnrollmentMembers { screen: ScreenOptions; @@ -52,6 +54,4 @@ export default class PasskeyEnrollment extends BaseContext implements PasskeyEnr } } -export { - PasskeyEnrollmentMembers -} +export { PasskeyEnrollmentMembers }; diff --git a/packages/auth0-acul-js/src/screens/passkey-enrollment/screen-override.ts b/packages/auth0-acul-js/src/screens/passkey-enrollment/screen-override.ts index f6ab082..63c1951 100644 --- a/packages/auth0-acul-js/src/screens/passkey-enrollment/screen-override.ts +++ b/packages/auth0-acul-js/src/screens/passkey-enrollment/screen-override.ts @@ -1,8 +1,9 @@ -import type { ScreenContext } from '../../../interfaces/models/screen'; -import type { ScreenMembersOnPasskeyEnrollment as OverrideOptions } from '../../../interfaces/screens/passkey-enrollment'; import { Screen } from '../../models/screen'; import { getBackLink, getLoginLink, getPublicKey } from '../../shared/screen'; +import type { ScreenContext } from '../../../interfaces/models/screen'; +import type { ScreenMembersOnPasskeyEnrollment as OverrideOptions } from '../../../interfaces/screens/passkey-enrollment'; + export class ScreenOverride extends Screen implements OverrideOptions { loginLink: OverrideOptions['loginLink']; backLink: OverrideOptions['backLink']; diff --git a/packages/auth0-acul-js/src/screens/phone-identifier-challenge/index.ts b/packages/auth0-acul-js/src/screens/phone-identifier-challenge/index.ts index 7d7a6a9..f9a007f 100644 --- a/packages/auth0-acul-js/src/screens/phone-identifier-challenge/index.ts +++ b/packages/auth0-acul-js/src/screens/phone-identifier-challenge/index.ts @@ -1,4 +1,8 @@ +import { BaseContext } from '../../models/base-context'; +import { FormHandler } from '../../utils/form-handler'; + import { ScreenOverride } from './screen-override'; + import type { CustomOptions } from '../../../interfaces/common'; import type { ScreenContext } from '../../../interfaces/models/screen'; import type { @@ -7,8 +11,6 @@ import type { PhoneIdentifierChallengeMembers, } from '../../../interfaces/screens/phone-identifier-challenge'; import type { FormOptions } from '../../../interfaces/utils/form-handler'; -import { BaseContext } from '../../models/base-context'; -import { FormHandler } from '../../utils/form-handler'; export default class PhoneIdentifierChallenge extends BaseContext implements PhoneIdentifierChallengeMembers { screen: ScreenOptions; @@ -65,7 +67,4 @@ export default class PhoneIdentifierChallenge extends BaseContext implements Pho } } -export { - PhoneIdentifierChallengeMembers, - PhoneChallengeOptions, -} +export { PhoneIdentifierChallengeMembers, PhoneChallengeOptions }; diff --git a/packages/auth0-acul-js/src/screens/phone-identifier-challenge/screen-override.ts b/packages/auth0-acul-js/src/screens/phone-identifier-challenge/screen-override.ts index 2716fce..c9d811d 100644 --- a/packages/auth0-acul-js/src/screens/phone-identifier-challenge/screen-override.ts +++ b/packages/auth0-acul-js/src/screens/phone-identifier-challenge/screen-override.ts @@ -1,6 +1,7 @@ +import { Screen } from '../../models/screen'; + import type { ScreenContext } from '../../../interfaces/models/screen'; import type { ScreenMembersOnPhoneIdentifierChallenge as OverrideOptions } from '../../../interfaces/screens/phone-identifier-challenge'; -import { Screen } from '../../models/screen'; export class ScreenOverride extends Screen implements OverrideOptions { data: OverrideOptions['data']; diff --git a/packages/auth0-acul-js/src/screens/phone-identifier-enrollment/index.ts b/packages/auth0-acul-js/src/screens/phone-identifier-enrollment/index.ts index 6413e09..f3c185f 100644 --- a/packages/auth0-acul-js/src/screens/phone-identifier-enrollment/index.ts +++ b/packages/auth0-acul-js/src/screens/phone-identifier-enrollment/index.ts @@ -1,4 +1,8 @@ +import { BaseContext } from '../../models/base-context'; +import { FormHandler } from '../../utils/form-handler'; + import { ScreenOverride } from './screen-override'; + import type { CustomOptions } from '../../../interfaces/common'; import type { ScreenContext } from '../../../interfaces/models/screen'; import type { @@ -7,8 +11,6 @@ import type { PhoneEnrollmentOptions, } from '../../../interfaces/screens/phone-identifier-enrollment'; import type { FormOptions } from '../../../interfaces/utils/form-handler'; -import { BaseContext } from '../../models/base-context'; -import { FormHandler } from '../../utils/form-handler'; export default class PhoneIdentifierEnrollment extends BaseContext implements PhoneIdentifierEnrollmentMembers { screen: ScreenOptions; @@ -52,7 +54,4 @@ export default class PhoneIdentifierEnrollment extends BaseContext implements Ph } } -export { - PhoneIdentifierEnrollmentMembers, - PhoneEnrollmentOptions -} +export { PhoneIdentifierEnrollmentMembers, PhoneEnrollmentOptions }; diff --git a/packages/auth0-acul-js/src/screens/phone-identifier-enrollment/screen-override.ts b/packages/auth0-acul-js/src/screens/phone-identifier-enrollment/screen-override.ts index f6da0e3..c6f27c1 100644 --- a/packages/auth0-acul-js/src/screens/phone-identifier-enrollment/screen-override.ts +++ b/packages/auth0-acul-js/src/screens/phone-identifier-enrollment/screen-override.ts @@ -1,8 +1,9 @@ -import type { ScreenContext } from '../../../interfaces/models/screen'; -import type { ScreenMembersOnPhoneIdentifierEnrollment as OverrideOptions } from '../../../interfaces/screens/phone-identifier-enrollment'; import { getEditIdentifierLink } from '../../../src/shared/screen'; import { Screen } from '../../models/screen'; +import type { ScreenContext } from '../../../interfaces/models/screen'; +import type { ScreenMembersOnPhoneIdentifierEnrollment as OverrideOptions } from '../../../interfaces/screens/phone-identifier-enrollment'; + export class ScreenOverride extends Screen implements OverrideOptions { editIdentifierLink: OverrideOptions['editIdentifierLink']; data: OverrideOptions['data']; @@ -16,11 +17,11 @@ export class ScreenOverride extends Screen implements OverrideOptions { static getScreenData(screenContext: ScreenContext): OverrideOptions['data'] { const data = screenContext.data; if (!data) return null; - + return { ...data, phone: data?.phone_number, messageType: data?.message_type, } as OverrideOptions['data']; } -} \ No newline at end of file +} diff --git a/packages/auth0-acul-js/src/screens/signup-id/index.ts b/packages/auth0-acul-js/src/screens/signup-id/index.ts index 7c48a1a..001424b 100644 --- a/packages/auth0-acul-js/src/screens/signup-id/index.ts +++ b/packages/auth0-acul-js/src/screens/signup-id/index.ts @@ -1,5 +1,9 @@ +import { BaseContext } from '../../models/base-context'; +import { FormHandler } from '../../utils/form-handler'; + import { ScreenOverride } from './screen-override'; import { TransactionOverride } from './transaction-override'; + import type { ScreenContext } from '../../../interfaces/models/screen'; import type { TransactionContext } from '../../../interfaces/models/transaction'; import type { @@ -10,8 +14,6 @@ import type { SocialSignupOptions, } from '../../../interfaces/screens/signup-id'; import type { FormOptions } from '../../../interfaces/utils/form-handler'; -import { BaseContext } from '../../models/base-context'; -import { FormHandler } from '../../utils/form-handler'; export default class SignupId extends BaseContext implements SignupIdMembers { screen: ScreenOptions; @@ -37,11 +39,11 @@ export default class SignupId extends BaseContext implements SignupIdMembers { * * const signupIdManager = new SignupId(); * const { transaction } = signupIdManager; - * + * * //get mandatory & optional identifiers required for signup * const mandatoryIdentifier = transaction.getRequiredIdentifiers(); // eg: email * const optionalIdentifiers = transaction.getOptionalIdentifiers() // eg: phone - * + * * const signupParams = { * email : "testEmail", * phone : "+91923456789" @@ -96,8 +98,4 @@ export default class SignupId extends BaseContext implements SignupIdMembers { } } -export { - SignupIdMembers, - SignupOptions, - SocialSignupOptions -} +export { SignupIdMembers, SignupOptions, SocialSignupOptions }; diff --git a/packages/auth0-acul-js/src/screens/signup-id/screen-override.ts b/packages/auth0-acul-js/src/screens/signup-id/screen-override.ts index 6a2c9ff..cb3e7cf 100644 --- a/packages/auth0-acul-js/src/screens/signup-id/screen-override.ts +++ b/packages/auth0-acul-js/src/screens/signup-id/screen-override.ts @@ -1,8 +1,9 @@ -import type { ScreenContext } from '../../../interfaces/models/screen'; -import type { ScreenMembersOnSignupId as OverrideOptions } from '../../../interfaces/screens/signup-id'; import { getLoginLink } from '../../../src/shared/screen'; import { Screen } from '../../models/screen'; +import type { ScreenContext } from '../../../interfaces/models/screen'; +import type { ScreenMembersOnSignupId as OverrideOptions } from '../../../interfaces/screens/signup-id'; + export class ScreenOverride extends Screen implements OverrideOptions { loginLink: OverrideOptions['loginLink']; diff --git a/packages/auth0-acul-js/src/screens/signup-id/transaction-override.ts b/packages/auth0-acul-js/src/screens/signup-id/transaction-override.ts index e50f104..f750e6f 100644 --- a/packages/auth0-acul-js/src/screens/signup-id/transaction-override.ts +++ b/packages/auth0-acul-js/src/screens/signup-id/transaction-override.ts @@ -1,12 +1,8 @@ +import { Transaction } from '../../models/transaction'; +import { isPasskeyEnabled, getUsernamePolicy, getRequiredIdentifiers, getOptionalIdentifiers } from '../../shared/transaction'; + import type { TransactionContext } from '../../../interfaces/models/transaction'; import type { TransactionMembersOnSignupId as OverrideOptions } from '../../../interfaces/screens/signup-id'; -import { Transaction } from '../../models/transaction'; -import { - isPasskeyEnabled, - getUsernamePolicy, - getRequiredIdentifiers, - getOptionalIdentifiers, -} from '../../shared/transaction'; export class TransactionOverride extends Transaction implements OverrideOptions { isPasskeyEnabled: OverrideOptions['isPasskeyEnabled']; @@ -22,10 +18,7 @@ export class TransactionOverride extends Transaction implements OverrideOptions this.requiredIdentifiers = TransactionOverride.getRequiredIdentifiers(transactionContext, this.connectionStrategy); } - static getRequiredIdentifiers( - transactionContext: TransactionContext, - connectionStrategy: string | null - ): OverrideOptions['requiredIdentifiers'] { + static getRequiredIdentifiers(transactionContext: TransactionContext, connectionStrategy: string | null): OverrideOptions['requiredIdentifiers'] { if (connectionStrategy === 'sms') return ['phone']; if (connectionStrategy === 'email') return ['email']; return getRequiredIdentifiers(transactionContext); diff --git a/packages/auth0-acul-js/src/screens/signup-password/index.ts b/packages/auth0-acul-js/src/screens/signup-password/index.ts index 9c40c1a..e0405b2 100644 --- a/packages/auth0-acul-js/src/screens/signup-password/index.ts +++ b/packages/auth0-acul-js/src/screens/signup-password/index.ts @@ -1,5 +1,9 @@ +import { BaseContext } from '../../models/base-context'; +import { FormHandler } from '../../utils/form-handler'; + import { ScreenOverride } from './screen-override'; import { TransactionOverride } from './transaction-override'; + import type { TransactionContext } from '../../../interfaces/models/transaction'; import type { SignupPasswordMembers, @@ -9,8 +13,6 @@ import type { SignupPasswordOptions, } from '../../../interfaces/screens/signup-password'; import type { FormOptions } from '../../../interfaces/utils/form-handler'; -import { BaseContext } from '../../models/base-context'; -import { FormHandler } from '../../utils/form-handler'; export default class SignupPassword extends BaseContext implements SignupPasswordMembers { screen: ScreenOptions; @@ -30,13 +32,13 @@ export default class SignupPassword extends BaseContext implements SignupPasswor * @remarks * This methods handles signup-password related screen configuration. * It allows to proceed with registering signup password along with signup identifiers passed in previous screen - * + * * @example * import SignupPassword from "@auth0/auth0-acul-js/signup-password"; * * const signupPasswordManager = new SignupPassword(); * const { transaction, screen } = signupPasswordManager; - * + * * //get mandatory & optional identifiers required for signup-password screen to proceed * const mandatoryIdentifier = transaction.getRequiredIdentifiers(); //eg: email * const optionalIdentifiers = transaction.getOptionalIdentifiers() //eg: phone @@ -66,7 +68,4 @@ export default class SignupPassword extends BaseContext implements SignupPasswor } } -export { - SignupPasswordMembers, - SignupPasswordOptions -} +export { SignupPasswordMembers, SignupPasswordOptions }; diff --git a/packages/auth0-acul-js/src/screens/signup-password/screen-override.ts b/packages/auth0-acul-js/src/screens/signup-password/screen-override.ts index 243a0d3..b662c95 100644 --- a/packages/auth0-acul-js/src/screens/signup-password/screen-override.ts +++ b/packages/auth0-acul-js/src/screens/signup-password/screen-override.ts @@ -1,7 +1,8 @@ -import type { ScreenContextOnSignupPassword, ScreenMembersOnSignupPassword as OverrideOptions } from '../../../interfaces/screens/signup-password'; import { Screen } from '../../models/screen'; import { getLoginLink, getEditIdentifierLink } from '../../shared/screen'; +import type { ScreenContextOnSignupPassword, ScreenMembersOnSignupPassword as OverrideOptions } from '../../../interfaces/screens/signup-password'; + export class ScreenOverride extends Screen implements OverrideOptions { loginLink: OverrideOptions['loginLink']; editLink: OverrideOptions['editLink']; diff --git a/packages/auth0-acul-js/src/screens/signup-password/transaction-override.ts b/packages/auth0-acul-js/src/screens/signup-password/transaction-override.ts index b03d5c1..3f3e57b 100644 --- a/packages/auth0-acul-js/src/screens/signup-password/transaction-override.ts +++ b/packages/auth0-acul-js/src/screens/signup-password/transaction-override.ts @@ -1,12 +1,8 @@ +import { Transaction } from '../../models/transaction'; +import { isPasskeyEnabled, getPasswordPolicy, getRequiredIdentifiers, getOptionalIdentifiers } from '../../shared/transaction'; + import type { TransactionContext } from '../../../interfaces/models/transaction'; import type { TransactionMembersOnSignupPassword as OverrideOptions } from '../../../interfaces/screens/signup-password'; -import { Transaction } from '../../models/transaction'; -import { - isPasskeyEnabled, - getPasswordPolicy, - getRequiredIdentifiers, - getOptionalIdentifiers, -} from '../../shared/transaction'; export class TransactionOverride extends Transaction implements OverrideOptions { isPasskeyEnabled: OverrideOptions['isPasskeyEnabled']; @@ -22,10 +18,7 @@ export class TransactionOverride extends Transaction implements OverrideOptions this.requiredIdentifiers = TransactionOverride.getRequiredIdentifiers(transactionContext, this.connectionStrategy); } - static getRequiredIdentifiers( - transactionContext: TransactionContext, - connectionStrategy: string | null - ): OverrideOptions['requiredIdentifiers'] { + static getRequiredIdentifiers(transactionContext: TransactionContext, connectionStrategy: string | null): OverrideOptions['requiredIdentifiers'] { if (connectionStrategy === 'sms') return ['phone']; if (connectionStrategy === 'email') return ['email']; return getRequiredIdentifiers(transactionContext); diff --git a/packages/auth0-acul-js/src/shared/transaction.ts b/packages/auth0-acul-js/src/shared/transaction.ts index f0141d1..382b418 100644 --- a/packages/auth0-acul-js/src/shared/transaction.ts +++ b/packages/auth0-acul-js/src/shared/transaction.ts @@ -1,4 +1,4 @@ -import type { DBConnection, PasswordPolicy, TransactionContext } from '../../interfaces/models/transaction'; +import type { DBConnection, UsernamePolicy, PasswordPolicy, TransactionContext } from '../../interfaces/models/transaction'; import type { TransactionMembersOnLoginId } from '../../interfaces/screens/login-id'; import type { TransactionMembersOnSignupId } from '../../interfaces/screens/signup-id'; @@ -20,11 +20,10 @@ export function isPasskeyEnabled(transaction: TransactionContext): boolean { export function isUsernameRequired(transaction: TransactionContext): boolean { const connection = transaction?.connection as DBConnection; - if (!connection?.options?.hasOwnProperty('username_required')) return false; return connection?.options?.username_required ?? false; } -export function getUsernamePolicy(transaction: TransactionContext) { +export function getUsernamePolicy(transaction: TransactionContext): UsernamePolicy | null { const connection = transaction?.connection as DBConnection; if (!connection?.options?.attributes?.username?.validation) return null; @@ -40,12 +39,14 @@ export function getUsernamePolicy(transaction: TransactionContext) { }; } -export function getPasswordPolicy(transaction: TransactionContext) { +export function getPasswordPolicy(transaction: TransactionContext): PasswordPolicy | null { const connection = transaction?.connection as DBConnection; + // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (!connection?.options?.authentication_methods?.password) return null; const { password } = connection.options.authentication_methods; + // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (!password?.policy && !password?.min_length) return null; return { @@ -57,9 +58,9 @@ export function getPasswordPolicy(transaction: TransactionContext) { export function getAllowedIdentifiers(transaction: TransactionContext): TransactionMembersOnLoginId['allowedIdentifiers'] { const identifiers: TransactionMembersOnLoginId['allowedIdentifiers'] = []; - const connection = transaction?.connection as DBConnection; + // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (!connection?.options?.attributes) return null; const { email, username, phone } = connection.options.attributes; @@ -67,6 +68,7 @@ export function getAllowedIdentifiers(transaction: TransactionContext): Transact const identifiersList = ['email', 'username', 'phone']; [email, username, phone].forEach((attribute, index) => { + // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (attribute?.signup_status && requiredStatusList.includes(attribute.signup_status)) { identifiers.push(identifiersList[index] as 'email' | 'username' | 'phone'); } @@ -75,7 +77,7 @@ export function getAllowedIdentifiers(transaction: TransactionContext): Transact return identifiers.length > 0 ? identifiers : null; } -export function getRequiredIdentifiers(transaction: TransactionContext) { +export function getRequiredIdentifiers(transaction: TransactionContext): TransactionMembersOnSignupId['requiredIdentifiers'] { return getIdentifiersByStatus(transaction, 'required'); } @@ -85,10 +87,11 @@ export function getOptionalIdentifiers(transaction: TransactionContext): Transac function getIdentifiersByStatus(transaction: TransactionContext, status: 'required' | 'optional'): ('email' | 'username' | 'phone')[] | null { const connection = transaction?.connection as DBConnection; + // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (!connection?.options?.attributes) return null; const identifiers = Object.entries(connection.options.attributes) - .filter(([_, value]) => value.signup_status === status) + .filter(([, value]) => value.signup_status === status) .map(([key]) => key as 'email' | 'username' | 'phone'); return identifiers.length > 0 ? identifiers : null; diff --git a/packages/auth0-acul-js/src/utils/browser-capabilities.ts b/packages/auth0-acul-js/src/utils/browser-capabilities.ts index d89e248..d5384f4 100644 --- a/packages/auth0-acul-js/src/utils/browser-capabilities.ts +++ b/packages/auth0-acul-js/src/utils/browser-capabilities.ts @@ -1,7 +1,13 @@ export async function isBrave(): Promise { - // @ts-ignore - const isBrave = (navigator.brave && (await navigator.brave?.isBrave())) || false; - return isBrave; + // @ts-expect-error: navigator.brave may not exist on all browsers + const navigatorBrave = navigator?.brave as { isBrave?: () => Promise } | undefined; + + if (navigatorBrave && typeof navigatorBrave.isBrave === 'function') { + const isBraveBrowser = await navigatorBrave.isBrave(); + return Boolean(isBraveBrowser); + } + + return false; } export function isWebAuthAvailable(): boolean { @@ -16,6 +22,7 @@ export async function isWebAuthPlatformAvailable(): Promise { if (typeof window.PublicKeyCredential === 'undefined') { return false; } + const isAvailable = await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable(); - return isAvailable; + return Boolean(isAvailable); } diff --git a/packages/auth0-acul-js/src/utils/codec.ts b/packages/auth0-acul-js/src/utils/codec.ts index 4f5f74d..e214af1 100644 --- a/packages/auth0-acul-js/src/utils/codec.ts +++ b/packages/auth0-acul-js/src/utils/codec.ts @@ -15,7 +15,7 @@ export function base64UrlToUint8Array(base64Url: string): ArrayBuffer { } export function uint8ArrayToBase64Url(arraybuffer: ArrayBufferLike): string | null { - if (!arraybuffer) return null; + if (!(arraybuffer instanceof ArrayBuffer)) return null; const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'; const bytes = new Uint8Array(arraybuffer); diff --git a/packages/auth0-acul-js/src/utils/form-handler.ts b/packages/auth0-acul-js/src/utils/form-handler.ts index eed1d91..c7a1f77 100644 --- a/packages/auth0-acul-js/src/utils/form-handler.ts +++ b/packages/auth0-acul-js/src/utils/form-handler.ts @@ -6,6 +6,7 @@ export class FormHandler { this.options = options; } + // eslint-disable-next-line @typescript-eslint/require-await async submitData(payload: T): Promise { const extendedPayload: PostPayloadOptions = { ...payload, @@ -21,7 +22,7 @@ export class FormHandler { private buildForm(payload: PostPayloadOptions): HTMLFormElement { const $form = document.createElement('form'); $form.method = 'POST'; - $form.action = this.options.route || ''; + $form.action = this.options.route ?? ''; Object.entries(payload).forEach(([key, value]) => { const input = document.createElement('input'); diff --git a/packages/auth0-acul-js/src/utils/passkeys.ts b/packages/auth0-acul-js/src/utils/passkeys.ts index ab1bccb..b7c3ddf 100644 --- a/packages/auth0-acul-js/src/utils/passkeys.ts +++ b/packages/auth0-acul-js/src/utils/passkeys.ts @@ -1,6 +1,7 @@ import { isWebAuthPlatformAvailable } from './browser-capabilities'; import { base64UrlToUint8Array, uint8ArrayToBase64Url } from './codec'; import { Errors } from './errors'; + import type { PasskeyRead, PasskeyCreate } from '../../interfaces/models/screen'; import type { PasskeyCreateResponse, PasskeyCredentialResponse } from '../../interfaces/utils/passkeys'; @@ -38,7 +39,7 @@ function isAuthenticatorAssertionResponse(response: AuthenticatorResponse): resp } export async function getPasskeyCredentials(publicKey: PasskeyRead['public_key']): Promise { - if (!publicKey) throw new Error(Errors.PASSKEY_PUBLIC_KEY_UNAVAILABLE); + if (!publicKey?.challenge) throw new Error(Errors.PASSKEY_PUBLIC_KEY_UNAVAILABLE); const hasWebAuthPlatform = await isWebAuthPlatformAvailable(); const challenge = base64UrlToUint8Array(publicKey.challenge); @@ -68,7 +69,7 @@ export async function getPasskeyCredentials(publicKey: PasskeyRead['public_key'] } export async function createPasskeyCredentials(publicKey: PasskeyCreate['public_key']): Promise { - if (!publicKey) throw new Error(Errors.PASSKEY_PUBLIC_KEY_UNAVAILABLE); + if (!publicKey?.challenge) throw new Error(Errors.PASSKEY_PUBLIC_KEY_UNAVAILABLE); const publicKeyDecoded = decodePublicKey(publicKey); const credential = (await navigator.credentials.create({ publicKey: publicKeyDecoded })) as PublicKeyCredential | null; @@ -83,7 +84,7 @@ export async function createPasskeyCredentials(publicKey: PasskeyCreate['public_ response: { clientDataJSON: uint8ArrayToBase64Url(credentialResponse.clientDataJSON), attestationObject: uint8ArrayToBase64Url(credentialResponse.attestationObject), - transports: credentialResponse.getTransports ? credentialResponse.getTransports() : undefined, + transports: typeof credentialResponse?.getTransports === 'function' ? credentialResponse.getTransports() : undefined, }, }; }