@evervault/evervault-react-native 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -12
- package/android/build.gradle +5 -3
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/evervaultsdk/EvervaultSdkModule.kt +34 -5
- package/android/src/main/java/com/evervaultsdk/EvervaultSdkPackage.kt +1 -1
- package/lib/commonjs/components/Card/Card.js +115 -0
- package/lib/commonjs/components/Card/Card.js.map +1 -0
- package/lib/commonjs/components/Card/CardCVC.js +53 -0
- package/lib/commonjs/components/Card/CardCVC.js.map +1 -0
- package/lib/commonjs/components/Card/CardExpiry.js +40 -0
- package/lib/commonjs/components/Card/CardExpiry.js.map +1 -0
- package/lib/commonjs/components/Card/CardHolder.js +38 -0
- package/lib/commonjs/components/Card/CardHolder.js.map +1 -0
- package/lib/commonjs/components/Card/CardNumber.js +63 -0
- package/lib/commonjs/components/Card/CardNumber.js.map +1 -0
- package/lib/commonjs/components/Card/context.js +23 -0
- package/lib/commonjs/components/Card/context.js.map +1 -0
- package/lib/commonjs/components/Card/index.js +20 -0
- package/lib/commonjs/components/Card/index.js.map +1 -0
- package/lib/commonjs/components/Card/types.js +6 -0
- package/lib/commonjs/components/Card/types.js.map +1 -0
- package/lib/commonjs/components/Card/utilities.js +85 -0
- package/lib/commonjs/components/Card/utilities.js.map +1 -0
- package/lib/commonjs/components/Common/Error.js +2 -0
- package/lib/commonjs/components/Common/Error.js.map +1 -0
- package/lib/commonjs/components/index.js +3 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/index.js +18 -16
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native.js +17 -0
- package/lib/commonjs/native.js.map +1 -0
- package/lib/commonjs/sdk.js +22 -0
- package/lib/commonjs/sdk.js.map +1 -0
- package/lib/module/components/Card/Card.js +110 -0
- package/lib/module/components/Card/Card.js.map +1 -0
- package/lib/module/components/Card/CardCVC.js +44 -0
- package/lib/module/components/Card/CardCVC.js.map +1 -0
- package/lib/module/components/Card/CardExpiry.js +34 -0
- package/lib/module/components/Card/CardExpiry.js.map +1 -0
- package/lib/module/components/Card/CardHolder.js +32 -0
- package/lib/module/components/Card/CardHolder.js.map +1 -0
- package/lib/module/components/Card/CardNumber.js +57 -0
- package/lib/module/components/Card/CardNumber.js.map +1 -0
- package/lib/module/components/Card/context.js +16 -0
- package/lib/module/components/Card/context.js.map +1 -0
- package/lib/module/components/Card/index.js +3 -0
- package/lib/module/components/Card/index.js.map +1 -0
- package/lib/module/components/Card/types.js +2 -0
- package/lib/module/components/Card/types.js.map +1 -0
- package/lib/module/components/Card/utilities.js +77 -0
- package/lib/module/components/Card/utilities.js.map +1 -0
- package/lib/module/components/Common/Error.js +2 -0
- package/lib/module/components/Common/Error.js.map +1 -0
- package/lib/module/components/index.js +2 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/index.js +2 -16
- package/lib/module/index.js.map +1 -1
- package/lib/module/native.js +11 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/sdk.js +15 -0
- package/lib/module/sdk.js.map +1 -0
- package/lib/typescript/src/components/Card/Card.d.ts +30 -0
- package/lib/typescript/src/components/Card/Card.d.ts.map +1 -0
- package/lib/typescript/src/components/Card/CardCVC.d.ts +6 -0
- package/lib/typescript/src/components/Card/CardCVC.d.ts.map +1 -0
- package/lib/typescript/src/components/Card/CardExpiry.d.ts +6 -0
- package/lib/typescript/src/components/Card/CardExpiry.d.ts.map +1 -0
- package/lib/typescript/src/components/Card/CardHolder.d.ts +7 -0
- package/lib/typescript/src/components/Card/CardHolder.d.ts.map +1 -0
- package/lib/typescript/src/components/Card/CardNumber.d.ts +8 -0
- package/lib/typescript/src/components/Card/CardNumber.d.ts.map +1 -0
- package/lib/typescript/src/components/Card/context.d.ts +13 -0
- package/lib/typescript/src/components/Card/context.d.ts.map +1 -0
- package/lib/typescript/src/components/Card/index.d.ts +3 -0
- package/lib/typescript/src/components/Card/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Card/types.d.ts +13 -0
- package/lib/typescript/src/components/Card/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Card/utilities.d.ts +8 -0
- package/lib/typescript/src/components/Card/utilities.d.ts.map +1 -0
- package/lib/typescript/src/components/Common/Error.d.ts +1 -0
- package/lib/typescript/src/components/Common/Error.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +1 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native.d.ts +2 -0
- package/lib/typescript/src/native.d.ts.map +1 -0
- package/lib/typescript/src/sdk.d.ts +3 -0
- package/lib/typescript/src/sdk.d.ts.map +1 -0
- package/package.json +29 -23
- package/src/components/Card/Card.tsx +156 -0
- package/src/components/Card/CardCVC.tsx +47 -0
- package/src/components/Card/CardExpiry.tsx +39 -0
- package/src/components/Card/CardHolder.tsx +39 -0
- package/src/components/Card/CardNumber.tsx +64 -0
- package/src/components/Card/context.tsx +26 -0
- package/src/components/Card/index.ts +2 -0
- package/src/components/Card/types.ts +15 -0
- package/src/components/Card/utilities.ts +105 -0
- package/src/components/Common/Error.tsx +0 -0
- package/src/components/index.ts +1 -0
- package/src/index.tsx +3 -26
- package/src/native.ts +18 -0
- package/src/sdk.ts +17 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/Common/Error.tsx"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":"AAAA"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
ios: "- You have run 'pod install'\n",
|
|
4
|
-
default: ''
|
|
5
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
6
|
-
const EvervaultSdk = NativeModules.EvervaultSdk ? NativeModules.EvervaultSdk : new Proxy({}, {
|
|
7
|
-
get() {
|
|
8
|
-
throw new Error(LINKING_ERROR);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
export async function init(teamUuid, appUuid) {
|
|
12
|
-
return EvervaultSdk.initialize(teamUuid, appUuid);
|
|
13
|
-
}
|
|
14
|
-
export async function encrypt(data) {
|
|
15
|
-
return EvervaultSdk.encrypt(data);
|
|
16
|
-
}
|
|
1
|
+
export { Card } from './components/Card/Card';
|
|
2
|
+
export { init, encrypt } from './sdk';
|
|
17
3
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Card","init","encrypt"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAAyBA,IAAI,QAAQ,wBAAwB;AAC7D,SAASC,IAAI,EAAEC,OAAO,QAAQ,OAAO"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
const LINKING_ERROR = `The package '@evervault/evervault-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
3
|
+
ios: "- You have run 'pod install'\n",
|
|
4
|
+
default: ''
|
|
5
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
6
|
+
export const EvervaultSdk = NativeModules.EvervaultSdk ? NativeModules.EvervaultSdk : new Proxy({}, {
|
|
7
|
+
get() {
|
|
8
|
+
throw new Error(LINKING_ERROR);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","EvervaultSdk","Proxy","get","Error"],"sourceRoot":"../../src","sources":["native.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GAChB,4FAA2F,GAC5FD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,OAAO,MAAMC,YAAY,GAAGN,aAAa,CAACM,YAAY,GAClDN,aAAa,CAACM,YAAY,GAC1B,IAAIC,KAAK,CACT,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
import { EvervaultSdk } from "./native";
|
|
3
|
+
export async function init(teamUuid, appUuid) {
|
|
4
|
+
return EvervaultSdk.initialize(teamUuid, appUuid);
|
|
5
|
+
}
|
|
6
|
+
export async function encrypt(data) {
|
|
7
|
+
if (Platform.OS === "android" && typeof data !== "string") {
|
|
8
|
+
throw new Error(`The Evervault SDK does not currently support encrypting non-string data on Android.
|
|
9
|
+
If this is required for your use case, please get in touch with us at support@evervault.com. Please do not
|
|
10
|
+
serialize other data types to strings and pass them to this method as this will result in the data
|
|
11
|
+
type being returned in it's stringified form when decryption occurs.`);
|
|
12
|
+
}
|
|
13
|
+
return EvervaultSdk.encrypt(data.toString());
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Platform","EvervaultSdk","init","teamUuid","appUuid","initialize","encrypt","data","OS","Error","toString"],"sourceRoot":"../../src","sources":["sdk.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,YAAY,QAAQ,UAAU;AAEvC,OAAO,eAAeC,IAAIA,CAACC,QAAgB,EAAEC,OAAe,EAAiB;EAC3E,OAAOH,YAAY,CAACI,UAAU,CAACF,QAAQ,EAAEC,OAAO,CAAC;AACnD;AAEA,OAAO,eAAeE,OAAOA,CAACC,IAAS,EAAmB;EACxD,IAAIP,QAAQ,CAACQ,EAAE,KAAK,SAAS,IAAI,OAAOD,IAAI,KAAK,QAAQ,EAAE;IACzD,MAAM,IAAIE,KAAK,CAAE;AACrB;AACA;AACA,2EAA2E,CAAC;EAC1E;EAEA,OAAOR,YAAY,CAACK,OAAO,CAACC,IAAI,CAACG,QAAQ,CAAC,CAAC,CAAC;AAC9C"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { CardForm, CardConfig } from './types';
|
|
3
|
+
import { CardNumber } from './CardNumber';
|
|
4
|
+
import { CardPayload } from 'types';
|
|
5
|
+
import { CardHolder } from './CardHolder';
|
|
6
|
+
import { CardExpiry } from './CardExpiry';
|
|
7
|
+
import { StyleProp, TextStyle } from 'react-native';
|
|
8
|
+
export interface BaseProps {
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
style?: StyleProp<TextStyle>;
|
|
13
|
+
}
|
|
14
|
+
export interface CardProps {
|
|
15
|
+
initialValue?: CardForm;
|
|
16
|
+
config?: CardConfig;
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
onChange?: (payload: CardPayload) => void;
|
|
19
|
+
onComplete?: (payload: CardPayload) => void;
|
|
20
|
+
style?: StyleProp<TextStyle>;
|
|
21
|
+
}
|
|
22
|
+
declare function Card({ initialValue, config, children, onChange, onComplete, style, }: CardProps): import("react").JSX.Element;
|
|
23
|
+
declare const CardNamespace: typeof Card & {
|
|
24
|
+
Number: typeof CardNumber;
|
|
25
|
+
CVC: ({ style, disabled, placeholder, readOnly, }: import("./CardCVC").CVCProps) => import("react").JSX.Element;
|
|
26
|
+
Holder: typeof CardHolder;
|
|
27
|
+
Expiry: typeof CardExpiry;
|
|
28
|
+
};
|
|
29
|
+
export { CardNamespace as Card };
|
|
30
|
+
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/Card.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAGvD,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAa,WAAW,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAQ,MAAM,cAAc,CAAC;AAE1D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,SAAS;IACxB,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1C,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5C,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,iBAAS,IAAI,CAAC,EACZ,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,KAAK,GACN,EAAE,SAAS,+BAyGX;AAED,QAAA,MAAM,aAAa;;;;;CAKjB,CAAC;AAEH,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardCVC.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/CardCVC.tsx"],"names":[],"mappings":"AACA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAGlD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,MAAM,WAAW,QAAS,SAAQ,SAAS;CAAG;AAE9C,eAAO,MAAM,OAAO,gDAKjB,QAAQ,sBAiCV,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseProps } from './Card';
|
|
3
|
+
export interface CardExpiryProps extends BaseProps {
|
|
4
|
+
}
|
|
5
|
+
export declare function CardExpiry({ disabled, placeholder, readOnly, }: CardExpiryProps): import("react").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=CardExpiry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardExpiry.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/CardExpiry.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,MAAM,WAAW,eAAgB,SAAQ,SAAS;CAAG;AAErD,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,WAAW,EACX,QAAQ,GACT,EAAE,eAAe,+BA2BjB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseProps } from './Card';
|
|
3
|
+
export interface CardHolderProps extends BaseProps {
|
|
4
|
+
autoFocus?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function CardHolder({ autoFocus, disabled, placeholder, readOnly, }: CardHolderProps): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=CardHolder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardHolder.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/CardHolder.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,QAAQ,EACR,WAAW,EACX,QAAQ,GACT,EAAE,eAAe,+BAwBjB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseProps } from './Card';
|
|
3
|
+
interface CardNumberProps extends BaseProps {
|
|
4
|
+
autoFocus?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function CardNumber({ autoFocus, disabled, placeholder, readOnly, style, }: CardNumberProps): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=CardNumber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardNumber.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/CardNumber.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,UAAU,eAAgB,SAAQ,SAAS;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,KAAK,GACN,EAAE,eAAe,+BA+CjB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UseFormReturn } from 'shared';
|
|
2
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
3
|
+
import { CardForm } from './types';
|
|
4
|
+
import { CardField } from 'types';
|
|
5
|
+
type Context<T> = {
|
|
6
|
+
values: CardForm;
|
|
7
|
+
register: UseFormReturn<T>['register'];
|
|
8
|
+
setRegisteredFields: Dispatch<SetStateAction<Set<CardField>>>;
|
|
9
|
+
};
|
|
10
|
+
export declare const CardContext: import("react").Context<Context<CardForm>>;
|
|
11
|
+
export declare const useCardContext: () => Context<CardForm>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAA6B,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,KAAK,OAAO,CAAC,CAAC,IAAI;IAChB,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACvC,mBAAmB,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;CAC/D,CAAC;AAEF,eAAO,MAAM,WAAW,4CAYtB,CAAC;AAEH,eAAO,MAAM,cAAc,yBAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CardBrandName } from 'types';
|
|
2
|
+
export interface CardConfig {
|
|
3
|
+
autoFocus?: boolean;
|
|
4
|
+
acceptedBrands?: CardBrandName[];
|
|
5
|
+
}
|
|
6
|
+
export interface CardForm {
|
|
7
|
+
name: string;
|
|
8
|
+
number: string;
|
|
9
|
+
cvc: string;
|
|
10
|
+
expiry: string;
|
|
11
|
+
}
|
|
12
|
+
export { CardBrandName };
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CardNumberValidationResult } from '@evervault/card-validator';
|
|
2
|
+
import type { CardForm } from './types';
|
|
3
|
+
import type { CardBrandName, CardField, CardPayload } from 'types';
|
|
4
|
+
import { UseFormReturn } from 'shared';
|
|
5
|
+
export declare function changePayload(encrypt: (value: string) => Promise<string>, form: UseFormReturn<CardForm>, fields: CardField[]): Promise<CardPayload>;
|
|
6
|
+
export declare function isComplete(form: UseFormReturn<CardForm>, fields: CardField[]): boolean;
|
|
7
|
+
export declare function isAcceptedBrand(acceptedBrands: CardBrandName[] | undefined, cardNumberValidationResult: CardNumberValidationResult): boolean;
|
|
8
|
+
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,wBAAsB,aAAa,CACjC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,EAC3C,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,EAC7B,MAAM,EAAE,SAAS,EAAE,GAClB,OAAO,CAAC,WAAW,CAAC,CAyBtB;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,WAqB5E;AAED,wBAAgB,eAAe,CAC7B,cAAc,EAAE,aAAa,EAAE,GAAG,SAAS,EAC3C,0BAA0B,EAAE,0BAA0B,GACrD,OAAO,CAUT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=Error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../../../../src/components/Common/Error.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { type CardProps, Card } from './components/Card/Card';
|
|
2
|
+
export { init, encrypt } from './sdk';
|
|
3
|
+
export type { CardPayload, CardExpiry } from 'types';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACtC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/native.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,KAStB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":"AAGA,wBAAsB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3E;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CASxD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evervault/evervault-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Evervault react native sdk",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -25,14 +25,6 @@
|
|
|
25
25
|
"!**/__mocks__",
|
|
26
26
|
"!**/.*"
|
|
27
27
|
],
|
|
28
|
-
"scripts": {
|
|
29
|
-
"example": "yarn workspace react-native-evervault-sdk-example",
|
|
30
|
-
"test": "jest",
|
|
31
|
-
"typecheck": "tsc --noEmit",
|
|
32
|
-
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
33
|
-
"prepare": "bob build",
|
|
34
|
-
"release": "release-it"
|
|
35
|
-
},
|
|
36
28
|
"keywords": [
|
|
37
29
|
"react-native",
|
|
38
30
|
"ios",
|
|
@@ -40,14 +32,14 @@
|
|
|
40
32
|
],
|
|
41
33
|
"repository": {
|
|
42
34
|
"type": "git",
|
|
43
|
-
"url": "git+https://github.com/evervault/evervault-
|
|
35
|
+
"url": "git+https://github.com/evervault/evervault-js.git"
|
|
44
36
|
},
|
|
45
37
|
"author": "Eoin Boylan <eoin@evervault.com> (https://evervault.com)",
|
|
46
38
|
"license": "MIT",
|
|
47
39
|
"bugs": {
|
|
48
|
-
"url": "https://github.com/evervault/evervault-
|
|
40
|
+
"url": "https://github.com/evervault/evervault-js/issues"
|
|
49
41
|
},
|
|
50
|
-
"homepage": "https://github.com/evervault/evervault-
|
|
42
|
+
"homepage": "https://github.com/evervault/evervault-js",
|
|
51
43
|
"publishConfig": {
|
|
52
44
|
"registry": "https://registry.npmjs.org/",
|
|
53
45
|
"access": "public"
|
|
@@ -57,8 +49,7 @@
|
|
|
57
49
|
"@react-native/eslint-config": "^0.72.2",
|
|
58
50
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
59
51
|
"@types/jest": "^28.1.2",
|
|
60
|
-
"@types/react": "~
|
|
61
|
-
"@types/react-native": "0.70.0",
|
|
52
|
+
"@types/react": "~18.2.45",
|
|
62
53
|
"commitlint": "^17.0.2",
|
|
63
54
|
"del-cli": "^5.0.0",
|
|
64
55
|
"eslint": "^8.4.1",
|
|
@@ -68,30 +59,30 @@
|
|
|
68
59
|
"pod-install": "^0.1.0",
|
|
69
60
|
"prettier": "^2.0.5",
|
|
70
61
|
"react": "18.2.0",
|
|
71
|
-
"react-native": "0.
|
|
62
|
+
"react-native": "0.74.1",
|
|
72
63
|
"react-native-builder-bob": "^0.23.2",
|
|
64
|
+
"react-native-mask-input": "^1.2.3",
|
|
73
65
|
"release-it": "^16.1.3",
|
|
74
66
|
"turbo": "^1.10.7",
|
|
75
|
-
"typescript": "^5.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
67
|
+
"typescript": "^5.3.3",
|
|
68
|
+
"@evervault/card-validator": "1.0.1",
|
|
69
|
+
"shared": "1.0.0",
|
|
70
|
+
"types": "0.0.0"
|
|
79
71
|
},
|
|
80
72
|
"peerDependencies": {
|
|
81
73
|
"react": "*",
|
|
82
74
|
"react-native": "*"
|
|
83
75
|
},
|
|
84
76
|
"workspaces": [
|
|
85
|
-
"example"
|
|
77
|
+
"example-usage"
|
|
86
78
|
],
|
|
87
|
-
"packageManager": "yarn@3.6.1",
|
|
88
79
|
"engines": {
|
|
89
80
|
"node": ">= 18.0.0"
|
|
90
81
|
},
|
|
91
82
|
"jest": {
|
|
92
83
|
"preset": "react-native",
|
|
93
84
|
"modulePathIgnorePatterns": [
|
|
94
|
-
"<rootDir>/example/node_modules",
|
|
85
|
+
"<rootDir>/example-usage/node_modules",
|
|
95
86
|
"<rootDir>/lib/"
|
|
96
87
|
]
|
|
97
88
|
},
|
|
@@ -124,6 +115,7 @@
|
|
|
124
115
|
"prettier"
|
|
125
116
|
],
|
|
126
117
|
"rules": {
|
|
118
|
+
"react/react-in-jsx-scope": "off",
|
|
127
119
|
"prettier/prettier": [
|
|
128
120
|
"error",
|
|
129
121
|
{
|
|
@@ -150,6 +142,12 @@
|
|
|
150
142
|
"react-native-builder-bob": {
|
|
151
143
|
"source": "src",
|
|
152
144
|
"output": "lib",
|
|
145
|
+
"exclude": "example-usage/**",
|
|
146
|
+
"typescript": [
|
|
147
|
+
{
|
|
148
|
+
"project": "tsconfig.build.json"
|
|
149
|
+
}
|
|
150
|
+
],
|
|
153
151
|
"targets": [
|
|
154
152
|
"commonjs",
|
|
155
153
|
"module",
|
|
@@ -160,5 +158,13 @@
|
|
|
160
158
|
}
|
|
161
159
|
]
|
|
162
160
|
]
|
|
161
|
+
},
|
|
162
|
+
"dependencies": {
|
|
163
|
+
"react-native-masked-text": "^1.13.0"
|
|
164
|
+
},
|
|
165
|
+
"scripts": {
|
|
166
|
+
"typecheck": "tsc --noEmit",
|
|
167
|
+
"clean": "del-cli android/build example-usage/android/build example-usage/android/app/build example-usage/ios/build lib",
|
|
168
|
+
"release": "release-it"
|
|
163
169
|
}
|
|
164
|
-
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {
|
|
2
|
+
validateNumber,
|
|
3
|
+
validateCVC,
|
|
4
|
+
validateExpiry,
|
|
5
|
+
} from '@evervault/card-validator';
|
|
6
|
+
import { ReactNode, useEffect, useState } from 'react';
|
|
7
|
+
import { useForm } from 'shared';
|
|
8
|
+
import { changePayload, isAcceptedBrand, isComplete } from './utilities';
|
|
9
|
+
import type { CardForm, CardConfig } from './types';
|
|
10
|
+
import { CardNumber } from './CardNumber';
|
|
11
|
+
import { CardContext } from './context';
|
|
12
|
+
import { CardField, CardPayload } from 'types';
|
|
13
|
+
import { encrypt } from '../../sdk';
|
|
14
|
+
import { CardCVC } from './CardCVC';
|
|
15
|
+
import { CardHolder } from './CardHolder';
|
|
16
|
+
import { CardExpiry } from './CardExpiry';
|
|
17
|
+
import { StyleProp, TextStyle, View } from 'react-native';
|
|
18
|
+
|
|
19
|
+
export interface BaseProps {
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
style?: StyleProp<TextStyle>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CardProps {
|
|
27
|
+
initialValue?: CardForm;
|
|
28
|
+
config?: CardConfig;
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
onChange?: (payload: CardPayload) => void;
|
|
31
|
+
onComplete?: (payload: CardPayload) => void;
|
|
32
|
+
style?: StyleProp<TextStyle>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function Card({
|
|
36
|
+
initialValue,
|
|
37
|
+
config,
|
|
38
|
+
children,
|
|
39
|
+
onChange,
|
|
40
|
+
onComplete,
|
|
41
|
+
style,
|
|
42
|
+
}: CardProps) {
|
|
43
|
+
const [registeredFields, setRegisteredFields] = useState<Set<CardField>>(
|
|
44
|
+
new Set()
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const form = useForm<CardForm>({
|
|
48
|
+
initialValues: initialValue ?? {
|
|
49
|
+
cvc: '',
|
|
50
|
+
expiry: '',
|
|
51
|
+
number: '',
|
|
52
|
+
name: '',
|
|
53
|
+
},
|
|
54
|
+
validate: {
|
|
55
|
+
name: (values) => {
|
|
56
|
+
if (!registeredFields.has('name')) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (values.name.length === 0) {
|
|
61
|
+
return 'invalid';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return undefined;
|
|
65
|
+
},
|
|
66
|
+
number: (values) => {
|
|
67
|
+
if (!registeredFields.has('number')) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const cardValidation = validateNumber(values.number);
|
|
71
|
+
if (!cardValidation.isValid) {
|
|
72
|
+
return 'invalid';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!isAcceptedBrand(config?.acceptedBrands, cardValidation)) {
|
|
76
|
+
return 'unsupportedBrand';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return undefined;
|
|
80
|
+
},
|
|
81
|
+
expiry: (values) => {
|
|
82
|
+
if (!registeredFields.has('expiry')) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
const expiryValidation = validateExpiry(values.expiry);
|
|
86
|
+
if (!expiryValidation.isValid) {
|
|
87
|
+
return 'invalid';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return undefined;
|
|
91
|
+
},
|
|
92
|
+
cvc: (values) => {
|
|
93
|
+
if (!registeredFields.has('cvc')) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
const cvcValidation = validateCVC(values.cvc, values.number);
|
|
97
|
+
if (!cvcValidation.isValid) {
|
|
98
|
+
return 'invalid';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return undefined;
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
onChange: (formState) => {
|
|
105
|
+
const triggerChange = async () => {
|
|
106
|
+
const cardData = await changePayload(
|
|
107
|
+
encrypt,
|
|
108
|
+
formState,
|
|
109
|
+
Array.from(registeredFields)
|
|
110
|
+
);
|
|
111
|
+
if (onChange) {
|
|
112
|
+
onChange(cardData);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
triggerChange();
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
const getCardData = async () => {
|
|
122
|
+
const cardData = await changePayload(
|
|
123
|
+
encrypt,
|
|
124
|
+
form,
|
|
125
|
+
Array.from(registeredFields)
|
|
126
|
+
);
|
|
127
|
+
if (onComplete) {
|
|
128
|
+
onComplete(cardData);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
if (isComplete(form, Array.from(registeredFields))) {
|
|
132
|
+
getCardData();
|
|
133
|
+
}
|
|
134
|
+
}, [form, onComplete, registeredFields]);
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<CardContext.Provider
|
|
138
|
+
value={{
|
|
139
|
+
values: form.values,
|
|
140
|
+
register: form.register,
|
|
141
|
+
setRegisteredFields,
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<View style={style}>{children}</View>
|
|
145
|
+
</CardContext.Provider>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const CardNamespace = Object.assign(Card, {
|
|
150
|
+
Number: CardNumber,
|
|
151
|
+
CVC: CardCVC,
|
|
152
|
+
Holder: CardHolder,
|
|
153
|
+
Expiry: CardExpiry,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
export { CardNamespace as Card };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { validateNumber } from '@evervault/card-validator';
|
|
2
|
+
import React, { useEffect, useMemo } from 'react';
|
|
3
|
+
import { TextInputMask } from 'react-native-masked-text';
|
|
4
|
+
import { useCardContext } from './context';
|
|
5
|
+
import { BaseProps } from './Card';
|
|
6
|
+
|
|
7
|
+
export interface CVCProps extends BaseProps {}
|
|
8
|
+
|
|
9
|
+
export const CardCVC = ({
|
|
10
|
+
style,
|
|
11
|
+
disabled,
|
|
12
|
+
placeholder,
|
|
13
|
+
readOnly,
|
|
14
|
+
}: CVCProps) => {
|
|
15
|
+
const context = useCardContext();
|
|
16
|
+
const mask = useMemo(() => {
|
|
17
|
+
const type = validateNumber(context.values.number).brand;
|
|
18
|
+
if (type === 'american-express') {
|
|
19
|
+
return '9999';
|
|
20
|
+
}
|
|
21
|
+
return '999';
|
|
22
|
+
}, [context.values.number]);
|
|
23
|
+
|
|
24
|
+
const { onChange, onBlur } = context.register('cvc');
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
context.setRegisteredFields((prev) => new Set(prev).add('cvc'));
|
|
28
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<TextInputMask
|
|
33
|
+
type="custom"
|
|
34
|
+
options={{ mask }}
|
|
35
|
+
style={style}
|
|
36
|
+
value={context.values.cvc}
|
|
37
|
+
onChangeText={(t) => onChange(t)}
|
|
38
|
+
id="cvc"
|
|
39
|
+
editable={disabled}
|
|
40
|
+
selectTextOnFocus={disabled}
|
|
41
|
+
onBlur={onBlur}
|
|
42
|
+
placeholder={placeholder}
|
|
43
|
+
autoComplete="cc-csc"
|
|
44
|
+
readOnly={readOnly}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TextInputMask } from 'react-native-masked-text';
|
|
2
|
+
import { useCardContext } from './context';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { BaseProps } from './Card';
|
|
5
|
+
|
|
6
|
+
export interface CardExpiryProps extends BaseProps {}
|
|
7
|
+
|
|
8
|
+
export function CardExpiry({
|
|
9
|
+
disabled,
|
|
10
|
+
placeholder,
|
|
11
|
+
readOnly,
|
|
12
|
+
}: CardExpiryProps) {
|
|
13
|
+
const context = useCardContext();
|
|
14
|
+
|
|
15
|
+
const { onBlur, onChange } = context.register('expiry');
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
context.setRegisteredFields((prev) => new Set(prev).add('expiry'));
|
|
19
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<TextInputMask
|
|
24
|
+
type="datetime"
|
|
25
|
+
value={context.values.expiry}
|
|
26
|
+
editable={disabled}
|
|
27
|
+
selectTextOnFocus={disabled}
|
|
28
|
+
onChangeText={onChange}
|
|
29
|
+
options={{
|
|
30
|
+
format: '99 / 99',
|
|
31
|
+
}}
|
|
32
|
+
id="expiry"
|
|
33
|
+
onBlur={onBlur}
|
|
34
|
+
placeholder={placeholder ?? 'MM / YY'}
|
|
35
|
+
autoComplete="cc-exp"
|
|
36
|
+
readOnly={readOnly}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|