playbook_ui 11.11.0 → 11.12.1.pre.alpha.passphrase1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/index.js +2 -0
  3. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +21 -1
  4. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +17 -1
  5. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.html.erb +62 -0
  6. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.jsx +86 -0
  7. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.md +17 -0
  8. data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +2 -0
  9. data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
  10. data/app/pb_kits/playbook/pb_button/_button.scss +6 -0
  11. data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +4 -4
  12. data/app/pb_kits/playbook/pb_button/docs/_button_default.jsx +18 -17
  13. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +15 -0
  14. data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +16 -0
  15. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.html.erb +86 -0
  16. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.jsx +114 -0
  17. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.md +17 -0
  18. data/app/pb_kits/playbook/pb_circle_chart/docs/example.yml +2 -0
  19. data/app/pb_kits/playbook/pb_circle_chart/docs/index.js +1 -0
  20. data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +50 -50
  21. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.jsx +1 -0
  22. data/app/pb_kits/playbook/pb_date_picker/plugins/timeSelect.ts +89 -89
  23. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_time_selection_styles.scss +15 -0
  24. data/app/pb_kits/playbook/pb_dialog/_dialog.scss +30 -1
  25. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +28 -0
  26. data/app/pb_kits/playbook/pb_dialog/dialog.rb +7 -35
  27. data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +21 -0
  28. data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +7 -0
  29. data/app/pb_kits/playbook/pb_dialog/dialog_body.rb +13 -0
  30. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +13 -0
  31. data/app/pb_kits/playbook/pb_dialog/dialog_footer.rb +16 -0
  32. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +13 -0
  33. data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +3 -20
  34. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +12 -0
  35. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.md +3 -1
  36. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.html.erb +11 -0
  37. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.md +3 -0
  38. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_sizes.html.erb +29 -0
  39. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +3 -0
  40. data/app/pb_kits/playbook/pb_icon/_icon.tsx +3 -1
  41. data/app/pb_kits/playbook/pb_icon/icon.rb +8 -1
  42. data/app/pb_kits/playbook/pb_icon/icon.test.js +155 -0
  43. data/app/pb_kits/playbook/pb_legend/{_legend.jsx → _legend.tsx} +6 -6
  44. data/app/pb_kits/playbook/pb_legend/legend.test.js +29 -0
  45. data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +20 -0
  46. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.html.erb +62 -0
  47. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.jsx +83 -0
  48. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.md +17 -0
  49. data/app/pb_kits/playbook/pb_line_graph/docs/example.yml +2 -0
  50. data/app/pb_kits/playbook/pb_line_graph/docs/index.js +1 -0
  51. data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +17 -1
  52. data/app/pb_kits/playbook/pb_passphrase/_passphrase.jsx +56 -97
  53. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.html.erb +145 -1
  54. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.jsx +127 -3
  55. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.md +11 -2
  56. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.html.erb +136 -0
  57. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.jsx +90 -8
  58. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.md +5 -0
  59. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.html.erb +51 -0
  60. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.jsx +39 -0
  61. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.html.erb +0 -2
  62. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.jsx +6 -20
  63. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.html.erb +2 -2
  64. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.jsx +1 -1
  65. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.html.erb +318 -5
  66. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.jsx +134 -48
  67. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.md +11 -5
  68. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.html.erb +123 -0
  69. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.jsx +96 -20
  70. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.md +6 -2
  71. data/app/pb_kits/playbook/pb_passphrase/docs/example.yml +4 -0
  72. data/app/pb_kits/playbook/pb_passphrase/docs/index.js +1 -0
  73. data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
  74. data/app/pb_kits/playbook/pb_passphrase/passphrase.rb +5 -9
  75. data/app/pb_kits/playbook/pb_passphrase/passphrase.test.jsx +0 -47
  76. data/app/pb_kits/playbook/pb_radio/_radio.scss +1 -1
  77. data/app/pb_kits/playbook/pb_title/_title.scss +5 -0
  78. data/app/pb_kits/playbook/pb_title/_title.tsx +4 -1
  79. data/app/pb_kits/playbook/pb_title/docs/{_title_light.html.erb → _title_default.html.erb} +3 -3
  80. data/app/pb_kits/playbook/pb_title/docs/{_title_light.jsx → _title_default.jsx} +14 -14
  81. data/app/pb_kits/playbook/pb_title/docs/{_title_light.md → _title_default.md} +0 -0
  82. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.html.erb +1 -0
  83. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.jsx +19 -0
  84. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.md +4 -0
  85. data/app/pb_kits/playbook/pb_title/docs/example.yml +4 -2
  86. data/app/pb_kits/playbook/pb_title/docs/index.js +2 -1
  87. data/app/pb_kits/playbook/pb_title/title.rb +6 -1
  88. data/app/pb_kits/playbook/pb_title/title.test.js +13 -0
  89. data/app/pb_kits/playbook/playbook-rails.js +4 -0
  90. data/app/pb_kits/playbook/plugins/pb_chart.js +13 -0
  91. data/app/pb_kits/playbook/tokens/_titles.scss +10 -1
  92. data/app/pb_kits/playbook/tokens/_typography.scss +2 -2
  93. data/lib/playbook/version.rb +2 -2
  94. metadata +37 -13
  95. data/app/pb_kits/playbook/pb_dialog/_dialog.html.erb +0 -10
  96. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.md +0 -1
  97. data/app/pb_kits/playbook/pb_passphrase/passwordStrength.js +0 -55
  98. data/app/pb_kits/playbook/pb_passphrase/useHaveIBeenPwned.js +0 -52
  99. data/app/pb_kits/playbook/pb_passphrase/useZxcvbn.js +0 -58
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.11.0
4
+ version: 11.12.1.pre.alpha.passphrase1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-10-28 00:00:00.000000000 Z
12
+ date: 2022-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -377,6 +377,9 @@ files:
377
377
  - app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend.jsx
