mada-design-system 0.5.12 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +1 -1
- package/index.cjs10.js +1 -1
- package/index.cjs100.js +1 -1
- package/index.cjs101.js +1 -1
- package/index.cjs102.js +1 -1
- package/index.cjs103.js +1 -1
- package/index.cjs104.js +1 -1
- package/index.cjs105.js +1 -1
- package/index.cjs106.js +1 -5
- package/index.cjs107.js +1 -1
- package/index.cjs108.js +1 -1
- package/index.cjs109.js +5 -1
- package/index.cjs11.js +1 -1
- package/index.cjs110.js +1 -1
- package/index.cjs111.js +1 -1
- package/index.cjs112.js +1 -1
- package/index.cjs113.js +1 -1
- package/index.cjs114.js +1 -1
- package/index.cjs115.js +1 -1
- package/index.cjs116.js +1 -1
- package/index.cjs117.js +1 -1
- package/index.cjs118.js +1 -4
- package/index.cjs119.js +1 -1
- package/index.cjs12.js +1 -1
- package/index.cjs120.js +1 -2
- package/index.cjs121.js +1 -1
- package/index.cjs122.js +4 -2
- package/index.cjs123.js +1 -1
- package/index.cjs124.js +2 -1
- package/index.cjs125.js +1 -1
- package/index.cjs126.js +2 -1
- package/index.cjs127.js +1 -1
- package/index.cjs128.js +1 -1
- package/index.cjs129.js +1 -1
- package/index.cjs13.js +1 -1
- package/index.cjs130.js +1 -1
- package/index.cjs131.js +1 -1
- package/index.cjs132.js +1 -20
- package/index.cjs133.js +1 -1
- package/index.cjs134.js +20 -1
- package/index.cjs135.js +1 -1
- package/index.cjs136.js +1 -1
- package/index.cjs137.js +1 -1
- package/index.cjs138.js +1 -1
- package/index.cjs139.js +1 -1
- package/index.cjs14.js +1 -1
- package/index.cjs140.js +1 -1
- package/index.cjs141.js +1 -1
- package/index.cjs142.js +1 -1
- package/index.cjs143.js +1 -1
- package/index.cjs144.js +1 -1
- package/index.cjs145.js +1 -1
- package/index.cjs146.js +1 -1
- package/index.cjs147.js +1 -1
- package/index.cjs148.js +1 -1
- package/index.cjs149.js +1 -1
- package/index.cjs150.js +1 -1
- package/index.cjs151.js +1 -1
- package/index.cjs152.js +1 -1
- package/index.cjs153.js +1 -1
- package/index.cjs154.js +1 -1
- package/index.cjs155.js +1 -1
- package/index.cjs156.js +1 -1
- package/index.cjs157.js +1 -1
- package/index.cjs158.js +1 -1
- package/index.cjs159.js +1 -1
- package/index.cjs16.js +1 -1
- package/index.cjs160.js +1 -1
- package/index.cjs161.js +1 -1
- package/index.cjs162.js +1 -1
- package/index.cjs163.js +1 -1
- package/index.cjs164.js +1 -1
- package/index.cjs165.js +1 -1
- package/index.cjs166.js +1 -1
- package/index.cjs167.js +1 -1
- package/index.cjs168.js +1 -1
- package/index.cjs169.js +1 -1
- package/index.cjs170.js +1 -1
- package/index.cjs171.js +1 -1
- package/index.cjs172.js +1 -1
- package/index.cjs173.js +1 -1
- package/index.cjs174.js +1 -1
- package/index.cjs175.js +1 -1
- package/index.cjs176.js +1 -1
- package/index.cjs177.js +1 -1
- package/index.cjs178.js +1 -1
- package/index.cjs179.js +1 -1
- package/index.cjs18.js +1 -1
- package/index.cjs180.js +1 -1
- package/index.cjs181.js +1 -1
- package/index.cjs182.js +1 -1
- package/index.cjs183.js +1 -1
- package/index.cjs184.js +1 -1
- package/index.cjs185.js +1 -1
- package/index.cjs186.js +1 -1
- package/index.cjs187.js +1 -1
- package/index.cjs188.js +1 -1
- package/index.cjs189.js +1 -1
- package/index.cjs19.js +1 -1
- package/index.cjs190.js +1 -1
- package/index.cjs191.js +1 -1
- package/index.cjs192.js +1 -1
- package/index.cjs193.js +1 -1
- package/index.cjs194.js +1 -1
- package/index.cjs195.js +1 -4
- package/index.cjs196.js +1 -1
- package/index.cjs197.js +4 -1
- package/index.cjs198.js +1 -1
- package/index.cjs199.js +1 -1
- package/index.cjs200.js +1 -3
- package/index.cjs201.js +1 -1
- package/index.cjs202.js +1 -1
- package/index.cjs203.js +3 -1
- package/index.cjs204.js +1 -1
- package/index.cjs205.js +1 -1
- package/index.cjs206.js +1 -1
- package/index.cjs207.js +1 -1
- package/index.cjs208.js +1 -1
- package/index.cjs209.js +1 -1
- package/index.cjs21.js +1 -1
- package/index.cjs210.js +1 -1
- package/index.cjs211.js +1 -1
- package/index.cjs212.js +1 -1
- package/index.cjs213.js +1 -1
- package/index.cjs214.js +1 -1
- package/index.cjs215.js +1 -1
- package/index.cjs216.js +1 -1
- package/index.cjs217.js +1 -1
- package/index.cjs218.js +1 -1
- package/index.cjs219.js +1 -1
- package/index.cjs22.js +1 -1
- package/index.cjs220.js +1 -1
- package/index.cjs221.js +1 -1
- package/index.cjs222.js +1 -1
- package/index.cjs223.js +1 -1
- package/index.cjs224.js +1 -1
- package/index.cjs225.js +1 -1
- package/index.cjs226.js +1 -1
- package/index.cjs227.js +1 -1
- package/index.cjs228.js +1 -1
- package/index.cjs229.js +1 -1
- package/index.cjs23.js +1 -1
- package/index.cjs230.js +1 -1
- package/index.cjs231.js +1 -3
- package/index.cjs232.js +1 -1
- package/index.cjs233.js +1 -1
- package/index.cjs234.js +3 -1
- package/index.cjs235.js +1 -1
- package/index.cjs236.js +1 -1
- package/index.cjs237.js +1 -1
- package/index.cjs238.js +1 -1
- package/index.cjs239.js +1 -1
- package/index.cjs24.js +1 -1
- package/index.cjs240.js +1 -1
- package/index.cjs241.js +1 -1
- package/index.cjs242.js +1 -1
- package/index.cjs243.js +1 -1
- package/index.cjs244.js +1 -1
- package/index.cjs245.js +1 -1
- package/index.cjs246.js +1 -1
- package/index.cjs247.js +1 -2
- package/index.cjs248.js +1 -1
- package/index.cjs249.js +1 -1
- package/index.cjs250.js +2 -1
- package/index.cjs251.js +1 -1
- package/index.cjs252.js +1 -1
- package/index.cjs253.js +1 -1
- package/index.cjs254.js +1 -1
- package/index.cjs255.js +1 -1
- package/index.cjs256.js +1 -1
- package/index.cjs257.js +1 -1
- package/index.cjs258.js +1 -1
- package/index.cjs259.js +1 -1
- package/index.cjs26.js +1 -1
- package/index.cjs260.js +1 -1
- package/index.cjs261.js +1 -1
- package/index.cjs262.js +1 -1
- package/index.cjs263.js +1 -2
- package/index.cjs264.js +1 -1
- package/index.cjs265.js +1 -1
- package/index.cjs266.js +2 -1
- package/index.cjs267.js +1 -1
- package/index.cjs268.js +1 -1
- package/index.cjs269.js +1 -1
- package/index.cjs270.js +1 -1
- package/index.cjs271.js +1 -1
- package/index.cjs272.js +1 -1
- package/index.cjs273.js +1 -1
- package/index.cjs274.js +1 -15
- package/index.cjs275.js +1 -1
- package/index.cjs276.js +1 -1
- package/index.cjs277.js +1 -1
- package/index.cjs278.js +1 -1
- package/index.cjs279.js +1 -1
- package/index.cjs28.js +1 -1
- package/index.cjs280.js +1 -1
- package/index.cjs281.js +1 -1
- package/index.cjs282.js +1 -1
- package/index.cjs283.js +1 -1
- package/index.cjs284.js +15 -1
- package/index.cjs285.js +1 -1
- package/index.cjs286.js +1 -1
- package/index.cjs287.js +1 -1
- package/index.cjs288.js +1 -1
- package/index.cjs289.js +1 -1
- package/index.cjs29.js +1 -1
- package/index.cjs290.js +1 -1
- package/index.cjs291.js +1 -1
- package/index.cjs292.js +1 -1
- package/index.cjs293.js +1 -1
- package/index.cjs294.js +1 -1
- package/index.cjs295.js +1 -1
- package/index.cjs296.js +1 -1
- package/index.cjs297.js +1 -1
- package/index.cjs298.js +1 -1
- package/index.cjs299.js +1 -1
- package/index.cjs30.js +1 -1
- package/index.cjs300.js +1 -1
- package/index.cjs301.js +1 -1
- package/index.cjs302.js +1 -1
- package/index.cjs303.js +1 -1
- package/index.cjs304.js +1 -1
- package/index.cjs305.js +1 -1
- package/index.cjs306.js +1 -1
- package/index.cjs307.js +1 -1
- package/index.cjs308.js +1 -1
- package/index.cjs309.js +1 -1
- package/index.cjs31.js +1 -1
- package/index.cjs310.js +1 -1
- package/index.cjs311.js +1 -1
- package/index.cjs312.js +1 -1
- package/index.cjs313.js +1 -1
- package/index.cjs314.js +1 -1
- package/index.cjs315.js +1 -1
- package/index.cjs316.js +1 -1
- package/index.cjs317.js +1 -1
- package/index.cjs318.js +1 -1
- package/index.cjs319.js +1 -1
- package/index.cjs32.js +1 -1
- package/index.cjs320.js +1 -1
- package/index.cjs321.js +1 -1
- package/index.cjs322.js +1 -1
- package/index.cjs323.js +1 -1
- package/index.cjs324.js +1 -1
- package/index.cjs325.js +1 -1
- package/index.cjs326.js +1 -1
- package/index.cjs327.js +1 -1
- package/index.cjs328.js +1 -1
- package/index.cjs329.js +1 -1
- package/index.cjs33.js +1 -1
- package/index.cjs330.js +1 -1
- package/index.cjs331.js +1 -1
- package/index.cjs332.js +1 -1
- package/index.cjs333.js +1 -1
- package/index.cjs334.js +1 -1
- package/index.cjs335.js +1 -1
- package/index.cjs336.js +1 -1
- package/index.cjs337.js +1 -1
- package/index.cjs338.js +1 -1
- package/index.cjs339.js +1 -1
- package/index.cjs34.js +1 -1
- package/index.cjs340.js +1 -1
- package/index.cjs341.js +1 -1
- package/index.cjs342.js +1 -1
- package/index.cjs343.js +1 -1
- package/index.cjs344.js +1 -1
- package/index.cjs345.js +1 -1
- package/index.cjs346.js +1 -1
- package/index.cjs347.js +1 -1
- package/index.cjs348.js +1 -1
- package/index.cjs349.js +1 -1
- package/index.cjs35.js +1 -1
- package/index.cjs350.js +1 -1
- package/index.cjs351.js +1 -1
- package/index.cjs352.js +1 -1
- package/index.cjs353.js +1 -1
- package/index.cjs354.js +1 -1
- package/index.cjs355.js +1 -1
- package/index.cjs356.js +1 -1
- package/index.cjs357.js +1 -1
- package/index.cjs358.js +1 -1
- package/index.cjs359.js +1 -1
- package/index.cjs36.js +1 -1
- package/index.cjs360.js +1 -1
- package/index.cjs361.js +1 -1
- package/index.cjs362.js +1 -1
- package/index.cjs363.js +1 -1
- package/index.cjs364.js +1 -1
- package/index.cjs365.js +1 -1
- package/index.cjs366.js +1 -1
- package/index.cjs367.js +1 -1
- package/index.cjs368.js +1 -1
- package/index.cjs369.js +1 -1
- package/index.cjs37.js +5 -1
- package/index.cjs370.js +1 -1
- package/index.cjs371.js +1 -1
- package/index.cjs372.js +1 -1
- package/index.cjs373.js +1 -1
- package/index.cjs374.js +1 -1
- package/index.cjs375.js +1 -1
- package/index.cjs376.js +1 -1
- package/index.cjs377.js +1 -1
- package/index.cjs378.js +1 -1
- package/index.cjs379.js +1 -1
- package/index.cjs38.js +1 -5
- package/index.cjs380.js +1 -1
- package/index.cjs381.js +1 -1
- package/index.cjs382.js +1 -1
- package/index.cjs383.js +1 -1
- package/index.cjs384.js +1 -1
- package/index.cjs385.js +1 -1
- package/index.cjs386.js +1 -2
- package/index.cjs387.js +1 -1
- package/index.cjs388.js +1 -1
- package/index.cjs389.js +1 -1
- package/index.cjs39.js +1 -1
- package/index.cjs390.js +1 -1
- package/index.cjs391.js +1 -1
- package/index.cjs392.js +1 -1
- package/index.cjs393.js +1 -1
- package/index.cjs394.js +1 -1
- package/index.cjs395.js +2 -1
- package/index.cjs396.js +1 -1
- package/index.cjs397.js +1 -1
- package/index.cjs398.js +1 -1
- package/index.cjs399.js +1 -1
- package/index.cjs4.js +1 -1
- package/index.cjs40.js +1 -1
- package/index.cjs400.js +1 -1
- package/index.cjs401.js +1 -1
- package/index.cjs402.js +1 -1
- package/index.cjs403.js +1 -1
- package/index.cjs404.js +1 -1
- package/index.cjs405.js +1 -74
- package/index.cjs406.js +1 -1
- package/index.cjs407.js +1 -1
- package/index.cjs408.js +74 -1
- package/index.cjs409.js +1 -1
- package/index.cjs41.js +1 -1
- package/index.cjs410.js +1 -1
- package/index.cjs411.js +1 -1
- package/index.cjs412.js +1 -1
- package/index.cjs413.js +1 -1
- package/index.cjs414.js +1 -1
- package/index.cjs415.js +1 -1
- package/index.cjs416.js +1 -1
- package/index.cjs417.js +1 -1
- package/index.cjs418.js +1 -1
- package/index.cjs419.js +1 -1
- package/index.cjs42.js +1 -1
- package/index.cjs420.js +1 -1
- package/index.cjs421.js +1 -1
- package/index.cjs422.js +1 -1
- package/index.cjs423.js +1 -1
- package/index.cjs424.js +1 -1
- package/index.cjs425.js +1 -1
- package/index.cjs426.js +1 -1
- package/index.cjs427.js +1 -1
- package/index.cjs428.js +1 -1
- package/index.cjs429.js +1 -1
- package/index.cjs43.js +6 -1
- package/index.cjs430.js +1 -1
- package/index.cjs431.js +1 -0
- package/index.cjs432.js +1 -0
- package/index.cjs433.js +1 -0
- package/index.cjs44.js +1 -6
- package/index.cjs46.js +1 -1
- package/index.cjs47.js +1 -1
- package/index.cjs48.js +1 -1
- package/index.cjs49.js +1 -1
- package/index.cjs5.js +1 -1
- package/index.cjs50.js +1 -1
- package/index.cjs52.js +1 -1
- package/index.cjs53.js +1 -1
- package/index.cjs54.js +1 -1
- package/index.cjs55.js +1 -1
- package/index.cjs56.js +1 -1
- package/index.cjs57.js +1 -1
- package/index.cjs58.js +1 -1
- package/index.cjs6.js +1 -1
- package/index.cjs62.js +1 -1
- package/index.cjs64.js +1 -1
- package/index.cjs65.js +1 -1
- package/index.cjs67.js +1 -1
- package/index.cjs68.js +1 -1
- package/index.cjs7.js +1 -1
- package/index.cjs73.js +1 -1
- package/index.cjs74.js +1 -1
- package/index.cjs75.js +1 -1
- package/index.cjs76.js +1 -1
- package/index.cjs77.js +1 -1
- package/index.cjs8.js +1 -1
- package/index.cjs80.js +1 -1
- package/index.cjs82.js +1 -1
- package/index.cjs83.js +1 -1
- package/index.cjs86.js +1 -1
- package/index.cjs87.js +1 -1
- package/index.cjs88.js +1 -1
- package/index.cjs89.js +1 -1
- package/index.cjs9.js +1 -1
- package/index.cjs90.js +1 -1
- package/index.cjs93.js +1 -1
- package/index.cjs97.js +1 -1
- package/index.cjs99.js +1 -1
- package/index.es.d.ts +17 -5
- package/index.es.js +105 -105
- package/index.es10.js +7 -7
- package/index.es100.js +1 -1
- package/index.es101.js +470 -10
- package/index.es102.js +10 -87
- package/index.es103.js +86 -22
- package/index.es104.js +23 -1708
- package/index.es105.js +18 -35
- package/index.es106.js +25 -2596
- package/index.es107.js +1687 -300
- package/index.es108.js +35 -11
- package/index.es109.js +2596 -11
- package/index.es11.js +44 -44
- package/index.es110.js +321 -10
- package/index.es111.js +10 -7
- package/index.es112.js +10 -32
- package/index.es113.js +5 -5
- package/index.es114.js +7 -10
- package/index.es115.js +32 -10
- package/index.es116.js +2 -11
- package/index.es117.js +5 -5
- package/index.es118.js +9 -2567
- package/index.es119.js +12 -142
- package/index.es12.js +13 -10
- package/index.es120.js +11 -117
- package/index.es121.js +11 -137
- package/index.es122.js +2563 -217
- package/index.es123.js +142 -517
- package/index.es124.js +117 -11
- package/index.es125.js +137 -11
- package/index.es126.js +223 -11
- package/index.es127.js +375 -238
- package/index.es128.js +11 -21
- package/index.es129.js +5 -5
- package/index.es13.js +69 -72
- package/index.es130.js +21 -11
- package/index.es131.js +5 -5
- package/index.es132.js +11 -205
- package/index.es133.js +5 -5
- package/index.es134.js +205 -5
- package/index.es135.js +5 -5
- package/index.es136.js +4 -10
- package/index.es137.js +5 -5
- package/index.es138.js +5 -5
- package/index.es139.js +378 -10
- package/index.es14.js +2 -2
- package/index.es140.js +5 -5
- package/index.es141.js +5 -5
- package/index.es142.js +11 -2
- package/index.es143.js +11 -2
- package/index.es144.js +11 -2
- package/index.es145.js +11 -2
- package/index.es146.js +1 -1
- package/index.es147.js +1 -1
- package/index.es148.js +2 -11
- package/index.es149.js +2 -11
- package/index.es150.js +2 -11
- package/index.es151.js +2 -11
- package/index.es152.js +11 -3
- package/index.es153.js +5 -5
- package/index.es154.js +5 -5
- package/index.es155.js +4 -4
- package/index.es156.js +3 -11
- package/index.es157.js +11 -2
- package/index.es158.js +11 -2
- package/index.es159.js +5 -5
- package/index.es16.js +8 -8
- package/index.es160.js +5 -5
- package/index.es161.js +2 -11
- package/index.es162.js +2 -11
- package/index.es163.js +5 -5
- package/index.es164.js +11 -22
- package/index.es165.js +5 -5
- package/index.es166.js +11 -22
- package/index.es167.js +5 -5
- package/index.es168.js +22 -11
- package/index.es169.js +11 -12
- package/index.es170.js +22 -11
- package/index.es171.js +5 -5
- package/index.es172.js +5 -5
- package/index.es173.js +12 -11
- package/index.es174.js +10 -470
- package/index.es175.js +11 -2338
- package/index.es176.js +11 -2152
- package/index.es177.js +11 -11
- package/index.es178.js +2324 -125
- package/index.es179.js +2152 -6
- package/index.es18.js +1 -1
- package/index.es180.js +13 -3
- package/index.es181.js +128 -469
- package/index.es182.js +6 -31
- package/index.es183.js +3 -14
- package/index.es184.js +232 -5
- package/index.es185.js +51 -36
- package/index.es186.js +30 -232
- package/index.es187.js +11 -53
- package/index.es188.js +5 -17
- package/index.es189.js +477 -32
- package/index.es19.js +23 -23
- package/index.es190.js +17 -1223
- package/index.es191.js +35 -14
- package/index.es192.js +1224 -8
- package/index.es193.js +14 -50
- package/index.es194.js +8 -2
- package/index.es195.js +49 -2260
- package/index.es196.js +2 -11
- package/index.es197.js +2260 -12
- package/index.es198.js +39 -13
- package/index.es199.js +10 -105
- package/index.es200.js +13 -25
- package/index.es201.js +13 -51
- package/index.es202.js +104 -369
- package/index.es203.js +25 -62
- package/index.es204.js +51 -48
- package/index.es205.js +371 -6
- package/index.es206.js +62 -5
- package/index.es207.js +46 -45
- package/index.es208.js +6 -22
- package/index.es209.js +5 -7
- package/index.es21.js +1 -1
- package/index.es210.js +47 -10
- package/index.es211.js +22 -11
- package/index.es212.js +7 -17
- package/index.es213.js +10 -230
- package/index.es214.js +11 -25
- package/index.es215.js +15 -10
- package/index.es216.js +202 -251
- package/index.es217.js +23 -260
- package/index.es218.js +11 -16
- package/index.es219.js +277 -13
- package/index.es22.js +5 -5
- package/index.es220.js +260 -19
- package/index.es221.js +16 -7
- package/index.es222.js +15 -5
- package/index.es223.js +21 -5
- package/index.es224.js +8 -5
- package/index.es225.js +5 -3
- package/index.es226.js +5 -7
- package/index.es227.js +5 -28
- package/index.es228.js +3 -161
- package/index.es229.js +7 -238
- package/index.es23.js +1 -1
- package/index.es230.js +28 -10
- package/index.es231.js +155 -89
- package/index.es232.js +238 -2
- package/index.es233.js +9 -57
- package/index.es234.js +94 -56
- package/index.es235.js +2 -13
- package/index.es236.js +56 -23
- package/index.es237.js +56 -10
- package/index.es238.js +3 -38
- package/index.es239.js +2 -2000
- package/index.es24.js +6 -6
- package/index.es240.js +12 -6
- package/index.es241.js +24 -71
- package/index.es242.js +10 -24
- package/index.es243.js +38 -3
- package/index.es244.js +2000 -2
- package/index.es245.js +7 -2
- package/index.es246.js +71 -7
- package/index.es247.js +22 -324
- package/index.es248.js +2 -51
- package/index.es249.js +8 -30
- package/index.es250.js +327 -34
- package/index.es251.js +51 -53
- package/index.es252.js +30 -119
- package/index.es253.js +34 -9
- package/index.es254.js +53 -163
- package/index.es255.js +105 -296
- package/index.es256.js +8 -126
- package/index.es257.js +131 -148
- package/index.es258.js +308 -24
- package/index.es259.js +124 -59
- package/index.es26.js +1 -1
- package/index.es260.js +180 -5
- package/index.es261.js +26 -36
- package/index.es262.js +60 -24
- package/index.es263.js +5 -186
- package/index.es264.js +36 -138
- package/index.es265.js +26 -2
- package/index.es266.js +186 -8
- package/index.es267.js +138 -2
- package/index.es268.js +2 -98
- package/index.es269.js +7 -25
- package/index.es270.js +2 -39
- package/index.es271.js +98 -2
- package/index.es272.js +22 -56
- package/index.es273.js +35 -13
- package/index.es274.js +2 -244
- package/index.es275.js +67 -72
- package/index.es276.js +84 -4
- package/index.es277.js +45 -55
- package/index.es278.js +9 -11
- package/index.es279.js +4 -6
- package/index.es28.js +59 -64
- package/index.es280.js +51 -35
- package/index.es281.js +2 -27
- package/index.es282.js +58 -289
- package/index.es283.js +15 -89
- package/index.es284.js +244 -3
- package/index.es285.js +73 -7
- package/index.es286.js +4 -15
- package/index.es287.js +53 -142
- package/index.es288.js +11 -11
- package/index.es289.js +7 -38
- package/index.es29.js +1 -1
- package/index.es290.js +36 -2
- package/index.es291.js +26 -68
- package/index.es292.js +290 -84
- package/index.es293.js +87 -44
- package/index.es294.js +3 -9
- package/index.es295.js +7 -4
- package/index.es296.js +15 -51
- package/index.es297.js +145 -118
- package/index.es298.js +38 -7
- package/index.es299.js +11 -8
- package/index.es30.js +3 -3
- package/index.es300.js +116 -8
- package/index.es301.js +7 -351
- package/index.es302.js +8 -3
- package/index.es303.js +119 -205
- package/index.es304.js +7 -116
- package/index.es305.js +7 -6
- package/index.es306.js +7 -7
- package/index.es307.js +350 -15
- package/index.es308.js +2 -4
- package/index.es309.js +206 -8
- package/index.es31.js +97 -38
- package/index.es310.js +16 -3
- package/index.es311.js +5 -3
- package/index.es312.js +8 -3
- package/index.es313.js +3 -6
- package/index.es314.js +3 -5
- package/index.es315.js +3 -4
- package/index.es316.js +6 -117
- package/index.es317.js +4 -3
- package/index.es318.js +4 -15
- package/index.es319.js +117 -2
- package/index.es32.js +115 -90
- package/index.es320.js +3 -44
- package/index.es321.js +14 -51
- package/index.es322.js +2 -13
- package/index.es323.js +45 -143
- package/index.es324.js +51 -42
- package/index.es325.js +2 -3
- package/index.es326.js +2 -41
- package/index.es327.js +12 -7
- package/index.es328.js +143 -76
- package/index.es329.js +41 -53
- package/index.es33.js +64 -116
- package/index.es330.js +3 -8
- package/index.es331.js +39 -74
- package/index.es332.js +7 -23
- package/index.es333.js +75 -61
- package/index.es334.js +54 -4
- package/index.es335.js +6 -5
- package/index.es336.js +75 -31
- package/index.es337.js +23 -58
- package/index.es338.js +61 -12
- package/index.es339.js +5 -4
- package/index.es34.js +53 -69
- package/index.es340.js +6 -9
- package/index.es341.js +31 -54
- package/index.es342.js +58 -3
- package/index.es343.js +13 -5
- package/index.es344.js +4 -17
- package/index.es345.js +10 -17
- package/index.es346.js +55 -17
- package/index.es347.js +3 -16
- package/index.es348.js +5 -17
- package/index.es349.js +17 -17
- package/index.es35.js +70 -53
- package/index.es350.js +17 -17
- package/index.es351.js +17 -6
- package/index.es352.js +17 -24
- package/index.es353.js +17 -21
- package/index.es354.js +17 -6
- package/index.es355.js +17 -3
- package/index.es356.js +5 -18
- package/index.es357.js +21 -64
- package/index.es358.js +20 -15
- package/index.es359.js +6 -2
- package/index.es36.js +1208 -69
- package/index.es360.js +3 -2
- package/index.es361.js +18 -15
- package/index.es362.js +64 -333
- package/index.es363.js +15 -4
- package/index.es364.js +15 -4
- package/index.es365.js +335 -6
- package/index.es366.js +5 -19
- package/index.es367.js +5 -4
- package/index.es368.js +6 -5
- package/index.es369.js +19 -3
- package/index.es37.js +55 -1203
- package/index.es370.js +4 -72
- package/index.es371.js +6 -4
- package/index.es372.js +3 -7
- package/index.es373.js +70 -28
- package/index.es374.js +4 -8
- package/index.es375.js +6 -9
- package/index.es376.js +29 -6
- package/index.es377.js +10 -2
- package/index.es378.js +8 -2
- package/index.es379.js +7 -2
- package/index.es38.js +43 -55
- package/index.es380.js +2 -71
- package/index.es381.js +2 -92
- package/index.es382.js +2 -2
- package/index.es383.js +71 -2
- package/index.es384.js +92 -2
- package/index.es385.js +2 -2
- package/index.es386.js +2 -78
- package/index.es387.js +2 -259
- package/index.es388.js +2 -32
- package/index.es389.js +11 -6
- package/index.es39.js +17 -50
- package/index.es390.js +3 -131
- package/index.es391.js +6 -17
- package/index.es392.js +45 -6
- package/index.es393.js +24 -10
- package/index.es394.js +8 -3
- package/index.es395.js +78 -9
- package/index.es396.js +258 -3
- package/index.es397.js +31 -45
- package/index.es398.js +5 -24
- package/index.es399.js +132 -2
- package/index.es4.js +7 -177
- package/index.es40.js +240 -13
- package/index.es400.js +17 -69
- package/index.es401.js +6 -65
- package/index.es402.js +2 -6
- package/index.es403.js +66 -3
- package/index.es404.js +66 -2
- package/index.es405.js +6 -251
- package/index.es406.js +3 -7
- package/index.es407.js +2 -3
- package/index.es408.js +238 -161
- package/index.es409.js +8 -2
- package/index.es41.js +18 -245
- package/index.es410.js +3 -2
- package/index.es411.js +174 -2
- package/index.es412.js +2 -2
- package/index.es413.js +2 -7
- package/index.es414.js +2 -249
- package/index.es415.js +2 -20
- package/index.es416.js +7 -51
- package/index.es417.js +8 -7
- package/index.es418.js +6 -42
- package/index.es419.js +19 -15
- package/index.es42.js +116 -18
- package/index.es420.js +51 -10
- package/index.es421.js +248 -47
- package/index.es422.js +41 -24
- package/index.es423.js +15 -128
- package/index.es424.js +10 -112
- package/index.es425.js +48 -8
- package/index.es426.js +26 -2
- package/index.es427.js +129 -2
- package/index.es428.js +110 -71
- package/index.es429.js +2 -9
- package/index.es43.js +283 -109
- package/index.es430.js +2 -7
- package/index.es431.js +75 -0
- package/index.es432.js +11 -0
- package/index.es433.js +9 -0
- package/index.es44.js +37 -288
- package/index.es46.js +4 -4
- package/index.es47.js +182 -164
- package/index.es48.js +11 -11
- package/index.es49.js +2 -2
- package/index.es5.js +7 -7
- package/index.es50.js +12 -12
- package/index.es52.js +1 -1
- package/index.es53.js +6 -6
- package/index.es54.js +1 -1
- package/index.es55.js +1 -1
- package/index.es56.js +36 -36
- package/index.es57.js +2 -2
- package/index.es58.js +3 -3
- package/index.es6.js +43 -7
- package/index.es62.js +2 -2
- package/index.es64.js +4 -4
- package/index.es65.js +5 -5
- package/index.es67.js +8 -8
- package/index.es68.js +4 -4
- package/index.es7.js +121 -41
- package/index.es73.js +1 -1
- package/index.es74.js +3 -3
- package/index.es75.js +3 -3
- package/index.es76.js +29 -29
- package/index.es77.js +1 -1
- package/index.es8.js +209 -120
- package/index.es80.js +1 -1
- package/index.es82.js +1 -1
- package/index.es83.js +1 -1
- package/index.es86.js +5 -5
- package/index.es87.js +1 -1
- package/index.es88.js +1 -1
- package/index.es89.js +2 -2
- package/index.es9.js +14 -14
- package/index.es90.js +1 -1
- package/index.es93.js +1 -1
- package/index.es97.js +2 -2
- package/index.es99.js +1 -1
- package/package.json +11 -6
- package/style.css +1 -1
package/index.es178.js
CHANGED
|
@@ -1,141 +1,2340 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
)
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import { jwtDecode as Ee } from "./index.es195.js";
|
|
2
|
+
var Te = {
|
|
3
|
+
debug: () => {
|
|
4
|
+
},
|
|
5
|
+
info: () => {
|
|
6
|
+
},
|
|
7
|
+
warn: () => {
|
|
8
|
+
},
|
|
9
|
+
error: () => {
|
|
10
|
+
}
|
|
11
|
+
}, b, k, H = /* @__PURE__ */ ((e) => (e[e.NONE = 0] = "NONE", e[e.ERROR = 1] = "ERROR", e[e.WARN = 2] = "WARN", e[e.INFO = 3] = "INFO", e[e.DEBUG = 4] = "DEBUG", e))(H || {});
|
|
12
|
+
((e) => {
|
|
13
|
+
function t() {
|
|
14
|
+
b = 3, k = Te;
|
|
15
|
+
}
|
|
16
|
+
e.reset = t;
|
|
17
|
+
function s(r) {
|
|
18
|
+
if (!(0 <= r && r <= 4))
|
|
19
|
+
throw new Error("Invalid log level");
|
|
20
|
+
b = r;
|
|
21
|
+
}
|
|
22
|
+
e.setLevel = s;
|
|
23
|
+
function i(r) {
|
|
24
|
+
k = r;
|
|
25
|
+
}
|
|
26
|
+
e.setLogger = i;
|
|
27
|
+
})(H || (H = {}));
|
|
28
|
+
var g = class v {
|
|
29
|
+
constructor(t) {
|
|
30
|
+
this._name = t;
|
|
31
|
+
}
|
|
32
|
+
/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
|
|
33
|
+
debug(...t) {
|
|
34
|
+
b >= 4 && k.debug(v._format(this._name, this._method), ...t);
|
|
35
|
+
}
|
|
36
|
+
info(...t) {
|
|
37
|
+
b >= 3 && k.info(v._format(this._name, this._method), ...t);
|
|
38
|
+
}
|
|
39
|
+
warn(...t) {
|
|
40
|
+
b >= 2 && k.warn(v._format(this._name, this._method), ...t);
|
|
41
|
+
}
|
|
42
|
+
error(...t) {
|
|
43
|
+
b >= 1 && k.error(v._format(this._name, this._method), ...t);
|
|
44
|
+
}
|
|
45
|
+
/* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */
|
|
46
|
+
throw(t) {
|
|
47
|
+
throw this.error(t), t;
|
|
48
|
+
}
|
|
49
|
+
create(t) {
|
|
50
|
+
const s = Object.create(this);
|
|
51
|
+
return s._method = t, s.debug("begin"), s;
|
|
52
|
+
}
|
|
53
|
+
static createStatic(t, s) {
|
|
54
|
+
const i = new v(`${t}.${s}`);
|
|
55
|
+
return i.debug("begin"), i;
|
|
56
|
+
}
|
|
57
|
+
static _format(t, s) {
|
|
58
|
+
const i = `[${t}]`;
|
|
59
|
+
return s ? `${i} ${s}:` : i;
|
|
60
|
+
}
|
|
61
|
+
/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
|
|
62
|
+
// helpers for static class methods
|
|
63
|
+
static debug(t, ...s) {
|
|
64
|
+
b >= 4 && k.debug(v._format(t), ...s);
|
|
65
|
+
}
|
|
66
|
+
static info(t, ...s) {
|
|
67
|
+
b >= 3 && k.info(v._format(t), ...s);
|
|
68
|
+
}
|
|
69
|
+
static warn(t, ...s) {
|
|
70
|
+
b >= 2 && k.warn(v._format(t), ...s);
|
|
71
|
+
}
|
|
72
|
+
static error(t, ...s) {
|
|
73
|
+
b >= 1 && k.error(v._format(t), ...s);
|
|
74
|
+
}
|
|
75
|
+
/* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */
|
|
76
|
+
};
|
|
77
|
+
H.reset();
|
|
78
|
+
var D = class {
|
|
79
|
+
// IMPORTANT: doesn't validate the token
|
|
80
|
+
static decode(e) {
|
|
81
|
+
try {
|
|
82
|
+
return Ee(e);
|
|
83
|
+
} catch (t) {
|
|
84
|
+
throw g.error("JwtUtils.decode", t), t;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
static async generateSignedJwt(e, t, s) {
|
|
88
|
+
const i = f.encodeBase64Url(new TextEncoder().encode(JSON.stringify(e))), r = f.encodeBase64Url(new TextEncoder().encode(JSON.stringify(t))), o = `${i}.${r}`, n = await window.crypto.subtle.sign(
|
|
37
89
|
{
|
|
38
|
-
|
|
39
|
-
|
|
90
|
+
name: "ECDSA",
|
|
91
|
+
hash: { name: "SHA-256" }
|
|
40
92
|
},
|
|
93
|
+
s,
|
|
94
|
+
new TextEncoder().encode(o)
|
|
95
|
+
), c = f.encodeBase64Url(new Uint8Array(n));
|
|
96
|
+
return `${o}.${c}`;
|
|
97
|
+
}
|
|
98
|
+
}, Re = "10000000-1000-4000-8000-100000000000", K = (e) => btoa([...new Uint8Array(e)].map((t) => String.fromCharCode(t)).join("")), ie = class y {
|
|
99
|
+
static _randomWord() {
|
|
100
|
+
const t = new Uint32Array(1);
|
|
101
|
+
return crypto.getRandomValues(t), t[0];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Generates RFC4122 version 4 guid
|
|
105
|
+
*/
|
|
106
|
+
static generateUUIDv4() {
|
|
107
|
+
return Re.replace(
|
|
108
|
+
/[018]/g,
|
|
109
|
+
(s) => (+s ^ y._randomWord() & 15 >> +s / 4).toString(16)
|
|
110
|
+
).replace(/-/g, "");
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* PKCE: Generate a code verifier
|
|
114
|
+
*/
|
|
115
|
+
static generateCodeVerifier() {
|
|
116
|
+
return y.generateUUIDv4() + y.generateUUIDv4() + y.generateUUIDv4();
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* PKCE: Generate a code challenge
|
|
120
|
+
*/
|
|
121
|
+
static async generateCodeChallenge(t) {
|
|
122
|
+
if (!crypto.subtle)
|
|
123
|
+
throw new Error("Crypto.subtle is available only in secure contexts (HTTPS).");
|
|
124
|
+
try {
|
|
125
|
+
const i = new TextEncoder().encode(t), r = await crypto.subtle.digest("SHA-256", i);
|
|
126
|
+
return K(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
127
|
+
} catch (s) {
|
|
128
|
+
throw g.error("CryptoUtils.generateCodeChallenge", s), s;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Generates a base64-encoded string for a basic auth header
|
|
133
|
+
*/
|
|
134
|
+
static generateBasicAuth(t, s) {
|
|
135
|
+
const r = new TextEncoder().encode([t, s].join(":"));
|
|
136
|
+
return K(r);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Generates a hash of a string using a given algorithm
|
|
140
|
+
* @param alg
|
|
141
|
+
* @param message
|
|
142
|
+
*/
|
|
143
|
+
static async hash(t, s) {
|
|
144
|
+
const i = new TextEncoder().encode(s), r = await crypto.subtle.digest(t, i);
|
|
145
|
+
return new Uint8Array(r);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Generates a rfc7638 compliant jwk thumbprint
|
|
149
|
+
* @param jwk
|
|
150
|
+
*/
|
|
151
|
+
static async customCalculateJwkThumbprint(t) {
|
|
152
|
+
let s;
|
|
153
|
+
switch (t.kty) {
|
|
154
|
+
case "RSA":
|
|
155
|
+
s = {
|
|
156
|
+
e: t.e,
|
|
157
|
+
kty: t.kty,
|
|
158
|
+
n: t.n
|
|
159
|
+
};
|
|
160
|
+
break;
|
|
161
|
+
case "EC":
|
|
162
|
+
s = {
|
|
163
|
+
crv: t.crv,
|
|
164
|
+
kty: t.kty,
|
|
165
|
+
x: t.x,
|
|
166
|
+
y: t.y
|
|
167
|
+
};
|
|
168
|
+
break;
|
|
169
|
+
case "OKP":
|
|
170
|
+
s = {
|
|
171
|
+
crv: t.crv,
|
|
172
|
+
kty: t.kty,
|
|
173
|
+
x: t.x
|
|
174
|
+
};
|
|
175
|
+
break;
|
|
176
|
+
case "oct":
|
|
177
|
+
s = {
|
|
178
|
+
crv: t.k,
|
|
179
|
+
kty: t.kty
|
|
180
|
+
};
|
|
181
|
+
break;
|
|
182
|
+
default:
|
|
183
|
+
throw new Error("Unknown jwk type");
|
|
184
|
+
}
|
|
185
|
+
const i = await y.hash("SHA-256", JSON.stringify(s));
|
|
186
|
+
return y.encodeBase64Url(i);
|
|
187
|
+
}
|
|
188
|
+
static async generateDPoPProof({
|
|
189
|
+
url: t,
|
|
190
|
+
accessToken: s,
|
|
191
|
+
httpMethod: i,
|
|
192
|
+
keyPair: r,
|
|
193
|
+
nonce: o
|
|
194
|
+
}) {
|
|
195
|
+
let n, c;
|
|
196
|
+
const a = {
|
|
197
|
+
jti: window.crypto.randomUUID(),
|
|
198
|
+
htm: i ?? "GET",
|
|
199
|
+
htu: t,
|
|
200
|
+
iat: Math.floor(Date.now() / 1e3)
|
|
201
|
+
};
|
|
202
|
+
s && (n = await y.hash("SHA-256", s), c = y.encodeBase64Url(n), a.ath = c), o && (a.nonce = o);
|
|
203
|
+
try {
|
|
204
|
+
const l = await crypto.subtle.exportKey("jwk", r.publicKey), d = {
|
|
205
|
+
alg: "ES256",
|
|
206
|
+
typ: "dpop+jwt",
|
|
207
|
+
jwk: {
|
|
208
|
+
crv: l.crv,
|
|
209
|
+
kty: l.kty,
|
|
210
|
+
x: l.x,
|
|
211
|
+
y: l.y
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
return await D.generateSignedJwt(d, a, r.privateKey);
|
|
215
|
+
} catch (l) {
|
|
216
|
+
throw l instanceof TypeError ? new Error(`Error exporting dpop public key: ${l.message}`) : l;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
static async generateDPoPJkt(t) {
|
|
220
|
+
try {
|
|
221
|
+
const s = await crypto.subtle.exportKey("jwk", t.publicKey);
|
|
222
|
+
return await y.customCalculateJwkThumbprint(s);
|
|
223
|
+
} catch (s) {
|
|
224
|
+
throw s instanceof TypeError ? new Error(`Could not retrieve dpop keys from storage: ${s.message}`) : s;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
static async generateDPoPKeys() {
|
|
228
|
+
return await window.crypto.subtle.generateKey(
|
|
41
229
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
230
|
+
name: "ECDSA",
|
|
231
|
+
namedCurve: "P-256"
|
|
232
|
+
},
|
|
233
|
+
!1,
|
|
234
|
+
["sign", "verify"]
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
ie.encodeBase64Url = (e) => K(e).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
239
|
+
var f = ie, I = class {
|
|
240
|
+
constructor(e) {
|
|
241
|
+
this._name = e, this._callbacks = [], this._logger = new g(`Event('${this._name}')`);
|
|
242
|
+
}
|
|
243
|
+
addHandler(e) {
|
|
244
|
+
return this._callbacks.push(e), () => this.removeHandler(e);
|
|
245
|
+
}
|
|
246
|
+
removeHandler(e) {
|
|
247
|
+
const t = this._callbacks.lastIndexOf(e);
|
|
248
|
+
t >= 0 && this._callbacks.splice(t, 1);
|
|
249
|
+
}
|
|
250
|
+
async raise(...e) {
|
|
251
|
+
this._logger.debug("raise:", ...e);
|
|
252
|
+
for (const t of this._callbacks)
|
|
253
|
+
await t(...e);
|
|
254
|
+
}
|
|
255
|
+
}, Z = class {
|
|
256
|
+
/**
|
|
257
|
+
* Populates a map of window features with a placement centered in front of
|
|
258
|
+
* the current window. If no explicit width is given, a default value is
|
|
259
|
+
* binned into [800, 720, 600, 480, 360] based on the current window's width.
|
|
260
|
+
*/
|
|
261
|
+
static center({ ...e }) {
|
|
262
|
+
var t, s, i;
|
|
263
|
+
return e.width == null && (e.width = (t = [800, 720, 600, 480].find((r) => r <= window.outerWidth / 1.618)) != null ? t : 360), (s = e.left) != null || (e.left = Math.max(0, Math.round(window.screenX + (window.outerWidth - e.width) / 2))), e.height != null && ((i = e.top) != null || (e.top = Math.max(0, Math.round(window.screenY + (window.outerHeight - e.height) / 2)))), e;
|
|
264
|
+
}
|
|
265
|
+
static serialize(e) {
|
|
266
|
+
return Object.entries(e).filter(([, t]) => t != null).map(([t, s]) => `${t}=${typeof s != "boolean" ? s : s ? "yes" : "no"}`).join(",");
|
|
267
|
+
}
|
|
268
|
+
}, T = class j extends I {
|
|
269
|
+
constructor() {
|
|
270
|
+
super(...arguments), this._logger = new g(`Timer('${this._name}')`), this._timerHandle = null, this._expiration = 0, this._callback = () => {
|
|
271
|
+
const t = this._expiration - j.getEpochTime();
|
|
272
|
+
this._logger.debug("timer completes in", t), this._expiration <= j.getEpochTime() && (this.cancel(), super.raise());
|
|
63
273
|
};
|
|
64
274
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
275
|
+
// get the time
|
|
276
|
+
static getEpochTime() {
|
|
277
|
+
return Math.floor(Date.now() / 1e3);
|
|
278
|
+
}
|
|
279
|
+
init(t) {
|
|
280
|
+
const s = this._logger.create("init");
|
|
281
|
+
t = Math.max(Math.floor(t), 1);
|
|
282
|
+
const i = j.getEpochTime() + t;
|
|
283
|
+
if (this.expiration === i && this._timerHandle) {
|
|
284
|
+
s.debug("skipping since already initialized for expiration at", this.expiration);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
this.cancel(), s.debug("using duration", t), this._expiration = i;
|
|
288
|
+
const r = Math.min(t, 5);
|
|
289
|
+
this._timerHandle = setInterval(this._callback, r * 1e3);
|
|
290
|
+
}
|
|
291
|
+
get expiration() {
|
|
292
|
+
return this._expiration;
|
|
293
|
+
}
|
|
294
|
+
cancel() {
|
|
295
|
+
this._logger.create("cancel"), this._timerHandle && (clearInterval(this._timerHandle), this._timerHandle = null);
|
|
296
|
+
}
|
|
297
|
+
}, F = class {
|
|
298
|
+
static readParams(e, t = "query") {
|
|
299
|
+
if (!e)
|
|
300
|
+
throw new TypeError("Invalid URL");
|
|
301
|
+
const i = new URL(e, "http://127.0.0.1")[t === "fragment" ? "hash" : "search"];
|
|
302
|
+
return new URLSearchParams(i.slice(1));
|
|
303
|
+
}
|
|
304
|
+
}, N = ";", q = class extends Error {
|
|
305
|
+
constructor(e, t) {
|
|
306
|
+
var s, i, r;
|
|
307
|
+
if (super(e.error_description || e.error || ""), this.form = t, this.name = "ErrorResponse", !e.error)
|
|
308
|
+
throw g.error("ErrorResponse", "No error passed"), new Error("No error passed");
|
|
309
|
+
this.error = e.error, this.error_description = (s = e.error_description) != null ? s : null, this.error_uri = (i = e.error_uri) != null ? i : null, this.state = e.userState, this.session_state = (r = e.session_state) != null ? r : null, this.url_state = e.url_state;
|
|
310
|
+
}
|
|
311
|
+
}, G = class extends Error {
|
|
312
|
+
constructor(e) {
|
|
313
|
+
super(e), this.name = "ErrorTimeout";
|
|
314
|
+
}
|
|
315
|
+
}, Pe = class {
|
|
316
|
+
constructor(e) {
|
|
317
|
+
this._logger = new g("AccessTokenEvents"), this._expiringTimer = new T("Access token expiring"), this._expiredTimer = new T("Access token expired"), this._expiringNotificationTimeInSeconds = e.expiringNotificationTimeInSeconds;
|
|
318
|
+
}
|
|
319
|
+
async load(e) {
|
|
320
|
+
const t = this._logger.create("load");
|
|
321
|
+
if (e.access_token && e.expires_in !== void 0) {
|
|
322
|
+
const s = e.expires_in;
|
|
323
|
+
if (t.debug("access token present, remaining duration:", s), s > 0) {
|
|
324
|
+
let r = s - this._expiringNotificationTimeInSeconds;
|
|
325
|
+
r <= 0 && (r = 1), t.debug("registering expiring timer, raising in", r, "seconds"), this._expiringTimer.init(r);
|
|
326
|
+
} else
|
|
327
|
+
t.debug("canceling existing expiring timer because we're past expiration."), this._expiringTimer.cancel();
|
|
328
|
+
const i = s + 1;
|
|
329
|
+
t.debug("registering expired timer, raising in", i, "seconds"), this._expiredTimer.init(i);
|
|
330
|
+
} else
|
|
331
|
+
this._expiringTimer.cancel(), this._expiredTimer.cancel();
|
|
332
|
+
}
|
|
333
|
+
async unload() {
|
|
334
|
+
this._logger.debug("unload: canceling existing access token timers"), this._expiringTimer.cancel(), this._expiredTimer.cancel();
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Add callback: Raised prior to the access token expiring.
|
|
338
|
+
*/
|
|
339
|
+
addAccessTokenExpiring(e) {
|
|
340
|
+
return this._expiringTimer.addHandler(e);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Remove callback: Raised prior to the access token expiring.
|
|
344
|
+
*/
|
|
345
|
+
removeAccessTokenExpiring(e) {
|
|
346
|
+
this._expiringTimer.removeHandler(e);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Add callback: Raised after the access token has expired.
|
|
350
|
+
*/
|
|
351
|
+
addAccessTokenExpired(e) {
|
|
352
|
+
return this._expiredTimer.addHandler(e);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Remove callback: Raised after the access token has expired.
|
|
356
|
+
*/
|
|
357
|
+
removeAccessTokenExpired(e) {
|
|
358
|
+
this._expiredTimer.removeHandler(e);
|
|
359
|
+
}
|
|
360
|
+
}, Ie = class {
|
|
361
|
+
constructor(e, t, s, i, r) {
|
|
362
|
+
this._callback = e, this._client_id = t, this._intervalInSeconds = i, this._stopOnError = r, this._logger = new g("CheckSessionIFrame"), this._timer = null, this._session_state = null, this._message = (n) => {
|
|
363
|
+
n.origin === this._frame_origin && n.source === this._frame.contentWindow && (n.data === "error" ? (this._logger.error("error message from check session op iframe"), this._stopOnError && this.stop()) : n.data === "changed" ? (this._logger.debug("changed message from check session op iframe"), this.stop(), this._callback()) : this._logger.debug(n.data + " message from check session op iframe"));
|
|
364
|
+
};
|
|
365
|
+
const o = new URL(s);
|
|
366
|
+
this._frame_origin = o.origin, this._frame = window.document.createElement("iframe"), this._frame.style.visibility = "hidden", this._frame.style.position = "fixed", this._frame.style.left = "-1000px", this._frame.style.top = "0", this._frame.width = "0", this._frame.height = "0", this._frame.src = o.href;
|
|
367
|
+
}
|
|
368
|
+
load() {
|
|
369
|
+
return new Promise((e) => {
|
|
370
|
+
this._frame.onload = () => {
|
|
371
|
+
e();
|
|
372
|
+
}, window.document.body.appendChild(this._frame), window.addEventListener("message", this._message, !1);
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
start(e) {
|
|
376
|
+
if (this._session_state === e)
|
|
377
|
+
return;
|
|
378
|
+
this._logger.create("start"), this.stop(), this._session_state = e;
|
|
379
|
+
const t = () => {
|
|
380
|
+
!this._frame.contentWindow || !this._session_state || this._frame.contentWindow.postMessage(this._client_id + " " + this._session_state, this._frame_origin);
|
|
381
|
+
};
|
|
382
|
+
t(), this._timer = setInterval(t, this._intervalInSeconds * 1e3);
|
|
383
|
+
}
|
|
384
|
+
stop() {
|
|
385
|
+
this._logger.create("stop"), this._session_state = null, this._timer && (clearInterval(this._timer), this._timer = null);
|
|
386
|
+
}
|
|
387
|
+
}, re = class {
|
|
388
|
+
constructor() {
|
|
389
|
+
this._logger = new g("InMemoryWebStorage"), this._data = {};
|
|
390
|
+
}
|
|
391
|
+
clear() {
|
|
392
|
+
this._logger.create("clear"), this._data = {};
|
|
393
|
+
}
|
|
394
|
+
getItem(e) {
|
|
395
|
+
return this._logger.create(`getItem('${e}')`), this._data[e];
|
|
396
|
+
}
|
|
397
|
+
setItem(e, t) {
|
|
398
|
+
this._logger.create(`setItem('${e}')`), this._data[e] = t;
|
|
399
|
+
}
|
|
400
|
+
removeItem(e) {
|
|
401
|
+
this._logger.create(`removeItem('${e}')`), delete this._data[e];
|
|
402
|
+
}
|
|
403
|
+
get length() {
|
|
404
|
+
return Object.getOwnPropertyNames(this._data).length;
|
|
405
|
+
}
|
|
406
|
+
key(e) {
|
|
407
|
+
return Object.getOwnPropertyNames(this._data)[e];
|
|
408
|
+
}
|
|
409
|
+
}, L = class extends Error {
|
|
410
|
+
constructor(e, t) {
|
|
411
|
+
super(t), this.name = "ErrorDPoPNonce", this.nonce = e;
|
|
412
|
+
}
|
|
413
|
+
}, Q = class {
|
|
414
|
+
constructor(e = [], t = null, s = {}) {
|
|
415
|
+
this._jwtHandler = t, this._extraHeaders = s, this._logger = new g("JsonService"), this._contentTypes = [], this._contentTypes.push(...e, "application/json"), t && this._contentTypes.push("application/jwt");
|
|
416
|
+
}
|
|
417
|
+
async fetchWithTimeout(e, t = {}) {
|
|
418
|
+
const { timeoutInSeconds: s, ...i } = t;
|
|
419
|
+
if (!s)
|
|
420
|
+
return await fetch(e, i);
|
|
421
|
+
const r = new AbortController(), o = setTimeout(() => r.abort(), s * 1e3);
|
|
422
|
+
try {
|
|
423
|
+
return await fetch(e, {
|
|
424
|
+
...t,
|
|
425
|
+
signal: r.signal
|
|
426
|
+
});
|
|
427
|
+
} catch (n) {
|
|
428
|
+
throw n instanceof DOMException && n.name === "AbortError" ? new G("Network timed out") : n;
|
|
429
|
+
} finally {
|
|
430
|
+
clearTimeout(o);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
async getJson(e, {
|
|
434
|
+
token: t,
|
|
435
|
+
credentials: s,
|
|
436
|
+
timeoutInSeconds: i
|
|
437
|
+
} = {}) {
|
|
438
|
+
const r = this._logger.create("getJson"), o = {
|
|
439
|
+
Accept: this._contentTypes.join(", ")
|
|
440
|
+
};
|
|
441
|
+
t && (r.debug("token passed, setting Authorization header"), o.Authorization = "Bearer " + t), this._appendExtraHeaders(o);
|
|
442
|
+
let n;
|
|
443
|
+
try {
|
|
444
|
+
r.debug("url:", e), n = await this.fetchWithTimeout(e, { method: "GET", headers: o, timeoutInSeconds: i, credentials: s });
|
|
445
|
+
} catch (l) {
|
|
446
|
+
throw r.error("Network Error"), l;
|
|
447
|
+
}
|
|
448
|
+
r.debug("HTTP response received, status", n.status);
|
|
449
|
+
const c = n.headers.get("Content-Type");
|
|
450
|
+
if (c && !this._contentTypes.find((l) => c.startsWith(l)) && r.throw(new Error(`Invalid response Content-Type: ${c ?? "undefined"}, from URL: ${e}`)), n.ok && this._jwtHandler && (c != null && c.startsWith("application/jwt")))
|
|
451
|
+
return await this._jwtHandler(await n.text());
|
|
452
|
+
let a;
|
|
453
|
+
try {
|
|
454
|
+
a = await n.json();
|
|
455
|
+
} catch (l) {
|
|
456
|
+
throw r.error("Error parsing JSON response", l), n.ok ? l : new Error(`${n.statusText} (${n.status})`);
|
|
457
|
+
}
|
|
458
|
+
if (!n.ok)
|
|
459
|
+
throw r.error("Error from server:", a), a.error ? new q(a) : new Error(`${n.statusText} (${n.status}): ${JSON.stringify(a)}`);
|
|
460
|
+
return a;
|
|
461
|
+
}
|
|
462
|
+
async postForm(e, {
|
|
463
|
+
body: t,
|
|
464
|
+
basicAuth: s,
|
|
465
|
+
timeoutInSeconds: i,
|
|
466
|
+
initCredentials: r,
|
|
467
|
+
extraHeaders: o
|
|
468
|
+
}) {
|
|
469
|
+
const n = this._logger.create("postForm"), c = {
|
|
470
|
+
Accept: this._contentTypes.join(", "),
|
|
471
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
472
|
+
...o
|
|
473
|
+
};
|
|
474
|
+
s !== void 0 && (c.Authorization = "Basic " + s), this._appendExtraHeaders(c);
|
|
475
|
+
let a;
|
|
476
|
+
try {
|
|
477
|
+
n.debug("url:", e), a = await this.fetchWithTimeout(e, { method: "POST", headers: c, body: t, timeoutInSeconds: i, credentials: r });
|
|
478
|
+
} catch (u) {
|
|
479
|
+
throw n.error("Network error"), u;
|
|
480
|
+
}
|
|
481
|
+
n.debug("HTTP response received, status", a.status);
|
|
482
|
+
const l = a.headers.get("Content-Type");
|
|
483
|
+
if (l && !this._contentTypes.find((u) => l.startsWith(u)))
|
|
484
|
+
throw new Error(`Invalid response Content-Type: ${l ?? "undefined"}, from URL: ${e}`);
|
|
485
|
+
const d = await a.text();
|
|
486
|
+
let h = {};
|
|
487
|
+
if (d)
|
|
488
|
+
try {
|
|
489
|
+
h = JSON.parse(d);
|
|
490
|
+
} catch (u) {
|
|
491
|
+
throw n.error("Error parsing JSON response", u), a.ok ? u : new Error(`${a.statusText} (${a.status})`);
|
|
492
|
+
}
|
|
493
|
+
if (!a.ok) {
|
|
494
|
+
if (n.error("Error from server:", h), a.headers.has("dpop-nonce")) {
|
|
495
|
+
const u = a.headers.get("dpop-nonce");
|
|
496
|
+
throw new L(u, `${JSON.stringify(h)}`);
|
|
497
|
+
}
|
|
498
|
+
throw h.error ? new q(h, t) : new Error(`${a.statusText} (${a.status}): ${JSON.stringify(h)}`);
|
|
499
|
+
}
|
|
500
|
+
return h;
|
|
501
|
+
}
|
|
502
|
+
_appendExtraHeaders(e) {
|
|
503
|
+
const t = this._logger.create("appendExtraHeaders"), s = Object.keys(this._extraHeaders), i = [
|
|
504
|
+
"accept",
|
|
505
|
+
"content-type"
|
|
506
|
+
], r = [
|
|
507
|
+
"authorization"
|
|
508
|
+
];
|
|
509
|
+
s.length !== 0 && s.forEach((o) => {
|
|
510
|
+
if (i.includes(o.toLocaleLowerCase())) {
|
|
511
|
+
t.warn("Protected header could not be set", o, i);
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
if (r.includes(o.toLocaleLowerCase()) && Object.keys(e).includes(o)) {
|
|
515
|
+
t.warn("Header could not be overridden", o, r);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const n = typeof this._extraHeaders[o] == "function" ? this._extraHeaders[o]() : this._extraHeaders[o];
|
|
519
|
+
n && n !== "" && (e[o] = n);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}, xe = class {
|
|
523
|
+
constructor(e) {
|
|
524
|
+
this._settings = e, this._logger = new g("MetadataService"), this._signingKeys = null, this._metadata = null, this._metadataUrl = this._settings.metadataUrl, this._jsonService = new Q(
|
|
525
|
+
["application/jwk-set+json"],
|
|
526
|
+
null,
|
|
527
|
+
this._settings.extraHeaders
|
|
528
|
+
), this._settings.signingKeys && (this._logger.debug("using signingKeys from settings"), this._signingKeys = this._settings.signingKeys), this._settings.metadata && (this._logger.debug("using metadata from settings"), this._metadata = this._settings.metadata), this._settings.fetchRequestCredentials && (this._logger.debug("using fetchRequestCredentials from settings"), this._fetchRequestCredentials = this._settings.fetchRequestCredentials);
|
|
529
|
+
}
|
|
530
|
+
resetSigningKeys() {
|
|
531
|
+
this._signingKeys = null;
|
|
532
|
+
}
|
|
533
|
+
async getMetadata() {
|
|
534
|
+
const e = this._logger.create("getMetadata");
|
|
535
|
+
if (this._metadata)
|
|
536
|
+
return e.debug("using cached values"), this._metadata;
|
|
537
|
+
if (!this._metadataUrl)
|
|
538
|
+
throw e.throw(new Error("No authority or metadataUrl configured on settings")), null;
|
|
539
|
+
e.debug("getting metadata from", this._metadataUrl);
|
|
540
|
+
const t = await this._jsonService.getJson(this._metadataUrl, { credentials: this._fetchRequestCredentials, timeoutInSeconds: this._settings.requestTimeoutInSeconds });
|
|
541
|
+
return e.debug("merging remote JSON with seed metadata"), this._metadata = Object.assign({}, t, this._settings.metadataSeed), this._metadata;
|
|
542
|
+
}
|
|
543
|
+
getIssuer() {
|
|
544
|
+
return this._getMetadataProperty("issuer");
|
|
545
|
+
}
|
|
546
|
+
getAuthorizationEndpoint() {
|
|
547
|
+
return this._getMetadataProperty("authorization_endpoint");
|
|
548
|
+
}
|
|
549
|
+
getUserInfoEndpoint() {
|
|
550
|
+
return this._getMetadataProperty("userinfo_endpoint");
|
|
551
|
+
}
|
|
552
|
+
getTokenEndpoint(e = !0) {
|
|
553
|
+
return this._getMetadataProperty("token_endpoint", e);
|
|
554
|
+
}
|
|
555
|
+
getCheckSessionIframe() {
|
|
556
|
+
return this._getMetadataProperty("check_session_iframe", !0);
|
|
557
|
+
}
|
|
558
|
+
getEndSessionEndpoint() {
|
|
559
|
+
return this._getMetadataProperty("end_session_endpoint", !0);
|
|
560
|
+
}
|
|
561
|
+
getRevocationEndpoint(e = !0) {
|
|
562
|
+
return this._getMetadataProperty("revocation_endpoint", e);
|
|
563
|
+
}
|
|
564
|
+
getKeysEndpoint(e = !0) {
|
|
565
|
+
return this._getMetadataProperty("jwks_uri", e);
|
|
566
|
+
}
|
|
567
|
+
async _getMetadataProperty(e, t = !1) {
|
|
568
|
+
const s = this._logger.create(`_getMetadataProperty('${e}')`), i = await this.getMetadata();
|
|
569
|
+
if (s.debug("resolved"), i[e] === void 0) {
|
|
570
|
+
if (t === !0) {
|
|
571
|
+
s.warn("Metadata does not contain optional property");
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
s.throw(new Error("Metadata does not contain property " + e));
|
|
575
|
+
}
|
|
576
|
+
return i[e];
|
|
577
|
+
}
|
|
578
|
+
async getSigningKeys() {
|
|
579
|
+
const e = this._logger.create("getSigningKeys");
|
|
580
|
+
if (this._signingKeys)
|
|
581
|
+
return e.debug("returning signingKeys from cache"), this._signingKeys;
|
|
582
|
+
const t = await this.getKeysEndpoint(!1);
|
|
583
|
+
e.debug("got jwks_uri", t);
|
|
584
|
+
const s = await this._jsonService.getJson(t, { timeoutInSeconds: this._settings.requestTimeoutInSeconds });
|
|
585
|
+
if (e.debug("got key set", s), !Array.isArray(s.keys))
|
|
586
|
+
throw e.throw(new Error("Missing keys on keyset")), null;
|
|
587
|
+
return this._signingKeys = s.keys, this._signingKeys;
|
|
588
|
+
}
|
|
589
|
+
}, ne = class {
|
|
590
|
+
constructor({
|
|
591
|
+
prefix: e = "oidc.",
|
|
592
|
+
store: t = localStorage
|
|
593
|
+
} = {}) {
|
|
594
|
+
this._logger = new g("WebStorageStateStore"), this._store = t, this._prefix = e;
|
|
595
|
+
}
|
|
596
|
+
async set(e, t) {
|
|
597
|
+
this._logger.create(`set('${e}')`), e = this._prefix + e, await this._store.setItem(e, t);
|
|
598
|
+
}
|
|
599
|
+
async get(e) {
|
|
600
|
+
return this._logger.create(`get('${e}')`), e = this._prefix + e, await this._store.getItem(e);
|
|
601
|
+
}
|
|
602
|
+
async remove(e) {
|
|
603
|
+
this._logger.create(`remove('${e}')`), e = this._prefix + e;
|
|
604
|
+
const t = await this._store.getItem(e);
|
|
605
|
+
return await this._store.removeItem(e), t;
|
|
606
|
+
}
|
|
607
|
+
async getAllKeys() {
|
|
608
|
+
this._logger.create("getAllKeys");
|
|
609
|
+
const e = await this._store.length, t = [];
|
|
610
|
+
for (let s = 0; s < e; s++) {
|
|
611
|
+
const i = await this._store.key(s);
|
|
612
|
+
i && i.indexOf(this._prefix) === 0 && t.push(i.substr(this._prefix.length));
|
|
613
|
+
}
|
|
614
|
+
return t;
|
|
615
|
+
}
|
|
616
|
+
}, Ce = "code", Ue = "openid", Ae = "client_secret_post", Oe = 60 * 15, z = class {
|
|
617
|
+
constructor({
|
|
618
|
+
// metadata related
|
|
619
|
+
authority: e,
|
|
620
|
+
metadataUrl: t,
|
|
621
|
+
metadata: s,
|
|
622
|
+
signingKeys: i,
|
|
623
|
+
metadataSeed: r,
|
|
624
|
+
// client related
|
|
625
|
+
client_id: o,
|
|
626
|
+
client_secret: n,
|
|
627
|
+
response_type: c = Ce,
|
|
628
|
+
scope: a = Ue,
|
|
629
|
+
redirect_uri: l,
|
|
630
|
+
post_logout_redirect_uri: d,
|
|
631
|
+
client_authentication: h = Ae,
|
|
632
|
+
// optional protocol
|
|
633
|
+
prompt: u,
|
|
634
|
+
display: p,
|
|
635
|
+
max_age: x,
|
|
636
|
+
ui_locales: C,
|
|
637
|
+
acr_values: U,
|
|
638
|
+
resource: A,
|
|
639
|
+
response_mode: R,
|
|
640
|
+
// behavior flags
|
|
641
|
+
filterProtocolClaims: P = !0,
|
|
642
|
+
loadUserInfo: O = !1,
|
|
643
|
+
requestTimeoutInSeconds: m,
|
|
644
|
+
staleStateAgeInSeconds: _ = Oe,
|
|
645
|
+
mergeClaimsStrategy: E = { array: "replace" },
|
|
646
|
+
disablePKCE: S = !1,
|
|
647
|
+
// other behavior
|
|
648
|
+
stateStore: w,
|
|
649
|
+
revokeTokenAdditionalContentTypes: M,
|
|
650
|
+
fetchRequestCredentials: X,
|
|
651
|
+
refreshTokenAllowedScope: we,
|
|
652
|
+
// extra
|
|
653
|
+
extraQueryParams: me = {},
|
|
654
|
+
extraTokenParams: Se = {},
|
|
655
|
+
extraHeaders: ve = {},
|
|
656
|
+
dpop: ye,
|
|
657
|
+
omitScopeWhenRequesting: be = !1
|
|
658
|
+
}) {
|
|
659
|
+
var Y;
|
|
660
|
+
if (this.authority = e, t ? this.metadataUrl = t : (this.metadataUrl = e, e && (this.metadataUrl.endsWith("/") || (this.metadataUrl += "/"), this.metadataUrl += ".well-known/openid-configuration")), this.metadata = s, this.metadataSeed = r, this.signingKeys = i, this.client_id = o, this.client_secret = n, this.response_type = c, this.scope = a, this.redirect_uri = l, this.post_logout_redirect_uri = d, this.client_authentication = h, this.prompt = u, this.display = p, this.max_age = x, this.ui_locales = C, this.acr_values = U, this.resource = A, this.response_mode = R, this.filterProtocolClaims = P ?? !0, this.loadUserInfo = !!O, this.staleStateAgeInSeconds = _, this.mergeClaimsStrategy = E, this.omitScopeWhenRequesting = be, this.disablePKCE = !!S, this.revokeTokenAdditionalContentTypes = M, this.fetchRequestCredentials = X || "same-origin", this.requestTimeoutInSeconds = m, w)
|
|
661
|
+
this.stateStore = w;
|
|
662
|
+
else {
|
|
663
|
+
const ke = typeof window < "u" ? window.localStorage : new re();
|
|
664
|
+
this.stateStore = new ne({ store: ke });
|
|
665
|
+
}
|
|
666
|
+
if (this.refreshTokenAllowedScope = we, this.extraQueryParams = me, this.extraTokenParams = Se, this.extraHeaders = ve, this.dpop = ye, this.dpop && !((Y = this.dpop) != null && Y.store))
|
|
667
|
+
throw new Error("A DPoPStore is required when dpop is enabled");
|
|
668
|
+
}
|
|
669
|
+
}, qe = class {
|
|
670
|
+
constructor(e, t) {
|
|
671
|
+
this._settings = e, this._metadataService = t, this._logger = new g("UserInfoService"), this._getClaimsFromJwt = async (s) => {
|
|
672
|
+
const i = this._logger.create("_getClaimsFromJwt");
|
|
673
|
+
try {
|
|
674
|
+
const r = D.decode(s);
|
|
675
|
+
return i.debug("JWT decoding successful"), r;
|
|
676
|
+
} catch (r) {
|
|
677
|
+
throw i.error("Error parsing JWT response"), r;
|
|
678
|
+
}
|
|
679
|
+
}, this._jsonService = new Q(
|
|
680
|
+
void 0,
|
|
681
|
+
this._getClaimsFromJwt,
|
|
682
|
+
this._settings.extraHeaders
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
async getClaims(e) {
|
|
686
|
+
const t = this._logger.create("getClaims");
|
|
687
|
+
e || this._logger.throw(new Error("No token passed"));
|
|
688
|
+
const s = await this._metadataService.getUserInfoEndpoint();
|
|
689
|
+
t.debug("got userinfo url", s);
|
|
690
|
+
const i = await this._jsonService.getJson(s, {
|
|
691
|
+
token: e,
|
|
692
|
+
credentials: this._settings.fetchRequestCredentials,
|
|
693
|
+
timeoutInSeconds: this._settings.requestTimeoutInSeconds
|
|
694
|
+
});
|
|
695
|
+
return t.debug("got claims", i), i;
|
|
696
|
+
}
|
|
697
|
+
}, oe = class {
|
|
698
|
+
constructor(e, t) {
|
|
699
|
+
this._settings = e, this._metadataService = t, this._logger = new g("TokenClient"), this._jsonService = new Q(
|
|
700
|
+
this._settings.revokeTokenAdditionalContentTypes,
|
|
701
|
+
null,
|
|
702
|
+
this._settings.extraHeaders
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Exchange code.
|
|
707
|
+
*
|
|
708
|
+
* @see https://www.rfc-editor.org/rfc/rfc6749#section-4.1.3
|
|
709
|
+
*/
|
|
710
|
+
async exchangeCode({
|
|
711
|
+
grant_type: e = "authorization_code",
|
|
712
|
+
redirect_uri: t = this._settings.redirect_uri,
|
|
713
|
+
client_id: s = this._settings.client_id,
|
|
714
|
+
client_secret: i = this._settings.client_secret,
|
|
715
|
+
extraHeaders: r,
|
|
716
|
+
...o
|
|
717
|
+
}) {
|
|
718
|
+
const n = this._logger.create("exchangeCode");
|
|
719
|
+
s || n.throw(new Error("A client_id is required")), t || n.throw(new Error("A redirect_uri is required")), o.code || n.throw(new Error("A code is required"));
|
|
720
|
+
const c = new URLSearchParams({ grant_type: e, redirect_uri: t });
|
|
721
|
+
for (const [h, u] of Object.entries(o))
|
|
722
|
+
u != null && c.set(h, u);
|
|
723
|
+
let a;
|
|
724
|
+
switch (this._settings.client_authentication) {
|
|
725
|
+
case "client_secret_basic":
|
|
726
|
+
if (i == null)
|
|
727
|
+
throw n.throw(new Error("A client_secret is required")), null;
|
|
728
|
+
a = f.generateBasicAuth(s, i);
|
|
729
|
+
break;
|
|
730
|
+
case "client_secret_post":
|
|
731
|
+
c.append("client_id", s), i && c.append("client_secret", i);
|
|
732
|
+
break;
|
|
733
|
+
}
|
|
734
|
+
const l = await this._metadataService.getTokenEndpoint(!1);
|
|
735
|
+
n.debug("got token endpoint");
|
|
736
|
+
const d = await this._jsonService.postForm(l, {
|
|
737
|
+
body: c,
|
|
738
|
+
basicAuth: a,
|
|
739
|
+
timeoutInSeconds: this._settings.requestTimeoutInSeconds,
|
|
740
|
+
initCredentials: this._settings.fetchRequestCredentials,
|
|
741
|
+
extraHeaders: r
|
|
742
|
+
});
|
|
743
|
+
return n.debug("got response"), d;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Exchange credentials.
|
|
747
|
+
*
|
|
748
|
+
* @see https://www.rfc-editor.org/rfc/rfc6749#section-4.3.2
|
|
749
|
+
*/
|
|
750
|
+
async exchangeCredentials({
|
|
751
|
+
grant_type: e = "password",
|
|
752
|
+
client_id: t = this._settings.client_id,
|
|
753
|
+
client_secret: s = this._settings.client_secret,
|
|
754
|
+
scope: i = this._settings.scope,
|
|
755
|
+
...r
|
|
756
|
+
}) {
|
|
757
|
+
const o = this._logger.create("exchangeCredentials");
|
|
758
|
+
t || o.throw(new Error("A client_id is required"));
|
|
759
|
+
const n = new URLSearchParams({ grant_type: e });
|
|
760
|
+
this._settings.omitScopeWhenRequesting || n.set("scope", i);
|
|
761
|
+
for (const [d, h] of Object.entries(r))
|
|
762
|
+
h != null && n.set(d, h);
|
|
763
|
+
let c;
|
|
764
|
+
switch (this._settings.client_authentication) {
|
|
765
|
+
case "client_secret_basic":
|
|
766
|
+
if (s == null)
|
|
767
|
+
throw o.throw(new Error("A client_secret is required")), null;
|
|
768
|
+
c = f.generateBasicAuth(t, s);
|
|
769
|
+
break;
|
|
770
|
+
case "client_secret_post":
|
|
771
|
+
n.append("client_id", t), s && n.append("client_secret", s);
|
|
772
|
+
break;
|
|
773
|
+
}
|
|
774
|
+
const a = await this._metadataService.getTokenEndpoint(!1);
|
|
775
|
+
o.debug("got token endpoint");
|
|
776
|
+
const l = await this._jsonService.postForm(a, { body: n, basicAuth: c, timeoutInSeconds: this._settings.requestTimeoutInSeconds, initCredentials: this._settings.fetchRequestCredentials });
|
|
777
|
+
return o.debug("got response"), l;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Exchange a refresh token.
|
|
781
|
+
*
|
|
782
|
+
* @see https://www.rfc-editor.org/rfc/rfc6749#section-6
|
|
783
|
+
*/
|
|
784
|
+
async exchangeRefreshToken({
|
|
785
|
+
grant_type: e = "refresh_token",
|
|
786
|
+
client_id: t = this._settings.client_id,
|
|
787
|
+
client_secret: s = this._settings.client_secret,
|
|
788
|
+
timeoutInSeconds: i,
|
|
789
|
+
extraHeaders: r,
|
|
790
|
+
...o
|
|
791
|
+
}) {
|
|
792
|
+
const n = this._logger.create("exchangeRefreshToken");
|
|
793
|
+
t || n.throw(new Error("A client_id is required")), o.refresh_token || n.throw(new Error("A refresh_token is required"));
|
|
794
|
+
const c = new URLSearchParams({ grant_type: e });
|
|
795
|
+
for (const [h, u] of Object.entries(o))
|
|
796
|
+
Array.isArray(u) ? u.forEach((p) => c.append(h, p)) : u != null && c.set(h, u);
|
|
797
|
+
let a;
|
|
798
|
+
switch (this._settings.client_authentication) {
|
|
799
|
+
case "client_secret_basic":
|
|
800
|
+
if (s == null)
|
|
801
|
+
throw n.throw(new Error("A client_secret is required")), null;
|
|
802
|
+
a = f.generateBasicAuth(t, s);
|
|
803
|
+
break;
|
|
804
|
+
case "client_secret_post":
|
|
805
|
+
c.append("client_id", t), s && c.append("client_secret", s);
|
|
806
|
+
break;
|
|
807
|
+
}
|
|
808
|
+
const l = await this._metadataService.getTokenEndpoint(!1);
|
|
809
|
+
n.debug("got token endpoint");
|
|
810
|
+
const d = await this._jsonService.postForm(l, { body: c, basicAuth: a, timeoutInSeconds: i, initCredentials: this._settings.fetchRequestCredentials, extraHeaders: r });
|
|
811
|
+
return n.debug("got response"), d;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Revoke an access or refresh token.
|
|
815
|
+
*
|
|
816
|
+
* @see https://datatracker.ietf.org/doc/html/rfc7009#section-2.1
|
|
817
|
+
*/
|
|
818
|
+
async revoke(e) {
|
|
819
|
+
var t;
|
|
820
|
+
const s = this._logger.create("revoke");
|
|
821
|
+
e.token || s.throw(new Error("A token is required"));
|
|
822
|
+
const i = await this._metadataService.getRevocationEndpoint(!1);
|
|
823
|
+
s.debug(`got revocation endpoint, revoking ${(t = e.token_type_hint) != null ? t : "default token type"}`);
|
|
824
|
+
const r = new URLSearchParams();
|
|
825
|
+
for (const [o, n] of Object.entries(e))
|
|
826
|
+
n != null && r.set(o, n);
|
|
827
|
+
r.set("client_id", this._settings.client_id), this._settings.client_secret && r.set("client_secret", this._settings.client_secret), await this._jsonService.postForm(i, { body: r, timeoutInSeconds: this._settings.requestTimeoutInSeconds }), s.debug("got response");
|
|
828
|
+
}
|
|
829
|
+
}, Ne = class {
|
|
830
|
+
constructor(e, t, s) {
|
|
831
|
+
this._settings = e, this._metadataService = t, this._claimsService = s, this._logger = new g("ResponseValidator"), this._userInfoService = new qe(this._settings, this._metadataService), this._tokenClient = new oe(this._settings, this._metadataService);
|
|
832
|
+
}
|
|
833
|
+
async validateSigninResponse(e, t, s) {
|
|
834
|
+
const i = this._logger.create("validateSigninResponse");
|
|
835
|
+
this._processSigninState(e, t), i.debug("state processed"), await this._processCode(e, t, s), i.debug("code processed"), e.isOpenId && this._validateIdTokenAttributes(e), i.debug("tokens validated"), await this._processClaims(e, t == null ? void 0 : t.skipUserInfo, e.isOpenId), i.debug("claims processed");
|
|
836
|
+
}
|
|
837
|
+
async validateCredentialsResponse(e, t) {
|
|
838
|
+
const s = this._logger.create("validateCredentialsResponse");
|
|
839
|
+
e.isOpenId && e.id_token && this._validateIdTokenAttributes(e), s.debug("tokens validated"), await this._processClaims(e, t, e.isOpenId), s.debug("claims processed");
|
|
840
|
+
}
|
|
841
|
+
async validateRefreshResponse(e, t) {
|
|
842
|
+
var s, i;
|
|
843
|
+
const r = this._logger.create("validateRefreshResponse");
|
|
844
|
+
e.userState = t.data, (s = e.session_state) != null || (e.session_state = t.session_state), (i = e.scope) != null || (e.scope = t.scope), e.isOpenId && e.id_token && (this._validateIdTokenAttributes(e, t.id_token), r.debug("ID Token validated")), e.id_token || (e.id_token = t.id_token, e.profile = t.profile);
|
|
845
|
+
const o = e.isOpenId && !!e.id_token;
|
|
846
|
+
await this._processClaims(e, !1, o), r.debug("claims processed");
|
|
847
|
+
}
|
|
848
|
+
validateSignoutResponse(e, t) {
|
|
849
|
+
const s = this._logger.create("validateSignoutResponse");
|
|
850
|
+
if (t.id !== e.state && s.throw(new Error("State does not match")), s.debug("state validated"), e.userState = t.data, e.error)
|
|
851
|
+
throw s.warn("Response was error", e.error), new q(e);
|
|
852
|
+
}
|
|
853
|
+
_processSigninState(e, t) {
|
|
854
|
+
var s;
|
|
855
|
+
const i = this._logger.create("_processSigninState");
|
|
856
|
+
if (t.id !== e.state && i.throw(new Error("State does not match")), t.client_id || i.throw(new Error("No client_id on state")), t.authority || i.throw(new Error("No authority on state")), this._settings.authority !== t.authority && i.throw(new Error("authority mismatch on settings vs. signin state")), this._settings.client_id && this._settings.client_id !== t.client_id && i.throw(new Error("client_id mismatch on settings vs. signin state")), i.debug("state validated"), e.userState = t.data, e.url_state = t.url_state, (s = e.scope) != null || (e.scope = t.scope), e.error)
|
|
857
|
+
throw i.warn("Response was error", e.error), new q(e);
|
|
858
|
+
t.code_verifier && !e.code && i.throw(new Error("Expected code in response"));
|
|
859
|
+
}
|
|
860
|
+
async _processClaims(e, t = !1, s = !0) {
|
|
861
|
+
const i = this._logger.create("_processClaims");
|
|
862
|
+
if (e.profile = this._claimsService.filterProtocolClaims(e.profile), t || !this._settings.loadUserInfo || !e.access_token) {
|
|
863
|
+
i.debug("not loading user info");
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
i.debug("loading user info");
|
|
867
|
+
const r = await this._userInfoService.getClaims(e.access_token);
|
|
868
|
+
i.debug("user info claims received from user info endpoint"), s && r.sub !== e.profile.sub && i.throw(new Error("subject from UserInfo response does not match subject in ID Token")), e.profile = this._claimsService.mergeClaims(e.profile, this._claimsService.filterProtocolClaims(r)), i.debug("user info claims received, updated profile:", e.profile);
|
|
869
|
+
}
|
|
870
|
+
async _processCode(e, t, s) {
|
|
871
|
+
const i = this._logger.create("_processCode");
|
|
872
|
+
if (e.code) {
|
|
873
|
+
i.debug("Validating code");
|
|
874
|
+
const r = await this._tokenClient.exchangeCode({
|
|
875
|
+
client_id: t.client_id,
|
|
876
|
+
client_secret: t.client_secret,
|
|
877
|
+
code: e.code,
|
|
878
|
+
redirect_uri: t.redirect_uri,
|
|
879
|
+
code_verifier: t.code_verifier,
|
|
880
|
+
extraHeaders: s,
|
|
881
|
+
...t.extraTokenParams
|
|
882
|
+
});
|
|
883
|
+
Object.assign(e, r);
|
|
884
|
+
} else
|
|
885
|
+
i.debug("No code to process");
|
|
886
|
+
}
|
|
887
|
+
_validateIdTokenAttributes(e, t) {
|
|
888
|
+
var s;
|
|
889
|
+
const i = this._logger.create("_validateIdTokenAttributes");
|
|
890
|
+
i.debug("decoding ID Token JWT");
|
|
891
|
+
const r = D.decode((s = e.id_token) != null ? s : "");
|
|
892
|
+
if (r.sub || i.throw(new Error("ID Token is missing a subject claim")), t) {
|
|
893
|
+
const o = D.decode(t);
|
|
894
|
+
r.sub !== o.sub && i.throw(new Error("sub in id_token does not match current sub")), r.auth_time && r.auth_time !== o.auth_time && i.throw(new Error("auth_time in id_token does not match original auth_time")), r.azp && r.azp !== o.azp && i.throw(new Error("azp in id_token does not match original azp")), !r.azp && o.azp && i.throw(new Error("azp not in id_token, but present in original id_token"));
|
|
895
|
+
}
|
|
896
|
+
e.profile = r;
|
|
897
|
+
}
|
|
898
|
+
}, W = class B {
|
|
899
|
+
constructor(t) {
|
|
900
|
+
this.id = t.id || f.generateUUIDv4(), this.data = t.data, t.created && t.created > 0 ? this.created = t.created : this.created = T.getEpochTime(), this.request_type = t.request_type, this.url_state = t.url_state;
|
|
901
|
+
}
|
|
902
|
+
toStorageString() {
|
|
903
|
+
return new g("State").create("toStorageString"), JSON.stringify({
|
|
904
|
+
id: this.id,
|
|
905
|
+
data: this.data,
|
|
906
|
+
created: this.created,
|
|
907
|
+
request_type: this.request_type,
|
|
908
|
+
url_state: this.url_state
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
static fromStorageString(t) {
|
|
912
|
+
return g.createStatic("State", "fromStorageString"), Promise.resolve(new B(JSON.parse(t)));
|
|
913
|
+
}
|
|
914
|
+
static async clearStaleState(t, s) {
|
|
915
|
+
const i = g.createStatic("State", "clearStaleState"), r = T.getEpochTime() - s, o = await t.getAllKeys();
|
|
916
|
+
i.debug("got keys", o);
|
|
917
|
+
for (let n = 0; n < o.length; n++) {
|
|
918
|
+
const c = o[n], a = await t.get(c);
|
|
919
|
+
let l = !1;
|
|
920
|
+
if (a)
|
|
921
|
+
try {
|
|
922
|
+
const d = await B.fromStorageString(a);
|
|
923
|
+
i.debug("got item from key:", c, d.created), d.created <= r && (l = !0);
|
|
924
|
+
} catch (d) {
|
|
925
|
+
i.error("Error parsing state for key:", c, d), l = !0;
|
|
926
|
+
}
|
|
927
|
+
else
|
|
928
|
+
i.debug("no item in storage for key:", c), l = !0;
|
|
929
|
+
l && (i.debug("removed item for key:", c), t.remove(c));
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}, ae = class V extends W {
|
|
933
|
+
constructor(t) {
|
|
934
|
+
super(t), this.code_verifier = t.code_verifier, this.code_challenge = t.code_challenge, this.authority = t.authority, this.client_id = t.client_id, this.redirect_uri = t.redirect_uri, this.scope = t.scope, this.client_secret = t.client_secret, this.extraTokenParams = t.extraTokenParams, this.response_mode = t.response_mode, this.skipUserInfo = t.skipUserInfo;
|
|
935
|
+
}
|
|
936
|
+
static async create(t) {
|
|
937
|
+
const s = t.code_verifier === !0 ? f.generateCodeVerifier() : t.code_verifier || void 0, i = s ? await f.generateCodeChallenge(s) : void 0;
|
|
938
|
+
return new V({
|
|
939
|
+
...t,
|
|
940
|
+
code_verifier: s,
|
|
941
|
+
code_challenge: i
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
toStorageString() {
|
|
945
|
+
return new g("SigninState").create("toStorageString"), JSON.stringify({
|
|
946
|
+
id: this.id,
|
|
947
|
+
data: this.data,
|
|
948
|
+
created: this.created,
|
|
949
|
+
request_type: this.request_type,
|
|
950
|
+
url_state: this.url_state,
|
|
951
|
+
code_verifier: this.code_verifier,
|
|
952
|
+
authority: this.authority,
|
|
953
|
+
client_id: this.client_id,
|
|
954
|
+
redirect_uri: this.redirect_uri,
|
|
955
|
+
scope: this.scope,
|
|
956
|
+
client_secret: this.client_secret,
|
|
957
|
+
extraTokenParams: this.extraTokenParams,
|
|
958
|
+
response_mode: this.response_mode,
|
|
959
|
+
skipUserInfo: this.skipUserInfo
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
static fromStorageString(t) {
|
|
963
|
+
g.createStatic("SigninState", "fromStorageString");
|
|
964
|
+
const s = JSON.parse(t);
|
|
965
|
+
return V.create(s);
|
|
966
|
+
}
|
|
967
|
+
}, ce = class le {
|
|
968
|
+
constructor(t) {
|
|
969
|
+
this.url = t.url, this.state = t.state;
|
|
970
|
+
}
|
|
971
|
+
static async create({
|
|
972
|
+
// mandatory
|
|
973
|
+
url: t,
|
|
974
|
+
authority: s,
|
|
975
|
+
client_id: i,
|
|
976
|
+
redirect_uri: r,
|
|
977
|
+
response_type: o,
|
|
978
|
+
scope: n,
|
|
979
|
+
// optional
|
|
980
|
+
state_data: c,
|
|
981
|
+
response_mode: a,
|
|
982
|
+
request_type: l,
|
|
983
|
+
client_secret: d,
|
|
984
|
+
nonce: h,
|
|
985
|
+
url_state: u,
|
|
986
|
+
resource: p,
|
|
987
|
+
skipUserInfo: x,
|
|
988
|
+
extraQueryParams: C,
|
|
989
|
+
extraTokenParams: U,
|
|
990
|
+
disablePKCE: A,
|
|
991
|
+
dpopJkt: R,
|
|
992
|
+
omitScopeWhenRequesting: P,
|
|
993
|
+
...O
|
|
994
|
+
}) {
|
|
995
|
+
if (!t)
|
|
996
|
+
throw this._logger.error("create: No url passed"), new Error("url");
|
|
997
|
+
if (!i)
|
|
998
|
+
throw this._logger.error("create: No client_id passed"), new Error("client_id");
|
|
999
|
+
if (!r)
|
|
1000
|
+
throw this._logger.error("create: No redirect_uri passed"), new Error("redirect_uri");
|
|
1001
|
+
if (!o)
|
|
1002
|
+
throw this._logger.error("create: No response_type passed"), new Error("response_type");
|
|
1003
|
+
if (!n)
|
|
1004
|
+
throw this._logger.error("create: No scope passed"), new Error("scope");
|
|
1005
|
+
if (!s)
|
|
1006
|
+
throw this._logger.error("create: No authority passed"), new Error("authority");
|
|
1007
|
+
const m = await ae.create({
|
|
1008
|
+
data: c,
|
|
1009
|
+
request_type: l,
|
|
1010
|
+
url_state: u,
|
|
1011
|
+
code_verifier: !A,
|
|
1012
|
+
client_id: i,
|
|
1013
|
+
authority: s,
|
|
1014
|
+
redirect_uri: r,
|
|
1015
|
+
response_mode: a,
|
|
1016
|
+
client_secret: d,
|
|
1017
|
+
scope: n,
|
|
1018
|
+
extraTokenParams: U,
|
|
1019
|
+
skipUserInfo: x
|
|
1020
|
+
}), _ = new URL(t);
|
|
1021
|
+
_.searchParams.append("client_id", i), _.searchParams.append("redirect_uri", r), _.searchParams.append("response_type", o), P || _.searchParams.append("scope", n), h && _.searchParams.append("nonce", h), R && _.searchParams.append("dpop_jkt", R);
|
|
1022
|
+
let E = m.id;
|
|
1023
|
+
u && (E = `${E}${N}${u}`), _.searchParams.append("state", E), m.code_challenge && (_.searchParams.append("code_challenge", m.code_challenge), _.searchParams.append("code_challenge_method", "S256")), p && (Array.isArray(p) ? p : [p]).forEach((w) => _.searchParams.append("resource", w));
|
|
1024
|
+
for (const [S, w] of Object.entries({ response_mode: a, ...O, ...C }))
|
|
1025
|
+
w != null && _.searchParams.append(S, w.toString());
|
|
1026
|
+
return new le({
|
|
1027
|
+
url: _.href,
|
|
1028
|
+
state: m
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
ce._logger = new g("SigninRequest");
|
|
1033
|
+
var Me = ce, je = "openid", $ = class {
|
|
1034
|
+
constructor(e) {
|
|
1035
|
+
if (this.access_token = "", this.token_type = "", this.profile = {}, this.state = e.get("state"), this.session_state = e.get("session_state"), this.state) {
|
|
1036
|
+
const t = decodeURIComponent(this.state).split(N);
|
|
1037
|
+
this.state = t[0], t.length > 1 && (this.url_state = t.slice(1).join(N));
|
|
1038
|
+
}
|
|
1039
|
+
this.error = e.get("error"), this.error_description = e.get("error_description"), this.error_uri = e.get("error_uri"), this.code = e.get("code");
|
|
1040
|
+
}
|
|
1041
|
+
get expires_in() {
|
|
1042
|
+
if (this.expires_at !== void 0)
|
|
1043
|
+
return this.expires_at - T.getEpochTime();
|
|
1044
|
+
}
|
|
1045
|
+
set expires_in(e) {
|
|
1046
|
+
typeof e == "string" && (e = Number(e)), e !== void 0 && e >= 0 && (this.expires_at = Math.floor(e) + T.getEpochTime());
|
|
1047
|
+
}
|
|
1048
|
+
get isOpenId() {
|
|
1049
|
+
var e;
|
|
1050
|
+
return ((e = this.scope) == null ? void 0 : e.split(" ").includes(je)) || !!this.id_token;
|
|
1051
|
+
}
|
|
1052
|
+
}, He = class {
|
|
1053
|
+
constructor({
|
|
1054
|
+
url: e,
|
|
1055
|
+
state_data: t,
|
|
1056
|
+
id_token_hint: s,
|
|
1057
|
+
post_logout_redirect_uri: i,
|
|
1058
|
+
extraQueryParams: r,
|
|
1059
|
+
request_type: o,
|
|
1060
|
+
client_id: n,
|
|
1061
|
+
url_state: c
|
|
1062
|
+
}) {
|
|
1063
|
+
if (this._logger = new g("SignoutRequest"), !e)
|
|
1064
|
+
throw this._logger.error("ctor: No url passed"), new Error("url");
|
|
1065
|
+
const a = new URL(e);
|
|
1066
|
+
if (s && a.searchParams.append("id_token_hint", s), n && a.searchParams.append("client_id", n), i && (a.searchParams.append("post_logout_redirect_uri", i), t || c)) {
|
|
1067
|
+
this.state = new W({ data: t, request_type: o, url_state: c });
|
|
1068
|
+
let l = this.state.id;
|
|
1069
|
+
c && (l = `${l}${N}${c}`), a.searchParams.append("state", l);
|
|
1070
|
+
}
|
|
1071
|
+
for (const [l, d] of Object.entries({ ...r }))
|
|
1072
|
+
d != null && a.searchParams.append(l, d.toString());
|
|
1073
|
+
this.url = a.href;
|
|
1074
|
+
}
|
|
1075
|
+
}, De = class {
|
|
1076
|
+
constructor(e) {
|
|
1077
|
+
if (this.state = e.get("state"), this.state) {
|
|
1078
|
+
const t = decodeURIComponent(this.state).split(N);
|
|
1079
|
+
this.state = t[0], t.length > 1 && (this.url_state = t.slice(1).join(N));
|
|
1080
|
+
}
|
|
1081
|
+
this.error = e.get("error"), this.error_description = e.get("error_description"), this.error_uri = e.get("error_uri");
|
|
1082
|
+
}
|
|
1083
|
+
}, We = [
|
|
1084
|
+
"nbf",
|
|
1085
|
+
"jti",
|
|
1086
|
+
"auth_time",
|
|
1087
|
+
"nonce",
|
|
1088
|
+
"acr",
|
|
1089
|
+
"amr",
|
|
1090
|
+
"azp",
|
|
1091
|
+
"at_hash"
|
|
1092
|
+
// https://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken
|
|
1093
|
+
], $e = ["sub", "iss", "aud", "exp", "iat"], Je = class {
|
|
1094
|
+
constructor(e) {
|
|
1095
|
+
this._settings = e, this._logger = new g("ClaimsService");
|
|
1096
|
+
}
|
|
1097
|
+
filterProtocolClaims(e) {
|
|
1098
|
+
const t = { ...e };
|
|
1099
|
+
if (this._settings.filterProtocolClaims) {
|
|
1100
|
+
let s;
|
|
1101
|
+
Array.isArray(this._settings.filterProtocolClaims) ? s = this._settings.filterProtocolClaims : s = We;
|
|
1102
|
+
for (const i of s)
|
|
1103
|
+
$e.includes(i) || delete t[i];
|
|
1104
|
+
}
|
|
1105
|
+
return t;
|
|
1106
|
+
}
|
|
1107
|
+
mergeClaims(e, t) {
|
|
1108
|
+
const s = { ...e };
|
|
1109
|
+
for (const [i, r] of Object.entries(t))
|
|
1110
|
+
if (s[i] !== r)
|
|
1111
|
+
if (Array.isArray(s[i]) || Array.isArray(r))
|
|
1112
|
+
if (this._settings.mergeClaimsStrategy.array == "replace")
|
|
1113
|
+
s[i] = r;
|
|
1114
|
+
else {
|
|
1115
|
+
const o = Array.isArray(s[i]) ? s[i] : [s[i]];
|
|
1116
|
+
for (const n of Array.isArray(r) ? r : [r])
|
|
1117
|
+
o.includes(n) || o.push(n);
|
|
1118
|
+
s[i] = o;
|
|
85
1119
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1120
|
+
else
|
|
1121
|
+
typeof s[i] == "object" && typeof r == "object" ? s[i] = this.mergeClaims(s[i], r) : s[i] = r;
|
|
1122
|
+
return s;
|
|
1123
|
+
}
|
|
1124
|
+
}, de = class {
|
|
1125
|
+
constructor(e, t) {
|
|
1126
|
+
this.keys = e, this.nonce = t;
|
|
1127
|
+
}
|
|
1128
|
+
}, Ke = class {
|
|
1129
|
+
constructor(e, t) {
|
|
1130
|
+
this._logger = new g("OidcClient"), this.settings = e instanceof z ? e : new z(e), this.metadataService = t ?? new xe(this.settings), this._claimsService = new Je(this.settings), this._validator = new Ne(this.settings, this.metadataService, this._claimsService), this._tokenClient = new oe(this.settings, this.metadataService);
|
|
1131
|
+
}
|
|
1132
|
+
async createSigninRequest({
|
|
1133
|
+
state: e,
|
|
1134
|
+
request: t,
|
|
1135
|
+
request_uri: s,
|
|
1136
|
+
request_type: i,
|
|
1137
|
+
id_token_hint: r,
|
|
1138
|
+
login_hint: o,
|
|
1139
|
+
skipUserInfo: n,
|
|
1140
|
+
nonce: c,
|
|
1141
|
+
url_state: a,
|
|
1142
|
+
response_type: l = this.settings.response_type,
|
|
1143
|
+
scope: d = this.settings.scope,
|
|
1144
|
+
redirect_uri: h = this.settings.redirect_uri,
|
|
1145
|
+
prompt: u = this.settings.prompt,
|
|
1146
|
+
display: p = this.settings.display,
|
|
1147
|
+
max_age: x = this.settings.max_age,
|
|
1148
|
+
ui_locales: C = this.settings.ui_locales,
|
|
1149
|
+
acr_values: U = this.settings.acr_values,
|
|
1150
|
+
resource: A = this.settings.resource,
|
|
1151
|
+
response_mode: R = this.settings.response_mode,
|
|
1152
|
+
extraQueryParams: P = this.settings.extraQueryParams,
|
|
1153
|
+
extraTokenParams: O = this.settings.extraTokenParams,
|
|
1154
|
+
dpopJkt: m,
|
|
1155
|
+
omitScopeWhenRequesting: _ = this.settings.omitScopeWhenRequesting
|
|
1156
|
+
}) {
|
|
1157
|
+
const E = this._logger.create("createSigninRequest");
|
|
1158
|
+
if (l !== "code")
|
|
1159
|
+
throw new Error("Only the Authorization Code flow (with PKCE) is supported");
|
|
1160
|
+
const S = await this.metadataService.getAuthorizationEndpoint();
|
|
1161
|
+
E.debug("Received authorization endpoint", S);
|
|
1162
|
+
const w = await Me.create({
|
|
1163
|
+
url: S,
|
|
1164
|
+
authority: this.settings.authority,
|
|
1165
|
+
client_id: this.settings.client_id,
|
|
1166
|
+
redirect_uri: h,
|
|
1167
|
+
response_type: l,
|
|
1168
|
+
scope: d,
|
|
1169
|
+
state_data: e,
|
|
1170
|
+
url_state: a,
|
|
1171
|
+
prompt: u,
|
|
1172
|
+
display: p,
|
|
1173
|
+
max_age: x,
|
|
1174
|
+
ui_locales: C,
|
|
1175
|
+
id_token_hint: r,
|
|
1176
|
+
login_hint: o,
|
|
1177
|
+
acr_values: U,
|
|
1178
|
+
dpopJkt: m,
|
|
1179
|
+
resource: A,
|
|
1180
|
+
request: t,
|
|
1181
|
+
request_uri: s,
|
|
1182
|
+
extraQueryParams: P,
|
|
1183
|
+
extraTokenParams: O,
|
|
1184
|
+
request_type: i,
|
|
1185
|
+
response_mode: R,
|
|
1186
|
+
client_secret: this.settings.client_secret,
|
|
1187
|
+
skipUserInfo: n,
|
|
1188
|
+
nonce: c,
|
|
1189
|
+
disablePKCE: this.settings.disablePKCE,
|
|
1190
|
+
omitScopeWhenRequesting: _
|
|
1191
|
+
});
|
|
1192
|
+
await this.clearStaleState();
|
|
1193
|
+
const M = w.state;
|
|
1194
|
+
return await this.settings.stateStore.set(M.id, M.toStorageString()), w;
|
|
1195
|
+
}
|
|
1196
|
+
async readSigninResponseState(e, t = !1) {
|
|
1197
|
+
const s = this._logger.create("readSigninResponseState"), i = new $(F.readParams(e, this.settings.response_mode));
|
|
1198
|
+
if (!i.state)
|
|
1199
|
+
throw s.throw(new Error("No state in response")), null;
|
|
1200
|
+
const r = await this.settings.stateStore[t ? "remove" : "get"](i.state);
|
|
1201
|
+
if (!r)
|
|
1202
|
+
throw s.throw(new Error("No matching state found in storage")), null;
|
|
1203
|
+
return { state: await ae.fromStorageString(r), response: i };
|
|
1204
|
+
}
|
|
1205
|
+
async processSigninResponse(e, t, s = !0) {
|
|
1206
|
+
const i = this._logger.create("processSigninResponse"), { state: r, response: o } = await this.readSigninResponseState(e, s);
|
|
1207
|
+
if (i.debug("received state from storage; validating response"), this.settings.dpop && this.settings.dpop.store) {
|
|
1208
|
+
const n = await this.getDpopProof(this.settings.dpop.store);
|
|
1209
|
+
t = { ...t, DPoP: n };
|
|
1210
|
+
}
|
|
1211
|
+
try {
|
|
1212
|
+
await this._validator.validateSigninResponse(o, r, t);
|
|
1213
|
+
} catch (n) {
|
|
1214
|
+
if (n instanceof L && this.settings.dpop) {
|
|
1215
|
+
const c = await this.getDpopProof(this.settings.dpop.store, n.nonce);
|
|
1216
|
+
t.DPoP = c, await this._validator.validateSigninResponse(o, r, t);
|
|
1217
|
+
} else
|
|
1218
|
+
throw n;
|
|
1219
|
+
}
|
|
1220
|
+
return o;
|
|
1221
|
+
}
|
|
1222
|
+
async getDpopProof(e, t) {
|
|
1223
|
+
let s, i;
|
|
1224
|
+
return (await e.getAllKeys()).includes(this.settings.client_id) ? (i = await e.get(this.settings.client_id), i.nonce !== t && t && (i.nonce = t, await e.set(this.settings.client_id, i))) : (s = await f.generateDPoPKeys(), i = new de(s, t), await e.set(this.settings.client_id, i)), await f.generateDPoPProof({
|
|
1225
|
+
url: await this.metadataService.getTokenEndpoint(!1),
|
|
1226
|
+
httpMethod: "POST",
|
|
1227
|
+
keyPair: i.keys,
|
|
1228
|
+
nonce: i.nonce
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
async processResourceOwnerPasswordCredentials({
|
|
1232
|
+
username: e,
|
|
1233
|
+
password: t,
|
|
1234
|
+
skipUserInfo: s = !1,
|
|
1235
|
+
extraTokenParams: i = {}
|
|
1236
|
+
}) {
|
|
1237
|
+
const r = await this._tokenClient.exchangeCredentials({ username: e, password: t, ...i }), o = new $(new URLSearchParams());
|
|
1238
|
+
return Object.assign(o, r), await this._validator.validateCredentialsResponse(o, s), o;
|
|
1239
|
+
}
|
|
1240
|
+
async useRefreshToken({
|
|
1241
|
+
state: e,
|
|
1242
|
+
redirect_uri: t,
|
|
1243
|
+
resource: s,
|
|
1244
|
+
timeoutInSeconds: i,
|
|
1245
|
+
extraHeaders: r,
|
|
1246
|
+
extraTokenParams: o
|
|
1247
|
+
}) {
|
|
1248
|
+
var n;
|
|
1249
|
+
const c = this._logger.create("useRefreshToken");
|
|
1250
|
+
let a;
|
|
1251
|
+
if (this.settings.refreshTokenAllowedScope === void 0)
|
|
1252
|
+
a = e.scope;
|
|
1253
|
+
else {
|
|
1254
|
+
const h = this.settings.refreshTokenAllowedScope.split(" ");
|
|
1255
|
+
a = (((n = e.scope) == null ? void 0 : n.split(" ")) || []).filter((p) => h.includes(p)).join(" ");
|
|
1256
|
+
}
|
|
1257
|
+
if (this.settings.dpop && this.settings.dpop.store) {
|
|
1258
|
+
const h = await this.getDpopProof(this.settings.dpop.store);
|
|
1259
|
+
r = { ...r, DPoP: h };
|
|
1260
|
+
}
|
|
1261
|
+
let l;
|
|
1262
|
+
try {
|
|
1263
|
+
l = await this._tokenClient.exchangeRefreshToken({
|
|
1264
|
+
refresh_token: e.refresh_token,
|
|
1265
|
+
// provide the (possible filtered) scope list
|
|
1266
|
+
scope: a,
|
|
1267
|
+
redirect_uri: t,
|
|
1268
|
+
resource: s,
|
|
1269
|
+
timeoutInSeconds: i,
|
|
1270
|
+
extraHeaders: r,
|
|
1271
|
+
...o
|
|
1272
|
+
});
|
|
1273
|
+
} catch (h) {
|
|
1274
|
+
if (h instanceof L && this.settings.dpop)
|
|
1275
|
+
r.DPoP = await this.getDpopProof(this.settings.dpop.store, h.nonce), l = await this._tokenClient.exchangeRefreshToken({
|
|
1276
|
+
refresh_token: e.refresh_token,
|
|
1277
|
+
// provide the (possible filtered) scope list
|
|
1278
|
+
scope: a,
|
|
1279
|
+
redirect_uri: t,
|
|
1280
|
+
resource: s,
|
|
1281
|
+
timeoutInSeconds: i,
|
|
1282
|
+
extraHeaders: r,
|
|
1283
|
+
...o
|
|
1284
|
+
});
|
|
1285
|
+
else
|
|
1286
|
+
throw h;
|
|
1287
|
+
}
|
|
1288
|
+
const d = new $(new URLSearchParams());
|
|
1289
|
+
return Object.assign(d, l), c.debug("validating response", d), await this._validator.validateRefreshResponse(d, {
|
|
1290
|
+
...e,
|
|
1291
|
+
// override the scope in the state handed over to the validator
|
|
1292
|
+
// so it can set the granted scope to the requested scope in case none is included in the response
|
|
1293
|
+
scope: a
|
|
1294
|
+
}), d;
|
|
1295
|
+
}
|
|
1296
|
+
async createSignoutRequest({
|
|
1297
|
+
state: e,
|
|
1298
|
+
id_token_hint: t,
|
|
1299
|
+
client_id: s,
|
|
1300
|
+
request_type: i,
|
|
1301
|
+
url_state: r,
|
|
1302
|
+
post_logout_redirect_uri: o = this.settings.post_logout_redirect_uri,
|
|
1303
|
+
extraQueryParams: n = this.settings.extraQueryParams
|
|
1304
|
+
} = {}) {
|
|
1305
|
+
const c = this._logger.create("createSignoutRequest"), a = await this.metadataService.getEndSessionEndpoint();
|
|
1306
|
+
if (!a)
|
|
1307
|
+
throw c.throw(new Error("No end session endpoint")), null;
|
|
1308
|
+
c.debug("Received end session endpoint", a), !s && o && !t && (s = this.settings.client_id);
|
|
1309
|
+
const l = new He({
|
|
1310
|
+
url: a,
|
|
1311
|
+
id_token_hint: t,
|
|
1312
|
+
client_id: s,
|
|
1313
|
+
post_logout_redirect_uri: o,
|
|
1314
|
+
state_data: e,
|
|
1315
|
+
extraQueryParams: n,
|
|
1316
|
+
request_type: i,
|
|
1317
|
+
url_state: r
|
|
1318
|
+
});
|
|
1319
|
+
await this.clearStaleState();
|
|
1320
|
+
const d = l.state;
|
|
1321
|
+
return d && (c.debug("Signout request has state to persist"), await this.settings.stateStore.set(d.id, d.toStorageString())), l;
|
|
1322
|
+
}
|
|
1323
|
+
async readSignoutResponseState(e, t = !1) {
|
|
1324
|
+
const s = this._logger.create("readSignoutResponseState"), i = new De(F.readParams(e, this.settings.response_mode));
|
|
1325
|
+
if (!i.state) {
|
|
1326
|
+
if (s.debug("No state in response"), i.error)
|
|
1327
|
+
throw s.warn("Response was error:", i.error), new q(i);
|
|
1328
|
+
return { state: void 0, response: i };
|
|
1329
|
+
}
|
|
1330
|
+
const r = await this.settings.stateStore[t ? "remove" : "get"](i.state);
|
|
1331
|
+
if (!r)
|
|
1332
|
+
throw s.throw(new Error("No matching state found in storage")), null;
|
|
1333
|
+
return { state: await W.fromStorageString(r), response: i };
|
|
1334
|
+
}
|
|
1335
|
+
async processSignoutResponse(e) {
|
|
1336
|
+
const t = this._logger.create("processSignoutResponse"), { state: s, response: i } = await this.readSignoutResponseState(e, !0);
|
|
1337
|
+
return s ? (t.debug("Received state from storage; validating response"), this._validator.validateSignoutResponse(i, s)) : t.debug("No state from storage; skipping response validation"), i;
|
|
1338
|
+
}
|
|
1339
|
+
clearStaleState() {
|
|
1340
|
+
return this._logger.create("clearStaleState"), W.clearStaleState(this.settings.stateStore, this.settings.staleStateAgeInSeconds);
|
|
1341
|
+
}
|
|
1342
|
+
async revokeToken(e, t) {
|
|
1343
|
+
return this._logger.create("revokeToken"), await this._tokenClient.revoke({
|
|
1344
|
+
token: e,
|
|
1345
|
+
token_type_hint: t
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
}, Fe = class {
|
|
1349
|
+
constructor(e) {
|
|
1350
|
+
this._userManager = e, this._logger = new g("SessionMonitor"), this._start = async (t) => {
|
|
1351
|
+
const s = t.session_state;
|
|
1352
|
+
if (!s)
|
|
1353
|
+
return;
|
|
1354
|
+
const i = this._logger.create("_start");
|
|
1355
|
+
if (t.profile ? (this._sub = t.profile.sub, i.debug("session_state", s, ", sub", this._sub)) : (this._sub = void 0, i.debug("session_state", s, ", anonymous user")), this._checkSessionIFrame) {
|
|
1356
|
+
this._checkSessionIFrame.start(s);
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
try {
|
|
1360
|
+
const r = await this._userManager.metadataService.getCheckSessionIframe();
|
|
1361
|
+
if (r) {
|
|
1362
|
+
i.debug("initializing check session iframe");
|
|
1363
|
+
const o = this._userManager.settings.client_id, n = this._userManager.settings.checkSessionIntervalInSeconds, c = this._userManager.settings.stopCheckSessionOnError, a = new Ie(this._callback, o, r, n, c);
|
|
1364
|
+
await a.load(), this._checkSessionIFrame = a, a.start(s);
|
|
1365
|
+
} else
|
|
1366
|
+
i.warn("no check session iframe found in the metadata");
|
|
1367
|
+
} catch (r) {
|
|
1368
|
+
i.error("Error from getCheckSessionIframe:", r instanceof Error ? r.message : r);
|
|
1369
|
+
}
|
|
1370
|
+
}, this._stop = () => {
|
|
1371
|
+
const t = this._logger.create("_stop");
|
|
1372
|
+
if (this._sub = void 0, this._checkSessionIFrame && this._checkSessionIFrame.stop(), this._userManager.settings.monitorAnonymousSession) {
|
|
1373
|
+
const s = setInterval(async () => {
|
|
1374
|
+
clearInterval(s);
|
|
1375
|
+
try {
|
|
1376
|
+
const i = await this._userManager.querySessionStatus();
|
|
1377
|
+
if (i) {
|
|
1378
|
+
const r = {
|
|
1379
|
+
session_state: i.session_state,
|
|
1380
|
+
profile: i.sub ? {
|
|
1381
|
+
sub: i.sub
|
|
1382
|
+
} : null
|
|
1383
|
+
};
|
|
1384
|
+
this._start(r);
|
|
95
1385
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
1386
|
+
} catch (i) {
|
|
1387
|
+
t.error("error from querySessionStatus", i instanceof Error ? i.message : i);
|
|
1388
|
+
}
|
|
1389
|
+
}, 1e3);
|
|
1390
|
+
}
|
|
1391
|
+
}, this._callback = async () => {
|
|
1392
|
+
const t = this._logger.create("_callback");
|
|
1393
|
+
try {
|
|
1394
|
+
const s = await this._userManager.querySessionStatus();
|
|
1395
|
+
let i = !0;
|
|
1396
|
+
s && this._checkSessionIFrame ? s.sub === this._sub ? (i = !1, this._checkSessionIFrame.start(s.session_state), t.debug("same sub still logged in at OP, session state has changed, restarting check session iframe; session_state", s.session_state), await this._userManager.events._raiseUserSessionChanged()) : t.debug("different subject signed into OP", s.sub) : t.debug("subject no longer signed into OP"), i ? this._sub ? await this._userManager.events._raiseUserSignedOut() : await this._userManager.events._raiseUserSignedIn() : t.debug("no change in session detected, no event to raise");
|
|
1397
|
+
} catch (s) {
|
|
1398
|
+
this._sub && (t.debug("Error calling queryCurrentSigninSession; raising signed out event", s), await this._userManager.events._raiseUserSignedOut());
|
|
1399
|
+
}
|
|
1400
|
+
}, e || this._logger.throw(new Error("No user manager passed")), this._userManager.events.addUserLoaded(this._start), this._userManager.events.addUserUnloaded(this._stop), this._init().catch((t) => {
|
|
1401
|
+
this._logger.error(t);
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
async _init() {
|
|
1405
|
+
this._logger.create("_init");
|
|
1406
|
+
const e = await this._userManager.getUser();
|
|
1407
|
+
if (e)
|
|
1408
|
+
this._start(e);
|
|
1409
|
+
else if (this._userManager.settings.monitorAnonymousSession) {
|
|
1410
|
+
const t = await this._userManager.querySessionStatus();
|
|
1411
|
+
if (t) {
|
|
1412
|
+
const s = {
|
|
1413
|
+
session_state: t.session_state,
|
|
1414
|
+
profile: t.sub ? {
|
|
1415
|
+
sub: t.sub
|
|
1416
|
+
} : null
|
|
1417
|
+
};
|
|
1418
|
+
this._start(s);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
}, J = class he {
|
|
1423
|
+
constructor(t) {
|
|
1424
|
+
var s;
|
|
1425
|
+
this.id_token = t.id_token, this.session_state = (s = t.session_state) != null ? s : null, this.access_token = t.access_token, this.refresh_token = t.refresh_token, this.token_type = t.token_type, this.scope = t.scope, this.profile = t.profile, this.expires_at = t.expires_at, this.state = t.userState, this.url_state = t.url_state;
|
|
1426
|
+
}
|
|
1427
|
+
/** Computed number of seconds the access token has remaining. */
|
|
1428
|
+
get expires_in() {
|
|
1429
|
+
if (this.expires_at !== void 0)
|
|
1430
|
+
return this.expires_at - T.getEpochTime();
|
|
1431
|
+
}
|
|
1432
|
+
set expires_in(t) {
|
|
1433
|
+
t !== void 0 && (this.expires_at = Math.floor(t) + T.getEpochTime());
|
|
1434
|
+
}
|
|
1435
|
+
/** Computed value indicating if the access token is expired. */
|
|
1436
|
+
get expired() {
|
|
1437
|
+
const t = this.expires_in;
|
|
1438
|
+
if (t !== void 0)
|
|
1439
|
+
return t <= 0;
|
|
1440
|
+
}
|
|
1441
|
+
/** Array representing the parsed values from the `scope`. */
|
|
1442
|
+
get scopes() {
|
|
1443
|
+
var t, s;
|
|
1444
|
+
return (s = (t = this.scope) == null ? void 0 : t.split(" ")) != null ? s : [];
|
|
1445
|
+
}
|
|
1446
|
+
toStorageString() {
|
|
1447
|
+
return new g("User").create("toStorageString"), JSON.stringify({
|
|
1448
|
+
id_token: this.id_token,
|
|
1449
|
+
session_state: this.session_state,
|
|
1450
|
+
access_token: this.access_token,
|
|
1451
|
+
refresh_token: this.refresh_token,
|
|
1452
|
+
token_type: this.token_type,
|
|
1453
|
+
scope: this.scope,
|
|
1454
|
+
profile: this.profile,
|
|
1455
|
+
expires_at: this.expires_at
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
static fromStorageString(t) {
|
|
1459
|
+
return g.createStatic("User", "fromStorageString"), new he(JSON.parse(t));
|
|
1460
|
+
}
|
|
1461
|
+
}, ee = "oidc-client", ge = class {
|
|
1462
|
+
constructor() {
|
|
1463
|
+
this._abort = new I("Window navigation aborted"), this._disposeHandlers = /* @__PURE__ */ new Set(), this._window = null;
|
|
1464
|
+
}
|
|
1465
|
+
async navigate(e) {
|
|
1466
|
+
const t = this._logger.create("navigate");
|
|
1467
|
+
if (!this._window)
|
|
1468
|
+
throw new Error("Attempted to navigate on a disposed window");
|
|
1469
|
+
t.debug("setting URL in window"), this._window.location.replace(e.url);
|
|
1470
|
+
const { url: s, keepOpen: i } = await new Promise((r, o) => {
|
|
1471
|
+
const n = (c) => {
|
|
1472
|
+
var a;
|
|
1473
|
+
const l = c.data, d = (a = e.scriptOrigin) != null ? a : window.location.origin;
|
|
1474
|
+
if (!(c.origin !== d || (l == null ? void 0 : l.source) !== ee)) {
|
|
1475
|
+
try {
|
|
1476
|
+
const h = F.readParams(l.url, e.response_mode).get("state");
|
|
1477
|
+
if (h || t.warn("no state found in response url"), c.source !== this._window && h !== e.state)
|
|
117
1478
|
return;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// FIXME no-any
|
|
121
|
-
e
|
|
122
|
-
);
|
|
123
|
-
return;
|
|
1479
|
+
} catch {
|
|
1480
|
+
this._dispose(), o(new Error("Invalid response from window"));
|
|
124
1481
|
}
|
|
125
|
-
|
|
126
|
-
return _ = !_;
|
|
1482
|
+
r(l);
|
|
127
1483
|
}
|
|
1484
|
+
};
|
|
1485
|
+
window.addEventListener("message", n, !1), this._disposeHandlers.add(() => window.removeEventListener("message", n, !1)), this._disposeHandlers.add(this._abort.addHandler((c) => {
|
|
1486
|
+
this._dispose(), o(c);
|
|
1487
|
+
}));
|
|
1488
|
+
});
|
|
1489
|
+
return t.debug("got response from window"), this._dispose(), i || this.close(), { url: s };
|
|
1490
|
+
}
|
|
1491
|
+
_dispose() {
|
|
1492
|
+
this._logger.create("_dispose");
|
|
1493
|
+
for (const e of this._disposeHandlers)
|
|
1494
|
+
e();
|
|
1495
|
+
this._disposeHandlers.clear();
|
|
1496
|
+
}
|
|
1497
|
+
static _notifyParent(e, t, s = !1, i = window.location.origin) {
|
|
1498
|
+
e.postMessage({
|
|
1499
|
+
source: ee,
|
|
1500
|
+
url: t,
|
|
1501
|
+
keepOpen: s
|
|
1502
|
+
}, i);
|
|
1503
|
+
}
|
|
1504
|
+
}, ue = {
|
|
1505
|
+
location: !1,
|
|
1506
|
+
toolbar: !1,
|
|
1507
|
+
height: 640,
|
|
1508
|
+
closePopupWindowAfterInSeconds: -1
|
|
1509
|
+
}, _e = "_blank", Le = 60, ze = 2, pe = 10, Be = class extends z {
|
|
1510
|
+
constructor(e) {
|
|
1511
|
+
const {
|
|
1512
|
+
popup_redirect_uri: t = e.redirect_uri,
|
|
1513
|
+
popup_post_logout_redirect_uri: s = e.post_logout_redirect_uri,
|
|
1514
|
+
popupWindowFeatures: i = ue,
|
|
1515
|
+
popupWindowTarget: r = _e,
|
|
1516
|
+
redirectMethod: o = "assign",
|
|
1517
|
+
redirectTarget: n = "self",
|
|
1518
|
+
iframeNotifyParentOrigin: c = e.iframeNotifyParentOrigin,
|
|
1519
|
+
iframeScriptOrigin: a = e.iframeScriptOrigin,
|
|
1520
|
+
requestTimeoutInSeconds: l,
|
|
1521
|
+
silent_redirect_uri: d = e.redirect_uri,
|
|
1522
|
+
silentRequestTimeoutInSeconds: h,
|
|
1523
|
+
automaticSilentRenew: u = !0,
|
|
1524
|
+
validateSubOnSilentRenew: p = !0,
|
|
1525
|
+
includeIdTokenInSilentRenew: x = !1,
|
|
1526
|
+
monitorSession: C = !1,
|
|
1527
|
+
monitorAnonymousSession: U = !1,
|
|
1528
|
+
checkSessionIntervalInSeconds: A = ze,
|
|
1529
|
+
query_status_response_type: R = "code",
|
|
1530
|
+
stopCheckSessionOnError: P = !0,
|
|
1531
|
+
revokeTokenTypes: O = ["access_token", "refresh_token"],
|
|
1532
|
+
revokeTokensOnSignout: m = !1,
|
|
1533
|
+
includeIdTokenInSilentSignout: _ = !1,
|
|
1534
|
+
accessTokenExpiringNotificationTimeInSeconds: E = Le,
|
|
1535
|
+
userStore: S
|
|
1536
|
+
} = e;
|
|
1537
|
+
if (super(e), this.popup_redirect_uri = t, this.popup_post_logout_redirect_uri = s, this.popupWindowFeatures = i, this.popupWindowTarget = r, this.redirectMethod = o, this.redirectTarget = n, this.iframeNotifyParentOrigin = c, this.iframeScriptOrigin = a, this.silent_redirect_uri = d, this.silentRequestTimeoutInSeconds = h || l || pe, this.automaticSilentRenew = u, this.validateSubOnSilentRenew = p, this.includeIdTokenInSilentRenew = x, this.monitorSession = C, this.monitorAnonymousSession = U, this.checkSessionIntervalInSeconds = A, this.stopCheckSessionOnError = P, this.query_status_response_type = R, this.revokeTokenTypes = O, this.revokeTokensOnSignout = m, this.includeIdTokenInSilentSignout = _, this.accessTokenExpiringNotificationTimeInSeconds = E, S)
|
|
1538
|
+
this.userStore = S;
|
|
1539
|
+
else {
|
|
1540
|
+
const w = typeof window < "u" ? window.sessionStorage : new re();
|
|
1541
|
+
this.userStore = new ne({ store: w });
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}, te = class fe extends ge {
|
|
1545
|
+
constructor({
|
|
1546
|
+
silentRequestTimeoutInSeconds: t = pe
|
|
1547
|
+
}) {
|
|
1548
|
+
super(), this._logger = new g("IFrameWindow"), this._timeoutInSeconds = t, this._frame = fe.createHiddenIframe(), this._window = this._frame.contentWindow;
|
|
1549
|
+
}
|
|
1550
|
+
static createHiddenIframe() {
|
|
1551
|
+
const t = window.document.createElement("iframe");
|
|
1552
|
+
return t.style.visibility = "hidden", t.style.position = "fixed", t.style.left = "-1000px", t.style.top = "0", t.width = "0", t.height = "0", window.document.body.appendChild(t), t;
|
|
1553
|
+
}
|
|
1554
|
+
async navigate(t) {
|
|
1555
|
+
this._logger.debug("navigate: Using timeout of:", this._timeoutInSeconds);
|
|
1556
|
+
const s = setTimeout(() => void this._abort.raise(new G("IFrame timed out without a response")), this._timeoutInSeconds * 1e3);
|
|
1557
|
+
return this._disposeHandlers.add(() => clearTimeout(s)), await super.navigate(t);
|
|
1558
|
+
}
|
|
1559
|
+
close() {
|
|
1560
|
+
var t;
|
|
1561
|
+
this._frame && (this._frame.parentNode && (this._frame.addEventListener("load", (s) => {
|
|
1562
|
+
var i;
|
|
1563
|
+
const r = s.target;
|
|
1564
|
+
(i = r.parentNode) == null || i.removeChild(r), this._abort.raise(new Error("IFrame removed from DOM"));
|
|
1565
|
+
}, !0), (t = this._frame.contentWindow) == null || t.location.replace("about:blank")), this._frame = null), this._window = null;
|
|
1566
|
+
}
|
|
1567
|
+
static notifyParent(t, s) {
|
|
1568
|
+
return super._notifyParent(window.parent, t, !1, s);
|
|
1569
|
+
}
|
|
1570
|
+
}, Ve = class {
|
|
1571
|
+
constructor(e) {
|
|
1572
|
+
this._settings = e, this._logger = new g("IFrameNavigator");
|
|
1573
|
+
}
|
|
1574
|
+
async prepare({
|
|
1575
|
+
silentRequestTimeoutInSeconds: e = this._settings.silentRequestTimeoutInSeconds
|
|
1576
|
+
}) {
|
|
1577
|
+
return new te({ silentRequestTimeoutInSeconds: e });
|
|
1578
|
+
}
|
|
1579
|
+
async callback(e) {
|
|
1580
|
+
this._logger.create("callback"), te.notifyParent(e, this._settings.iframeNotifyParentOrigin);
|
|
1581
|
+
}
|
|
1582
|
+
}, Ge = 500, Qe = 1e3, se = class extends ge {
|
|
1583
|
+
constructor({
|
|
1584
|
+
popupWindowTarget: e = _e,
|
|
1585
|
+
popupWindowFeatures: t = {},
|
|
1586
|
+
popupSignal: s
|
|
1587
|
+
}) {
|
|
1588
|
+
super(), this._logger = new g("PopupWindow");
|
|
1589
|
+
const i = Z.center({ ...ue, ...t });
|
|
1590
|
+
this._window = window.open(void 0, e, Z.serialize(i)), s && s.addEventListener("abort", () => {
|
|
1591
|
+
var r;
|
|
1592
|
+
this._abort.raise(new Error((r = s.reason) != null ? r : "Popup aborted"));
|
|
1593
|
+
}), t.closePopupWindowAfterInSeconds && t.closePopupWindowAfterInSeconds > 0 && setTimeout(() => {
|
|
1594
|
+
if (!this._window || typeof this._window.closed != "boolean" || this._window.closed) {
|
|
1595
|
+
this._abort.raise(new Error("Popup blocked by user"));
|
|
128
1596
|
return;
|
|
1597
|
+
}
|
|
1598
|
+
this.close();
|
|
1599
|
+
}, t.closePopupWindowAfterInSeconds * Qe);
|
|
1600
|
+
}
|
|
1601
|
+
async navigate(e) {
|
|
1602
|
+
var t;
|
|
1603
|
+
(t = this._window) == null || t.focus();
|
|
1604
|
+
const s = setInterval(() => {
|
|
1605
|
+
(!this._window || this._window.closed) && this._abort.raise(new Error("Popup closed by user"));
|
|
1606
|
+
}, Ge);
|
|
1607
|
+
return this._disposeHandlers.add(() => clearInterval(s)), await super.navigate(e);
|
|
1608
|
+
}
|
|
1609
|
+
close() {
|
|
1610
|
+
this._window && (this._window.closed || (this._window.close(), this._abort.raise(new Error("Popup closed")))), this._window = null;
|
|
1611
|
+
}
|
|
1612
|
+
static notifyOpener(e, t) {
|
|
1613
|
+
if (!window.opener)
|
|
1614
|
+
throw new Error("No window.opener. Can't complete notification.");
|
|
1615
|
+
return super._notifyParent(window.opener, e, t);
|
|
1616
|
+
}
|
|
1617
|
+
}, Xe = class {
|
|
1618
|
+
constructor(e) {
|
|
1619
|
+
this._settings = e, this._logger = new g("PopupNavigator");
|
|
1620
|
+
}
|
|
1621
|
+
async prepare({
|
|
1622
|
+
popupWindowFeatures: e = this._settings.popupWindowFeatures,
|
|
1623
|
+
popupWindowTarget: t = this._settings.popupWindowTarget,
|
|
1624
|
+
popupSignal: s
|
|
1625
|
+
}) {
|
|
1626
|
+
return new se({ popupWindowFeatures: e, popupWindowTarget: t, popupSignal: s });
|
|
1627
|
+
}
|
|
1628
|
+
async callback(e, { keepOpen: t = !1 }) {
|
|
1629
|
+
this._logger.create("callback"), se.notifyOpener(e, t);
|
|
1630
|
+
}
|
|
1631
|
+
}, Ye = class {
|
|
1632
|
+
constructor(e) {
|
|
1633
|
+
this._settings = e, this._logger = new g("RedirectNavigator");
|
|
1634
|
+
}
|
|
1635
|
+
async prepare({
|
|
1636
|
+
redirectMethod: e = this._settings.redirectMethod,
|
|
1637
|
+
redirectTarget: t = this._settings.redirectTarget
|
|
1638
|
+
}) {
|
|
1639
|
+
var s;
|
|
1640
|
+
this._logger.create("prepare");
|
|
1641
|
+
let i = window.self;
|
|
1642
|
+
t === "top" && (i = (s = window.top) != null ? s : window.self);
|
|
1643
|
+
const r = i.location[e].bind(i.location);
|
|
1644
|
+
let o;
|
|
1645
|
+
return {
|
|
1646
|
+
navigate: async (n) => {
|
|
1647
|
+
this._logger.create("navigate");
|
|
1648
|
+
const c = new Promise((a, l) => {
|
|
1649
|
+
o = l;
|
|
1650
|
+
});
|
|
1651
|
+
return r(n.url), await c;
|
|
1652
|
+
},
|
|
1653
|
+
close: () => {
|
|
1654
|
+
this._logger.create("close"), o == null || o(new Error("Redirect aborted")), i.stop();
|
|
1655
|
+
}
|
|
1656
|
+
};
|
|
1657
|
+
}
|
|
1658
|
+
async callback() {
|
|
1659
|
+
}
|
|
1660
|
+
}, Ze = class extends Pe {
|
|
1661
|
+
constructor(e) {
|
|
1662
|
+
super({ expiringNotificationTimeInSeconds: e.accessTokenExpiringNotificationTimeInSeconds }), this._logger = new g("UserManagerEvents"), this._userLoaded = new I("User loaded"), this._userUnloaded = new I("User unloaded"), this._silentRenewError = new I("Silent renew error"), this._userSignedIn = new I("User signed in"), this._userSignedOut = new I("User signed out"), this._userSessionChanged = new I("User session changed");
|
|
1663
|
+
}
|
|
1664
|
+
async load(e, t = !0) {
|
|
1665
|
+
await super.load(e), t && await this._userLoaded.raise(e);
|
|
1666
|
+
}
|
|
1667
|
+
async unload() {
|
|
1668
|
+
await super.unload(), await this._userUnloaded.raise();
|
|
1669
|
+
}
|
|
1670
|
+
/**
|
|
1671
|
+
* Add callback: Raised when a user session has been established (or re-established).
|
|
1672
|
+
*/
|
|
1673
|
+
addUserLoaded(e) {
|
|
1674
|
+
return this._userLoaded.addHandler(e);
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* Remove callback: Raised when a user session has been established (or re-established).
|
|
1678
|
+
*/
|
|
1679
|
+
removeUserLoaded(e) {
|
|
1680
|
+
return this._userLoaded.removeHandler(e);
|
|
1681
|
+
}
|
|
1682
|
+
/**
|
|
1683
|
+
* Add callback: Raised when a user session has been terminated.
|
|
1684
|
+
*/
|
|
1685
|
+
addUserUnloaded(e) {
|
|
1686
|
+
return this._userUnloaded.addHandler(e);
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Remove callback: Raised when a user session has been terminated.
|
|
1690
|
+
*/
|
|
1691
|
+
removeUserUnloaded(e) {
|
|
1692
|
+
return this._userUnloaded.removeHandler(e);
|
|
1693
|
+
}
|
|
1694
|
+
/**
|
|
1695
|
+
* Add callback: Raised when the automatic silent renew has failed.
|
|
1696
|
+
*/
|
|
1697
|
+
addSilentRenewError(e) {
|
|
1698
|
+
return this._silentRenewError.addHandler(e);
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Remove callback: Raised when the automatic silent renew has failed.
|
|
1702
|
+
*/
|
|
1703
|
+
removeSilentRenewError(e) {
|
|
1704
|
+
return this._silentRenewError.removeHandler(e);
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* @internal
|
|
1708
|
+
*/
|
|
1709
|
+
async _raiseSilentRenewError(e) {
|
|
1710
|
+
await this._silentRenewError.raise(e);
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Add callback: Raised when the user is signed in (when `monitorSession` is set).
|
|
1714
|
+
* @see {@link UserManagerSettings.monitorSession}
|
|
1715
|
+
*/
|
|
1716
|
+
addUserSignedIn(e) {
|
|
1717
|
+
return this._userSignedIn.addHandler(e);
|
|
1718
|
+
}
|
|
1719
|
+
/**
|
|
1720
|
+
* Remove callback: Raised when the user is signed in (when `monitorSession` is set).
|
|
1721
|
+
*/
|
|
1722
|
+
removeUserSignedIn(e) {
|
|
1723
|
+
this._userSignedIn.removeHandler(e);
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* @internal
|
|
1727
|
+
*/
|
|
1728
|
+
async _raiseUserSignedIn() {
|
|
1729
|
+
await this._userSignedIn.raise();
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Add callback: Raised when the user's sign-in status at the OP has changed (when `monitorSession` is set).
|
|
1733
|
+
* @see {@link UserManagerSettings.monitorSession}
|
|
1734
|
+
*/
|
|
1735
|
+
addUserSignedOut(e) {
|
|
1736
|
+
return this._userSignedOut.addHandler(e);
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Remove callback: Raised when the user's sign-in status at the OP has changed (when `monitorSession` is set).
|
|
1740
|
+
*/
|
|
1741
|
+
removeUserSignedOut(e) {
|
|
1742
|
+
this._userSignedOut.removeHandler(e);
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* @internal
|
|
1746
|
+
*/
|
|
1747
|
+
async _raiseUserSignedOut() {
|
|
1748
|
+
await this._userSignedOut.raise();
|
|
1749
|
+
}
|
|
1750
|
+
/**
|
|
1751
|
+
* Add callback: Raised when the user session changed (when `monitorSession` is set).
|
|
1752
|
+
* @see {@link UserManagerSettings.monitorSession}
|
|
1753
|
+
*/
|
|
1754
|
+
addUserSessionChanged(e) {
|
|
1755
|
+
return this._userSessionChanged.addHandler(e);
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* Remove callback: Raised when the user session changed (when `monitorSession` is set).
|
|
1759
|
+
*/
|
|
1760
|
+
removeUserSessionChanged(e) {
|
|
1761
|
+
this._userSessionChanged.removeHandler(e);
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* @internal
|
|
1765
|
+
*/
|
|
1766
|
+
async _raiseUserSessionChanged() {
|
|
1767
|
+
await this._userSessionChanged.raise();
|
|
1768
|
+
}
|
|
1769
|
+
}, et = class {
|
|
1770
|
+
constructor(e) {
|
|
1771
|
+
this._userManager = e, this._logger = new g("SilentRenewService"), this._isStarted = !1, this._retryTimer = new T("Retry Silent Renew"), this._tokenExpiring = async () => {
|
|
1772
|
+
const t = this._logger.create("_tokenExpiring");
|
|
1773
|
+
try {
|
|
1774
|
+
await this._userManager.signinSilent(), t.debug("silent token renewal successful");
|
|
1775
|
+
} catch (s) {
|
|
1776
|
+
if (s instanceof G) {
|
|
1777
|
+
t.warn("ErrorTimeout from signinSilent:", s, "retry in 5s"), this._retryTimer.init(5);
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
t.error("Error from signinSilent:", s), await this._userManager.events._raiseSilentRenewError(s);
|
|
1781
|
+
}
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
async start() {
|
|
1785
|
+
const e = this._logger.create("start");
|
|
1786
|
+
if (!this._isStarted) {
|
|
1787
|
+
this._isStarted = !0, this._userManager.events.addAccessTokenExpiring(this._tokenExpiring), this._retryTimer.addHandler(this._tokenExpiring);
|
|
1788
|
+
try {
|
|
1789
|
+
await this._userManager.getUser();
|
|
1790
|
+
} catch (t) {
|
|
1791
|
+
e.error("getUser error", t);
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
stop() {
|
|
1796
|
+
this._isStarted && (this._retryTimer.cancel(), this._retryTimer.removeHandler(this._tokenExpiring), this._userManager.events.removeAccessTokenExpiring(this._tokenExpiring), this._isStarted = !1);
|
|
1797
|
+
}
|
|
1798
|
+
}, tt = class {
|
|
1799
|
+
constructor(e) {
|
|
1800
|
+
this.refresh_token = e.refresh_token, this.id_token = e.id_token, this.session_state = e.session_state, this.scope = e.scope, this.profile = e.profile, this.data = e.state;
|
|
1801
|
+
}
|
|
1802
|
+
}, it = class {
|
|
1803
|
+
constructor(e, t, s, i) {
|
|
1804
|
+
this._logger = new g("UserManager"), this.settings = new Be(e), this._client = new Ke(e), this._redirectNavigator = t ?? new Ye(this.settings), this._popupNavigator = s ?? new Xe(this.settings), this._iframeNavigator = i ?? new Ve(this.settings), this._events = new Ze(this.settings), this._silentRenewService = new et(this), this.settings.automaticSilentRenew && this.startSilentRenew(), this._sessionMonitor = null, this.settings.monitorSession && (this._sessionMonitor = new Fe(this));
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* Get object used to register for events raised by the `UserManager`.
|
|
1808
|
+
*/
|
|
1809
|
+
get events() {
|
|
1810
|
+
return this._events;
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Get object used to access the metadata configuration of the identity provider.
|
|
1814
|
+
*/
|
|
1815
|
+
get metadataService() {
|
|
1816
|
+
return this._client.metadataService;
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Load the `User` object for the currently authenticated user.
|
|
1820
|
+
*
|
|
1821
|
+
* @param raiseEvent - If `true`, the `UserLoaded` event will be raised. Defaults to false.
|
|
1822
|
+
* @returns A promise
|
|
1823
|
+
*/
|
|
1824
|
+
async getUser(e = !1) {
|
|
1825
|
+
const t = this._logger.create("getUser"), s = await this._loadUser();
|
|
1826
|
+
return s ? (t.info("user loaded"), await this._events.load(s, e), s) : (t.info("user not found in storage"), null);
|
|
1827
|
+
}
|
|
1828
|
+
/**
|
|
1829
|
+
* Remove from any storage the currently authenticated user.
|
|
1830
|
+
*
|
|
1831
|
+
* @returns A promise
|
|
1832
|
+
*/
|
|
1833
|
+
async removeUser() {
|
|
1834
|
+
const e = this._logger.create("removeUser");
|
|
1835
|
+
await this.storeUser(null), e.info("user removed from storage"), await this._events.unload();
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* Trigger a redirect of the current window to the authorization endpoint.
|
|
1839
|
+
*
|
|
1840
|
+
* @returns A promise
|
|
1841
|
+
*
|
|
1842
|
+
* @throws `Error` In cases of wrong authentication.
|
|
1843
|
+
*/
|
|
1844
|
+
async signinRedirect(e = {}) {
|
|
1845
|
+
var t;
|
|
1846
|
+
this._logger.create("signinRedirect");
|
|
1847
|
+
const {
|
|
1848
|
+
redirectMethod: s,
|
|
1849
|
+
...i
|
|
1850
|
+
} = e;
|
|
1851
|
+
let r;
|
|
1852
|
+
(t = this.settings.dpop) != null && t.bind_authorization_code && (r = await this.generateDPoPJkt(this.settings.dpop));
|
|
1853
|
+
const o = await this._redirectNavigator.prepare({ redirectMethod: s });
|
|
1854
|
+
await this._signinStart({
|
|
1855
|
+
request_type: "si:r",
|
|
1856
|
+
dpopJkt: r,
|
|
1857
|
+
...i
|
|
1858
|
+
}, o);
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Process the response (callback) from the authorization endpoint.
|
|
1862
|
+
* It is recommended to use {@link UserManager.signinCallback} instead.
|
|
1863
|
+
*
|
|
1864
|
+
* @returns A promise containing the authenticated `User`.
|
|
1865
|
+
*
|
|
1866
|
+
* @see {@link UserManager.signinCallback}
|
|
1867
|
+
*/
|
|
1868
|
+
async signinRedirectCallback(e = window.location.href) {
|
|
1869
|
+
const t = this._logger.create("signinRedirectCallback"), s = await this._signinEnd(e);
|
|
1870
|
+
return s.profile && s.profile.sub ? t.info("success, signed in subject", s.profile.sub) : t.info("no subject"), s;
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* Trigger the signin with user/password.
|
|
1874
|
+
*
|
|
1875
|
+
* @returns A promise containing the authenticated `User`.
|
|
1876
|
+
* @throws {@link ErrorResponse} In cases of wrong authentication.
|
|
1877
|
+
*/
|
|
1878
|
+
async signinResourceOwnerCredentials({
|
|
1879
|
+
username: e,
|
|
1880
|
+
password: t,
|
|
1881
|
+
skipUserInfo: s = !1
|
|
1882
|
+
}) {
|
|
1883
|
+
const i = this._logger.create("signinResourceOwnerCredential"), r = await this._client.processResourceOwnerPasswordCredentials({
|
|
1884
|
+
username: e,
|
|
1885
|
+
password: t,
|
|
1886
|
+
skipUserInfo: s,
|
|
1887
|
+
extraTokenParams: this.settings.extraTokenParams
|
|
1888
|
+
});
|
|
1889
|
+
i.debug("got signin response");
|
|
1890
|
+
const o = await this._buildUser(r);
|
|
1891
|
+
return o.profile && o.profile.sub ? i.info("success, signed in subject", o.profile.sub) : i.info("no subject"), o;
|
|
1892
|
+
}
|
|
1893
|
+
/**
|
|
1894
|
+
* Trigger a request (via a popup window) to the authorization endpoint.
|
|
1895
|
+
*
|
|
1896
|
+
* @returns A promise containing the authenticated `User`.
|
|
1897
|
+
* @throws `Error` In cases of wrong authentication.
|
|
1898
|
+
*/
|
|
1899
|
+
async signinPopup(e = {}) {
|
|
1900
|
+
var t;
|
|
1901
|
+
const s = this._logger.create("signinPopup");
|
|
1902
|
+
let i;
|
|
1903
|
+
(t = this.settings.dpop) != null && t.bind_authorization_code && (i = await this.generateDPoPJkt(this.settings.dpop));
|
|
1904
|
+
const {
|
|
1905
|
+
popupWindowFeatures: r,
|
|
1906
|
+
popupWindowTarget: o,
|
|
1907
|
+
popupSignal: n,
|
|
1908
|
+
...c
|
|
1909
|
+
} = e, a = this.settings.popup_redirect_uri;
|
|
1910
|
+
a || s.throw(new Error("No popup_redirect_uri configured"));
|
|
1911
|
+
const l = await this._popupNavigator.prepare({ popupWindowFeatures: r, popupWindowTarget: o, popupSignal: n }), d = await this._signin({
|
|
1912
|
+
request_type: "si:p",
|
|
1913
|
+
redirect_uri: a,
|
|
1914
|
+
display: "popup",
|
|
1915
|
+
dpopJkt: i,
|
|
1916
|
+
...c
|
|
1917
|
+
}, l);
|
|
1918
|
+
return d && (d.profile && d.profile.sub ? s.info("success, signed in subject", d.profile.sub) : s.info("no subject")), d;
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Notify the opening window of response (callback) from the authorization endpoint.
|
|
1922
|
+
* It is recommended to use {@link UserManager.signinCallback} instead.
|
|
1923
|
+
*
|
|
1924
|
+
* @returns A promise
|
|
1925
|
+
*
|
|
1926
|
+
* @see {@link UserManager.signinCallback}
|
|
1927
|
+
*/
|
|
1928
|
+
async signinPopupCallback(e = window.location.href, t = !1) {
|
|
1929
|
+
const s = this._logger.create("signinPopupCallback");
|
|
1930
|
+
await this._popupNavigator.callback(e, { keepOpen: t }), s.info("success");
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Trigger a silent request (via refresh token or an iframe) to the authorization endpoint.
|
|
1934
|
+
*
|
|
1935
|
+
* @returns A promise that contains the authenticated `User`.
|
|
1936
|
+
*/
|
|
1937
|
+
async signinSilent(e = {}) {
|
|
1938
|
+
var t, s;
|
|
1939
|
+
const i = this._logger.create("signinSilent"), {
|
|
1940
|
+
silentRequestTimeoutInSeconds: r,
|
|
1941
|
+
...o
|
|
1942
|
+
} = e;
|
|
1943
|
+
let n = await this._loadUser();
|
|
1944
|
+
if (n != null && n.refresh_token) {
|
|
1945
|
+
i.debug("using refresh token");
|
|
1946
|
+
const h = new tt(n);
|
|
1947
|
+
return await this._useRefreshToken({
|
|
1948
|
+
state: h,
|
|
1949
|
+
redirect_uri: o.redirect_uri,
|
|
1950
|
+
resource: o.resource,
|
|
1951
|
+
extraTokenParams: o.extraTokenParams,
|
|
1952
|
+
timeoutInSeconds: r
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
let c;
|
|
1956
|
+
(t = this.settings.dpop) != null && t.bind_authorization_code && (c = await this.generateDPoPJkt(this.settings.dpop));
|
|
1957
|
+
const a = this.settings.silent_redirect_uri;
|
|
1958
|
+
a || i.throw(new Error("No silent_redirect_uri configured"));
|
|
1959
|
+
let l;
|
|
1960
|
+
n && this.settings.validateSubOnSilentRenew && (i.debug("subject prior to silent renew:", n.profile.sub), l = n.profile.sub);
|
|
1961
|
+
const d = await this._iframeNavigator.prepare({ silentRequestTimeoutInSeconds: r });
|
|
1962
|
+
return n = await this._signin({
|
|
1963
|
+
request_type: "si:s",
|
|
1964
|
+
redirect_uri: a,
|
|
1965
|
+
prompt: "none",
|
|
1966
|
+
id_token_hint: this.settings.includeIdTokenInSilentRenew ? n == null ? void 0 : n.id_token : void 0,
|
|
1967
|
+
dpopJkt: c,
|
|
1968
|
+
...o
|
|
1969
|
+
}, d, l), n && ((s = n.profile) != null && s.sub ? i.info("success, signed in subject", n.profile.sub) : i.info("no subject")), n;
|
|
1970
|
+
}
|
|
1971
|
+
async _useRefreshToken(e) {
|
|
1972
|
+
const t = await this._client.useRefreshToken({
|
|
1973
|
+
timeoutInSeconds: this.settings.silentRequestTimeoutInSeconds,
|
|
1974
|
+
...e
|
|
1975
|
+
}), s = new J({ ...e.state, ...t });
|
|
1976
|
+
return await this.storeUser(s), await this._events.load(s), s;
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
*
|
|
1980
|
+
* Notify the parent window of response (callback) from the authorization endpoint.
|
|
1981
|
+
* It is recommended to use {@link UserManager.signinCallback} instead.
|
|
1982
|
+
*
|
|
1983
|
+
* @returns A promise
|
|
1984
|
+
*
|
|
1985
|
+
* @see {@link UserManager.signinCallback}
|
|
1986
|
+
*/
|
|
1987
|
+
async signinSilentCallback(e = window.location.href) {
|
|
1988
|
+
const t = this._logger.create("signinSilentCallback");
|
|
1989
|
+
await this._iframeNavigator.callback(e), t.info("success");
|
|
1990
|
+
}
|
|
1991
|
+
/**
|
|
1992
|
+
* Process any response (callback) from the authorization endpoint, by dispatching the request_type
|
|
1993
|
+
* and executing one of the following functions:
|
|
1994
|
+
* - {@link UserManager.signinRedirectCallback}
|
|
1995
|
+
* - {@link UserManager.signinPopupCallback}
|
|
1996
|
+
* - {@link UserManager.signinSilentCallback}
|
|
1997
|
+
*
|
|
1998
|
+
* @throws `Error` If request_type is unknown or signin cannot be processed.
|
|
1999
|
+
*/
|
|
2000
|
+
async signinCallback(e = window.location.href) {
|
|
2001
|
+
const { state: t } = await this._client.readSigninResponseState(e);
|
|
2002
|
+
switch (t.request_type) {
|
|
2003
|
+
case "si:r":
|
|
2004
|
+
return await this.signinRedirectCallback(e);
|
|
2005
|
+
case "si:p":
|
|
2006
|
+
await this.signinPopupCallback(e);
|
|
2007
|
+
break;
|
|
2008
|
+
case "si:s":
|
|
2009
|
+
await this.signinSilentCallback(e);
|
|
2010
|
+
break;
|
|
2011
|
+
default:
|
|
2012
|
+
throw new Error("invalid response_type in state");
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
/**
|
|
2016
|
+
* Process any response (callback) from the end session endpoint, by dispatching the request_type
|
|
2017
|
+
* and executing one of the following functions:
|
|
2018
|
+
* - {@link UserManager.signoutRedirectCallback}
|
|
2019
|
+
* - {@link UserManager.signoutPopupCallback}
|
|
2020
|
+
* - {@link UserManager.signoutSilentCallback}
|
|
2021
|
+
*
|
|
2022
|
+
* @throws `Error` If request_type is unknown or signout cannot be processed.
|
|
2023
|
+
*/
|
|
2024
|
+
async signoutCallback(e = window.location.href, t = !1) {
|
|
2025
|
+
const { state: s } = await this._client.readSignoutResponseState(e);
|
|
2026
|
+
if (s)
|
|
2027
|
+
switch (s.request_type) {
|
|
2028
|
+
case "so:r":
|
|
2029
|
+
return await this.signoutRedirectCallback(e);
|
|
2030
|
+
case "so:p":
|
|
2031
|
+
await this.signoutPopupCallback(e, t);
|
|
2032
|
+
break;
|
|
2033
|
+
case "so:s":
|
|
2034
|
+
await this.signoutSilentCallback(e);
|
|
2035
|
+
break;
|
|
2036
|
+
default:
|
|
2037
|
+
throw new Error("invalid response_type in state");
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* Query OP for user's current signin status.
|
|
2042
|
+
*
|
|
2043
|
+
* @returns A promise object with session_state and subject identifier.
|
|
2044
|
+
*/
|
|
2045
|
+
async querySessionStatus(e = {}) {
|
|
2046
|
+
const t = this._logger.create("querySessionStatus"), {
|
|
2047
|
+
silentRequestTimeoutInSeconds: s,
|
|
2048
|
+
...i
|
|
2049
|
+
} = e, r = this.settings.silent_redirect_uri;
|
|
2050
|
+
r || t.throw(new Error("No silent_redirect_uri configured"));
|
|
2051
|
+
const o = await this._loadUser(), n = await this._iframeNavigator.prepare({ silentRequestTimeoutInSeconds: s }), c = await this._signinStart({
|
|
2052
|
+
request_type: "si:s",
|
|
2053
|
+
// this acts like a signin silent
|
|
2054
|
+
redirect_uri: r,
|
|
2055
|
+
prompt: "none",
|
|
2056
|
+
id_token_hint: this.settings.includeIdTokenInSilentRenew ? o == null ? void 0 : o.id_token : void 0,
|
|
2057
|
+
response_type: this.settings.query_status_response_type,
|
|
2058
|
+
scope: "openid",
|
|
2059
|
+
skipUserInfo: !0,
|
|
2060
|
+
...i
|
|
2061
|
+
}, n);
|
|
2062
|
+
try {
|
|
2063
|
+
const a = {}, l = await this._client.processSigninResponse(c.url, a);
|
|
2064
|
+
return t.debug("got signin response"), l.session_state && l.profile.sub ? (t.info("success for subject", l.profile.sub), {
|
|
2065
|
+
session_state: l.session_state,
|
|
2066
|
+
sub: l.profile.sub
|
|
2067
|
+
}) : (t.info("success, user not authenticated"), null);
|
|
2068
|
+
} catch (a) {
|
|
2069
|
+
if (this.settings.monitorAnonymousSession && a instanceof q)
|
|
2070
|
+
switch (a.error) {
|
|
2071
|
+
case "login_required":
|
|
2072
|
+
case "consent_required":
|
|
2073
|
+
case "interaction_required":
|
|
2074
|
+
case "account_selection_required":
|
|
2075
|
+
return t.info("success for anonymous user"), {
|
|
2076
|
+
session_state: a.session_state
|
|
2077
|
+
};
|
|
2078
|
+
}
|
|
2079
|
+
throw a;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
async _signin(e, t, s) {
|
|
2083
|
+
const i = await this._signinStart(e, t);
|
|
2084
|
+
return await this._signinEnd(i.url, s);
|
|
2085
|
+
}
|
|
2086
|
+
async _signinStart(e, t) {
|
|
2087
|
+
const s = this._logger.create("_signinStart");
|
|
2088
|
+
try {
|
|
2089
|
+
const i = await this._client.createSigninRequest(e);
|
|
2090
|
+
return s.debug("got signin request"), await t.navigate({
|
|
2091
|
+
url: i.url,
|
|
2092
|
+
state: i.state.id,
|
|
2093
|
+
response_mode: i.state.response_mode,
|
|
2094
|
+
scriptOrigin: this.settings.iframeScriptOrigin
|
|
2095
|
+
});
|
|
2096
|
+
} catch (i) {
|
|
2097
|
+
throw s.debug("error after preparing navigator, closing navigator window"), t.close(), i;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
async _signinEnd(e, t) {
|
|
2101
|
+
const s = this._logger.create("_signinEnd"), i = {}, r = await this._client.processSigninResponse(e, i);
|
|
2102
|
+
return s.debug("got signin response"), await this._buildUser(r, t);
|
|
2103
|
+
}
|
|
2104
|
+
async _buildUser(e, t) {
|
|
2105
|
+
const s = this._logger.create("_buildUser"), i = new J(e);
|
|
2106
|
+
if (t) {
|
|
2107
|
+
if (t !== i.profile.sub)
|
|
2108
|
+
throw s.debug("current user does not match user returned from signin. sub from signin:", i.profile.sub), new q({ ...e, error: "login_required" });
|
|
2109
|
+
s.debug("current user matches user returned from signin");
|
|
2110
|
+
}
|
|
2111
|
+
return await this.storeUser(i), s.debug("user stored"), await this._events.load(i), i;
|
|
2112
|
+
}
|
|
2113
|
+
/**
|
|
2114
|
+
* Trigger a redirect of the current window to the end session endpoint.
|
|
2115
|
+
*
|
|
2116
|
+
* @returns A promise
|
|
2117
|
+
*/
|
|
2118
|
+
async signoutRedirect(e = {}) {
|
|
2119
|
+
const t = this._logger.create("signoutRedirect"), {
|
|
2120
|
+
redirectMethod: s,
|
|
2121
|
+
...i
|
|
2122
|
+
} = e, r = await this._redirectNavigator.prepare({ redirectMethod: s });
|
|
2123
|
+
await this._signoutStart({
|
|
2124
|
+
request_type: "so:r",
|
|
2125
|
+
post_logout_redirect_uri: this.settings.post_logout_redirect_uri,
|
|
2126
|
+
...i
|
|
2127
|
+
}, r), t.info("success");
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* Process response (callback) from the end session endpoint.
|
|
2131
|
+
* It is recommended to use {@link UserManager.signoutCallback} instead.
|
|
2132
|
+
*
|
|
2133
|
+
* @returns A promise containing signout response
|
|
2134
|
+
*
|
|
2135
|
+
* @see {@link UserManager.signoutCallback}
|
|
2136
|
+
*/
|
|
2137
|
+
async signoutRedirectCallback(e = window.location.href) {
|
|
2138
|
+
const t = this._logger.create("signoutRedirectCallback"), s = await this._signoutEnd(e);
|
|
2139
|
+
return t.info("success"), s;
|
|
2140
|
+
}
|
|
2141
|
+
/**
|
|
2142
|
+
* Trigger a redirect of a popup window to the end session endpoint.
|
|
2143
|
+
*
|
|
2144
|
+
* @returns A promise
|
|
2145
|
+
*/
|
|
2146
|
+
async signoutPopup(e = {}) {
|
|
2147
|
+
const t = this._logger.create("signoutPopup"), {
|
|
2148
|
+
popupWindowFeatures: s,
|
|
2149
|
+
popupWindowTarget: i,
|
|
2150
|
+
popupSignal: r,
|
|
2151
|
+
...o
|
|
2152
|
+
} = e, n = this.settings.popup_post_logout_redirect_uri, c = await this._popupNavigator.prepare({ popupWindowFeatures: s, popupWindowTarget: i, popupSignal: r });
|
|
2153
|
+
await this._signout({
|
|
2154
|
+
request_type: "so:p",
|
|
2155
|
+
post_logout_redirect_uri: n,
|
|
2156
|
+
// we're putting a dummy entry in here because we
|
|
2157
|
+
// need a unique id from the state for notification
|
|
2158
|
+
// to the parent window, which is necessary if we
|
|
2159
|
+
// plan to return back to the client after signout
|
|
2160
|
+
// and so we can close the popup after signout
|
|
2161
|
+
state: n == null ? void 0 : {},
|
|
2162
|
+
...o
|
|
2163
|
+
}, c), t.info("success");
|
|
2164
|
+
}
|
|
2165
|
+
/**
|
|
2166
|
+
* Process response (callback) from the end session endpoint from a popup window.
|
|
2167
|
+
* It is recommended to use {@link UserManager.signoutCallback} instead.
|
|
2168
|
+
*
|
|
2169
|
+
* @returns A promise
|
|
2170
|
+
*
|
|
2171
|
+
* @see {@link UserManager.signoutCallback}
|
|
2172
|
+
*/
|
|
2173
|
+
async signoutPopupCallback(e = window.location.href, t = !1) {
|
|
2174
|
+
const s = this._logger.create("signoutPopupCallback");
|
|
2175
|
+
await this._popupNavigator.callback(e, { keepOpen: t }), s.info("success");
|
|
2176
|
+
}
|
|
2177
|
+
async _signout(e, t) {
|
|
2178
|
+
const s = await this._signoutStart(e, t);
|
|
2179
|
+
return await this._signoutEnd(s.url);
|
|
2180
|
+
}
|
|
2181
|
+
async _signoutStart(e = {}, t) {
|
|
2182
|
+
var s;
|
|
2183
|
+
const i = this._logger.create("_signoutStart");
|
|
2184
|
+
try {
|
|
2185
|
+
const r = await this._loadUser();
|
|
2186
|
+
i.debug("loaded current user from storage"), this.settings.revokeTokensOnSignout && await this._revokeInternal(r);
|
|
2187
|
+
const o = e.id_token_hint || r && r.id_token;
|
|
2188
|
+
o && (i.debug("setting id_token_hint in signout request"), e.id_token_hint = o), await this.removeUser(), i.debug("user removed, creating signout request");
|
|
2189
|
+
const n = await this._client.createSignoutRequest(e);
|
|
2190
|
+
return i.debug("got signout request"), await t.navigate({
|
|
2191
|
+
url: n.url,
|
|
2192
|
+
state: (s = n.state) == null ? void 0 : s.id,
|
|
2193
|
+
scriptOrigin: this.settings.iframeScriptOrigin
|
|
2194
|
+
});
|
|
2195
|
+
} catch (r) {
|
|
2196
|
+
throw i.debug("error after preparing navigator, closing navigator window"), t.close(), r;
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
async _signoutEnd(e) {
|
|
2200
|
+
const t = this._logger.create("_signoutEnd"), s = await this._client.processSignoutResponse(e);
|
|
2201
|
+
return t.debug("got signout response"), s;
|
|
2202
|
+
}
|
|
2203
|
+
/**
|
|
2204
|
+
* Trigger a silent request (via an iframe) to the end session endpoint.
|
|
2205
|
+
*
|
|
2206
|
+
* @returns A promise
|
|
2207
|
+
*/
|
|
2208
|
+
async signoutSilent(e = {}) {
|
|
2209
|
+
var t;
|
|
2210
|
+
const s = this._logger.create("signoutSilent"), {
|
|
2211
|
+
silentRequestTimeoutInSeconds: i,
|
|
2212
|
+
...r
|
|
2213
|
+
} = e, o = this.settings.includeIdTokenInSilentSignout ? (t = await this._loadUser()) == null ? void 0 : t.id_token : void 0, n = this.settings.popup_post_logout_redirect_uri, c = await this._iframeNavigator.prepare({ silentRequestTimeoutInSeconds: i });
|
|
2214
|
+
await this._signout({
|
|
2215
|
+
request_type: "so:s",
|
|
2216
|
+
post_logout_redirect_uri: n,
|
|
2217
|
+
id_token_hint: o,
|
|
2218
|
+
...r
|
|
2219
|
+
}, c), s.info("success");
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* Notify the parent window of response (callback) from the end session endpoint.
|
|
2223
|
+
* It is recommended to use {@link UserManager.signoutCallback} instead.
|
|
2224
|
+
*
|
|
2225
|
+
* @returns A promise
|
|
2226
|
+
*
|
|
2227
|
+
* @see {@link UserManager.signoutCallback}
|
|
2228
|
+
*/
|
|
2229
|
+
async signoutSilentCallback(e = window.location.href) {
|
|
2230
|
+
const t = this._logger.create("signoutSilentCallback");
|
|
2231
|
+
await this._iframeNavigator.callback(e), t.info("success");
|
|
2232
|
+
}
|
|
2233
|
+
async revokeTokens(e) {
|
|
2234
|
+
const t = await this._loadUser();
|
|
2235
|
+
await this._revokeInternal(t, e);
|
|
2236
|
+
}
|
|
2237
|
+
async _revokeInternal(e, t = this.settings.revokeTokenTypes) {
|
|
2238
|
+
const s = this._logger.create("_revokeInternal");
|
|
2239
|
+
if (!e)
|
|
2240
|
+
return;
|
|
2241
|
+
const i = t.filter((r) => typeof e[r] == "string");
|
|
2242
|
+
if (!i.length) {
|
|
2243
|
+
s.debug("no need to revoke due to no token(s)");
|
|
2244
|
+
return;
|
|
2245
|
+
}
|
|
2246
|
+
for (const r of i)
|
|
2247
|
+
await this._client.revokeToken(
|
|
2248
|
+
e[r],
|
|
2249
|
+
r
|
|
2250
|
+
), s.info(`${r} revoked successfully`), r !== "access_token" && (e[r] = null);
|
|
2251
|
+
await this.storeUser(e), s.debug("user stored"), await this._events.load(e);
|
|
2252
|
+
}
|
|
2253
|
+
/**
|
|
2254
|
+
* Enables silent renew for the `UserManager`.
|
|
2255
|
+
*/
|
|
2256
|
+
startSilentRenew() {
|
|
2257
|
+
this._logger.create("startSilentRenew"), this._silentRenewService.start();
|
|
2258
|
+
}
|
|
2259
|
+
/**
|
|
2260
|
+
* Disables silent renew for the `UserManager`.
|
|
2261
|
+
*/
|
|
2262
|
+
stopSilentRenew() {
|
|
2263
|
+
this._silentRenewService.stop();
|
|
2264
|
+
}
|
|
2265
|
+
get _userStoreKey() {
|
|
2266
|
+
return `user:${this.settings.authority}:${this.settings.client_id}`;
|
|
2267
|
+
}
|
|
2268
|
+
async _loadUser() {
|
|
2269
|
+
const e = this._logger.create("_loadUser"), t = await this.settings.userStore.get(this._userStoreKey);
|
|
2270
|
+
return t ? (e.debug("user storageString loaded"), J.fromStorageString(t)) : (e.debug("no user storageString"), null);
|
|
2271
|
+
}
|
|
2272
|
+
async storeUser(e) {
|
|
2273
|
+
const t = this._logger.create("storeUser");
|
|
2274
|
+
if (e) {
|
|
2275
|
+
t.debug("storing user");
|
|
2276
|
+
const s = e.toStorageString();
|
|
2277
|
+
await this.settings.userStore.set(this._userStoreKey, s);
|
|
2278
|
+
} else
|
|
2279
|
+
this._logger.debug("removing user"), await this.settings.userStore.remove(this._userStoreKey), this.settings.dpop && await this.settings.dpop.store.remove(this.settings.client_id);
|
|
2280
|
+
}
|
|
2281
|
+
/**
|
|
2282
|
+
* Removes stale state entries in storage for incomplete authorize requests.
|
|
2283
|
+
*/
|
|
2284
|
+
async clearStaleState() {
|
|
2285
|
+
await this._client.clearStaleState();
|
|
2286
|
+
}
|
|
2287
|
+
/**
|
|
2288
|
+
* Dynamically generates a DPoP proof for a given user, URL and optional Http method.
|
|
2289
|
+
* This method is useful when you need to make a request to a resource server
|
|
2290
|
+
* with fetch or similar, and you need to include a DPoP proof in a DPoP header.
|
|
2291
|
+
* @param url - The URL to generate the DPoP proof for
|
|
2292
|
+
* @param user - The user to generate the DPoP proof for
|
|
2293
|
+
* @param httpMethod - Optional, defaults to "GET"
|
|
2294
|
+
* @param nonce - Optional nonce provided by the resource server
|
|
2295
|
+
*
|
|
2296
|
+
* @returns A promise containing the DPoP proof or undefined if DPoP is not enabled/no user is found.
|
|
2297
|
+
*/
|
|
2298
|
+
async dpopProof(e, t, s, i) {
|
|
2299
|
+
var r, o;
|
|
2300
|
+
const n = await ((o = (r = this.settings.dpop) == null ? void 0 : r.store) == null ? void 0 : o.get(this.settings.client_id));
|
|
2301
|
+
if (n)
|
|
2302
|
+
return await f.generateDPoPProof({
|
|
2303
|
+
url: e,
|
|
2304
|
+
accessToken: t == null ? void 0 : t.access_token,
|
|
2305
|
+
httpMethod: s,
|
|
2306
|
+
keyPair: n.keys,
|
|
2307
|
+
nonce: i
|
|
2308
|
+
});
|
|
2309
|
+
}
|
|
2310
|
+
async generateDPoPJkt(e) {
|
|
2311
|
+
let t = await e.store.get(this.settings.client_id);
|
|
2312
|
+
if (!t) {
|
|
2313
|
+
const s = await f.generateDPoPKeys();
|
|
2314
|
+
t = new de(s), await e.store.set(this.settings.client_id, t);
|
|
129
2315
|
}
|
|
130
|
-
|
|
131
|
-
}, h = R, I = (d, l) => {
|
|
132
|
-
let i;
|
|
133
|
-
try {
|
|
134
|
-
i = JSON.parse(d);
|
|
135
|
-
} catch {
|
|
2316
|
+
return await f.generateDPoPJkt(t.keys);
|
|
136
2317
|
}
|
|
137
|
-
i !== void 0 && l(i);
|
|
138
2318
|
};
|
|
139
2319
|
export {
|
|
140
|
-
|
|
2320
|
+
Pe as AccessTokenEvents,
|
|
2321
|
+
Ie as CheckSessionIFrame,
|
|
2322
|
+
de as DPoPState,
|
|
2323
|
+
q as ErrorResponse,
|
|
2324
|
+
G as ErrorTimeout,
|
|
2325
|
+
re as InMemoryWebStorage,
|
|
2326
|
+
H as Log,
|
|
2327
|
+
g as Logger,
|
|
2328
|
+
xe as MetadataService,
|
|
2329
|
+
Ke as OidcClient,
|
|
2330
|
+
z as OidcClientSettingsStore,
|
|
2331
|
+
Fe as SessionMonitor,
|
|
2332
|
+
$ as SigninResponse,
|
|
2333
|
+
ae as SigninState,
|
|
2334
|
+
De as SignoutResponse,
|
|
2335
|
+
W as State,
|
|
2336
|
+
J as User,
|
|
2337
|
+
it as UserManager,
|
|
2338
|
+
Be as UserManagerSettingsStore,
|
|
2339
|
+
ne as WebStorageStateStore
|
|
141
2340
|
};
|