Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version: 2.1

orbs:
security-tools: moneytree/security-tools@2.0.4

docker_defaults: &docker_defaults
docker:
- image: cimg/node:26.0
Expand Down Expand Up @@ -43,11 +46,8 @@ jobs:
- *attach_workspace
- *install_corepack
- run:
name: Linting JavaScript
command: yarn lint:js
- run:
name: Linting TypeScript
command: yarn lint:ts
name: Linting
command: yarn lint

unit_test:
<<: *docker_defaults
Expand All @@ -68,7 +68,12 @@ workflows:
version: 2.1
build_and_test:
jobs:
- dependencies
- security-tools/supply_chain_guard:
context: new_github_mtservice_read
- security-tools/bearer
- dependencies:
requires:
- security-tools/supply_chain_guard
- lint:
requires:
- dependencies
Expand Down
8 changes: 0 additions & 8 deletions .eslintrc-ts.js

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc.js

This file was deleted.

2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ updates:
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 10
ignore:
# ignore automatic major updates for all dependencies
- dependency-name: "*"
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ approvedGitRepositories:

enableScripts: true
nodeLinker: node-modules
npmMinimalAgeGate: "10d"
49 changes: 49 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const { defineConfig } = require('eslint/config');

const tsParser = require('@typescript-eslint/parser');
const typescriptEslint = require('@typescript-eslint/eslint-plugin');
const js = require('@eslint/js');
const globals = require('globals');

module.exports = defineConfig([
{
ignores: [
'**/dist',
'**/docs',
'**/coverage',
'webpack.config.js',
'sample/webpack.config.js',
'eslint.config.js',
'jest.config.js'
]
},
js.configs.recommended,
typescriptEslint.configs['flat/recommended'],
{
languageOptions: {
parser: tsParser,
globals: {
...globals.browser,
...globals.commonjs,
...globals.node,
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
ecmaVersion: 11,
parserOptions: {}
},

plugins: {
'@typescript-eslint': typescriptEslint
},

rules: {
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
]
}
}
]);
32 changes: 15 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,37 @@
"build": "rm -rf dist && webpack",
"build:docs": "rm -rf docs/types && typedoc --out docs/types src",
"prepareRelease": "npm run build && git add dist && npm run build:docs && git add docs",
"createChangelog": "conventional-changelog -i CHANGELOG.md -s && git add CHANGELOG.md",
"createChangelog": "conventional-changelog -p conventionalcommits && git add CHANGELOG.md",
"version": "npm run prepareRelease && npm run createChangelog",
"test": "jest --no-cache",
"test:dev": "jest --watch",
"lint:js": "eslint '**/*.js'",
"lint:ts": "eslint -c './.eslintrc-ts.js' '**/*.ts'",
"lint": "yarn lint:js; yarn lint:ts",
"lint": "eslint",
"format": "prettier scripts src sample/src --write",
"spellcheck": "cspell src script sample/src",
"lint:fix": "yarn lint:js --fix; yarn lint:ts --fix",
"lint:fix": "yarn lint --fix",
"start:docs": "docsify serve docs",
"prepare": "husky install"
},
"devDependencies": {
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@commitlint/cli": "21.2.1",
"@commitlint/config-conventional": "21.2.0",
"@eslint/js": "10.0.1",
"@testing-library/jest-dom": "^5.12.0",
"@types/jest": "30.0.0",
"@types/node": "^26.1.2",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@typescript-eslint/eslint-plugin": "8.64.0",
"@typescript-eslint/parser": "8.64.0",
"buffer": "^6.0.3",
"conventional-changelog-cli": "^2.1.1",
"cspell": "^7.3.7",
"conventional-changelog": "8.1.0",
"conventional-changelog-conventionalcommits": "10.2.1",
"docsify-cli": "^4.4.3",
"eslint": "^7.26.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"husky": "^6.0.0",
"eslint": "10.7.0",
"eslint-config-prettier": "10.1.8",
"globals": "17.7.0",
"husky": "9.1.7",
"jest": "30.4.2",
"jest-environment-jsdom": "^30.4.1",
"jest-fetch-mock": "^3.0.3",
"prettier": "^2.3.0",
"prettier": "3.9.5",
"process": "^0.11.10",
"stream-browserify": "^3.0.0",
"ts-jest": "29.4.12",
Expand Down
4 changes: 3 additions & 1 deletion sample/src/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export default {
entityKey: document.getElementById('open-service-options-entityKey') as HTMLInputElement,
credentialId: document.getElementById('open-service-options-credentialId') as HTMLInputElement,
showBackBarOn: document.getElementById('open-service-options-showBackBarOn') as HTMLSelectElement,
showBackBarOnCredentialId: document.getElementById('open-service-options-showBackBarOn-credentialId') as HTMLInputElement
showBackBarOnCredentialId: document.getElementById(
'open-service-options-showBackBarOn-credentialId'
) as HTMLInputElement
},
initializeBtn: document.getElementById('initialize-btn') as HTMLButtonElement,
authorizeBtn: document.getElementById('authorize-btn') as HTMLButtonElement,
Expand Down
2 changes: 1 addition & 1 deletion sample/src/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
4 changes: 2 additions & 2 deletions sample/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ elements.openServiceBtn.onclick = async () => {
| VaultOpenServiceViewServiceList
| VaultOpenServiceViewCustomerSupport
| VaultOpenServiceViewOnboarding;
let openServicesOptions: VaultOptions = {} as VaultOptions;
let openServicesOptions: VaultOptions;

const getShowBackBarOn = (): VaultSpecificOptions['showBackBarOn'] => {
const selectedView =
Expand Down Expand Up @@ -318,7 +318,7 @@ const validateToken = async () => {
`;

switchAuthorizeFunctions('none');
} catch (error) {
} catch {
// Disables buttons when a session has not been initialized.
disabledFunctions();
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/__tests__/authorize-url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('api', () => {
state,
redirectUri,
scopes,
affiliateCode: null as any
affiliateCode: ''
});

const urlObj = new URL(url);
Expand Down
6 changes: 3 additions & 3 deletions src/api/__tests__/authorize.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MY_ACCOUNT_DOMAINS } from '../../server-paths';
import { MtLinkSdk } from '../..';
import { AuthorizeOptions, MtLinkSdk } from '../..';
import authorize from '../authorize';
import { generateConfigs } from '../../helper';
import * as helper from '../../helper';
Expand Down Expand Up @@ -165,7 +165,7 @@ describe('api', () => {
const state = 'state';
const scopes = 'points_read';
const samlSubjectId = 'mySubject';
const affiliateCode = null as any;
const affiliateCode = null;

const mtLinkSdk = new MtLinkSdk();
mtLinkSdk.init(clientId, { samlSubjectId });
Expand All @@ -175,7 +175,7 @@ describe('api', () => {
redirectUri,
scopes,
affiliateCode
});
} as unknown as AuthorizeOptions);

expect(open).toHaveBeenCalledTimes(1);
expect(open).toHaveBeenCalledWith(expect.any(String), '_self', 'noreferrer');
Expand Down
2 changes: 1 addition & 1 deletion src/api/exchange-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ export default async function exchangeToken(
storage.del('cv');
return result as Token;
} catch (error) {
throw new Error(`[mt-link-sdk] \`exchangeToken\` execution failed. ${error}`);
throw new Error(`[mt-link-sdk] \`exchangeToken\` execution failed. ${error}`, { cause: error });
}
}
2 changes: 1 addition & 1 deletion src/api/request-login-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ export default async function requestLoginLink(
throw new Error(response.statusText);
}
} catch (error) {
throw new Error(`[mt-link-sdk] \`requestLoginLink\` execution failed. ${error}`);
throw new Error(`[mt-link-sdk] \`requestLoginLink\` execution failed. ${error}`, { cause: error });
}
}
2 changes: 1 addition & 1 deletion src/api/token-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ export default async function tokenInfo(storedOptions: StoredOptions, token: str

return result;
} catch (error) {
throw new Error(`[mt-link-sdk] \`tokenInfo\` execution failed. ${error}`);
throw new Error(`[mt-link-sdk] \`tokenInfo\` execution failed. ${error}`, { cause: error });
}
}
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
LinkKitOpenServiceOptions,
MyAccountOpenServiceOptions,
OpenServiceOptions,
ConfigsOptions,
VaultOpenServiceOptions,
VaultOpenServiceUrlOptions,
VaultOpenServiceUrlViewServiceList,
Expand Down
2 changes: 1 addition & 1 deletion src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function isStorageAvailable(storage: Storage): boolean {
storage.setItem(test, test);
storage.removeItem(test);
return true;
} catch (_) {
} catch {
return false;
}
}
Expand Down
12 changes: 4 additions & 8 deletions src/typings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const supportedAuthAction = ['login', 'signup'] as const;
export type AuthAction = typeof supportedAuthAction[number];
export type AuthAction = (typeof supportedAuthAction)[number];