378
378
  - app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_non_clickable.html.erb
379
379
  - app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_non_clickable.jsx
380
+ - app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.html.erb
381
+ - app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.jsx
382
+ - app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.md
380
383
  - app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_spline.html.erb
381
384
  - app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_spline.jsx
382
385
  - app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_spline.md
@@ -550,6 +553,9 @@ files:
550
553
  - app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_default.jsx
551
554
  - app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_inner_sizes.html.erb
552
555
  - app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_inner_sizes.jsx
556
+ - app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.html.erb
557
+ - app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.jsx
558
+ - app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.md
553
559
  - app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_live_data.jsx
554
560
  - app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_rounded.html.erb
555
561
  - app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_rounded.jsx
@@ -808,19 +814,28 @@ files:
808
814
  - app/pb_kits/playbook/pb_date_year_stacked/docs/example.yml
809
815
  - app/pb_kits/playbook/pb_date_year_stacked/docs/index.js
810
816
  - app/pb_kits/playbook/pb_dialog/_close_icon.tsx
811
- - app/pb_kits/playbook/pb_dialog/_dialog.html.erb
812
817
  - app/pb_kits/playbook/pb_dialog/_dialog.scss
813
818
  - app/pb_kits/playbook/pb_dialog/_dialog.tsx
814
819
  - app/pb_kits/playbook/pb_dialog/_dialog_context.tsx
815
820
  - app/pb_kits/playbook/pb_dialog/child_kits/_dialog_body.tsx
816
821
  - app/pb_kits/playbook/pb_dialog/child_kits/_dialog_footer.tsx
817
822
  - app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.tsx
823
+ - app/pb_kits/playbook/pb_dialog/dialog.html.erb
818
824
  - app/pb_kits/playbook/pb_dialog/dialog.rb
819
825
  - app/pb_kits/playbook/pb_dialog/dialog.test.jsx
826
+ - app/pb_kits/playbook/pb_dialog/dialogHelper.js
827
+ - app/pb_kits/playbook/pb_dialog/dialog_body.html.erb
828
+ - app/pb_kits/playbook/pb_dialog/dialog_body.rb
829
+ - app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb
830
+ - app/pb_kits/playbook/pb_dialog/dialog_footer.rb
831
+ - app/pb_kits/playbook/pb_dialog/dialog_header.html.erb
820
832
  - app/pb_kits/playbook/pb_dialog/dialog_header.rb
