-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
WorldlineConnect
committed
Mar 19, 2024
1 parent
bd126d5
commit 1cca6d9
Showing
126 changed files
with
16,029 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Browsers that we support | ||
# See https://github.com/browserslist/browserslist#browsers | ||
|
||
ChromeAndroid >= 87 | ||
Chrome >= 69 | ||
Edge >= 90 | ||
Firefox >= 78 | ||
Opera >= 85 | ||
Samsung >= 7.4 | ||
Safari >= 13.1 | ||
ios_saf >= 14 | ||
and_chr >= 103 | ||
|
||
not dead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
/dist | ||
/docs | ||
/schemas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"root": true, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.gitattributes export-ignore | ||
.gitignore export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: API docs | ||
|
||
on: | ||
push: | ||
tags: ['[0-9]+.[0-9]+*'] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
api-docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
path: code | ||
persist-credentials: false | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.x' | ||
cache: 'npm' | ||
cache-dependency-path: code/package-lock.json | ||
- name: Build API docs | ||
run: npm ci && npm run build && npm run typedoc | ||
working-directory: code | ||
- name: Checkout pages | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: gh-pages | ||
path: pages | ||
- name: Deploy pages | ||
run: | | ||
SDK_VERSION_FOLDER=`echo "$SDK_VERSION" | awk --field-separator '.' '{print $1".x";}'` | ||
# Create .nojekyll if it doesn't exist yet | ||
touch .nojekyll | ||
mkdir -p "$SDK_VERSION_FOLDER" | ||
rsync --quiet --archive --checksum --delete --exclude .git ../code/docs/ "$SDK_VERSION_FOLDER/" | ||
# Remove .nojekyll generated by TypeDoc | ||
if [ -f "$SDK_VERSION_FOLDER/.nojekyll" ]; then rm "$SDK_VERSION_FOLDER/.nojekyll"; fi | ||
if [ -e latest ]; then rm -r latest; fi | ||
ln -s "$SDK_VERSION_FOLDER" latest | ||
git config user.email "$USER_EMAIL" | ||
git config user.name "$USER_NAME" | ||
git add --all . | ||
# Only commit when there are changes | ||
git diff --quiet && git diff --staged --quiet || git commit --message "Generated API docs for version ${SDK_VERSION}" | ||
git push | ||
shell: bash | ||
working-directory: pages | ||
env: | ||
SDK_VERSION: ${{ github.ref_name }} | ||
USER_EMAIL: ${{ github.event.pusher.email }} | ||
USER_NAME: ${{ github.event.pusher.name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
tags: ['[0-9]+.[0-9]+*'] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.x' | ||
# sets up .npmrc file to publish to npm | ||
registry-url: 'https://registry.npmjs.org' | ||
cache: 'npm' | ||
- name: Build | ||
run: npm ci && npm run build | ||
- name: Publish | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
node_modules | ||
/.project | ||
/npm-debug.log | ||
.vscode | ||
.idea | ||
*.iml | ||
*.tsbuildinfo | ||
.DS_Store | ||
.cache | ||
junit.xml | ||
|
||
# TypeDoc generation | ||
/docs | ||
|
||
# Microbundle visualization files | ||
stats.html | ||
|
||
# Distribution | ||
/dist | ||
|
||
# Tests | ||
.test-results.xml | ||
|
||
# Environment variable files | ||
.env* | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"./src/**/*.{ts,json}": ["npx prettier --write"], | ||
"./src/**/*.ts": ["bash -c tsc --noEmit", "npx eslint --fix"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
package-lock.json | ||
/dist | ||
/docs | ||
/schemas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"semi": true, | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"printWidth": 80, | ||
"tabWidth": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# Worldline Connect JavaScript SDK | ||
|
||
### Introduction | ||
|
||
The JavaScript SDK helps you to communicate with the [Worldline Connect](https://docs.connect.worldline-solutions.com/) Client API. Its primary features are: | ||
|
||
- handling of all the details concerning the encryption of the payment details, | ||
- convenient JavaScript wrapper around the API calls and responses, | ||
- localization of various labels and messages, | ||
- user-friendly formatting (masking) of payment data such as card numbers and expiry dates, | ||
- validation of input | ||
- check to determine to which payment provider a card number is associated. | ||
|
||
See the [Worldline Global Collect Developer Hub](https://docs.connect.worldline-solutions.com/documentation/sdk/mobile/javascript/) for more information on how to use the SDK. | ||
|
||
### Requirements | ||
|
||
Minimal browser versions: | ||
|
||
- Chrome 69+ | ||
- Chrome mobile 87+ | ||
- Safari 13.1+ | ||
- Safari mobile 14+ | ||
- MS Edge 90+ | ||
- MS Edge mobile 103+ | ||
- Firefox 78+ | ||
- Opera 85+ | ||
- Samsung mobile 7.4+ | ||
|
||
### Examples | ||
|
||
⚠ Please note that all examples have been moved to their own [repository](https://github.com/Worldline-Global-Collect/connect-sdk-client-js-example). | ||
|
||
### Installation | ||
|
||
Install this SDK using your preferred node package manager [`npm`](https://www.npmjs.com), [`yarn`](https://yarnpkg.com), [`pnpm`](https://pnpm.io) or [Bun](https://bun.sh/package-manager). | ||
|
||
```bash | ||
npm install connect-sdk-client-js | ||
``` | ||
|
||
### Distributed packages | ||
|
||
The SDK can be used AS UMD, CJS or ESM module. | ||
|
||
#### Example Universal Module Definition (UMD) | ||
|
||
The SDK is available under global namespace `connectsdk` and can be used in the following way: | ||
|
||
_app.js_ | ||
|
||
```js | ||
const sessionDetails = { | ||
/* ... */ | ||
}; | ||
|
||
// We can access the SDK via the global namespace `window.connectsdk` | ||
const session = new window.connectsdk.Session(sessionDetails); | ||
``` | ||
|
||
_index.html_ | ||
|
||
```html | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Example UMD</title> | ||
<script | ||
defer | ||
src="./node_modules/connect-sdk-client-js/dist/connect-sdk-client-js.umd.js" | ||
></script> | ||
<script defer src="./app.js"></script> | ||
</head> | ||
</html> | ||
``` | ||
|
||
#### Example ECMAScript Module (ESM) | ||
|
||
```ts | ||
import { Session, type SessionDetails } from 'connect-sdk-client-js'; | ||
|
||
const sessionDetails: SessionDetails = { | ||
/* ... */ | ||
}; | ||
|
||
const session = new Session(sessionDetails); | ||
``` | ||
|
||
#### Example CommonJS (CJS) | ||
|
||
```js | ||
const { Session } = require('connect-sdk-client-js'); | ||
|
||
/** | ||
* @type {import('connect-sdk-client-js').SessionDetails} | ||
*/ | ||
const sessionDetails = { | ||
/* ... */ | ||
}; | ||
|
||
const session = new Session(sessionDetails); | ||
``` | ||
|
||
### Build from source | ||
|
||
This repository uses [microbundle](https://github.com/developit/microbundle) to build the SDK. | ||
You can build the sdk by running the following commands: | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
The result of the build will have been written to the `dist` folder. This folder will contain the following files: | ||
|
||
- `/dist/types` - Directory containing all type declaration file. The `index.d.ts` is set as main file for the exported package, see `package.json:types` property. | ||
- `/dist/connect-sdk-client-js.js` - The compiled TypeScript as ESM module. This file will be when using ESM, see `package.json:module` property. | ||
- `/dist/connect-sdk-client-js.umd.js` - The compiled TypeScript as UMD module. This file can be used when you want to use the library as UMD, see `package.json:unpkg` property. | ||
- `/dist/connect-sdk-client-js.cjs` - The compiled TypeScript as CommonJS module. This file can be used when you want to use the library as CommonJS, see `package.json:main` property. | ||
|
||
### Test | ||
|
||
This library contains unit- and integration tests written with [Vitest](https://vitest.dev). | ||
By default Vitest starts in _watch mode_ when starting locally and _run mode_ when running in CI (when environment var `CI` is set), [see documentation](https://vitest.dev/guide/features.html#watch-mode). | ||
|
||
| Command | Description | | ||
|:---------------------------|:----------------------| | ||
| `npm run test` | Run unit tests | | ||
| `npm run test:integration` | Run integration tests | |
Oops, something went wrong.