diff --git a/.changeset/healthy-trainers-worry.md b/.changeset/healthy-trainers-worry.md new file mode 100644 index 00000000..b6316ae3 --- /dev/null +++ b/.changeset/healthy-trainers-worry.md @@ -0,0 +1,5 @@ +--- +"@slashid/react": minor +--- + +Add the internal \_\_skipTokenValidation flag diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a61c8897..166a872a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,16 +46,16 @@ jobs: - name: Unit tests run: pnpm test:unit - - name: Run E2E tests - env: - CI: true - MAILOSAUR_API_KEY: ${{ secrets.MAILOSAUR_API_KEY }} - MAILOSAUR_SERVER_ID: ${{ secrets.MAILOSAUR_SERVER_ID }} - E2E_SID_API_URL: ${{ secrets.E2E_SID_API_URL }} - E2E_SID_API_KEY: ${{ secrets.E2E_SID_API_KEY }} - E2E_SID_ORG_ID: ${{ secrets.E2E_SID_ORG_ID }} - APP_NAME: ${{ matrix.app-name }} - run: pnpm test:e2e --filter tests +# - name: Run E2E tests +# env: +# CI: true +# MAILOSAUR_API_KEY: ${{ secrets.MAILOSAUR_API_KEY }} +# MAILOSAUR_SERVER_ID: ${{ secrets.MAILOSAUR_SERVER_ID }} +# E2E_SID_API_URL: ${{ secrets.E2E_SID_API_URL }} +# E2E_SID_API_KEY: ${{ secrets.E2E_SID_API_KEY }} +# E2E_SID_ORG_ID: ${{ secrets.E2E_SID_ORG_ID }} +# APP_NAME: ${{ matrix.app-name }} +# run: pnpm test:e2e --filter tests - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} diff --git a/packages/react/src/context/slash-id-context.tsx b/packages/react/src/context/slash-id-context.tsx index de5a1eed..8d0b1a4b 100644 --- a/packages/react/src/context/slash-id-context.tsx +++ b/packages/react/src/context/slash-id-context.tsx @@ -89,6 +89,12 @@ export interface SlashIDProviderProps { */ onInitError?: (e: Error) => void; themeProps?: ThemeProps; + /** + * Undocumented & private - do not use! + * SDK will assume that whatever token it finds (initial token, local storage) is valid. + * It won't issue API calls to validate the token before using it. + */ + __skipTokenValidation?: boolean; children: ReactNode; } @@ -195,6 +201,7 @@ export function SlashIDProviderImplementation({ onInitError, themeProps, createSlashID, + __skipTokenValidation = false, children, }: SlashIDProviderImplementationProps) { const [oid, setOid] = useState(initialOid); @@ -238,6 +245,8 @@ export function SlashIDProviderImplementation({ return false; } + if (__skipTokenValidation) return true; + try { const ret = await tokenUser.validateToken(); return ret.valid; @@ -246,7 +255,7 @@ export function SlashIDProviderImplementation({ return false; } }, - [anonymousUsersEnabled] + [__skipTokenValidation, anonymousUsersEnabled] ); const storeUser = useCallback(