833
+ - app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb
821
834
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.jsx
822
835
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.md
836
+ - app/pb_kits/playbook/pb_dialog/docs/_dialog_default.html.erb
823
837
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx
838
+ - app/pb_kits/playbook/pb_dialog/docs/_dialog_default.md
824
839
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height.jsx
825
840
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height.md
826
841
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height_placement.jsx
@@ -831,6 +846,7 @@ files:
831
846
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_separators.md
832
847
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_should_close_on_overlay.jsx
833
848
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_should_close_on_overlay.md
849
+ - app/pb_kits/playbook/pb_dialog/docs/_dialog_sizes.html.erb
834
850
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_sizes.jsx
835
851
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.jsx
836
852
  - app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.md
@@ -1116,6 +1132,7 @@ files:
1116
1132
  - app/pb_kits/playbook/pb_icon/docs/index.js
1117
1133
  - app/pb_kits/playbook/pb_icon/icon.html.erb
1118
1134
  - app/pb_kits/playbook/pb_icon/icon.rb
1135
+ - app/pb_kits/playbook/pb_icon/icon.test.js
1119
1136
  - app/pb_kits/playbook/pb_icon_circle/_icon_circle.scss
1120
1137
  - app/pb_kits/playbook/pb_icon_circle/_icon_circle.tsx
1121
1138
  - app/pb_kits/playbook/pb_icon_circle/docs/_description.md
@@ -1244,8 +1261,8 @@ files:
1244
1261
  - app/pb_kits/playbook/pb_layout/layout.test.js
1245
1262
  - app/pb_kits/playbook/pb_layout/sidebar.html.erb
1246
1263
  - app/pb_kits/playbook/pb_layout/sidebar.rb
1247
- - app/pb_kits/playbook/pb_legend/_legend.jsx
1248
1264
  - app/pb_kits/playbook/pb_legend/_legend.scss
1265
+ - app/pb_kits/playbook/pb_legend/_legend.tsx
1249
1266
  - app/pb_kits/playbook/pb_legend/docs/_description.md
1250
1267
  - app/pb_kits/playbook/pb_legend/docs/_footer.md
1251
1268
  - app/pb_kits/playbook/pb_legend/docs/_legend_colors.html.erb
@@ -1301,6 +1318,9 @@ files:
1301
1318
  - app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend.jsx
1302
1319
  - app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_nonclickable.html.erb
1303
1320
  - app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_nonclickable.jsx
1321
+ - app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.html.erb
1322
+ - app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.jsx
1323
+ - app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.md
1304
1324
  - app/pb_kits/playbook/pb_line_graph/docs/example.yml
1305
1325
  - app/pb_kits/playbook/pb_line_graph/docs/index.js
1306
1326
  - app/pb_kits/playbook/pb_line_graph/lineGraphSettings.js
@@ -1438,16 +1458,20 @@ files:
1438
1458
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.html.erb
1439
1459
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.jsx
1440
1460
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.md
1461
+ - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.html.erb
1441
1462
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.jsx
1463
+ - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.md
1464
+ - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.html.erb
1465
+ - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.jsx
1442
1466
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.html.erb
1443
1467
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.jsx
1444
- - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.md
1445
1468
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.html.erb
1446
1469
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.jsx
1447
1470
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.md
1448
1471
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.html.erb
1449
1472
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.jsx
1450
1473
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.md
1474
+ - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.html.erb
1451
1475
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.jsx
1452
1476
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.md
1453
1477
  - app/pb_kits/playbook/pb_passphrase/docs/_passphrase_tips.html.erb
@@ -1458,9 +1482,6 @@ files:
1458
1482
  - app/pb_kits/playbook/pb_passphrase/passphrase.html.erb
1459
1483
  - app/pb_kits/playbook/pb_passphrase/passphrase.rb
1460
1484
  - app/pb_kits/playbook/pb_passphrase/passphrase.test.jsx
1461
- - app/pb_kits/playbook/pb_passphrase/passwordStrength.js
1462
- - app/pb_kits/playbook/pb_passphrase/useHaveIBeenPwned.js
1463
- - app/pb_kits/playbook/pb_passphrase/useZxcvbn.js
1464
1485
  - app/pb_kits/playbook/pb_person/_person.jsx
