@tern-secure/nextjs 3.0.8 → 3.1.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/dist/app-router/client/auth.d.ts +1 -0
- package/dist/app-router/client/auth.d.ts.map +1 -0
- package/dist/app-router/client/client-init.d.ts +1 -0
- package/dist/app-router/client/client-init.d.ts.map +1 -0
- package/dist/app-router/client/config.d.ts +1 -0
- package/dist/app-router/client/config.d.ts.map +1 -0
- package/dist/app-router/client/index.d.ts +1 -0
- package/dist/app-router/client/index.d.ts.map +1 -0
- package/dist/app-router/client/providers/ternSecureClientProvider.d.ts +3 -4
- package/dist/app-router/client/providers/ternSecureClientProvider.d.ts.map +1 -0
- package/dist/app-router/client/providers/ternSecureContext.d.ts +3 -2
- package/dist/app-router/client/providers/ternSecureContext.d.ts.map +1 -0
- package/dist/app-router/server/index.d.ts +1 -0
- package/dist/app-router/server/index.d.ts.map +1 -0
- package/dist/app-router/server/providers/TernSecureServerProvider.d.ts +1 -0
- package/dist/app-router/server/providers/TernSecureServerProvider.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/sign-in.d.ts +1 -0
- package/dist/components/sign-in.d.ts.map +1 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useAuth.d.ts +1 -0
- package/dist/hooks/useAuth.d.ts.map +1 -0
- package/dist/index.cjs.js +491 -2
- package/dist/index.cjs.js.map +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +449 -1
- package/dist/index.js.map +7 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/create-styles.d.ts +1 -0
- package/dist/utils/create-styles.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/app-router/client/index.js +0 -1
- package/dist/app-router/server/index.js +0 -1
- package/dist/chunk-2ENCFXUN.js +0 -1
- package/dist/chunk-2NA7K5TN.js +0 -2
- package/dist/chunk-64G22XTD.js +0 -1
- package/dist/chunk-ASFHFC2I.js +0 -1
- package/dist/chunk-DLMCL4UP.js +0 -1
- package/dist/chunk-LHW3RBUN.js +0 -1
- package/dist/components/index.js +0 -1
- package/dist/hooks/index.js +0 -1
- package/dist/ternSecureClientProvider-IGH5T42M.js +0 -1
- package/dist/types/index.js +0 -0
- package/dist/utils/create-styles.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/app-router/client/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAE/E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,wBAAsB,eAAe,CAAC,EACpC,KAAK,EACL,QAAQ,EACT,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAG7C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const TernSecureAuth: () => import("@firebase/auth").Auth;
|
|
2
2
|
export declare const TernSecureFirestore: () => import("@firebase/firestore").Firestore;
|
|
3
3
|
export declare const TernSecureStorage: () => import("@firebase/storage").FirebaseStorage;
|
|
4
|
+
//# sourceMappingURL=client-init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-init.d.ts","sourceRoot":"","sources":["../../../src/app-router/client/client-init.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,cAAc,qCAAa,CAAC;AACzC,eAAO,MAAM,mBAAmB,+CAAkB,CAAC;AACnD,eAAO,MAAM,iBAAiB,mDAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/app-router/client/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,cAAc,QAAO,gBAQhC,CAAC;AAEH,eAAO,MAAM,cAAc,WAAY,gBAAgB,qBAOtD,CAAC"}
|
|
@@ -4,3 +4,4 @@ export { signInWithEmail } from './auth';
|
|
|
4
4
|
export { loadFireConfig, validateConfig } from './config';
|
|
5
5
|
export { TernSecureContext, useTernSecure } from './providers/ternSecureContext';
|
|
6
6
|
export { TernSecureClientProvider } from './providers/ternSecureClientProvider';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app-router/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAC,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
export declare function TernSecureClientProvider({ children }: {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export {};
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
//# sourceMappingURL=ternSecureClientProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternSecureClientProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureClientProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAGvC,wBAAgB,wBAAwB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAQnF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TernSecureState } from '../../../types';
|
|
3
|
+
declare const initialState: TernSecureState;
|
|
3
4
|
declare const TernSecureContext: React.Context<[TernSecureState, React.Dispatch<React.SetStateAction<TernSecureState>>]>;
|
|
4
5
|
declare const useTernSecure: (hookname?: string) => [TernSecureState, React.Dispatch<React.SetStateAction<TernSecureState>>];
|
|
5
|
-
export
|
|
6
|
-
|
|
6
|
+
export { TernSecureContext, useTernSecure, initialState };
|
|
7
|
+
//# sourceMappingURL=ternSecureContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternSecureContext.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/providers/ternSecureContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD,QAAA,MAAM,YAAY,EAAE,eAWnB,CAAA;AAED,QAAA,MAAM,iBAAiB,yFAA0H,CAAA;AAEjJ,QAAA,MAAM,aAAa,cAAe,MAAM,6EAOvC,CAAA;AAED,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,YAAY,EACb,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app-router/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -4,3 +4,4 @@ interface TernSecureProviderProps {
|
|
|
4
4
|
}
|
|
5
5
|
export declare function TernSecureProvider({ children }: TernSecureProviderProps): import("react/jsx-runtime").JSX.Element | (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>)[] | null | undefined;
|
|
6
6
|
export {};
|
|
7
|
+
//# sourceMappingURL=TernSecureServerProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TernSecureServerProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/server/providers/TernSecureServerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzC,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAWD,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE,uBAAuB,qLA+BvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in.d.ts","sourceRoot":"","sources":["../../src/components/sign-in.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,YAAY,CAAC,EAAE;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AAED,wBAAgB,MAAM,CAAC,EACrB,SAAS,EACT,OAAO,EACP,WAAW,EACX,SAAc,EACd,KAAK,EACL,YAAiB,EAClB,EAAE,WAAW,2CAmGb"}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;sCAGU,MAAM;CACvB,CAAC;AAEX,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA"}
|
package/dist/hooks/useAuth.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAMA,wBAAgB,OAAO,iCA0DtB"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,2 +1,491 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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 __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// src/app-router/client/providers/ternSecureContext.tsx
|
|
34
|
+
var import_react, initialState, TernSecureContext, useTernSecure;
|
|
35
|
+
var init_ternSecureContext = __esm({
|
|
36
|
+
"src/app-router/client/providers/ternSecureContext.tsx"() {
|
|
37
|
+
"use strict";
|
|
38
|
+
"use client";
|
|
39
|
+
import_react = __toESM(require("react"), 1);
|
|
40
|
+
initialState = {
|
|
41
|
+
firebase: {
|
|
42
|
+
initialized: false,
|
|
43
|
+
error: null
|
|
44
|
+
},
|
|
45
|
+
auth: {
|
|
46
|
+
user: null,
|
|
47
|
+
loading: true,
|
|
48
|
+
error: null,
|
|
49
|
+
isSignedIn: false
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
TernSecureContext = import_react.default.createContext([initialState, () => {
|
|
53
|
+
}]);
|
|
54
|
+
useTernSecure = (hookname) => {
|
|
55
|
+
const context = import_react.default.useContext(TernSecureContext);
|
|
56
|
+
if (!context) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`${hookname} must be used within TernSecureProvider`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return context;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// src/app-router/client/providers/ternSecureClientProvider.tsx
|
|
67
|
+
var ternSecureClientProvider_exports = {};
|
|
68
|
+
__export(ternSecureClientProvider_exports, {
|
|
69
|
+
TernSecureClientProvider: () => TernSecureClientProvider
|
|
70
|
+
});
|
|
71
|
+
function TernSecureClientProvider({ children }) {
|
|
72
|
+
const stateAndUpdater = (0, import_react2.useState)(initialState);
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TernSecureContext.Provider, { value: stateAndUpdater, children });
|
|
74
|
+
}
|
|
75
|
+
var import_react2, import_jsx_runtime;
|
|
76
|
+
var init_ternSecureClientProvider = __esm({
|
|
77
|
+
"src/app-router/client/providers/ternSecureClientProvider.tsx"() {
|
|
78
|
+
"use strict";
|
|
79
|
+
"use client";
|
|
80
|
+
import_react2 = require("react");
|
|
81
|
+
init_ternSecureContext();
|
|
82
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// src/index.ts
|
|
87
|
+
var src_exports = {};
|
|
88
|
+
__export(src_exports, {
|
|
89
|
+
SignIn: () => SignIn,
|
|
90
|
+
TernSecureAuth: () => TernSecureAuth,
|
|
91
|
+
TernSecureClientProvider: () => TernSecureClientProvider,
|
|
92
|
+
TernSecureContext: () => TernSecureContext,
|
|
93
|
+
TernSecureFirestore: () => TernSecureFirestore,
|
|
94
|
+
TernSecureProvider: () => TernSecureProvider,
|
|
95
|
+
TernSecureStorage: () => TernSecureStorage,
|
|
96
|
+
loadFireConfig: () => loadFireConfig,
|
|
97
|
+
signInWithEmail: () => signInWithEmail,
|
|
98
|
+
useAuth: () => useAuth,
|
|
99
|
+
useTernSecure: () => useTernSecure,
|
|
100
|
+
validateConfig: () => validateConfig
|
|
101
|
+
});
|
|
102
|
+
module.exports = __toCommonJS(src_exports);
|
|
103
|
+
|
|
104
|
+
// src/app-router/client/client-init.ts
|
|
105
|
+
var import_app = require("firebase/app");
|
|
106
|
+
var import_auth = require("firebase/auth");
|
|
107
|
+
var import_firestore = require("firebase/firestore");
|
|
108
|
+
var import_storage = require("firebase/storage");
|
|
109
|
+
var app = (() => {
|
|
110
|
+
const config = validateConfig(loadFireConfig());
|
|
111
|
+
return (0, import_app.getApps)().length ? (0, import_app.getApps)()[0] : (0, import_app.initializeApp)(config);
|
|
112
|
+
})();
|
|
113
|
+
var auth = (0, import_auth.getAuth)(app);
|
|
114
|
+
(0, import_auth.setPersistence)(auth, import_auth.browserSessionPersistence);
|
|
115
|
+
var firestore = (0, import_firestore.getFirestore)(app);
|
|
116
|
+
var storage = (0, import_storage.getStorage)(app);
|
|
117
|
+
var TernSecureAuth = () => auth;
|
|
118
|
+
var TernSecureFirestore = () => firestore;
|
|
119
|
+
var TernSecureStorage = () => storage;
|
|
120
|
+
|
|
121
|
+
// src/app-router/client/auth.ts
|
|
122
|
+
var import_auth2 = require("firebase/auth");
|
|
123
|
+
async function signInWithEmail({
|
|
124
|
+
email,
|
|
125
|
+
password
|
|
126
|
+
}) {
|
|
127
|
+
const auth2 = TernSecureAuth();
|
|
128
|
+
return (0, import_auth2.signInWithEmailAndPassword)(auth2, email, password);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/app-router/client/config.ts
|
|
132
|
+
var loadFireConfig = () => ({
|
|
133
|
+
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
|
|
134
|
+
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
|
|
135
|
+
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
|
136
|
+
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
|
|
137
|
+
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
|
|
138
|
+
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
|
|
139
|
+
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
|
|
140
|
+
});
|
|
141
|
+
var validateConfig = (config) => {
|
|
142
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
143
|
+
if (!value) {
|
|
144
|
+
throw new Error(`Missing environment variable: NEXT_PUBLIC_FIREBASE_${key.toUpperCase()}`);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return config;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// src/app-router/client/index.ts
|
|
151
|
+
init_ternSecureContext();
|
|
152
|
+
init_ternSecureClientProvider();
|
|
153
|
+
|
|
154
|
+
// src/app-router/server/providers/TernSecureServerProvider.tsx
|
|
155
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
156
|
+
var import_dynamic = __toESM(require("next/dynamic"), 1);
|
|
157
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
158
|
+
var TernSecureClientProvider2 = (0, import_dynamic.default)(
|
|
159
|
+
() => Promise.resolve().then(() => (init_ternSecureClientProvider(), ternSecureClientProvider_exports)).then((mod) => mod.TernSecureClientProvider),
|
|
160
|
+
{
|
|
161
|
+
//ssr: false,
|
|
162
|
+
loading: () => null
|
|
163
|
+
// Return null or a loading indicator
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
function TernSecureProvider({ children }) {
|
|
167
|
+
const isRootLayout = import_react3.default.Children.toArray(children).some(
|
|
168
|
+
(child) => import_react3.default.isValidElement(child) && child.type === "html"
|
|
169
|
+
);
|
|
170
|
+
if (isRootLayout) {
|
|
171
|
+
return import_react3.default.Children.map(children, (child) => {
|
|
172
|
+
if (import_react3.default.isValidElement(child) && child.type === "html") {
|
|
173
|
+
return import_react3.default.cloneElement(
|
|
174
|
+
child,
|
|
175
|
+
{},
|
|
176
|
+
import_react3.default.Children.map(child.props.children, (bodyChild) => {
|
|
177
|
+
if (import_react3.default.isValidElement(bodyChild) && bodyChild.type === "body") {
|
|
178
|
+
const bodyProps = bodyChild.props;
|
|
179
|
+
return import_react3.default.cloneElement(
|
|
180
|
+
bodyChild,
|
|
181
|
+
{},
|
|
182
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TernSecureClientProvider2, { children: bodyProps.children })
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
return bodyChild;
|
|
186
|
+
})
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return child;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TernSecureClientProvider2, { children });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// src/hooks/useAuth.ts
|
|
196
|
+
var import_react4 = require("react");
|
|
197
|
+
function useAuth() {
|
|
198
|
+
const [state, setState] = useTernSecure("useAuth");
|
|
199
|
+
(0, import_react4.useEffect)(() => {
|
|
200
|
+
try {
|
|
201
|
+
const auth2 = TernSecureAuth();
|
|
202
|
+
setState((prev) => ({
|
|
203
|
+
...prev,
|
|
204
|
+
firebase: {
|
|
205
|
+
initialized: true,
|
|
206
|
+
error: null
|
|
207
|
+
}
|
|
208
|
+
}));
|
|
209
|
+
const unsubscribe = auth2.onAuthStateChanged(
|
|
210
|
+
(user) => {
|
|
211
|
+
setState((prev) => ({
|
|
212
|
+
...prev,
|
|
213
|
+
auth: {
|
|
214
|
+
user,
|
|
215
|
+
loading: false,
|
|
216
|
+
error: null,
|
|
217
|
+
isSignedIn: !!user
|
|
218
|
+
}
|
|
219
|
+
}));
|
|
220
|
+
},
|
|
221
|
+
(error) => {
|
|
222
|
+
setState((prev) => ({
|
|
223
|
+
...prev,
|
|
224
|
+
auth: {
|
|
225
|
+
user: null,
|
|
226
|
+
loading: false,
|
|
227
|
+
error,
|
|
228
|
+
isSignedIn: false
|
|
229
|
+
}
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
return () => unsubscribe();
|
|
234
|
+
} catch (error) {
|
|
235
|
+
setState((prev) => ({
|
|
236
|
+
...prev,
|
|
237
|
+
firebase: {
|
|
238
|
+
initialized: false,
|
|
239
|
+
error
|
|
240
|
+
},
|
|
241
|
+
auth: {
|
|
242
|
+
user: null,
|
|
243
|
+
loading: false,
|
|
244
|
+
error,
|
|
245
|
+
isSignedIn: false
|
|
246
|
+
}
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
}, []);
|
|
250
|
+
return state.auth;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/components/sign-in.tsx
|
|
254
|
+
var import_react5 = require("react");
|
|
255
|
+
|
|
256
|
+
// src/utils/create-styles.ts
|
|
257
|
+
var PREFIX = "tern";
|
|
258
|
+
var styleInjection = {
|
|
259
|
+
isInjected: false,
|
|
260
|
+
styleElement: null
|
|
261
|
+
};
|
|
262
|
+
var defaultClassNames = {
|
|
263
|
+
container: `${PREFIX}-container`,
|
|
264
|
+
header: `${PREFIX}-header`,
|
|
265
|
+
title: `${PREFIX}-title`,
|
|
266
|
+
formWrapper: `${PREFIX}-formWrapper`,
|
|
267
|
+
formContainer: `${PREFIX}-formContainer`,
|
|
268
|
+
form: `${PREFIX}-form`,
|
|
269
|
+
label: `${PREFIX}-label`,
|
|
270
|
+
input: `${PREFIX}-input`,
|
|
271
|
+
button: `${PREFIX}-button`,
|
|
272
|
+
error: `${PREFIX}-error`
|
|
273
|
+
};
|
|
274
|
+
function createStyleSheet(styles2) {
|
|
275
|
+
if (typeof window === "undefined") return defaultClassNames;
|
|
276
|
+
if (styleInjection.isInjected) {
|
|
277
|
+
return defaultClassNames;
|
|
278
|
+
}
|
|
279
|
+
let styleElement = document.querySelector("[data-tern-secure]");
|
|
280
|
+
if (!styleElement) {
|
|
281
|
+
styleElement = document.createElement("style");
|
|
282
|
+
styleElement.setAttribute("data-tern-secure", "");
|
|
283
|
+
document.head.appendChild(styleElement);
|
|
284
|
+
styleInjection.styleElement = styleElement;
|
|
285
|
+
}
|
|
286
|
+
const cssRules = Object.entries(styles2).map(([key, rules]) => {
|
|
287
|
+
const className = defaultClassNames[key];
|
|
288
|
+
const cssProperties = Object.entries(rules).map(([prop, value]) => {
|
|
289
|
+
const cssProperty = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
290
|
+
return `${cssProperty}: ${value};`;
|
|
291
|
+
}).join(" ");
|
|
292
|
+
return `.${className} { ${cssProperties} }`;
|
|
293
|
+
}).join("\n");
|
|
294
|
+
styleElement.textContent = cssRules;
|
|
295
|
+
styleInjection.isInjected = true;
|
|
296
|
+
return defaultClassNames;
|
|
297
|
+
}
|
|
298
|
+
var styleConfig = {
|
|
299
|
+
container: {
|
|
300
|
+
display: "flex",
|
|
301
|
+
minHeight: "100%",
|
|
302
|
+
flex: "1",
|
|
303
|
+
flexDirection: "column",
|
|
304
|
+
justifyContent: "center",
|
|
305
|
+
padding: "3rem 1.5rem"
|
|
306
|
+
},
|
|
307
|
+
header: {
|
|
308
|
+
margin: "0 auto",
|
|
309
|
+
width: "100%",
|
|
310
|
+
maxWidth: "28rem"
|
|
311
|
+
},
|
|
312
|
+
title: {
|
|
313
|
+
marginTop: "1.5rem",
|
|
314
|
+
textAlign: "center",
|
|
315
|
+
fontSize: "1.875rem",
|
|
316
|
+
fontWeight: "700",
|
|
317
|
+
lineHeight: "2.25rem",
|
|
318
|
+
letterSpacing: "-0.025em",
|
|
319
|
+
color: "var(--tern-text-primary, #111827)"
|
|
320
|
+
},
|
|
321
|
+
formWrapper: {
|
|
322
|
+
marginTop: "2.5rem",
|
|
323
|
+
margin: "0 auto",
|
|
324
|
+
width: "100%",
|
|
325
|
+
maxWidth: "30rem"
|
|
326
|
+
},
|
|
327
|
+
formContainer: {
|
|
328
|
+
padding: "3rem 1.5rem",
|
|
329
|
+
boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1)",
|
|
330
|
+
borderRadius: "0.5rem",
|
|
331
|
+
backgroundColor: "var(--tern-background, white)"
|
|
332
|
+
},
|
|
333
|
+
form: {
|
|
334
|
+
display: "flex",
|
|
335
|
+
flexDirection: "column",
|
|
336
|
+
gap: "1rem"
|
|
337
|
+
},
|
|
338
|
+
label: {
|
|
339
|
+
display: "block",
|
|
340
|
+
fontSize: "0.875rem",
|
|
341
|
+
fontWeight: "500",
|
|
342
|
+
color: "var(--tern-text-secondary, #374151)"
|
|
343
|
+
},
|
|
344
|
+
input: {
|
|
345
|
+
marginTop: "0.25rem",
|
|
346
|
+
display: "block",
|
|
347
|
+
width: "100%",
|
|
348
|
+
padding: "0.5rem 0.75rem",
|
|
349
|
+
borderRadius: "0.375rem",
|
|
350
|
+
border: "1px solid var(--tern-border, #D1D5DB)",
|
|
351
|
+
backgroundColor: "var(--tern-input-background, white)",
|
|
352
|
+
color: "var(--tern-text-primary, #111827)"
|
|
353
|
+
},
|
|
354
|
+
button: {
|
|
355
|
+
display: "flex",
|
|
356
|
+
width: "100%",
|
|
357
|
+
justifyContent: "center",
|
|
358
|
+
padding: "0.5rem 1rem",
|
|
359
|
+
fontSize: "0.875rem",
|
|
360
|
+
fontWeight: "500",
|
|
361
|
+
color: "white",
|
|
362
|
+
backgroundColor: "var(--tern-primary, #2563EB)",
|
|
363
|
+
border: "none",
|
|
364
|
+
borderRadius: "0.375rem",
|
|
365
|
+
cursor: "pointer"
|
|
366
|
+
},
|
|
367
|
+
error: {
|
|
368
|
+
color: "var(--tern-error, #DC2626)",
|
|
369
|
+
fontSize: "0.875rem"
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
var styles = createStyleSheet(styleConfig);
|
|
373
|
+
|
|
374
|
+
// src/components/sign-in.tsx
|
|
375
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
376
|
+
function SignIn({
|
|
377
|
+
onSuccess,
|
|
378
|
+
onError,
|
|
379
|
+
redirectUrl,
|
|
380
|
+
className = "",
|
|
381
|
+
style,
|
|
382
|
+
customStyles = {}
|
|
383
|
+
}) {
|
|
384
|
+
const [email, setEmail] = (0, import_react5.useState)("");
|
|
385
|
+
const [password, setPassword] = (0, import_react5.useState)("");
|
|
386
|
+
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
387
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
388
|
+
const handleSubmit = async (e) => {
|
|
389
|
+
e.preventDefault();
|
|
390
|
+
setLoading(true);
|
|
391
|
+
setError("");
|
|
392
|
+
try {
|
|
393
|
+
await signInWithEmail({ email, password });
|
|
394
|
+
onSuccess?.();
|
|
395
|
+
if (redirectUrl) {
|
|
396
|
+
window.location.href = redirectUrl;
|
|
397
|
+
}
|
|
398
|
+
} catch (err) {
|
|
399
|
+
const errorMessage = err instanceof Error ? err.message : "Failed to sign in";
|
|
400
|
+
setError(errorMessage);
|
|
401
|
+
onError?.(err instanceof Error ? err : new Error("Failed to sign in"));
|
|
402
|
+
} finally {
|
|
403
|
+
setLoading(false);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `${styles.container} ${customStyles.container || ""}`, style, children: [
|
|
407
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${styles.header} ${customStyles.header || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { className: `${styles.title} ${customStyles.title || ""}`, children: "Sign in to your account" }) }),
|
|
408
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${styles.formWrapper} ${customStyles.formWrapper || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${styles.formContainer} ${customStyles.formContainer || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
409
|
+
"form",
|
|
410
|
+
{
|
|
411
|
+
onSubmit: handleSubmit,
|
|
412
|
+
className: `${styles.form} ${customStyles.form || ""} ${className}`,
|
|
413
|
+
role: "form",
|
|
414
|
+
"aria-label": "Sign in form",
|
|
415
|
+
children: [
|
|
416
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
417
|
+
"div",
|
|
418
|
+
{
|
|
419
|
+
className: `${styles.error} ${customStyles.errorText || ""}`,
|
|
420
|
+
role: "alert",
|
|
421
|
+
"aria-live": "polite",
|
|
422
|
+
children: error
|
|
423
|
+
}
|
|
424
|
+
),
|
|
425
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
426
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { htmlFor: "email", className: `${styles.label} ${customStyles.label || ""}`, children: "Email" }),
|
|
427
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
428
|
+
"input",
|
|
429
|
+
{
|
|
430
|
+
id: "email",
|
|
431
|
+
type: "email",
|
|
432
|
+
value: email,
|
|
433
|
+
onChange: (e) => setEmail(e.target.value),
|
|
434
|
+
placeholder: "Enter your email",
|
|
435
|
+
required: true,
|
|
436
|
+
className: `${styles.input} ${customStyles.input || ""}`,
|
|
437
|
+
disabled: loading,
|
|
438
|
+
"aria-required": "true",
|
|
439
|
+
"aria-invalid": !!error
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
] }),
|
|
443
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
444
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { htmlFor: "password", className: `${styles.label} ${customStyles.label || ""}`, children: "Password" }),
|
|
445
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
446
|
+
"input",
|
|
447
|
+
{
|
|
448
|
+
id: "password",
|
|
449
|
+
type: "password",
|
|
450
|
+
value: password,
|
|
451
|
+
onChange: (e) => setPassword(e.target.value),
|
|
452
|
+
placeholder: "Enter your password",
|
|
453
|
+
required: true,
|
|
454
|
+
className: `${styles.input} ${customStyles.input || ""}`,
|
|
455
|
+
disabled: loading,
|
|
456
|
+
"aria-required": "true",
|
|
457
|
+
"aria-invalid": !!error
|
|
458
|
+
}
|
|
459
|
+
)
|
|
460
|
+
] }),
|
|
461
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
462
|
+
"button",
|
|
463
|
+
{
|
|
464
|
+
type: "submit",
|
|
465
|
+
disabled: loading,
|
|
466
|
+
className: `${styles.button} ${customStyles.button || ""}`,
|
|
467
|
+
"data-testid": "sign-in-submit",
|
|
468
|
+
children: loading ? "Signing in..." : "Sign in"
|
|
469
|
+
}
|
|
470
|
+
)
|
|
471
|
+
]
|
|
472
|
+
}
|
|
473
|
+
) }) })
|
|
474
|
+
] });
|
|
475
|
+
}
|
|
476
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
477
|
+
0 && (module.exports = {
|
|
478
|
+
SignIn,
|
|
479
|
+
TernSecureAuth,
|
|
480
|
+
TernSecureClientProvider,
|
|
481
|
+
TernSecureContext,
|
|
482
|
+
TernSecureFirestore,
|
|
483
|
+
TernSecureProvider,
|
|
484
|
+
TernSecureStorage,
|
|
485
|
+
loadFireConfig,
|
|
486
|
+
signInWithEmail,
|
|
487
|
+
useAuth,
|
|
488
|
+
useTernSecure,
|
|
489
|
+
validateConfig
|
|
490
|
+
});
|
|
491
|
+
//# sourceMappingURL=index.cjs.js.map
|