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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
43 changes: 43 additions & 0 deletions .github/workflows/security-code-scanner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'MetaMask Security Code Scanner'

on:
push:
branches: ['main']
pull_request:
branches: ['main']

jobs:
run-security-scan:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: MetaMask Security Code Scanner
uses: MetaMask/Security-Code-Scanner@main
with:
repo: ${{ github.repository }}
paths_ignored: |
.storybook/
'**/__snapshots__/'
'**/*.snap'
'**/*.stories.js'
'**/*.stories.tsx'
'**/*.test.browser.ts*'
'**/*.test.js*'
'**/*.test.ts*'
'**/fixtures/'
'**/jest.config.js'
'**/jest.environment.js'
'**/mocks/'
'**/test*/'
docs/
e2e/
merged-packages/
node_modules
storybook/
test*/
rules_excluded: example
project_metrics_token: ${{ secrets.SECURITY_SCAN_METRICS_TOKEN }}
slack_webhook: ${{ secrets.APPSEC_BOT_SLACK_WEBHOOK }}
2 changes: 1 addition & 1 deletion packages/react-native-payments/.npmignore → .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ examples
.babelrc
.flowconfig
docs/
lib/js/__mocks__/
lib/js/__tests__/
lib/js/errors/__tests__/
lib/js/helpers/__tests__/

27 changes: 27 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
lintOptions {
warning 'InvalidPackage'
}
}

dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'com.google.android.gms:play-services-base:17.0.0'
implementation 'com.google.android.gms:play-services-identity:17.0.0'
implementation 'com.google.android.gms:play-services-wallet:17.0.0'
implementation 'com.android.support:support-v4:23.0.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.NonNull;
import android.app.Fragment;
import android.app.FragmentManager;
import android.support.annotation.RequiresPermission;
import androidx.annotation.RequiresPermission;
import android.util.Log;

import com.facebook.react.bridge.Callback;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 0 additions & 8 deletions lerna.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,12 @@ export default class PaymentRequest {

_removeEventListeners() {
// Internal Events
DeviceEventEmitter.removeSubscription(this._userDismissSubscription);
DeviceEventEmitter.removeSubscription(this._userAcceptSubscription);
this._userDismissSubscription?.remove?.()
this._userAcceptSubscription?.remove?.()

if (IS_IOS) {
DeviceEventEmitter.removeSubscription(
this._shippingAddressChangeSubscription
);
DeviceEventEmitter.removeSubscription(
this._shippingOptionChangeSubscription
);
this._shippingAddressChangeSubscription?.remove?.()
this._shippingOptionChangeSubscription?.remove?.()
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const {
isValidDecimalMonetaryValue,
isValidStringAmount,
toNumber
} = require('..');

describe('helpers', () => {
Expand Down Expand Up @@ -48,22 +47,4 @@ describe('helpers', () => {
expect(isValidStringAmount('9.')).toBe(false);
});
});

describe('toNumber', () => {
it('"9.999" should convert to 9.999', () => {
expect(toNumber('9.999')).toBe(9.999);
});

it('"9.99" should convert to 9.99', () => {
expect(toNumber('9.99')).toBe(9.99);
});

it('"9.9" should convert to 9.9', () => {
expect(toNumber('9.9')).toBe(9.9);
});

it('"9" should convert to 9', () => {
expect(toNumber('9')).toBe(9);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type {
PaymentShippingOption
} from '../types';

import { isDecimal, isFloat, isInt, toFloat, toInt } from 'validator';
import { DOMException, ConstructorError } from '../errors';

type AmountValue = string | number;
Expand Down Expand Up @@ -32,21 +31,11 @@ export function isNegative(amountValue: AmountValue): boolean {
}

export function isValidStringAmount(stringAmount): boolean {
if (stringAmount.endsWith('.')) {
return false;
}

return isDecimal(stringAmount);
}
if (typeof stringAmount !== 'string') throw new TypeError('Expected a string');

export function toNumber(string: string): number {
if (isFloat(string)) {
return toFloat(string);
}

if (isInt(string)) {
return toInt(string);
}
// '9', '.9' and '9.9' are correct
// '9.', '.' and '' are not
return /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]+)?)$/.test(stringAmount);
}

export function toString(amountValue: AmountValue) {
Expand Down
File renamed without changes.
File renamed without changes.
44 changes: 36 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,44 @@
{
"name": "@metamask/react-native-payments",
"version": "2.0.1",
"main": "lib/js/index.js",
"scripts": {
"precommit": "lint-staged"
"test": "jest"
},
"repository": "https://github.com/MetaMask/react-native-payments",
"keywords": [
"react",
"react-native",
"apple-pay",
"stripe",
"braintree",
"payments"
],
"author": "Naoufal Kadhom",
"license": "MIT",
"dependencies": {
"es6-error": "^4.0.2",
"uuid": "3.3.2"
},
"devDependencies": {
"lerna": "^2.0.0",
"lint-staged": "^4.0.0",
"prettier": "^1.4.4"
"babel-jest": "20.0.3",
"babel-preset-react-native": "2.0.0",
"husky": "^0.14.1",
"jest": "20.0.4",
"react-test-renderer": "16.0.0-alpha.12"
},
"peerDependencies": {
"react": ">=15",
"react-native": ">=0.41"
},
"lint-staged": {
"*.js": [
"prettier --single-quote --write",
"git add"
"jest": {
"testPathIgnorePatterns": [
"/node_modules/",
"lib/js/__tests__"
]
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
1 change: 0 additions & 1 deletion packages/react-native-payments-addon-braintree/.gitignore

This file was deleted.

Empty file.
1 change: 0 additions & 1 deletion packages/react-native-payments-addon-braintree/Cartfile

This file was deleted.

This file was deleted.

48 changes: 0 additions & 48 deletions packages/react-native-payments-addon-braintree/README.md

This file was deleted.

23 changes: 0 additions & 23 deletions packages/react-native-payments-addon-braintree/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/react-native-payments-addon-stripe/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion packages/react-native-payments-addon-stripe/Cartfile

This file was deleted.

This file was deleted.

49 changes: 0 additions & 49 deletions packages/react-native-payments-addon-stripe/README.md

This file was deleted.

Loading