/** @hidden */
export interface PrivateParams {
Expand All @@ -23,7 +23,7 @@ export interface PrivateConfigsOptions {
}

export const supportedAuthnMethod = ['passwordless', 'sso', 'credentials', 'otp'] as const;
export type AuthnMethod = typeof supportedAuthnMethod[number];
export type AuthnMethod = (typeof supportedAuthnMethod)[number];

export interface ConfigsOptions extends PrivateConfigsOptions {
/**
Expand Down Expand Up @@ -190,8 +190,7 @@ export type MyAccountServiceTypes = {

export type MyAccountOpenServiceOptions = ConfigsOptions | (ConfigsOptions & MyAccountServiceTypes);
export type MyAccountOpenServiceUrlOptions =
| ConfigsOptionsWithoutIsNewTab
| (ConfigsOptionsWithoutIsNewTab & MyAccountServiceTypes);
ConfigsOptionsWithoutIsNewTab | (ConfigsOptionsWithoutIsNewTab & MyAccountServiceTypes);

export type VaultOpenServiceOptions = ConfigsOptions & VaultSpecificOptions;
export type VaultOpenServiceUrlOptions = ConfigsOptionsWithoutIsNewTab & VaultSpecificOptions;
Expand Down Expand Up @@ -267,10 +266,7 @@ export interface AffiliateTrackingParams {
affiliateCode?: string;
}
export interface AuthorizeOptions
extends OAuthSharedParams,
ConfigsOptions,
AuthorizeConfigsOptions,
AffiliateTrackingParams {
extends OAuthSharedParams, ConfigsOptions, AuthorizeConfigsOptions, AffiliateTrackingParams {
/**
* Access scopes you're requesting. This can be a single scope, or an array of scopes.
*
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"removeComments": true,
"rootDir": "./src",
"outDir": "./dist",
"lib": ["es2015", "dom"],
"lib": ["es2022", "dom"],
"types": ["node", "jest"]
},
"include": ["./src/**/*.ts", "./src/**/*.json"],
Expand Down
Loading