@cedarjs/auth-firebase-web 6.0.0-canary.2769 → 6.0.0-canary.2771
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/package.json +6 -16
- package/dist/cjs/firebase.d.ts +0 -32
- package/dist/cjs/firebase.d.ts.map +0 -1
- package/dist/cjs/firebase.js +0 -131
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -28
- package/dist/cjs/package.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/auth-firebase-web",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2771",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -10,28 +10,19 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"
|
|
13
|
+
"default": {
|
|
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"
|
|
20
16
|
}
|
|
21
17
|
},
|
|
22
18
|
"./dist/firebase": {
|
|
23
|
-
"
|
|
19
|
+
"default": {
|
|
24
20
|
"types": "./dist/firebase.d.ts",
|
|
25
21
|
"default": "./dist/firebase.js"
|
|
26
|
-
},
|
|
27
|
-
"default": {
|
|
28
|
-
"types": "./dist/cjs/firebase.d.ts",
|
|
29
|
-
"default": "./dist/cjs/firebase.js"
|
|
30
22
|
}
|
|
31
23
|
}
|
|
32
24
|
},
|
|
33
|
-
"main": "./dist/
|
|
34
|
-
"module": "./dist/index.js",
|
|
25
|
+
"main": "./dist/index.js",
|
|
35
26
|
"types": "./dist/index.d.ts",
|
|
36
27
|
"files": [
|
|
37
28
|
"dist"
|
|
@@ -40,7 +31,6 @@
|
|
|
40
31
|
"build": "node ./build.ts",
|
|
41
32
|
"build:pack": "yarn pack -o cedarjs-auth-firebase-web.tgz",
|
|
42
33
|
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
43
|
-
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
|
|
44
34
|
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
|
|
45
35
|
"check:attw": "yarn cedar-fwtools-attw",
|
|
46
36
|
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
@@ -49,10 +39,10 @@
|
|
|
49
39
|
"test:watch": "vitest watch"
|
|
50
40
|
},
|
|
51
41
|
"dependencies": {
|
|
52
|
-
"@cedarjs/auth": "6.0.0-canary.
|
|
42
|
+
"@cedarjs/auth": "6.0.0-canary.2771"
|
|
53
43
|
},
|
|
54
44
|
"devDependencies": {
|
|
55
|
-
"@cedarjs/framework-tools": "6.0.0-canary.
|
|
45
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2771",
|
|
56
46
|
"@types/react": "^18.2.55",
|
|
57
47
|
"concurrently": "9.2.4",
|
|
58
48
|
"firebase": "10.14.1",
|
package/dist/cjs/firebase.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { FirebaseApp } from 'firebase/app';
|
|
2
|
-
import type { CustomParameters, User } from 'firebase/auth';
|
|
3
|
-
import type FirebaseAuthNamespace from 'firebase/auth';
|
|
4
|
-
import type { CurrentUser } from '@cedarjs/auth';
|
|
5
|
-
type FirebaseAuth = typeof FirebaseAuthNamespace;
|
|
6
|
-
export type oAuthProvider = 'google.com' | 'facebook.com' | 'github.com' | 'twitter.com' | 'microsoft.com' | 'apple.com';
|
|
7
|
-
export type anonymousProvider = 'anonymous';
|
|
8
|
-
export type customTokenProvider = 'customToken';
|
|
9
|
-
export type emailLinkProvider = 'emailLink';
|
|
10
|
-
interface Options {
|
|
11
|
-
providerId?: anonymousProvider | customTokenProvider | emailLinkProvider | oAuthProvider;
|
|
12
|
-
email?: string;
|
|
13
|
-
emailLink?: string;
|
|
14
|
-
customToken?: string;
|
|
15
|
-
password?: string;
|
|
16
|
-
scopes?: string[];
|
|
17
|
-
customParameters?: CustomParameters;
|
|
18
|
-
}
|
|
19
|
-
export declare function createAuth(firebaseClient: FirebaseClient, customProviderHooks?: {
|
|
20
|
-
useCurrentUser?: () => Promise<CurrentUser>;
|
|
21
|
-
useHasRole?: (currentUser: CurrentUser | null) => (rolesToCheck: string | string[]) => boolean;
|
|
22
|
-
}): {
|
|
23
|
-
AuthContext: import("react").Context<import("@cedarjs/auth").AuthContextInterface<User, "google.com" | "facebook.com" | "github.com" | "twitter.com" | "microsoft.com" | "apple.com" | Options, FirebaseAuthNamespace.UserCredential | undefined, unknown, void, "google.com" | "facebook.com" | "github.com" | "twitter.com" | "microsoft.com" | "apple.com" | Options, FirebaseAuthNamespace.UserCredential | undefined, unknown, unknown, unknown, unknown, FirebaseAuthNamespace.Auth> | undefined>;
|
|
24
|
-
AuthProvider: ({ children }: import("@cedarjs/auth").AuthProviderProps) => import("react").JSX.Element;
|
|
25
|
-
useAuth: () => import("@cedarjs/auth").AuthContextInterface<User, "google.com" | "facebook.com" | "github.com" | "twitter.com" | "microsoft.com" | "apple.com" | Options, FirebaseAuthNamespace.UserCredential | undefined, unknown, void, "google.com" | "facebook.com" | "github.com" | "twitter.com" | "microsoft.com" | "apple.com" | Options, FirebaseAuthNamespace.UserCredential | undefined, unknown, unknown, unknown, unknown, FirebaseAuthNamespace.Auth>;
|
|
26
|
-
};
|
|
27
|
-
export interface FirebaseClient {
|
|
28
|
-
firebaseAuth: FirebaseAuth;
|
|
29
|
-
firebaseApp?: FirebaseApp;
|
|
30
|
-
}
|
|
31
|
-
export {};
|
|
32
|
-
//# sourceMappingURL=firebase.d.ts.map
|
|
@@ -1 +0,0 @@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EAAE,YAAY,CAAA;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B"}
|
package/dist/cjs/firebase.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
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 firebase_exports = {};
|
|
20
|
-
__export(firebase_exports, {
|
|
21
|
-
createAuth: () => createAuth
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(firebase_exports);
|
|
24
|
-
var import_auth = require("@cedarjs/auth");
|
|
25
|
-
const hasPasswordCredentials = (options) => {
|
|
26
|
-
return options.email !== void 0 && options.password !== void 0;
|
|
27
|
-
};
|
|
28
|
-
const isEmailLinkOptions = (options) => {
|
|
29
|
-
return options.providerId === "emailLink" && options.email !== void 0 && options.emailLink !== void 0;
|
|
30
|
-
};
|
|
31
|
-
const applyProviderOptions = (provider, options) => {
|
|
32
|
-
if (options.customParameters) {
|
|
33
|
-
provider.setCustomParameters(options.customParameters);
|
|
34
|
-
}
|
|
35
|
-
if (options.scopes) {
|
|
36
|
-
options.scopes.forEach((scope) => provider.addScope(scope));
|
|
37
|
-
}
|
|
38
|
-
return provider;
|
|
39
|
-
};
|
|
40
|
-
function createAuth(firebaseClient, customProviderHooks) {
|
|
41
|
-
const authImplementation = createAuthImplementation(firebaseClient);
|
|
42
|
-
return (0, import_auth.createAuthentication)(authImplementation, customProviderHooks);
|
|
43
|
-
}
|
|
44
|
-
function createAuthImplementation({
|
|
45
|
-
firebaseAuth,
|
|
46
|
-
firebaseApp
|
|
47
|
-
}) {
|
|
48
|
-
const auth = firebaseAuth.getAuth(firebaseApp);
|
|
49
|
-
function getProvider(providerId) {
|
|
50
|
-
return new firebaseAuth.OAuthProvider(providerId);
|
|
51
|
-
}
|
|
52
|
-
const loginWithEmailLink = ({ email, emailLink }) => {
|
|
53
|
-
if (firebaseAuth.isSignInWithEmailLink(auth, emailLink)) {
|
|
54
|
-
return firebaseAuth.signInWithEmailLink(auth, email, emailLink);
|
|
55
|
-
}
|
|
56
|
-
return void 0;
|
|
57
|
-
};
|
|
58
|
-
return {
|
|
59
|
-
type: "firebase",
|
|
60
|
-
// TODO: Should we change this to { firebaseAuth, firebaseApp } to match
|
|
61
|
-
// what's created in the user's RW App?
|
|
62
|
-
client: auth,
|
|
63
|
-
restoreAuthState: () => {
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
const unsubscribe = auth.onAuthStateChanged((user) => {
|
|
66
|
-
unsubscribe();
|
|
67
|
-
resolve(user);
|
|
68
|
-
}, reject);
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
login: async (options = { providerId: "google.com" }) => {
|
|
72
|
-
if (typeof options === "string") {
|
|
73
|
-
options = { providerId: options };
|
|
74
|
-
}
|
|
75
|
-
if (hasPasswordCredentials(options)) {
|
|
76
|
-
return firebaseAuth.signInWithEmailAndPassword(
|
|
77
|
-
auth,
|
|
78
|
-
options.email,
|
|
79
|
-
options.password
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
if (isEmailLinkOptions(options)) {
|
|
83
|
-
return loginWithEmailLink(options);
|
|
84
|
-
}
|
|
85
|
-
if (options.providerId === "anonymous") {
|
|
86
|
-
return firebaseAuth.signInAnonymously(auth);
|
|
87
|
-
}
|
|
88
|
-
if (options.providerId === "customToken" && options.customToken) {
|
|
89
|
-
return firebaseAuth.signInWithCustomToken(auth, options.customToken);
|
|
90
|
-
}
|
|
91
|
-
const provider = getProvider(options.providerId || "google.com");
|
|
92
|
-
const providerWithOptions = applyProviderOptions(provider, options);
|
|
93
|
-
return firebaseAuth.signInWithPopup(auth, providerWithOptions);
|
|
94
|
-
},
|
|
95
|
-
logout: () => auth.signOut(),
|
|
96
|
-
signup: async (options = { providerId: "google.com" }) => {
|
|
97
|
-
if (typeof options === "string") {
|
|
98
|
-
options = { providerId: options };
|
|
99
|
-
}
|
|
100
|
-
if (hasPasswordCredentials(options)) {
|
|
101
|
-
return firebaseAuth.createUserWithEmailAndPassword(
|
|
102
|
-
auth,
|
|
103
|
-
options.email,
|
|
104
|
-
options.password
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
if (isEmailLinkOptions(options)) {
|
|
108
|
-
return loginWithEmailLink(options);
|
|
109
|
-
}
|
|
110
|
-
if (options.providerId === "anonymous") {
|
|
111
|
-
return firebaseAuth.signInAnonymously(auth);
|
|
112
|
-
}
|
|
113
|
-
if (options.providerId === "customToken" && options.customToken) {
|
|
114
|
-
return firebaseAuth.signInWithCustomToken(auth, options.customToken);
|
|
115
|
-
}
|
|
116
|
-
const provider = getProvider(options.providerId || "google.com");
|
|
117
|
-
const providerWithOptions = applyProviderOptions(provider, options);
|
|
118
|
-
return firebaseAuth.signInWithPopup(auth, providerWithOptions);
|
|
119
|
-
},
|
|
120
|
-
getToken: async () => {
|
|
121
|
-
return auth.currentUser ? auth.currentUser.getIdToken() : null;
|
|
122
|
-
},
|
|
123
|
-
getUserMetadata: async () => {
|
|
124
|
-
return auth.currentUser;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
-
0 && (module.exports = {
|
|
130
|
-
createAuth
|
|
131
|
-
});
|
package/dist/cjs/index.d.ts
DELETED
package/dist/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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_firebase.createAuth
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(index_exports);
|
|
24
|
-
var import_firebase = require("./firebase.js");
|
|
25
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
-
0 && (module.exports = {
|
|
27
|
-
createAuth
|
|
28
|
-
});
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|