@notabene/javascript-sdk
Advanced tools
Comparing version 1.14.3 to 1.15.2
@@ -7,2 +7,18 @@ var $4mxld$jsxpragmatic = require("jsx-pragmatic"); | ||
} | ||
function $parcel$exportWildcard(dest, source) { | ||
Object.keys(source).forEach(function(key) { | ||
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) { | ||
return; | ||
} | ||
Object.defineProperty(dest, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return source[key]; | ||
} | ||
}); | ||
}); | ||
return dest; | ||
} | ||
function $parcel$interopDefault(a) { | ||
@@ -15,19 +31,76 @@ return a && a.__esModule ? a.default : a; | ||
let $fef5d623a19b12b5$export$7f2c168e71c689ea; | ||
(function($fef5d623a19b12b5$export$7f2c168e71c689ea) { | ||
$fef5d623a19b12b5$export$7f2c168e71c689ea["ALL"] = "ALL"; | ||
$fef5d623a19b12b5$export$7f2c168e71c689ea["VASP_2_VASP_ONLY"] = "VASP_2_VASP_ONLY"; | ||
$fef5d623a19b12b5$export$7f2c168e71c689ea["SELF_TRANSACTION_ONLY"] = "SELF_TRANSACTION_ONLY"; | ||
})($fef5d623a19b12b5$export$7f2c168e71c689ea || ($fef5d623a19b12b5$export$7f2c168e71c689ea = {})); | ||
let $fef5d623a19b12b5$export$1a2fd016dc0a19e9; | ||
(function($fef5d623a19b12b5$export$1a2fd016dc0a19e9) { | ||
$fef5d623a19b12b5$export$1a2fd016dc0a19e9["SIGNATURE"] = "SIGNATURE"; | ||
$fef5d623a19b12b5$export$1a2fd016dc0a19e9["DECLARATION"] = "DECLARATION"; | ||
$fef5d623a19b12b5$export$1a2fd016dc0a19e9["SIGNATURE_OR_DECLARATION"] = "SIGNATURE_OR_DECLARATION"; | ||
})($fef5d623a19b12b5$export$1a2fd016dc0a19e9 || ($fef5d623a19b12b5$export$1a2fd016dc0a19e9 = {})); | ||
const $fd25ee12f453fb93$var$generalProps = { | ||
vaspDID: { | ||
type: 'string', | ||
required: true | ||
}, | ||
transaction: { | ||
type: 'object', | ||
required: false | ||
}, | ||
error: { | ||
type: 'object', | ||
required: false | ||
}, | ||
onError: { | ||
type: 'function', | ||
required: true | ||
}, | ||
storeTransaction: { | ||
type: 'function', | ||
required: true | ||
}, | ||
theme: { | ||
type: 'object', | ||
required: false | ||
}, | ||
dictionary: { | ||
type: 'object', | ||
required: false | ||
}, | ||
transactionTypeAllowed: { | ||
type: 'string', | ||
required: false | ||
}, | ||
nonCustodialDeclarationType: { | ||
type: 'string', | ||
required: false | ||
}, | ||
beneficiaryDetails: { | ||
type: 'array', | ||
required: false | ||
} | ||
}; | ||
const $fd25ee12f453fb93$export$1aafbfc7f973e450 = { | ||
...$fd25ee12f453fb93$var$generalProps, | ||
onRequireAdditionalInformation: { | ||
type: 'function', | ||
required: true | ||
}, | ||
onValidStateChange: { | ||
type: 'function', | ||
required: true | ||
} | ||
}; | ||
const $fd25ee12f453fb93$export$73ab9d0d47d71b0c = { | ||
...$fd25ee12f453fb93$var$generalProps, | ||
close: { | ||
type: 'function' | ||
}, | ||
popupOpen: { | ||
type: 'boolean', | ||
required: true | ||
}, | ||
setPopupOpen: { | ||
type: 'function', | ||
required: true | ||
} | ||
}; | ||
class $fef5d623a19b12b5$export$2e2bcd8739ae039 { | ||
constructor(config){ | ||
this.config = config; | ||
this.config.nonCustodialDeclarationType = config.nonCustodialDeclarationType || $fef5d623a19b12b5$export$1a2fd016dc0a19e9.SIGNATURE; | ||
this.config.transactionTypeAllowed = config.transactionTypeAllowed || $fef5d623a19b12b5$export$7f2c168e71c689ea.ALL; | ||
this.config.nonCustodialDeclarationType = config.nonCustodialDeclarationType || 'SIGNATURE'; | ||
this.config.transactionTypeAllowed = config.transactionTypeAllowed || 'ALL'; | ||
this.widgetRendered = false; | ||
@@ -73,27 +146,2 @@ this.shouldBeDestroyed = false; | ||
setTransaction(tx) { | ||
const validProperties = [ | ||
'transactionAsset', | ||
'transactionAmount', | ||
'beneficiaryAccountNumber', | ||
'beneficiaryAccountNumber', | ||
'originatorVASPdid', | ||
'originatorDid', | ||
'transactionBlockchainInfo', | ||
'beneficiaryVASPname', | ||
'beneficiaryVASPdid', | ||
'beneficiaryName', | ||
'beneficiaryGeographicAddress', | ||
'beneficiaryNationalIdentification', | ||
'beneficiaryDateAndPlaceOfBirth', | ||
'beneficiaryPersonType', | ||
'beneficiaryDid', | ||
'isNonCustodial', | ||
'originatorEqualsBeneficiary', | ||
'beneficiaryProof', | ||
'isValid', | ||
'errors', | ||
]; | ||
if (tx) Object.keys(tx).forEach((key)=>{ | ||
if (!validProperties.includes(key)) throw new Error(`Notabene: Invalid transaction property ${key}`); | ||
}); | ||
this.tx = tx; | ||
@@ -149,52 +197,3 @@ if (this.widgetRendered) { | ||
}, | ||
props: { | ||
vaspDID: { | ||
type: 'string', | ||
required: true | ||
}, | ||
transaction: { | ||
type: 'object', | ||
required: false | ||
}, | ||
onRequireAdditionalInformation: { | ||
type: 'function', | ||
required: true | ||
}, | ||
onValidStateChange: { | ||
type: 'function', | ||
required: true | ||
}, | ||
error: { | ||
type: 'object', | ||
required: false | ||
}, | ||
onError: { | ||
type: 'function', | ||
required: true | ||
}, | ||
storeTransaction: { | ||
type: 'function', | ||
required: true | ||
}, | ||
theme: { | ||
type: 'object', | ||
required: false | ||
}, | ||
dictionary: { | ||
type: 'object', | ||
required: false | ||
}, | ||
transactionTypeAllowed: { | ||
type: 'string', | ||
required: false | ||
}, | ||
nonCustodialDeclarationType: { | ||
type: 'string', | ||
required: false | ||
}, | ||
beneficiaryDetails: { | ||
type: 'array', | ||
required: false | ||
} | ||
} | ||
props: $fd25ee12f453fb93$export$1aafbfc7f973e450 | ||
})({ | ||
@@ -249,55 +248,3 @@ vaspDID: this.config.vaspDID, | ||
}, | ||
props: { | ||
vaspDID: { | ||
type: 'string', | ||
required: true | ||
}, | ||
transaction: { | ||
type: 'object', | ||
required: false | ||
}, | ||
storeTransaction: { | ||
type: 'function', | ||
required: true | ||
}, | ||
close: { | ||
type: 'function' | ||
}, | ||
theme: { | ||
type: 'object', | ||
required: false | ||
}, | ||
dictionary: { | ||
type: 'object', | ||
required: false | ||
}, | ||
transactionTypeAllowed: { | ||
type: 'string', | ||
required: false | ||
}, | ||
nonCustodialDeclarationType: { | ||
type: 'string', | ||
required: false | ||
}, | ||
popupOpen: { | ||
type: 'boolean', | ||
required: true | ||
}, | ||
setPopupOpen: { | ||
type: 'function', | ||
required: true | ||
}, | ||
error: { | ||
type: 'object', | ||
required: false | ||
}, | ||
onError: { | ||
type: 'function', | ||
required: true | ||
}, | ||
beneficiaryDetails: { | ||
type: 'array', | ||
required: false | ||
} | ||
}, | ||
props: $fd25ee12f453fb93$export$73ab9d0d47d71b0c, | ||
containerTemplate: ({ uid: uid , doc: doc , frame: frame , prerenderFrame: prerenderFrame })=>{ | ||
@@ -323,3 +270,2 @@ return $4mxld$jsxpragmatic.node('div', { | ||
.nb-popup { | ||
max-width: 608px; | ||
width: 100%; | ||
@@ -381,3 +327,7 @@ height: 100%; | ||
var $48505191f6b4c91c$exports = {}; | ||
$parcel$exportWildcard(module.exports, $48505191f6b4c91c$exports); | ||
@@ -11,3 +11,3 @@ { | ||
"license": "MIT", | ||
"version": "1.14.3", | ||
"version": "1.15.2", | ||
"main": "dist/index.js", | ||
@@ -93,2 +93,3 @@ "packageManager": "yarn@3.2.1", | ||
"dependencies": { | ||
"@notabene/validation": "^1.8.0", | ||
"jsx-pragmatic": "^2.0.22", | ||
@@ -95,0 +96,0 @@ "zoid": "^9.0.86" |
@@ -75,4 +75,10 @@ <div align="center"> | ||
--- | ||
### Re-rendering | ||
**WARNING:** this shouldn't be used often, if you need to change the transaction's initial fields call `setTransaction` again. (This should be used only for tearing down the component). | ||
The container of the widget must be in the DOM before calling `destroyWidget` or `renderWidget`. | ||
If you need to close and re-render the widget, call the `destroyWidget` method like so: | ||
@@ -170,5 +176,12 @@ | ||
- `beneficiaryGeographicAddress` - Recipient Address | ||
- `beneficiaryNationalIdentification` - Recipient National Identification | ||
- `beneficiaryDateAndPlaceOfBirth` - Recipient Date and Place of Birth | ||
```js | ||
beneficiaryDetails: ['benficiaryName', 'beneficiaryGeographicAddress']; | ||
beneficiaryDetails: [ | ||
'benficiaryName', | ||
'beneficiaryGeographicAddress', | ||
'beneficiaryNationalIdentification', | ||
'beneficiaryDateAndPlaceOfBirth', | ||
]; | ||
``` | ||
@@ -175,0 +188,0 @@ |
export { default as Notabene } from '../notabene'; | ||
export * from '../types'; |
import Notabene from '../notabene'; | ||
export * from '../types'; | ||
@@ -3,0 +4,0 @@ declare global { |
// @ts-ignore | ||
import { dom, node } from 'jsx-pragmatic'; | ||
import { | ||
NonCustodialDeclarationType, | ||
Theme, | ||
Transaction, | ||
TransactionTypeAllowed, | ||
} from './types'; | ||
// @ts-ignore | ||
import zoid, { destroy } from 'zoid'; | ||
import { popupProps, widgetProps } from './zoidComponentProps'; | ||
export interface Theme { | ||
primaryColor: string; | ||
secondaryColor: string; | ||
fontFamily: string; | ||
logo: string; | ||
} | ||
export enum TransactionTypeAllowed { | ||
ALL = 'ALL', | ||
VASP_2_VASP_ONLY = 'VASP_2_VASP_ONLY', | ||
SELF_TRANSACTION_ONLY = 'SELF_TRANSACTION_ONLY', | ||
} | ||
export enum NonCustodialDeclarationType { | ||
SIGNATURE = 'SIGNATURE', | ||
DECLARATION = 'DECLARATION', | ||
SIGNATURE_OR_DECLARATION = 'SIGNATURE_OR_DECLARATION', | ||
} | ||
interface NotabeneConfig { | ||
@@ -39,30 +27,2 @@ widget: string; | ||
export interface OwnershipProofInput { | ||
type?: string | null; | ||
proof?: string | null; | ||
} | ||
export interface TransactionBlockchainInfo { | ||
destination?: string | null; | ||
} | ||
interface Transaction { | ||
transactionAsset: string; | ||
transactionAmount: string; | ||
beneficiaryAccountNumber: string; | ||
originatorVASPdid?: string; | ||
originatorDid?: string; | ||
transactionBlockchainInfo?: TransactionBlockchainInfo; | ||
beneficiaryVASPname?: string; | ||
beneficiaryName?: string; | ||
beneficiaryGeographicAddress?: string; | ||
beneficiaryNationalIdentification?: string; | ||
beneficiaryDateAndPlaceOfBirth?: string; | ||
beneficiaryDid?: string; | ||
isNonCustodial?: boolean; | ||
originatorEqualsBeneficiary?: boolean; | ||
beneficiaryProof?: OwnershipProofInput; | ||
isValid?: boolean; | ||
errors?: string[]; | ||
} | ||
export default class Notabene { | ||
@@ -81,6 +41,4 @@ private widget: zoid.ZoidComponent; | ||
this.config.nonCustodialDeclarationType = | ||
config.nonCustodialDeclarationType || | ||
NonCustodialDeclarationType.SIGNATURE; | ||
this.config.transactionTypeAllowed = | ||
config.transactionTypeAllowed || TransactionTypeAllowed.ALL; | ||
config.nonCustodialDeclarationType || 'SIGNATURE'; | ||
this.config.transactionTypeAllowed = config.transactionTypeAllowed || 'ALL'; | ||
this.widgetRendered = false; | ||
@@ -136,31 +94,2 @@ this.shouldBeDestroyed = false; | ||
public setTransaction(tx: Transaction) { | ||
const validProperties = [ | ||
'transactionAsset', | ||
'transactionAmount', | ||
'beneficiaryAccountNumber', | ||
'beneficiaryAccountNumber', | ||
'originatorVASPdid', | ||
'originatorDid', | ||
'transactionBlockchainInfo', | ||
'beneficiaryVASPname', | ||
'beneficiaryVASPdid', | ||
'beneficiaryName', | ||
'beneficiaryGeographicAddress', | ||
'beneficiaryNationalIdentification', | ||
'beneficiaryDateAndPlaceOfBirth', | ||
'beneficiaryPersonType', | ||
'beneficiaryDid', | ||
'isNonCustodial', | ||
'originatorEqualsBeneficiary', | ||
'beneficiaryProof', | ||
'isValid', | ||
'errors', | ||
]; | ||
if (tx) { | ||
Object.keys(tx).forEach((key) => { | ||
if (!validProperties.includes(key)) { | ||
throw new Error(`Notabene: Invalid transaction property ${key}`); | ||
} | ||
}); | ||
} | ||
this.tx = tx; | ||
@@ -222,52 +151,3 @@ if (this.widgetRendered) { | ||
}, | ||
props: { | ||
vaspDID: { | ||
type: 'string', | ||
required: true, | ||
}, | ||
transaction: { | ||
type: 'object', | ||
required: false, | ||
}, | ||
onRequireAdditionalInformation: { | ||
type: 'function', | ||
required: true, | ||
}, | ||
onValidStateChange: { | ||
type: 'function', | ||
required: true, | ||
}, | ||
error: { | ||
type: 'object', | ||
required: false, | ||
}, | ||
onError: { | ||
type: 'function', | ||
required: true, | ||
}, | ||
storeTransaction: { | ||
type: 'function', | ||
required: true, | ||
}, | ||
theme: { | ||
type: 'object', | ||
required: false, | ||
}, | ||
dictionary: { | ||
type: 'object', | ||
required: false, | ||
}, | ||
transactionTypeAllowed: { | ||
type: 'string', | ||
required: false, | ||
}, | ||
nonCustodialDeclarationType: { | ||
type: 'string', | ||
required: false, | ||
}, | ||
beneficiaryDetails: { | ||
type: 'array', | ||
required: false, | ||
}, | ||
}, | ||
props: widgetProps, | ||
})({ | ||
@@ -326,55 +206,3 @@ vaspDID: this.config.vaspDID, | ||
}, | ||
props: { | ||
vaspDID: { | ||
type: 'string', | ||
required: true, | ||
}, | ||
transaction: { | ||
type: 'object', | ||
required: false, | ||
}, | ||
storeTransaction: { | ||
type: 'function', | ||
required: true, | ||
}, | ||
close: { | ||
type: 'function', | ||
}, | ||
theme: { | ||
type: 'object', | ||
required: false, | ||
}, | ||
dictionary: { | ||
type: 'object', | ||
required: false, | ||
}, | ||
transactionTypeAllowed: { | ||
type: 'string', | ||
required: false, | ||
}, | ||
nonCustodialDeclarationType: { | ||
type: 'string', | ||
required: false, | ||
}, | ||
popupOpen: { | ||
type: 'boolean', | ||
required: true, | ||
}, | ||
setPopupOpen: { | ||
type: 'function', | ||
required: true, | ||
}, | ||
error: { | ||
type: 'object', | ||
required: false, | ||
}, | ||
onError: { | ||
type: 'function', | ||
required: true, | ||
}, | ||
beneficiaryDetails: { | ||
type: 'array', | ||
required: false, | ||
}, | ||
}, | ||
props: popupProps, | ||
containerTemplate: ({ uid, doc, frame, prerenderFrame }: any) => { | ||
@@ -403,3 +231,2 @@ return node( | ||
.nb-popup { | ||
max-width: 608px; | ||
width: 100%; | ||
@@ -406,0 +233,0 @@ height: 100%; |
@@ -13,2 +13,3 @@ { | ||
"baseUrl": "src", | ||
"resolveJsonModule": true, | ||
"lib": ["dom", "es2016"] | ||
@@ -15,0 +16,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
153004
29
1055
205
3
+ Added@notabene/validation@^1.8.0