New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@supabase/gotrue-js

Package Overview
Dependencies
Maintainers
3
Versions
316
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@supabase/gotrue-js - npm Package Compare versions

Comparing version 1.10.6 to 1.11.0

30

dist/main/GoTrueApi.d.ts

@@ -19,2 +19,3 @@ import { Session, Provider, UserAttributes, CookieOptions, User } from './lib/types';

* @param password The password of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*

@@ -24,3 +25,5 @@ * @returns A logged-in session if the server has "autoconfirm" ON

*/
signUpWithEmail(email: string, password: string): Promise<{
signUpWithEmail(email: string, password: string, options?: {
redirectTo?: string;
}): Promise<{
data: Session | User | null;

@@ -33,4 +36,7 @@ error: Error | null;

* @param password The password of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signInWithEmail(email: string, password: string): Promise<{
signInWithEmail(email: string, password: string, options?: {
redirectTo?: string;
}): Promise<{
data: Session | null;

@@ -42,4 +48,7 @@ error: Error | null;

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
sendMagicLinkEmail(email: string): Promise<{
sendMagicLinkEmail(email: string, options?: {
redirectTo?: string;
}): Promise<{
data: {} | null;

@@ -51,4 +60,7 @@ error: Error | null;

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
inviteUserByEmail(email: string): Promise<{
inviteUserByEmail(email: string, options?: {
redirectTo?: string;
}): Promise<{
data: {} | null;

@@ -60,4 +72,7 @@ error: Error | null;

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
resetPasswordForEmail(email: string): Promise<{
resetPasswordForEmail(email: string, options?: {
redirectTo?: string;
}): Promise<{
data: {} | null;

@@ -82,4 +97,7 @@ error: Error | null;

* @param provider One of the providers supported by GoTrue.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
getUrlForProvider(provider: Provider): string;
getUrlForProvider(provider: Provider, options: {
redirectTo?: string;
}): string;
/**

@@ -86,0 +104,0 @@ * Gets the user details.

30

dist/main/GoTrueApi.js

@@ -25,2 +25,3 @@ "use strict";

* @param password The password of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*

@@ -30,6 +31,10 @@ * @returns A logged-in session if the server has "autoconfirm" ON

*/
signUpWithEmail(email, password) {
signUpWithEmail(email, password, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
try {
const data = yield fetch_1.post(`${this.url}/signup`, { email, password }, { headers: this.headers });
let headers = Object.assign({}, this.headers);
if (options.redirectTo) {
headers['referer'] = options.redirectTo;
}
const data = yield fetch_1.post(`${this.url}/signup`, { email, password }, { headers });
return { data, error: null };

@@ -46,4 +51,5 @@ }

* @param password The password of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signInWithEmail(email, password) {
signInWithEmail(email, password, options = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -62,4 +68,5 @@ try {

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
sendMagicLinkEmail(email) {
sendMagicLinkEmail(email, options = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -78,4 +85,5 @@ try {

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
inviteUserByEmail(email) {
inviteUserByEmail(email, options = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -94,4 +102,5 @@ try {

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
resetPasswordForEmail(email) {
resetPasswordForEmail(email, options = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -135,5 +144,10 @@ try {

* @param provider One of the providers supported by GoTrue.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
getUrlForProvider(provider) {
return `${this.url}/authorize?provider=${provider}`;
getUrlForProvider(provider, options) {
let urlParams = [`provider=${provider}`];
if (options === null || options === void 0 ? void 0 : options.redirectTo) {
urlParams.push(`redirect_to=${options.redirectTo}`);
}
return `${this.url}/authorize?${urlParams.join('&')}`;
}

@@ -140,0 +154,0 @@ /**

@@ -46,4 +46,7 @@ import GoTrueApi from './GoTrueApi';

* @param password The user's password.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signUp({ email, password, }: UserCredentials): Promise<{
signUp({ email, password }: UserCredentials, options?: {
redirectTo?: string;
}): Promise<{
user: User | null;

@@ -60,4 +63,7 @@ session: Session | null;

* @param provider One of the providers supported by GoTrue.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signIn({ email, password, provider, }: UserCredentials): Promise<{
signIn({ email, password, provider }: UserCredentials, options?: {
redirectTo?: string;
}): Promise<{
session: Session | null;

@@ -64,0 +70,0 @@ user: User | null;

@@ -67,8 +67,11 @@ "use strict";

* @param password The user's password.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signUp({ email, password, }) {
signUp({ email, password }, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
try {
this._removeSession();
const { data, error } = yield this.api.signUpWithEmail(email, password);
const { data, error } = yield this.api.signUpWithEmail(email, password, {
redirectTo: options.redirectTo,
});
if (error) {

@@ -104,4 +107,5 @@ throw error;

* @param provider One of the providers supported by GoTrue.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signIn({ email, password, provider, }) {
signIn({ email, password, provider }, options = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -111,9 +115,17 @@ try {

if (email && !password) {
const { error } = yield this.api.sendMagicLinkEmail(email);
const { error } = yield this.api.sendMagicLinkEmail(email, {
redirectTo: options.redirectTo,
});
return { data: null, user: null, session: null, error };
}
if (email && password)
return this._handleEmailSignIn(email, password);
if (provider)
return this._handleProviderSignIn(provider);
if (email && password) {
return this._handleEmailSignIn(email, password, {
redirectTo: options.redirectTo,
});
}
if (provider) {
return this._handleProviderSignIn(provider, {
redirectTo: options.redirectTo,
});
}
throw new Error(`You must provide either an email or a third-party provider.`);

@@ -272,7 +284,9 @@ }

}
_handleEmailSignIn(email, password) {
_handleEmailSignIn(email, password, options = {}) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
try {
const { data, error } = yield this.api.signInWithEmail(email, password);
const { data, error } = yield this.api.signInWithEmail(email, password, {
redirectTo: options.redirectTo,
});
if (error || !data)

@@ -291,4 +305,4 @@ return { data: null, user: null, session: null, error };

}
_handleProviderSignIn(provider) {
const url = this.api.getUrlForProvider(provider);
_handleProviderSignIn(provider, options = {}) {
const url = this.api.getUrlForProvider(provider, { redirectTo: options.redirectTo });
try {

@@ -295,0 +309,0 @@ // try to open on the browser

@@ -71,3 +71,5 @@ export declare type Provider = 'azure' | 'bitbucket' | 'facebook' | 'github' | 'gitlab' | 'google';

provider?: Provider;
/** A URL to redirect the user to after confirmation. */
redirectTo?: URL;
}
//# sourceMappingURL=types.d.ts.map

@@ -19,2 +19,3 @@ import { Session, Provider, UserAttributes, CookieOptions, User } from './lib/types';

* @param password The password of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*

@@ -24,3 +25,5 @@ * @returns A logged-in session if the server has "autoconfirm" ON

*/
signUpWithEmail(email: string, password: string): Promise<{
signUpWithEmail(email: string, password: string, options?: {
redirectTo?: string;
}): Promise<{
data: Session | User | null;

@@ -33,4 +36,7 @@ error: Error | null;

* @param password The password of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signInWithEmail(email: string, password: string): Promise<{
signInWithEmail(email: string, password: string, options?: {
redirectTo?: string;
}): Promise<{
data: Session | null;

@@ -42,4 +48,7 @@ error: Error | null;

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
sendMagicLinkEmail(email: string): Promise<{
sendMagicLinkEmail(email: string, options?: {
redirectTo?: string;
}): Promise<{
data: {} | null;

@@ -51,4 +60,7 @@ error: Error | null;

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
inviteUserByEmail(email: string): Promise<{
inviteUserByEmail(email: string, options?: {
redirectTo?: string;
}): Promise<{
data: {} | null;

@@ -60,4 +72,7 @@ error: Error | null;

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
resetPasswordForEmail(email: string): Promise<{
resetPasswordForEmail(email: string, options?: {
redirectTo?: string;
}): Promise<{
data: {} | null;

@@ -82,4 +97,7 @@ error: Error | null;

* @param provider One of the providers supported by GoTrue.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
getUrlForProvider(provider: Provider): string;
getUrlForProvider(provider: Provider, options: {
redirectTo?: string;
}): string;
/**

@@ -86,0 +104,0 @@ * Gets the user details.

@@ -23,2 +23,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

* @param password The password of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*

@@ -28,6 +29,10 @@ * @returns A logged-in session if the server has "autoconfirm" ON

*/
signUpWithEmail(email, password) {
signUpWithEmail(email, password, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
try {
const data = yield post(`${this.url}/signup`, { email, password }, { headers: this.headers });
let headers = Object.assign({}, this.headers);
if (options.redirectTo) {
headers['referer'] = options.redirectTo;
}
const data = yield post(`${this.url}/signup`, { email, password }, { headers });
return { data, error: null };

@@ -44,4 +49,5 @@ }

* @param password The password of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signInWithEmail(email, password) {
signInWithEmail(email, password, options = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -60,4 +66,5 @@ try {

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
sendMagicLinkEmail(email) {
sendMagicLinkEmail(email, options = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -76,4 +83,5 @@ try {

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
inviteUserByEmail(email) {
inviteUserByEmail(email, options = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -92,4 +100,5 @@ try {

* @param email The email address of the user.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
resetPasswordForEmail(email) {
resetPasswordForEmail(email, options = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -133,5 +142,10 @@ try {

* @param provider One of the providers supported by GoTrue.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
getUrlForProvider(provider) {
return `${this.url}/authorize?provider=${provider}`;
getUrlForProvider(provider, options) {
let urlParams = [`provider=${provider}`];
if (options === null || options === void 0 ? void 0 : options.redirectTo) {
urlParams.push(`redirect_to=${options.redirectTo}`);
}
return `${this.url}/authorize?${urlParams.join('&')}`;
}

@@ -138,0 +152,0 @@ /**

@@ -46,4 +46,7 @@ import GoTrueApi from './GoTrueApi';

* @param password The user's password.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signUp({ email, password, }: UserCredentials): Promise<{
signUp({ email, password }: UserCredentials, options?: {
redirectTo?: string;
}): Promise<{
user: User | null;

@@ -60,4 +63,7 @@ session: Session | null;

* @param provider One of the providers supported by GoTrue.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signIn({ email, password, provider, }: UserCredentials): Promise<{
signIn({ email, password, provider }: UserCredentials, options?: {
redirectTo?: string;
}): Promise<{
session: Session | null;

@@ -64,0 +70,0 @@ user: User | null;

@@ -62,8 +62,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

* @param password The user's password.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signUp({ email, password, }) {
signUp({ email, password }, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
try {
this._removeSession();
const { data, error } = yield this.api.signUpWithEmail(email, password);
const { data, error } = yield this.api.signUpWithEmail(email, password, {
redirectTo: options.redirectTo,
});
if (error) {

@@ -99,4 +102,5 @@ throw error;

* @param provider One of the providers supported by GoTrue.
* @param redirectTo A URL or mobile address to send the user to after they are confirmed.
*/
signIn({ email, password, provider, }) {
signIn({ email, password, provider }, options = {}) {
return __awaiter(this, void 0, void 0, function* () {

@@ -106,9 +110,17 @@ try {

if (email && !password) {
const { error } = yield this.api.sendMagicLinkEmail(email);
const { error } = yield this.api.sendMagicLinkEmail(email, {
redirectTo: options.redirectTo,
});
return { data: null, user: null, session: null, error };
}
if (email && password)
return this._handleEmailSignIn(email, password);
if (provider)
return this._handleProviderSignIn(provider);
if (email && password) {
return this._handleEmailSignIn(email, password, {
redirectTo: options.redirectTo,
});
}
if (provider) {
return this._handleProviderSignIn(provider, {
redirectTo: options.redirectTo,
});
}
throw new Error(`You must provide either an email or a third-party provider.`);

@@ -267,7 +279,9 @@ }

}
_handleEmailSignIn(email, password) {
_handleEmailSignIn(email, password, options = {}) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
try {
const { data, error } = yield this.api.signInWithEmail(email, password);
const { data, error } = yield this.api.signInWithEmail(email, password, {
redirectTo: options.redirectTo,
});
if (error || !data)

@@ -286,4 +300,4 @@ return { data: null, user: null, session: null, error };

}
_handleProviderSignIn(provider) {
const url = this.api.getUrlForProvider(provider);
_handleProviderSignIn(provider, options = {}) {
const url = this.api.getUrlForProvider(provider, { redirectTo: options.redirectTo });
try {

@@ -290,0 +304,0 @@ // try to open on the browser

@@ -71,3 +71,5 @@ export declare type Provider = 'azure' | 'bitbucket' | 'facebook' | 'github' | 'gitlab' | 'google';

provider?: Provider;
/** A URL to redirect the user to after confirmation. */
redirectTo?: URL;
}
//# sourceMappingURL=types.d.ts.map
{
"name": "@supabase/gotrue-js",
"version": "1.10.6",
"version": "1.11.0",
"description": "Isomorphic GoTrue client",

@@ -5,0 +5,0 @@ "keywords": [

@@ -5,4 +5,11 @@ # `gotrue-js`

## Installation
## Docs
- Using `gotrue-js`: https://supabase.io/docs/gotrue/client/initializing
- TypeDoc: https://supabase.github.io/gotrue-js/
## Quick start
Install
```bash

@@ -12,7 +19,16 @@ npm install --save @supabase/gotrue-js

## Docs
Usage
- Using `gotrue-js`: https://supabase.io/docs/gotrue/client/initializing
- TypeDoc: https://supabase.github.io/gotrue-js/
```js
import { GoTrueClient } from '@supabase/gotrue-js'
const GOTRUE_URL = 'http://localhost:9999'
const auth = new GoTrueClient({ url: GOTRUE_URL })
```
- `signUp()`: https://supabase.io/docs/gotrue/client/signup
- `signIn()`: https://supabase.io/docs/gotrue/client/signin
- `signOut()`: https://supabase.io/docs/gotrue/client/signout
## Sponsors

@@ -23,1 +39,3 @@

[![New Sponsor](https://user-images.githubusercontent.com/10214025/90518111-e74bbb00-e198-11ea-8f88-c9e3c1aa4b5b.png)](https://github.com/sponsors/supabase)
![Watch this repo](https://gitcdn.xyz/repo/supabase/monorepo/master/web/static/watch-repo.gif "Watch this repo")

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc