@cedarjs/auth-supabase-web 5.0.7-next.338 → 5.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +28 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/supabase.d.ts +178 -0
- package/dist/cjs/supabase.d.ts.map +1 -0
- package/dist/cjs/supabase.js +249 -0
- package/dist/supabase.d.ts.map +1 -1
- package/package.json +21 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
|
+
createAuth: () => import_supabase.createAuth
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(index_exports);
|
|
24
|
+
var import_supabase = require("./supabase.js");
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
createAuth
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { SupabaseClient, AuthResponse, OAuthResponse, SSOResponse, SignInWithOAuthCredentials, SignInWithIdTokenCredentials, SignInWithPasswordCredentials, SignInWithPasswordlessCredentials, SignInWithSSO } from '@supabase/supabase-js';
|
|
2
|
+
import type { CurrentUser } from '@cedarjs/auth';
|
|
3
|
+
export type SignInWithOAuthOptions = SignInWithOAuthCredentials & {
|
|
4
|
+
authMethod: 'oauth';
|
|
5
|
+
};
|
|
6
|
+
export type SignInWithIdTokenOptions = SignInWithIdTokenCredentials & {
|
|
7
|
+
authMethod: 'id_token';
|
|
8
|
+
};
|
|
9
|
+
export type SignInWithPasswordOptions = SignInWithPasswordCredentials & {
|
|
10
|
+
authMethod: 'password';
|
|
11
|
+
};
|
|
12
|
+
export type SignInWithPasswordlessOptions = SignInWithPasswordlessCredentials & {
|
|
13
|
+
authMethod: 'otp';
|
|
14
|
+
};
|
|
15
|
+
export type SignInWithSSOOptions = SignInWithSSO & {
|
|
16
|
+
authMethod: 'sso';
|
|
17
|
+
};
|
|
18
|
+
export declare function createAuth(supabaseClient: SupabaseClient, customProviderHooks?: {
|
|
19
|
+
useCurrentUser?: () => Promise<CurrentUser>;
|
|
20
|
+
useHasRole?: (currentUser: CurrentUser | null) => (rolesToCheck: string | string[]) => boolean;
|
|
21
|
+
}): {
|
|
22
|
+
AuthContext: import("react").Context<import("@cedarjs/auth").AuthContextInterface<import("@supabase/supabase-js").UserMetadata, SignInWithOAuthOptions | SignInWithIdTokenOptions | ({
|
|
23
|
+
email: string;
|
|
24
|
+
password: string;
|
|
25
|
+
} & {
|
|
26
|
+
options?: {
|
|
27
|
+
captchaToken?: string;
|
|
28
|
+
};
|
|
29
|
+
} & {
|
|
30
|
+
authMethod: "password";
|
|
31
|
+
}) | ({
|
|
32
|
+
phone: string;
|
|
33
|
+
password: string;
|
|
34
|
+
} & {
|
|
35
|
+
options?: {
|
|
36
|
+
captchaToken?: string;
|
|
37
|
+
};
|
|
38
|
+
} & {
|
|
39
|
+
authMethod: "password";
|
|
40
|
+
}) | ({
|
|
41
|
+
email: string;
|
|
42
|
+
options?: {
|
|
43
|
+
emailRedirectTo?: string;
|
|
44
|
+
shouldCreateUser?: boolean;
|
|
45
|
+
data?: object;
|
|
46
|
+
captchaToken?: string;
|
|
47
|
+
};
|
|
48
|
+
} & {
|
|
49
|
+
authMethod: "otp";
|
|
50
|
+
}) | ({
|
|
51
|
+
phone: string;
|
|
52
|
+
options?: {
|
|
53
|
+
shouldCreateUser?: boolean;
|
|
54
|
+
data?: object;
|
|
55
|
+
captchaToken?: string;
|
|
56
|
+
channel?: "sms" | "whatsapp";
|
|
57
|
+
};
|
|
58
|
+
} & {
|
|
59
|
+
authMethod: "otp";
|
|
60
|
+
}) | ({
|
|
61
|
+
providerId: string;
|
|
62
|
+
options?: {
|
|
63
|
+
redirectTo?: string;
|
|
64
|
+
captchaToken?: string;
|
|
65
|
+
skipBrowserRedirect?: boolean;
|
|
66
|
+
};
|
|
67
|
+
} & {
|
|
68
|
+
authMethod: "sso";
|
|
69
|
+
}) | ({
|
|
70
|
+
domain: string;
|
|
71
|
+
options?: {
|
|
72
|
+
redirectTo?: string;
|
|
73
|
+
captchaToken?: string;
|
|
74
|
+
skipBrowserRedirect?: boolean;
|
|
75
|
+
};
|
|
76
|
+
} & {
|
|
77
|
+
authMethod: "sso";
|
|
78
|
+
}), AuthResponse | OAuthResponse | SSOResponse, unknown, void, ({
|
|
79
|
+
email: string;
|
|
80
|
+
password: string;
|
|
81
|
+
} & {
|
|
82
|
+
options?: {
|
|
83
|
+
emailRedirectTo?: string;
|
|
84
|
+
data?: object;
|
|
85
|
+
captchaToken?: string;
|
|
86
|
+
channel?: "sms" | "whatsapp";
|
|
87
|
+
};
|
|
88
|
+
}) | ({
|
|
89
|
+
phone: string;
|
|
90
|
+
password: string;
|
|
91
|
+
} & {
|
|
92
|
+
options?: {
|
|
93
|
+
emailRedirectTo?: string;
|
|
94
|
+
data?: object;
|
|
95
|
+
captchaToken?: string;
|
|
96
|
+
channel?: "sms" | "whatsapp";
|
|
97
|
+
};
|
|
98
|
+
}), AuthResponse, unknown, unknown, unknown, unknown, SupabaseClient<any, "public", "public", any, any>> | undefined>;
|
|
99
|
+
AuthProvider: ({ children }: import("@cedarjs/auth").AuthProviderProps) => import("react").JSX.Element;
|
|
100
|
+
useAuth: () => import("@cedarjs/auth").AuthContextInterface<import("@supabase/supabase-js").UserMetadata, SignInWithOAuthOptions | SignInWithIdTokenOptions | ({
|
|
101
|
+
email: string;
|
|
102
|
+
password: string;
|
|
103
|
+
} & {
|
|
104
|
+
options?: {
|
|
105
|
+
captchaToken?: string;
|
|
106
|
+
};
|
|
107
|
+
} & {
|
|
108
|
+
authMethod: "password";
|
|
109
|
+
}) | ({
|
|
110
|
+
phone: string;
|
|
111
|
+
password: string;
|
|
112
|
+
} & {
|
|
113
|
+
options?: {
|
|
114
|
+
captchaToken?: string;
|
|
115
|
+
};
|
|
116
|
+
} & {
|
|
117
|
+
authMethod: "password";
|
|
118
|
+
}) | ({
|
|
119
|
+
email: string;
|
|
120
|
+
options?: {
|
|
121
|
+
emailRedirectTo?: string;
|
|
122
|
+
shouldCreateUser?: boolean;
|
|
123
|
+
data?: object;
|
|
124
|
+
captchaToken?: string;
|
|
125
|
+
};
|
|
126
|
+
} & {
|
|
127
|
+
authMethod: "otp";
|
|
128
|
+
}) | ({
|
|
129
|
+
phone: string;
|
|
130
|
+
options?: {
|
|
131
|
+
shouldCreateUser?: boolean;
|
|
132
|
+
data?: object;
|
|
133
|
+
captchaToken?: string;
|
|
134
|
+
channel?: "sms" | "whatsapp";
|
|
135
|
+
};
|
|
136
|
+
} & {
|
|
137
|
+
authMethod: "otp";
|
|
138
|
+
}) | ({
|
|
139
|
+
providerId: string;
|
|
140
|
+
options?: {
|
|
141
|
+
redirectTo?: string;
|
|
142
|
+
captchaToken?: string;
|
|
143
|
+
skipBrowserRedirect?: boolean;
|
|
144
|
+
};
|
|
145
|
+
} & {
|
|
146
|
+
authMethod: "sso";
|
|
147
|
+
}) | ({
|
|
148
|
+
domain: string;
|
|
149
|
+
options?: {
|
|
150
|
+
redirectTo?: string;
|
|
151
|
+
captchaToken?: string;
|
|
152
|
+
skipBrowserRedirect?: boolean;
|
|
153
|
+
};
|
|
154
|
+
} & {
|
|
155
|
+
authMethod: "sso";
|
|
156
|
+
}), AuthResponse | OAuthResponse | SSOResponse, unknown, void, ({
|
|
157
|
+
email: string;
|
|
158
|
+
password: string;
|
|
159
|
+
} & {
|
|
160
|
+
options?: {
|
|
161
|
+
emailRedirectTo?: string;
|
|
162
|
+
data?: object;
|
|
163
|
+
captchaToken?: string;
|
|
164
|
+
channel?: "sms" | "whatsapp";
|
|
165
|
+
};
|
|
166
|
+
}) | ({
|
|
167
|
+
phone: string;
|
|
168
|
+
password: string;
|
|
169
|
+
} & {
|
|
170
|
+
options?: {
|
|
171
|
+
emailRedirectTo?: string;
|
|
172
|
+
data?: object;
|
|
173
|
+
captchaToken?: string;
|
|
174
|
+
channel?: "sms" | "whatsapp";
|
|
175
|
+
};
|
|
176
|
+
}), AuthResponse, unknown, unknown, unknown, unknown, SupabaseClient<any, "public", "public", any, any>>;
|
|
177
|
+
};
|
|
178
|
+
//# sourceMappingURL=supabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/supabase.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,WAAW,EACX,0BAA0B,EAC1B,4BAA4B,EAC5B,6BA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,CAAC;gBAAsB,CAAC;wBAA8B,CAAC;mBAAyB,CAAC;;;;;;;2BAAjF,CAAC;gBAAsB,CAAC;wBAA8B,CAAC;mBAAyB,CAAC;;;;;;;;;wBAAwQ,CAAC;;;oBAlSl/R,UAAU;;;;;;wBAkSu+R,CAAC;;;oBAlSl/R,UAAU;;;;2BAkSwsS,CAAC;4BAA4H,CAAC;gBAAoS,CAAC;wBAA0H,CAAC;;;oBA7R9uT,KAAK;;;;4BA6Ry7T,CAAC;gBAAoS,CAAC;wBAA0H,CAAC;mBAAwF,CAAC;;;oBA7Rx7U,KAAK;;;;sBA6R6ziB,CAAC;wBAA0H,CAAC;+BAAwP,CAAC;;;oBAzRzrjB,KAAK;;;;sBAyRq5jB,CAAC;wBAA0H,CAAC;+BAAwP,CAAC;;;oBAzR/wkB,KAAK;;;;;;2BAyRmpR,CAAC;gBAAsB,CAAC;wBAA8B,CAAC;mBAAyB,CAAC;;;;;;;2BAAjF,CAAC;gBAAsB,CAAC;wBAA8B,CAAC;mBAAyB,CAAC;;;EArPtvR"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var supabase_exports = {};
|
|
20
|
+
__export(supabase_exports, {
|
|
21
|
+
createAuth: () => createAuth
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(supabase_exports);
|
|
24
|
+
var import_ssr = require("@supabase/ssr");
|
|
25
|
+
var import_ssr2 = require("@supabase/ssr");
|
|
26
|
+
var import_supabase_js = require("@supabase/supabase-js");
|
|
27
|
+
var import_auth = require("@cedarjs/auth");
|
|
28
|
+
function createMiddlewareAuth(supabaseClient, customProviderHooks) {
|
|
29
|
+
const authImplementation = createAuthImplementation({
|
|
30
|
+
supabaseClient,
|
|
31
|
+
middleware: true
|
|
32
|
+
});
|
|
33
|
+
return (0, import_auth.createAuthentication)(authImplementation, {
|
|
34
|
+
...customProviderHooks,
|
|
35
|
+
useCurrentUser: customProviderHooks?.useCurrentUser ?? (() => (0, import_auth.getCurrentUserFromMiddleware)("/middleware/supabase"))
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function createAuth(supabaseClient, customProviderHooks) {
|
|
39
|
+
if (RWJS_ENV.RWJS_EXP_STREAMING_SSR) {
|
|
40
|
+
return createMiddlewareAuth(supabaseClient, customProviderHooks);
|
|
41
|
+
}
|
|
42
|
+
const authImplementation = createAuthImplementation({ supabaseClient });
|
|
43
|
+
return (0, import_auth.createAuthentication)(authImplementation, customProviderHooks);
|
|
44
|
+
}
|
|
45
|
+
const setAuthProviderCookie = () => {
|
|
46
|
+
const authProviderCookieString = (0, import_ssr2.serialize)(
|
|
47
|
+
"auth-provider",
|
|
48
|
+
"supabase",
|
|
49
|
+
import_ssr.DEFAULT_COOKIE_OPTIONS
|
|
50
|
+
);
|
|
51
|
+
document.cookie = authProviderCookieString;
|
|
52
|
+
};
|
|
53
|
+
const expireAuthProviderCookie = () => {
|
|
54
|
+
const authProviderCookieString = (0, import_ssr2.serialize)("auth-provider", "supabase", {
|
|
55
|
+
...import_ssr.DEFAULT_COOKIE_OPTIONS,
|
|
56
|
+
maxAge: -1
|
|
57
|
+
});
|
|
58
|
+
document.cookie = authProviderCookieString;
|
|
59
|
+
};
|
|
60
|
+
function createAuthImplementation({
|
|
61
|
+
supabaseClient,
|
|
62
|
+
middleware = false
|
|
63
|
+
}) {
|
|
64
|
+
return {
|
|
65
|
+
type: "supabase",
|
|
66
|
+
client: supabaseClient,
|
|
67
|
+
/*
|
|
68
|
+
* All Supabase Sign In Authentication Methods
|
|
69
|
+
*/
|
|
70
|
+
login: async (credentials) => {
|
|
71
|
+
let result;
|
|
72
|
+
switch (credentials.authMethod) {
|
|
73
|
+
/**
|
|
74
|
+
* Log in an existing user with an email and password or phone and password.
|
|
75
|
+
*
|
|
76
|
+
* Be aware that you may get back an error message that will not distinguish
|
|
77
|
+
* between the cases where the account does not exist or that the
|
|
78
|
+
* email/phone and password combination is wrong or that the account can only
|
|
79
|
+
* be accessed via social login.
|
|
80
|
+
*/
|
|
81
|
+
case "password":
|
|
82
|
+
result = await supabaseClient.auth.signInWithPassword(credentials);
|
|
83
|
+
break;
|
|
84
|
+
/**
|
|
85
|
+
* Log in an existing user via a third-party provider.
|
|
86
|
+
*/
|
|
87
|
+
case "oauth":
|
|
88
|
+
result = await supabaseClient.auth.signInWithOAuth(credentials);
|
|
89
|
+
break;
|
|
90
|
+
/**
|
|
91
|
+
* Log in a user using magiclink or a one-time password (OTP).
|
|
92
|
+
*
|
|
93
|
+
* If the `{{ .ConfirmationURL }}` variable is specified in the email template, a magiclink will be sent.
|
|
94
|
+
* If the `{{ .Token }}` variable is specified in the email template, an OTP will be sent.
|
|
95
|
+
* If you're using phone sign-ins, only an OTP will be sent. You won't be able to send a magiclink for phone sign-ins.
|
|
96
|
+
*
|
|
97
|
+
* Be aware that you may get back an error message that will not distinguish
|
|
98
|
+
* between the cases where the account does not exist or, that the account
|
|
99
|
+
* can only be accessed via social login.
|
|
100
|
+
*/
|
|
101
|
+
case "otp":
|
|
102
|
+
result = await supabaseClient.auth.signInWithOtp(credentials);
|
|
103
|
+
break;
|
|
104
|
+
/**
|
|
105
|
+
* Attempts a single-sign on using an enterprise Identity Provider. A
|
|
106
|
+
* successful SSO attempt will redirect the current page to the identity
|
|
107
|
+
* provider authorization page. The redirect URL is implementation and SSO
|
|
108
|
+
* protocol specific.
|
|
109
|
+
*
|
|
110
|
+
* You can use it by providing a SSO domain. Typically you can extract this
|
|
111
|
+
* domain by asking users for their email address. If this domain is
|
|
112
|
+
* registered on the Auth instance the redirect will use that organization's
|
|
113
|
+
* currently active SSO Identity Provider for the login.
|
|
114
|
+
*
|
|
115
|
+
* If you have built an organization-specific login page, you can use the
|
|
116
|
+
* organization's SSO Identity Provider UUID directly instead.
|
|
117
|
+
*
|
|
118
|
+
* This API is experimental and availability is conditional on correct
|
|
119
|
+
* settings on the Auth service.
|
|
120
|
+
*
|
|
121
|
+
* @experimental
|
|
122
|
+
*/
|
|
123
|
+
case "sso":
|
|
124
|
+
result = await supabaseClient.auth.signInWithSSO(credentials);
|
|
125
|
+
break;
|
|
126
|
+
/**
|
|
127
|
+
* Allows signing in with an ID token issued by certain supported providers.
|
|
128
|
+
* The ID token is verified for validity and a new session is established.
|
|
129
|
+
*
|
|
130
|
+
* @experimental
|
|
131
|
+
*/
|
|
132
|
+
case "id_token":
|
|
133
|
+
result = await supabaseClient.auth.signInWithIdToken(credentials);
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
return {
|
|
137
|
+
data: { user: null, session: null },
|
|
138
|
+
error: new import_supabase_js.AuthError("Unsupported authentication method")
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (middleware) {
|
|
142
|
+
setAuthProviderCookie();
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* Inside a browser context, `signOut()` will remove the logged in user from the browser session
|
|
148
|
+
* and log them out - removing all items from localStorage and then trigger a `"SIGNED_OUT"` event.
|
|
149
|
+
*
|
|
150
|
+
* For server-side management, you can revoke all refresh tokens for a user by passing a user's JWT through to `auth.api.signOut(JWT: string)`.
|
|
151
|
+
* There is no way to revoke a user's access token jwt until it expires. It is recommended to set a shorter expiry on the jwt for this reason.
|
|
152
|
+
*/
|
|
153
|
+
logout: async () => {
|
|
154
|
+
const { error } = await supabaseClient.auth.signOut();
|
|
155
|
+
if (error) {
|
|
156
|
+
console.error(error);
|
|
157
|
+
}
|
|
158
|
+
if (middleware) {
|
|
159
|
+
expireAuthProviderCookie();
|
|
160
|
+
}
|
|
161
|
+
return;
|
|
162
|
+
},
|
|
163
|
+
/**
|
|
164
|
+
* Creates a new user.
|
|
165
|
+
*
|
|
166
|
+
* Be aware that if a user account exists in the system you may get back an
|
|
167
|
+
* error message that attempts to hide this information from the user.
|
|
168
|
+
*
|
|
169
|
+
* @returns A logged-in session if the server has "autoconfirm" ON
|
|
170
|
+
* @returns A user if the server has "autoconfirm" OFF
|
|
171
|
+
*/
|
|
172
|
+
signup: async (credentials) => {
|
|
173
|
+
const result = await supabaseClient.auth.signUp(credentials);
|
|
174
|
+
if (result.data?.session) {
|
|
175
|
+
setAuthProviderCookie();
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
},
|
|
179
|
+
getToken: async () => {
|
|
180
|
+
const { data, error } = await supabaseClient.auth.getSession();
|
|
181
|
+
if (error) {
|
|
182
|
+
console.error(error);
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
return data?.session?.access_token ?? null;
|
|
186
|
+
},
|
|
187
|
+
/**
|
|
188
|
+
* Gets the current user metadata if there is an existing session.
|
|
189
|
+
*/
|
|
190
|
+
getUserMetadata: async () => {
|
|
191
|
+
const { data, error } = await supabaseClient.auth.getSession();
|
|
192
|
+
if (error) {
|
|
193
|
+
console.error(error);
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
return data?.session?.user?.user_metadata ?? null;
|
|
197
|
+
},
|
|
198
|
+
/**
|
|
199
|
+
* Restore CedarJS authentication state when an OAuth or magiclink callback
|
|
200
|
+
* redirects back to site with access token by restoring the Supabase auth
|
|
201
|
+
* session.
|
|
202
|
+
*
|
|
203
|
+
* Initializes the Supabase client session either from the url or from
|
|
204
|
+
* storage. This method is automatically called when instantiating the
|
|
205
|
+
* client, but should also be called manually when checking for an error
|
|
206
|
+
* from an auth redirect (oauth, magiclink, password recovery, etc).
|
|
207
|
+
*/
|
|
208
|
+
restoreAuthState: async () => {
|
|
209
|
+
try {
|
|
210
|
+
const { data } = await supabaseClient.auth.refreshSession();
|
|
211
|
+
if (middleware) {
|
|
212
|
+
if (data.session) {
|
|
213
|
+
setAuthProviderCookie();
|
|
214
|
+
} else {
|
|
215
|
+
expireAuthProviderCookie();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const currentUrl = new URL(window.location.href);
|
|
219
|
+
const authParams = [
|
|
220
|
+
"access_token",
|
|
221
|
+
"refresh_token",
|
|
222
|
+
"token_type",
|
|
223
|
+
"expires_in",
|
|
224
|
+
"expires_at"
|
|
225
|
+
];
|
|
226
|
+
let hasAuthParams = false;
|
|
227
|
+
authParams.forEach((param) => {
|
|
228
|
+
if (currentUrl.searchParams.has(param)) {
|
|
229
|
+
currentUrl.searchParams.delete(param);
|
|
230
|
+
hasAuthParams = true;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
if (hasAuthParams) {
|
|
234
|
+
const cleanUrl = currentUrl.pathname + (currentUrl.search || "");
|
|
235
|
+
window.history.replaceState({}, document.title, cleanUrl);
|
|
236
|
+
}
|
|
237
|
+
} catch (error) {
|
|
238
|
+
console.error(error);
|
|
239
|
+
}
|
|
240
|
+
return;
|
|
241
|
+
},
|
|
242
|
+
// This is important, so we can skip fetching getCurrentUser
|
|
243
|
+
useMiddlewareAuth: middleware
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
247
|
+
0 && (module.exports = {
|
|
248
|
+
createAuth
|
|
249
|
+
});
|
package/dist/supabase.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../src/supabase.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,WAAW,EACX,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,iCAAiC,EACjC,aAAa,EAId,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,eAAe,CAAA;AAMrE,MAAM,MAAM,sBAAsB,GAAG,0BAA0B,GAAG;IAChE,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,4BAA4B,GAAG;IACpE,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,6BAA6B,GAAG;IACtE,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,6BAA6B,GACvC,iCAAiC,GAAG;IAClC,UAAU,EAAE,KAAK,CAAA;CAClB,CAAA;AAEH,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,UAAU,EAAE,KAAK,CAAA;CAClB,CAAA;AAmBD,wBAAgB,UAAU,CACxB,cAAc,EAAE,cAAc,EAC9B,mBAAmB,CAAC,EAAE;IACpB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3C,UAAU,CAAC,EAAE,CACX,WAAW,EAAE,WAAW,GAAG,IAAI,KAC5B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAA;CAClD;;;;;;
|
|
1
|
+
{"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../src/supabase.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,WAAW,EACX,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;oBAzR/wkB,KAAK;;;;;;2BAyRmpR,CAAC;gBAAsB,CAAC;wBAA8B,CAAC;mBAAyB,CAAC;;;;;;;2BAAjF,CAAC;gBAAsB,CAAC;wBAA8B,CAAC;mBAAyB,CAAC;;;;;;;;;wBAAwQ,CAAC;;;oBAlSl/R,UAAU;;;;;;wBAkSu+R,CAAC;;;oBAlSl/R,UAAU;;;;2BAkSwsS,CAAC;4BAA4H,CAAC;gBAAoS,CAAC;wBAA0H,CAAC;;;oBA7R9uT,KAAK;;;;4BA6Ry7T,CAAC;gBAAoS,CAAC;wBAA0H,CAAC;mBAAwF,CAAC;;;oBA7Rx7U,KAAK;;;;sBA6R6ziB,CAAC;wBAA0H,CAAC;+BAAwP,CAAC;;;oBAzRzrjB,KAAK;;;;sBAyRq5jB,CAAC;wBAA0H,CAAC;+BAAwP,CAAC;;;oBAzR/wkB,KAAK;;;;;;2BAyRmpR,CAAC;gBAAsB,CAAC;wBAA8B,CAAC;mBAAyB,CAAC;;;;;;;2BAAjF,CAAC;gBAAsB,CAAC;wBAA8B,CAAC;mBAAyB,CAAC;;;EArPtvR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/auth-supabase-web",
|
|
3
|
-
"version": "5.0.7
|
|
3
|
+
"version": "5.0.7",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -10,19 +10,28 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"
|
|
13
|
+
"import": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"default": {
|
|
18
|
+
"types": "./dist/cjs/index.d.ts",
|
|
19
|
+
"default": "./dist/cjs/index.js"
|
|
16
20
|
}
|
|
17
21
|
},
|
|
18
22
|
"./dist/supabase": {
|
|
19
|
-
"
|
|
23
|
+
"import": {
|
|
20
24
|
"types": "./dist/supabase.d.ts",
|
|
21
25
|
"default": "./dist/supabase.js"
|
|
26
|
+
},
|
|
27
|
+
"default": {
|
|
28
|
+
"types": "./dist/cjs/supabase.d.ts",
|
|
29
|
+
"default": "./dist/cjs/supabase.js"
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
},
|
|
25
|
-
"main": "./dist/index.js",
|
|
33
|
+
"main": "./dist/cjs/index.js",
|
|
34
|
+
"module": "./dist/index.js",
|
|
26
35
|
"types": "./dist/index.d.ts",
|
|
27
36
|
"files": [
|
|
28
37
|
"dist"
|
|
@@ -31,6 +40,7 @@
|
|
|
31
40
|
"build": "node ./build.ts",
|
|
32
41
|
"build:pack": "yarn pack -o cedarjs-auth-supabase-web.tgz",
|
|
33
42
|
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
43
|
+
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
|
|
34
44
|
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
|
|
35
45
|
"check:attw": "yarn cedar-fwtools-attw",
|
|
36
46
|
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
@@ -39,21 +49,21 @@
|
|
|
39
49
|
"test:watch": "vitest watch"
|
|
40
50
|
},
|
|
41
51
|
"dependencies": {
|
|
42
|
-
"@cedarjs/auth": "5.0.7
|
|
52
|
+
"@cedarjs/auth": "5.0.7"
|
|
43
53
|
},
|
|
44
54
|
"devDependencies": {
|
|
45
|
-
"@cedarjs/framework-tools": "5.0.7
|
|
46
|
-
"@supabase/ssr": "0.12.
|
|
47
|
-
"@supabase/supabase-js": "2.
|
|
55
|
+
"@cedarjs/framework-tools": "5.0.7",
|
|
56
|
+
"@supabase/ssr": "0.12.0",
|
|
57
|
+
"@supabase/supabase-js": "2.110.3",
|
|
48
58
|
"@types/react": "^18.2.55",
|
|
49
59
|
"concurrently": "9.2.4",
|
|
50
|
-
"publint": "0.3.
|
|
60
|
+
"publint": "0.3.21",
|
|
51
61
|
"react": "18.3.1",
|
|
52
62
|
"typescript": "5.9.3",
|
|
53
|
-
"vitest": "
|
|
63
|
+
"vitest": "3.2.6"
|
|
54
64
|
},
|
|
55
65
|
"peerDependencies": {
|
|
56
|
-
"@supabase/supabase-js": "2.
|
|
66
|
+
"@supabase/supabase-js": "2.110.3"
|
|
57
67
|
},
|
|
58
68
|
"engines": {
|
|
59
69
|
"node": ">=24"
|