1465
1486
  - app/pb_kits/playbook/pb_person/_person.scss
1466
1487
  - app/pb_kits/playbook/pb_person/docs/_description.md
@@ -1995,9 +2016,12 @@ files:
1995
2016
  - app/pb_kits/playbook/pb_title/docs/_title_colors.html.erb
1996
2017
  - app/pb_kits/playbook/pb_title/docs/_title_colors.jsx
1997
2018
  - app/pb_kits/playbook/pb_title/docs/_title_colors.md
1998
- - app/pb_kits/playbook/pb_title/docs/_title_light.html.erb
1999
- - app/pb_kits/playbook/pb_title/docs/_title_light.jsx
2000
- - app/pb_kits/playbook/pb_title/docs/_title_light.md
2019
+ - app/pb_kits/playbook/pb_title/docs/_title_default.html.erb
2020
+ - app/pb_kits/playbook/pb_title/docs/_title_default.jsx
2021
+ - app/pb_kits/playbook/pb_title/docs/_title_default.md
2022
+ - app/pb_kits/playbook/pb_title/docs/_title_light_weight.html.erb
2023
+ - app/pb_kits/playbook/pb_title/docs/_title_light_weight.jsx
2024
+ - app/pb_kits/playbook/pb_title/docs/_title_light_weight.md
2001
2025
  - app/pb_kits/playbook/pb_title/docs/example.yml
2002
2026
  - app/pb_kits/playbook/pb_title/docs/index.js
2003
2027
  - app/pb_kits/playbook/pb_title/title.html.erb
@@ -2328,9 +2352,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
2328
2352
  version: '0'
2329
2353
  required_rubygems_version: !ruby/object:Gem::Requirement
2330
2354
  requirements:
2331
- - - ">="
2355
+ - - ">"
2332
2356
  - !ruby/object:Gem::Version
2333
- version: '0'
2357
+ version: 1.3.1
2334
2358
  requirements: []
2335
2359
  rubygems_version: 3.3.7
2336
2360
  signing_key:
