@netlify/identity 0.1.0-alpha.0
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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/index.cjs +174 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +79 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Netlify
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
AuthError: () => AuthError,
|
|
34
|
+
MissingIdentityError: () => MissingIdentityError,
|
|
35
|
+
getIdentityConfig: () => getIdentityConfig,
|
|
36
|
+
getSettings: () => getSettings,
|
|
37
|
+
getUser: () => getUser,
|
|
38
|
+
isAuthenticated: () => isAuthenticated,
|
|
39
|
+
toUser: () => toUser
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(index_exports);
|
|
42
|
+
|
|
43
|
+
// src/environment.ts
|
|
44
|
+
var import_gotrue_js = __toESM(require("gotrue-js"), 1);
|
|
45
|
+
var goTrueClient = null;
|
|
46
|
+
var cachedApiUrl;
|
|
47
|
+
var warnedMissingUrl = false;
|
|
48
|
+
var isBrowser = () => typeof window !== "undefined";
|
|
49
|
+
var discoverApiUrl = () => {
|
|
50
|
+
if (cachedApiUrl !== void 0) return cachedApiUrl;
|
|
51
|
+
if (isBrowser()) {
|
|
52
|
+
cachedApiUrl = `${window.location.origin}/.netlify/identity`;
|
|
53
|
+
} else {
|
|
54
|
+
const identityContext = getIdentityContext();
|
|
55
|
+
if (identityContext?.url) {
|
|
56
|
+
cachedApiUrl = identityContext.url;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return cachedApiUrl ?? null;
|
|
60
|
+
};
|
|
61
|
+
var getGoTrueClient = () => {
|
|
62
|
+
if (goTrueClient) return goTrueClient;
|
|
63
|
+
const apiUrl = discoverApiUrl();
|
|
64
|
+
if (!apiUrl) {
|
|
65
|
+
if (!warnedMissingUrl) {
|
|
66
|
+
console.warn(
|
|
67
|
+
"@netlify/identity: Could not determine the Identity endpoint URL. Make sure your site has Netlify Identity enabled, or run your app with `netlify dev`."
|
|
68
|
+
);
|
|
69
|
+
warnedMissingUrl = true;
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
goTrueClient = new import_gotrue_js.default({ APIUrl: apiUrl, setCookie: isBrowser() });
|
|
74
|
+
return goTrueClient;
|
|
75
|
+
};
|
|
76
|
+
var getIdentityContext = () => {
|
|
77
|
+
const identityContext = globalThis.netlifyIdentityContext;
|
|
78
|
+
if (!identityContext?.url) return null;
|
|
79
|
+
return { url: identityContext.url, token: identityContext.token };
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// src/user.ts
|
|
83
|
+
var toUser = (userData) => {
|
|
84
|
+
const name = userData.user_metadata.full_name || userData.user_metadata.name;
|
|
85
|
+
const pictureUrl = userData.user_metadata.avatar_url;
|
|
86
|
+
return {
|
|
87
|
+
id: userData.id,
|
|
88
|
+
email: userData.email,
|
|
89
|
+
emailVerified: !!userData.confirmed_at,
|
|
90
|
+
createdAt: userData.created_at,
|
|
91
|
+
updatedAt: userData.updated_at,
|
|
92
|
+
provider: userData.app_metadata.provider,
|
|
93
|
+
name: typeof name === "string" ? name : void 0,
|
|
94
|
+
pictureUrl: typeof pictureUrl === "string" ? pictureUrl : void 0,
|
|
95
|
+
metadata: userData.user_metadata,
|
|
96
|
+
rawGoTrueData: { ...userData }
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
var getUser = () => {
|
|
100
|
+
if (isBrowser()) {
|
|
101
|
+
const client = getGoTrueClient();
|
|
102
|
+
const currentUser = client?.currentUser() ?? null;
|
|
103
|
+
if (!currentUser) return null;
|
|
104
|
+
return toUser(currentUser);
|
|
105
|
+
}
|
|
106
|
+
const identityContext = globalThis.netlifyIdentityContext;
|
|
107
|
+
if (!identityContext?.user) return null;
|
|
108
|
+
return toUser(identityContext.user);
|
|
109
|
+
};
|
|
110
|
+
var isAuthenticated = () => getUser() !== null;
|
|
111
|
+
|
|
112
|
+
// src/errors.ts
|
|
113
|
+
var AuthError = class extends Error {
|
|
114
|
+
constructor(message, status, options) {
|
|
115
|
+
super(message);
|
|
116
|
+
this.name = "AuthError";
|
|
117
|
+
this.status = status;
|
|
118
|
+
if (options?.cause) {
|
|
119
|
+
this.cause = options.cause;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
var MissingIdentityError = class extends Error {
|
|
124
|
+
constructor(message = "Identity is not available in this environment") {
|
|
125
|
+
super(message);
|
|
126
|
+
this.name = "MissingIdentityError";
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// src/config.ts
|
|
131
|
+
var getIdentityConfig = () => {
|
|
132
|
+
if (isBrowser()) {
|
|
133
|
+
return { url: `${window.location.origin}/.netlify/identity` };
|
|
134
|
+
}
|
|
135
|
+
return getIdentityContext();
|
|
136
|
+
};
|
|
137
|
+
var getSettings = async () => {
|
|
138
|
+
const client = getGoTrueClient();
|
|
139
|
+
if (!client) throw new MissingIdentityError();
|
|
140
|
+
try {
|
|
141
|
+
const raw = await client.settings();
|
|
142
|
+
const external = raw.external ?? {};
|
|
143
|
+
return {
|
|
144
|
+
autoconfirm: raw.autoconfirm,
|
|
145
|
+
disableSignup: raw.disable_signup,
|
|
146
|
+
providers: {
|
|
147
|
+
google: external.google ?? false,
|
|
148
|
+
github: external.github ?? false,
|
|
149
|
+
gitlab: external.gitlab ?? false,
|
|
150
|
+
bitbucket: external.bitbucket ?? false,
|
|
151
|
+
facebook: external.facebook ?? false,
|
|
152
|
+
email: external.email ?? false,
|
|
153
|
+
saml: false
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
} catch (err) {
|
|
157
|
+
throw new AuthError(
|
|
158
|
+
err instanceof Error ? err.message : "Failed to fetch identity settings",
|
|
159
|
+
502,
|
|
160
|
+
{ cause: err }
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
165
|
+
0 && (module.exports = {
|
|
166
|
+
AuthError,
|
|
167
|
+
MissingIdentityError,
|
|
168
|
+
getIdentityConfig,
|
|
169
|
+
getSettings,
|
|
170
|
+
getUser,
|
|
171
|
+
isAuthenticated,
|
|
172
|
+
toUser
|
|
173
|
+
});
|
|
174
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/environment.ts","../src/user.ts","../src/errors.ts","../src/config.ts"],"sourcesContent":["export type { User } from './user.js'\nexport { toUser, getUser, isAuthenticated } from './user.js'\nexport { getIdentityConfig, getSettings } from './config.js'\nexport type { JWTClaims } from './auth.js'\nexport { AuthError, MissingIdentityError } from './errors.js'\nexport type { AppMetadata, AuthProvider, IdentityConfig, Settings } from './types.js'\n","import GoTrue from 'gotrue-js'\n\nimport type { IdentityConfig } from './types.js'\n\nlet goTrueClient: GoTrue | null = null\nlet cachedApiUrl: string | null | undefined\nlet warnedMissingUrl = false\n\nexport const isBrowser = (): boolean => typeof window !== 'undefined'\n\n/**\n * Discovers and caches the GoTrue API URL.\n *\n * Browser: uses `window.location.origin` + `/.netlify/identity`.\n * Server: reads from `globalThis.netlifyIdentityContext`.\n */\nconst discoverApiUrl = (): string | null => {\n if (cachedApiUrl !== undefined) return cachedApiUrl\n\n if (isBrowser()) {\n cachedApiUrl = `${window.location.origin}/.netlify/identity`\n } else {\n const identityContext = getIdentityContext()\n if (identityContext?.url) {\n cachedApiUrl = identityContext.url\n }\n }\n\n return cachedApiUrl ?? null\n}\n\n/**\n * Returns (and lazily creates) a singleton gotrue-js client.\n * Returns `null` and logs a warning if no identity URL can be discovered.\n */\nexport const getGoTrueClient = (): GoTrue | null => {\n if (goTrueClient) return goTrueClient\n\n const apiUrl = discoverApiUrl()\n if (!apiUrl) {\n if (!warnedMissingUrl) {\n console.warn(\n '@netlify/identity: Could not determine the Identity endpoint URL. ' +\n 'Make sure your site has Netlify Identity enabled, or run your app with `netlify dev`.',\n )\n warnedMissingUrl = true\n }\n return null\n }\n\n goTrueClient = new GoTrue({ APIUrl: apiUrl, setCookie: isBrowser() })\n return goTrueClient\n}\n\n/**\n * Reads the server-side identity context set by the Netlify bootstrap.\n * Returns `null` outside the Netlify serverless environment.\n */\nexport const getIdentityContext = (): IdentityConfig | null => {\n const identityContext = globalThis.netlifyIdentityContext\n if (!identityContext?.url) return null\n return { url: identityContext.url, token: identityContext.token }\n}\n\n/** Reset cached state for tests. */\nexport const resetTestGoTrueClient = (): void => {\n goTrueClient = null\n cachedApiUrl = undefined\n warnedMissingUrl = false\n}\n","import type { UserData } from 'gotrue-js'\nimport type { AuthProvider } from './types.js'\nimport { getGoTrueClient, isBrowser } from './environment.js'\n\nexport interface User {\n id: string\n email?: string\n emailVerified?: boolean\n createdAt?: string\n updatedAt?: string\n provider?: AuthProvider\n name?: string\n pictureUrl?: string\n metadata?: Record<string, unknown>\n rawGoTrueData?: Record<string, unknown>\n}\n\nexport const toUser = (userData: UserData): User => {\n const name = userData.user_metadata.full_name || userData.user_metadata.name\n const pictureUrl = userData.user_metadata.avatar_url\n\n return {\n id: userData.id,\n email: userData.email,\n emailVerified: !!userData.confirmed_at,\n createdAt: userData.created_at,\n updatedAt: userData.updated_at,\n provider: userData.app_metadata.provider as AuthProvider,\n name: typeof name === 'string' ? name : undefined,\n pictureUrl: typeof pictureUrl === 'string' ? pictureUrl : undefined,\n metadata: userData.user_metadata,\n rawGoTrueData: { ...userData },\n }\n}\n\n/**\n * Returns the currently authenticated user, or `null` if not logged in.\n * Synchronous. Never throws.\n */\nexport const getUser = (): User | null => {\n if (isBrowser()) {\n const client = getGoTrueClient()\n const currentUser = client?.currentUser() ?? null\n if (!currentUser) return null\n return toUser(currentUser)\n }\n\n const identityContext = globalThis.netlifyIdentityContext\n if (!identityContext?.user) return null\n return toUser(identityContext.user)\n}\n\n/**\n * Returns `true` if a user is currently authenticated.\n */\nexport const isAuthenticated = (): boolean => getUser() !== null\n\n","export class AuthError extends Error {\n override name = 'AuthError'\n status?: number\n declare cause?: unknown\n\n constructor(message: string, status?: number, options?: { cause?: unknown }) {\n super(message)\n this.status = status\n if (options?.cause) {\n this.cause = options.cause\n }\n }\n}\n\nexport class MissingIdentityError extends Error {\n override name = 'MissingIdentityError'\n\n constructor(message = 'Identity is not available in this environment') {\n super(message)\n }\n}\n","import type { IdentityConfig, Settings } from './types.js'\nimport { AuthError, MissingIdentityError } from './errors.js'\nimport { getGoTrueClient, getIdentityContext, isBrowser } from './environment.js'\n\n/**\n * Returns the identity configuration for the current environment.\n * Browser: always returns `{ url }` derived from `window.location.origin`.\n * Server: returns `{ url, token }` from the identity context, or `null` if unavailable.\n * Never throws.\n */\nexport const getIdentityConfig = (): IdentityConfig | null => {\n if (isBrowser()) {\n return { url: `${window.location.origin}/.netlify/identity` }\n }\n\n return getIdentityContext()\n}\n\n/**\n * Fetches the GoTrue `/settings` endpoint.\n * Throws `MissingIdentityError` if Identity is not configured.\n * Throws `AuthError` if the endpoint is unreachable.\n */\nexport const getSettings = async (): Promise<Settings> => {\n const client = getGoTrueClient()\n if (!client) throw new MissingIdentityError()\n\n try {\n const raw = await client.settings()\n const external = raw.external ?? {}\n return {\n autoconfirm: raw.autoconfirm,\n disableSignup: raw.disable_signup,\n providers: {\n google: external.google ?? false,\n github: external.github ?? false,\n gitlab: external.gitlab ?? false,\n bitbucket: external.bitbucket ?? false,\n facebook: external.facebook ?? false,\n email: external.email ?? false,\n saml: false,\n },\n }\n } catch (err) {\n throw new AuthError(\n err instanceof Error ? err.message : 'Failed to fetch identity settings',\n 502,\n { cause: err },\n )\n }\n}\n"],"mappings":"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","names":["GoTrue"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { UserData } from 'gotrue-js';
|
|
2
|
+
|
|
3
|
+
type AuthProvider = 'google' | 'github' | 'gitlab' | 'bitbucket' | 'facebook' | 'saml' | 'email';
|
|
4
|
+
interface AppMetadata {
|
|
5
|
+
provider: AuthProvider;
|
|
6
|
+
roles?: string[];
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
interface IdentityConfig {
|
|
10
|
+
url: string;
|
|
11
|
+
token?: string;
|
|
12
|
+
}
|
|
13
|
+
interface Settings {
|
|
14
|
+
autoconfirm: boolean;
|
|
15
|
+
disableSignup: boolean;
|
|
16
|
+
providers: Record<AuthProvider, boolean>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface User {
|
|
20
|
+
id: string;
|
|
21
|
+
email?: string;
|
|
22
|
+
emailVerified?: boolean;
|
|
23
|
+
createdAt?: string;
|
|
24
|
+
updatedAt?: string;
|
|
25
|
+
provider?: AuthProvider;
|
|
26
|
+
name?: string;
|
|
27
|
+
pictureUrl?: string;
|
|
28
|
+
metadata?: Record<string, unknown>;
|
|
29
|
+
rawGoTrueData?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
declare const toUser: (userData: UserData) => User;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the currently authenticated user, or `null` if not logged in.
|
|
34
|
+
* Synchronous. Never throws.
|
|
35
|
+
*/
|
|
36
|
+
declare const getUser: () => User | null;
|
|
37
|
+
/**
|
|
38
|
+
* Returns `true` if a user is currently authenticated.
|
|
39
|
+
*/
|
|
40
|
+
declare const isAuthenticated: () => boolean;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns the identity configuration for the current environment.
|
|
44
|
+
* Browser: always returns `{ url }` derived from `window.location.origin`.
|
|
45
|
+
* Server: returns `{ url, token }` from the identity context, or `null` if unavailable.
|
|
46
|
+
* Never throws.
|
|
47
|
+
*/
|
|
48
|
+
declare const getIdentityConfig: () => IdentityConfig | null;
|
|
49
|
+
/**
|
|
50
|
+
* Fetches the GoTrue `/settings` endpoint.
|
|
51
|
+
* Throws `MissingIdentityError` if Identity is not configured.
|
|
52
|
+
* Throws `AuthError` if the endpoint is unreachable.
|
|
53
|
+
*/
|
|
54
|
+
declare const getSettings: () => Promise<Settings>;
|
|
55
|
+
|
|
56
|
+
interface JWTClaims {
|
|
57
|
+
sub: string;
|
|
58
|
+
email: string;
|
|
59
|
+
exp: number;
|
|
60
|
+
iat: number;
|
|
61
|
+
aud: string;
|
|
62
|
+
app_metadata: AppMetadata;
|
|
63
|
+
user_metadata: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare class AuthError extends Error {
|
|
67
|
+
name: string;
|
|
68
|
+
status?: number;
|
|
69
|
+
cause?: unknown;
|
|
70
|
+
constructor(message: string, status?: number, options?: {
|
|
71
|
+
cause?: unknown;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
declare class MissingIdentityError extends Error {
|
|
75
|
+
name: string;
|
|
76
|
+
constructor(message?: string);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { type AppMetadata, AuthError, type AuthProvider, type IdentityConfig, type JWTClaims, MissingIdentityError, type Settings, type User, getIdentityConfig, getSettings, getUser, isAuthenticated, toUser };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { UserData } from 'gotrue-js';
|
|
2
|
+
|
|
3
|
+
type AuthProvider = 'google' | 'github' | 'gitlab' | 'bitbucket' | 'facebook' | 'saml' | 'email';
|
|
4
|
+
interface AppMetadata {
|
|
5
|
+
provider: AuthProvider;
|
|
6
|
+
roles?: string[];
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
interface IdentityConfig {
|
|
10
|
+
url: string;
|
|
11
|
+
token?: string;
|
|
12
|
+
}
|
|
13
|
+
interface Settings {
|
|
14
|
+
autoconfirm: boolean;
|
|
15
|
+
disableSignup: boolean;
|
|
16
|
+
providers: Record<AuthProvider, boolean>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface User {
|
|
20
|
+
id: string;
|
|
21
|
+
email?: string;
|
|
22
|
+
emailVerified?: boolean;
|
|
23
|
+
createdAt?: string;
|
|
24
|
+
updatedAt?: string;
|
|
25
|
+
provider?: AuthProvider;
|
|
26
|
+
name?: string;
|
|
27
|
+
pictureUrl?: string;
|
|
28
|
+
metadata?: Record<string, unknown>;
|
|
29
|
+
rawGoTrueData?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
declare const toUser: (userData: UserData) => User;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the currently authenticated user, or `null` if not logged in.
|
|
34
|
+
* Synchronous. Never throws.
|
|
35
|
+
*/
|
|
36
|
+
declare const getUser: () => User | null;
|
|
37
|
+
/**
|
|
38
|
+
* Returns `true` if a user is currently authenticated.
|
|
39
|
+
*/
|
|
40
|
+
declare const isAuthenticated: () => boolean;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns the identity configuration for the current environment.
|
|
44
|
+
* Browser: always returns `{ url }` derived from `window.location.origin`.
|
|
45
|
+
* Server: returns `{ url, token }` from the identity context, or `null` if unavailable.
|
|
46
|
+
* Never throws.
|
|
47
|
+
*/
|
|
48
|
+
declare const getIdentityConfig: () => IdentityConfig | null;
|
|
49
|
+
/**
|
|
50
|
+
* Fetches the GoTrue `/settings` endpoint.
|
|
51
|
+
* Throws `MissingIdentityError` if Identity is not configured.
|
|
52
|
+
* Throws `AuthError` if the endpoint is unreachable.
|
|
53
|
+
*/
|
|
54
|
+
declare const getSettings: () => Promise<Settings>;
|
|
55
|
+
|
|
56
|
+
interface JWTClaims {
|
|
57
|
+
sub: string;
|
|
58
|
+
email: string;
|
|
59
|
+
exp: number;
|
|
60
|
+
iat: number;
|
|
61
|
+
aud: string;
|
|
62
|
+
app_metadata: AppMetadata;
|
|
63
|
+
user_metadata: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare class AuthError extends Error {
|
|
67
|
+
name: string;
|
|
68
|
+
status?: number;
|
|
69
|
+
cause?: unknown;
|
|
70
|
+
constructor(message: string, status?: number, options?: {
|
|
71
|
+
cause?: unknown;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
declare class MissingIdentityError extends Error {
|
|
75
|
+
name: string;
|
|
76
|
+
constructor(message?: string);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { type AppMetadata, AuthError, type AuthProvider, type IdentityConfig, type JWTClaims, MissingIdentityError, type Settings, type User, getIdentityConfig, getSettings, getUser, isAuthenticated, toUser };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// src/environment.ts
|
|
2
|
+
import GoTrue from "gotrue-js";
|
|
3
|
+
var goTrueClient = null;
|
|
4
|
+
var cachedApiUrl;
|
|
5
|
+
var warnedMissingUrl = false;
|
|
6
|
+
var isBrowser = () => typeof window !== "undefined";
|
|
7
|
+
var discoverApiUrl = () => {
|
|
8
|
+
if (cachedApiUrl !== void 0) return cachedApiUrl;
|
|
9
|
+
if (isBrowser()) {
|
|
10
|
+
cachedApiUrl = `${window.location.origin}/.netlify/identity`;
|
|
11
|
+
} else {
|
|
12
|
+
const identityContext = getIdentityContext();
|
|
13
|
+
if (identityContext?.url) {
|
|
14
|
+
cachedApiUrl = identityContext.url;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return cachedApiUrl ?? null;
|
|
18
|
+
};
|
|
19
|
+
var getGoTrueClient = () => {
|
|
20
|
+
if (goTrueClient) return goTrueClient;
|
|
21
|
+
const apiUrl = discoverApiUrl();
|
|
22
|
+
if (!apiUrl) {
|
|
23
|
+
if (!warnedMissingUrl) {
|
|
24
|
+
console.warn(
|
|
25
|
+
"@netlify/identity: Could not determine the Identity endpoint URL. Make sure your site has Netlify Identity enabled, or run your app with `netlify dev`."
|
|
26
|
+
);
|
|
27
|
+
warnedMissingUrl = true;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
goTrueClient = new GoTrue({ APIUrl: apiUrl, setCookie: isBrowser() });
|
|
32
|
+
return goTrueClient;
|
|
33
|
+
};
|
|
34
|
+
var getIdentityContext = () => {
|
|
35
|
+
const identityContext = globalThis.netlifyIdentityContext;
|
|
36
|
+
if (!identityContext?.url) return null;
|
|
37
|
+
return { url: identityContext.url, token: identityContext.token };
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/user.ts
|
|
41
|
+
var toUser = (userData) => {
|
|
42
|
+
const name = userData.user_metadata.full_name || userData.user_metadata.name;
|
|
43
|
+
const pictureUrl = userData.user_metadata.avatar_url;
|
|
44
|
+
return {
|
|
45
|
+
id: userData.id,
|
|
46
|
+
email: userData.email,
|
|
47
|
+
emailVerified: !!userData.confirmed_at,
|
|
48
|
+
createdAt: userData.created_at,
|
|
49
|
+
updatedAt: userData.updated_at,
|
|
50
|
+
provider: userData.app_metadata.provider,
|
|
51
|
+
name: typeof name === "string" ? name : void 0,
|
|
52
|
+
pictureUrl: typeof pictureUrl === "string" ? pictureUrl : void 0,
|
|
53
|
+
metadata: userData.user_metadata,
|
|
54
|
+
rawGoTrueData: { ...userData }
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
var getUser = () => {
|
|
58
|
+
if (isBrowser()) {
|
|
59
|
+
const client = getGoTrueClient();
|
|
60
|
+
const currentUser = client?.currentUser() ?? null;
|
|
61
|
+
if (!currentUser) return null;
|
|
62
|
+
return toUser(currentUser);
|
|
63
|
+
}
|
|
64
|
+
const identityContext = globalThis.netlifyIdentityContext;
|
|
65
|
+
if (!identityContext?.user) return null;
|
|
66
|
+
return toUser(identityContext.user);
|
|
67
|
+
};
|
|
68
|
+
var isAuthenticated = () => getUser() !== null;
|
|
69
|
+
|
|
70
|
+
// src/errors.ts
|
|
71
|
+
var AuthError = class extends Error {
|
|
72
|
+
constructor(message, status, options) {
|
|
73
|
+
super(message);
|
|
74
|
+
this.name = "AuthError";
|
|
75
|
+
this.status = status;
|
|
76
|
+
if (options?.cause) {
|
|
77
|
+
this.cause = options.cause;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var MissingIdentityError = class extends Error {
|
|
82
|
+
constructor(message = "Identity is not available in this environment") {
|
|
83
|
+
super(message);
|
|
84
|
+
this.name = "MissingIdentityError";
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/config.ts
|
|
89
|
+
var getIdentityConfig = () => {
|
|
90
|
+
if (isBrowser()) {
|
|
91
|
+
return { url: `${window.location.origin}/.netlify/identity` };
|
|
92
|
+
}
|
|
93
|
+
return getIdentityContext();
|
|
94
|
+
};
|
|
95
|
+
var getSettings = async () => {
|
|
96
|
+
const client = getGoTrueClient();
|
|
97
|
+
if (!client) throw new MissingIdentityError();
|
|
98
|
+
try {
|
|
99
|
+
const raw = await client.settings();
|
|
100
|
+
const external = raw.external ?? {};
|
|
101
|
+
return {
|
|
102
|
+
autoconfirm: raw.autoconfirm,
|
|
103
|
+
disableSignup: raw.disable_signup,
|
|
104
|
+
providers: {
|
|
105
|
+
google: external.google ?? false,
|
|
106
|
+
github: external.github ?? false,
|
|
107
|
+
gitlab: external.gitlab ?? false,
|
|
108
|
+
bitbucket: external.bitbucket ?? false,
|
|
109
|
+
facebook: external.facebook ?? false,
|
|
110
|
+
email: external.email ?? false,
|
|
111
|
+
saml: false
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
} catch (err) {
|
|
115
|
+
throw new AuthError(
|
|
116
|
+
err instanceof Error ? err.message : "Failed to fetch identity settings",
|
|
117
|
+
502,
|
|
118
|
+
{ cause: err }
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
export {
|
|
123
|
+
AuthError,
|
|
124
|
+
MissingIdentityError,
|
|
125
|
+
getIdentityConfig,
|
|
126
|
+
getSettings,
|
|
127
|
+
getUser,
|
|
128
|
+
isAuthenticated,
|
|
129
|
+
toUser
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/environment.ts","../src/user.ts","../src/errors.ts","../src/config.ts"],"sourcesContent":["import GoTrue from 'gotrue-js'\n\nimport type { IdentityConfig } from './types.js'\n\nlet goTrueClient: GoTrue | null = null\nlet cachedApiUrl: string | null | undefined\nlet warnedMissingUrl = false\n\nexport const isBrowser = (): boolean => typeof window !== 'undefined'\n\n/**\n * Discovers and caches the GoTrue API URL.\n *\n * Browser: uses `window.location.origin` + `/.netlify/identity`.\n * Server: reads from `globalThis.netlifyIdentityContext`.\n */\nconst discoverApiUrl = (): string | null => {\n if (cachedApiUrl !== undefined) return cachedApiUrl\n\n if (isBrowser()) {\n cachedApiUrl = `${window.location.origin}/.netlify/identity`\n } else {\n const identityContext = getIdentityContext()\n if (identityContext?.url) {\n cachedApiUrl = identityContext.url\n }\n }\n\n return cachedApiUrl ?? null\n}\n\n/**\n * Returns (and lazily creates) a singleton gotrue-js client.\n * Returns `null` and logs a warning if no identity URL can be discovered.\n */\nexport const getGoTrueClient = (): GoTrue | null => {\n if (goTrueClient) return goTrueClient\n\n const apiUrl = discoverApiUrl()\n if (!apiUrl) {\n if (!warnedMissingUrl) {\n console.warn(\n '@netlify/identity: Could not determine the Identity endpoint URL. ' +\n 'Make sure your site has Netlify Identity enabled, or run your app with `netlify dev`.',\n )\n warnedMissingUrl = true\n }\n return null\n }\n\n goTrueClient = new GoTrue({ APIUrl: apiUrl, setCookie: isBrowser() })\n return goTrueClient\n}\n\n/**\n * Reads the server-side identity context set by the Netlify bootstrap.\n * Returns `null` outside the Netlify serverless environment.\n */\nexport const getIdentityContext = (): IdentityConfig | null => {\n const identityContext = globalThis.netlifyIdentityContext\n if (!identityContext?.url) return null\n return { url: identityContext.url, token: identityContext.token }\n}\n\n/** Reset cached state for tests. */\nexport const resetTestGoTrueClient = (): void => {\n goTrueClient = null\n cachedApiUrl = undefined\n warnedMissingUrl = false\n}\n","import type { UserData } from 'gotrue-js'\nimport type { AuthProvider } from './types.js'\nimport { getGoTrueClient, isBrowser } from './environment.js'\n\nexport interface User {\n id: string\n email?: string\n emailVerified?: boolean\n createdAt?: string\n updatedAt?: string\n provider?: AuthProvider\n name?: string\n pictureUrl?: string\n metadata?: Record<string, unknown>\n rawGoTrueData?: Record<string, unknown>\n}\n\nexport const toUser = (userData: UserData): User => {\n const name = userData.user_metadata.full_name || userData.user_metadata.name\n const pictureUrl = userData.user_metadata.avatar_url\n\n return {\n id: userData.id,\n email: userData.email,\n emailVerified: !!userData.confirmed_at,\n createdAt: userData.created_at,\n updatedAt: userData.updated_at,\n provider: userData.app_metadata.provider as AuthProvider,\n name: typeof name === 'string' ? name : undefined,\n pictureUrl: typeof pictureUrl === 'string' ? pictureUrl : undefined,\n metadata: userData.user_metadata,\n rawGoTrueData: { ...userData },\n }\n}\n\n/**\n * Returns the currently authenticated user, or `null` if not logged in.\n * Synchronous. Never throws.\n */\nexport const getUser = (): User | null => {\n if (isBrowser()) {\n const client = getGoTrueClient()\n const currentUser = client?.currentUser() ?? null\n if (!currentUser) return null\n return toUser(currentUser)\n }\n\n const identityContext = globalThis.netlifyIdentityContext\n if (!identityContext?.user) return null\n return toUser(identityContext.user)\n}\n\n/**\n * Returns `true` if a user is currently authenticated.\n */\nexport const isAuthenticated = (): boolean => getUser() !== null\n\n","export class AuthError extends Error {\n override name = 'AuthError'\n status?: number\n declare cause?: unknown\n\n constructor(message: string, status?: number, options?: { cause?: unknown }) {\n super(message)\n this.status = status\n if (options?.cause) {\n this.cause = options.cause\n }\n }\n}\n\nexport class MissingIdentityError extends Error {\n override name = 'MissingIdentityError'\n\n constructor(message = 'Identity is not available in this environment') {\n super(message)\n }\n}\n","import type { IdentityConfig, Settings } from './types.js'\nimport { AuthError, MissingIdentityError } from './errors.js'\nimport { getGoTrueClient, getIdentityContext, isBrowser } from './environment.js'\n\n/**\n * Returns the identity configuration for the current environment.\n * Browser: always returns `{ url }` derived from `window.location.origin`.\n * Server: returns `{ url, token }` from the identity context, or `null` if unavailable.\n * Never throws.\n */\nexport const getIdentityConfig = (): IdentityConfig | null => {\n if (isBrowser()) {\n return { url: `${window.location.origin}/.netlify/identity` }\n }\n\n return getIdentityContext()\n}\n\n/**\n * Fetches the GoTrue `/settings` endpoint.\n * Throws `MissingIdentityError` if Identity is not configured.\n * Throws `AuthError` if the endpoint is unreachable.\n */\nexport const getSettings = async (): Promise<Settings> => {\n const client = getGoTrueClient()\n if (!client) throw new MissingIdentityError()\n\n try {\n const raw = await client.settings()\n const external = raw.external ?? {}\n return {\n autoconfirm: raw.autoconfirm,\n disableSignup: raw.disable_signup,\n providers: {\n google: external.google ?? false,\n github: external.github ?? false,\n gitlab: external.gitlab ?? false,\n bitbucket: external.bitbucket ?? false,\n facebook: external.facebook ?? false,\n email: external.email ?? false,\n saml: false,\n },\n }\n } catch (err) {\n throw new AuthError(\n err instanceof Error ? err.message : 'Failed to fetch identity settings',\n 502,\n { cause: err },\n )\n }\n}\n"],"mappings":"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","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@netlify/identity",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Add authentication to your Netlify site with a few lines of code",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"default": "./dist/index.cjs"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/**/*.js",
|
|
22
|
+
"dist/**/*.cjs",
|
|
23
|
+
"dist/**/*.d.ts",
|
|
24
|
+
"dist/**/*.d.cts",
|
|
25
|
+
"dist/**/*.map"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup",
|
|
32
|
+
"dev": "tsup --watch",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest",
|
|
35
|
+
"lint": "eslint src test",
|
|
36
|
+
"format": "prettier --check .",
|
|
37
|
+
"format:fix": "prettier --write .",
|
|
38
|
+
"prepack": "npm run build",
|
|
39
|
+
"prepublishOnly": "npm run test"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"netlify",
|
|
43
|
+
"identity",
|
|
44
|
+
"authentication",
|
|
45
|
+
"jwt"
|
|
46
|
+
],
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "https://github.com/netlify/identity.git"
|
|
51
|
+
},
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/netlify/identity/issues"
|
|
54
|
+
},
|
|
55
|
+
"author": "Netlify Inc.",
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"eslint": "^9.0.0",
|
|
58
|
+
"jsdom": "^28.1.0",
|
|
59
|
+
"prettier": "^3.0.0",
|
|
60
|
+
"tsup": "^8.5.0",
|
|
61
|
+
"typescript": "^5.0.0",
|
|
62
|
+
"typescript-eslint": "^8.0.0",
|
|
63
|
+
"vitest": "^4.0.0"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"gotrue-js": "^1.0.1"
|
|
67
|
+
}
|
|
68
|
+
}
|