Skip to content

Commit 551a04f

Browse files
committed
adds version in passwordless apis
1 parent 31e958e commit 551a04f

File tree

8 files changed

+42
-5
lines changed

8 files changed

+42
-5
lines changed

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/modal/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"@coinbase/wallet-sdk": "^4.3.x",
5252
"@mertasan/tailwindcss-variables": "^2.7.0",
5353
"@rollup/plugin-json": "^6.1.0",
54+
"@rollup/plugin-replace": "^6.0.2",
5455
"@rollup/plugin-url": "^8.0.2",
5556
"@svgr/rollup": "^8.1.0",
5657
"@svgr/webpack": "^8.1.0",

packages/modal/rollup.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
/* eslint-disable import/no-extraneous-dependencies */
22
import json from "@rollup/plugin-json";
3+
import replace from "@rollup/plugin-replace";
34
import url from "@rollup/plugin-url";
45
import svgr from "@svgr/rollup";
6+
import { readJSONFile } from "@toruslabs/torus-scripts/helpers/utils.js";
57
import path from "path";
68
import postcss from "rollup-plugin-postcss";
9+
10+
const pkg = await readJSONFile(path.resolve("./package.json"));
711
// TODO: use ssr module for cjs build
812

913
export const baseConfig = {
1014
input: ["./src/index.ts", "./src/react/index.ts", "./src/vue/index.ts"],
1115
plugins: [
16+
replace({
17+
"process.env.WEB3AUTH_VERSION": `"${pkg.version}"`,
18+
preventAssignment: true,
19+
}),
1220
postcss({
1321
config: {
1422
path: path.resolve("./postcss.config.js"),

packages/modal/src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { EVM_CONNECTORS } from "@web3auth/no-modal";
22

33
import { ConnectorsModalConfig } from "./interface";
44

5+
export const version = process.env.WEB3AUTH_VERSION;
6+
57
export const defaultConnectorsModalConfig: ConnectorsModalConfig = {
68
hideWalletDiscovery: false,
79
connectors: {

packages/modal/src/ui/handlers/AbstractHandler.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { post } from "@toruslabs/http-helpers";
22
import { AUTH_CONNECTION, BUILD_ENV, storageAvailable } from "@web3auth/auth";
33
import { WalletInitializationError } from "@web3auth/no-modal";
44

5+
import { version } from "../../config";
56
import { PASSWORDLESS_BUILD_ENV_MAP } from "../config";
67
import {
78
CodeInitiateRequestBodyParams,
@@ -20,6 +21,8 @@ export abstract class PasswordlessHandler {
2021

2122
trackingIdentifier?: string;
2223

24+
version: string = `web3auth-${version.split(".")[0]}`;
25+
2326
constructor(params: PasswordlessHandlerParams) {
2427
if (!params.authConnection) throw WalletInitializationError.invalidParams("authConnection is required");
2528
if (!params.web3authClientId) throw WalletInitializationError.invalidParams("web3authClientId is required");

packages/modal/src/ui/handlers/EmailPasswordlessHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class EmailPasswordlessHandler extends PasswordlessHandler {
2424
login_hint: loginHint,
2525
tracking_id: this.trackingId,
2626
whitelabel: this.whiteLabelParams,
27-
version: "",
27+
version: this.version,
2828
network,
2929
flow_type: EMAIL_FLOW.code,
3030
captcha_token: captchaToken,
@@ -42,7 +42,7 @@ export default class EmailPasswordlessHandler extends PasswordlessHandler {
4242
code,
4343
connection: "email",
4444
tracking_id: this.trackingId as string,
45-
version: "",
45+
version: this.version,
4646
network,
4747
flow_type: EMAIL_FLOW.code,
4848
};

packages/modal/src/ui/handlers/SmsPasswordlessHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default class SmsPasswordlessHandler extends PasswordlessHandler {
2828
login_hint: loginHint,
2929
tracking_id: this.trackingId,
3030
whitelabel: this.whiteLabelParams,
31-
version: "",
31+
version: this.version,
3232
network,
3333
captcha_token: captchaToken,
3434
};
@@ -44,7 +44,7 @@ export default class SmsPasswordlessHandler extends PasswordlessHandler {
4444
code,
4545
connection: this.connection,
4646
tracking_id: this.trackingId as string,
47-
version: "",
47+
version: this.version,
4848
network,
4949
};
5050
return super.verify(params);

packages/modal/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
21
const path = require("path");
2+
const { EnvironmentPlugin } = require("webpack");
33
const generateWebpackConfig = require("../../webpack.config");
44

55
const pkg = require("./package.json");
@@ -67,6 +67,7 @@ const config = generateWebpackConfig({
6767
},
6868
],
6969
},
70+
plugins: [new EnvironmentPlugin({ WEB3AUTH_VERSION: pkg.version })],
7071
ssrModule,
7172
});
7273

0 commit comments

Comments
 (0)