@gr4vy/secure-fields-react 0.5.4 → 0.6.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/CHANGELOG.md +17 -0
- package/lib/components/CardNumber/CardNumber.d.ts +2 -2
- package/lib/components/CardNumber/CardNumber.js +2 -1
- package/lib/components/CardNumber/CardNumber.js.map +1 -1
- package/lib/components/ExpiryDate/ExpiryDate.d.ts +2 -2
- package/lib/components/ExpiryDate/ExpiryDate.js +2 -1
- package/lib/components/ExpiryDate/ExpiryDate.js.map +1 -1
- package/lib/components/Field/Field.d.ts +3 -0
- package/lib/components/Field/Field.js +24 -0
- package/lib/components/Field/Field.js.map +1 -0
- package/lib/components/Field/index.d.ts +1 -0
- package/lib/components/Field/index.js +6 -0
- package/lib/components/Field/index.js.map +1 -0
- package/lib/components/SecureFields/SecureFields.d.ts +3 -6
- package/lib/components/SecureFields/SecureFields.js +25 -2
- package/lib/components/SecureFields/SecureFields.js.map +1 -1
- package/lib/components/SecurityCode/SecurityCode.d.ts +2 -2
- package/lib/components/SecurityCode/SecurityCode.js +2 -1
- package/lib/components/SecurityCode/SecurityCode.js.map +1 -1
- package/lib/hooks/use-secure-fields.d.ts +12 -0
- package/lib/hooks/use-secure-fields.js +63 -0
- package/lib/hooks/use-secure-fields.js.map +1 -0
- package/lib/hooks/use-secure-input.d.ts +3 -0
- package/lib/hooks/use-secure-input.js +63 -0
- package/lib/hooks/use-secure-input.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +16 -1
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +16 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
# v0.6.0 (Wed Sep 21 2022)
|
|
2
|
+
|
|
3
|
+
#### 🚀 Enhancement
|
|
4
|
+
|
|
5
|
+
- feat: hooks and components [#40](https://github.com/gr4vy/secure-fields/pull/40) ([@luca-gr4vy](https://github.com/luca-gr4vy))
|
|
6
|
+
|
|
7
|
+
#### 🏠 Internal
|
|
8
|
+
|
|
9
|
+
- task: add react dev [#51](https://github.com/gr4vy/secure-fields/pull/51) ([@luca-gr4vy](https://github.com/luca-gr4vy))
|
|
10
|
+
- fix: example-react prod build [#50](https://github.com/gr4vy/secure-fields/pull/50) ([@luca-gr4vy](https://github.com/luca-gr4vy))
|
|
11
|
+
|
|
12
|
+
#### Authors: 1
|
|
13
|
+
|
|
14
|
+
- Luca Allievi ([@luca-gr4vy](https://github.com/luca-gr4vy))
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
1
18
|
# v0.5.4 (Fri Sep 16 2022)
|
|
2
19
|
|
|
3
20
|
#### 🏠 Internal
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
export declare const CardNumber: (props:
|
|
2
|
+
import { Field as FieldProps } from '../../types';
|
|
3
|
+
export declare const CardNumber: (props: Omit<FieldProps, 'type'>) => JSX.Element;
|
|
@@ -13,8 +13,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.CardNumber = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var Field_1 = require("../Field");
|
|
16
17
|
var CardNumber = function (props) {
|
|
17
|
-
return (0, jsx_runtime_1.jsx)(
|
|
18
|
+
return (0, jsx_runtime_1.jsx)(Field_1.Field, __assign({ type: "number" }, props));
|
|
18
19
|
};
|
|
19
20
|
exports.CardNumber = CardNumber;
|
|
20
21
|
//# sourceMappingURL=CardNumber.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CardNumber.js","sourceRoot":"","sources":["../../../src/components/CardNumber/CardNumber.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"CardNumber.js","sourceRoot":"","sources":["../../../src/components/CardNumber/CardNumber.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kCAAgC;AAEzB,IAAM,UAAU,GAAG,UAAC,KAA+B;IACxD,OAAO,uBAAC,aAAK,aAAC,IAAI,EAAC,QAAQ,IAAK,KAAK,EAAI,CAAA;AAC3C,CAAC,CAAA;AAFY,QAAA,UAAU,cAEtB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
export declare const ExpiryDate: (props:
|
|
2
|
+
import { Field as FieldProps } from '../../types';
|
|
3
|
+
export declare const ExpiryDate: (props: Omit<FieldProps, 'type'>) => JSX.Element;
|
|
@@ -13,8 +13,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.ExpiryDate = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var Field_1 = require("../Field");
|
|
16
17
|
var ExpiryDate = function (props) {
|
|
17
|
-
return (0, jsx_runtime_1.jsx)(
|
|
18
|
+
return (0, jsx_runtime_1.jsx)(Field_1.Field, __assign({ type: "expiryDate" }, props));
|
|
18
19
|
};
|
|
19
20
|
exports.ExpiryDate = ExpiryDate;
|
|
20
21
|
//# sourceMappingURL=ExpiryDate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpiryDate.js","sourceRoot":"","sources":["../../../src/components/ExpiryDate/ExpiryDate.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ExpiryDate.js","sourceRoot":"","sources":["../../../src/components/ExpiryDate/ExpiryDate.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kCAAgC;AAEzB,IAAM,UAAU,GAAG,UAAC,KAA+B;IACxD,OAAO,uBAAC,aAAK,aAAC,IAAI,EAAC,YAAY,IAAK,KAAK,EAAI,CAAA;AAC/C,CAAC,CAAA;AAFY,QAAA,UAAU,cAEtB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.Field = void 0;
|
|
15
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var react_1 = require("react");
|
|
17
|
+
var __1 = require("../..");
|
|
18
|
+
var Field = function (props) {
|
|
19
|
+
var ref = (0, react_1.useRef)();
|
|
20
|
+
(0, __1.useSecureInput)(__assign(__assign({}, props), { ref: ref }));
|
|
21
|
+
return (0, jsx_runtime_1.jsx)("input", { ref: ref });
|
|
22
|
+
};
|
|
23
|
+
exports.Field = Field;
|
|
24
|
+
//# sourceMappingURL=Field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../src/components/Field/Field.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,2BAAsC;AAG/B,IAAM,KAAK,GAAG,UAAC,KAAiB;IACrC,IAAM,GAAG,GAAG,IAAA,cAAM,GAAE,CAAA;IACpB,IAAA,kBAAc,wBAAM,KAAK,KAAE,GAAG,KAAA,IAAG,CAAA;IACjC,OAAO,kCAAO,GAAG,EAAE,GAAG,GAAI,CAAA;AAC5B,CAAC,CAAA;AAJY,QAAA,KAAK,SAIjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Field } from './Field';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Field = void 0;
|
|
4
|
+
var Field_1 = require("./Field");
|
|
5
|
+
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return Field_1.Field; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Field/index.ts"],"names":[],"mappings":";;;AAAA,iCAA+B;AAAtB,8FAAA,KAAK,OAAA"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { Config } from '../../types';
|
|
2
3
|
export declare type Props = {
|
|
3
4
|
children?: ReactNode;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
onCardVaultSuccess?: () => void;
|
|
7
|
-
ready?: () => void;
|
|
8
|
-
};
|
|
9
|
-
export declare const SecureFields: ({ children }: Props) => JSX.Element;
|
|
5
|
+
} & Config;
|
|
6
|
+
export declare const SecureFields: ({ children, ...config }: Props) => JSX.Element;
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
2
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
25
|
exports.SecureFields = void 0;
|
|
4
26
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
+
var use_secure_fields_1 = require("../../hooks/use-secure-fields");
|
|
5
28
|
var SecureFields = function (_a) {
|
|
6
|
-
var children = _a.children;
|
|
7
|
-
return (0, jsx_runtime_1.jsx)(
|
|
29
|
+
var children = _a.children, config = __rest(_a, ["children"]);
|
|
30
|
+
return (0, jsx_runtime_1.jsx)(use_secure_fields_1.SecureFieldsProvider, __assign({}, config, { children: children }));
|
|
8
31
|
};
|
|
9
32
|
exports.SecureFields = SecureFields;
|
|
10
33
|
//# sourceMappingURL=SecureFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecureFields.js","sourceRoot":"","sources":["../../../src/components/SecureFields/SecureFields.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SecureFields.js","sourceRoot":"","sources":["../../../src/components/SecureFields/SecureFields.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mEAAoE;AAO7D,IAAM,YAAY,GAAG,UAAC,EAA8B;IAA5B,IAAA,QAAQ,cAAA,EAAK,MAAM,cAArB,YAAuB,CAAF;IAChD,OAAO,uBAAC,wCAAoB,eAAK,MAAM,cAAG,QAAQ,IAAwB,CAAA;AAC5E,CAAC,CAAA;AAFY,QAAA,YAAY,gBAExB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
export declare const SecurityCode: (props:
|
|
2
|
+
import { Field as FieldProps } from '../../types';
|
|
3
|
+
export declare const SecurityCode: (props: Omit<FieldProps, 'type'>) => JSX.Element;
|
|
@@ -13,8 +13,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.SecurityCode = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var Field_1 = require("../Field");
|
|
16
17
|
var SecurityCode = function (props) {
|
|
17
|
-
return (0, jsx_runtime_1.jsx)(
|
|
18
|
+
return (0, jsx_runtime_1.jsx)(Field_1.Field, __assign({ type: "securityCode" }, props));
|
|
18
19
|
};
|
|
19
20
|
exports.SecurityCode = SecurityCode;
|
|
20
21
|
//# sourceMappingURL=SecurityCode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecurityCode.js","sourceRoot":"","sources":["../../../src/components/SecurityCode/SecurityCode.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"SecurityCode.js","sourceRoot":"","sources":["../../../src/components/SecurityCode/SecurityCode.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kCAAgC;AAEzB,IAAM,YAAY,GAAG,UAAC,KAA+B;IAC1D,OAAO,uBAAC,aAAK,aAAC,IAAI,EAAC,cAAc,IAAK,KAAK,EAAI,CAAA;AACjD,CAAC,CAAA;AAFY,QAAA,YAAY,gBAExB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SecureFields } from '@gr4vy/secure-fields';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { Config } from '../types';
|
|
4
|
+
export declare const SecureFieldsContext: import("react").Context<{
|
|
5
|
+
secureFields: SecureFields;
|
|
6
|
+
debug: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const SecureFieldsProvider: ({ children, ...config }: PropsWithChildren<Config>) => JSX.Element;
|
|
9
|
+
export declare const useSecureFields: () => {
|
|
10
|
+
secureFields: SecureFields;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.useSecureFields = exports.SecureFieldsProvider = exports.SecureFieldsContext = void 0;
|
|
26
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
+
var secure_fields_1 = require("@gr4vy/secure-fields");
|
|
28
|
+
var react_1 = require("react");
|
|
29
|
+
exports.SecureFieldsContext = (0, react_1.createContext)(null);
|
|
30
|
+
var SecureFieldsProvider = function (_a) {
|
|
31
|
+
var children = _a.children, config = __rest(_a, ["children"]);
|
|
32
|
+
var sessionId = config.sessionId, debug = config.debug, onReady = config.onReady, onCardVaultSuccess = config.onCardVaultSuccess, onCardVaultFailure = config.onCardVaultFailure;
|
|
33
|
+
var _b = (0, react_1.useState)(), secureFields = _b[0], setSecureFields = _b[1];
|
|
34
|
+
(0, react_1.useEffect)(function () {
|
|
35
|
+
setSecureFields(new secure_fields_1.SecureFields(config));
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, [sessionId]);
|
|
38
|
+
(0, react_1.useEffect)(function () {
|
|
39
|
+
secureFields === null || secureFields === void 0 ? void 0 : secureFields.setDebug(debug);
|
|
40
|
+
onReady &&
|
|
41
|
+
(secureFields === null || secureFields === void 0 ? void 0 : secureFields.addEventListener(secure_fields_1.SecureFields.Events.READY, onReady));
|
|
42
|
+
onCardVaultSuccess &&
|
|
43
|
+
(secureFields === null || secureFields === void 0 ? void 0 : secureFields.addEventListener(secure_fields_1.SecureFields.Events.CARD_VAULT_SUCCESS, onCardVaultSuccess));
|
|
44
|
+
onCardVaultFailure &&
|
|
45
|
+
(secureFields === null || secureFields === void 0 ? void 0 : secureFields.addEventListener(secure_fields_1.SecureFields.Events.CARD_VAULT_FAILURE, onCardVaultFailure));
|
|
46
|
+
return function () {
|
|
47
|
+
onReady &&
|
|
48
|
+
(secureFields === null || secureFields === void 0 ? void 0 : secureFields.removeEventListener(secure_fields_1.SecureFields.Events.READY, onReady));
|
|
49
|
+
onCardVaultSuccess &&
|
|
50
|
+
(secureFields === null || secureFields === void 0 ? void 0 : secureFields.removeEventListener(secure_fields_1.SecureFields.Events.CARD_VAULT_SUCCESS, onCardVaultSuccess));
|
|
51
|
+
onCardVaultFailure &&
|
|
52
|
+
(secureFields === null || secureFields === void 0 ? void 0 : secureFields.removeEventListener(secure_fields_1.SecureFields.Events.CARD_VAULT_FAILURE, onCardVaultFailure));
|
|
53
|
+
};
|
|
54
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
|
+
}, [secureFields]);
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(exports.SecureFieldsContext.Provider, __assign({ value: { secureFields: secureFields, debug: debug } }, { children: children })));
|
|
57
|
+
};
|
|
58
|
+
exports.SecureFieldsProvider = SecureFieldsProvider;
|
|
59
|
+
var useSecureFields = function () {
|
|
60
|
+
return (0, react_1.useContext)(exports.SecureFieldsContext);
|
|
61
|
+
};
|
|
62
|
+
exports.useSecureFields = useSecureFields;
|
|
63
|
+
//# sourceMappingURL=use-secure-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-secure-fields.js","sourceRoot":"","sources":["../../src/hooks/use-secure-fields.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAmD;AACnD,+BAMc;AAGD,QAAA,mBAAmB,GAAG,IAAA,qBAAa,EAG7C,IAAI,CAAC,CAAA;AAED,IAAM,oBAAoB,GAAG,UAAC,EAGT;IAF1B,IAAA,QAAQ,cAAA,EACL,MAAM,cAF0B,YAGpC,CADU;IAED,IAAA,SAAS,GACf,MAAM,UADS,EAAE,KAAK,GACtB,MAAM,MADgB,EAAE,OAAO,GAC/B,MAAM,QADyB,EAAE,kBAAkB,GACnD,MAAM,mBAD6C,EAAE,kBAAkB,GACvE,MAAM,mBADiE,CACjE;IACF,IAAA,KAAkC,IAAA,gBAAQ,GAAgB,EAAzD,YAAY,QAAA,EAAE,eAAe,QAA4B,CAAA;IAEhE,IAAA,iBAAS,EAAC;QACR,eAAe,CAAC,IAAI,4BAAY,CAAC,MAAM,CAAC,CAAC,CAAA;QACzC,uDAAuD;IACzD,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAEf,IAAA,iBAAS,EAAC;QACR,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC7B,OAAO;aACL,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,gBAAgB,CAAC,4BAAY,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA,CAAA;QAC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1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.useSecureInput = void 0;
|
|
26
|
+
var react_1 = require("react");
|
|
27
|
+
var use_secure_fields_1 = require("./use-secure-fields");
|
|
28
|
+
var addFieldFns = {
|
|
29
|
+
number: 'addCardNumberField',
|
|
30
|
+
expiryDate: 'addExpiryDateField',
|
|
31
|
+
securityCode: 'addSecurityCodeField',
|
|
32
|
+
};
|
|
33
|
+
var useSecureInput = function (options) {
|
|
34
|
+
var secureFields = (0, use_secure_fields_1.useSecureFields)().secureFields;
|
|
35
|
+
var _a = (0, react_1.useState)(), field = _a[0], setField = _a[1];
|
|
36
|
+
var ref = options.ref, type = options.type, onBlur = options.onBlur, onFocus = options.onFocus, onInput = options.onInput, rest = __rest(options, ["ref", "type", "onBlur", "onFocus", "onInput"]);
|
|
37
|
+
var addField = function (type) {
|
|
38
|
+
if (!secureFields || !(options === null || options === void 0 ? void 0 : options.ref) || field) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
return secureFields[addFieldFns[type]](ref.current, __assign({}, rest));
|
|
42
|
+
};
|
|
43
|
+
(0, react_1.useEffect)(function () {
|
|
44
|
+
setField(addField(options === null || options === void 0 ? void 0 : options.type));
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
}, [secureFields]);
|
|
47
|
+
(0, react_1.useEffect)(function () {
|
|
48
|
+
if (!field)
|
|
49
|
+
return;
|
|
50
|
+
onBlur && field.addEventListener('blur', onBlur);
|
|
51
|
+
onFocus && field.addEventListener('focus', onFocus);
|
|
52
|
+
onInput && field.addEventListener('input', onInput);
|
|
53
|
+
return function () {
|
|
54
|
+
onBlur && field.addEventListener('blur', onBlur);
|
|
55
|
+
onFocus && field.addEventListener('focus', onFocus);
|
|
56
|
+
onInput && field.addEventListener('input', onInput);
|
|
57
|
+
};
|
|
58
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
+
}, [secureFields, field]);
|
|
60
|
+
return field;
|
|
61
|
+
};
|
|
62
|
+
exports.useSecureInput = useSecureInput;
|
|
63
|
+
//# sourceMappingURL=use-secure-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-secure-input.js","sourceRoot":"","sources":["../../src/hooks/use-secure-input.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,+BAA2C;AAE3C,yDAAqD;AAErD,IAAM,WAAW,GAAG;IAClB,MAAM,EAAE,oBAAoB;IAC5B,UAAU,EAAE,oBAAoB;IAChC,YAAY,EAAE,sBAAsB;CACrC,CAAA;AAEM,IAAM,cAAc,GAAG,UAAC,OAAe;IACpC,IAAA,YAAY,GAAK,IAAA,mCAAe,GAAE,aAAtB,CAAsB;IACpC,IAAA,KAAoB,IAAA,gBAAQ,GAAe,EAA1C,KAAK,QAAA,EAAE,QAAQ,QAA2B,CAAA;IACzC,IAAA,GAAG,GAA8C,OAAO,IAArD,EAAE,IAAI,GAAw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,CAAA;IAEzB,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAjCY,QAAA,cAAc,kBAiC1B"}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export { CardNumber } from './components/CardNumber';
|
|
|
2
2
|
export { ExpiryDate } from './components/ExpiryDate';
|
|
3
3
|
export { SecureFields } from './components/SecureFields';
|
|
4
4
|
export { SecurityCode } from './components/SecurityCode';
|
|
5
|
+
export { useSecureFields } from './hooks/use-secure-fields';
|
|
6
|
+
export { useSecureInput } from './hooks/use-secure-input';
|
package/lib/index.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSecureInput = exports.useSecureFields = exports.SecurityCode = exports.SecureFields = exports.ExpiryDate = exports.CardNumber = void 0;
|
|
4
|
+
var CardNumber_1 = require("./components/CardNumber");
|
|
5
|
+
Object.defineProperty(exports, "CardNumber", { enumerable: true, get: function () { return CardNumber_1.CardNumber; } });
|
|
6
|
+
var ExpiryDate_1 = require("./components/ExpiryDate");
|
|
7
|
+
Object.defineProperty(exports, "ExpiryDate", { enumerable: true, get: function () { return ExpiryDate_1.ExpiryDate; } });
|
|
8
|
+
var SecureFields_1 = require("./components/SecureFields");
|
|
9
|
+
Object.defineProperty(exports, "SecureFields", { enumerable: true, get: function () { return SecureFields_1.SecureFields; } });
|
|
10
|
+
var SecurityCode_1 = require("./components/SecurityCode");
|
|
11
|
+
Object.defineProperty(exports, "SecurityCode", { enumerable: true, get: function () { return SecurityCode_1.SecurityCode; } });
|
|
12
|
+
var use_secure_fields_1 = require("./hooks/use-secure-fields");
|
|
13
|
+
Object.defineProperty(exports, "useSecureFields", { enumerable: true, get: function () { return use_secure_fields_1.useSecureFields; } });
|
|
14
|
+
var use_secure_input_1 = require("./hooks/use-secure-input");
|
|
15
|
+
Object.defineProperty(exports, "useSecureInput", { enumerable: true, get: function () { return use_secure_input_1.useSecureInput; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;AAAA,sDAAoD;AAA3C,wGAAA,UAAU,OAAA;AACnB,sDAAoD;AAA3C,wGAAA,UAAU,OAAA;AACnB,0DAAwD;AAA/C,4GAAA,YAAY,OAAA;AACrB,0DAAwD;AAA/C,4GAAA,YAAY,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;AAAA,sDAAoD;AAA3C,wGAAA,UAAU,OAAA;AACnB,sDAAoD;AAA3C,wGAAA,UAAU,OAAA;AACnB,0DAAwD;AAA/C,4GAAA,YAAY,OAAA;AACrB,0DAAwD;AAA/C,4GAAA,YAAY,OAAA;AACrB,+DAA2D;AAAlD,oHAAA,eAAe,OAAA;AACxB,6DAAyD;AAAhD,kHAAA,cAAc,OAAA"}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Config as BaseConfig, Field as BaseField } from '@gr4vy/secure-fields';
|
|
2
|
+
import { MutableRefObject } from 'react';
|
|
3
|
+
export declare type Config = BaseConfig & {
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
onReady?: (config: {
|
|
6
|
+
version: string;
|
|
7
|
+
} & BaseConfig) => void;
|
|
8
|
+
onCardVaultSuccess?: () => void;
|
|
9
|
+
onCardVaultFailure?: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare type Field = BaseField & {
|
|
12
|
+
ref?: MutableRefObject<HTMLElement>;
|
|
13
|
+
onBlur?: (data: any) => void;
|
|
14
|
+
onFocus?: (data: any) => void;
|
|
15
|
+
onInput?: (data: any) => void;
|
|
16
|
+
};
|
package/lib/types.js
ADDED
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gr4vy/secure-fields-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Gr4vy-hosted secure fields offering advanced theming, PCI compliance, event handling, and more.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"types": "lib/index",
|
|
@@ -18,12 +18,14 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "tsc
|
|
21
|
+
"build": "tsc",
|
|
22
22
|
"clean": "rm -rf lib *.tgz",
|
|
23
|
+
"dev": "TOKEN=$(yarn --silent token) webpack serve --config webpack.dev.js",
|
|
23
24
|
"lint": "eslint src --ext ts,tsx",
|
|
24
25
|
"prebuild": "yarn clean",
|
|
25
26
|
"prepack": "yarn build",
|
|
26
|
-
"test": "jest --colors"
|
|
27
|
+
"test": "jest --colors",
|
|
28
|
+
"token": "node ../secure-fields/generate-token"
|
|
27
29
|
},
|
|
28
30
|
"files": [
|
|
29
31
|
"lib",
|
|
@@ -36,14 +38,15 @@
|
|
|
36
38
|
"react-dom": ">=17.0.0"
|
|
37
39
|
},
|
|
38
40
|
"dependencies": {
|
|
39
|
-
"@gr4vy/secure-fields": "^0.
|
|
41
|
+
"@gr4vy/secure-fields": "^0.6.0"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
44
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
42
45
|
"react": "^17.0.2",
|
|
43
46
|
"react-dom": "^17.0.2"
|
|
44
47
|
},
|
|
45
48
|
"publishConfig": {
|
|
46
49
|
"access": "public"
|
|
47
50
|
},
|
|
48
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "be805ba6434d6c0941a06769d80d3bcddb5cf59e"
|
|
49
52
|
}
|