Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library Breakage Due to 'api' Namespace Replacement with 'admin' in supabase-js #12

Open
arravo-github opened this issue Jan 15, 2025 · 0 comments

Comments

@arravo-github
Copy link

The New supabase-js release note has noted that the 'api' namespace has been replaced by 'admin'. This change has broken the library, unfortunately. The affect code is below:

authenticate(req) {
        const idToken = this.extractor(req);
        if (!idToken) {
            this.fail(constants_1.UNAUTHORIZED, 401);
            return;
        }
        **this.supabase.auth.api
            .getUser(idToken)**
            .then((res) => this.validateSupabaseResponse(res))
            .catch((err) => {
            this.fail(err.message, 401);
        });
    }

Suggested change:

authenticate(req) {
        const idToken = this.extractor(req);
        if (!idToken) {
            this.fail(constants_1.UNAUTHORIZED, 401);
            return;
        }
        **this.supabase.auth
            .getUser(idToken)**
            .then((res) => this.validateSupabaseResponse(res))
            .catch((err) => {
            this.fail(err.message, 401);
        });
    }

NB: The 'admin' namespace does not have 'getUser(jwt:string)', instead, the method is now in 'auth'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant