[{"data":1,"prerenderedAt":855},["ShallowReactive",2],{"navigation_docs":3,"-concepts-state-and-events":189,"-concepts-state-and-events-surround":850},[4,30,65,105,120,135,164,184],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":6},"Getting started",false,"/getting-started","1.getting-started",[10,15,20,25],{"title":11,"path":12,"stem":13,"icon":14},"Introduction","/getting-started/introduction","1.getting-started/1.introduction","i-lucide-book-open",{"title":16,"path":17,"stem":18,"icon":19},"Installation","/getting-started/installation","1.getting-started/2.installation","i-lucide-download",{"title":21,"path":22,"stem":23,"icon":24},"Quick start","/getting-started/quick-start","1.getting-started/3.quick-start","i-lucide-rocket",{"title":26,"path":27,"stem":28,"icon":29},"Session Lab","/getting-started/session-lab","1.getting-started/4.session-lab","i-lucide-flask-conical",{"title":31,"icon":6,"path":32,"stem":33,"children":34,"page":6},"Concepts","/concepts","2.concepts",[35,40,45,50,55,60],{"title":36,"path":37,"stem":38,"icon":39},"How it works","/concepts/how-it-works","2.concepts/1.how-it-works","i-lucide-workflow",{"title":41,"path":42,"stem":43,"icon":44},"Sessions and tokens","/concepts/sessions-and-tokens","2.concepts/2.sessions-and-tokens","i-lucide-key-round",{"title":46,"path":47,"stem":48,"icon":49},"State and events","/concepts/state-and-events","2.concepts/3.state-and-events","i-lucide-radio",{"title":51,"path":52,"stem":53,"icon":54},"Token refresh","/concepts/token-refresh","2.concepts/4.token-refresh","i-lucide-refresh-cw",{"title":56,"path":57,"stem":58,"icon":59},"Storage","/concepts/storage","2.concepts/5.storage","i-lucide-hard-drive",{"title":61,"path":62,"stem":63,"icon":64},"Guarantees","/concepts/guarantees","2.concepts/6.guarantees","i-lucide-shield-check",{"title":66,"icon":6,"path":67,"stem":68,"children":69,"page":6},"Providers","/providers","3.providers",[70,75,80,85,90,95,100],{"title":71,"path":72,"stem":73,"icon":74},"Choosing a provider","/providers/choosing","3.providers/1.choosing","i-lucide-signpost",{"title":76,"path":77,"stem":78,"icon":79},"Credentials","/providers/credentials","3.providers/2.credentials","i-lucide-user-round-key",{"title":81,"path":82,"stem":83,"icon":84},"OAuth 2.0 and OpenID Connect","/providers/oauth2","3.providers/3.oauth2","i-lucide-shield",{"title":86,"path":87,"stem":88,"icon":89},"OAuth through your backend","/providers/backend-oauth","3.providers/4.backend-oauth","i-lucide-server",{"title":91,"path":92,"stem":93,"icon":94},"Google","/providers/google","3.providers/5.google","i-simple-icons-google",{"title":96,"path":97,"stem":98,"icon":99},"Apple","/providers/apple","3.providers/6.apple","i-simple-icons-apple",{"title":101,"path":102,"stem":103,"icon":104},"Custom providers","/providers/custom","3.providers/7.custom","i-lucide-puzzle",{"title":106,"icon":6,"path":107,"stem":108,"children":109,"page":6},"Flutter","/flutter","4.flutter",[110,115],{"title":111,"path":112,"stem":113,"icon":114},"Widgets","/flutter/widgets","4.flutter/1.widgets","i-lucide-layout-template",{"title":116,"path":117,"stem":118,"icon":119},"Routing","/flutter/routing","4.flutter/2.routing","i-lucide-route",{"title":121,"icon":6,"path":122,"stem":123,"children":124,"page":6},"HTTP","/http","5.http",[125,130],{"title":126,"path":127,"stem":128,"icon":129},"Dio","/http/dio","5.http/1.dio","i-lucide-arrow-left-right",{"title":131,"path":132,"stem":133,"icon":134},"Other HTTP clients","/http/other-clients","5.http/2.other-clients","i-lucide-plug-zap",{"title":136,"icon":6,"path":137,"stem":138,"children":139,"page":6},"Guides","/guides","6.guides",[140,145,150,155,159],{"title":141,"path":142,"stem":143,"icon":144},"Multiple accounts","/guides/multi-account","6.guides/1.multi-account","i-lucide-users",{"title":146,"path":147,"stem":148,"icon":149},"Sign-out and revocation","/guides/sign-out","6.guides/2.sign-out","i-lucide-log-out",{"title":151,"path":152,"stem":153,"icon":154},"Access policy","/guides/access-policy","6.guides/3.access-policy","i-lucide-shield-alert",{"title":156,"path":157,"stem":158,"icon":29},"Testing","/guides/testing","6.guides/4.testing",{"title":160,"path":161,"stem":162,"icon":163},"Backend requirements","/guides/backend-requirements","6.guides/5.backend-requirements","i-lucide-server-cog",{"title":165,"icon":6,"path":166,"stem":167,"children":168,"page":6},"Reference","/reference","7.reference",[169,174,179],{"title":170,"path":171,"stem":172,"icon":173},"API reference","/reference/api","7.reference/1.api","i-lucide-library",{"title":175,"path":176,"stem":177,"icon":178},"FAQ","/reference/faq","7.reference/2.faq","i-lucide-message-circle-question",{"title":180,"path":181,"stem":182,"icon":183},"Troubleshooting","/reference/troubleshooting","7.reference/3.troubleshooting","i-lucide-wrench",{"title":185,"path":186,"stem":187,"icon":188},"Changelog","/changelog","changelog","i-lucide-history",{"id":190,"title":46,"body":191,"description":843,"extension":844,"links":845,"meta":846,"navigation":847,"path":47,"seo":848,"stem":48,"__hash__":849},"docs/2.concepts/3.state-and-events.md",{"type":192,"value":193,"toc":838},"minimark",[194,199,203,266,390,396,407,410,414,420,514,592,598,602,613,734,834],[195,196,198],"h2",{"id":197},"authstate","AuthState",[200,201,202],"p",{},"Three states, as a sealed class your code can switch over exhaustively:",[204,205,206,222],"table",{},[207,208,209],"thead",{},[210,211,212,216,219],"tr",{},[213,214,215],"th",{},"State",[213,217,218],{},"Meaning",[213,220,221],{},"Show",[223,224,225,240,253],"tbody",{},[210,226,227,234,237],{},[228,229,230],"td",{},[231,232,233],"code",{},"AuthUnknown",[228,235,236],{},"Saved sessions are being restored.",[228,238,239],{},"A splash screen. Showing the sign-in screen here makes it flash for signed-in users.",[210,241,242,247,250],{},[228,243,244],{},[231,245,246],{},"AuthSignedIn(key, user)",[228,248,249],{},"A session is active.",[228,251,252],{},"The app.",[210,254,255,260,263],{},[228,256,257],{},[231,258,259],{},"AuthSignedOut",[228,261,262],{},"No session is active.",[228,264,265],{},"The sign-in screen.",[267,268,273],"pre",{"className":269,"code":270,"language":271,"meta":272,"style":272},"language-dart shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","final screen = switch (authyra.state) {\n  AuthUnknown() => const SplashScreen(),\n  AuthSignedIn(:final user) => HomeScreen(user: user),\n  AuthSignedOut() => const SignInScreen(),\n};\n","dart","",[231,274,275,305,330,362,381],{"__ignoreMap":272},[276,277,280,284,288,292,296,299,302],"span",{"class":278,"line":279},"line",1,[276,281,283],{"class":282},"spNyl","final",[276,285,287],{"class":286},"sTEyZ"," screen ",[276,289,291],{"class":290},"sMK4o","=",[276,293,295],{"class":294},"s7zQu"," switch",[276,297,298],{"class":286}," (authyra",[276,300,301],{"class":290},".",[276,303,304],{"class":286},"state) {\n",[276,306,308,312,315,318,321,324,327],{"class":278,"line":307},2,[276,309,311],{"class":310},"sBMFI","  AuthUnknown",[276,313,314],{"class":286},"() ",[276,316,317],{"class":290},"=>",[276,319,320],{"class":282}," const",[276,322,323],{"class":310}," SplashScreen",[276,325,326],{"class":286},"()",[276,328,329],{"class":290},",\n",[276,331,333,336,339,342,344,347,349,352,355,357,360],{"class":278,"line":332},3,[276,334,335],{"class":310},"  AuthSignedIn",[276,337,338],{"class":286},"(",[276,340,341],{"class":290},":",[276,343,283],{"class":282},[276,345,346],{"class":286}," user) ",[276,348,317],{"class":290},[276,350,351],{"class":310}," HomeScreen",[276,353,354],{"class":286},"(user",[276,356,341],{"class":290},[276,358,359],{"class":286}," user)",[276,361,329],{"class":290},[276,363,365,368,370,372,374,377,379],{"class":278,"line":364},4,[276,366,367],{"class":310},"  AuthSignedOut",[276,369,314],{"class":286},[276,371,317],{"class":290},[276,373,320],{"class":282},[276,375,376],{"class":310}," SignInScreen",[276,378,326],{"class":286},[276,380,329],{"class":290},[276,382,384,387],{"class":278,"line":383},5,[276,385,386],{"class":286},"}",[276,388,389],{"class":290},";\n",[200,391,392,395],{},[231,393,394],{},"authyra.states"," is a stream that gives each new listener the current state first, then every change. Equal consecutive states are not repeated.",[397,398,399,402,403,406],"note",{},[231,400,401],{},"AuthSignedIn"," carries the session's identity, never its tokens. A token refresh is not a state change, so your widgets do not rebuild every 15 minutes. Ask ",[231,404,405],{},"accessToken()"," when you need a token.",[200,408,409],{},"Errors are not states either: a failed sign-in throws to its caller and leaves the state as it was.",[195,411,413],{"id":412},"events","Events",[200,415,416,419],{},[231,417,418],{},"authyra.events"," describes what happens to every session, active or not. Use it for analytics, audit logs, banners and debugging.",[204,421,422,432],{},[207,423,424],{},[210,425,426,429],{},[213,427,428],{},"Event",[213,430,431],{},"When",[223,433,434,452,462,472,482,504],{},[210,435,436,441],{},[228,437,438],{},[231,439,440],{},"SessionStartedEvent(session, isNew)",[228,442,443,444,447,448,451],{},"A sign-in succeeded. ",[231,445,446],{},"isNew"," is ",[231,449,450],{},"false"," when an existing session of the same identity was updated.",[210,453,454,459],{},[228,455,456],{},[231,457,458],{},"SessionSwitchedEvent(previous, current)",[228,460,461],{},"The active session changed.",[210,463,464,469],{},[228,465,466],{},[231,467,468],{},"SessionRefreshedEvent(session)",[228,470,471],{},"Tokens were renewed.",[210,473,474,479],{},[228,475,476],{},[231,477,478],{},"SessionRefreshFailedEvent(session, error)",[228,480,481],{},"A refresh failed for a transient reason; it will be retried.",[210,483,484,489],{},[228,485,486],{},[231,487,488],{},"SessionEndedEvent(session, reason)",[228,490,491,492,495,496,499,500,503],{},"A session was removed: ",[231,493,494],{},"signedOut",", ",[231,497,498],{},"revoked"," by the server, or ",[231,501,502],{},"expired"," (could no longer be renewed).",[210,505,506,511],{},[228,507,508],{},[231,509,510],{},"SignInFailedEvent(providerId, error)",[228,512,513],{},"A sign-in failed or was cancelled.",[267,515,517],{"className":269,"code":516,"language":271,"meta":272,"style":272},"authyra.events.listen((event) {\n  if (event case SessionEndedEvent(reason: SessionEndReason.revoked)) {\n    showBanner('Your session ended. Please sign in again.');\n  }\n});\n",[231,518,519,537,564,580,585],{"__ignoreMap":272},[276,520,521,524,526,528,530,534],{"class":278,"line":279},[276,522,523],{"class":286},"authyra",[276,525,301],{"class":290},[276,527,412],{"class":286},[276,529,301],{"class":290},[276,531,533],{"class":532},"s2Zo4","listen",[276,535,536],{"class":286},"((event) {\n",[276,538,539,542,545,548,551,554,556,559,561],{"class":278,"line":307},[276,540,541],{"class":294},"  if",[276,543,544],{"class":286}," (event ",[276,546,547],{"class":294},"case",[276,549,550],{"class":310}," SessionEndedEvent",[276,552,553],{"class":286},"(reason",[276,555,341],{"class":290},[276,557,558],{"class":310}," SessionEndReason",[276,560,301],{"class":290},[276,562,563],{"class":286},"revoked)) {\n",[276,565,566,569,571,575,578],{"class":278,"line":332},[276,567,568],{"class":532},"    showBanner",[276,570,338],{"class":286},[276,572,574],{"class":573},"sfazB","'Your session ended. Please sign in again.'",[276,576,577],{"class":286},")",[276,579,389],{"class":290},[276,581,582],{"class":278,"line":364},[276,583,584],{"class":286},"  }\n",[276,586,587,590],{"class":278,"line":383},[276,588,589],{"class":286},"})",[276,591,389],{"class":290},[200,593,594,595,301],{},"No event prints token values in its ",[231,596,597],{},"toString()",[195,599,601],{"id":600},"errors","Errors",[200,603,604,605,608,609,612],{},"Every error Authyra throws is an ",[231,606,607],{},"AuthException",", a sealed hierarchy. Its ",[231,610,611],{},"message"," never contains tokens.",[204,614,615,625],{},[207,616,617],{},[210,618,619,622],{},[213,620,621],{},"Exception",[213,623,624],{},"Thrown when",[223,626,627,637,647,665,678,696,706,719],{},[210,628,629,634],{},[228,630,631],{},[231,632,633],{},"SignInCancelledException",[228,635,636],{},"The user closed the browser or dismissed the native sheet. Usually not worth a message.",[210,638,639,644],{},[228,640,641],{},[231,642,643],{},"SignInFailedException",[228,645,646],{},"The provider could not authenticate the user: wrong password, server error, misconfiguration.",[210,648,649,654],{},[228,650,651],{},[231,652,653],{},"AuthDeniedException",[228,655,656,657,660,661,664],{},"Your ",[231,658,659],{},"AuthPolicy"," refused the operation. ",[231,662,663],{},"reason"," is meant for display.",[210,666,667,672],{},[228,668,669],{},[231,670,671],{},"SessionNotFoundException",[228,673,674,677],{},[231,675,676],{},"switchTo"," targeted a session that no longer exists or can no longer be renewed (it is then ended).",[210,679,680,685],{},[228,681,682],{},[231,683,684],{},"TokenRefreshException",[228,686,687,688,691,692,695],{},"A refresh failed for a transient reason where a fresh token was required: the current token expired, the server rejected it (",[231,689,690],{},"accessToken(rejectedToken:)","), or you called ",[231,693,694],{},"refresh()",". The session is kept.",[210,697,698,703],{},[228,699,700],{},[231,701,702],{},"AuthStorageException",[228,704,705],{},"The storage could not read or write.",[210,707,708,713],{},[228,709,710],{},[231,711,712],{},"AuthConfigException",[228,714,715,716,301],{},"Misuse: unknown provider id, duplicate ids, use before ",[231,717,718],{},"start()",[210,720,721,726],{},[228,722,723],{},[231,724,725],{},"RefreshRevokedException",[228,727,728,729,733],{},"Thrown by ",[730,731,732],"strong",{},"providers",", not by Authyra, to say the refresh token was rejected.",[267,735,737],{"className":269,"code":736,"language":271,"meta":272,"style":272},"try {\n  await authyra.signIn('api', params: credentials);\n} on SignInCancelledException {\n  // Nothing to say.\n} on AuthException catch (error) {\n  showError(error.message);\n}\n",[231,738,739,747,778,791,797,812,828],{"__ignoreMap":272},[276,740,741,744],{"class":278,"line":279},[276,742,743],{"class":294},"try",[276,745,746],{"class":286}," {\n",[276,748,749,752,755,757,760,762,765,768,771,773,776],{"class":278,"line":307},[276,750,751],{"class":294},"  await",[276,753,754],{"class":286}," authyra",[276,756,301],{"class":290},[276,758,759],{"class":532},"signIn",[276,761,338],{"class":286},[276,763,764],{"class":573},"'api'",[276,766,767],{"class":290},",",[276,769,770],{"class":286}," params",[276,772,341],{"class":290},[276,774,775],{"class":286}," credentials)",[276,777,389],{"class":290},[276,779,780,783,786,789],{"class":278,"line":332},[276,781,782],{"class":286},"} ",[276,784,785],{"class":294},"on",[276,787,788],{"class":310}," SignInCancelledException",[276,790,746],{"class":286},[276,792,793],{"class":278,"line":364},[276,794,796],{"class":795},"sHwdD","  // Nothing to say.\n",[276,798,799,801,803,806,809],{"class":278,"line":383},[276,800,782],{"class":286},[276,802,785],{"class":294},[276,804,805],{"class":310}," AuthException",[276,807,808],{"class":294}," catch",[276,810,811],{"class":286}," (error) {\n",[276,813,815,818,821,823,826],{"class":278,"line":814},6,[276,816,817],{"class":532},"  showError",[276,819,820],{"class":286},"(error",[276,822,301],{"class":290},[276,824,825],{"class":286},"message)",[276,827,389],{"class":290},[276,829,831],{"class":278,"line":830},7,[276,832,833],{"class":286},"}\n",[835,836,837],"style",{},"html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}",{"title":272,"searchDepth":307,"depth":307,"links":839},[840,841,842],{"id":197,"depth":307,"text":198},{"id":412,"depth":307,"text":413},{"id":600,"depth":307,"text":601},"The sealed AuthState your UI renders, the events that describe what happened to each session, and the errors Authyra throws.","md",null,{},{"icon":49},{"title":46,"description":843},"VzRYH0hqKwThP1ayM1w2Om8N9iNroK-EDEQfT95ViQA",[851,853],{"title":41,"path":42,"stem":43,"description":852,"icon":44,"children":-1},"AuthSession, SessionKey, AuthUser and AuthTokens, and the rule that keeps identity credentials out of session tokens.",{"title":51,"path":52,"stem":53,"description":854,"icon":54,"children":-1},"When Authyra refreshes, why there is never more than one refresh per session, and how failures are handled.",1794303128106]