@medipass/web-sdk 13.0.0 → 13.0.1
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/dist/_virtual/rolldown_runtime.js +1 -25
- package/dist/index.js +14 -17
- package/dist/index.js.map +1 -1
- package/dist/resources/accounts.js +4 -5
- package/dist/resources/accounts.js.map +1 -1
- package/dist/resources/auth.js +5 -7
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/devices.js +5 -6
- package/dist/resources/devices.js.map +1 -1
- package/dist/resources/members.js +4 -5
- package/dist/resources/members.js.map +1 -1
- package/dist/resources/payments.js +3 -4
- package/dist/resources/payments.js.map +1 -1
- package/dist/resources/self-checkout-sessions.js +8 -9
- package/dist/resources/self-checkout-sessions.js.map +1 -1
- package/dist/services/storage.js +5 -9
- package/dist/services/storage.js.map +1 -1
- package/dist/services/version.js +8 -10
- package/dist/services/version.js.map +1 -1
- package/dist/utils/does-param-exist.js +2 -4
- package/dist/utils/does-param-exist.js.map +1 -1
- package/dist/utils/professions.js +5 -7
- package/dist/utils/professions.js.map +1 -1
- package/dist/utils/request.js +3 -5
- package/dist/utils/request.js.map +1 -1
- package/dist/utils/staff.js +6 -8
- package/dist/utils/staff.js.map +1 -1
- package/package.json +10 -12
- package/dist/node_modules/compare-versions/index.js +0 -60
- package/dist/node_modules/compare-versions/index.js.map +0 -1
- package/dist/node_modules/jwt-decode/build/esm/index.js +0 -50
- package/dist/node_modules/jwt-decode/build/esm/index.js.map +0 -1
- package/dist/node_modules/lodash/_DataView.js +0 -15
- package/dist/node_modules/lodash/_DataView.js.map +0 -1
- package/dist/node_modules/lodash/_Hash.js +0 -38
- package/dist/node_modules/lodash/_Hash.js.map +0 -1
- package/dist/node_modules/lodash/_ListCache.js +0 -38
- package/dist/node_modules/lodash/_ListCache.js.map +0 -1
- package/dist/node_modules/lodash/_Map.js +0 -15
- package/dist/node_modules/lodash/_Map.js.map +0 -1
- package/dist/node_modules/lodash/_MapCache.js +0 -38
- package/dist/node_modules/lodash/_MapCache.js.map +0 -1
- package/dist/node_modules/lodash/_Promise.js +0 -15
- package/dist/node_modules/lodash/_Promise.js.map +0 -1
- package/dist/node_modules/lodash/_Set.js +0 -15
- package/dist/node_modules/lodash/_Set.js.map +0 -1
- package/dist/node_modules/lodash/_SetCache.js +0 -31
- package/dist/node_modules/lodash/_SetCache.js.map +0 -1
- package/dist/node_modules/lodash/_Stack.js +0 -34
- package/dist/node_modules/lodash/_Stack.js.map +0 -1
- package/dist/node_modules/lodash/_Symbol.js +0 -15
- package/dist/node_modules/lodash/_Symbol.js.map +0 -1
- package/dist/node_modules/lodash/_Uint8Array.js +0 -15
- package/dist/node_modules/lodash/_Uint8Array.js.map +0 -1
- package/dist/node_modules/lodash/_WeakMap.js +0 -15
- package/dist/node_modules/lodash/_WeakMap.js.map +0 -1
- package/dist/node_modules/lodash/_apply.js +0 -31
- package/dist/node_modules/lodash/_apply.js.map +0 -1
- package/dist/node_modules/lodash/_arrayFilter.js +0 -29
- package/dist/node_modules/lodash/_arrayFilter.js.map +0 -1
- package/dist/node_modules/lodash/_arrayIncludes.js +0 -26
- package/dist/node_modules/lodash/_arrayIncludes.js.map +0 -1
- package/dist/node_modules/lodash/_arrayIncludesWith.js +0 -26
- package/dist/node_modules/lodash/_arrayIncludesWith.js.map +0 -1
- package/dist/node_modules/lodash/_arrayLikeKeys.js +0 -34
- package/dist/node_modules/lodash/_arrayLikeKeys.js.map +0 -1
- package/dist/node_modules/lodash/_arrayMap.js +0 -26
- package/dist/node_modules/lodash/_arrayMap.js.map +0 -1
- package/dist/node_modules/lodash/_arrayPush.js +0 -25
- package/dist/node_modules/lodash/_arrayPush.js.map +0 -1
- package/dist/node_modules/lodash/_arraySome.js +0 -27
- package/dist/node_modules/lodash/_arraySome.js.map +0 -1
- package/dist/node_modules/lodash/_assignMergeValue.js +0 -27
- package/dist/node_modules/lodash/_assignMergeValue.js.map +0 -1
- package/dist/node_modules/lodash/_assignValue.js +0 -31
- package/dist/node_modules/lodash/_assignValue.js.map +0 -1
- package/dist/node_modules/lodash/_assocIndexOf.js +0 -27
- package/dist/node_modules/lodash/_assocIndexOf.js.map +0 -1
- package/dist/node_modules/lodash/_baseAssignValue.js +0 -32
- package/dist/node_modules/lodash/_baseAssignValue.js.map +0 -1
- package/dist/node_modules/lodash/_baseCreate.js +0 -35
- package/dist/node_modules/lodash/_baseCreate.js.map +0 -1
- package/dist/node_modules/lodash/_baseFindIndex.js +0 -28
- package/dist/node_modules/lodash/_baseFindIndex.js.map +0 -1
- package/dist/node_modules/lodash/_baseFlatten.js +0 -38
- package/dist/node_modules/lodash/_baseFlatten.js.map +0 -1
- package/dist/node_modules/lodash/_baseFor.js +0 -25
- package/dist/node_modules/lodash/_baseFor.js.map +0 -1
- package/dist/node_modules/lodash/_baseForOwn.js +0 -26
- package/dist/node_modules/lodash/_baseForOwn.js.map +0 -1
- package/dist/node_modules/lodash/_baseGet.js +0 -29
- package/dist/node_modules/lodash/_baseGet.js.map +0 -1
- package/dist/node_modules/lodash/_baseGetAllKeys.js +0 -30
- package/dist/node_modules/lodash/_baseGetAllKeys.js.map +0 -1
- package/dist/node_modules/lodash/_baseGetTag.js +0 -31
- package/dist/node_modules/lodash/_baseGetTag.js.map +0 -1
- package/dist/node_modules/lodash/_baseHasIn.js +0 -23
- package/dist/node_modules/lodash/_baseHasIn.js.map +0 -1
- package/dist/node_modules/lodash/_baseIndexOf.js +0 -28
- package/dist/node_modules/lodash/_baseIndexOf.js.map +0 -1
- package/dist/node_modules/lodash/_baseIsArguments.js +0 -27
- package/dist/node_modules/lodash/_baseIsArguments.js.map +0 -1
- package/dist/node_modules/lodash/_baseIsEqual.js +0 -34
- package/dist/node_modules/lodash/_baseIsEqual.js.map +0 -1
- package/dist/node_modules/lodash/_baseIsEqualDeep.js +0 -67
- package/dist/node_modules/lodash/_baseIsEqualDeep.js.map +0 -1
- package/dist/node_modules/lodash/_baseIsMatch.js +0 -48
- package/dist/node_modules/lodash/_baseIsMatch.js.map +0 -1
- package/dist/node_modules/lodash/_baseIsNaN.js +0 -22
- package/dist/node_modules/lodash/_baseIsNaN.js.map +0 -1
- package/dist/node_modules/lodash/_baseIsNative.js +0 -44
- package/dist/node_modules/lodash/_baseIsNative.js.map +0 -1
- package/dist/node_modules/lodash/_baseIsTypedArray.js +0 -33
- package/dist/node_modules/lodash/_baseIsTypedArray.js.map +0 -1
- package/dist/node_modules/lodash/_baseIteratee.js +0 -31
- package/dist/node_modules/lodash/_baseIteratee.js.map +0 -1
- package/dist/node_modules/lodash/_baseKeys.js +0 -30
- package/dist/node_modules/lodash/_baseKeys.js.map +0 -1
- package/dist/node_modules/lodash/_baseKeysIn.js +0 -31
- package/dist/node_modules/lodash/_baseKeysIn.js.map +0 -1
- package/dist/node_modules/lodash/_baseMatches.js +0 -30
- package/dist/node_modules/lodash/_baseMatches.js.map +0 -1
- package/dist/node_modules/lodash/_baseMatchesProperty.js +0 -37
- package/dist/node_modules/lodash/_baseMatchesProperty.js.map +0 -1
- package/dist/node_modules/lodash/_baseMerge.js +0 -43
- package/dist/node_modules/lodash/_baseMerge.js.map +0 -1
- package/dist/node_modules/lodash/_baseMergeDeep.js +0 -76
- package/dist/node_modules/lodash/_baseMergeDeep.js.map +0 -1
- package/dist/node_modules/lodash/_basePickBy.js +0 -33
- package/dist/node_modules/lodash/_basePickBy.js.map +0 -1
- package/dist/node_modules/lodash/_baseProperty.js +0 -24
- package/dist/node_modules/lodash/_baseProperty.js.map +0 -1
- package/dist/node_modules/lodash/_basePropertyDeep.js +0 -26
- package/dist/node_modules/lodash/_basePropertyDeep.js.map +0 -1
- package/dist/node_modules/lodash/_baseRest.js +0 -27
- package/dist/node_modules/lodash/_baseRest.js.map +0 -1
- package/dist/node_modules/lodash/_baseSet.js +0 -45
- package/dist/node_modules/lodash/_baseSet.js.map +0 -1
- package/dist/node_modules/lodash/_baseSetToString.js +0 -32
- package/dist/node_modules/lodash/_baseSetToString.js.map +0 -1
- package/dist/node_modules/lodash/_baseTimes.js +0 -26
- package/dist/node_modules/lodash/_baseTimes.js.map +0 -1
- package/dist/node_modules/lodash/_baseToString.js +0 -36
- package/dist/node_modules/lodash/_baseToString.js.map +0 -1
- package/dist/node_modules/lodash/_baseUnary.js +0 -24
- package/dist/node_modules/lodash/_baseUnary.js.map +0 -1
- package/dist/node_modules/lodash/_baseUniq.js +0 -57
- package/dist/node_modules/lodash/_baseUniq.js.map +0 -1
- package/dist/node_modules/lodash/_cacheHas.js +0 -23
- package/dist/node_modules/lodash/_cacheHas.js.map +0 -1
- package/dist/node_modules/lodash/_castFunction.js +0 -24
- package/dist/node_modules/lodash/_castFunction.js.map +0 -1
- package/dist/node_modules/lodash/_castPath.js +0 -29
- package/dist/node_modules/lodash/_castPath.js.map +0 -1
- package/dist/node_modules/lodash/_cloneArrayBuffer.js +0 -26
- package/dist/node_modules/lodash/_cloneArrayBuffer.js.map +0 -1
- package/dist/node_modules/lodash/_cloneBuffer.js +0 -34
- package/dist/node_modules/lodash/_cloneBuffer.js.map +0 -1
- package/dist/node_modules/lodash/_cloneTypedArray.js +0 -26
- package/dist/node_modules/lodash/_cloneTypedArray.js.map +0 -1
- package/dist/node_modules/lodash/_copyArray.js +0 -26
- package/dist/node_modules/lodash/_copyArray.js.map +0 -1
- package/dist/node_modules/lodash/_copyObject.js +0 -38
- package/dist/node_modules/lodash/_copyObject.js.map +0 -1
- package/dist/node_modules/lodash/_coreJsData.js +0 -15
- package/dist/node_modules/lodash/_coreJsData.js.map +0 -1
- package/dist/node_modules/lodash/_createAssigner.js +0 -38
- package/dist/node_modules/lodash/_createAssigner.js.map +0 -1
- package/dist/node_modules/lodash/_createBaseFor.js +0 -29
- package/dist/node_modules/lodash/_createBaseFor.js.map +0 -1
- package/dist/node_modules/lodash/_createSet.js +0 -26
- package/dist/node_modules/lodash/_createSet.js.map +0 -1
- package/dist/node_modules/lodash/_defineProperty.js +0 -21
- package/dist/node_modules/lodash/_defineProperty.js.map +0 -1
- package/dist/node_modules/lodash/_equalArrays.js +0 -64
- package/dist/node_modules/lodash/_equalArrays.js.map +0 -1
- package/dist/node_modules/lodash/_equalByTag.js +0 -74
- package/dist/node_modules/lodash/_equalByTag.js.map +0 -1
- package/dist/node_modules/lodash/_equalObjects.js +0 -64
- package/dist/node_modules/lodash/_equalObjects.js.map +0 -1
- package/dist/node_modules/lodash/_freeGlobal.js +0 -14
- package/dist/node_modules/lodash/_freeGlobal.js.map +0 -1
- package/dist/node_modules/lodash/_getAllKeys.js +0 -26
- package/dist/node_modules/lodash/_getAllKeys.js.map +0 -1
- package/dist/node_modules/lodash/_getAllKeysIn.js +0 -27
- package/dist/node_modules/lodash/_getAllKeysIn.js.map +0 -1
- package/dist/node_modules/lodash/_getMapData.js +0 -26
- package/dist/node_modules/lodash/_getMapData.js.map +0 -1
- package/dist/node_modules/lodash/_getMatchData.js +0 -34
- package/dist/node_modules/lodash/_getMatchData.js.map +0 -1
- package/dist/node_modules/lodash/_getNative.js +0 -27
- package/dist/node_modules/lodash/_getNative.js.map +0 -1
- package/dist/node_modules/lodash/_getPrototype.js +0 -15
- package/dist/node_modules/lodash/_getPrototype.js.map +0 -1
- package/dist/node_modules/lodash/_getRawTag.js +0 -44
- package/dist/node_modules/lodash/_getRawTag.js.map +0 -1
- package/dist/node_modules/lodash/_getSymbols.js +0 -32
- package/dist/node_modules/lodash/_getSymbols.js.map +0 -1
- package/dist/node_modules/lodash/_getSymbolsIn.js +0 -32
- package/dist/node_modules/lodash/_getSymbolsIn.js.map +0 -1
- package/dist/node_modules/lodash/_getTag.js +0 -44
- package/dist/node_modules/lodash/_getTag.js.map +0 -1
- package/dist/node_modules/lodash/_getValue.js +0 -23
- package/dist/node_modules/lodash/_getValue.js.map +0 -1
- package/dist/node_modules/lodash/_hasPath.js +0 -40
- package/dist/node_modules/lodash/_hasPath.js.map +0 -1
- package/dist/node_modules/lodash/_hashClear.js +0 -25
- package/dist/node_modules/lodash/_hashClear.js.map +0 -1
- package/dist/node_modules/lodash/_hashDelete.js +0 -27
- package/dist/node_modules/lodash/_hashDelete.js.map +0 -1
- package/dist/node_modules/lodash/_hashGet.js +0 -35
- package/dist/node_modules/lodash/_hashGet.js.map +0 -1
- package/dist/node_modules/lodash/_hashHas.js +0 -29
- package/dist/node_modules/lodash/_hashHas.js.map +0 -1
- package/dist/node_modules/lodash/_hashSet.js +0 -32
- package/dist/node_modules/lodash/_hashSet.js.map +0 -1
- package/dist/node_modules/lodash/_initCloneObject.js +0 -26
- package/dist/node_modules/lodash/_initCloneObject.js.map +0 -1
- package/dist/node_modules/lodash/_isFlattenable.js +0 -28
- package/dist/node_modules/lodash/_isFlattenable.js.map +0 -1
- package/dist/node_modules/lodash/_isIndex.js +0 -29
- package/dist/node_modules/lodash/_isIndex.js.map +0 -1
- package/dist/node_modules/lodash/_isIterateeCall.js +0 -33
- package/dist/node_modules/lodash/_isIterateeCall.js.map +0 -1
- package/dist/node_modules/lodash/_isKey.js +0 -31
- package/dist/node_modules/lodash/_isKey.js.map +0 -1
- package/dist/node_modules/lodash/_isKeyable.js +0 -23
- package/dist/node_modules/lodash/_isKeyable.js.map +0 -1
- package/dist/node_modules/lodash/_isMasked.js +0 -29
- package/dist/node_modules/lodash/_isMasked.js.map +0 -1
- package/dist/node_modules/lodash/_isPrototype.js +0 -25
- package/dist/node_modules/lodash/_isPrototype.js.map +0 -1
- package/dist/node_modules/lodash/_isStrictComparable.js +0 -25
- package/dist/node_modules/lodash/_isStrictComparable.js.map +0 -1
- package/dist/node_modules/lodash/_listCacheClear.js +0 -23
- package/dist/node_modules/lodash/_listCacheClear.js.map +0 -1
- package/dist/node_modules/lodash/_listCacheDelete.js +0 -33
- package/dist/node_modules/lodash/_listCacheDelete.js.map +0 -1
- package/dist/node_modules/lodash/_listCacheGet.js +0 -27
- package/dist/node_modules/lodash/_listCacheGet.js.map +0 -1
- package/dist/node_modules/lodash/_listCacheHas.js +0 -26
- package/dist/node_modules/lodash/_listCacheHas.js.map +0 -1
- package/dist/node_modules/lodash/_listCacheSet.js +0 -32
- package/dist/node_modules/lodash/_listCacheSet.js.map +0 -1
- package/dist/node_modules/lodash/_mapCacheClear.js +0 -31
- package/dist/node_modules/lodash/_mapCacheClear.js.map +0 -1
- package/dist/node_modules/lodash/_mapCacheDelete.js +0 -28
- package/dist/node_modules/lodash/_mapCacheDelete.js.map +0 -1
- package/dist/node_modules/lodash/_mapCacheGet.js +0 -26
- package/dist/node_modules/lodash/_mapCacheGet.js.map +0 -1
- package/dist/node_modules/lodash/_mapCacheHas.js +0 -26
- package/dist/node_modules/lodash/_mapCacheHas.js.map +0 -1
- package/dist/node_modules/lodash/_mapCacheSet.js +0 -30
- package/dist/node_modules/lodash/_mapCacheSet.js.map +0 -1
- package/dist/node_modules/lodash/_mapToArray.js +0 -26
- package/dist/node_modules/lodash/_mapToArray.js.map +0 -1
- package/dist/node_modules/lodash/_matchesStrictComparable.js +0 -27
- package/dist/node_modules/lodash/_matchesStrictComparable.js.map +0 -1
- package/dist/node_modules/lodash/_memoizeCapped.js +0 -32
- package/dist/node_modules/lodash/_memoizeCapped.js.map +0 -1
- package/dist/node_modules/lodash/_nativeCreate.js +0 -14
- package/dist/node_modules/lodash/_nativeCreate.js.map +0 -1
- package/dist/node_modules/lodash/_nativeKeys.js +0 -14
- package/dist/node_modules/lodash/_nativeKeys.js.map +0 -1
- package/dist/node_modules/lodash/_nativeKeysIn.js +0 -26
- package/dist/node_modules/lodash/_nativeKeysIn.js.map +0 -1
- package/dist/node_modules/lodash/_nodeUtil.js +0 -28
- package/dist/node_modules/lodash/_nodeUtil.js.map +0 -1
- package/dist/node_modules/lodash/_objectToString.js +0 -28
- package/dist/node_modules/lodash/_objectToString.js.map +0 -1
- package/dist/node_modules/lodash/_overArg.js +0 -25
- package/dist/node_modules/lodash/_overArg.js.map +0 -1
- package/dist/node_modules/lodash/_overRest.js +0 -36
- package/dist/node_modules/lodash/_overRest.js.map +0 -1
- package/dist/node_modules/lodash/_root.js +0 -18
- package/dist/node_modules/lodash/_root.js.map +0 -1
- package/dist/node_modules/lodash/_safeGet.js +0 -25
- package/dist/node_modules/lodash/_safeGet.js.map +0 -1
- package/dist/node_modules/lodash/_setCacheAdd.js +0 -28
- package/dist/node_modules/lodash/_setCacheAdd.js.map +0 -1
- package/dist/node_modules/lodash/_setCacheHas.js +0 -24
- package/dist/node_modules/lodash/_setCacheHas.js.map +0 -1
- package/dist/node_modules/lodash/_setToArray.js +0 -26
- package/dist/node_modules/lodash/_setToArray.js.map +0 -1
- package/dist/node_modules/lodash/_setToString.js +0 -24
- package/dist/node_modules/lodash/_setToString.js.map +0 -1
- package/dist/node_modules/lodash/_shortOut.js +0 -35
- package/dist/node_modules/lodash/_shortOut.js.map +0 -1
- package/dist/node_modules/lodash/_stackClear.js +0 -25
- package/dist/node_modules/lodash/_stackClear.js.map +0 -1
- package/dist/node_modules/lodash/_stackDelete.js +0 -26
- package/dist/node_modules/lodash/_stackDelete.js.map +0 -1
- package/dist/node_modules/lodash/_stackGet.js +0 -24
- package/dist/node_modules/lodash/_stackGet.js.map +0 -1
- package/dist/node_modules/lodash/_stackHas.js +0 -24
- package/dist/node_modules/lodash/_stackHas.js.map +0 -1
- package/dist/node_modules/lodash/_stackSet.js +0 -43
- package/dist/node_modules/lodash/_stackSet.js.map +0 -1
- package/dist/node_modules/lodash/_strictIndexOf.js +0 -27
- package/dist/node_modules/lodash/_strictIndexOf.js.map +0 -1
- package/dist/node_modules/lodash/_stringToPath.js +0 -33
- package/dist/node_modules/lodash/_stringToPath.js.map +0 -1
- package/dist/node_modules/lodash/_toKey.js +0 -28
- package/dist/node_modules/lodash/_toKey.js.map +0 -1
- package/dist/node_modules/lodash/_toSource.js +0 -32
- package/dist/node_modules/lodash/_toSource.js.map +0 -1
- package/dist/node_modules/lodash/constant.js +0 -36
- package/dist/node_modules/lodash/constant.js.map +0 -1
- package/dist/node_modules/lodash/eq.js +0 -47
- package/dist/node_modules/lodash/eq.js.map +0 -1
- package/dist/node_modules/lodash/flatten.js +0 -31
- package/dist/node_modules/lodash/flatten.js.map +0 -1
- package/dist/node_modules/lodash/forOwn.js +0 -46
- package/dist/node_modules/lodash/forOwn.js.map +0 -1
- package/dist/node_modules/lodash/get.js +0 -43
- package/dist/node_modules/lodash/get.js.map +0 -1
- package/dist/node_modules/lodash/hasIn.js +0 -44
- package/dist/node_modules/lodash/hasIn.js.map +0 -1
- package/dist/node_modules/lodash/identity.js +0 -31
- package/dist/node_modules/lodash/identity.js.map +0 -1
- package/dist/node_modules/lodash/isArguments.js +0 -44
- package/dist/node_modules/lodash/isArguments.js.map +0 -1
- package/dist/node_modules/lodash/isArray.js +0 -36
- package/dist/node_modules/lodash/isArray.js.map +0 -1
- package/dist/node_modules/lodash/isArrayLike.js +0 -43
- package/dist/node_modules/lodash/isArrayLike.js.map +0 -1
- package/dist/node_modules/lodash/isArrayLikeObject.js +0 -43
- package/dist/node_modules/lodash/isArrayLikeObject.js.map +0 -1
- package/dist/node_modules/lodash/isBuffer.js +0 -39
- package/dist/node_modules/lodash/isBuffer.js.map +0 -1
- package/dist/node_modules/lodash/isEmpty.js +0 -67
- package/dist/node_modules/lodash/isEmpty.js.map +0 -1
- package/dist/node_modules/lodash/isFunction.js +0 -39
- package/dist/node_modules/lodash/isFunction.js.map +0 -1
- package/dist/node_modules/lodash/isLength.js +0 -43
- package/dist/node_modules/lodash/isLength.js.map +0 -1
- package/dist/node_modules/lodash/isObject.js +0 -41
- package/dist/node_modules/lodash/isObject.js.map +0 -1
- package/dist/node_modules/lodash/isObjectLike.js +0 -39
- package/dist/node_modules/lodash/isObjectLike.js.map +0 -1
- package/dist/node_modules/lodash/isPlainObject.js +0 -61
- package/dist/node_modules/lodash/isPlainObject.js.map +0 -1
- package/dist/node_modules/lodash/isSymbol.js +0 -37
- package/dist/node_modules/lodash/isSymbol.js.map +0 -1
- package/dist/node_modules/lodash/isTypedArray.js +0 -35
- package/dist/node_modules/lodash/isTypedArray.js.map +0 -1
- package/dist/node_modules/lodash/keys.js +0 -47
- package/dist/node_modules/lodash/keys.js.map +0 -1
- package/dist/node_modules/lodash/keysIn.js +0 -42
- package/dist/node_modules/lodash/keysIn.js.map +0 -1
- package/dist/node_modules/lodash/memoize.js +0 -73
- package/dist/node_modules/lodash/memoize.js.map +0 -1
- package/dist/node_modules/lodash/merge.js +0 -49
- package/dist/node_modules/lodash/merge.js.map +0 -1
- package/dist/node_modules/lodash/negate.js +0 -47
- package/dist/node_modules/lodash/negate.js.map +0 -1
- package/dist/node_modules/lodash/noop.js +0 -25
- package/dist/node_modules/lodash/noop.js.map +0 -1
- package/dist/node_modules/lodash/omitBy.js +0 -39
- package/dist/node_modules/lodash/omitBy.js.map +0 -1
- package/dist/node_modules/lodash/pickBy.js +0 -45
- package/dist/node_modules/lodash/pickBy.js.map +0 -1
- package/dist/node_modules/lodash/property.js +0 -42
- package/dist/node_modules/lodash/property.js.map +0 -1
- package/dist/node_modules/lodash/stubArray.js +0 -33
- package/dist/node_modules/lodash/stubArray.js.map +0 -1
- package/dist/node_modules/lodash/stubFalse.js +0 -28
- package/dist/node_modules/lodash/stubFalse.js.map +0 -1
- package/dist/node_modules/lodash/toPlainObject.js +0 -42
- package/dist/node_modules/lodash/toPlainObject.js.map +0 -1
- package/dist/node_modules/lodash/toString.js +0 -38
- package/dist/node_modules/lodash/toString.js.map +0 -1
- package/dist/node_modules/lodash/uniq.js +0 -35
- package/dist/node_modules/lodash/uniq.js.map +0 -1
- package/dist/node_modules/pify/index.js +0 -79
- package/dist/node_modules/pify/index.js.map +0 -1
- package/dist/node_modules/platform/platform.js +0 -891
- package/dist/node_modules/platform/platform.js.map +0 -1
- package/dist/node_modules/store/src/store-engine.js +0 -158
- package/dist/node_modules/store/src/store-engine.js.map +0 -1
- package/dist/node_modules/store/src/util.js +0 -98
- package/dist/node_modules/store/src/util.js.map +0 -1
- package/dist/node_modules/store/storages/localStorage.js +0 -42
- package/dist/node_modules/store/storages/localStorage.js.map +0 -1
- package/dist/node_modules/store/storages/sessionStorage.js +0 -42
- package/dist/node_modules/store/storages/sessionStorage.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devices.js","names":["
|
|
1
|
+
{"version":3,"file":"devices.js","names":["request","medipassWebSdk","storage"],"sources":["../../src/resources/devices.ts"],"sourcesContent":["// @ts-expect-error TS(7016): Could not find a declaration file for module 'plat... Remove this comment to see the full error message\nimport platform from 'platform';\nimport medipassWebSdk from '../index';\nimport doesParamExist from '../utils/does-param-exist';\nimport request from '../utils/request';\nimport storage from '../services/storage';\nimport type { Device, MedipassRequestOpts } from '../types';\nconst PATH__DEVICES = '/devices';\nlet isRegistering = false;\n// @ts-expect-error TS(7006): Parameter 'deviceId' implicitly has an 'any' type.\nexport const pathDeviceByDeviceId = deviceId => `/devices/${deviceId}`;\n\nconst deviceData = {\n deviceType: 'browser',\n os: {\n type: platform.os.family || 'Unknown',\n ver: platform.os.version || '0'\n },\n app: {\n appId: platform.ua || 'Unknown'\n }\n};\n\n/**\n * Register a device\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const registerDevice = async (opts?: MedipassRequestOpts): Promise<Record<string, any>> => {\n if (!isRegistering) {\n try {\n isRegistering = true;\n const data = await request(\n { ...opts, path: PATH__DEVICES },\n {\n method: 'post',\n data: deviceData,\n skipDeviceCheck: true\n }\n );\n medipassWebSdk.device = data;\n storage.set('device', data);\n return data;\n } finally {\n isRegistering = false;\n }\n } else {\n let data;\n\n do {\n await new Promise(resolve => setTimeout(resolve, 100));\n data = medipassWebSdk.device;\n } while (!data);\n\n return data;\n }\n};\n\n/**\n * Check if the device exists, and set the device id request header.\n */\nexport const getDeviceId = async (): Promise<void | null | undefined> => {\n const device = medipassWebSdk.device || storage.get('device');\n\n if (!device || !device.deviceId) {\n const data = await registerDevice();\n return data.deviceId;\n }\n\n return device.deviceId;\n};\n\n/**\n * Update device\n * @param {String} deviceId - Device ID\n * @param {Object} opts - Additional options\n */\nexport const updateDevice = async (deviceId: string, opts: MedipassRequestOpts = {}): Promise<Device> => {\n doesParamExist(\n {\n deviceId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathDeviceByDeviceId(deviceId) },\n {\n method: 'put',\n data: deviceData\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAOA,MAAM,gBAAgB;AACtB,IAAI,gBAAgB;AAEpB,MAAa,wBAAuB,aAAY,YAAY;AAE5D,MAAM,aAAa;CACjB,YAAY;CACZ,IAAI;EACF,MAAM,SAAS,GAAG,UAAU;EAC5B,KAAK,SAAS,GAAG,WAAW;EAC7B;CACD,KAAK,EACH,OAAO,SAAS,MAAM,WACvB;CACF;;;;;;AAOD,MAAa,iBAAiB,OAAO,SAA6D;AAChG,KAAI,CAAC,cACH,KAAI;AACF,kBAAgB;EAChB,MAAM,OAAO,MAAMA,gBACjB;GAAE,GAAG;GAAM,MAAM;GAAe,EAChC;GACE,QAAQ;GACR,MAAM;GACN,iBAAiB;GAClB,CACF;AACD,cAAe,SAAS;AACxB,kBAAQ,IAAI,UAAU,KAAK;AAC3B,SAAO;WACC;AACR,kBAAgB;;MAEb;EACL,IAAI;AAEJ,KAAG;AACD,SAAM,IAAI,SAAQ,YAAW,WAAW,SAAS,IAAI,CAAC;AACtD,UAAOC,YAAe;WACf,CAAC;AAEV,SAAO;;;;;;AAOX,MAAa,cAAc,YAA8C;CACvE,MAAM,SAASA,YAAe,UAAUC,gBAAQ,IAAI,SAAS;AAE7D,KAAI,CAAC,UAAU,CAAC,OAAO,SAErB,SADa,MAAM,gBAAgB,EACvB;AAGd,QAAO,OAAO;;;;;;;AAQhB,MAAa,eAAe,OAAO,UAAkB,OAA4B,EAAE,KAAsB;AACvG,0BACE,EACE,UACD,EACD,KAAK,mBACN;AACD,QAAOF,gBACL;EAAE,GAAG;EAAM,MAAM,qBAAqB,SAAS;EAAE,EACjD;EACE,QAAQ;EACR,MAAM;EACP,CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { __export
|
|
2
|
-
import { require_get } from "../node_modules/lodash/get.js";
|
|
1
|
+
import { __export } from "../_virtual/rolldown_runtime.js";
|
|
3
2
|
import request_default from "../utils/request.js";
|
|
4
3
|
import does_param_exist_default from "../utils/does-param-exist.js";
|
|
5
4
|
import src_default from "../index.js";
|
|
5
|
+
import _get from "lodash/get";
|
|
6
6
|
|
|
7
7
|
//#region src/resources/members.ts
|
|
8
8
|
var members_exports = /* @__PURE__ */ __export({
|
|
@@ -21,7 +21,6 @@ var members_exports = /* @__PURE__ */ __export({
|
|
|
21
21
|
inviteMember: () => inviteMember,
|
|
22
22
|
updateMember: () => updateMember
|
|
23
23
|
});
|
|
24
|
-
var import_get = /* @__PURE__ */ __toESM(require_get(), 1);
|
|
25
24
|
const PATH__MEMBERS = "/members";
|
|
26
25
|
const PATH__DISCOVER_MEMBERS = "/discovery/members";
|
|
27
26
|
const pathAccountMembers = (accountId) => `/accounts/${accountId}/members`;
|
|
@@ -208,7 +207,7 @@ const getMember = async (memberId, opts = {}) => {
|
|
|
208
207
|
...opts,
|
|
209
208
|
path: pathMember(memberId)
|
|
210
209
|
}, { method: "get" });
|
|
211
|
-
if (memberId === (
|
|
210
|
+
if (memberId === _get(src_default, "member._id")) src_default.setMember(member);
|
|
212
211
|
return member;
|
|
213
212
|
};
|
|
214
213
|
/**
|
|
@@ -226,7 +225,7 @@ const updateMember = async (memberId, body, opts = {}) => {
|
|
|
226
225
|
method: "put",
|
|
227
226
|
data: body
|
|
228
227
|
});
|
|
229
|
-
if (memberId === (
|
|
228
|
+
if (memberId === _get(src_default, "member._id")) src_default.setMember(member);
|
|
230
229
|
return member;
|
|
231
230
|
};
|
|
232
231
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"members.js","names":["request","sdk"],"sources":["../../src/resources/members.ts"],"sourcesContent":["import _get from 'lodash/get';\nimport doesParamExist from '../utils/does-param-exist';\nimport request from '../utils/request';\nimport type { MedipassRequestOpts } from '../types';\nimport sdk from '../index';\nconst PATH__MEMBERS = '/members';\nconst PATH__DISCOVER_MEMBERS = '/discovery/members';\n\n// @ts-expect-error TS(7006): Parameter 'accountId' implicitly has an 'any' type... Remove this comment to see the full error message\nconst pathAccountMembers = accountId => `/accounts/${accountId}/members`;\n\n// @ts-expect-error TS(7006): Parameter 'businessId' implicitly has an 'any' typ... Remove this comment to see the full error message\nconst pathBusinessMember = (businessId, memberId) => `/businesses/${businessId}/members/${memberId}`;\n\n// @ts-expect-error TS(7006): Parameter 'businessId' implicitly has an 'any' typ... Remove this comment to see the full error message\nconst pathBusinessMembers = businessId => `/businesses/${businessId}/members`;\n\n// @ts-expect-error TS(7006): Parameter 'memberId' implicitly has an 'any' type.\nconst pathMember = memberId => `/members/${memberId}`;\n\n// @ts-expect-error TS(7006): Parameter 'healthFundId' implicitly has an 'any' t... Remove this comment to see the full error message\nconst pathMembersForHealthFund = healthFundId => `/healthfunds/${healthFundId}/members`;\n\n// @ts-expect-error TS(7006): Parameter 'healthFundId' implicitly has an 'any' t... Remove this comment to see the full error message\nconst pathHealthFundMemberByMemberId = (healthFundId, memberId) => `/healthfunds/${healthFundId}/members/${memberId}`;\n\n/**\n * Check for duplicate member\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const checkDupe = async (\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__MEMBERS}/checkdupe` },\n {\n method: 'post',\n data: body\n }\n );\n};\n\n/**\n * Create member for an account\n * @param {string} accountId - Account ID\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const createAccountMember = async (\n accountId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: pathAccountMembers(accountId) },\n {\n method: 'post',\n data: body\n }\n );\n};\n\n/**\n * Delete a members\n * @param {Object} memberId - Member ID\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const deleteMember = async (memberId: string, opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n doesParamExist(\n {\n memberId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathMember(memberId) },\n {\n method: 'delete'\n }\n );\n};\n\n/**\n * Discover a member\n * @param {Object} query - Query parameters\n * @param {Object} opts - Additional options\n */\nexport const discoverMember = async (\n query: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: PATH__DISCOVER_MEMBERS },\n {\n method: 'get',\n params: query\n }\n );\n};\n\n/**\n * Invite someone to become a Tyro Health member\n * @param {String} businessId - Member ID\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const inviteAnyone = async (\n businessId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n businessId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${pathBusinessMembers(businessId)}/invites` },\n {\n method: 'post',\n data: body\n }\n );\n};\n\n/**\n * Send an SMS to member with link to download app\n * @param {String} memberId - Member ID\n * @param {Object} opts - Additional options\n */\nexport const inviteMember = async (memberId: string, opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n doesParamExist(\n {\n memberId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${pathMember(memberId)}/invites` },\n {\n method: 'post'\n }\n );\n};\n\n/**\n * Get members for an account\n * @param {string} accountId - Account ID\n * @param {Object} query - Query parameters\n * @param {Object} opts - Additional options\n */\nexport const getAccountMembers = async (\n accountId: string,\n query: Record<string, any> = {},\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: pathAccountMembers(accountId) },\n {\n method: 'get',\n params: query\n }\n );\n};\n\n/**\n * Get members by health fund\n * @param {String} healthFundId - Health fund ID\n * @param {Object} opts - Additional options\n */\nexport const getMembersForHealthFund = async (\n healthFundId: string,\n query: Record<string, any> = {},\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: pathMembersForHealthFund(healthFundId) },\n {\n method: 'get',\n params: query\n }\n );\n};\n\n/**\n * Get health fund member by member ID.\n * @param {String} healthFundId - Health Fund ID\n * @param {String} memberId - Member ID\n * @param {Object} opts - Additional options\n */\nexport const getHealthFundMemberByMemberId = async (\n healthFundId: string,\n memberId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: pathHealthFundMemberByMemberId(healthFundId, memberId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get business members\n * @param {String} businessId - Business ID\n * @param {Object} query - Query parameters\n * @param {Object} opts - Additional options\n */\nexport const getBusinessMembers = async (\n businessId: string,\n query: Record<string, any> = {},\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n businessId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessMembers(businessId) },\n {\n method: 'get',\n params: query\n }\n );\n};\n\n/**\n * Get business member\n * @param {String} businessId - Business ID\n * @param {String} memberId - Member ID\n * @param {Object} opts - Additional options\n */\nexport const getBusinessMember = async (\n businessId: string,\n memberId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n businessId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessMember(businessId, memberId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get members\n * @param {Object} opts - Additional options\n */\nexport const getMembers = async (\n query: Record<string, any> = {},\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: PATH__MEMBERS },\n {\n method: 'get',\n params: query\n }\n );\n};\n\n/**\n * Get member\n * @param {String} memberId - Member ID\n * @param {Object} opts - Additional options\n */\nexport const getMember = async (memberId: string, opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n doesParamExist(\n {\n memberId\n },\n opts.hyperMediaEndpoint\n );\n const member = await request(\n { ...opts, path: pathMember(memberId) },\n {\n method: 'get'\n }\n );\n\n if (memberId === _get(sdk, 'member._id')) {\n sdk.setMember(member);\n }\n\n return member;\n};\n\n/**\n * Update a members\n * @param {Object} memberId - Member ID\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const updateMember = async (\n memberId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n memberId\n },\n opts.hyperMediaEndpoint\n );\n const member = await request(\n { ...opts, path: pathMember(memberId) },\n {\n method: 'put',\n data: body\n }\n );\n\n if (memberId === _get(sdk, 'member._id')) {\n sdk.setMember(member);\n }\n\n return member;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,gBAAgB;AACtB,MAAM,yBAAyB;AAG/B,MAAM,sBAAqB,cAAa,aAAa,UAAU;AAG/D,MAAM,sBAAsB,YAAY,aAAa,eAAe,WAAW,WAAW;AAG1F,MAAM,uBAAsB,eAAc,eAAe,WAAW;AAGpE,MAAM,cAAa,aAAY,YAAY;AAG3C,MAAM,4BAA2B,iBAAgB,gBAAgB,aAAa;AAG9E,MAAM,kCAAkC,cAAc,aAAa,gBAAgB,aAAa,WAAW;;;;;;AAO3G,MAAa,YAAY,OACvB,MACA,OAA4B,EAAE,KACG;AACjC,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM,GAAG,cAAc;EAAa,EAC/C;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;;;AASH,MAAa,sBAAsB,OACjC,WACA,MACA,OAA4B,EAAE,KACG;AACjC,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM,mBAAmB,UAAU;EAAE,EAChD;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;;;AASH,MAAa,eAAe,OAAO,UAAkB,OAA4B,EAAE,KAAmC;AACpH,0BACE,EACE,UACD,EACD,KAAK,mBACN;AACD,QAAOA,gBACL;EAAE,GAAG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,YACD,EACD,KAAK,mBACN;AACD,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM,oBAAoB,WAAW;EAAE,EAClD;EACE,QAAQ;EACR,QAAQ;EACT,CACF;;;;;;;;AASH,MAAa,oBAAoB,OAC/B,YACA,UACA,OAA4B,EAAE,KACG;AACjC,0BACE,EACE,YACD,EACD,KAAK,mBACN;AACD,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM,mBAAmB,YAAY,SAAS;EAAE,EAC3D,EACE,QAAQ,OACT,CACF;;;;;;AAOH,MAAa,aAAa,OACxB,QAA6B,EAAE,EAC/B,OAA4B,EAAE,KACG;AACjC,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM;EAAe,EAChC;EACE,QAAQ;EACR,QAAQ;EACT,CACF;;;;;;;AAQH,MAAa,YAAY,OAAO,UAAkB,OAA4B,EAAE,KAAmC;AACjH,0BACE,EACE,UACD,EACD,KAAK,mBACN;CACD,MAAM,SAAS,MAAMA,gBACnB;EAAE,GAAG;EAAM,MAAM,WAAW,SAAS;EAAE,EACvC,EACE,QAAQ,OACT,CACF;AAED,KAAI,qCAAkBC,aAAK,aAAa,CACtC,aAAI,UAAU,OAAO;AAGvB,QAAO;;;;;;;;AAST,MAAa,eAAe,OAC1B,UACA,MACA,OAA4B,EAAE,KACG;AACjC,0BACE,EACE,UACD,EACD,KAAK,mBACN;CACD,MAAM,SAAS,MAAMD,gBACnB;EAAE,GAAG;EAAM,MAAM,WAAW,SAAS;EAAE,EACvC;EACE,QAAQ;EACR,MAAM;EACP,CACF;AAED,KAAI,qCAAkBC,aAAK,aAAa,CACtC,aAAI,UAAU,OAAO;AAGvB,QAAO"}
|
|
1
|
+
{"version":3,"file":"members.js","names":["request","sdk"],"sources":["../../src/resources/members.ts"],"sourcesContent":["import _get from 'lodash/get';\nimport doesParamExist from '../utils/does-param-exist';\nimport request from '../utils/request';\nimport type { MedipassRequestOpts } from '../types';\nimport sdk from '../index';\nconst PATH__MEMBERS = '/members';\nconst PATH__DISCOVER_MEMBERS = '/discovery/members';\n\n// @ts-expect-error TS(7006): Parameter 'accountId' implicitly has an 'any' type... Remove this comment to see the full error message\nconst pathAccountMembers = accountId => `/accounts/${accountId}/members`;\n\n// @ts-expect-error TS(7006): Parameter 'businessId' implicitly has an 'any' typ... Remove this comment to see the full error message\nconst pathBusinessMember = (businessId, memberId) => `/businesses/${businessId}/members/${memberId}`;\n\n// @ts-expect-error TS(7006): Parameter 'businessId' implicitly has an 'any' typ... Remove this comment to see the full error message\nconst pathBusinessMembers = businessId => `/businesses/${businessId}/members`;\n\n// @ts-expect-error TS(7006): Parameter 'memberId' implicitly has an 'any' type.\nconst pathMember = memberId => `/members/${memberId}`;\n\n// @ts-expect-error TS(7006): Parameter 'healthFundId' implicitly has an 'any' t... Remove this comment to see the full error message\nconst pathMembersForHealthFund = healthFundId => `/healthfunds/${healthFundId}/members`;\n\n// @ts-expect-error TS(7006): Parameter 'healthFundId' implicitly has an 'any' t... Remove this comment to see the full error message\nconst pathHealthFundMemberByMemberId = (healthFundId, memberId) => `/healthfunds/${healthFundId}/members/${memberId}`;\n\n/**\n * Check for duplicate member\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const checkDupe = async (\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__MEMBERS}/checkdupe` },\n {\n method: 'post',\n data: body\n }\n );\n};\n\n/**\n * Create member for an account\n * @param {string} accountId - Account ID\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const createAccountMember = async (\n accountId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: pathAccountMembers(accountId) },\n {\n method: 'post',\n data: body\n }\n );\n};\n\n/**\n * Delete a members\n * @param {Object} memberId - Member ID\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const deleteMember = async (memberId: string, opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n doesParamExist(\n {\n memberId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathMember(memberId) },\n {\n method: 'delete'\n }\n );\n};\n\n/**\n * Discover a member\n * @param {Object} query - Query parameters\n * @param {Object} opts - Additional options\n */\nexport const discoverMember = async (\n query: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: PATH__DISCOVER_MEMBERS },\n {\n method: 'get',\n params: query\n }\n );\n};\n\n/**\n * Invite someone to become a Tyro Health member\n * @param {String} businessId - Member ID\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const inviteAnyone = async (\n businessId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n businessId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${pathBusinessMembers(businessId)}/invites` },\n {\n method: 'post',\n data: body\n }\n );\n};\n\n/**\n * Send an SMS to member with link to download app\n * @param {String} memberId - Member ID\n * @param {Object} opts - Additional options\n */\nexport const inviteMember = async (memberId: string, opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n doesParamExist(\n {\n memberId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${pathMember(memberId)}/invites` },\n {\n method: 'post'\n }\n );\n};\n\n/**\n * Get members for an account\n * @param {string} accountId - Account ID\n * @param {Object} query - Query parameters\n * @param {Object} opts - Additional options\n */\nexport const getAccountMembers = async (\n accountId: string,\n query: Record<string, any> = {},\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: pathAccountMembers(accountId) },\n {\n method: 'get',\n params: query\n }\n );\n};\n\n/**\n * Get members by health fund\n * @param {String} healthFundId - Health fund ID\n * @param {Object} opts - Additional options\n */\nexport const getMembersForHealthFund = async (\n healthFundId: string,\n query: Record<string, any> = {},\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: pathMembersForHealthFund(healthFundId) },\n {\n method: 'get',\n params: query\n }\n );\n};\n\n/**\n * Get health fund member by member ID.\n * @param {String} healthFundId - Health Fund ID\n * @param {String} memberId - Member ID\n * @param {Object} opts - Additional options\n */\nexport const getHealthFundMemberByMemberId = async (\n healthFundId: string,\n memberId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: pathHealthFundMemberByMemberId(healthFundId, memberId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get business members\n * @param {String} businessId - Business ID\n * @param {Object} query - Query parameters\n * @param {Object} opts - Additional options\n */\nexport const getBusinessMembers = async (\n businessId: string,\n query: Record<string, any> = {},\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n businessId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessMembers(businessId) },\n {\n method: 'get',\n params: query\n }\n );\n};\n\n/**\n * Get business member\n * @param {String} businessId - Business ID\n * @param {String} memberId - Member ID\n * @param {Object} opts - Additional options\n */\nexport const getBusinessMember = async (\n businessId: string,\n memberId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n businessId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessMember(businessId, memberId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get members\n * @param {Object} opts - Additional options\n */\nexport const getMembers = async (\n query: Record<string, any> = {},\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: PATH__MEMBERS },\n {\n method: 'get',\n params: query\n }\n );\n};\n\n/**\n * Get member\n * @param {String} memberId - Member ID\n * @param {Object} opts - Additional options\n */\nexport const getMember = async (memberId: string, opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n doesParamExist(\n {\n memberId\n },\n opts.hyperMediaEndpoint\n );\n const member = await request(\n { ...opts, path: pathMember(memberId) },\n {\n method: 'get'\n }\n );\n\n if (memberId === _get(sdk, 'member._id')) {\n sdk.setMember(member);\n }\n\n return member;\n};\n\n/**\n * Update a members\n * @param {Object} memberId - Member ID\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const updateMember = async (\n memberId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n memberId\n },\n opts.hyperMediaEndpoint\n );\n const member = await request(\n { ...opts, path: pathMember(memberId) },\n {\n method: 'put',\n data: body\n }\n );\n\n if (memberId === _get(sdk, 'member._id')) {\n sdk.setMember(member);\n }\n\n return member;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,gBAAgB;AACtB,MAAM,yBAAyB;AAG/B,MAAM,sBAAqB,cAAa,aAAa,UAAU;AAG/D,MAAM,sBAAsB,YAAY,aAAa,eAAe,WAAW,WAAW;AAG1F,MAAM,uBAAsB,eAAc,eAAe,WAAW;AAGpE,MAAM,cAAa,aAAY,YAAY;AAG3C,MAAM,4BAA2B,iBAAgB,gBAAgB,aAAa;AAG9E,MAAM,kCAAkC,cAAc,aAAa,gBAAgB,aAAa,WAAW;;;;;;AAO3G,MAAa,YAAY,OACvB,MACA,OAA4B,EAAE,KACG;AACjC,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM,GAAG,cAAc;EAAa,EAC/C;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;;;AASH,MAAa,sBAAsB,OACjC,WACA,MACA,OAA4B,EAAE,KACG;AACjC,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM,mBAAmB,UAAU;EAAE,EAChD;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;;;AASH,MAAa,eAAe,OAAO,UAAkB,OAA4B,EAAE,KAAmC;AACpH,0BACE,EACE,UACD,EACD,KAAK,mBACN;AACD,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM,WAAW,SA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;AACD,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM,oBAAoB,WAAW;EAAE,EAClD;EACE,QAAQ;EACR,QAAQ;EACT,CACF;;;;;;;;AASH,MAAa,oBAAoB,OAC/B,YACA,UACA,OAA4B,EAAE,KACG;AACjC,0BACE,EACE,YACD,EACD,KAAK,mBACN;AACD,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM,mBAAmB,YAAY,SAAS;EAAE,EAC3D,EACE,QAAQ,OACT,CACF;;;;;;AAOH,MAAa,aAAa,OACxB,QAA6B,EAAE,EAC/B,OAA4B,EAAE,KACG;AACjC,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM;EAAe,EAChC;EACE,QAAQ;EACR,QAAQ;EACT,CACF;;;;;;;AAQH,MAAa,YAAY,OAAO,UAAkB,OAA4B,EAAE,KAAmC;AACjH,0BACE,EACE,UACD,EACD,KAAK,mBACN;CACD,MAAM,SAAS,MAAMA,gBACnB;EAAE,GAAG;EAAM,MAAM,WAAW,SAAS;EAAE,EACvC,EACE,QAAQ,OACT,CACF;AAED,KAAI,aAAa,KAAKC,aAAK,aAAa,CACtC,aAAI,UAAU,OAAO;AAGvB,QAAO;;;;;;;;AAST,MAAa,eAAe,OAC1B,UACA,MACA,OAA4B,EAAE,KACG;AACjC,0BACE,EACE,UACD,EACD,KAAK,mBACN;CACD,MAAM,SAAS,MAAMD,gBACnB;EAAE,GAAG;EAAM,MAAM,WAAW,SAAS;EAAE,EACvC;EACE,QAAQ;EACR,MAAM;EACP,CACF;AAED,KAAI,aAAa,KAAKC,aAAK,aAAa,CACtC,aAAI,UAAU,OAAO;AAGvB,QAAO"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { __export
|
|
1
|
+
import { __export } from "../_virtual/rolldown_runtime.js";
|
|
2
2
|
import request_default from "../utils/request.js";
|
|
3
3
|
import does_param_exist_default from "../utils/does-param-exist.js";
|
|
4
|
-
import { require_pify } from "../node_modules/pify/index.js";
|
|
5
4
|
import { ERROR_MESSAGES, PAYMENT_PROVIDERS } from "@medipass/utils/constants";
|
|
5
|
+
import pify from "pify";
|
|
6
6
|
import envModule from "@medipass/utils/get-env";
|
|
7
7
|
|
|
8
8
|
//#region src/resources/payments.ts
|
|
@@ -30,7 +30,6 @@ var payments_exports = /* @__PURE__ */ __export({
|
|
|
30
30
|
updateBusinessPatientPaymentMethod: () => updateBusinessPatientPaymentMethod,
|
|
31
31
|
updateBusinessPaymentMethod: () => updateBusinessPaymentMethod
|
|
32
32
|
});
|
|
33
|
-
var import_pify = /* @__PURE__ */ __toESM(require_pify(), 1);
|
|
34
33
|
const PATH__PAYMENTS = "/payments";
|
|
35
34
|
const env = envModule.default ?? envModule;
|
|
36
35
|
const pathAccountPaymentMethods = (accountId) => `/accounts/${accountId}/paymentmethods`;
|
|
@@ -433,7 +432,7 @@ const getNonce = async ({ amount, businessId, patientId, cardNumber: _cardNumber
|
|
|
433
432
|
if (!paymentSession) throw new Error(ERROR_MESSAGES.PAYMENT_GATEWAY_ERROR);
|
|
434
433
|
if (paymentProvider === PAYMENT_PROVIDERS.PAYMENT_CARD) {
|
|
435
434
|
paymentSession.setMerchant(clientToken.merchantId);
|
|
436
|
-
const updateSessionResponse = await (
|
|
435
|
+
const updateSessionResponse = await pify(paymentSession.updateSession, { errorFirst: false })(clientToken.clientToken, {
|
|
437
436
|
cardNumber,
|
|
438
437
|
cardExpiryMonth,
|
|
439
438
|
cardExpiryYear,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payments.js","names":["request","clientToken: ClientToken","baseCardPaymentMethod: google.payments.api.IsReadyToPayPaymentMethodSpecification"],"sources":["../../src/resources/payments.ts"],"sourcesContent":["import pify from 'pify';\nimport envModule from '@medipass/utils/get-env';\nimport { ERROR_MESSAGES, PAYMENT_PROVIDERS } from '@medipass/utils/constants';\nimport request from '../utils/request';\nimport doesParamExist from '../utils/does-param-exist';\nimport type { MedipassRequestOpts } from '../types';\nimport type { PaymentMethod, PaymentMethodResponse } from '../types/payment-methods';\nexport * from '../types/payment-methods';\n\nconst PATH__PAYMENTS = '/payments';\nconst env = (envModule as typeof envModule & { default?: typeof envModule }).default ?? envModule;\n\nconst pathAccountPaymentMethods = (accountId: string) => `/accounts/${accountId}/paymentmethods`;\n\nconst pathAccountPaymentMethod = (accountId: string, paymentMethodId: string) =>\n `/accounts/${accountId}/paymentmethods/${paymentMethodId}`;\n\nconst pathBusinessPaymentsClientTokens = (businessId: string) => `/businesses/${businessId}/payments/clienttoken`;\n\nconst pathBusinessPaymentMethods = (businessId: string) => `/businesses/${businessId}/paymentmethods`;\n\nconst pathBusinessPaymentMethod = (businessId: string, paymentMethodId: string) =>\n `/businesses/${businessId}/paymentmethods/${paymentMethodId}`;\n\nconst pathBusinessPatientPaymentMethods = (businessId: string, patientId: string) =>\n `/businesses/${businessId}/patients/${patientId}/paymentmethods`;\n\nconst pathBusinessPatientPaymentMethodsByRefId = (businessId: string, refId: string) =>\n `/businesses/${businessId}/patients/refid/${refId}/paymentmethods`;\n\nconst pathBusinessPatientPaymentMethod = (businessId: string, patientId: string, paymentMethodId: string) =>\n `/businesses/${businessId}/patients/${patientId}/paymentmethods/${paymentMethodId}`;\n\nconst pathBusinessSalesClientToken = (businessId: string) => `/businesses/${businessId}/sales/clienttoken`;\n\nconst pathBusinessPaymentClientToken = (businessId: string, patientId: string) =>\n `/businesses/${businessId}/patients/${patientId}/sales/clienttoken`;\n\n/**\n * Create an account's payment method\n * @param {String} accountId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const createAccountPaymentMethod = async (\n accountId: string,\n nonce: string,\n source: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n accountId,\n nonce,\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathAccountPaymentMethods(accountId) },\n {\n method: 'post',\n data: {\n nonce,\n source\n }\n }\n );\n};\n\n/**\n * Get a business' payment methods\n * @param {String} businessId - Business ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const createBusinessPaymentMethod = async (\n businessId: string,\n nonce: string,\n source: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n nonce,\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentMethods(businessId) },\n {\n method: 'post',\n data: {\n nonce,\n source\n }\n }\n );\n};\n\n/**\n * Create a business patient payment method\n * @param {String} accountId - Account ID\n * @param {String} patientId - Patient ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const createBusinessPatientPaymentMethod = async (\n businessId: string,\n patientId: string,\n nonce: string,\n source: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n patientId,\n nonce,\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethods(businessId, patientId) },\n {\n method: 'post',\n data: {\n nonce,\n source\n }\n }\n );\n};\n\n/**\n * Delete an account's payment method\n * @param {String} accountId - Account ID\n * @param {String} paymentMethodId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const deleteAccountPaymentMethod = async (\n accountId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n accountId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathAccountPaymentMethod(accountId, paymentMethodId) },\n {\n method: 'delete'\n }\n );\n};\n\n/**\n * Delete a business' payment method\n * @param {String} businessId - Business ID\n * @param {String} paymentMethodId - Payment Method ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const deleteBusinessPaymentMethod = async (\n businessId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n businessId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentMethod(businessId, paymentMethodId) },\n {\n method: 'delete'\n }\n );\n};\n\n/**\n * Delete a business patient payment method\n * @param {String} businessId - Business ID\n * @param {String} patientId - Patient ID\n * @param {String} paymentMethodId - Payment Method ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const deleteBusinessPatientPaymentMethod = async (\n businessId: string,\n patientId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n businessId,\n patientId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethod(businessId, patientId, paymentMethodId) },\n {\n method: 'delete'\n }\n );\n};\n\n/**\n * Get an account's payment methods\n * @param {String} accountId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getAccountPaymentMethods = async (\n accountId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Array<PaymentMethod>> => {\n doesParamExist(\n {\n accountId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathAccountPaymentMethods(accountId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get a business' payment methods\n * @param {String} businessId - Business ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessPaymentMethods = async (\n businessId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethodResponse> => {\n doesParamExist(\n {\n businessId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentMethods(businessId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get a business patient payment methods\n * @param {String} businessId - Business ID\n * @param {Object} opts - Additional options\n * @returns {Object} The payment methods data\n */\nexport const getBusinessPatientPaymentMethods = async (\n businessId: string,\n patientId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethodResponse> => {\n doesParamExist(\n {\n businessId,\n patientId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethods(businessId, patientId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get a business patient payment methods by ref id\n * @param {String} businessId - Business ID\n * @param {String} refId - Patient ref ID\n * @param {Object} opts - Additional options\n * @returns {Object} The payment methods data\n */\nexport const getBusinessPatientPaymentMethodsByRefId = async (\n businessId: string,\n refId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethodResponse> => {\n doesParamExist(\n {\n businessId,\n refId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethodsByRefId(businessId, refId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get an account's payment method\n * @param {String} accountId - Account ID\n * @param {String} paymentMethodId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getAccountPaymentMethod = async (\n accountId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n accountId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathAccountPaymentMethod(accountId, paymentMethodId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get a business payment method\n * @param {String} businessId - Business ID\n * @param {String} paymentMethodId - Payment Method ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessPaymentMethod = async (\n businessId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentMethod(businessId, paymentMethodId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get a business patient payment method\n * @param {String} businessId - Business ID\n * @param {String} patientID - Patient ID\n * @param {String} paymentMethodId - Payment Method ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessPatientPaymentMethod = async (\n businessId: string,\n patientId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n patientId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethod(businessId, patientId, paymentMethodId) },\n {\n method: 'get'\n }\n );\n};\n\nexport interface ClientToken {\n clientToken: string;\n merchantId: string;\n source: 'mastercard';\n}\n\nexport interface NonceResponse extends ClientToken {\n nonce: string;\n sourceResponse: any;\n}\n\nexport interface ApplePayResponse extends ClientToken {\n canMakeApplePayment: boolean;\n paymentRequest: {\n countryCode: string;\n currencyCode: string;\n supportedNetworks: string[];\n merchantCapabilities: string[];\n total: { label: string; amount: string };\n };\n}\n\nexport type GetNonceResponse = ClientToken | NonceResponse | ApplePayResponse;\n\n/**\n * Get business client token\n * @param {String} businessId - Business ID\n * @param {String} source - Source of payment\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessClientToken = async (\n businessId: string,\n source: string,\n opts: MedipassRequestOpts = {}\n): Promise<ClientToken> => {\n doesParamExist(\n {\n businessId,\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentsClientTokens(businessId) },\n {\n method: 'get',\n params: {\n source\n }\n }\n );\n};\n\n/**\n * Get business payment client token\n * @param {String} businessId - Business ID\n * @param {String} patientId - Patient ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessPaymentClientToken = async (\n businessId: string,\n patientId: string,\n opts: MedipassRequestOpts = {}\n): Promise<ClientToken> => {\n doesParamExist(\n {\n businessId,\n patientId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentClientToken(businessId, patientId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get business sales client token\n * @param {String} businessId - Business ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessSalesClientToken = async (\n businessId: string,\n opts: MedipassRequestOpts = {}\n): Promise<ClientToken> => {\n doesParamExist(\n {\n businessId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessSalesClientToken(businessId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get client token\n * @param {String} source - Source of payment\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getClientToken = async (\n source: string,\n opts: MedipassRequestOpts = {\n tokenType: 'account'\n }\n): Promise<ClientToken> => {\n doesParamExist(\n {\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${PATH__PAYMENTS}/clienttoken` },\n {\n method: 'get',\n params: {\n source\n },\n tokenType: opts.tokenType\n }\n );\n};\n\n/**\n * Update an account's payment method\n * @param {String} accountId - Account ID\n * @param {String} paymentMethodId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const updateAccountPaymentMethod = async (\n accountId: string,\n paymentMethodId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n accountId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathAccountPaymentMethod(accountId, paymentMethodId) },\n {\n data: body,\n method: 'put'\n }\n );\n};\n\n/**\n * Update a business' payment method\n * @param {String} businessId - Business ID\n * @param {String} paymentMethodId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const updateBusinessPaymentMethod = async (\n businessId: string,\n paymentMethodId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentMethod(businessId, paymentMethodId) },\n {\n data: body,\n method: 'put'\n }\n );\n};\n\n/**\n * Update a business patient payment method\n * @param {String} businessId - Business ID\n * @param {String} paymentMethodId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const updateBusinessPatientPaymentMethod = async (\n businessId: string,\n patientId: string,\n paymentMethodId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n patientId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethod(businessId, patientId, paymentMethodId) },\n {\n data: body,\n method: 'put'\n }\n );\n};\n//////////////////////////////////////////////////////////////\nexport const getPaymentGatewayError = (sessionResponse: Record<string, any>) => {\n if (sessionResponse && sessionResponse.status === 'fields_in_error') {\n return ERROR_MESSAGES.PAYMENT_GATEWAY_FIELDS;\n } else if (sessionResponse && sessionResponse.status === 'system_error') {\n return ERROR_MESSAGES.PAYMENT_GATEWAY_ERROR;\n }\n\n return null;\n};\n\n/**\n * Get a business nonce\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const getNonce = async (\n {\n amount,\n businessId,\n patientId,\n cardNumber: _cardNumber,\n expiry,\n cvc,\n paymentProvider = PAYMENT_PROVIDERS.PAYMENT_CARD,\n isSales = true,\n isSelfCheckoutSession = false,\n source = 'mastercard'\n }: {\n amount?: string;\n businessId?: string;\n patientId?: string;\n cardNumber?: string;\n expiry?: string;\n cvc?: string;\n paymentProvider?:\n | typeof PAYMENT_PROVIDERS.PAYMENT_CARD\n | typeof PAYMENT_PROVIDERS.GOOGLE_PAY\n | typeof PAYMENT_PROVIDERS.APPLE_PAY;\n isSales?: boolean;\n isSelfCheckoutSession?: boolean;\n source?: 'mastercard';\n },\n opts: MedipassRequestOpts = {}\n): Promise<GetNonceResponse> => {\n const cardNumber = _cardNumber ? _cardNumber.replace(/\\s/g, '') : '';\n const cardExpiryMonth = expiry ? expiry.split('/')[0].trim() : '';\n const cardExpiryYear = expiry ? expiry.split('/')[1].trim() : '';\n const cardSecurityCode = cvc;\n let clientToken: ClientToken;\n\n if (businessId && isSales && !patientId) {\n clientToken = await getBusinessSalesClientToken(\n businessId,\n isSelfCheckoutSession\n ? {\n tokenType: 'session'\n }\n : {}\n );\n } else if (businessId && !patientId) {\n clientToken = await getBusinessClientToken(\n businessId,\n source,\n isSelfCheckoutSession\n ? {\n tokenType: 'session'\n }\n : {}\n );\n } else if (businessId && patientId) {\n clientToken = await getBusinessPaymentClientToken(businessId, patientId, {\n requestConfig: { tokenType: 'session' }\n });\n } else {\n clientToken = await getClientToken(\n source,\n isSelfCheckoutSession\n ? {\n tokenType: 'session'\n }\n : {}\n );\n }\n\n if (!clientToken.source) clientToken.source = source;\n\n if (clientToken.source === 'mastercard') {\n const paymentSession = HostedForm;\n\n if (!paymentSession) {\n throw new Error(ERROR_MESSAGES.PAYMENT_GATEWAY_ERROR);\n }\n\n if (paymentProvider === PAYMENT_PROVIDERS.PAYMENT_CARD) {\n paymentSession.setMerchant(clientToken.merchantId);\n const updateSessionResponse = await pify(paymentSession.updateSession, {\n errorFirst: false\n })(clientToken.clientToken, {\n cardNumber,\n cardExpiryMonth,\n cardExpiryYear,\n cardSecurityCode\n });\n\n if (getPaymentGatewayError(updateSessionResponse)) {\n const error = getPaymentGatewayError(updateSessionResponse);\n if (error !== null) {\n throw new Error(error);\n }\n }\n\n return { ...clientToken, nonce: clientToken.clientToken, sourceResponse: updateSessionResponse };\n }\n\n if (paymentProvider === PAYMENT_PROVIDERS.GOOGLE_PAY && amount && window?.google?.payments?.api) {\n const paymentsClient = new window.google.payments.api.PaymentsClient({\n environment: env.ENV_NAME === 'prod' || env.ENV_NAME === 'pre-prod' ? 'PRODUCTION' : 'TEST'\n });\n\n const tokenizationSpecification = {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'mpgs',\n gatewayMerchantId: clientToken?.merchantId\n }\n };\n\n const baseCardPaymentMethod: google.payments.api.IsReadyToPayPaymentMethodSpecification = {\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY'],\n allowedCardNetworks: ['VISA', 'MASTERCARD'],\n billingAddressRequired: false\n }\n };\n const cardPaymentMethod = Object.assign(\n { tokenizationSpecification: tokenizationSpecification },\n baseCardPaymentMethod\n );\n\n const response = await paymentsClient.isReadyToPay({\n apiVersion: 2,\n apiVersionMinor: 0,\n allowedPaymentMethods: [baseCardPaymentMethod]\n });\n\n if (response.result) {\n const paymentDataRequest = {\n apiVersion: 2,\n apiVersionMinor: 0,\n allowedPaymentMethods: [cardPaymentMethod],\n transactionInfo: {\n currencyCode: 'AUD',\n totalPriceStatus: 'FINAL' as google.payments.api.TotalPriceStatus,\n totalPrice: amount.replace('$', '')\n },\n merchantInfo: {\n merchantName: 'Tyro Health',\n merchantId: env.GOOGLE_MERCHANT_ID\n }\n };\n\n /* TODO: (optional)\n prefetch payment method data for performance boost\n */\n\n const paymentData = await paymentsClient.loadPaymentData(paymentDataRequest);\n\n return {\n ...clientToken,\n nonce: paymentData.paymentMethodData.tokenizationData.token,\n sourceResponse: paymentData\n };\n }\n }\n\n if (paymentProvider === PAYMENT_PROVIDERS.APPLE_PAY) {\n const canMakeApplePayment = window.ApplePaySession.canMakePayments();\n\n const paymentRequest = {\n countryCode: 'AU',\n currencyCode: 'AUD',\n supportedNetworks: ['visa', 'masterCard'],\n merchantCapabilities: ['supports3DS'],\n total: { label: 'Tyro Health', amount: amount?.replace('$', '') || '' }\n };\n\n return { ...clientToken, canMakeApplePayment, paymentRequest };\n }\n\n return clientToken;\n }\n\n return clientToken;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,iBAAiB;AACvB,MAAM,MAAO,UAAgE,WAAW;AAExF,MAAM,6BAA6B,cAAsB,aAAa,UAAU;AAEhF,MAAM,4BAA4B,WAAmB,oBACnD,aAAa,UAAU,kBAAkB;AAE3C,MAAM,oCAAoC,eAAuB,eAAe,WAAW;AAE3F,MAAM,8BAA8B,eAAuB,eAAe,WAAW;AAErF,MAAM,6BAA6B,YAAoB,oBACrD,eAAe,WAAW,kBAAkB;AAE9C,MAAM,qCAAq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Aa,aAAa,eAAe,QACtF,CAAC;GAEF,MAAM,4BAA4B;IAChC,MAAM;IACN,YAAY;KACV,SAAS;KACT,mBAAmB,aAAa;KACjC;IACF;GAED,MAAMC,wBAAoF;IACxF,MAAM;IACN,YAAY;KACV,oBAAoB,CAAC,WAAW;KAChC,qBAAqB,CAAC,QAAQ,aAAa;KAC3C,wBAAwB;KACzB;IACF;GACD,MAAM,oBAAoB,OAAO,OAC/B,EAA6B,2BAA2B,EACxD,sBACD;AAQD,QANiB,MAAM,eAAe,aAAa;IACjD,YAAY;IACZ,iBAAiB;IACjB,uBAAuB,CAAC,sBAAsB;IAC/C,CAAC,EAEW,QAAQ;IACnB,MAAM,qBAAqB;KACzB,YAAY;KACZ,iBAAiB;KACjB,uBAAuB,CAAC,kBAAkB;KAC1C,iBAAiB;MACf,cAAc;MACd,kBAAkB;MAClB,YAAY,OAAO,QAAQ,KAAK,GAAG;MACpC;KACD,cAAc;MACZ,cAAc;MACd,YAAY,IAAI;MACjB;KACF;IAMD,MAAM,cAAc,MAAM,eAAe,gBAAgB,mBAAmB;AAE5E,WAAO;KACL,GAAG;KACH,OAAO,YAAY,kBAAkB,iBAAiB;KACtD,gBAAgB;KACjB;;;AAIL,MAAI,oBAAoB,kBAAkB,WAAW;GACnD,MAAM,sBAAsB,OAAO,gBAAgB,iBAAiB;GAEpE,MAAM,iBAAiB;IACrB,aAAa;IACb,cAAc;IACd,mBAAmB,CAAC,QAAQ,aAAa;IACzC,sBAAsB,CAAC,cAAc;IACrC,OAAO;KAAE,OAAO;KAAe,QAAQ,QAAQ,QAAQ,KAAK,GAAG,IAAI;KAAI;IACxE;AAED,UAAO;IAAE,GAAG;IAAa;IAAqB;IAAgB;;AAGhE,SAAO;;AAGT,QAAO"}
|
|
1
|
+
{"version":3,"file":"payments.js","names":["request","clientToken: ClientToken","baseCardPaymentMethod: google.payments.api.IsReadyToPayPaymentMethodSpecification"],"sources":["../../src/resources/payments.ts"],"sourcesContent":["import pify from 'pify';\nimport envModule from '@medipass/utils/get-env';\nimport { ERROR_MESSAGES, PAYMENT_PROVIDERS } from '@medipass/utils/constants';\nimport request from '../utils/request';\nimport doesParamExist from '../utils/does-param-exist';\nimport type { MedipassRequestOpts } from '../types';\nimport type { PaymentMethod, PaymentMethodResponse } from '../types/payment-methods';\nexport * from '../types/payment-methods';\n\nconst PATH__PAYMENTS = '/payments';\nconst env = (envModule as typeof envModule & { default?: typeof envModule }).default ?? envModule;\n\nconst pathAccountPaymentMethods = (accountId: string) => `/accounts/${accountId}/paymentmethods`;\n\nconst pathAccountPaymentMethod = (accountId: string, paymentMethodId: string) =>\n `/accounts/${accountId}/paymentmethods/${paymentMethodId}`;\n\nconst pathBusinessPaymentsClientTokens = (businessId: string) => `/businesses/${businessId}/payments/clienttoken`;\n\nconst pathBusinessPaymentMethods = (businessId: string) => `/businesses/${businessId}/paymentmethods`;\n\nconst pathBusinessPaymentMethod = (businessId: string, paymentMethodId: string) =>\n `/businesses/${businessId}/paymentmethods/${paymentMethodId}`;\n\nconst pathBusinessPatientPaymentMethods = (businessId: string, patientId: string) =>\n `/businesses/${businessId}/patients/${patientId}/paymentmethods`;\n\nconst pathBusinessPatientPaymentMethodsByRefId = (businessId: string, refId: string) =>\n `/businesses/${businessId}/patients/refid/${refId}/paymentmethods`;\n\nconst pathBusinessPatientPaymentMethod = (businessId: string, patientId: string, paymentMethodId: string) =>\n `/businesses/${businessId}/patients/${patientId}/paymentmethods/${paymentMethodId}`;\n\nconst pathBusinessSalesClientToken = (businessId: string) => `/businesses/${businessId}/sales/clienttoken`;\n\nconst pathBusinessPaymentClientToken = (businessId: string, patientId: string) =>\n `/businesses/${businessId}/patients/${patientId}/sales/clienttoken`;\n\n/**\n * Create an account's payment method\n * @param {String} accountId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const createAccountPaymentMethod = async (\n accountId: string,\n nonce: string,\n source: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n accountId,\n nonce,\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathAccountPaymentMethods(accountId) },\n {\n method: 'post',\n data: {\n nonce,\n source\n }\n }\n );\n};\n\n/**\n * Get a business' payment methods\n * @param {String} businessId - Business ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const createBusinessPaymentMethod = async (\n businessId: string,\n nonce: string,\n source: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n nonce,\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentMethods(businessId) },\n {\n method: 'post',\n data: {\n nonce,\n source\n }\n }\n );\n};\n\n/**\n * Create a business patient payment method\n * @param {String} accountId - Account ID\n * @param {String} patientId - Patient ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const createBusinessPatientPaymentMethod = async (\n businessId: string,\n patientId: string,\n nonce: string,\n source: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n patientId,\n nonce,\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethods(businessId, patientId) },\n {\n method: 'post',\n data: {\n nonce,\n source\n }\n }\n );\n};\n\n/**\n * Delete an account's payment method\n * @param {String} accountId - Account ID\n * @param {String} paymentMethodId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const deleteAccountPaymentMethod = async (\n accountId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n accountId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathAccountPaymentMethod(accountId, paymentMethodId) },\n {\n method: 'delete'\n }\n );\n};\n\n/**\n * Delete a business' payment method\n * @param {String} businessId - Business ID\n * @param {String} paymentMethodId - Payment Method ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const deleteBusinessPaymentMethod = async (\n businessId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n businessId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentMethod(businessId, paymentMethodId) },\n {\n method: 'delete'\n }\n );\n};\n\n/**\n * Delete a business patient payment method\n * @param {String} businessId - Business ID\n * @param {String} patientId - Patient ID\n * @param {String} paymentMethodId - Payment Method ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const deleteBusinessPatientPaymentMethod = async (\n businessId: string,\n patientId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n businessId,\n patientId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethod(businessId, patientId, paymentMethodId) },\n {\n method: 'delete'\n }\n );\n};\n\n/**\n * Get an account's payment methods\n * @param {String} accountId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getAccountPaymentMethods = async (\n accountId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Array<PaymentMethod>> => {\n doesParamExist(\n {\n accountId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathAccountPaymentMethods(accountId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get a business' payment methods\n * @param {String} businessId - Business ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessPaymentMethods = async (\n businessId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethodResponse> => {\n doesParamExist(\n {\n businessId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentMethods(businessId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get a business patient payment methods\n * @param {String} businessId - Business ID\n * @param {Object} opts - Additional options\n * @returns {Object} The payment methods data\n */\nexport const getBusinessPatientPaymentMethods = async (\n businessId: string,\n patientId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethodResponse> => {\n doesParamExist(\n {\n businessId,\n patientId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethods(businessId, patientId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get a business patient payment methods by ref id\n * @param {String} businessId - Business ID\n * @param {String} refId - Patient ref ID\n * @param {Object} opts - Additional options\n * @returns {Object} The payment methods data\n */\nexport const getBusinessPatientPaymentMethodsByRefId = async (\n businessId: string,\n refId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethodResponse> => {\n doesParamExist(\n {\n businessId,\n refId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethodsByRefId(businessId, refId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get an account's payment method\n * @param {String} accountId - Account ID\n * @param {String} paymentMethodId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getAccountPaymentMethod = async (\n accountId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n accountId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathAccountPaymentMethod(accountId, paymentMethodId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get a business payment method\n * @param {String} businessId - Business ID\n * @param {String} paymentMethodId - Payment Method ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessPaymentMethod = async (\n businessId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentMethod(businessId, paymentMethodId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get a business patient payment method\n * @param {String} businessId - Business ID\n * @param {String} patientID - Patient ID\n * @param {String} paymentMethodId - Payment Method ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessPatientPaymentMethod = async (\n businessId: string,\n patientId: string,\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n patientId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethod(businessId, patientId, paymentMethodId) },\n {\n method: 'get'\n }\n );\n};\n\nexport interface ClientToken {\n clientToken: string;\n merchantId: string;\n source: 'mastercard';\n}\n\nexport interface NonceResponse extends ClientToken {\n nonce: string;\n sourceResponse: any;\n}\n\nexport interface ApplePayResponse extends ClientToken {\n canMakeApplePayment: boolean;\n paymentRequest: {\n countryCode: string;\n currencyCode: string;\n supportedNetworks: string[];\n merchantCapabilities: string[];\n total: { label: string; amount: string };\n };\n}\n\nexport type GetNonceResponse = ClientToken | NonceResponse | ApplePayResponse;\n\n/**\n * Get business client token\n * @param {String} businessId - Business ID\n * @param {String} source - Source of payment\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessClientToken = async (\n businessId: string,\n source: string,\n opts: MedipassRequestOpts = {}\n): Promise<ClientToken> => {\n doesParamExist(\n {\n businessId,\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentsClientTokens(businessId) },\n {\n method: 'get',\n params: {\n source\n }\n }\n );\n};\n\n/**\n * Get business payment client token\n * @param {String} businessId - Business ID\n * @param {String} patientId - Patient ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessPaymentClientToken = async (\n businessId: string,\n patientId: string,\n opts: MedipassRequestOpts = {}\n): Promise<ClientToken> => {\n doesParamExist(\n {\n businessId,\n patientId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentClientToken(businessId, patientId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get business sales client token\n * @param {String} businessId - Business ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getBusinessSalesClientToken = async (\n businessId: string,\n opts: MedipassRequestOpts = {}\n): Promise<ClientToken> => {\n doesParamExist(\n {\n businessId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessSalesClientToken(businessId) },\n {\n method: 'get'\n }\n );\n};\n\n/**\n * Get client token\n * @param {String} source - Source of payment\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const getClientToken = async (\n source: string,\n opts: MedipassRequestOpts = {\n tokenType: 'account'\n }\n): Promise<ClientToken> => {\n doesParamExist(\n {\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${PATH__PAYMENTS}/clienttoken` },\n {\n method: 'get',\n params: {\n source\n },\n tokenType: opts.tokenType\n }\n );\n};\n\n/**\n * Update an account's payment method\n * @param {String} accountId - Account ID\n * @param {String} paymentMethodId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const updateAccountPaymentMethod = async (\n accountId: string,\n paymentMethodId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n accountId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathAccountPaymentMethod(accountId, paymentMethodId) },\n {\n data: body,\n method: 'put'\n }\n );\n};\n\n/**\n * Update a business' payment method\n * @param {String} businessId - Business ID\n * @param {String} paymentMethodId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const updateBusinessPaymentMethod = async (\n businessId: string,\n paymentMethodId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPaymentMethod(businessId, paymentMethodId) },\n {\n data: body,\n method: 'put'\n }\n );\n};\n\n/**\n * Update a business patient payment method\n * @param {String} businessId - Business ID\n * @param {String} paymentMethodId - Account ID\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const updateBusinessPatientPaymentMethod = async (\n businessId: string,\n patientId: string,\n paymentMethodId: string,\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<PaymentMethod> => {\n doesParamExist(\n {\n businessId,\n patientId,\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: pathBusinessPatientPaymentMethod(businessId, patientId, paymentMethodId) },\n {\n data: body,\n method: 'put'\n }\n );\n};\n//////////////////////////////////////////////////////////////\nexport const getPaymentGatewayError = (sessionResponse: Record<string, any>) => {\n if (sessionResponse && sessionResponse.status === 'fields_in_error') {\n return ERROR_MESSAGES.PAYMENT_GATEWAY_FIELDS;\n } else if (sessionResponse && sessionResponse.status === 'system_error') {\n return ERROR_MESSAGES.PAYMENT_GATEWAY_ERROR;\n }\n\n return null;\n};\n\n/**\n * Get a business nonce\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const getNonce = async (\n {\n amount,\n businessId,\n patientId,\n cardNumber: _cardNumber,\n expiry,\n cvc,\n paymentProvider = PAYMENT_PROVIDERS.PAYMENT_CARD,\n isSales = true,\n isSelfCheckoutSession = false,\n source = 'mastercard'\n }: {\n amount?: string;\n businessId?: string;\n patientId?: string;\n cardNumber?: string;\n expiry?: string;\n cvc?: string;\n paymentProvider?:\n | typeof PAYMENT_PROVIDERS.PAYMENT_CARD\n | typeof PAYMENT_PROVIDERS.GOOGLE_PAY\n | typeof PAYMENT_PROVIDERS.APPLE_PAY;\n isSales?: boolean;\n isSelfCheckoutSession?: boolean;\n source?: 'mastercard';\n },\n opts: MedipassRequestOpts = {}\n): Promise<GetNonceResponse> => {\n const cardNumber = _cardNumber ? _cardNumber.replace(/\\s/g, '') : '';\n const cardExpiryMonth = expiry ? expiry.split('/')[0].trim() : '';\n const cardExpiryYear = expiry ? expiry.split('/')[1].trim() : '';\n const cardSecurityCode = cvc;\n let clientToken: ClientToken;\n\n if (businessId && isSales && !patientId) {\n clientToken = await getBusinessSalesClientToken(\n businessId,\n isSelfCheckoutSession\n ? {\n tokenType: 'session'\n }\n : {}\n );\n } else if (businessId && !patientId) {\n clientToken = await getBusinessClientToken(\n businessId,\n source,\n isSelfCheckoutSession\n ? {\n tokenType: 'session'\n }\n : {}\n );\n } else if (businessId && patientId) {\n clientToken = await getBusinessPaymentClientToken(businessId, patientId, {\n requestConfig: { tokenType: 'session' }\n });\n } else {\n clientToken = await getClientToken(\n source,\n isSelfCheckoutSession\n ? {\n tokenType: 'session'\n }\n : {}\n );\n }\n\n if (!clientToken.source) clientToken.source = source;\n\n if (clientToken.source === 'mastercard') {\n const paymentSession = HostedForm;\n\n if (!paymentSession) {\n throw new Error(ERROR_MESSAGES.PAYMENT_GATEWAY_ERROR);\n }\n\n if (paymentProvider === PAYMENT_PROVIDERS.PAYMENT_CARD) {\n paymentSession.setMerchant(clientToken.merchantId);\n const updateSessionResponse = await pify(paymentSession.updateSession, {\n errorFirst: false\n })(clientToken.clientToken, {\n cardNumber,\n cardExpiryMonth,\n cardExpiryYear,\n cardSecurityCode\n });\n\n if (getPaymentGatewayError(updateSessionResponse)) {\n const error = getPaymentGatewayError(updateSessionResponse);\n if (error !== null) {\n throw new Error(error);\n }\n }\n\n return { ...clientToken, nonce: clientToken.clientToken, sourceResponse: updateSessionResponse };\n }\n\n if (paymentProvider === PAYMENT_PROVIDERS.GOOGLE_PAY && amount && window?.google?.payments?.api) {\n const paymentsClient = new window.google.payments.api.PaymentsClient({\n environment: env.ENV_NAME === 'prod' || env.ENV_NAME === 'pre-prod' ? 'PRODUCTION' : 'TEST'\n });\n\n const tokenizationSpecification = {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: 'mpgs',\n gatewayMerchantId: clientToken?.merchantId\n }\n };\n\n const baseCardPaymentMethod: google.payments.api.IsReadyToPayPaymentMethodSpecification = {\n type: 'CARD',\n parameters: {\n allowedAuthMethods: ['PAN_ONLY'],\n allowedCardNetworks: ['VISA', 'MASTERCARD'],\n billingAddressRequired: false\n }\n };\n const cardPaymentMethod = Object.assign(\n { tokenizationSpecification: tokenizationSpecification },\n baseCardPaymentMethod\n );\n\n const response = await paymentsClient.isReadyToPay({\n apiVersion: 2,\n apiVersionMinor: 0,\n allowedPaymentMethods: [baseCardPaymentMethod]\n });\n\n if (response.result) {\n const paymentDataRequest = {\n apiVersion: 2,\n apiVersionMinor: 0,\n allowedPaymentMethods: [cardPaymentMethod],\n transactionInfo: {\n currencyCode: 'AUD',\n totalPriceStatus: 'FINAL' as google.payments.api.TotalPriceStatus,\n totalPrice: amount.replace('$', '')\n },\n merchantInfo: {\n merchantName: 'Tyro Health',\n merchantId: env.GOOGLE_MERCHANT_ID\n }\n };\n\n /* TODO: (optional)\n prefetch payment method data for performance boost\n */\n\n const paymentData = await paymentsClient.loadPaymentData(paymentDataRequest);\n\n return {\n ...clientToken,\n nonce: paymentData.paymentMethodData.tokenizationData.token,\n sourceResponse: paymentData\n };\n }\n }\n\n if (paymentProvider === PAYMENT_PROVIDERS.APPLE_PAY) {\n const canMakeApplePayment = window.ApplePaySession.canMakePayments();\n\n const paymentRequest = {\n countryCode: 'AU',\n currencyCode: 'AUD',\n supportedNetworks: ['visa', 'masterCard'],\n merchantCapabilities: ['supports3DS'],\n total: { label: 'Tyro Health', amount: amount?.replace('$', '') || '' }\n };\n\n return { ...clientToken, canMakeApplePayment, paymentRequest };\n }\n\n return clientToken;\n }\n\n return clientToken;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,iBAAiB;AACvB,MAAM,MAAO,UAAgE,WAAW;AAExF,MAAM,6BAA6B,cAAsB,aAAa,UAAU;AAEhF,MAAM,4BAA4B,WAAmB,oBACnD,aAAa,UA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AGhE,SAAO;;AAGT,QAAO"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { __export
|
|
2
|
-
import { require_get } from "../node_modules/lodash/get.js";
|
|
1
|
+
import { __export } from "../_virtual/rolldown_runtime.js";
|
|
3
2
|
import request_default from "../utils/request.js";
|
|
4
3
|
import does_param_exist_default from "../utils/does-param-exist.js";
|
|
5
4
|
import src_default from "../index.js";
|
|
5
|
+
import _get from "lodash/get";
|
|
6
6
|
import { isMedicare } from "@medipass/utils/funders";
|
|
7
7
|
|
|
8
8
|
//#region src/resources/self-checkout-sessions.ts
|
|
@@ -27,7 +27,6 @@ var self_checkout_sessions_exports = /* @__PURE__ */ __export({
|
|
|
27
27
|
requestOtk: () => requestOtk,
|
|
28
28
|
updateMySelfCheckoutSession: () => updateMySelfCheckoutSession
|
|
29
29
|
});
|
|
30
|
-
var import_get = /* @__PURE__ */ __toESM(require_get(), 1);
|
|
31
30
|
const PATH__SELF_CHECKOUT_SESSIONS = "/selfcheckoutsessions";
|
|
32
31
|
/**
|
|
33
32
|
* Create a self checkout session
|
|
@@ -304,9 +303,9 @@ const addPaymentMethodToSelfCheckoutSession = async (body, opts = {}) => {
|
|
|
304
303
|
const addMemberToSelfCheckoutSession = async (body = {}, opts = {}) => {
|
|
305
304
|
const { data = {}, selfCheckoutSession = {} } = body;
|
|
306
305
|
let requestBody = {};
|
|
307
|
-
if ((
|
|
306
|
+
if (_get(src_default, "member._id") && !_get(selfCheckoutSession, "member._id")) requestBody = { member: { _id: _get(src_default, "member._id") } };
|
|
308
307
|
else {
|
|
309
|
-
const [day, month, year] = (
|
|
308
|
+
const [day, month, year] = _get(data, "dob", "").split("/");
|
|
310
309
|
requestBody = { patient: {
|
|
311
310
|
firstName: data.firstName,
|
|
312
311
|
lastName: data.lastName,
|
|
@@ -325,20 +324,20 @@ const addMemberToSelfCheckoutSession = async (body = {}, opts = {}) => {
|
|
|
325
324
|
const addHealthFundAccountToSelfCheckoutSession = async (body, opts = {}) => {
|
|
326
325
|
const { data = {}, funder, selfCheckoutSession } = body;
|
|
327
326
|
const isExistingAccount = selfCheckoutSession.accountId;
|
|
328
|
-
const memberId = (
|
|
327
|
+
const memberId = _get(selfCheckoutSession, "member._id") || _get(src_default, "member._id");
|
|
329
328
|
let healthFund = data.healthFund;
|
|
330
329
|
if (isMedicare(funder.code)) healthFund = await src_default.healthfunds.getMedicareHealthFund({
|
|
331
330
|
...opts,
|
|
332
331
|
requestConfig: { tokenType: "session" }
|
|
333
332
|
});
|
|
334
333
|
let healthFundAccounts;
|
|
335
|
-
if (isExistingAccount) healthFundAccounts = await src_default.healthFundAccounts.getMembersHealthFundAccounts(memberId, { funderId: (
|
|
336
|
-
const healthFundAccountId = (
|
|
334
|
+
if (isExistingAccount) healthFundAccounts = await src_default.healthFundAccounts.getMembersHealthFundAccounts(memberId, { funderId: _get(funder, "_id") }, opts);
|
|
335
|
+
const healthFundAccountId = _get(healthFundAccounts, "items[0]._id");
|
|
337
336
|
let healthFundAccount;
|
|
338
337
|
let requestBody = {};
|
|
339
338
|
if (data.membershipNumber || data.cardNumber) {
|
|
340
339
|
const healthFundAccountRequestBody = {
|
|
341
|
-
healthFundId: (
|
|
340
|
+
healthFundId: _get(healthFund, "_id"),
|
|
342
341
|
...data || {}
|
|
343
342
|
};
|
|
344
343
|
if (isExistingAccount) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"self-checkout-sessions.js","names":["request","sdk","paymentMethod"],"sources":["../../src/resources/self-checkout-sessions.ts"],"sourcesContent":["import _get from 'lodash/get';\nimport { isMedicare } from '@medipass/utils/funders';\nimport sdk from '../index';\nimport request from '../utils/request';\nimport doesParamExist from '../utils/does-param-exist';\nimport type { MedipassRequestOpts } from '../types';\nconst PATH__SELF_CHECKOUT_SESSIONS = '/selfcheckoutsessions';\n\n/**\n * Create a self checkout session\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const createSelfCheckoutSession = async (\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: PATH__SELF_CHECKOUT_SESSIONS },\n {\n method: 'post',\n data: body\n }\n );\n};\n\n/**\n * Approve my self checkout session\n * @param {Object} body - request body\n * @param {Object} opts - Additional options\n */\nexport const approve = async (\n body?: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/approvals` },\n {\n method: 'post',\n data: body,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Cancel my self checkout session\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const cancel = async (\n body?: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/cancellations` },\n {\n method: 'post',\n data: body,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Cancel my self checkout session\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const cancelSession = async (\n body?: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/cancels` },\n {\n method: 'post',\n data: body,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Create invoice for my self checkout session\n * @param {Object} opts - Additional options\n */\nexport const createMyInvoice = async (opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/invoices` },\n {\n method: 'post',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Create payment authority for my self checkout session\n * @param {Object} opts - Additional options\n */\nexport const createPaymentAuthority = async (opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentauthorities` },\n {\n method: 'post',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Create payment method for my self checkout session\n * @param {String} nonce - Nonce\n * @param {String} source - Source of payment\n * @param {Object} opts - Additional options\n */\nexport const createPaymentMethod = async (\n nonce: string,\n source: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n nonce,\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentmethods` },\n {\n method: 'post',\n data: {\n nonce,\n source\n },\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Get payment methods for my self checkout session\n * @param {Object} opts - Additional options\n */\nexport const getPaymentMethods = async (opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentmethods` },\n {\n method: 'get',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Discover member for a self checkout session\n * @param {Object} ids - Find by ids (Accepts: `memberId` and `email`)\n * @param {Object} query - Additional query parameters\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const discoverMember = async (\n {\n email,\n memberId\n }: {\n email?: string;\n memberId?: string;\n },\n query: Record<string, any> = {},\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n email,\n memberId\n },\n opts.hyperMediaEndpoint,\n {\n atLeastOneExists: true\n }\n );\n const params = Object.assign({}, query, {\n email,\n memberId\n });\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/discovery/members` },\n {\n method: 'get',\n params,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Check for duplicate member\n * @param {Object} body - Additional request body\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const checkDupe = async (\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/checkdupe` },\n {\n method: 'post',\n data: body,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Get my self checkout session\n * @param {Object} opts - Additional options\n */\nexport const getMySelfCheckoutSession = async (opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me` },\n {\n method: 'get',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Get transaction for self checkout session\n * @param {Object} opts - Additional options\n */\nexport const getMySelfCheckoutSessionTransaction = async (\n checkoutSessionId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/${checkoutSessionId}/transaction` },\n {\n method: 'get',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Remember me\n * @param {Object} opts - Additional options\n */\nexport const rememberMe = async (opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/rememberme` },\n {\n method: 'post',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Update my self checkout session\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const updateMySelfCheckoutSession = async (\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me` },\n {\n method: 'put',\n data: body,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Request OTK for a self checkout session\n * @param {String} accountId - Account ID\n * @param {Object} opts - Additional options\n */\nexport const requestOtk = async (accountId: string, opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n doesParamExist(\n {\n accountId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/otk` },\n {\n method: 'post',\n data: {\n accountId\n },\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Add a payment method to a self checkout session\n * @param {Object} body - Config for the method.\n * @param {Object} opts - Additional options\n */\nexport const addPaymentMethodToSelfCheckoutSession = async (\n body: {\n data?: Record<string, any>;\n selfCheckoutSession: Record<string, any>;\n },\n opts: MedipassRequestOpts = {}\n) => {\n const { data = {}, selfCheckoutSession } = body;\n const isExistingAccount = Boolean(selfCheckoutSession.accountId);\n let requestBody = {};\n let paymentMethod;\n\n // If card data exists, then add the card data to the self checkout session.\n if (data.cardNumber && data.expiry && data.cvc) {\n const nonceResponse = await sdk.payments.getNonce({\n cardNumber: data.cardNumber,\n expiry: data.expiry,\n cvc: data.cvc,\n isSelfCheckoutSession: true\n });\n\n // Type guard to check if nonce exists\n if (!('nonce' in nonceResponse)) {\n throw new Error('Nonce not available in response');\n }\n\n const source = nonceResponse?.source;\n const nonce = nonceResponse?.nonce;\n\n // If there is an existing account, create a new payment method and attach it to the self checkout session.\n if (isExistingAccount) {\n paymentMethod = await sdk.payments.createAccountPaymentMethod(selfCheckoutSession.accountId, nonce, source, opts);\n requestBody = {\n paymentMethod: {\n _id: paymentMethod._id\n }\n };\n } else {\n // Otherwise, we want to create a payment method on the self checkout session.\n await createPaymentMethod(nonce, source, opts);\n }\n } else if (data._id) {\n // If a payment method id is specified, attach it to the self checkout session.\n requestBody = {\n paymentMethod: {\n _id: data._id\n }\n };\n } else if (isExistingAccount) {\n // If there is an existing account, try get their payment method and attach it to the self checkout session.\n const paymentMethods = await sdk.payments.getAccountPaymentMethods(selfCheckoutSession.accountId, opts);\n paymentMethod = paymentMethods.find(paymentMethod => Boolean(paymentMethod.isDefault));\n\n if (paymentMethod) {\n requestBody = {\n paymentMethod: {\n _id: paymentMethod._id\n }\n };\n }\n }\n\n const newSelfCheckoutSession = await updateMySelfCheckoutSession(requestBody, opts);\n return {\n paymentMethod,\n selfCheckoutSession: newSelfCheckoutSession\n };\n};\n\n/**\n * Add a member to a self checkout session\n * @param {Object} body - Config for the method.\n * @param {Object} opts - Additional options\n */\nexport const addMemberToSelfCheckoutSession = async (\n body: {\n data?: Record<string, any>;\n selfCheckoutSession?: Record<string, any>;\n } = {},\n opts: MedipassRequestOpts = {}\n) => {\n const { data = {}, selfCheckoutSession = {} } = body;\n let requestBody = {};\n\n // If a member exists and there isn't already one attached to the self checkout session, then attach the member.\n if (_get(sdk, 'member._id') && !_get(selfCheckoutSession, 'member._id')) {\n requestBody = {\n member: {\n _id: _get(sdk, 'member._id')\n }\n };\n } else {\n // Otherwise, add member manually to the self checkout session.\n const [day, month, year] = _get(data, 'dob', '').split('/');\n\n requestBody = {\n patient: {\n firstName: data.firstName,\n lastName: data.lastName,\n email: data.email,\n mobile: data.mobile,\n dobString: day && month && year ? `${year}-${month}-${day}` : undefined\n }\n };\n }\n\n const newSelfCheckoutSession = await updateMySelfCheckoutSession(requestBody, opts);\n return {\n selfCheckoutSession: newSelfCheckoutSession\n };\n};\n\n/**\n * Add a health fund account to a self checkout session\n * @param {Object} body - Config for the method.\n * @param {Object} opts - Additional options\n */\nexport const addHealthFundAccountToSelfCheckoutSession = async (\n body: {\n data?: Record<string, any>;\n funder: Record<string, any>;\n selfCheckoutSession: Record<string, any>;\n },\n opts: MedipassRequestOpts = {}\n) => {\n const { data = {}, funder, selfCheckoutSession } = body;\n const isExistingAccount = selfCheckoutSession.accountId;\n\n const memberId = _get(selfCheckoutSession, 'member._id') || _get(sdk, 'member._id');\n\n let healthFund = data.healthFund;\n\n if (isMedicare(funder.code)) {\n healthFund = await sdk.healthfunds.getMedicareHealthFund({\n ...opts,\n requestConfig: {\n tokenType: 'session'\n }\n });\n }\n\n // If there is an existing account, we will need to get their existing health fund accounts to use below.\n let healthFundAccounts;\n\n if (isExistingAccount) {\n healthFundAccounts = await sdk.healthFundAccounts.getMembersHealthFundAccounts(\n memberId,\n {\n funderId: _get(funder, '_id')\n },\n opts\n );\n }\n\n const healthFundAccountId = _get(healthFundAccounts, 'items[0]._id');\n\n let healthFundAccount;\n let requestBody = {};\n\n // If health fund account data exists, then add the data to the self checkout session.\n if (data.membershipNumber || data.cardNumber) {\n const healthFundAccountRequestBody = {\n healthFundId: _get(healthFund, '_id'),\n ...(data || {})\n };\n\n // If it's an existing account, delete their current health fund account (if any), and add the new one to their account.\n if (isExistingAccount) {\n if (healthFundAccountId) {\n await sdk.healthFundAccounts.deleteMembersHealthFundAccount(memberId, healthFundAccountId, opts);\n }\n\n healthFundAccount = await sdk.healthFundAccounts.createMembersHealthFundAccount(\n memberId,\n healthFundAccountRequestBody,\n opts\n );\n requestBody = {\n healthFundAccount: {\n _id: healthFundAccount._id\n }\n };\n } else {\n // Otherwise, just add the data to the self checkout session.\n requestBody = {\n healthFundAccount: healthFundAccountRequestBody\n };\n }\n } else if (data._id) {\n // If a health fund account id is specified, attach it to the self checkout session.\n requestBody = {\n healthFundAccount: {\n _id: data._id\n }\n };\n } else if (isExistingAccount) {\n // If there is an existing account, try get the health fund account and attach it to the self checkout session.\n if (healthFundAccountId) {\n healthFundAccount = await sdk.healthFundAccounts.getMembersHealthFundAccount(memberId, healthFundAccountId, opts);\n requestBody = {\n healthFundAccount: {\n _id: healthFundAccount._id\n }\n };\n }\n }\n\n const newSelfCheckoutSession = await updateMySelfCheckoutSession(requestBody, opts);\n return {\n healthFundAccount,\n selfCheckoutSession: newSelfCheckoutSession\n };\n};\n\n/**\n * Delete payment method\n * @param {String} paymentMethodId - Payment method ID\n * @param {Object} opts - Additional options\n */\nexport const deletePaymentMethod = async (\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentmethods/${paymentMethodId}` },\n {\n method: 'delete',\n tokenType: 'session'\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,+BAA+B;;;;;;AAOrC,MAAa,4BAA4B,OACvC,MACA,OAA4B,EAAE,KACG;AACjC,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM;EAA8B,EAC/C;EACE,QAAQ;EACR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KAAK;AAGlG,uBAAoB,MAAMA,YAAI,mBAAmB,+BAC/C,UACA,8BACA,KACD;AACD,iBAAc,EACZ,mBAAmB,EACjB,KAAK,kBAAkB,KACxB,EACF;QAGD,eAAc,EACZ,mBAAmB,8BACpB;YAEM,KAAK,IAEd,eAAc,EACZ,mBAAmB,EACjB,KAAK,KAAK,KACX,EACF;UACQ,mBAET;MAAI,qBAAqB;AACvB,uBAAoB,MAAMA,YAAI,mBAAmB,4BAA4B,UAAU,qBAAqB,KAAK;AACjH,iBAAc,EACZ,mBAAmB,EACjB,KAAK,kBAAkB,KACxB,EACF;;;CAIL,MAAM,yBAAyB,MAAM,4BAA4B,aAAa,KAAK;AACnF,QAAO;EACL;EACA,qBAAqB;EACtB;;;;;;;AAQH,MAAa,sBAAsB,OACjC,iBACA,OAA4B,EAAE,KACG;AACjC,0BACE,EACE,iBACD,EACD,KAAK,mBACN;AACD,QAAOD,gBACL;EAAE,GAAG;EAAM,MAAM,GAAG,6BAA6B,qBAAqB;EAAmB,EACzF;EACE,QAAQ;EACR,WAAW;EACZ,CACF"}
|
|
1
|
+
{"version":3,"file":"self-checkout-sessions.js","names":["request","sdk","paymentMethod"],"sources":["../../src/resources/self-checkout-sessions.ts"],"sourcesContent":["import _get from 'lodash/get';\nimport { isMedicare } from '@medipass/utils/funders';\nimport sdk from '../index';\nimport request from '../utils/request';\nimport doesParamExist from '../utils/does-param-exist';\nimport type { MedipassRequestOpts } from '../types';\nconst PATH__SELF_CHECKOUT_SESSIONS = '/selfcheckoutsessions';\n\n/**\n * Create a self checkout session\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const createSelfCheckoutSession = async (\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: PATH__SELF_CHECKOUT_SESSIONS },\n {\n method: 'post',\n data: body\n }\n );\n};\n\n/**\n * Approve my self checkout session\n * @param {Object} body - request body\n * @param {Object} opts - Additional options\n */\nexport const approve = async (\n body?: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/approvals` },\n {\n method: 'post',\n data: body,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Cancel my self checkout session\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const cancel = async (\n body?: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/cancellations` },\n {\n method: 'post',\n data: body,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Cancel my self checkout session\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const cancelSession = async (\n body?: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/cancels` },\n {\n method: 'post',\n data: body,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Create invoice for my self checkout session\n * @param {Object} opts - Additional options\n */\nexport const createMyInvoice = async (opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/invoices` },\n {\n method: 'post',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Create payment authority for my self checkout session\n * @param {Object} opts - Additional options\n */\nexport const createPaymentAuthority = async (opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentauthorities` },\n {\n method: 'post',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Create payment method for my self checkout session\n * @param {String} nonce - Nonce\n * @param {String} source - Source of payment\n * @param {Object} opts - Additional options\n */\nexport const createPaymentMethod = async (\n nonce: string,\n source: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n nonce,\n source\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentmethods` },\n {\n method: 'post',\n data: {\n nonce,\n source\n },\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Get payment methods for my self checkout session\n * @param {Object} opts - Additional options\n */\nexport const getPaymentMethods = async (opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentmethods` },\n {\n method: 'get',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Discover member for a self checkout session\n * @param {Object} ids - Find by ids (Accepts: `memberId` and `email`)\n * @param {Object} query - Additional query parameters\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const discoverMember = async (\n {\n email,\n memberId\n }: {\n email?: string;\n memberId?: string;\n },\n query: Record<string, any> = {},\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n email,\n memberId\n },\n opts.hyperMediaEndpoint,\n {\n atLeastOneExists: true\n }\n );\n const params = Object.assign({}, query, {\n email,\n memberId\n });\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/discovery/members` },\n {\n method: 'get',\n params,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Check for duplicate member\n * @param {Object} body - Additional request body\n * @param {Object} opts - Additional options\n * @returns {Object} The device data\n */\nexport const checkDupe = async (\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/checkdupe` },\n {\n method: 'post',\n data: body,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Get my self checkout session\n * @param {Object} opts - Additional options\n */\nexport const getMySelfCheckoutSession = async (opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me` },\n {\n method: 'get',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Get transaction for self checkout session\n * @param {Object} opts - Additional options\n */\nexport const getMySelfCheckoutSessionTransaction = async (\n checkoutSessionId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/${checkoutSessionId}/transaction` },\n {\n method: 'get',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Remember me\n * @param {Object} opts - Additional options\n */\nexport const rememberMe = async (opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/rememberme` },\n {\n method: 'post',\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Update my self checkout session\n * @param {Object} body - Request body\n * @param {Object} opts - Additional options\n */\nexport const updateMySelfCheckoutSession = async (\n body: Record<string, any>,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me` },\n {\n method: 'put',\n data: body,\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Request OTK for a self checkout session\n * @param {String} accountId - Account ID\n * @param {Object} opts - Additional options\n */\nexport const requestOtk = async (accountId: string, opts: MedipassRequestOpts = {}): Promise<Record<string, any>> => {\n doesParamExist(\n {\n accountId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/otk` },\n {\n method: 'post',\n data: {\n accountId\n },\n tokenType: 'session'\n }\n );\n};\n\n/**\n * Add a payment method to a self checkout session\n * @param {Object} body - Config for the method.\n * @param {Object} opts - Additional options\n */\nexport const addPaymentMethodToSelfCheckoutSession = async (\n body: {\n data?: Record<string, any>;\n selfCheckoutSession: Record<string, any>;\n },\n opts: MedipassRequestOpts = {}\n) => {\n const { data = {}, selfCheckoutSession } = body;\n const isExistingAccount = Boolean(selfCheckoutSession.accountId);\n let requestBody = {};\n let paymentMethod;\n\n // If card data exists, then add the card data to the self checkout session.\n if (data.cardNumber && data.expiry && data.cvc) {\n const nonceResponse = await sdk.payments.getNonce({\n cardNumber: data.cardNumber,\n expiry: data.expiry,\n cvc: data.cvc,\n isSelfCheckoutSession: true\n });\n\n // Type guard to check if nonce exists\n if (!('nonce' in nonceResponse)) {\n throw new Error('Nonce not available in response');\n }\n\n const source = nonceResponse?.source;\n const nonce = nonceResponse?.nonce;\n\n // If there is an existing account, create a new payment method and attach it to the self checkout session.\n if (isExistingAccount) {\n paymentMethod = await sdk.payments.createAccountPaymentMethod(selfCheckoutSession.accountId, nonce, source, opts);\n requestBody = {\n paymentMethod: {\n _id: paymentMethod._id\n }\n };\n } else {\n // Otherwise, we want to create a payment method on the self checkout session.\n await createPaymentMethod(nonce, source, opts);\n }\n } else if (data._id) {\n // If a payment method id is specified, attach it to the self checkout session.\n requestBody = {\n paymentMethod: {\n _id: data._id\n }\n };\n } else if (isExistingAccount) {\n // If there is an existing account, try get their payment method and attach it to the self checkout session.\n const paymentMethods = await sdk.payments.getAccountPaymentMethods(selfCheckoutSession.accountId, opts);\n paymentMethod = paymentMethods.find(paymentMethod => Boolean(paymentMethod.isDefault));\n\n if (paymentMethod) {\n requestBody = {\n paymentMethod: {\n _id: paymentMethod._id\n }\n };\n }\n }\n\n const newSelfCheckoutSession = await updateMySelfCheckoutSession(requestBody, opts);\n return {\n paymentMethod,\n selfCheckoutSession: newSelfCheckoutSession\n };\n};\n\n/**\n * Add a member to a self checkout session\n * @param {Object} body - Config for the method.\n * @param {Object} opts - Additional options\n */\nexport const addMemberToSelfCheckoutSession = async (\n body: {\n data?: Record<string, any>;\n selfCheckoutSession?: Record<string, any>;\n } = {},\n opts: MedipassRequestOpts = {}\n) => {\n const { data = {}, selfCheckoutSession = {} } = body;\n let requestBody = {};\n\n // If a member exists and there isn't already one attached to the self checkout session, then attach the member.\n if (_get(sdk, 'member._id') && !_get(selfCheckoutSession, 'member._id')) {\n requestBody = {\n member: {\n _id: _get(sdk, 'member._id')\n }\n };\n } else {\n // Otherwise, add member manually to the self checkout session.\n const [day, month, year] = _get(data, 'dob', '').split('/');\n\n requestBody = {\n patient: {\n firstName: data.firstName,\n lastName: data.lastName,\n email: data.email,\n mobile: data.mobile,\n dobString: day && month && year ? `${year}-${month}-${day}` : undefined\n }\n };\n }\n\n const newSelfCheckoutSession = await updateMySelfCheckoutSession(requestBody, opts);\n return {\n selfCheckoutSession: newSelfCheckoutSession\n };\n};\n\n/**\n * Add a health fund account to a self checkout session\n * @param {Object} body - Config for the method.\n * @param {Object} opts - Additional options\n */\nexport const addHealthFundAccountToSelfCheckoutSession = async (\n body: {\n data?: Record<string, any>;\n funder: Record<string, any>;\n selfCheckoutSession: Record<string, any>;\n },\n opts: MedipassRequestOpts = {}\n) => {\n const { data = {}, funder, selfCheckoutSession } = body;\n const isExistingAccount = selfCheckoutSession.accountId;\n\n const memberId = _get(selfCheckoutSession, 'member._id') || _get(sdk, 'member._id');\n\n let healthFund = data.healthFund;\n\n if (isMedicare(funder.code)) {\n healthFund = await sdk.healthfunds.getMedicareHealthFund({\n ...opts,\n requestConfig: {\n tokenType: 'session'\n }\n });\n }\n\n // If there is an existing account, we will need to get their existing health fund accounts to use below.\n let healthFundAccounts;\n\n if (isExistingAccount) {\n healthFundAccounts = await sdk.healthFundAccounts.getMembersHealthFundAccounts(\n memberId,\n {\n funderId: _get(funder, '_id')\n },\n opts\n );\n }\n\n const healthFundAccountId = _get(healthFundAccounts, 'items[0]._id');\n\n let healthFundAccount;\n let requestBody = {};\n\n // If health fund account data exists, then add the data to the self checkout session.\n if (data.membershipNumber || data.cardNumber) {\n const healthFundAccountRequestBody = {\n healthFundId: _get(healthFund, '_id'),\n ...(data || {})\n };\n\n // If it's an existing account, delete their current health fund account (if any), and add the new one to their account.\n if (isExistingAccount) {\n if (healthFundAccountId) {\n await sdk.healthFundAccounts.deleteMembersHealthFundAccount(memberId, healthFundAccountId, opts);\n }\n\n healthFundAccount = await sdk.healthFundAccounts.createMembersHealthFundAccount(\n memberId,\n healthFundAccountRequestBody,\n opts\n );\n requestBody = {\n healthFundAccount: {\n _id: healthFundAccount._id\n }\n };\n } else {\n // Otherwise, just add the data to the self checkout session.\n requestBody = {\n healthFundAccount: healthFundAccountRequestBody\n };\n }\n } else if (data._id) {\n // If a health fund account id is specified, attach it to the self checkout session.\n requestBody = {\n healthFundAccount: {\n _id: data._id\n }\n };\n } else if (isExistingAccount) {\n // If there is an existing account, try get the health fund account and attach it to the self checkout session.\n if (healthFundAccountId) {\n healthFundAccount = await sdk.healthFundAccounts.getMembersHealthFundAccount(memberId, healthFundAccountId, opts);\n requestBody = {\n healthFundAccount: {\n _id: healthFundAccount._id\n }\n };\n }\n }\n\n const newSelfCheckoutSession = await updateMySelfCheckoutSession(requestBody, opts);\n return {\n healthFundAccount,\n selfCheckoutSession: newSelfCheckoutSession\n };\n};\n\n/**\n * Delete payment method\n * @param {String} paymentMethodId - Payment method ID\n * @param {Object} opts - Additional options\n */\nexport const deletePaymentMethod = async (\n paymentMethodId: string,\n opts: MedipassRequestOpts = {}\n): Promise<Record<string, any>> => {\n doesParamExist(\n {\n paymentMethodId\n },\n opts.hyperMediaEndpoint\n );\n return request(\n { ...opts, path: `${PATH__SELF_CHECKOUT_SESSIONS}/me/paymentmethods/${paymentMethodId}` },\n {\n method: 'delete',\n tokenType: 'session'\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,+BAA+B;;;;;;AAOrC,MAAa,4BAA4B,OACvC,MACA,OAA4B,EAAE,KACG;AACjC,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM;EAA8B,EAC/C;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;;AAQH,MAAa,UAAU,OACrB,MACA,OAA4B,EAAE,KACG;AACjC,QAAOA,gBACL;EAAE,GAAG;EAAM,MAAM,GAAG,6BAA6B;EAAgB,EACjE;EACE,QAAQ;EACR,MAAM;EACN,WAAW;EACZ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c,EACZ,mBAAmB,8BACpB;YAEM,KAAK,IAEd,eAAc,EACZ,mBAAmB,EACjB,KAAK,KAAK,KACX,EACF;UACQ,mBAET;MAAI,qBAAqB;AACvB,uBAAoB,MAAMA,YAAI,mBAAmB,4BAA4B,UAAU,qBAAqB,KAAK;AACjH,iBAAc,EACZ,mBAAmB,EACjB,KAAK,kBAAkB,KACxB,EACF;;;CAIL,MAAM,yBAAyB,MAAM,4BAA4B,aAAa,KAAK;AACnF,QAAO;EACL;EACA,qBAAqB;EACtB;;;;;;;AAQH,MAAa,sBAAsB,OACjC,iBACA,OAA4B,EAAE,KACG;AACjC,0BACE,EACE,iBACD,EACD,KAAK,mBACN;AACD,QAAOD,gBACL;EAAE,GAAG;EAAM,MAAM,GAAG,6BAA6B,qBAAqB;EAAmB,EACzF;EACE,QAAQ;EACR,WAAW;EACZ,CACF"}
|
package/dist/services/storage.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { require_sessionStorage } from "../node_modules/store/storages/sessionStorage.js";
|
|
1
|
+
import storageEngine from "store/src/store-engine";
|
|
2
|
+
import localStorage from "store/storages/localStorage";
|
|
3
|
+
import sessionStorage from "store/storages/sessionStorage";
|
|
5
4
|
import maskedModule from "@medipass/utils/masked";
|
|
6
5
|
import { VERY_SENSITIVE_KEYS } from "@medipass/utils/sensitive-keys";
|
|
7
6
|
|
|
8
7
|
//#region src/services/storage.ts
|
|
9
|
-
var import_store_engine = /* @__PURE__ */ __toESM(require_store_engine(), 1);
|
|
10
|
-
var import_localStorage = /* @__PURE__ */ __toESM(require_localStorage(), 1);
|
|
11
|
-
var import_sessionStorage = /* @__PURE__ */ __toESM(require_sessionStorage(), 1);
|
|
12
8
|
const STORAGE_PREFIX = "medipass-web-sdk";
|
|
13
9
|
const PERSIST_KEYS = [
|
|
14
10
|
"_persist",
|
|
@@ -24,8 +20,8 @@ const noopStore = {
|
|
|
24
20
|
set: (key, val) => {}
|
|
25
21
|
};
|
|
26
22
|
const stores = {
|
|
27
|
-
default: typeof window !== "undefined" && window.navigator.cookieEnabled ?
|
|
28
|
-
session: typeof window !== "undefined" && window.navigator.cookieEnabled ?
|
|
23
|
+
default: typeof window !== "undefined" && window.navigator.cookieEnabled ? storageEngine.createStore(localStorage) : noopStore,
|
|
24
|
+
session: typeof window !== "undefined" && window.navigator.cookieEnabled ? storageEngine.createStore(sessionStorage) : noopStore
|
|
29
25
|
};
|
|
30
26
|
const storeTypes = Object.keys(stores);
|
|
31
27
|
const clearAll = (opts = {}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","names":[
|
|
1
|
+
{"version":3,"file":"storage.js","names":[],"sources":["../../src/services/storage.ts"],"sourcesContent":["// @ts-expect-error TS(7016): Could not find a declaration file for module 'stor... Remove this comment to see the full error message\nimport storageEngine from 'store/src/store-engine';\n// @ts-expect-error TS(7016): Could not find a declaration file for module 'stor... Remove this comment to see the full error message\nimport localStorage from 'store/storages/localStorage';\n// @ts-expect-error TS(7016): Could not find a declaration file for module 'stor... Remove this comment to see the full error message\nimport sessionStorage from 'store/storages/sessionStorage';\nimport maskedModule from '@medipass/utils/masked';\nimport { VERY_SENSITIVE_KEYS } from '@medipass/utils/sensitive-keys';\nconst STORAGE_PREFIX = 'medipass-web-sdk';\nconst PERSIST_KEYS = ['_persist', 'device', 'savedEmail', 'rememberEmail'];\nconst masked = (maskedModule as typeof maskedModule & { default?: typeof maskedModule }).default ?? maskedModule;\nexport type StoreType = 'default' | 'session';\nexport type CommonOpts = {\n storeType?: StoreType;\n};\nexport type SetOpts = CommonOpts & {\n override?: boolean;\n};\nconst noopStore = {\n // @ts-expect-error TS(7006): Parameter 'key' implicitly has an 'any' type.\n get: key => {},\n // @ts-expect-error TS(7006): Parameter 'key' implicitly has an 'any' type.\n remove: key => {},\n // @ts-expect-error TS(7006): Parameter 'val' implicitly has an 'any' type.\n each: (val, key) => {},\n // @ts-expect-error TS(7006): Parameter 'key' implicitly has an 'any' type.\n set: (key, val) => {}\n};\n\nconst stores = {\n default:\n typeof window !== 'undefined' && window.navigator.cookieEnabled\n ? storageEngine.createStore(localStorage)\n : noopStore,\n session:\n typeof window !== 'undefined' && window.navigator.cookieEnabled\n ? storageEngine.createStore(sessionStorage)\n : noopStore\n};\nconst storeTypes = Object.keys(stores);\nexport const clearAll = (opts: CommonOpts = {}) => {\n // @ts-expect-error TS(7006): Parameter 'storeType' implicitly has an 'any' type... Remove this comment to see the full error message\n function clear(storeType) {\n // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message\n stores[storeType].each((val, key) => {\n key = key.replace(`${STORAGE_PREFIX}.`, '');\n const shouldPersist = PERSIST_KEYS.some(persistKey => key.includes(persistKey));\n\n if (shouldPersist) {\n return;\n }\n\n // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message\n stores[storeType].remove(`${STORAGE_PREFIX}.${key}`);\n });\n }\n\n // If a store type has been chosen, then clear all from that store type. Otherwise, clear all from every store type.\n if (opts.storeType) {\n clear(opts.storeType);\n } else {\n storeTypes.forEach(storeType => clear(storeType));\n }\n};\nexport const get = (key: string, opts: CommonOpts = {}) => {\n const storeType = opts.storeType || 'default';\n return stores[storeType].get(`${STORAGE_PREFIX}.${key}`);\n};\nexport const remove = (key: string, opts: CommonOpts = {}) => {\n // If a store type has been chosen, then clear all from that store type. Otherwise, clear all from every store type.\n if (opts.storeType) {\n stores[opts.storeType].remove(`${STORAGE_PREFIX}.${key}`);\n } else {\n // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message\n storeTypes.forEach(storeType => stores[storeType].remove(`${STORAGE_PREFIX}.${key}`));\n }\n};\nexport const set = (key: string, val: any, opts: SetOpts = {}) => {\n const storeType = opts.storeType || 'default';\n\n if (opts && opts.override) {\n stores[storeType].set(\n `${STORAGE_PREFIX}.${key}`,\n masked({ ...get(key), ...val }, VERY_SENSITIVE_KEYS, {\n omitKeys: true\n })\n );\n return;\n }\n\n stores[storeType].set(\n `${STORAGE_PREFIX}.${key}`,\n masked(val, VERY_SENSITIVE_KEYS, {\n omitKeys: true\n })\n );\n};\n\nconst _createStorageResource = (key: string) => ({\n get: () => get(key),\n set: (value: any, opts?: SetOpts) => set(key, value, opts),\n remove: () => remove(key)\n});\n\nconst storage = {\n clearAll,\n remove,\n get,\n set,\n onboardingStatus: _createStorageResource('onboardingStatus'),\n previousCreatePHITransactionFormValues: _createStorageResource('previousTransactionFormValues')\n};\n\nexport default storage;\n"],"mappings":";;;;;;;AAQA,MAAM,iBAAiB;AACvB,MAAM,eAAe;CAAC;CAAY;CAAU;CAAc;CAAgB;AAC1E,MAAM,SAAU,aAAyE,WAAW;AAQpG,MAAM,YAAY;CAEhB,MAAK,QAAO;CAEZ,SAAQ,QAAO;CAEf,OAAO,KAAK,QAAQ;CAEpB,MAAM,KAAK,QAAQ;CACpB;AAED,MAAM,SAAS;CACb,SACE,OAAO,WAAW,eAAe,OAAO,UAAU,gBAC9C,cAAc,YAAY,aAAa,GACvC;CACN,SACE,OAAO,WAAW,eAAe,OAAO,UAAU,gBAC9C,cAAc,YAAY,eAAe,GACzC;CACP;AACD,MAAM,aAAa,OAAO,KAAK,OAAO;AACtC,MAAa,YAAY,OAAmB,EAAE,KAAK;CAEjD,SAAS,MAAM,WAAW;AAExB,SAAO,WAAW,MAAM,KAAK,QAAQ;AACnC,SAAM,IAAI,QAAQ,GAAG,eAAe,IAAI,GAAG;AAG3C,OAFsB,aAAa,MAAK,eAAc,IAAI,SAAS,WAAW,CAAC,CAG7E;AAIF,UAAO,WAAW,OAAO,GAAG,eAAe,GAAG,MAAM;IACpD;;AAIJ,KAAI,KAAK,UACP,OAAM,KAAK,UAAU;KAErB,YAAW,SAAQ,cAAa,MAAM,UAAU,CAAC;;AAGrD,MAAa,OAAO,KAAa,OAAmB,EAAE,KAAK;AAEzD,QAAO,OADW,KAAK,aAAa,WACX,IAAI,GAAG,eAAe,GAAG,MAAM;;AAE1D,MAAa,UAAU,KAAa,OAAmB,EAAE,KAAK;AAE5D,KAAI,KAAK,UACP,QAAO,KAAK,WAAW,OAAO,GAAG,eAAe,GAAG,MAAM;KAGzD,YAAW,SAAQ,cAAa,OAAO,WAAW,OAAO,GAAG,eAAe,GAAG,MAAM,CAAC;;AAGzF,MAAa,OAAO,KAAa,KAAU,OAAgB,EAAE,KAAK;CAChE,MAAM,YAAY,KAAK,aAAa;AAEpC,KAAI,QAAQ,KAAK,UAAU;AACzB,SAAO,WAAW,IAChB,GAAG,eAAe,GAAG,OACrB,OAAO;GAAE,GAAG,IAAI,IAAI;GAAE,GAAG;GAAK,EAAE,qBAAqB,EACnD,UAAU,MACX,CAAC,CACH;AACD;;AAGF,QAAO,WAAW,IAChB,GAAG,eAAe,GAAG,OACrB,OAAO,KAAK,qBAAqB,EAC/B,UAAU,MACX,CAAC,CACH;;AAGH,MAAM,0BAA0B,SAAiB;CAC/C,WAAW,IAAI,IAAI;CACnB,MAAM,OAAY,SAAmB,IAAI,KAAK,OAAO,KAAK;CAC1D,cAAc,OAAO,IAAI;CAC1B;AAED,MAAM,UAAU;CACd;CACA;CACA;CACA;CACA,kBAAkB,uBAAuB,mBAAmB;CAC5D,wCAAwC,uBAAuB,gCAAgC;CAChG;AAED,sBAAe"}
|
package/dist/services/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { __export
|
|
2
|
-
import { require_get } from "../node_modules/lodash/get.js";
|
|
3
|
-
import { require_compare_versions } from "../node_modules/compare-versions/index.js";
|
|
1
|
+
import { __export } from "../_virtual/rolldown_runtime.js";
|
|
4
2
|
import src_default from "../index.js";
|
|
3
|
+
import _get from "lodash/get";
|
|
4
|
+
import compareVersions from "compare-versions";
|
|
5
5
|
|
|
6
6
|
//#region src/services/version.ts
|
|
7
7
|
var version_exports = /* @__PURE__ */ __export({
|
|
@@ -11,12 +11,10 @@ var version_exports = /* @__PURE__ */ __export({
|
|
|
11
11
|
getCurrentAppVersion: () => getCurrentAppVersion,
|
|
12
12
|
setCurrentAppVersion: () => setCurrentAppVersion
|
|
13
13
|
});
|
|
14
|
-
var import_compare_versions = /* @__PURE__ */ __toESM(require_compare_versions(), 1);
|
|
15
|
-
var import_get = /* @__PURE__ */ __toESM(require_get(), 1);
|
|
16
14
|
/**
|
|
17
15
|
* Get current app version
|
|
18
16
|
*/
|
|
19
|
-
const getCurrentAppVersion = () => (
|
|
17
|
+
const getCurrentAppVersion = () => _get(src_default, "appVersion");
|
|
20
18
|
/**
|
|
21
19
|
* Set current app version
|
|
22
20
|
*/
|
|
@@ -33,7 +31,7 @@ const fetchLatestAppVersion = async () => {
|
|
|
33
31
|
if (res.status === 404) return null;
|
|
34
32
|
throw new Error(`HTTP error: ${res.status}`);
|
|
35
33
|
}
|
|
36
|
-
return (
|
|
34
|
+
return _get(await res.json(), "app_version");
|
|
37
35
|
} catch (err) {
|
|
38
36
|
if (err instanceof Error && err.message.includes("404")) return null;
|
|
39
37
|
throw err;
|
|
@@ -44,7 +42,7 @@ const fetchLatestAppVersion = async () => {
|
|
|
44
42
|
*/
|
|
45
43
|
const fetchMinimumAppVerson = async () => {
|
|
46
44
|
try {
|
|
47
|
-
return (
|
|
45
|
+
return _get(await src_default.applications.getSelfApplication(), "minVersion");
|
|
48
46
|
} catch (err) {
|
|
49
47
|
throw err;
|
|
50
48
|
}
|
|
@@ -63,12 +61,12 @@ const checkAppVersion = async () => {
|
|
|
63
61
|
latestVersion,
|
|
64
62
|
minimumVersion
|
|
65
63
|
};
|
|
66
|
-
if (minimumVersion && (
|
|
64
|
+
if (minimumVersion && compareVersions(currentVersion, minimumVersion) < 0) return {
|
|
67
65
|
...versions,
|
|
68
66
|
requiresUpdate: true,
|
|
69
67
|
isForced: true
|
|
70
68
|
};
|
|
71
|
-
if ((
|
|
69
|
+
if (compareVersions(currentVersion, latestVersion) !== 0) return {
|
|
72
70
|
...versions,
|
|
73
71
|
requiresUpdate: true
|
|
74
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":["MedipassWebSdk"],"sources":["../../src/services/version.ts"],"sourcesContent":["import compareVersions from 'compare-versions';\nimport _get from 'lodash/get';\nimport MedipassWebSdk from '../index';\n\n/**\n * Get current app version\n */\nexport const getCurrentAppVersion = (): string => _get(MedipassWebSdk, 'appVersion');\n\n/**\n * Set current app version\n */\nexport const setCurrentAppVersion = (version: string | null | undefined): void => {\n MedipassWebSdk.appVersion = version;\n};\n\n/**\n * Fetch latest app version\n */\nexport const fetchLatestAppVersion = async (): Promise<string | null | undefined> => {\n try {\n const res = await fetch('/manifest.json');\n if (!res.ok) {\n if (res.status === 404) {\n return null;\n }\n throw new Error(`HTTP error: ${res.status}`);\n }\n const data = await res.json();\n return _get(data, 'app_version');\n } catch (err) {\n // Handle network errors that might not have a status\n if (err instanceof Error && err.message.includes('404')) {\n return null;\n }\n throw err;\n }\n};\n\n/**\n * Fetch minimum app version\n */\n// @ts-expect-error TS(1064): The return type of an async function or method mus... Remove this comment to see the full error message\nexport const fetchMinimumAppVerson = async (): string | null | undefined => {\n try {\n const res = await MedipassWebSdk.applications.getSelfApplication();\n return _get(res, 'minVersion');\n } catch (err) {\n throw err;\n }\n};\n\n/**\n * Check app version\n * Checks if the app is up-to-date\n */\n// @ts-expect-error TS(1064): The return type of an async function or method mus... Remove this comment to see the full error message\nexport const checkAppVersion = async (): Record<string, any> => {\n const currentVersion = getCurrentAppVersion();\n const latestVersion = await fetchLatestAppVersion();\n const minimumVersion = await fetchMinimumAppVerson();\n\n if (!latestVersion || !currentVersion) {\n return {};\n }\n\n const versions = {\n currentVersion,\n latestVersion,\n minimumVersion\n };\n\n if (minimumVersion && compareVersions(currentVersion, minimumVersion) < 0) {\n return { ...versions, requiresUpdate: true, isForced: true };\n }\n\n if (compareVersions(currentVersion, latestVersion) !== 0) {\n return { ...versions, requiresUpdate: true };\n }\n\n return { ...versions, requiresUpdate: false };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"version.js","names":["MedipassWebSdk"],"sources":["../../src/services/version.ts"],"sourcesContent":["import compareVersions from 'compare-versions';\nimport _get from 'lodash/get';\nimport MedipassWebSdk from '../index';\n\n/**\n * Get current app version\n */\nexport const getCurrentAppVersion = (): string => _get(MedipassWebSdk, 'appVersion');\n\n/**\n * Set current app version\n */\nexport const setCurrentAppVersion = (version: string | null | undefined): void => {\n MedipassWebSdk.appVersion = version;\n};\n\n/**\n * Fetch latest app version\n */\nexport const fetchLatestAppVersion = async (): Promise<string | null | undefined> => {\n try {\n const res = await fetch('/manifest.json');\n if (!res.ok) {\n if (res.status === 404) {\n return null;\n }\n throw new Error(`HTTP error: ${res.status}`);\n }\n const data = await res.json();\n return _get(data, 'app_version');\n } catch (err) {\n // Handle network errors that might not have a status\n if (err instanceof Error && err.message.includes('404')) {\n return null;\n }\n throw err;\n }\n};\n\n/**\n * Fetch minimum app version\n */\n// @ts-expect-error TS(1064): The return type of an async function or method mus... Remove this comment to see the full error message\nexport const fetchMinimumAppVerson = async (): string | null | undefined => {\n try {\n const res = await MedipassWebSdk.applications.getSelfApplication();\n return _get(res, 'minVersion');\n } catch (err) {\n throw err;\n }\n};\n\n/**\n * Check app version\n * Checks if the app is up-to-date\n */\n// @ts-expect-error TS(1064): The return type of an async function or method mus... Remove this comment to see the full error message\nexport const checkAppVersion = async (): Record<string, any> => {\n const currentVersion = getCurrentAppVersion();\n const latestVersion = await fetchLatestAppVersion();\n const minimumVersion = await fetchMinimumAppVerson();\n\n if (!latestVersion || !currentVersion) {\n return {};\n }\n\n const versions = {\n currentVersion,\n latestVersion,\n minimumVersion\n };\n\n if (minimumVersion && compareVersions(currentVersion, minimumVersion) < 0) {\n return { ...versions, requiresUpdate: true, isForced: true };\n }\n\n if (compareVersions(currentVersion, latestVersion) !== 0) {\n return { ...versions, requiresUpdate: true };\n }\n\n return { ...versions, requiresUpdate: false };\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAOA,MAAa,6BAAqC,KAAKA,aAAgB,aAAa;;;;AAKpF,MAAa,wBAAwB,YAA6C;AAChF,aAAe,aAAa;;;;;AAM9B,MAAa,wBAAwB,YAAgD;AACnF,KAAI;EACF,MAAM,MAAM,MAAM,MAAM,iBAAiB;AACzC,MAAI,CAAC,IAAI,IAAI;AACX,OAAI,IAAI,WAAW,IACjB,QAAO;AAET,SAAM,IAAI,MAAM,eAAe,IAAI,SAAS;;AAG9C,SAAO,KADM,MAAM,IAAI,MAAM,EACX,cAAc;UACzB,KAAK;AAEZ,MAAI,eAAe,SAAS,IAAI,QAAQ,SAAS,MAAM,CACrD,QAAO;AAET,QAAM;;;;;;AAQV,MAAa,wBAAwB,YAAuC;AAC1E,KAAI;AAEF,SAAO,KADK,MAAMA,YAAe,aAAa,oBAAoB,EACjD,aAAa;UACvB,KAAK;AACZ,QAAM;;;;;;;AASV,MAAa,kBAAkB,YAAiC;CAC9D,MAAM,iBAAiB,sBAAsB;CAC7C,MAAM,gBAAgB,MAAM,uBAAuB;CACnD,MAAM,iBAAiB,MAAM,uBAAuB;AAEpD,KAAI,CAAC,iBAAiB,CAAC,eACrB,QAAO,EAAE;CAGX,MAAM,WAAW;EACf;EACA;EACA;EACD;AAED,KAAI,kBAAkB,gBAAgB,gBAAgB,eAAe,GAAG,EACtE,QAAO;EAAE,GAAG;EAAU,gBAAgB;EAAM,UAAU;EAAM;AAG9D,KAAI,gBAAgB,gBAAgB,cAAc,KAAK,EACrD,QAAO;EAAE,GAAG;EAAU,gBAAgB;EAAM;AAG9C,QAAO;EAAE,GAAG;EAAU,gBAAgB;EAAO"}
|