⬆️v4 -> v5

Very little change in the API.

  • The public/silent-sso.html -> to public/silent-sso.htm ()

  • Use getOidc() instead or prOidc (React API)

src/oidc.ts
 import { createReactOidc } from "oidc-spa/react";
 
 export const {
     OidcProvider,
     useOidc,
-    prOidc,
+    getOidc
 } = createReactOidc({ });

-prOidc.then(oidc => { /* ... */ });
+getOidc().then(oidc => { /* ... */ });

If you are using the mock with the vanilla API (not React)

 import { createOidc } from "oidc-spa";
 import { createMockOidc } from "oidc-spa/mock";
 import { z } from "zod";

 const decodedIdTokenSchema = z.object({
     sub: z.string(),
     preferred_username: z.string()
 });

 const publicUrl= import.meta.env.BASE_URL;

 const oidc = !import.meta.env.VITE_OIDC_ISSUER
-    ? await createMockOidc({
+    ? await createMockOidc({
           isUserInitiallyLoggedIn: false,
           publicUrl,
           mockedTokens: {
               decodedIdToken: {
                   sub: "123",
                   preferred_username: "john doe"
               } satisfies z.infer<typeof decodedIdTokenSchema>
           }
       })
     : await createOidc({
           issuerUri: import.meta.env.VITE_OIDC_ISSUER,
           clientId: import.meta.env.VITE_OIDC_CLIENT_ID,
           publicUrl
       });

Last updated