@tern-secure/auth 1.0.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/cjs/global.d.js +2 -0
- package/dist/cjs/global.d.js.map +1 -0
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/instance/TernAuth.js +471 -0
- package/dist/cjs/instance/TernAuth.js.map +1 -0
- package/dist/cjs/instance/TernAuthServer.js +95 -0
- package/dist/cjs/instance/TernAuthServer.js.map +1 -0
- package/dist/cjs/instance/coreApiClient.example.js +96 -0
- package/dist/cjs/instance/coreApiClient.example.js.map +1 -0
- package/dist/cjs/instance/coreApiClient.js +255 -0
- package/dist/cjs/instance/coreApiClient.js.map +1 -0
- package/dist/cjs/instance/events.js +38 -0
- package/dist/cjs/instance/events.js.map +1 -0
- package/dist/cjs/resources/AuthCookieManager.js +89 -0
- package/dist/cjs/resources/AuthCookieManager.js.map +1 -0
- package/dist/cjs/resources/Base.js +125 -0
- package/dist/cjs/resources/Base.js.map +1 -0
- package/dist/cjs/resources/Error.js +31 -0
- package/dist/cjs/resources/Error.js.map +1 -0
- package/dist/cjs/resources/SignIn.js +224 -0
- package/dist/cjs/resources/SignIn.js.map +1 -0
- package/dist/cjs/resources/SignUp.js +43 -0
- package/dist/cjs/resources/SignUp.js.map +1 -0
- package/dist/cjs/resources/index.js +23 -0
- package/dist/cjs/resources/index.js.map +1 -0
- package/dist/cjs/resources/internal.js +33 -0
- package/dist/cjs/resources/internal.js.map +1 -0
- package/dist/cjs/utils/construct.js +174 -0
- package/dist/cjs/utils/construct.js.map +1 -0
- package/dist/cjs/utils/index.js +25 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/querystring.js +70 -0
- package/dist/cjs/utils/querystring.js.map +1 -0
- package/dist/esm/global.d.js +1 -0
- package/dist/esm/global.d.js.map +1 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/instance/TernAuth.js +455 -0
- package/dist/esm/instance/TernAuth.js.map +1 -0
- package/dist/esm/instance/TernAuthServer.js +73 -0
- package/dist/esm/instance/TernAuthServer.js.map +1 -0
- package/dist/esm/instance/coreApiClient.example.js +70 -0
- package/dist/esm/instance/coreApiClient.example.js.map +1 -0
- package/dist/esm/instance/coreApiClient.js +226 -0
- package/dist/esm/instance/coreApiClient.js.map +1 -0
- package/dist/esm/instance/events.js +13 -0
- package/dist/esm/instance/events.js.map +1 -0
- package/dist/esm/resources/AuthCookieManager.js +67 -0
- package/dist/esm/resources/AuthCookieManager.js.map +1 -0
- package/dist/esm/resources/Base.js +101 -0
- package/dist/esm/resources/Base.js.map +1 -0
- package/dist/esm/resources/Error.js +9 -0
- package/dist/esm/resources/Error.js.map +1 -0
- package/dist/esm/resources/SignIn.js +208 -0
- package/dist/esm/resources/SignIn.js.map +1 -0
- package/dist/esm/resources/SignUp.js +19 -0
- package/dist/esm/resources/SignUp.js.map +1 -0
- package/dist/esm/resources/index.js +2 -0
- package/dist/esm/resources/index.js.map +1 -0
- package/dist/esm/resources/internal.js +7 -0
- package/dist/esm/resources/internal.js.map +1 -0
- package/dist/esm/utils/construct.js +143 -0
- package/dist/esm/utils/construct.js.map +1 -0
- package/dist/esm/utils/index.js +3 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/querystring.js +45 -0
- package/dist/esm/utils/querystring.js.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/instance/TernAuth.d.ts +62 -0
- package/dist/types/instance/TernAuth.d.ts.map +1 -0
- package/dist/types/instance/TernAuthServer.d.ts +32 -0
- package/dist/types/instance/TernAuthServer.d.ts.map +1 -0
- package/dist/types/instance/coreApiClient.d.ts +65 -0
- package/dist/types/instance/coreApiClient.d.ts.map +1 -0
- package/dist/types/instance/coreApiClient.example.d.ts +8 -0
- package/dist/types/instance/coreApiClient.example.d.ts.map +1 -0
- package/dist/types/instance/events.d.ts +27 -0
- package/dist/types/instance/events.d.ts.map +1 -0
- package/dist/types/resources/AuthCookieManager.d.ts +26 -0
- package/dist/types/resources/AuthCookieManager.d.ts.map +1 -0
- package/dist/types/resources/Base.d.ts +40 -0
- package/dist/types/resources/Base.d.ts.map +1 -0
- package/dist/types/resources/Error.d.ts +2 -0
- package/dist/types/resources/Error.d.ts.map +1 -0
- package/dist/types/resources/SignIn.d.ts +32 -0
- package/dist/types/resources/SignIn.d.ts.map +1 -0
- package/dist/types/resources/SignUp.d.ts +14 -0
- package/dist/types/resources/SignUp.d.ts.map +1 -0
- package/dist/types/resources/index.d.ts +2 -0
- package/dist/types/resources/index.d.ts.map +1 -0
- package/dist/types/resources/internal.d.ts +8 -0
- package/dist/types/resources/internal.d.ts.map +1 -0
- package/dist/types/utils/construct.d.ts +67 -0
- package/dist/types/utils/construct.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/querystring.d.ts +7 -0
- package/dist/types/utils/querystring.d.ts.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/resources/Base.ts"],"sourcesContent":["import { isValidBrowserOnline } from '@tern-secure/shared/browser';\nimport type { TernSecureApiErrorJSON } from '@tern-secure/types';\n\nimport type { ApiRequestInit, ApiResponse, ApiResponseJSON } from '../instance/coreApiClient';\nimport { coreApiClient } from '../instance/coreApiClient';\nimport { TernSecureAPIResponseError } from './Error';\nimport type { AuthCookieManager,TernSecureAuth } from './internal';\n\nexport type HTTPMethod =\n | 'CONNECT'\n | 'DELETE'\n | 'GET'\n | 'HEAD'\n | 'OPTIONS'\n | 'PATCH'\n | 'POST'\n | 'PUT'\n | 'TRACE';\n\nexport type PostMutateParams = {\n action?: string | undefined;\n body?: any;\n method?: HTTPMethod | undefined;\n path?: string;\n};\n\nexport abstract class TernSecureBase {\n static ternsecure: TernSecureAuth;\n\n static get apiUrl() {\n return TernSecureBase.ternsecure.getApiUrl();\n }\n\n static get authCookieManager(): AuthCookieManager | undefined {\n return this.ternsecure.authCookieManager();\n }\n protected get authCookieManager(): AuthCookieManager | undefined {\n return TernSecureBase.authCookieManager;\n }\n\n /**\n * Core method to fetch data from API endpoints using coreApiClient\n * This method handles the complete request lifecycle including error handling\n */\n static async fetchFromCoreApi(requestInit: ApiRequestInit): Promise<ApiResponseJSON<any> | null> {\n if (!TernSecureBase.apiUrl) {\n throw new Error('API URL is not defined. Make sure TernSecureAuth is properly initialized.');\n }\n\n const apiUrl = this.ternsecure.apiUrl;\n\n let apiResponse: ApiResponse<any>;\n try {\n apiResponse = await coreApiClient.request(requestInit, { apiUrl });\n } catch (error) {\n if (!isValidBrowserOnline()) {\n console.warn(error);\n return null;\n }\n throw error;\n }\n\n const { payload, status, statusText, headers } = apiResponse;\n\n if (headers) {\n const country = headers.get('x-country');\n this.ternsecure.__internal_setCountry(country ? country.toLowerCase() : null);\n }\n\n if (status >= 200 && status <= 299) {\n return payload;\n }\n\n if (status >= 400) {\n const errors = payload?.errors as TernSecureApiErrorJSON[];\n const message = errors?.[0]?.message;\n\n const apiResponseOptions: ConstructorParameters<typeof TernSecureAPIResponseError>[1] = {\n data: errors,\n status,\n };\n if (status === 429 && headers) {\n const retryAfter = headers.get('retry-After');\n if (retryAfter) {\n const value = parseInt(retryAfter, 10);\n if (!isNaN(value)) {\n apiResponseOptions.retryAfter = value;\n }\n }\n }\n\n throw new TernSecureAPIResponseError(message || statusText, apiResponseOptions);\n }\n\n return null;\n }\n\n /**\n * Convenience method for making POST requests\n */\n static async basePost(params: PostMutateParams): Promise<ApiResponseJSON<any> | null> {\n return this.fetchFromCoreApi({ ...params, method: 'POST' });\n }\n\n /**\n * Instance method to fetch data from API endpoints\n */\n protected async fetchFromCoreApi(\n requestInit: ApiRequestInit,\n ): Promise<ApiResponseJSON<any> | null> {\n return TernSecureBase.fetchFromCoreApi(requestInit);\n }\n\n /**\n * Instance method for making POST requests\n */\n protected async basePost(params: PostMutateParams): Promise<ApiResponseJSON<any> | null> {\n return TernSecureBase.basePost(params);\n }\n\n /**\n * Protected instance method for making POST requests with specific path and body\n * This is designed to be used by child classes like SignIn\n */\n protected async _post(params: PostMutateParams): Promise<ApiResponseJSON<any> | null> {\n return this.basePost({\n path: params.path,\n body: params.body\n });\n }\n\n static async makeApiRequest(requestInit: ApiRequestInit): Promise<ApiResponseJSON<any> | null> {\n return this.fetchFromCoreApi(requestInit);\n }\n\n protected async makeApiRequest(\n requestInit: ApiRequestInit,\n ): Promise<ApiResponseJSON<any> | null> {\n return this.fetchFromCoreApi(requestInit);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAqC;AAIrC,2BAA8B;AAC9B,mBAA2C;AAqBpC,MAAe,eAAe;AAAA,EACnC,OAAO;AAAA,EAEP,WAAW,SAAS;AAClB,WAAO,eAAe,WAAW,UAAU;AAAA,EAC7C;AAAA,EAEA,WAAW,oBAAmD;AAC5D,WAAO,KAAK,WAAW,kBAAkB;AAAA,EAC3C;AAAA,EACA,IAAc,oBAAmD;AAC/D,WAAO,eAAe;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAa,iBAAiB,aAAmE;AA5CnG;AA6CI,QAAI,CAAC,eAAe,QAAQ;AAC1B,YAAM,IAAI,MAAM,2EAA2E;AAAA,IAC7F;AAEA,UAAM,SAAS,KAAK,WAAW;AAE/B,QAAI;AACJ,QAAI;AACF,oBAAc,MAAM,mCAAc,QAAQ,aAAa,EAAE,OAAO,CAAC;AAAA,IACnE,SAAS,OAAO;AACd,UAAI,KAAC,qCAAqB,GAAG;AAC3B,gBAAQ,KAAK,KAAK;AAClB,eAAO;AAAA,MACT;AACA,YAAM;AAAA,IACR;AAEA,UAAM,EAAE,SAAS,QAAQ,YAAY,QAAQ,IAAI;AAEjD,QAAI,SAAS;AACX,YAAM,UAAU,QAAQ,I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0,0 +1,31 @@
|
|
|
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 Error_exports = {};
|
|
20
|
+
__export(Error_exports, {
|
|
21
|
+
TernSecureAPIResponseError: () => import_errors_api.TernSecureAPIResponseError,
|
|
22
|
+
TernSecureRuntimeError: () => import_errors_api.TernSecureRuntimeError
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Error_exports);
|
|
25
|
+
var import_errors_api = require("@tern-secure/shared/errors-api");
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
TernSecureAPIResponseError,
|
|
29
|
+
TernSecureRuntimeError
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=Error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/resources/Error.ts"],"sourcesContent":["export {\n TernSecureAPIResponseError,\n TernSecureRuntimeError,\n} from \"@tern-secure/shared/errors-api\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAGO;","names":[]}
|
|
@@ -0,0 +1,224 @@
|
|
|
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 SignIn_exports = {};
|
|
20
|
+
__export(SignIn_exports, {
|
|
21
|
+
SignIn: () => SignIn
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(SignIn_exports);
|
|
24
|
+
var import_errors = require("@tern-secure/shared/errors");
|
|
25
|
+
var import_auth = require("firebase/auth");
|
|
26
|
+
var import_Base = require("./Base");
|
|
27
|
+
class SignIn extends import_Base.TernSecureBase {
|
|
28
|
+
pathRoot = "/sessions/createsession";
|
|
29
|
+
status;
|
|
30
|
+
auth;
|
|
31
|
+
csrfToken;
|
|
32
|
+
_currentUser = null;
|
|
33
|
+
constructor(auth, csrfToken) {
|
|
34
|
+
super();
|
|
35
|
+
this.auth = auth;
|
|
36
|
+
this.csrfToken = csrfToken;
|
|
37
|
+
}
|
|
38
|
+
signInWithCredential = async (credential) => {
|
|
39
|
+
const idToken = await credential.user.getIdToken();
|
|
40
|
+
const params = {
|
|
41
|
+
idToken,
|
|
42
|
+
csrfToken: this.csrfToken
|
|
43
|
+
};
|
|
44
|
+
return this._post({
|
|
45
|
+
path: this.pathRoot,
|
|
46
|
+
body: params
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
withEmailAndPassword = async (params) => {
|
|
50
|
+
try {
|
|
51
|
+
const { email, password } = params;
|
|
52
|
+
const userCredential = await (0, import_auth.signInWithEmailAndPassword)(
|
|
53
|
+
this.auth,
|
|
54
|
+
email,
|
|
55
|
+
password
|
|
56
|
+
);
|
|
57
|
+
await this.signInWithCredential(userCredential);
|
|
58
|
+
const { user } = userCredential;
|
|
59
|
+
return {
|
|
60
|
+
success: true,
|
|
61
|
+
message: "Authentication successful",
|
|
62
|
+
user,
|
|
63
|
+
error: !user.emailVerified ? "REQUIRES_VERIFICATION" : "AUTHENTICATED"
|
|
64
|
+
};
|
|
65
|
+
} catch (error) {
|
|
66
|
+
const authError = (0, import_errors.handleFirebaseAuthError)(error);
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
message: authError.message,
|
|
70
|
+
error: authError.code,
|
|
71
|
+
user: null
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
withCredential = async (params) => {
|
|
76
|
+
try {
|
|
77
|
+
const { email, password } = params;
|
|
78
|
+
const userCredential = await (0, import_auth.signInWithEmailAndPassword)(
|
|
79
|
+
this.auth,
|
|
80
|
+
email,
|
|
81
|
+
password
|
|
82
|
+
);
|
|
83
|
+
await this.signInWithCredential(userCredential);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
const authError = (0, import_errors.handleFirebaseAuthError)(error);
|
|
86
|
+
console.error(authError);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
withSocialProvider = async (provider, options) => {
|
|
90
|
+
try {
|
|
91
|
+
if ((options == null ? void 0 : options.mode) === "redirect") {
|
|
92
|
+
const redirectResult = await this.authRedirectResult();
|
|
93
|
+
if (redirectResult) {
|
|
94
|
+
if (redirectResult.success) {
|
|
95
|
+
console.log("Redirect after sign in");
|
|
96
|
+
}
|
|
97
|
+
return redirectResult;
|
|
98
|
+
}
|
|
99
|
+
await this._signInWithRedirect(provider);
|
|
100
|
+
return;
|
|
101
|
+
} else {
|
|
102
|
+
await this._signInWithPopUp(provider);
|
|
103
|
+
return {
|
|
104
|
+
success: true,
|
|
105
|
+
message: "Sign in successful"
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return {
|
|
110
|
+
success: false,
|
|
111
|
+
message: error.message || `Sign in with ${provider} failed`,
|
|
112
|
+
error,
|
|
113
|
+
user: null
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
completeMfaSignIn = async (_mfaToken, _mfaContext) => {
|
|
118
|
+
throw new Error("Method not implemented.");
|
|
119
|
+
};
|
|
120
|
+
sendPasswordResetEmail = async (email) => {
|
|
121
|
+
console.log(`Sending password reset email to ${email}`);
|
|
122
|
+
};
|
|
123
|
+
resendEmailVerification = async () => {
|
|
124
|
+
const user = this._currentUser;
|
|
125
|
+
if (!user) {
|
|
126
|
+
throw new Error("No user is currently signed in");
|
|
127
|
+
}
|
|
128
|
+
await user.reload();
|
|
129
|
+
if (user.emailVerified) {
|
|
130
|
+
return {
|
|
131
|
+
success: true,
|
|
132
|
+
message: "Email is already verified. You can sign in.",
|
|
133
|
+
isVerified: true
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const actionCodeSettings = {
|
|
137
|
+
url: "/sign-in",
|
|
138
|
+
// TODO: Make this configurable
|
|
139
|
+
handleCodeInApp: true
|
|
140
|
+
};
|
|
141
|
+
await (0, import_auth.sendEmailVerification)(user, actionCodeSettings);
|
|
142
|
+
return {
|
|
143
|
+
success: true,
|
|
144
|
+
message: "Verification email sent. Please check your inbox.",
|
|
145
|
+
isVerified: false
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
getProviderConfig(providerName) {
|
|
149
|
+
switch (providerName.toLowerCase()) {
|
|
150
|
+
case "google": {
|
|
151
|
+
const googleProvider = new import_auth.GoogleAuthProvider();
|
|
152
|
+
return {
|
|
153
|
+
provider: googleProvider,
|
|
154
|
+
customParameters: {
|
|
155
|
+
login_hint: "user@example.com",
|
|
156
|
+
prompt: "select_account"
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
case "microsoft": {
|
|
161
|
+
const microsoftProvider = new import_auth.OAuthProvider("microsoft.com");
|
|
162
|
+
return {
|
|
163
|
+
provider: microsoftProvider,
|
|
164
|
+
customParameters: {
|
|
165
|
+
prompt: "consent"
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
default:
|
|
170
|
+
throw new Error(`Unsupported provider: ${providerName}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async authRedirectResult() {
|
|
174
|
+
try {
|
|
175
|
+
const result = await (0, import_auth.getRedirectResult)(this.auth);
|
|
176
|
+
if (result) {
|
|
177
|
+
const user = result.user;
|
|
178
|
+
return {
|
|
179
|
+
success: true,
|
|
180
|
+
user
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
} catch (error) {
|
|
185
|
+
const authError = (0, import_errors.handleFirebaseAuthError)(error);
|
|
186
|
+
return {
|
|
187
|
+
success: false,
|
|
188
|
+
message: authError.message,
|
|
189
|
+
error: authError.code,
|
|
190
|
+
user: null
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async executeAuthMethod(authMethod, providerName) {
|
|
195
|
+
const config = this.getProviderConfig(providerName);
|
|
196
|
+
config.provider.setCustomParameters(config.customParameters);
|
|
197
|
+
try {
|
|
198
|
+
await authMethod(this.auth, config.provider);
|
|
199
|
+
return { success: true, message: "Authentication initiated" };
|
|
200
|
+
} catch (error) {
|
|
201
|
+
const authError = (0, import_errors.handleFirebaseAuthError)(error);
|
|
202
|
+
return {
|
|
203
|
+
success: false,
|
|
204
|
+
message: authError.message,
|
|
205
|
+
error: authError.code,
|
|
206
|
+
user: null
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async _signInWithRedirect(providerName) {
|
|
211
|
+
return this.executeAuthMethod(import_auth.signInWithRedirect, providerName);
|
|
212
|
+
}
|
|
213
|
+
async _signInWithPopUp(providerName) {
|
|
214
|
+
return this.executeAuthMethod(import_auth.signInWithPopup, providerName);
|
|
215
|
+
}
|
|
216
|
+
async checkRedirectResult() {
|
|
217
|
+
return this.authRedirectResult();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
221
|
+
0 && (module.exports = {
|
|
222
|
+
SignIn
|
|
223
|
+
});
|
|
224
|
+
//# sourceMappingURL=SignIn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/resources/SignIn.ts"],"sourcesContent":["import { handleFirebaseAuthError } from \"@tern-secure/shared/errors\";\nimport type {\n ResendEmailVerification,\n SignInFormValuesTree,\n SignInResource,\n SignInResponseTree,\n SignInStatus,\n TernSecureUser,\n} from \"@tern-secure/types\";\nimport type {\n Auth,\n UserCredential} from \"firebase/auth\";\nimport {\n getRedirectResult,\n GoogleAuthProvider,\n OAuthProvider,\n sendEmailVerification,\n signInWithEmailAndPassword,\n signInWithPopup,\n signInWithRedirect\n} from \"firebase/auth\";\n\nimport { TernSecureBase } from \"./Base\";\n\ninterface ProviderConfig {\n provider: GoogleAuthProvider | OAuthProvider;\n customParameters: Record<string, string>;\n}\n\nexport type TernRequestInit = RequestInit;\n\nexport type SignInParams = {\n idToken: string;\n csrfToken: string | undefined;\n};\n\n\n\ntype FirebaseAuthResult = UserCredential | void;\n\ntype AuthMethodFunction = (\n auth: Auth,\n provider: GoogleAuthProvider | OAuthProvider\n) => Promise<FirebaseAuthResult>;\n\nexport class SignIn extends TernSecureBase implements SignInResource {\n pathRoot = '/sessions/createsession';\n \n status?: SignInStatus | undefined;\n private auth: Auth;\n private csrfToken: string | undefined;\n private _currentUser: TernSecureUser | null = null;\n\n constructor(auth: Auth, csrfToken: string | undefined) {\n super();\n this.auth = auth;\n this.csrfToken = csrfToken;\n }\n\n\n signInWithCredential = async (credential: UserCredential) => {\n const idToken = await credential.user.getIdToken();\n const params = {\n idToken: idToken,\n csrfToken: this.csrfToken,\n };\n\n return this._post({\n path: this.pathRoot,\n body: params,\n });\n };\n\n \n\n\n withEmailAndPassword = async (\n params: SignInFormValuesTree\n ): Promise<SignInResponseTree> => {\n try {\n const { email, password } = params;\n const userCredential = await signInWithEmailAndPassword(\n this.auth,\n email,\n password\n );\n \n await this.signInWithCredential(userCredential);\n\n const { user } = userCredential;\n return {\n success: true,\n message: \"Authentication successful\",\n user,\n error: !user.emailVerified ? \"REQUIRES_VERIFICATION\" : \"AUTHENTICATED\",\n };\n } catch (error) {\n const authError = handleFirebaseAuthError(error);\n return {\n success: false,\n message: authError.message,\n error: authError.code,\n user: null,\n };\n }\n };\n\n withCredential = async (params: SignInFormValuesTree): Promise<void> => {\n try {\n const { email, password } = params;\n const userCredential = await signInWithEmailAndPassword(\n this.auth,\n email,\n password\n );\n await this.signInWithCredential(userCredential);\n } catch (error) {\n const authError = handleFirebaseAuthError(error);\n console.error(authError);\n }\n };\n\n withSocialProvider = async (\n provider: string,\n options?: {\n mode?: \"popup\" | \"redirect\";\n }\n ): Promise<SignInResponseTree | void> => {\n try {\n if (options?.mode === \"redirect\") {\n const redirectResult = await this.authRedirectResult();\n\n if (redirectResult) {\n if (redirectResult.success) {\n console.log(\"Redirect after sign in\");\n }\n return redirectResult;\n }\n\n await this._signInWithRedirect(provider);\n return;\n } else {\n await this._signInWithPopUp(provider);\n return {\n success: true,\n message: \"Sign in successful\",\n };\n }\n } catch (error: any) {\n return {\n success: false,\n message: error.message || `Sign in with ${provider} failed`,\n error,\n user: null,\n };\n }\n };\n\n completeMfaSignIn = async (\n _mfaToken: string,\n _mfaContext?: any\n ): Promise<SignInResponseTree> => {\n throw new Error(\"Method not implemented.\");\n };\n\n sendPasswordResetEmail = async (email: string): Promise<void> => {\n console.log(`Sending password reset email to ${email}`);\n };\n\n resendEmailVerification = async (): Promise<ResendEmailVerification> => {\n const user = this._currentUser;\n if (!user) {\n throw new Error(\"No user is currently signed in\");\n }\n\n await user.reload();\n\n if (user.emailVerified) {\n return {\n success: true,\n message: \"Email is already verified. You can sign in.\",\n isVerified: true,\n };\n }\n\n const actionCodeSettings = {\n url: \"/sign-in\", // TODO: Make this configurable\n handleCodeInApp: true,\n };\n\n await sendEmailVerification(user, actionCodeSettings);\n return {\n success: true,\n message: \"Verification email sent. Please check your inbox.\",\n isVerified: false,\n };\n };\n\n private getProviderConfig(providerName: string): ProviderConfig {\n switch (providerName.toLowerCase()) {\n case \"google\": {\n const googleProvider = new GoogleAuthProvider();\n return {\n provider: googleProvider,\n customParameters: {\n login_hint: \"user@example.com\",\n prompt: \"select_account\",\n },\n };\n }\n case \"microsoft\": {\n const microsoftProvider = new OAuthProvider(\"microsoft.com\");\n return {\n provider: microsoftProvider,\n customParameters: {\n prompt: \"consent\",\n },\n };\n }\n default:\n throw new Error(`Unsupported provider: ${providerName}`);\n }\n }\n\n private async authRedirectResult(): Promise<SignInResponseTree | null> {\n try {\n const result = await getRedirectResult(this.auth);\n\n if (result) {\n const user = result.user;\n return {\n success: true,\n user,\n };\n }\n return null;\n } catch (error) {\n const authError = handleFirebaseAuthError(error);\n return {\n success: false,\n message: authError.message,\n error: authError.code,\n user: null,\n };\n }\n }\n\n private async executeAuthMethod(\n authMethod: AuthMethodFunction,\n providerName: string\n ): Promise<SignInResponseTree> {\n const config = this.getProviderConfig(providerName);\n config.provider.setCustomParameters(config.customParameters);\n try {\n await authMethod(this.auth, config.provider);\n return { success: true, message: \"Authentication initiated\" };\n } catch (error) {\n const authError = handleFirebaseAuthError(error);\n return {\n success: false,\n message: authError.message,\n error: authError.code,\n user: null,\n };\n }\n }\n\n private async _signInWithRedirect(\n providerName: string\n ): Promise<SignInResponseTree> {\n return this.executeAuthMethod(signInWithRedirect, providerName);\n }\n\n private async _signInWithPopUp(\n providerName: string\n ): Promise<SignInResponseTree> {\n return this.executeAuthMethod(signInWithPopup, providerName);\n }\n\n public async checkRedirectResult(): Promise<SignInResponseTree | null> {\n return this.authRedirectResult();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAwC;AAYxC,kBAQO;AAEP,kBAA+B;AAuBxB,MAAM,eAAe,2BAAyC;AAAA,EACnE,WAAW;AAAA,EAEX;AAAA,EACQ;AAAA,EACA;AAAA,EACA,eAAsC;AAAA,EAE9C,YAAY,MAAY,WAA+B;AACrD,UAAM;AACN,SAAK,OAAO;AACZ,SAAK,YAAY;AAAA,EACnB;AAAA,EAGA,uBAAuB,OAAO,eAA+B;AAC3D,UAAM,UAAU,MAAM,WAAW,KAAK,WAAW;AACjD,UAAM,SAAS;AAAA,MACb;AAAA,MACA,WAAW,KAAK;AAAA,IAClB;AAEA,WAAO,KAAK,MAAM;AAAA,MAChB,MAAM,KAAK;AAAA,MACX,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AAAA,EAKA,uBAAuB,OACrB,WACgC;AAChC,QAAI;AACF,YAAM,EAAE,OAAO,SAAS,IAAI;AAC5B,YAAM,iBAAiB,UAAM;AAAA,QAC3B,KAAK;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAED,YAAM,KAAK,qBAAqB,cAAc;AAE7C,YAAM,EAAE,KAAK,IAAI;AACjB,aAAO;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,QACT;AAAA,QACA,OAAO,CAAC,KAAK,gBAAgB,0BAA0B;AAAA,MACzD;AAAA,IACF,SAAS,OAAO;AACd,YAAM,gBAAY,uCAAwB,KAAK;AAC/C,aAAO;AAAA,QAC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AC7B,UAAM,SAAS,KAAK,kBAAkB,YAAY;AAClD,WAAO,SAAS,oBAAoB,OAAO,gBAAgB;AAC3D,QAAI;AACF,YAAM,WAAW,KAAK,MAAM,OAAO,QAAQ;AAC3C,aAAO,EAAE,SAAS,MAAM,SAAS,2BAA2B;AAAA,IAC9D,SAAS,OAAO;AACd,YAAM,gBAAY,uCAAwB,KAAK;AAC/C,aAAO;AAAA,QACL,SAAS;AAAA,QACT,SAAS,UAAU;AAAA,QACnB,OAAO,UAAU;AAAA,QACjB,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAc,oBACZ,cAC6B;AAC7B,WAAO,KAAK,kBAAkB,gCAAoB,YAAY;AAAA,EAChE;AAAA,EAEA,MAAc,iBACZ,cAC6B;AAC7B,WAAO,KAAK,kBAAkB,6BAAiB,YAAY;AAAA,EAC7D;AAAA,EAEA,MAAa,sBAA0D;AACrE,WAAO,KAAK,mBAAmB;AAAA,EACjC;AACF;","names":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 SignUp_exports = {};
|
|
20
|
+
__export(SignUp_exports, {
|
|
21
|
+
SignUp: () => SignUp
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(SignUp_exports);
|
|
24
|
+
class SignUp {
|
|
25
|
+
status = null;
|
|
26
|
+
username = null;
|
|
27
|
+
firstName = null;
|
|
28
|
+
lastName = null;
|
|
29
|
+
email = null;
|
|
30
|
+
auth;
|
|
31
|
+
ternSecureConfig;
|
|
32
|
+
constructor(auth) {
|
|
33
|
+
this.auth = auth;
|
|
34
|
+
}
|
|
35
|
+
withSocialProvider() {
|
|
36
|
+
throw new Error("Method not implemented.");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
SignUp
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=SignUp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/resources/SignUp.ts"],"sourcesContent":["import type {\n SignUpResource,\n SignUpStatus,\n TernSecureConfig\n} from '@tern-secure/types';\nimport type { Auth } from 'firebase/auth';\n\nexport class SignUp implements SignUpResource {\n status?: SignUpStatus | null = null;\n username?: string | null = null;\n firstName?: string | null = null;\n lastName?: string | null = null\n email: string | null = null;\n private auth: Auth;\n private ternSecureConfig?: TernSecureConfig;\n\n constructor(auth: Auth) {\n this.auth = auth;\n }\n\n withSocialProvider(): Promise<void> {\n throw new Error('Method not implemented.');\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,MAAM,OAAiC;AAAA,EAC1C,SAA+B;AAAA,EAC/B,WAA2B;AAAA,EAC3B,YAA4B;AAAA,EAC5B,WAA2B;AAAA,EAC3B,QAAuB;AAAA,EACf;AAAA,EACA;AAAA,EAER,YAAY,MAAY;AACpB,SAAK,OAAO;AAAA,EAChB;AAAA,EAEF,qBAAoC;AAClC,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AACF;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var resources_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(resources_exports);
|
|
18
|
+
__reExport(resources_exports, require("./SignIn"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./SignIn")
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/resources/index.ts"],"sourcesContent":["export * from './SignIn';"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,8BAAc,qBAAd;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var internal_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(internal_exports);
|
|
18
|
+
__reExport(internal_exports, require("./SignUp"), module.exports);
|
|
19
|
+
__reExport(internal_exports, require("./SignIn"), module.exports);
|
|
20
|
+
__reExport(internal_exports, require("./Base"), module.exports);
|
|
21
|
+
__reExport(internal_exports, require("./AuthCookieManager"), module.exports);
|
|
22
|
+
__reExport(internal_exports, require("../utils"), module.exports);
|
|
23
|
+
__reExport(internal_exports, require("./Error"), module.exports);
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
...require("./SignUp"),
|
|
27
|
+
...require("./SignIn"),
|
|
28
|
+
...require("./Base"),
|
|
29
|
+
...require("./AuthCookieManager"),
|
|
30
|
+
...require("../utils"),
|
|
31
|
+
...require("./Error")
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/resources/internal.ts"],"sourcesContent":["export type { TernSecureAuth } from '../instance/TernAuth';\nexport * from './SignUp';\nexport * from './SignIn';\nexport * from './Base';\nexport * from './AuthCookieManager';\nexport * from '../utils';\nexport * from './Error';"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AACA,6BAAc,qBADd;AAEA,6BAAc,qBAFd;AAGA,6BAAc,mBAHd;AAIA,6BAAc,gCAJd;AAKA,6BAAc,qBALd;AAMA,6BAAc,oBANd;","names":[]}
|
|
@@ -0,0 +1,174 @@
|
|
|
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 construct_exports = {};
|
|
20
|
+
__export(construct_exports, {
|
|
21
|
+
buildURL: () => buildURL,
|
|
22
|
+
constructFullUrl: () => constructFullUrl,
|
|
23
|
+
getPreviousPath: () => getPreviousPath,
|
|
24
|
+
getValidRedirectUrl: () => getValidRedirectUrl,
|
|
25
|
+
hasRedirectLoop: () => hasRedirectLoop,
|
|
26
|
+
storePreviousPath: () => storePreviousPath,
|
|
27
|
+
toURL: () => toURL,
|
|
28
|
+
urlWithRedirect: () => urlWithRedirect
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(construct_exports);
|
|
31
|
+
function buildURL(params, options = {}) {
|
|
32
|
+
const { base, hashPath, hashSearch, searchParams, hashSearchParams, ...rest } = params;
|
|
33
|
+
const { stringify = true, skipOrigin = false } = options;
|
|
34
|
+
const baseFallback = typeof window !== "undefined" && window.location ? window.location.href : "http://react-native-fake-base-url";
|
|
35
|
+
const appendToUrlSearchParams = (target, source) => {
|
|
36
|
+
if (!source) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (source instanceof URLSearchParams) {
|
|
40
|
+
source.forEach((value, key) => {
|
|
41
|
+
target.set(key, value);
|
|
42
|
+
});
|
|
43
|
+
} else if (typeof source === "object") {
|
|
44
|
+
Object.entries(source).forEach(([key, value]) => {
|
|
45
|
+
target.set(key, String(value));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
try {
|
|
50
|
+
const url = new URL(base || "", baseFallback);
|
|
51
|
+
if (searchParams) {
|
|
52
|
+
searchParams.forEach((value, key) => {
|
|
53
|
+
url.searchParams.set(key, value);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (hashPath || hashSearch || hashSearchParams) {
|
|
57
|
+
const finalHashPath = hashPath || "";
|
|
58
|
+
const queryForHash = new URLSearchParams(hashSearch || "");
|
|
59
|
+
if (hashSearchParams) {
|
|
60
|
+
if (Array.isArray(hashSearchParams)) {
|
|
61
|
+
hashSearchParams.forEach((item) => appendToUrlSearchParams(queryForHash, item));
|
|
62
|
+
} else {
|
|
63
|
+
appendToUrlSearchParams(queryForHash, hashSearchParams);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const hashQueryString = queryForHash.toString();
|
|
67
|
+
let combinedHashString = "";
|
|
68
|
+
if (finalHashPath) {
|
|
69
|
+
combinedHashString = finalHashPath;
|
|
70
|
+
if (hashQueryString) {
|
|
71
|
+
if (combinedHashString.includes("?")) {
|
|
72
|
+
combinedHashString += "&" + hashQueryString;
|
|
73
|
+
} else {
|
|
74
|
+
combinedHashString += "?" + hashQueryString;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
if (hashQueryString) {
|
|
79
|
+
combinedHashString = hashQueryString;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (combinedHashString) {
|
|
83
|
+
url.hash = combinedHashString;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (stringify) {
|
|
87
|
+
return skipOrigin ? url.href.replace(url.origin, "") : url.href;
|
|
88
|
+
}
|
|
89
|
+
return url;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error("[TernSecure] Error building URL:", error);
|
|
92
|
+
const fallbackUrlString = base || "/";
|
|
93
|
+
if (stringify) {
|
|
94
|
+
return fallbackUrlString;
|
|
95
|
+
} else {
|
|
96
|
+
return new URL(fallbackUrlString, baseFallback);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const constructFullUrl = (path) => {
|
|
101
|
+
if (typeof window === "undefined") return path;
|
|
102
|
+
const baseUrl = window.location.origin;
|
|
103
|
+
if (path.startsWith("http")) {
|
|
104
|
+
return path;
|
|
105
|
+
}
|
|
106
|
+
return `${baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
|
|
107
|
+
};
|
|
108
|
+
const hasRedirectLoop = (currentPath, redirectPath) => {
|
|
109
|
+
if (!currentPath || !redirectPath) return false;
|
|
110
|
+
const cleanCurrentPath = currentPath.split("?")[0];
|
|
111
|
+
const cleanRedirectPath = redirectPath.split("?")[0];
|
|
112
|
+
return cleanCurrentPath === cleanRedirectPath;
|
|
113
|
+
};
|
|
114
|
+
const urlWithRedirect = (options) => {
|
|
115
|
+
const { signInUrl, signInPathParam = "/sign-in", currentPath, signUpUrl, signUpPathParam = "/sign-up" } = options;
|
|
116
|
+
const baseUrl = window.location.origin;
|
|
117
|
+
if (typeof window === "undefined") {
|
|
118
|
+
return signInUrl;
|
|
119
|
+
}
|
|
120
|
+
const url = new URL(signInUrl, baseUrl);
|
|
121
|
+
if (!currentPath.includes(signInPathParam) && !currentPath.includes(signUpPathParam)) {
|
|
122
|
+
url.searchParams.set("redirect", currentPath);
|
|
123
|
+
}
|
|
124
|
+
return url.toString();
|
|
125
|
+
};
|
|
126
|
+
const storePreviousPath = (path) => {
|
|
127
|
+
if (typeof window !== "undefined") {
|
|
128
|
+
sessionStorage.setItem("previousPath", path);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const getPreviousPath = () => {
|
|
132
|
+
if (typeof window !== "undefined") {
|
|
133
|
+
return sessionStorage.getItem("previousPath");
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
};
|
|
137
|
+
const getValidRedirectUrl = (searchParams, configuredRedirect) => {
|
|
138
|
+
const urlRedirect = searchParams.get("redirect");
|
|
139
|
+
if (urlRedirect) {
|
|
140
|
+
return validateUrl(urlRedirect);
|
|
141
|
+
}
|
|
142
|
+
if (configuredRedirect) {
|
|
143
|
+
return validateUrl(configuredRedirect);
|
|
144
|
+
}
|
|
145
|
+
return "/";
|
|
146
|
+
};
|
|
147
|
+
const validateUrl = (url) => {
|
|
148
|
+
try {
|
|
149
|
+
if (url.startsWith("http")) {
|
|
150
|
+
const urlObj = new URL(url);
|
|
151
|
+
if (typeof window !== "undefined" && urlObj.origin !== window.location.origin) {
|
|
152
|
+
return "/";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return "/";
|
|
156
|
+
} catch {
|
|
157
|
+
return "/";
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
function toURL(url) {
|
|
161
|
+
return new URL(url.toString(), window.location.origin);
|
|
162
|
+
}
|
|
163
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
164
|
+
0 && (module.exports = {
|
|
165
|
+
buildURL,
|
|
166
|
+
constructFullUrl,
|
|
167
|
+
getPreviousPath,
|
|
168
|
+
getValidRedirectUrl,
|
|
169
|
+
hasRedirectLoop,
|
|
170
|
+
storePreviousPath,
|
|
171
|
+
toURL,
|
|
172
|
+
urlWithRedirect
|
|
173
|
+
});
|
|
174
|
+
//# sourceMappingURL=construct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/construct.ts"],"sourcesContent":["//v2: redict with taking priority from the sign-in page\n\nexport type constructUrlWithRedirectProps = {\n signInUrl: string;\n signInPathParam?: string;\n currentPath: string;\n signUpUrl?: string;\n signUpPathParam?: string;\n};\n\ninterface BuildURLParams extends Partial<URL> {\n base?: string;\n hashPath?: string;\n hashSearch?: string;\n hashSearchParams?: URLSearchParams | Record<string, string> | Array<URLSearchParams | Record<string, string>>;\n}\n\ninterface BuildURLOptions<T> {\n skipOrigin?: boolean;\n stringify?: T;\n}\n\n/**\n *\n * buildURL(params: URLParams, options: BuildURLOptions): string\n *\n * Builds a URL safely by using the native URL() constructor. It can\n * also build a secondary path and search URL that lives inside the hash\n * of the main URL. For example:\n *\n * https://foo.com/bar?qux=42#/hash-bar?hash-qux=42\n *\n * References:\n * https://developer.mozilla.org/en-US/docs/Web/API/URL\n *\n * @param {BuildURLParams} params\n * @param {BuildURLOptions} options\n * @returns {URL | string} Returns the URL href\n */\nexport function buildURL<B extends boolean>(\n params: BuildURLParams,\n options?: BuildURLOptions<B>,\n): B extends true ? string : URL;\n\n/**\n * Builds a URL from given parameters, handling search and hash parameters\n * @param params - The parameters to construct the URL\n * @param options - Options for building the URL\n * @returns The constructed URL as a string or URL object\n */\nexport function buildURL(params: BuildURLParams, options: BuildURLOptions<boolean> = {}): URL | string {\n const { base, hashPath, hashSearch, searchParams, hashSearchParams, ...rest} = params;\n const { stringify = true, skipOrigin = false } = options;\n\n const baseFallback =\n typeof window !== 'undefined' && window.location ? window.location.href : 'http://react-native-fake-base-url';\n\n // Helper function to append parameters to a URLSearchParams object\n const appendToUrlSearchParams = (\n target: URLSearchParams,\n source: URLSearchParams | Record<string, string> | undefined | null,\n ) => {\n if (!source) {\n return;\n }\n if (source instanceof URLSearchParams) {\n source.forEach((value, key) => {\n target.set(key, value);\n });\n } else if (typeof source === 'object') {\n Object.entries(source).forEach(([key, value]) => {\n target.set(key, String(value));\n });\n }\n };\n\n try {\n const url = new URL(base || '', baseFallback);\n\n // Handle search parameters\n // params.searchParams comes from Partial<URL>, so it's URLSearchParams | undefined\n if (searchParams) {\n searchParams.forEach((value, key) => {\n url.searchParams.set(key, value);\n });\n }\n\n // Handle hash-related parameters\n if (hashPath || hashSearch || hashSearchParams) {\n const finalHashPath = hashPath || '';\n const queryForHash = new URLSearchParams(hashSearch || '');\n\n if (hashSearchParams) {\n if (Array.isArray(hashSearchParams)) {\n hashSearchParams.forEach(item => appendToUrlSearchParams(queryForHash, item));\n } else {\n appendToUrlSearchParams(queryForHash, hashSearchParams);\n }\n }\n\n const hashQueryString = queryForHash.toString();\n let combinedHashString = '';\n\n if (finalHashPath) {\n combinedHashString = finalHashPath;\n if (hashQueryString) {\n if (combinedHashString.includes('?')) {\n combinedHashString += '&' + hashQueryString;\n } else {\n combinedHashString += '?' + hashQueryString;\n }\n }\n } else {\n // No hashPath\n if (hashQueryString) {\n // If only query, it forms the hash content directly.\n // e.g. \"param=value\" or \"?param=value\" are both valid after '#'\n combinedHashString = hashQueryString;\n }\n }\n\n if (combinedHashString) {\n url.hash = combinedHashString;\n }\n }\n\n if (stringify) {\n return skipOrigin ? url.href.replace(url.origin, '') : url.href;\n }\n return url;\n } catch (error) {\n console.error('[TernSecure] Error building URL:', error);\n const fallbackUrlString = base || '/';\n if (stringify) {\n return fallbackUrlString;\n } else {\n // Attempt to create a URL object for the fallback\n return new URL(fallbackUrlString, baseFallback);\n }\n }\n}\n\n/**\n * Constructs a full URL with the current origin\n * @param path - The path to construct the URL for\n * @returns The full URL with origin\n */\nexport const constructFullUrl = (path: string) => {\n if (typeof window === 'undefined') return path;\n const baseUrl = window.location.origin;\n if (path.startsWith('http')) {\n return path;\n }\n return `${baseUrl}${path.startsWith('/') ? path : `/${path}`}`;\n};\n\n/**\n * Checks if the current URL has a redirect loop\n * @param currentPath - The current pathname\n * @param redirectPath - The path we're trying to redirect to\n * @returns boolean indicating if there's a redirect loop\n */\nexport const hasRedirectLoop = (currentPath: string, redirectPath: string): boolean => {\n if (!currentPath || !redirectPath) return false;\n\n // Remove any query parameters for comparison\n const cleanCurrentPath = currentPath.split('?')[0];\n const cleanRedirectPath = redirectPath.split('?')[0];\n\n return cleanCurrentPath === cleanRedirectPath;\n};\n\nexport const urlWithRedirect = (options: constructUrlWithRedirectProps): string => {\n const { signInUrl, signInPathParam = '/sign-in', currentPath, signUpUrl, signUpPathParam = '/sign-up' } = options;\n\n const baseUrl = window.location.origin;\n\n if (typeof window === 'undefined') {\n return signInUrl;\n }\n\n const url = new URL(signInUrl, baseUrl);\n\n if (!currentPath.includes(signInPathParam) && !currentPath.includes(signUpPathParam)) {\n url.searchParams.set('redirect', currentPath);\n }\n\n return url.toString();\n};\n\n/**\n * Stores the current path before signing out\n */\nexport const storePreviousPath = (path: string): void => {\n if (typeof window !== 'undefined') {\n sessionStorage.setItem('previousPath', path);\n }\n};\n\n/**\n * Gets the stored previous path\n */\nexport const getPreviousPath = (): string | null => {\n if (typeof window !== 'undefined') {\n return sessionStorage.getItem('previousPath');\n }\n return null;\n};\n\n/**\n * Gets a validated redirect URL ensuring it's from the same origin\n * @param redirectUrl - The URL to validate\n * @param searchParams - The search parameters to check for redirect\n * @returns A validated redirect URL\n */\nexport const getValidRedirectUrl = (searchParams: URLSearchParams, configuredRedirect?: string): string => {\n // Check URL search param first (highest priority)\n const urlRedirect = searchParams.get('redirect');\n if (urlRedirect) {\n return validateUrl(urlRedirect);\n }\n\n // Then check configured redirect (for first visits)\n if (configuredRedirect) {\n return validateUrl(configuredRedirect);\n }\n\n // Default fallback\n return '/';\n};\n\n/**\n * Validates and sanitizes URLs\n */\nconst validateUrl = (url: string): string => {\n try {\n // For absolute URLs\n if (url.startsWith('http')) {\n const urlObj = new URL(url);\n if (typeof window !== 'undefined' && urlObj.origin !== window.location.origin) {\n return '/';\n }\n }\n\n // For relative URLs\n return '/';\n } catch {\n return '/';\n }\n};\n\nexport function toURL(url: string | URL): URL {\n return new URL(url.toString(), window.location.origin);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkDO,SAAS,SAAS,QAAwB,UAAoC,CAAC,GAAiB;AACrG,QAAM,EAAE,MAAM,UAAU,YAAY,cAAc,kBAAkB,GAAG,KAAI,IAAI;AAC/E,QAAM,EAAE,YAAY,MAAM,aAAa,MAAM,IAAI;AAEjD,QAAM,eACJ,OAAO,WAAW,eAAe,OAAO,WAAW,OAAO,SAAS,OAAO;AAG5E,QAAM,0BAA0B,CAC9B,QACA,WACG;AACH,QAAI,CAAC,QAAQ;AACX;AAAA,IACF;AACA,QAAI,kBAAkB,iBAAiB;AACrC,aAAO,QAAQ,CAAC,OAAO,QAAQ;AAC7B,eAAO,IAAI,KAAK,KAAK;AAAA,MACvB,CAAC;AAAA,IACH,WAAW,OAAO,WAAW,UAAU;AACrC,aAAO,QAAQ,MAAM,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC/C,eAAO,IAAI,KAAK,OAAO,KAAK,CAAC;AAAA,MAC/B,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI;AACF,UAAM,MAAM,IAAI,IAAI,QAAQ,IAAI,YAAY;AAI5C,QAAI,cAAc;AAChB,mBAAa,QAAQ,CAAC,OAAO,QAAQ;AACnC,YAAI,aAAa,IAAI,KAAK,KAAK;AAAA,MACjC,CAAC;AAAA,IACH;AAGA,QAAI,YAAY,cAAc,kBAAkB;AAC9C,YAAM,gBAAgB,YAAY;AAClC,YAAM,eAAe,IAAI,gBAAgB,cAAc,EAAE;AAEzD,UAAI,kBAAkB;AACpB,YAAI,MAAM,QAAQ,gBAAgB,GAAG;AACnC,2BAAiB,QAAQ,UAAQ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|
+
"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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var utils_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(utils_exports);
|
|
18
|
+
__reExport(utils_exports, require("./construct"), module.exports);
|
|
19
|
+
__reExport(utils_exports, require("./querystring"), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require("./construct"),
|
|
23
|
+
...require("./querystring")
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["export * from './construct';\nexport * from './querystring';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,wBAAd;AACA,0BAAc,0BADd;","names":[]}
|