diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..ca65216 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,17 @@ +name: Build + +on: + push: + branches-ignore: + - main +jobs: + build-test: + name: "Build & test" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + # these if statements ensure that a publication only occurs when + # a new release is created: + - run: yarn install --immutable --immutable-cache + # for security reasons, use --check-cache if accepting PRs from third-parties. + - run: yarn prepublish diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..2d92f90 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +.pnp.cjs +.pnp.loader.mjs +*.md diff --git a/configs/commitlint.js b/configs/commitlint.js index 5073c20..422b194 100644 --- a/configs/commitlint.js +++ b/configs/commitlint.js @@ -1 +1 @@ -module.exports = { extends: ["@commitlint/config-conventional"] }; +module.exports = { extends: ['@commitlint/config-conventional'] }; diff --git a/configs/dts-bundle-generator.ts b/configs/dts-bundle-generator.ts index 9b333ff..a3caf54 100644 --- a/configs/dts-bundle-generator.ts +++ b/configs/dts-bundle-generator.ts @@ -1,8 +1,8 @@ const config = { entries: [ { - filePath: "../src/index.ts", - outFile: "../dist/index.d.ts", + filePath: '../src/index.ts', + outFile: '../dist/index.d.ts', noCheck: false, }, ], diff --git a/jest.config.ts b/jest.config.ts index c6077a7..b716d1e 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,12 +1,12 @@ -import type { Config } from "jest"; +import type { Config } from 'jest'; const config: Config = { transform: { - "^.+\\.(t|j)s$": "ts-jest", + '^.+\\.(t|j)s$': 'ts-jest', }, - testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(t|j)s$", - moduleFileExtensions: ["ts", "js", "json", "node"], - preset: "ts-jest", - testEnvironment: "node", + testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(t|j)s$', + moduleFileExtensions: ['ts', 'js', 'json', 'node'], + preset: 'ts-jest', + testEnvironment: 'node', }; export default config; diff --git a/package.json b/package.json index 996aefa..1d81afc 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,11 @@ "dist" ], "engines": { - "node": "18.x" + "node": ">= 17.5" }, "scripts": { - "build": "tsc && vite build && dts-bundle-generator --config ./configs/dts-bundle-generator.ts", + "build": "NODE_OPTIONS=--experimental-fetch yarn build:main", + "build:main": "tsc && vite build && dts-bundle-generator --config ./configs/dts-bundle-generator.ts", "clean": "rm -rf dist && rm -rf node_modules", "docs": "typedoc --options configs/typedoc.json", "docs:watch": "yarn docs --watch", @@ -29,7 +30,8 @@ "prepare": "husky install", "prepublish": "yarn build && yarn lint && yarn format && yarn test", "start": "vite --host --open", - "test": "jest", + "test": "NODE_OPTIONS=--experimental-fetch yarn test:main", + "test:main": "jest", "test:coverage": "jest --coverage", "watch": "tsc && vite build --watch" }, diff --git a/src/client.ts b/src/client.ts index fc9053e..4acb700 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,7 +1,7 @@ -import encodeBase64Url from "crypto-js/enc-base64url"; -import SHA256 from "crypto-js/sha256"; -import { generateRandomString } from "./utils"; -import { MONERIUM_CONFIG } from "./config"; +import encodeBase64Url from 'crypto-js/enc-base64url'; +import SHA256 from 'crypto-js/sha256'; +import { generateRandomString } from './utils'; +import { MONERIUM_CONFIG } from './config'; import type { AuthArgs, AuthCode, @@ -20,7 +20,7 @@ import type { RefreshToken, SupportingDoc, Token, -} from "./types"; +} from './types'; // import pjson from "../package.json"; export class MoneriumClient { @@ -31,7 +31,7 @@ export class MoneriumClient { codeVerifier?: string; bearerProfile?: BearerProfile; - constructor(env: "production" | "sandbox" = "sandbox") { + constructor(env: 'production' | 'sandbox' = 'sandbox') { this.#env = MONERIUM_CONFIG.environments[env]; } @@ -41,20 +41,20 @@ export class MoneriumClient { let params: AuthCode | RefreshToken | ClientCredentials; if (this.#isAuthCode(args)) { - params = { ...args, grant_type: "authorization_code" }; + params = { ...args, grant_type: 'authorization_code' }; } else if (this.#isRefreshToken(args)) { - params = { ...args, grant_type: "refresh_token" }; + params = { ...args, grant_type: 'refresh_token' }; } else if (this.#isClientCredentials(args)) { - params = { ...args, grant_type: "client_credentials" }; + params = { ...args, grant_type: 'client_credentials' }; } else { - throw new Error("Authentication method could not be detected."); + throw new Error('Authentication method could not be detected.'); } this.bearerProfile = (await this.#api( - "post", + 'post', `auth/token`, new URLSearchParams(params as unknown as Record), - true + true, )) as BearerProfile; this.#authPayload = `Bearer ${this.bearerProfile.access_token}`; @@ -72,15 +72,15 @@ export class MoneriumClient { // `Error: Native crypto module could not be used to get secure random number.` this.codeVerifier = generateRandomString(); const challenge = encodeBase64Url.stringify( - SHA256(this.codeVerifier as string) + SHA256(this.codeVerifier as string), ); const params: PKCERequest = { ...args, client_id: args?.client_id, code_challenge: challenge, - code_challenge_method: "S256", - response_type: "code", + code_challenge_method: 'S256', + response_type: 'code', }; return `${this.#env.api}/auth?${new URLSearchParams(params)}`; @@ -94,14 +94,14 @@ export class MoneriumClient { // -- Read Methods getAuthContext(): Promise { - return this.#api("get", `auth/context`) as Promise; + return this.#api('get', `auth/context`) as Promise; } /** * @param {string} profileId - the id of the profile to fetch. */ getProfile(profileId: string): Promise { - return this.#api("get", `profiles/${profileId}`) as Promise; + return this.#api('get', `profiles/${profileId}`) as Promise; } /** @@ -110,66 +110,66 @@ export class MoneriumClient { getBalances(profileId?: string): Promise | Promise { if (profileId) { return this.#api( - "get", - `profiles/${profileId}/balances` + 'get', + `profiles/${profileId}/balances`, ) as Promise; } else { - return this.#api("get", `balances`) as Promise; + return this.#api('get', `balances`) as Promise; } } getOrders(filter?: OrderFilter): Promise { const searchParams = new URLSearchParams( - filter as unknown as Record + filter as unknown as Record, ); - return this.#api("get", `orders?${searchParams}`) as Promise; + return this.#api('get', `orders?${searchParams}`) as Promise; } getOrder(orderId: string): Promise { - return this.#api("get", `orders/${orderId}`) as Promise; + return this.#api('get', `orders/${orderId}`) as Promise; } getTokens(): Promise { - return this.#api("get", "tokens") as Promise; + return this.#api('get', 'tokens') as Promise; } // -- Write Methods linkAddress(profileId: string, body: LinkAddress) { return this.#api( - "post", + 'post', `profiles/${profileId}/addresses`, - JSON.stringify(body) + JSON.stringify(body), ); } placeOrder(order: NewOrder, profileId?: string): Promise { if (profileId) { return this.#api( - "post", + 'post', `profiles/${profileId}/orders`, - JSON.stringify(order) + JSON.stringify(order), ) as Promise; } else { return this.#api( - "post", + 'post', `orders`, - JSON.stringify(order) + JSON.stringify(order), ) as Promise; } } uploadSupportingDocument(document: File): Promise { const searchParams = new URLSearchParams( - document as unknown as Record + document as unknown as Record, ); return this.#api( - "post", - "files/supporting-document", + 'post', + 'files/supporting-document', searchParams, - true + true, ) as Promise; } @@ -179,15 +179,15 @@ export class MoneriumClient { method: string, resource: string, body?: BodyInit, - isFormEncoded?: boolean + isFormEncoded?: boolean, ) { const res = await fetch(`${this.#env.api}/${resource}`, { method, headers: { - "Content-Type": `application/${ - isFormEncoded ? "x-www-form-urlencoded" : "json" + 'Content-Type': `application/${ + isFormEncoded ? 'x-www-form-urlencoded' : 'json' }`, - Authorization: this.#authPayload || "", + Authorization: this.#authPayload || '', // "User-Agent": "sdk/" + pjson.version, }, body, diff --git a/src/config.ts b/src/config.ts index 55e1999..4363b00 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,14 +1,14 @@ -import type { Config } from "./types"; +import type { Config } from './types'; const MONERIUM_CONFIG: Config = { environments: { production: { - api: "https://api.monerium.app", - web: "https://monerium.app", + api: 'https://api.monerium.app', + web: 'https://monerium.app', }, sandbox: { - api: "https://api.monerium.dev", - web: "https://sandbox.monerium.dev", + api: 'https://api.monerium.dev', + web: 'https://sandbox.monerium.dev', }, }, }; diff --git a/src/index.ts b/src/index.ts index 8a87c2d..282895d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,2 @@ -export { MoneriumClient } from "./client"; -export * from "./types"; +export { MoneriumClient } from './client'; +export * from './types'; diff --git a/src/types.ts b/src/types.ts index 7ab1c89..3d84c45 100644 --- a/src/types.ts +++ b/src/types.ts @@ -20,21 +20,21 @@ export interface BearerProfile { // --- Client Methods --- // export enum Currency { - eur = "eur", - usd = "usd", - gbp = "gbp", - isk = "isk", + eur = 'eur', + usd = 'usd', + gbp = 'gbp', + isk = 'isk', } // -- auth export type AuthArgs = - | Omit - | Omit - | Omit; + | Omit + | Omit + | Omit; export interface AuthCode { - grant_type: "authorization_code"; + grant_type: 'authorization_code'; client_id: string; code: string; code_verifier: string; @@ -43,14 +43,14 @@ export interface AuthCode { } export interface RefreshToken { - grant_type: "refresh_token"; + grant_type: 'refresh_token'; client_id: string; refresh_token: string; scope?: string; } export interface ClientCredentials { - grant_type: "client_credentials"; + grant_type: 'client_credentials'; client_id: string; client_secret: string; scope?: string; @@ -63,7 +63,7 @@ export interface ClientCredentials { */ export type PKCERequestArgs = Omit< PKCERequest, - "code_challenge" | "code_challenge_method" | "response_type" + 'code_challenge' | 'code_challenge_method' | 'response_type' >; export type PKCERequest = { @@ -72,9 +72,9 @@ export type PKCERequest = { /** the code challenge automatically generated by the SDK */ code_challenge: string; /** the code challenge method for the authentication flow , handled by the SDK */ - code_challenge_method: "S256"; + code_challenge_method: 'S256'; /** the response type of the authentication flow, handled by the SDK */ - response_type: "code"; + response_type: 'code'; /** the state of the application */ state?: string; /** the redirect uri of the application */ @@ -94,20 +94,20 @@ export type PKCERequest = { // -- authContext enum Method { - password = "password", - resource = "resource", - jwt = "jwt", - apiKey = "apiKey", + password = 'password', + resource = 'resource', + jwt = 'jwt', + apiKey = 'apiKey', } export enum ProfileType { - corporate = "corporate", - personal = "personal", + corporate = 'corporate', + personal = 'personal', } export enum Permission { - read = "read", - write = "write", + read = 'read', + write = 'write', } export interface AuthProfile { @@ -121,7 +121,7 @@ export interface AuthContext { userId: string; email: string; name: string; - roles: "admin"[]; + roles: 'admin'[]; auth: { method: Method; subject: string; verified: boolean }; defaultProfile: string; profiles: AuthProfile[]; @@ -130,16 +130,16 @@ export interface AuthContext { // -- getProfile export enum KYCState { - absent = "absent", - submitted = "submitted", - pending = "pending", - confirmed = "confirmed", + absent = 'absent', + submitted = 'submitted', + pending = 'pending', + confirmed = 'confirmed', } export enum KYCOutcome { - approved = "approved", - rejected = "rejected", - unknown = "unknown", + approved = 'approved', + rejected = 'rejected', + unknown = 'unknown', } export interface KYC { @@ -148,8 +148,8 @@ export interface KYC { } export enum PaymentStandard { - iban = "iban", - scan = "scan", + iban = 'iban', + scan = 'scan', } export interface Account { @@ -174,16 +174,16 @@ export interface Profile { // -- getBalances export enum Chain { - polygon = "polygon", - ethereum = "ethereum", - gnosis = "gnosis", + polygon = 'polygon', + ethereum = 'ethereum', + gnosis = 'gnosis', } export enum Network { - mainnet = "mainnet", - chiado = "chiado", - goerli = "goerli", - mumbai = "mumbai", + mainnet = 'mainnet', + chiado = 'chiado', + goerli = 'goerli', + mumbai = 'mumbai', } export interface Balance { @@ -202,19 +202,19 @@ export interface Balances { // --getOrders export enum OrderKind { - redeem = "redeem", - issue = "issue", + redeem = 'redeem', + issue = 'issue', } export enum OrderState { - placed = "placed", - pending = "pending", - processed = "processed", - rejected = "rejected", + placed = 'placed', + pending = 'pending', + processed = 'processed', + rejected = 'rejected', } export interface Fee { - provider: "satchel"; + provider: 'satchel'; currency: Currency; amount: string; } diff --git a/src/utils.ts b/src/utils.ts index 3a9b610..78b4221 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,7 +1,7 @@ export const generateRandomString = () => { - let result = ""; + let result = ''; const characters = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; const charactersLength = characters.length; let counter = 0; while (counter < 128) { diff --git a/test/client.test.ts b/test/client.test.ts index 17ebc70..bc32138 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -1,5 +1,5 @@ -import encodeBase64Url from "crypto-js/enc-base64url"; -import { MoneriumClient } from "../src/index"; +import encodeBase64Url from 'crypto-js/enc-base64url'; +import { MoneriumClient } from '../src/index'; import { Chain, Currency, @@ -7,31 +7,31 @@ import { Order, OrderKind, PaymentStandard, -} from "../src/types"; -import SHA256 from "crypto-js/sha256"; +} from '../src/types'; +import SHA256 from 'crypto-js/sha256'; -const clientAuthId = "654c9c30-44d3-11ed-adac-b2efc0e6677d"; -const redirectUri = "http://localhost:5173/integration"; -const clientId = "654e15da-44d3-11ed-adac-b2efc0e6677d"; +const clientAuthId = '654c9c30-44d3-11ed-adac-b2efc0e6677d'; +const redirectUri = 'http://localhost:5173/integration'; +const clientId = '654e15da-44d3-11ed-adac-b2efc0e6677d'; const clientSecret = - "7bb679cd597b62d77836cb877c432c80dcb1fcb6d8a2b8b703967bc9d12cd991"; + '7bb679cd597b62d77836cb877c432c80dcb1fcb6d8a2b8b703967bc9d12cd991'; // punkWallet: https://punkwallet.io/pk#0x3e4936f901535680c505b073a5f70094da38e2085ecf137b153d1866a7aa826b // const privateKey = "0x3e4936f901535680c505b073a5f70094da38e2085ecf137b153d1866a7aa826b"; -const publicKey = "0x2d312198e570912844b5a230AE6f7A2E3321371C"; +const publicKey = '0x2d312198e570912844b5a230AE6f7A2E3321371C'; -const message = "I hereby declare that I am the address owner."; +const message = 'I hereby declare that I am the address owner.'; const ownerSignatureHash = - "0xe206a1b5a268c9161d6874eeeab49cff554fddf485389b744491cf3920e6881d697c48a2e76453d04179b55d757365e2c591e9e8ad40f129c8f4bb592692f4031c"; + '0xe206a1b5a268c9161d6874eeeab49cff554fddf485389b744491cf3920e6881d697c48a2e76453d04179b55d757365e2c591e9e8ad40f129c8f4bb592692f4031c'; -test("client initialization", () => { +test('client initialization', () => { const client = new MoneriumClient(); expect(client).toBeInstanceOf(MoneriumClient); }); -test("authenticate with client credentials", async () => { +test('authenticate with client credentials', async () => { const client = new MoneriumClient(); await client.auth({ @@ -41,10 +41,10 @@ test("authenticate with client credentials", async () => { const authContext = await client.getAuthContext(); - expect(authContext.userId).toBe("05cc17db-17d0-11ed-81e7-a6f0ef57aabb"); + expect(authContext.userId).toBe('05cc17db-17d0-11ed-81e7-a6f0ef57aabb'); }); -test("authorization code flow", async () => { +test('authorization code flow', async () => { const client = new MoneriumClient(); const authFlowUrl = await client.pkceRequest({ @@ -53,13 +53,13 @@ test("authorization code flow", async () => { }); const challenge = encodeBase64Url.stringify( - SHA256(client?.codeVerifier as string) + SHA256(client?.codeVerifier as string), ); expect(authFlowUrl).toContain(challenge); }); -test("link address", async () => { +test('link address', async () => { const client = new MoneriumClient(); await client.auth({ @@ -96,10 +96,10 @@ test("link address", async () => { } catch (e: any) { error = e.errors.address; } - expect(error).toBe("Account already linked to your profile"); + expect(error).toBe('Account already linked to your profile'); }); -test("get profile", async () => { +test('get profile', async () => { const client = new MoneriumClient(); await client.auth({ @@ -110,10 +110,10 @@ test("get profile", async () => { const authContext = await client.getAuthContext(); const profile = await client.getProfile(authContext.profiles[0].id); - expect(profile.accounts[0].id).toBe("4b2be022-44e3-11ed-adac-b2efc0e6677d"); + expect(profile.accounts[0].id).toBe('4b2be022-44e3-11ed-adac-b2efc0e6677d'); }); -test("get balances", async () => { +test('get balances', async () => { const client = new MoneriumClient(); await client.auth({ @@ -126,16 +126,16 @@ test("get balances", async () => { expect(balances).toEqual( expect.arrayContaining([ expect.objectContaining({ - id: "4b208818-44e3-11ed-adac-b2efc0e6677d", - chain: "ethereum", - network: "goerli", - address: "0x1519cc67E620f5f4419Df88f4Ca668a754292e1C", + id: '4b208818-44e3-11ed-adac-b2efc0e6677d', + chain: 'ethereum', + network: 'goerli', + address: '0x1519cc67E620f5f4419Df88f4Ca668a754292e1C', }), - ]) + ]), ); }, 15000); -test("get orders", async () => { +test('get orders', async () => { const client = new MoneriumClient(); await client.auth({ @@ -145,16 +145,16 @@ test("get orders", async () => { const orders = await client.getOrders(); const order = orders.find( - (o: Order) => o.memo === "Powered by Monerium SDK" + (o: Order) => o.memo === 'Powered by Monerium SDK', ) as Order; - expect(order.kind).toBe("redeem"); - expect(order.amount).toBe("1"); - expect(order.memo).toBe("Powered by Monerium SDK"); + expect(order.kind).toBe('redeem'); + expect(order.amount).toBe('1'); + expect(order.memo).toBe('Powered by Monerium SDK'); }); -test("get orders by profileId", async () => { - const profileId = "04f5b0d5-17d0-11ed-81e7-a6f0ef57aabb"; +test('get orders by profileId', async () => { + const profileId = '04f5b0d5-17d0-11ed-81e7-a6f0ef57aabb'; const client = new MoneriumClient(); @@ -172,7 +172,7 @@ test("get orders by profileId", async () => { }); }); -test("get order", async () => { +test('get order', async () => { const client = new MoneriumClient(); await client.auth({ @@ -180,14 +180,14 @@ test("get order", async () => { client_secret: clientSecret, }); - const order = await client.getOrder("96cb9a3c-878d-11ed-ac14-4a76678fa2b6"); + const order = await client.getOrder('96cb9a3c-878d-11ed-ac14-4a76678fa2b6'); - expect(order.kind).toBe("redeem"); - expect(order.amount).toBe("1"); - expect(order.memo).toBe("Powered by Monerium SDK"); + expect(order.kind).toBe('redeem'); + expect(order.amount).toBe('1'); + expect(order.memo).toBe('Powered by Monerium SDK'); }); -test("get tokens", async () => { +test('get tokens', async () => { const client = new MoneriumClient(); await client.auth({ @@ -199,19 +199,19 @@ test("get tokens", async () => { const expected = [ { - address: "0x83B844180f66Bbc3BE2E97C6179035AF91c4Cce8", - chain: "ethereum", - currency: "eur", + address: '0x83B844180f66Bbc3BE2E97C6179035AF91c4Cce8', + chain: 'ethereum', + currency: 'eur', decimals: 18, - network: "goerli", - symbol: "EURe", - ticker: "EUR", + network: 'goerli', + symbol: 'EURe', + ticker: 'EUR', }, ]; expect(tokens).toEqual(expect.arrayContaining(expected)); }); -test("place order", async () => { +test('place order', async () => { const client = new MoneriumClient(); await client.auth({ @@ -224,17 +224,17 @@ test("place order", async () => { (a) => a.address === publicKey && a.currency === Currency.eur && - a.network === Network.goerli + a.network === Network.goerli, ); - const date = "Thu, 29 Dec 2022 14:58 +00:00"; + const date = 'Thu, 29 Dec 2022 14:58 +00:00'; const placeOrderMessage = `Send EUR 10 to GR1601101250000000012300695 at ${date}`; const placeOrderSignatureHash = - "0xe2baa7df880f140e37d4a0d9cb1aaa8969b40650f69dc826373efdcc0945050d45f64cf5a2c96fe6bba959abe1bee115cfa31cedc378233e051036cdebd992181c"; + '0xe2baa7df880f140e37d4a0d9cb1aaa8969b40650f69dc826373efdcc0945050d45f64cf5a2c96fe6bba959abe1bee115cfa31cedc378233e051036cdebd992181c'; const order = await client.placeOrder({ kind: OrderKind.redeem, - amount: "1", + amount: '1', signature: placeOrderSignatureHash, accountId: account?.id, address: publicKey, @@ -242,40 +242,40 @@ test("place order", async () => { counterpart: { identifier: { standard: PaymentStandard.iban, - iban: "GR1601101250000000012300695", + iban: 'GR1601101250000000012300695', }, details: { - firstName: "Mockbank", - lastName: "Testerson", + firstName: 'Mockbank', + lastName: 'Testerson', }, }, message: placeOrderMessage, - memo: "Powered by Monerium SDK", + memo: 'Powered by Monerium SDK', chain: Chain.ethereum, network: Network.goerli, }); const expected = { - profile: "04f5b0d5-17d0-11ed-81e7-a6f0ef57aabb", - accountId: "3cef7bfc-8779-11ed-ac14-4a76678fa2b6", - address: "0x2d312198e570912844b5a230AE6f7A2E3321371C", - kind: "redeem", - amount: "1", - currency: "eur", - memo: "Powered by Monerium SDK", - supportingDocumentId: "", - chain: "ethereum", - network: "goerli", + profile: '04f5b0d5-17d0-11ed-81e7-a6f0ef57aabb', + accountId: '3cef7bfc-8779-11ed-ac14-4a76678fa2b6', + address: '0x2d312198e570912844b5a230AE6f7A2E3321371C', + kind: 'redeem', + amount: '1', + currency: 'eur', + memo: 'Powered by Monerium SDK', + supportingDocumentId: '', + chain: 'ethereum', + network: 'goerli', counterpart: { details: { - name: "Mockbank Testerson", - country: "GR", - lastName: "Testerson", - firstName: "Mockbank", + name: 'Mockbank Testerson', + country: 'GR', + lastName: 'Testerson', + firstName: 'Mockbank', }, identifier: { - iban: "GR16 0110 1250 0000 0001 2300 695", - standard: "iban", + iban: 'GR16 0110 1250 0000 0001 2300 695', + standard: 'iban', }, }, }; diff --git a/vite.config.ts b/vite.config.ts index b348da3..d788ab4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,17 +1,17 @@ -import path from "path"; -import { defineConfig } from "vite"; +import path from 'path'; +import { defineConfig } from 'vite'; export default defineConfig({ - base: "./", + base: './', build: { sourcemap: true, lib: { - entry: path.resolve(__dirname, "src/index.ts"), - name: "monerium-sdk", + entry: path.resolve(__dirname, 'src/index.ts'), + name: 'monerium-sdk', // formats: ["es", "cjs", "umd", "iife"], fileName: (format) => { - if (format === "es") { - return "index.mjs"; + if (format === 'es') { + return 'index.mjs'; } else { return `index.${format}.js`; }