@@ -1,10 +0,0 @@
1
- <%= content_tag(:div,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname,
5
- aria: object.aria,
6
- dark: object.dark) do %>
7
- <% if object.children %>
8
- <%= pb_rails("dialog/dialog_header", props: { children: object.children }) %>
9
- <% end %>
10
- <% end %>
@@ -1 +0,0 @@
1
- Use the `confirmation` prop to only include the label and show/hide icon.
@@ -1,55 +0,0 @@
1
- import zxcvbn from 'zxcvbn'
2
-
3
- export const zxcvbnPasswordScore = (options) => {
4
- const {
5
- calculate = zxcvbn,
6
- averageThreshold = 2,
7
- strongThreshold = 3,
8
- minLength = 12,
9
- } = options
10
-
11
- return {
12
- minLength,
13
- averageThreshold,
14
- strongThreshold,
15
- test: function (password = '', common = false) {
16
- const feedbackValues = (str) => {
17
- let percent, variant, text
18
-
19
- if (password.length <= 0) {
20
- percent = '0'
21
- variant = 'negative'
22
- text = '\u00A0' //nbsp to keep form from jumping when typing beings
23
- } else if (common) {
24
- percent = '25'
25
- variant = 'negative'
26
- text = 'This passphrase is too common'
27
- } else if (password.length < this.minLength || str < this.averageThreshold) {
28
- percent = '25'
29
- variant = 'negative'
30
- text = 'Too weak'
31
- } else if (str < this.strongThreshold){
32
- percent = '50'
33
- variant = 'warning'
34
- text = 'Almost there, keep going!'
35
- } else if (str >= this.strongThreshold) {
36
- percent = '100'
37
- variant = 'positive'
38
- text = 'Success! Strong passphrase'
39
- }
40
- return { percent, variant, text }
41
- }
42
-
43
- const result = calculate(password)
44
-
45
- return (
46
- {
47
- suggestions: result.feedback.suggestions,
48
- warning: result.feedback.warning,
49
- strength: result.score,
50
- ...feedbackValues(result.score),
51
- }
52
- )
53
- },
54
- }
55
- }
@@ -1,52 +0,0 @@
1
-
2
- import { useEffect, useState } from 'react'
3
-
4
- const checkHaveIBeenPwned = async function (passphrase) {
5
- const buffer = new TextEncoder('utf-8').encode(passphrase)
6
- const digest = await crypto.subtle.digest('SHA-1', buffer)
7
- const hashArray = Array.from(new Uint8Array(digest))
8
- const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('')
9
-
10
- const firstFive = hashHex.slice(0, 5)
11
- const endOfHash = hashHex.slice(5)
12
-
13
- const resp = await fetch(`https://api.pwnedpasswords.com/range/${firstFive}`)
14
- const text = await resp.text()
15
-
16
- const match = text.split('\n').some((line) => {
17
- //Each line is <sha-1-hash-suffix>:<count of incidents>
18
- return line.split(':')[0] === endOfHash.toUpperCase()
19
- })
20
- return match
21
- }
22
-
23
- /**
24
- * If the input hasn't changed in <delay> ms,
25
- * hit the haveibeenpwned api and check if the given passphrase is compromised
26
- */
27
- export default function useHaveIBeenPwned(passphrase, minLength, delay = 400) {
28
- const [isPwned, setIsPwned] = useState(false)
29
-
30
- useEffect(
31
- () => {
32
- // only check the API for passphrases above the minimum size
33
- if (passphrase.length < minLength) {
34
- setIsPwned(false)
35
- return
36
- }
37
-
38
- const handler = setTimeout(() => {
39
- checkHaveIBeenPwned(passphrase)
40
- .then((pwned) => setIsPwned(pwned))
41
- .catch(() => setIsPwned(false))
42
- }, delay)
43
-
44
- return () => {
45
- clearTimeout(handler)
46
- }
47
- },
48
- [passphrase, minLength, delay]
49
- )
50
-
51
- return isPwned
52
- }
@@ -1,58 +0,0 @@
1
- import { useEffect, useMemo, useState } from 'react'
2
- import zxcvbn from 'zxcvbn'
3
-
4
- export default function useZxcvbn(options) {
5
- const { passphrase = '', common, isPwned, confirmation, averageThreshold, minLength, strongThreshold } = options
6
- const calculator = useMemo(
7
- () => confirmation ? () => ({ score: 0 }) : zxcvbn,
8
- [confirmation]
9
- )
10
-
11
- const [percent, setPercent] = useState('0')
12
- const [variant, setVariant] = useState('negative')
13
- const [text, setText] = useState('\u00A0') //nbsp to keep height constant
14
- const [result, setResult] = useState({})
15
-
16
- useEffect(() => {
17
- if (confirmation) return
18
- const newResult = calculator(passphrase)
19
- setResult(newResult)
20
- const str = newResult.score
21
-
22
- const noPassphrase = passphrase.length <= 0
23
- const commonPassphrase = common || isPwned
24
- const weakPassphrase = passphrase.length < minLength || str < averageThreshold
25
- const averagePassphrase = str < strongThreshold
26
- const strongPassphrase = str >= strongThreshold
27
-
28
- if (noPassphrase) {
29
- setPercent('0')
30
- setVariant('negative')
31
- setText('\u00A0') //nbsp to keep height constant
32
- } else if (commonPassphrase) {
33
- setPercent('25')
34
- setVariant('negative')
35
- setText('This passphrase is too common')
36
- } else if (weakPassphrase) {
37
- setPercent('25')
38
- setVariant('negative')
39
- setText('Too weak')
40
- } else if (averagePassphrase){
41
- setPercent('50')
42
- setVariant('warning')
43
- setText('Almost there, keep going!')
44
- } else if (strongPassphrase) {
45
- setPercent('100')
46
- setVariant('positive')
47
- setText('Success! Strong passphrase')
48
- }
49
- }, [passphrase, common, isPwned, averageThreshold, minLength, strongThreshold]
50
- )
51
-
52
- return {
53
- strength: common || isPwned ? 0 : result.score,
54
- percent,
55
- variant,
56
- text,
57
- }
58
- }